GenericDialog.java revision a23343e9e4e0b555b1bcfa99a7455e0e28117a3d
/*
* 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-2009 Sun Microsystems, Inc.
* Portions Copyright 2014-2015 ForgeRock AS
*/
/**
* The generic dialog of the Control Panel. It contains a StatusGenericPanel.
*/
public class GenericDialog extends JDialog
{
private static final long serialVersionUID = -2643144936460484112L;
private static final Color buttonPanelBackground =
/** The close button. */
protected JButton closeButton;
private JButton cancelButton;
/** The panel contained in the dialog. */
protected StatusGenericPanel panel;
private Component lastComponentWithFocus;
/** The different combinations of buttons that the dialog can have. */
public enum ButtonType
{
/** The dialog contains OK and CANCEL buttons. */
/** The dialog contains a OK button. */
OK,
/** The dialog contains a CLOSE button. */
/** The dialog has no buttons. */
}
/**
* Constructor of the dialog.
* @param parentFrame the parent frame of the dialog.
* @param panel the panel contained in this dialog.
*/
{
super(parentFrame);
if (panel.requiresBorder())
{
}
{
}
setResizable(true);
if (panel.requiresScroll())
{
}
else
{
}
{
}
{
/** {@inheritDoc} */
{
setVisible(false);
}
};
{
/** {@inheritDoc} */
{
}
};
addWindowListener(new WindowAdapter() {
/** {@inheritDoc} */
public void windowClosing(WindowEvent e) {
}
});
pack();
if (!SwingUtilities.isEventDispatchThread())
{
}
}
/**
* Method used to add a focus listeners to all the components in the panel.
* This is done to recover the focus on an item when the dialog is closed
* and then opened again.
* @param focusListener the focus listener.
* @param container the container where the components are layed out.
*/
{
{
if ((comp instanceof AbstractButton) ||
(comp instanceof JTextComponent) ||
{
}
{
}
}
}
/** {@inheritDoc} */
public void setVisible(boolean visible)
{
{
}
{
if (lastComponentWithFocus == null)
{
}
}
updateTitle();
super.setVisible(visible);
}
/**
* Sets the enable state of the OK button.
* @param enable whether the OK button must be enabled or not.
*/
public void setEnabledOK(boolean enable)
{
}
/**
* Sets the enable state of the Cancel button.
* @param enable whether the Cancel button must be enabled or not.
*/
public void setEnabledCancel(boolean enable)
{
}
/**
* Sets the enable state of the Close button.
* @param enable whether the Close button must be enabled or not.
*/
public void setEnabledClose(boolean enable)
{
}
/** Updates the title of the dialog using the title of the panel. */
public void updateTitle()
{
{
}
}
{
}
{
buttonsPanel.setOpaque(true);
{
{
{
}
});
cancelButton.setOpaque(false);
{
{
}
});
}
{
{
{
}
});
}
{
closeButton.setOpaque(false);
{
{
}
});
}
return buttonsPanel;
}
/**
* Updates the default button of the dialog, depending on the type of
* generic panel that it contains.
* @param panel the generic panel contained in this dialog.
*/
{
{
}
{
}
{
}
}
}