/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
* Portions Copyright 2011 ForgeRock AS
*/
/**
* The pane that is displayed when the user clicks on 'Browse Entries...'.
* It contains its own menu bar with all the actions to edit the entries.
*
*/
{
private boolean ignoreTreeSelectionEvents = false;
private boolean forceRefreshWhenOpening;
/**
* {@inheritDoc}
*/
{
{
}
return menuBar;
}
/**
* {@inheritDoc}
*/
{
return INFO_CTRL_PANEL_MANAGE_ENTRIES_TITLE.get();
}
/**
* {@inheritDoc}
*/
{
}
/**
* {@inheritDoc}
*/
{
super.createBrowserController(info);
}
/**
* {@inheritDoc}
*/
public void okClicked()
{
}
/**
* {@inheritDoc}
*/
{
super.toBeDisplayed(visible);
boolean isAuthenticated = false;
{
}
{
}
if (!visible)
{
}
}
/**
* {@inheritDoc}
*/
{
JComponent p = createTreePane();
entryPane = new LDAPEntryPanel();
// Create a split pane with the two scroll panes in it.
addPopupMenu();
return pane;
}
/**
* Adds the tree selection listener.
* @param tree the tree to which the listeners are added.
*/
{
{
/**
* {@inheritDoc}
*/
{
{
return;
}
if (entryPane.mustCheckUnsavedChanges())
{
ignoreTreeSelectionEvents = true;
switch (entryPane.checkUnsavedChanges())
{
case DO_NOT_SAVE:
break;
case SAVE:
break;
case CANCEL:
ignoreTreeSelectionEvents = false;
return;
}
{
}
else
{
}
ignoreTreeSelectionEvents = false;
}
{
}
// Update menu items
boolean enableDelete = false;
{
enableDelete = true;
{
if (!enableDelete)
{
break;
}
}
}
boolean enableDuplicateEntry = enableCopyDN;
boolean enableAddToGroup = enableDelete;
if (enableResetPassword)
{
}
// Assume that if we cannot delete, we cannot create a new path
}
};
}
/**
* Adds a drag and drop listener to a tree.
* @param tree the tree to which the listener is added.
*/
{
{
/**
* {@inheritDoc}
*/
{
}
/**
* {@inheritDoc}
*/
{
{
}
{
}
else
{
}
}
/**
* {@inheritDoc}
*/
{
}
/**
* {@inheritDoc}
*/
{
}
/**
* {@inheritDoc}
*/
{
}
};
{
/**
* {@inheritDoc}
*/
public void dragGestureRecognized(DragGestureEvent e)
{
//Get the selected node
{
{
}
//Select the appropriate cursor;
// begin the drag
}
}
};
);
}
/**
* {@inheritDoc}
*/
{
}
/**
* {@inheritDoc}
*/
{
super.configurationChanged(ev);
}
/**
* Returns <CODE>true</CODE> if the provided object classes allow (or require
* the userPassword attribute).
* @param ocs the object classes.
* @return <CODE>true</CODE> if the provided object classes allow (or require
* the userPassword attribute) and <CODE>false</CODE> otherwise.
*/
{
boolean hasUserPassword = false;
{
{
{
{
hasUserPassword = true;
break;
}
}
}
}
return hasUserPassword;
}
/**
* Updates the menus with the provided server descriptor.
* @param desc the server descriptor.
*/
{
}
/**
* Updates the contents of the right pane with the selected tree paths.
* @param paths the selected tree paths.
*/
{
{
}
{
}
{
if (controller.getFollowReferrals() &&
{
// We are in the case where we are following referrals but the referral
// could not be resolved. Display an error.
}
{
}
else
{
}
{
try
{
// Required to update the browser controller properly if the entry is
// deleted.
}
catch (Throwable t)
{
if (!isInterruptedException(t))
{
}
}
}
}
else
{
{
}
else
{
}
}
}
private void stopCurrentReader()
{
if (entryReader != null)
{
entryReader.setNotifyListeners(false);
}
}
/**
* Starts the provider reader.
* @param reader the LDAPEntryReader.
*/
{
{
{
Throwable t;
public void run()
{
while (true)
{
try
{
synchronized (entryReaderThread)
{
{
}
}
t = null;
try
{
}
{
t = th;
}
{
public void run()
{
if (reader == entryReader)
{
entryReader = null;
}
}
});
}
catch (Throwable t)
{
entryReader = null;
}
}
}
});
}
synchronized (entryReaderThread)
{
}
}
/**
* Adds a pop up menu to the tree.
*
*/
private void addPopupMenu()
{
popup = new JPopupMenu();
{
/**
* {@inheritDoc}
*/
{
newUser();
}
});
popupNewUserMenuItem.setEnabled(false);
{
/**
* {@inheritDoc}
*/
{
newGroup();
}
});
popupNewGroupMenuItem.setEnabled(false);
{
/**
* {@inheritDoc}
*/
{
}
});
popupNewOUMenuItem.setEnabled(false);
{
/**
* {@inheritDoc}
*/
{
}
});
{
/**
* {@inheritDoc}
*/
{
newDomain();
}
});
popupNewDomainMenuItem.setEnabled(false);
{
/**
* {@inheritDoc}
*/
{
}
});
{
/**
* {@inheritDoc}
*/
{
}
});
{
/**
* {@inheritDoc}
*/
{
addToGroup();
}
});
popupAddToGroupMenuItem.setEnabled(false);
{
/**
* {@inheritDoc}
*/
{
}
});
{
/**
* {@inheritDoc}
*/
{
copyDN();
}
});
popupCopyDNMenuItem.setEnabled(false);
{
/**
* {@inheritDoc}
*/
{
}
});
popupDeleteMenuItem.setEnabled(false);
}
private void resetUserPassword()
{
if (resetUserPasswordDlg == null)
{
Utilities.getParentDialog(this));
}
{
resetUserPasswordDlg.setVisible(true);
}
}
private void deleteBaseDN()
{
if (deleteBaseDNDlg == null)
{
Utilities.getParentDialog(this));
}
deleteBaseDNDlg.setVisible(true);
}
private void deleteBackend()
{
if (deleteBackendDlg == null)
{
Utilities.getParentDialog(this));
}
deleteBackendDlg.setVisible(true);
}
private void newUser()
{
if (newUserDlg == null)
{
newUserPanel = new NewUserPanel();
Utilities.getParentDialog(this));
}
{
}
newUserDlg.setVisible(true);
}
private void newGroup()
{
if (newGroupDlg == null)
{
newGroupPanel = new NewGroupPanel();
/* First argument: Component to associate the target with
* Second argument: DropTargetListener
*/
Utilities.getParentDialog(this));
}
{
}
newGroupDlg.setVisible(true);
}
private void newOrganizationalUnit()
{
{
newOUPanel = new NewOrganizationalUnitPanel();
Utilities.getParentDialog(this));
}
{
}
newOUDlg.setVisible(true);
}
private void newOrganization()
{
if (newOrganizationDlg == null)
{
newOrganizationPanel = new NewOrganizationPanel();
Utilities.getParentDialog(this));
}
{
}
newOrganizationDlg.setVisible(true);
}
private void newDomain()
{
if (newDomainDlg == null)
{
newDomainPanel = new NewDomainPanel();
Utilities.getParentDialog(this));
}
{
}
newDomainDlg.setVisible(true);
}
private void newEntryFromLDIF()
{
if (newEntryFromLDIFDlg == null)
{
Utilities.getParentDialog(this));
}
{
}
newEntryFromLDIFDlg.setVisible(true);
}
private void duplicateEntry()
{
if (duplicateEntryDlg == null)
{
if (duplicateEntryPanel == null)
{
duplicateEntryPanel = new DuplicateEntryPanel();
}
Utilities.getParentDialog(this));
}
{
}
duplicateEntryDlg.setVisible(true);
}
private void deleteClicked()
{
{
Utilities.getParentDialog(this),
{
}
{
{
null,
dlg);
dlg.setVisible(true);
}
}
}
}
private void copyDN()
{
{
/**
* {@inheritDoc}
*/
//do nothing
}
};
{
{
{
}
}
}
}
private void addToGroup()
{
{
{
try
{
}
catch (OpenDsException ode)
{
throw new RuntimeException(
ode);
}
}
if (addToGroupDlg == null)
{
addToGroupPanel = new AddToGroupPanel();
Utilities.getParentDialog(this));
}
addToGroupDlg.setVisible(true);
}
}
private void newWindow()
{
panel.setDisposeOnClose(true);
frame.setVisible(true);
}
/**
* The specific menu bar of this panel.
*
*/
{
/**
* Constructor.
* @param info the control panel info.
*/
{
super(info);
add(createFileMenuBar());
add(createViewMenuBar());
add(createHelpMenuBar());
}
/**
* Creates the file menu bar.
* @return the file menu bar.
*/
{
{
/**
* {@inheritDoc}
*/
{
newWindow();
}
});
{
/**
* {@inheritDoc}
*/
{
closeClicked();
}
});
return menu;
}
/**
* Creates the view menu bar.
* @return the view menu bar.
*/
{
};
};
final JRadioButtonMenuItem[] menus =
{
}
{
private boolean ignoreEvents;
/**
* {@inheritDoc}
*/
{
if (ignoreEvents)
{
return;
}
{
if (menus[i].isSelected())
{
ignoreEvents = true;
lastSelected.setSelected(true);
if (entryPane.mustCheckUnsavedChanges())
{
switch (entryPane.checkUnsavedChanges())
{
case DO_NOT_SAVE:
break;
case SAVE:
break;
case CANCEL:
ignoreEvents = false;
return;
}
}
lastSelected = menus[i];
menus[i].setSelected(true);
ignoreEvents = false;
break;
}
}
}
};
{
}
// Add the referral and sort data menus
final JCheckBoxMenuItem sortUserData =
{
{
try
{
}
catch (NamingException ne)
{
// Bug
}
}
});
{
{
try
{
}
catch (NamingException ne)
{
// Bug
}
}
});
// Add the refresh menu
{
{
}
});
return menu;
}
/**
* Creates the entries menu bar.
* @return the entries menu bar.
*/
{
{
/**
* {@inheritDoc}
*/
{
newUser();
}
});
newUserMenuItem.setEnabled(false);
{
/**
* {@inheritDoc}
*/
{
newGroup();
}
});
newGroupMenuItem.setEnabled(false);
{
/**
* {@inheritDoc}
*/
{
}
});
newOUMenuItem.setEnabled(false);
{
/**
* {@inheritDoc}
*/
{
}
});
newOrganizationMenuItem.setEnabled(false);
{
/**
* {@inheritDoc}
*/
{
newDomain();
}
});
newDomainMenuItem.setEnabled(false);
{
/**
* {@inheritDoc}
*/
{
}
});
{
/**
* {@inheritDoc}
*/
{
}
});
resetPasswordMenuItem.setEnabled(false);
{
/**
* {@inheritDoc}
*/
{
addToGroup();
}
});
addToGroupMenuItem.setEnabled(false);
{
/**
* {@inheritDoc}
*/
{
}
});
duplicateEntryMenuItem.setEnabled(false);
{
/**
* {@inheritDoc}
*/
{
copyDN();
}
});
copyDNMenuItem.setEnabled(false);
{
/**
* {@inheritDoc}
*/
{
}
});
deleteMenuItem.setEnabled(false);
{
/**
* {@inheritDoc}
*/
{
deleteBaseDN();
}
});
deleteBaseDNMenuItem.setEnabled(false);
{
/**
* {@inheritDoc}
*/
{
}
});
deleteBackendMenuItem.setEnabled(false);
return menu;
}
}
{
boolean isInterruptedException = false;
t instanceof InterruptedNamingException;
while ((t != null) && !isInterruptedException)
{
t = t.getCause();
t instanceof InterruptedNamingException;
}
return isInterruptedException;
}
private void refreshClicked()
{
// Refresh the contents of the selected entry.
{
if (entryPane.mustCheckUnsavedChanges())
{
switch (entryPane.checkUnsavedChanges())
{
case DO_NOT_SAVE:
break;
case SAVE:
break;
case CANCEL:
// Do nothing.
return;
}
}
}
}
}