EncListDialog.java revision 4d0eb50e691de4c20b1dd9976ad6839fede8a42d
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* This class creates a dialog box that helps the user select encryption types
* with some mouse clicks. The dialog box need only be created
* once. The Ok and Cancel buttons merely call setVisible with an
* argument of false.
*/
// The layout will consist of 2 panels:
// topPanel contains the dynamic list of encryption type check boxes.
// bottomPanel contains the buttons ok, clear, cancel, and help.
// The two panels are separated by a LineSeparator.
public class EncListDialog extends Dialog {
private boolean save;
private int i;
private Panel bottomPanel;
// For I18N
private static ResourceBundle rb =
private static ResourceBundle hrb =
/*
* Constructor that lays out the components and sets the different
* event handlers.
*/
true);
setLayout(new GridBagLayout());
addButtons();
setResizable(true);
addWindowListener(new DCWindowListener());
}
/*
* Adds the check boxes only
*/
private void addCheckboxes() {
}
}
// Adds all the buttons
private void addButtons() {
bottomPanel = new Panel();
}
/*
* Closes (hides) the dialog box when the user is done
* @param save true if the box is being dismissed by clicking on
* "ok" and the user wants to retain the modified value, false
* otherwise.
*/
private void encListDialogClose(boolean save) {
setVisible(false);
}
/*
* Checks if the user requested that the value in this
* EncListDialog be used e.g., by clicking on "Ok" instead of
* "Cancel."
* @return true if the user wants to save the value in the
* EncListDialog, false otherwise.
*/
public boolean isSaved() {
return save;
}
/*
* Sets the current enc list for the principal during modification.
* @param enc types of current principal.
*/
return;
== 0) {
break;
}
}
}
}
// ***********************************************
// I N N E R C L A S S E S F O L L O W
// ***********************************************
/*
* Listener for an annoying work around in deselection of a check box
* in case the user doesn't want any items in a grouped list.
*/
private class CBListener implements ItemListener {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == e.DESELECTED) {
c.setState(false);
} else if (e.getStateChange() == e.SELECTED) {
if (c == cb[i]) {
== true) {
}
}
break;
}
}
c.setState(true);
// else what else is there
}
}
}
/*
* Listener for closing the dialog box through the window close
* menu.
*/
private class DCWindowListener extends WindowAdapter {
public void windowClosing(WindowEvent e) {
encListDialogClose(false);
}
}
/*
* Listener for all the buttons. The listener is shared for the sake
* of reducing the number of overall listeners.
* TBD: I18N the help
*/
private class DCButtonListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
EncListDialog.this.encListDialogClose(true);
EncListDialog.this.encListDialogClose(false);
}
hd.setVisible(true);
else {
hd = new HelpDialog(
EncListDialog.this.parent,
"Help for Encryption Type Dialog"),
false);
hd.setVisible(true);
"EncryptionTypeDialogHelp"));
}
}
} // actionPerformed
}
/*
* The string representation of the dialog box.
* @return a String which contians the encryption type list
*/
" ");
}
return encList;
}
/*
* Call rb.getString(), but catch exception and return English
* key so that small spelling errors don't cripple the GUI
*/
}
try {
return res;
} catch (MissingResourceException e) {
", using English.");
return key;
}
}
}