StatusGenericPanel.java revision 8196da2152209c8c628611aeeb4adae32079921e
/*
* 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 2013-2015 ForgeRock AS.
*/
/**
* An abstract class that contains a number of methods that are shared by all
* the inheriting classes. In general a StatusGenericPanel is contained in a
* GenericDialog and specifies the kind of buttons that this dialog has. The
* StatusGenericPanel is also notified when the dialog is displayed (through the
* toBeDisplayed method)
*/
{
private static final long serialVersionUID = -9123358652232556732L;
/**
* The string to be used as combo separator.
*/
/**
* The not applicable message.
*/
private ControlPanelInfo info;
private final boolean enableClose = true;
private boolean enableCancel = true;
private boolean enableOK = true;
private boolean disposeOnClose;
private final JEditorPane message;
private final CardLayout cardLayout;
/** The error pane. */
protected JEditorPane errorPane;
/** The last displayed message in the error pane. */
private String lastDisplayedError;
private boolean sizeSet;
private boolean focusSet;
/**
* Returns the title that will be used as title of the dialog.
*
* @return the title that will be used as title of the dialog.
*/
public abstract LocalizableMessage getTitle();
/**
* Returns the buttons that the dialog where this panel is contained should
* display.
*
* @return the buttons that the dialog where this panel is contained should
* display.
*/
{
}
/**
* Returns the component that should get the focus when the dialog that
* contains this panel is displayed.
*
* @return the component that should get the focus.
*/
public abstract Component getPreferredFocusComponent();
/**
* Returns <CODE>true</CODE> if this panel requires some bordering (in general
* an EmptyBorder with some insets) and <CODE>false</CODE> otherwise.
*
* @return <CODE>true</CODE> if this panel requires some bordering (in general
* an EmptyBorder with some insets) and <CODE>false</CODE> otherwise.
*/
public boolean requiresBorder()
{
return true;
}
/**
* Returns the menu bar that the panel might have. Returns <CODE>null</CODE>
* if the panel has no menu bar associated.
*
* @return the menu bar that the panel might have.
*/
public JMenuBar getMenuBar()
{
return null;
}
/**
* This method is called to indicate that the configuration changes should be
* called in the background. In the case of panels which require some time to
* be updated with the new configuration this method returns <CODE>true</CODE>
* and the operation will be performed in the background while a message of
* type 'Loading...' is displayed on the panel.
*
* @return <CODE>true</CODE> if changes should be loaded in the background and
* <CODE>false</CODE> otherwise.
*/
public boolean callConfigurationChangedInBackground()
{
return false;
}
/**
* The panel is notified that the dialog is going to be visible or invisible.
*
* @param visible
* whether is going to be visible or not.
*/
public void toBeDisplayed(final boolean visible)
{
}
/**
* Tells whether this panel should be contained in a scroll pane or not.
*
* @return <CODE>true</CODE> if this panel should be contained in a scroll
* pane and <CODE>false</CODE> otherwise.
*/
public boolean requiresScroll()
{
return true;
}
/**
* Constructor.
*/
protected StatusGenericPanel()
{
super(new GridBagLayout());
cardLayout = new CardLayout();
messagePanel.setOpaque(false);
}
/**
* The components are not added directly to the panel but to the main panel.
* This is done to be able to display a message that takes the whole panel (of
* type 'Loading...') when we are doing long operations.
*
* @param comp
* the Component to be added.
* @param constraints
* the constraints.
*/
{
}
/**
* Adds a bottom glue to the main panel with the provided constraints.
*
* @param gbc
* the constraints.
*/
{
}
/**
* Returns a label with text 'Required Field' and an icon (used as legend in
* some panels).
*
* @return a label with text 'Required Field' and an icon (used as legend in
* some panels).
*/
protected JLabel createRequiredLabel()
{
JLabel requiredLabel = Utilities.createInlineHelpLabel(INFO_CTRL_PANEL_INDICATES_REQUIRED_FIELD_LABEL.get());
return requiredLabel;
}
/**
* Creates and adds an error pane. Is up to the caller to set the proper
* gridheight, gridwidth, gridx and gridy on the provided GridBagConstraints.
*
* @param baseGbc
* the GridBagConstraints to be used.
*/
{
addErrorPane(this, baseGbc);
}
/**
* Adds an error pane to the provided container. Is up to the caller to set
* the proper gridheight, gridwidth, gridx and gridy on the provided
* GridBagConstraints.
*
* @param baseGbc
* the GridBagConstraints to be used.
* @param p
* the container.
*/
{
if (requiresBorder())
{
}
else
{
}
}
/**
* Creates the error pane.
*/
protected void createErrorPane()
{
errorPane.setEditable(false);
errorPane.setVisible(false);
{
{
{
authenticate();
}
{
startServer();
}
}
});
}
/**
* Commodity method used to add lines, where each line contains a label, a
* component and an inline help label.
*
* @param labels
* the labels.
* @param comps
* the components.
* @param inlineHelp
* the inline help labels.
* @param panel
* the panel where we will add the lines.
* @param gbc
* the grid bag constraints.
*/
protected void add(final JLabel[] labels, final Component[] comps, final JLabel[] inlineHelp, final Container panel,
final GridBagConstraints gbc)
{
int i = 0;
{
{
}
if (inlineHelp[i] != null)
{
}
i++;
}
}
/**
* Enables the OK button in the parent dialog.
*
* @param enable
* whether to enable or disable the button.
*/
protected void setEnabledOK(final boolean enable)
{
if (w instanceof GenericDialog)
{
}
else if (w instanceof GenericFrame)
{
}
}
/**
* Enables the Cancel button in the parent dialog.
*
* @param enable
* whether to enable or disable the button.
*/
protected void setEnabledCancel(final boolean enable)
{
if (w instanceof GenericDialog)
{
}
else if (w instanceof GenericFrame)
{
}
}
/**
* Updates the font type and color of the component to be invalid and primary.
*
* @param comp
* the component to update.
*/
{
}
/**
* Updates the font type and color of the component to be valid and primary.
*
* @param comp
* the component to update.
*/
{
}
/**
* Updates the font type and color of the component to be invalid and
* secondary.
*
* @param comp
* the component to update.
*/
{
}
/**
* Updates the font type and color of the component to be valid and secondary.
*
* @param comp
* the component to update.
*/
{
}
/**
* Packs the parent dialog.
*/
protected void packParentDialog()
{
{
invalidate();
dlg.invalidate();
if (!SwingUtilities.isEventDispatchThread())
{
}
}
}
/**
* Notification that the ok button has been clicked, the panel is in charge of
* doing whatever is required (close the dialog, launch a task, etc.).
*/
public abstract void okClicked();
/**
* Adds a configuration element created listener.
*
* @param listener
* the listener.
*/
public void addConfigurationElementCreatedListener(final ConfigurationElementCreatedListener listener)
{
}
/**
* Removes a configuration element created listener.
*
* @param listener
* the listener.
*/
public void removeConfigurationElementCreatedListener(final ConfigurationElementCreatedListener listener)
{
}
/**
* Returns the list of configuration listeners.
*
* @return the list of configuration listeners.
*/
{
return confListeners;
}
/**
* Notification that cancel was clicked, the panel is in charge of doing
* whatever is required (close the dialog, etc.).
*/
public void cancelClicked()
{
// Default implementation
if (isDisposeOnClose())
{
}
}
/**
* Whether the dialog should be disposed when the user closes it.
*
* @return <CODE>true</CODE> if the dialog should be disposed when the user
* closes it or <CODE>true</CODE> otherwise.
*/
public boolean isDisposeOnClose()
{
return disposeOnClose;
}
/**
* Sets whether the dialog should be disposed when the user closes it or not.
*
* @param disposeOnClose
* <CODE>true</CODE> if the dialog should be disposed when the user
* closes it or <CODE>true</CODE> otherwise.
*/
public void setDisposeOnClose(final boolean disposeOnClose)
{
this.disposeOnClose = disposeOnClose;
}
/**
* Notification that close was clicked, the panel is in charge of doing
* whatever is required (close the dialog, etc.).
*/
public void closeClicked()
{
// Default implementation
if (isDisposeOnClose())
{
}
}
/**
* Displays a dialog with the provided list of error messages.
*
* @param errors
* the error messages.
*/
{
}
/**
* Displays a confirmation message.
*
* @param title
* @param msg
* the description of the confirmation.
* @return <CODE>true</CODE> if the user confirms and <CODE>false</CODE>
* otherwise.
*/
protected boolean displayConfirmationDialog(final LocalizableMessage title, final LocalizableMessage msg)
{
}
/**
* If the index must be rebuilt, asks the user for confirmation. If the user
* confirms launches a task that will rebuild the indexes. The progress will
* be displayed in the provided progress dialog.
*
* @param index
* the index.
* @param progressDialog
* the progress dialog.
*/
protected void rebuildIndexIfNecessary(final AbstractIndexDescriptor index, final ProgressDialog progressDialog)
{
progressDialog.setTaskIsOver(false);
boolean rebuildIndexes;
if (!isServerRunning())
{
}
else if (isLocal())
{
INFO_CTRL_PANEL_INDEX_REBUILD_REQUIRED_ONLINE_DETAILS.get(index.getName(), backendName, backendName));
}
else
{
rebuildIndexes = false;
}
if (rebuildIndexes)
{
{
}
{
}
{
if (progressDialog.isModal())
{
}
progressDialog.setVisible(true);
if (!progressDialog.isModal())
{
}
}
{
}
}
else
{
progressDialog.setTaskIsOver(true);
if (progressDialog.isVisible())
{
}
}
}
/**
* A class used to avoid the possibility a certain type of objects in a combo
* box. This is used for instance in the combo box that contains base DNs
* where the base DNs are separated in backends, so the combo box displays
* both the backends (~ categories) and base DNs (~ values) and we do not
* allow to select the backends (~ categories).
*/
protected class IgnoreItemListener implements ItemListener
{
private Object selectedItem;
/**
* Constructor.
*
* @param combo
* the combo box.
*/
{
if (isCategory(selectedItem))
{
selectedItem = null;
}
}
{
if (isCategory(o))
{
if (selectedItem == null)
{
}
if (selectedItem != null)
{
}
}
else if (COMBO_SEPARATOR.equals(o))
{
}
else
{
selectedItem = o;
}
}
{
{
{
return item;
}
}
return null;
}
}
/**
* Returns the HTML required to render an Authenticate button in HTML.
*
* @return the HTML required to render an Authenticate button in HTML.
*/
protected String getAuthenticateHTML()
{
}
/**
* Returns the HTML required to render an Start button in HTML.
*
* @return the HTML required to render an Start button in HTML.
*/
protected String getStartServerHTML()
{
}
/**
* status of the server.
*
* @param desc
* the Server Descriptor.
* @param details
* the message to be displayed if authentication has not been
* provided and the server is running.
*/
protected void updateErrorPaneAndOKButtonIfAuthRequired(
{
if (authenticationRequired(desc))
{
errorPane, title, ColorAndFontConstants.errorTitleFont, mb.toMessage(), ColorAndFontConstants.defaultFont);
{
public void run()
{
errorPane.setVisible(true);
setEnabledOK(false);
}
});
}
else
{
{
public void run()
{
errorPane.setVisible(false);
}
});
}
}
/**
* Returns <CODE>true</CODE> if the server is running and the user did not
* provide authentication and <CODE>false</CODE> otherwise.
*
* @param desc
* the server descriptor.
* @return <CODE>true</CODE> if the server is running and the user did not
* provide authentication and <CODE>false</CODE> otherwise.
*/
{
}
/**
* Updates the error panel depending on the status of the server.
*
* @param desc
* the Server Descriptor.
* @param details
* the message to be displayed if authentication has not been
* provided and the server is running.
*/
protected void updateErrorPaneIfAuthRequired(final ServerDescriptor desc, final LocalizableMessage details)
{
if (authenticationRequired(desc))
{
{
public void run()
{
errorPane.setVisible(true);
}
});
}
else
{
{
public void run()
{
errorPane.setVisible(false);
}
});
}
}
/**
* Updates the error panel depending on the status of the server. This method
* will display an error message in the error pane if the server is not
* running and another message if the server is running but authentication has
* not been provided.
*
* @param desc
* the Server Descriptor.
* @param detailsServerNotRunning
* the message to be displayed if the server is not running.
* @param authRequired
* the message to be displayed if authentication has not been
* provided and the server is running.
*/
{
{
errorPane, title, ColorAndFontConstants.errorTitleFont, mb.toMessage(), ColorAndFontConstants.defaultFont);
{
/** {@inheritDoc} */
public void run()
{
errorPane.setVisible(true);
}
});
}
else if (authenticationRequired(desc))
{
errorPane, title, ColorAndFontConstants.errorTitleFont, mb.toMessage(), ColorAndFontConstants.defaultFont);
{
public void run()
{
errorPane.setVisible(true);
}
});
}
else
{
{
public void run()
{
errorPane.setVisible(false);
}
});
}
}
/**
* error pane has already been updated.
*/
protected void checkOKButtonEnable()
{
}
/**
* Returns <CODE>true</CODE> if the provided object is a category object in a
* combo box.
*
* @param o
* the item in the combo box.
* @return <CODE>true</CODE> if the provided object is a category object in a
* combo box.
*/
protected boolean isCategory(final Object o)
{
if (o instanceof CategorizedComboBoxElement)
{
}
return false;
}
/**
* Returns the control panel info object.
*
* @return the control panel info object.
*/
public ControlPanelInfo getInfo()
{
return info;
}
/**
* Sets the control panel info object.
*
* @param info
* the control panel info object.
*/
{
{
{
this.info.removeConfigChangeListener(this);
}
this.info.addConfigChangeListener(this);
{
if (!sizeSet)
{
sizeSet = true;
}
// Do it outside the event thread if the panel requires it.
{
{
return null;
}
{
if (!focusSet)
{
focusSet = true;
{
}
}
}
};
}
{
}
}
}
/** Displays the main panel. */
protected void displayMainPanel()
{
}
/**
* Displays a message and hides the main panel.
*
* @param msg
* the message to be displayed.
*/
{
}
/**
* Displays an error message and hides the main panel.
*
* @param title
* the title of the message to be displayed.
* @param msg
* the message to be displayed.
*/
{
updateErrorPane(message, title, ColorAndFontConstants.errorTitleFont, msg, ColorAndFontConstants.defaultFont);
}
/**
* Updates the contents of an editor pane using the error format.
*
* @param pane
* the editor pane to be updated.
* @param title
* the title.
* @param titleFont
* the font to be used for the title.
* @param details
* the details message.
* @param detailsFont
* the font to be used for the details.
*/
protected void updateErrorPane(final JEditorPane pane, final LocalizableMessage title, final Font titleFont,
{
}
/**
* Updates the contents of an editor pane using the confirmation format.
*
* @param pane
* the editor pane to be updated.
* @param title
* the title.
* @param titleFont
* the font to be used for the title.
* @param details
* the details message.
* @param detailsFont
* the font to be used for the details.
*/
protected void updateConfirmationPane(final JEditorPane pane, final LocalizableMessage title, final Font titleFont,
{
}
/** The different types of error panels that are handled. */
private enum PanelType
{
/** The message in the panel is an error. */
/** The message in the panel is a confirmation. */
/** The message in the panel is an information message. */
/** The message in the panel is a warning message. */
}
/**
* Updates the contents of an editor pane using the provided format.
*
* @param pane
* the editor pane to be updated.
* @param title
* the title.
* @param titleFont
* the font to be used for the title.
* @param details
* the details message.
* @param detailsFont
* the font to be used for the details.
* @param type
* the type of panel.
*/
private void updatePane(final JEditorPane pane, final LocalizableMessage title, final Font titleFont,
{
{
switch (type)
{
case ERROR:
break;
default:
break;
}
pane.setPreferredSize(d);
}
{
{
public void run()
{
pane.invalidate();
}
});
}
}
PanelType type, LocalizableMessage title, Font titleFont, LocalizableMessage details, Font detailsFont)
{
switch (type)
{
case ERROR:
case CONFIRMATION:
case WARNING:
default:
}
}
/**
* Commodity method used to update the elements of a combo box that contains
* the different user backends. If no backends are found the combo box will be
* made invisible and a label will be made visible. This method does not
* update the label's text nor creates any layout.
*
* @param combo
* the combo to be updated.
* @param lNoBackendsFound
* the label that must be shown if no user backends are found.
* @param desc
* the server descriptor that contains the configuration.
*/
protected void updateSimpleBackendComboBoxModel(final JComboBox combo, final JLabel lNoBackendsFound,
final ServerDescriptor desc)
{
{
if (!backend.isConfigBackend())
{
}
}
{
public void run()
{
}
});
}
/**
* Method that says if a backend must be displayed. Only non-config backends
* are displayed.
*
* @param backend
* the backend.
* @return <CODE>true</CODE> if the backend must be displayed and
* <CODE>false</CODE> otherwise.
*/
{
return !backend.isConfigBackend();
}
/**
* Commodity method to update a combo box model with the backends of a server.
*
* @param model
* the combo box model to be updated.
* @param desc
* the server descriptor containing the configuration.
*/
protected void updateBaseDNComboBoxModel(final DefaultComboBoxModel model, final ServerDescriptor desc)
{
{
if (displayBackend(backend))
{
{
try
{
}
catch (Throwable t)
{
throw new RuntimeException("Unexpected error: " + t, t);
}
}
}
}
{
newElements.add(new CategorizedComboBoxElement(backendID, CategorizedComboBoxElement.Type.CATEGORY));
{
}
}
}
/**
* Updates a combo box model with a number of items.
*
* @param newElements
* the new items for the combo box model.
* @param model
* the combo box model to be updated.
*/
protected void updateComboBoxModel(final Collection<?> newElements, final DefaultComboBoxModel model)
{
}
/**
* Updates a combo box model with a number of items. The method assumes that
* is called outside the event thread.
*
* @param newElements
* the new items for the combo box model.
* @param model
* the combo box model to be updated.
* @param comparator
* the object that will be used to compare the objects in the model.
* If <CODE>null</CODE>, the equals method will be used.
*/
{
{
public void run()
{
}
});
}
/**
* Updates a map, so that the keys are the base DN where the indexes are
* defined and the values are a sorted set of indexes.
*
* @param desc
* the server descriptor containing the index configuration.
* @param hmIndexes
* the map to be updated.
*/
protected void updateIndexMap(
{
synchronized (hmIndexes)
{
{
{
{
try
{
}
catch (Throwable t)
{
throw new RuntimeException("Unexpected error: " + t, t);
}
SortedSet<AbstractIndexDescriptor> indexes = new TreeSet<AbstractIndexDescriptor>(backend.getIndexes());
if (currentIndexes != null)
{
{
}
}
else
{
}
}
}
}
{
{
}
}
}
}
/**
* Updates and addremove panel with the contents of the provided item. The
* selected item represents a base DN.
*
* @param hmIndexes
* the map that contains the indexes definitions as values and the
* base DNs as keys.
* @param selectedItem
* the selected item.
* @param addRemove
* the add remove panel to be updated.
*/
final CategorizedComboBoxElement selectedItem, final AddRemovePanel<AbstractIndexDescriptor> addRemove)
{
synchronized (hmIndexes)
{
if (selectedItem != null)
{
}
if (selectedDn != null)
{
{
boolean availableChanged = false;
boolean selectedChanged = false;
{
{
availableChanged = true;
}
}
if (availableChanged)
{
}
if (selectedChanged)
{
}
}
}
}
}
/**
* Returns <CODE>true</CODE> if the cancel button is enabled and
* <CODE>false</CODE> otherwise.
*
* @return <CODE>true</CODE> if the cancel button is enabled and
* <CODE>false</CODE> otherwise.
*/
public boolean isEnableCancel()
{
return enableCancel;
}
/**
* Returns <CODE>true</CODE> if the close button is enabled and
* <CODE>false</CODE> otherwise.
*
* @return <CODE>true</CODE> if the close button is enabled and
* <CODE>false</CODE> otherwise.
*/
public boolean isEnableClose()
{
return enableClose;
}
/**
* Returns <CODE>true</CODE> if the ok button is enabled and
* <CODE>false</CODE> otherwise.
*
* @return <CODE>true</CODE> if the ok button is enabled and
* <CODE>false</CODE> otherwise.
*/
public boolean isEnableOK()
{
return enableOK;
}
/**
* Returns <CODE>true</CODE> if the server is running and <CODE>false</CODE>
* otherwise.
*
* @return <CODE>true</CODE> if the server is running and <CODE>false</CODE>
* otherwise.
*/
protected boolean isServerRunning()
{
}
/**
* Returns <CODE>true</CODE> if the managed server is the local installation
* (where the control panel is installed) <CODE>false</CODE> otherwise.
*
* @return <CODE>true</CODE> if the managed server is the local installation
* (where the control panel is installed) <CODE>false</CODE>
* otherwise.
*/
protected boolean isLocal()
{
}
/**
* Launch an task.
*
* @param task
* the task to be launched.
* @param initialSummary
* the initial summary to be displayed in the progress dialog.
* @param successSummary
* the success summary to be displayed in the progress dialog if the
* task is successful.
* @param successDetail
* the success details to be displayed in the progress dialog if the
* task is successful.
* @param errorSummary
* the error summary to be displayed in the progress dialog if the
* task ended with error.
* @param errorDetail
* error details to be displayed in the progress dialog if the task
* ended with error.
* @param errorDetailCode
* error detail message to be displayed in the progress dialog if the
* task ended with error and we have an exit error code (for instance
* if the error occurred when launching a script we will have an
* error code).
* @param dialog
* the progress dialog.
*/
{
launchOperation(task, initialSummary, successSummary, successDetail, errorSummary, errorDetail, errorDetailCode,
dialog, true);
}
/**
* Launch an task.
*
* @param task
* the task to be launched.
* @param initialSummary
* the initial summary to be displayed in the progress dialog.
* @param successSummary
* the success summary to be displayed in the progress dialog if the
* task is successful.
* @param successDetail
* the success details to be displayed in the progress dialog if the
* task is successful.
* @param errorSummary
* the error summary to be displayed in the progress dialog if the
* task ended with error.
* @param errorDetail
* error details to be displayed in the progress dialog if the task
* ended with error.
* @param errorDetailCode
* error detail message to be displayed in the progress dialog if the
* task ended with error and we have an exit error code (for instance
* if the error occurred when launching a script we will have an
* error code).
* @param dialog
* the progress dialog.
* @param resetLogs
* whether the contents of the progress dialog should be reset or
* not.
*/
final boolean resetLogs)
{
launchOperation(task, initialSummary, successSummary, successDetail, errorSummary, errorDetail, errorDetailCode,
}
/**
* Launch an task.
*
* @param task
* the task to be launched.
* @param initialSummary
* the initial summary to be displayed in the progress dialog.
* @param successSummary
* the success summary to be displayed in the progress dialog if the
* task is successful.
* @param successDetail
* the success details to be displayed in the progress dialog if the
* task is successful.
* @param errorSummary
* the error summary to be displayed in the progress dialog if the
* task ended with error.
* @param errorDetail
* error details to be displayed in the progress dialog if the task
* ended with error.
* @param errorDetailCode
* error detail message to be displayed in the progress dialog if the
* task ended with error and we have an exit error code (for instance
* if the error occurred when launching a script we will have an
* error code).
* @param dialog
* the progress dialog.
* @param resetLogs
* whether the contents of the progress dialog should be reset or
* not.
* @param info
* the ControlPanelInfo.
*/
{
dialog.setTaskIsOver(false);
if (resetLogs)
{
}
{
dialog.appendProgressHtml(Utilities.applyFont(INFO_CTRL_PANEL_EQUIVALENT_COMMAND_LINE.get() + "<br><b>" + cmdLine
}
dialog.setEnabledClose(false);
{
{
if (task.regenerateDescriptor())
{
}
return task;
}
{
{
}
else
{
if (t == null)
{
t = task.getLastException();
}
if (t != null)
{
{
if (t instanceof OpenDsException)
{
}
else if (t.getMessage() != null)
{
sThrowable = t.getMessage();
}
else
{
sThrowable = t.toString();
}
}
else if (errorDetail != null)
{
}
else
{
summaryMsg = null;
}
}
{
}
else if (errorDetail != null)
{
}
else
{
summaryMsg = null;
}
}
if (summaryMsg != null)
{
}
dialog.setEnabledClose(true);
{
dialog.setTaskIsOver(true);
}
}
};
}
/**
* Checks that the provided string value is a valid integer and if it is not
* updates a list of error messages with an error.
*
* @param errors
* the list of error messages to be updated.
* @param stringValue
* the string value to analyze.
* @param minValue
* the minimum integer value accepted.
* @param maxValue
* the maximum integer value accepted.
* @param errMsg
* the error message to use to update the error list if the provided
* value is not valid.
* @return {@code true} if the provided string value is a valid integer and if
* it is not updates a list of error messages with an error.
*/
protected boolean checkIntValue(final Collection<LocalizableMessage> errors, final String stringValue,
{
try
{
{
return true;
}
}
catch (NumberFormatException ignored)
{
}
return false;
}
/**
* Starts the server. This method will launch a task and open a progress
* dialog that will start the server. This method must be called from the
* event thread.
*/
protected void startServer()
{
ProgressDialog progressDialog = new ProgressDialog(Utilities.createFrame(), Utilities.getParentDialog(this),
{
}
{
progressDialog.setVisible(true);
}
else
{
}
}
/**
* Stops the server. This method will launch a task and open a progress dialog
* that will stop the server. This method must be called from the event
* thread.
*/
protected void stopServer()
{
ProgressDialog progressDialog = new ProgressDialog(Utilities.createFrame(), Utilities.getParentDialog(this),
{
}
boolean confirmed = true;
{
}
{
progressDialog.setVisible(true);
}
{
}
}
/**
* Restarts the server. This method will launch a task and open a progress
* dialog that will restart the server. This method must be called from the
* event thread.
*/
protected void restartServer()
{
ProgressDialog progressDialog = new ProgressDialog(Utilities.createFrame(), Utilities.getParentDialog(this),
{
}
boolean confirmed = true;
{
}
{
progressDialog.setVisible(true);
}
{
}
}
/**
* Displays a dialog asking for authentication. This method must be called
* from the event thread.
*/
private void authenticate()
{
if (!getLoginDialog().isVisible())
{
getLoginDialog().setVisible(true);
}
getLoginDialog().toFront();
}
/**
* Returns the login dialog that is displayed when the method authenticate is
* called.
*
* @return the login dialog that is displayed when the method authenticate is
* called.
*/
protected GenericDialog getLoginDialog()
{
GenericDialog dialog = isLocal() ? getLocalServerLoginDialog(getInfo()) : getLocalOrRemoteDialog(getInfo());
return dialog;
}
/**
* Tells whether an entry exists or not. Actually it tells if we could find a
* given entry or not.
*
* @param dn
* the DN of the entry to look for.
* @return <CODE>true</CODE> if the entry with the provided DN could be found
* and <CODE>false</CODE> otherwise.
*/
{
boolean entryExists = false;
try
{
try
{
{
}
}
finally
{
}
}
catch (Throwable t)
{
}
return entryExists;
}
/**
* Tells whether a given entry exists and contains one of the specified object
* classes.
*
* @param dn
* the DN of the entry.
* @param objectClasses
* the object classes to check.
* @return <CODE>true</CODE> if the entry exists and contains one of the
* specified object classes and <CODE>false</CODE> otherwise.
*/
{
try
{
try
{
{
Set<String> values = ConnectionUtils.getValues(sr, ServerConstants.OBJECTCLASS_ATTRIBUTE_TYPE_NAME);
{
{
{
if (s.equalsIgnoreCase(objectClass))
{
return true;
}
}
}
}
}
}
finally
{
}
}
catch (Throwable t)
{
}
return false;
}
/**
* Returns the border to be used in the right panel of the dialog with a tree
* on the left (for instance the schema browser, entry browser and index
* browser).
*
* @return the border to be used in the right panel.
*/
protected Border getRightPanelBorder()
{
return ColorAndFontConstants.textAreaBorder;
}
/**
* Returns the monitoring value in a String form to be displayed to the user.
*
* @param attr
* the attribute to analyze.
* @param monitoringEntry
* the monitoring entry.
* @return the monitoring value in a String form to be displayed to the user.
*/
public static String getMonitoringValue(final MonitoringAttributes attr, final CustomSearchResult monitoringEntry)
{
}
/**
* Updates the monitoring information writing it to a list of labels.
*
* @param monitoringAttrs
* the monitoring operations whose information we want to update.
* @param monitoringLabels
* the monitoring labels to be updated.
* @param monitoringEntry
* the monitoring entry containing the information to be displayed.
*/
{
{
}
}
/**
* Returns the label to be used in panels (with ':') based on the definition
* of the monitoring attribute.
*
* @param attr
* the monitoring attribute.
* @return the label to be used in panels (with ':') based on the definition
* of the monitoring attribute.
*/
{
}
/**
* Returns the command-line arguments associated with the provided schedule.
*
* @param schedule
* the schedule.
* @return the command-line arguments associated with the provided schedule.
*/
{
{
case LAUNCH_LATER:
break;
case LAUNCH_PERIODICALLY:
break;
}
return args;
}
/**
* Checks whether the server is running or not and depending on the schedule
* updates the list of errors with the errors found.
*
* @param schedule
* the schedule.
* @param errors
* the list of errors.
* @param label
* the label to be marked as invalid if errors where encountered.
*/
protected void addScheduleErrors(final ScheduleType schedule, final Collection<LocalizableMessage> errors,
{
if (!isServerRunning())
{
{
}
{
}
}
}
{
}
/**
* Checks whether the provided superior object classes are compatible with the
* provided object class type. If not, the method updates the provided list of
* error messages with a message describing the incompatibility.
*
* @param objectClassSuperiors
* the superior object classes.
* @param objectClassType
* the object class type.
* @param errors
* the list of error messages.
*/
{
{
{
// Nothing to do.
}
{
}
}
if (!notCompatibleClasses.isEmpty())
{
{
}
{
}
{
}
}
}
}