878 } |
1010 } |
879 |
1011 |
880 /** |
1012 /** |
881 * The main window for the PolicyTool |
1013 * The main window for the PolicyTool |
882 */ |
1014 */ |
883 class ToolWindow extends Frame { |
1015 class ToolWindow extends JFrame { |
884 // use serialVersionUID from JDK 1.2.2 for interoperability |
1016 // use serialVersionUID from JDK 1.2.2 for interoperability |
885 private static final long serialVersionUID = 5682568601210376777L; |
1017 private static final long serialVersionUID = 5682568601210376777L; |
|
1018 |
|
1019 /* ESCAPE key */ |
|
1020 static final KeyStroke escKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); |
886 |
1021 |
887 /* external paddings */ |
1022 /* external paddings */ |
888 public static final Insets TOP_PADDING = new Insets(25,0,0,0); |
1023 public static final Insets TOP_PADDING = new Insets(25,0,0,0); |
889 public static final Insets BOTTOM_PADDING = new Insets(0,0,25,0); |
1024 public static final Insets BOTTOM_PADDING = new Insets(0,0,25,0); |
890 public static final Insets LITE_BOTTOM_PADDING = new Insets(0,0,10,0); |
1025 public static final Insets LITE_BOTTOM_PADDING = new Insets(0,0,10,0); |
891 public static final Insets LR_PADDING = new Insets(0,10,0,10); |
1026 public static final Insets LR_PADDING = new Insets(0,10,0,10); |
892 public static final Insets TOP_BOTTOM_PADDING = new Insets(15, 0, 15, 0); |
1027 public static final Insets TOP_BOTTOM_PADDING = new Insets(15, 0, 15, 0); |
893 public static final Insets L_TOP_BOTTOM_PADDING = new Insets(5,10,15,0); |
1028 public static final Insets L_TOP_BOTTOM_PADDING = new Insets(5,10,15,0); |
|
1029 public static final Insets LR_TOP_BOTTOM_PADDING = new Insets(15, 4, 15, 4); |
894 public static final Insets LR_BOTTOM_PADDING = new Insets(0,10,5,10); |
1030 public static final Insets LR_BOTTOM_PADDING = new Insets(0,10,5,10); |
895 public static final Insets L_BOTTOM_PADDING = new Insets(0,10,5,0); |
1031 public static final Insets L_BOTTOM_PADDING = new Insets(0,10,5,0); |
896 public static final Insets R_BOTTOM_PADDING = new Insets(0,0,5,10); |
1032 public static final Insets R_BOTTOM_PADDING = new Insets(0, 0, 25, 5); |
|
1033 public static final Insets R_PADDING = new Insets(0, 0, 0, 5); |
897 |
1034 |
898 /* buttons and menus */ |
1035 /* buttons and menus */ |
899 public static final String NEW_POLICY_FILE = |
1036 public static final String NEW_POLICY_FILE = "New"; |
900 PolicyTool.rb.getString("New"); |
1037 public static final String OPEN_POLICY_FILE = "Open"; |
901 public static final String OPEN_POLICY_FILE = |
1038 public static final String SAVE_POLICY_FILE = "Save"; |
902 PolicyTool.rb.getString("Open"); |
1039 public static final String SAVE_AS_POLICY_FILE = "Save.As"; |
903 public static final String SAVE_POLICY_FILE = |
1040 public static final String VIEW_WARNINGS = "View.Warning.Log"; |
904 PolicyTool.rb.getString("Save"); |
1041 public static final String QUIT = "Exit"; |
905 public static final String SAVE_AS_POLICY_FILE = |
1042 public static final String ADD_POLICY_ENTRY = "Add.Policy.Entry"; |
906 PolicyTool.rb.getString("Save.As"); |
1043 public static final String EDIT_POLICY_ENTRY = "Edit.Policy.Entry"; |
907 public static final String VIEW_WARNINGS = |
1044 public static final String REMOVE_POLICY_ENTRY = "Remove.Policy.Entry"; |
908 PolicyTool.rb.getString("View.Warning.Log"); |
1045 public static final String EDIT_KEYSTORE = "Edit"; |
909 public static final String QUIT = |
1046 public static final String ADD_PUBKEY_ALIAS = "Add.Public.Key.Alias"; |
910 PolicyTool.rb.getString("Exit"); |
1047 public static final String REMOVE_PUBKEY_ALIAS = "Remove.Public.Key.Alias"; |
911 public static final String ADD_POLICY_ENTRY = |
|
912 PolicyTool.rb.getString("Add.Policy.Entry"); |
|
913 public static final String EDIT_POLICY_ENTRY = |
|
914 PolicyTool.rb.getString("Edit.Policy.Entry"); |
|
915 public static final String REMOVE_POLICY_ENTRY = |
|
916 PolicyTool.rb.getString("Remove.Policy.Entry"); |
|
917 public static final String EDIT_KEYSTORE = |
|
918 PolicyTool.rb.getString("Edit"); |
|
919 public static final String ADD_PUBKEY_ALIAS = |
|
920 PolicyTool.rb.getString("Add.Public.Key.Alias"); |
|
921 public static final String REMOVE_PUBKEY_ALIAS = |
|
922 PolicyTool.rb.getString("Remove.Public.Key.Alias"); |
|
923 |
1048 |
924 /* gridbag index for components in the main window (MW) */ |
1049 /* gridbag index for components in the main window (MW) */ |
925 public static final int MW_FILENAME_LABEL = 0; |
1050 public static final int MW_FILENAME_LABEL = 0; |
926 public static final int MW_FILENAME_TEXTFIELD = 1; |
1051 public static final int MW_FILENAME_TEXTFIELD = 1; |
927 public static final int MW_PANEL = 2; |
1052 public static final int MW_PANEL = 2; |
928 public static final int MW_ADD_BUTTON = 0; |
1053 public static final int MW_ADD_BUTTON = 0; |
929 public static final int MW_EDIT_BUTTON = 1; |
1054 public static final int MW_EDIT_BUTTON = 1; |
930 public static final int MW_REMOVE_BUTTON = 2; |
1055 public static final int MW_REMOVE_BUTTON = 2; |
931 public static final int MW_POLICY_LIST = 3; // follows MW_PANEL |
1056 public static final int MW_POLICY_LIST = 3; // follows MW_PANEL |
932 |
1057 |
|
1058 /* The preferred height of JTextField should match JComboBox. */ |
|
1059 static final int TEXTFIELD_HEIGHT = new JComboBox().getPreferredSize().height; |
|
1060 |
933 private PolicyTool tool; |
1061 private PolicyTool tool; |
934 |
1062 |
935 /** |
1063 /** |
936 * Constructor |
1064 * Constructor |
937 */ |
1065 */ |
938 ToolWindow(PolicyTool tool) { |
1066 ToolWindow(PolicyTool tool) { |
939 this.tool = tool; |
1067 this.tool = tool; |
940 } |
1068 } |
941 |
1069 |
942 /** |
1070 /** |
|
1071 * Don't call getComponent directly on the window |
|
1072 */ |
|
1073 public Component getComponent(int n) { |
|
1074 Component c = getContentPane().getComponent(n); |
|
1075 if (c instanceof JScrollPane) { |
|
1076 c = ((JScrollPane)c).getViewport().getView(); |
|
1077 } |
|
1078 return c; |
|
1079 } |
|
1080 |
|
1081 /** |
943 * Initialize the PolicyTool window with the necessary components |
1082 * Initialize the PolicyTool window with the necessary components |
944 */ |
1083 */ |
945 private void initWindow() { |
1084 private void initWindow() { |
|
1085 // The ToolWindowListener will handle closing the window. |
|
1086 setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); |
946 |
1087 |
947 // create the top menu bar |
1088 // create the top menu bar |
948 MenuBar menuBar = new MenuBar(); |
1089 JMenuBar menuBar = new JMenuBar(); |
949 |
1090 |
950 // create a File menu |
1091 // create a File menu |
951 Menu menu = new Menu(PolicyTool.rb.getString("File")); |
1092 JMenu menu = new JMenu(); |
952 menu.add(NEW_POLICY_FILE); |
1093 configureButton(menu, "File"); |
953 menu.add(OPEN_POLICY_FILE); |
1094 ActionListener actionListener = new FileMenuListener(tool, this); |
954 menu.add(SAVE_POLICY_FILE); |
1095 addMenuItem(menu, NEW_POLICY_FILE, actionListener); |
955 menu.add(SAVE_AS_POLICY_FILE); |
1096 addMenuItem(menu, OPEN_POLICY_FILE, actionListener); |
956 menu.add(VIEW_WARNINGS); |
1097 addMenuItem(menu, SAVE_POLICY_FILE, actionListener); |
957 menu.add(QUIT); |
1098 addMenuItem(menu, SAVE_AS_POLICY_FILE, actionListener); |
958 menu.addActionListener(new FileMenuListener(tool, this)); |
1099 addMenuItem(menu, VIEW_WARNINGS, actionListener); |
|
1100 addMenuItem(menu, QUIT, actionListener); |
959 menuBar.add(menu); |
1101 menuBar.add(menu); |
960 setMenuBar(menuBar); |
|
961 |
1102 |
962 // create a KeyStore menu |
1103 // create a KeyStore menu |
963 menu = new Menu(PolicyTool.rb.getString("KeyStore")); |
1104 menu = new JMenu(); |
964 menu.add(EDIT_KEYSTORE); |
1105 configureButton(menu, "KeyStore"); |
965 menu.addActionListener(new MainWindowListener(tool, this)); |
1106 actionListener = new MainWindowListener(tool, this); |
|
1107 addMenuItem(menu, EDIT_KEYSTORE, actionListener); |
966 menuBar.add(menu); |
1108 menuBar.add(menu); |
967 setMenuBar(menuBar); |
1109 setJMenuBar(menuBar); |
968 |
1110 |
|
1111 // Create some space around components |
|
1112 ((JPanel)getContentPane()).setBorder(new EmptyBorder(6, 6, 6, 6)); |
969 |
1113 |
970 // policy entry listing |
1114 // policy entry listing |
971 Label label = new Label(PolicyTool.rb.getString("Policy.File.")); |
1115 JLabel label = new JLabel(PolicyTool.getMessage("Policy.File.")); |
972 addNewComponent(this, label, MW_FILENAME_LABEL, |
1116 addNewComponent(this, label, MW_FILENAME_LABEL, |
973 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
1117 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
974 TOP_BOTTOM_PADDING); |
1118 LR_TOP_BOTTOM_PADDING); |
975 TextField tf = new TextField(50); |
1119 JTextField tf = new JTextField(50); |
|
1120 tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
976 tf.getAccessibleContext().setAccessibleName( |
1121 tf.getAccessibleContext().setAccessibleName( |
977 PolicyTool.rb.getString("Policy.File.")); |
1122 PolicyTool.getMessage("Policy.File.")); |
978 tf.setEditable(false); |
1123 tf.setEditable(false); |
979 addNewComponent(this, tf, MW_FILENAME_TEXTFIELD, |
1124 addNewComponent(this, tf, MW_FILENAME_TEXTFIELD, |
980 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
1125 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
981 TOP_BOTTOM_PADDING); |
1126 LR_TOP_BOTTOM_PADDING); |
982 |
1127 |
983 |
1128 |
984 // add ADD/REMOVE/EDIT buttons in a new panel |
1129 // add ADD/REMOVE/EDIT buttons in a new panel |
985 Panel panel = new Panel(); |
1130 JPanel panel = new JPanel(); |
986 panel.setLayout(new GridBagLayout()); |
1131 panel.setLayout(new GridBagLayout()); |
987 |
1132 |
988 Button button = new Button(ADD_POLICY_ENTRY); |
1133 JButton button = new JButton(); |
|
1134 configureButton(button, ADD_POLICY_ENTRY); |
989 button.addActionListener(new MainWindowListener(tool, this)); |
1135 button.addActionListener(new MainWindowListener(tool, this)); |
990 addNewComponent(panel, button, MW_ADD_BUTTON, |
1136 addNewComponent(panel, button, MW_ADD_BUTTON, |
991 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
1137 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
992 LR_PADDING); |
1138 LR_PADDING); |
993 |
1139 |
994 button = new Button(EDIT_POLICY_ENTRY); |
1140 button = new JButton(); |
|
1141 configureButton(button, EDIT_POLICY_ENTRY); |
995 button.addActionListener(new MainWindowListener(tool, this)); |
1142 button.addActionListener(new MainWindowListener(tool, this)); |
996 addNewComponent(panel, button, MW_EDIT_BUTTON, |
1143 addNewComponent(panel, button, MW_EDIT_BUTTON, |
997 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
1144 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
998 LR_PADDING); |
1145 LR_PADDING); |
999 |
1146 |
1000 button = new Button(REMOVE_POLICY_ENTRY); |
1147 button = new JButton(); |
|
1148 configureButton(button, REMOVE_POLICY_ENTRY); |
1001 button.addActionListener(new MainWindowListener(tool, this)); |
1149 button.addActionListener(new MainWindowListener(tool, this)); |
1002 addNewComponent(panel, button, MW_REMOVE_BUTTON, |
1150 addNewComponent(panel, button, MW_REMOVE_BUTTON, |
1003 2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
1151 2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
1004 LR_PADDING); |
1152 LR_PADDING); |
1005 |
1153 |
1019 try { |
1167 try { |
1020 // open the policy file |
1168 // open the policy file |
1021 tool.openPolicy(policyFile); |
1169 tool.openPolicy(policyFile); |
1022 |
1170 |
1023 // display the policy entries via the policy list textarea |
1171 // display the policy entries via the policy list textarea |
1024 List list = new List(40, false); |
1172 DefaultListModel listModel = new DefaultListModel(); |
1025 list.addActionListener(new PolicyListListener(tool, this)); |
1173 JList list = new JList(listModel); |
|
1174 list.setVisibleRowCount(15); |
|
1175 list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
|
1176 list.addMouseListener(new PolicyListListener(tool, this)); |
1026 PolicyEntry entries[] = tool.getEntry(); |
1177 PolicyEntry entries[] = tool.getEntry(); |
1027 if (entries != null) { |
1178 if (entries != null) { |
1028 for (int i = 0; i < entries.length; i++) |
1179 for (int i = 0; i < entries.length; i++) { |
1029 list.add(entries[i].headerToString()); |
1180 listModel.addElement(entries[i].headerToString()); |
|
1181 } |
1030 } |
1182 } |
1031 TextField newFilename = (TextField) |
1183 JTextField newFilename = (JTextField) |
1032 getComponent(MW_FILENAME_TEXTFIELD); |
1184 getComponent(MW_FILENAME_TEXTFIELD); |
1033 newFilename.setText(policyFile); |
1185 newFilename.setText(policyFile); |
1034 initPolicyList(list); |
1186 initPolicyList(list); |
1035 |
1187 |
1036 } catch (FileNotFoundException fnfe) { |
1188 } catch (FileNotFoundException fnfe) { |
1037 // add blank policy listing |
1189 // add blank policy listing |
1038 List list = new List(40, false); |
1190 JList list = new JList(new DefaultListModel()); |
1039 list.addActionListener(new PolicyListListener(tool, this)); |
1191 list.setVisibleRowCount(15); |
|
1192 list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
|
1193 list.addMouseListener(new PolicyListListener(tool, this)); |
1040 initPolicyList(list); |
1194 initPolicyList(list); |
1041 tool.setPolicyFileName(null); |
1195 tool.setPolicyFileName(null); |
1042 tool.modified = false; |
1196 tool.modified = false; |
1043 setVisible(true); |
|
1044 |
1197 |
1045 // just add warning |
1198 // just add warning |
1046 tool.warnings.addElement(fnfe.toString()); |
1199 tool.warnings.addElement(fnfe.toString()); |
1047 |
1200 |
1048 } catch (Exception e) { |
1201 } catch (Exception e) { |
1049 // add blank policy listing |
1202 // add blank policy listing |
1050 List list = new List(40, false); |
1203 JList list = new JList(new DefaultListModel()); |
1051 list.addActionListener(new PolicyListListener(tool, this)); |
1204 list.setVisibleRowCount(15); |
|
1205 list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
|
1206 list.addMouseListener(new PolicyListListener(tool, this)); |
1052 initPolicyList(list); |
1207 initPolicyList(list); |
1053 tool.setPolicyFileName(null); |
1208 tool.setPolicyFileName(null); |
1054 tool.modified = false; |
1209 tool.modified = false; |
1055 setVisible(true); |
|
1056 |
1210 |
1057 // display the error |
1211 // display the error |
1058 MessageFormat form = new MessageFormat(PolicyTool.rb.getString |
1212 MessageFormat form = new MessageFormat(PolicyTool.getMessage |
1059 ("Could.not.open.policy.file.policyFile.e.toString.")); |
1213 ("Could.not.open.policy.file.policyFile.e.toString.")); |
1060 Object[] source = {policyFile, e.toString()}; |
1214 Object[] source = {policyFile, e.toString()}; |
1061 displayErrorDialog(null, form.format(source)); |
1215 displayErrorDialog(null, form.format(source)); |
1062 } |
1216 } |
1063 } |
1217 } |
1064 |
1218 |
1065 |
1219 |
|
1220 // Platform specific modifier (control / command). |
|
1221 private int shortCutModifier = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); |
|
1222 |
|
1223 private void addMenuItem(JMenu menu, String key, ActionListener actionListener) { |
|
1224 JMenuItem menuItem = new JMenuItem(); |
|
1225 configureButton(menuItem, key); |
|
1226 |
|
1227 if (PolicyTool.rb.containsKey(key + ".accelerator")) { |
|
1228 String accelerator = PolicyTool.getMessage(key + ".accelerator"); |
|
1229 if (accelerator != null && !accelerator.isEmpty()) { |
|
1230 KeyStroke keyStroke; |
|
1231 if (accelerator.matches("^control .$")) { |
|
1232 // Map "control" key to "command" on MacOS |
|
1233 keyStroke = KeyStroke.getKeyStroke(KeyEvent.getExtendedKeyCodeForChar(accelerator.charAt(8)), |
|
1234 shortCutModifier); |
|
1235 } else { |
|
1236 keyStroke = KeyStroke.getKeyStroke(accelerator); |
|
1237 } |
|
1238 menuItem.setAccelerator(keyStroke); |
|
1239 } |
|
1240 } |
|
1241 |
|
1242 menuItem.addActionListener(actionListener); |
|
1243 menu.add(menuItem); |
|
1244 } |
|
1245 |
|
1246 static void configureButton(AbstractButton button, String key) { |
|
1247 button.setText(PolicyTool.getMessage(key)); |
|
1248 button.setActionCommand(key); |
|
1249 |
|
1250 int mnemonicInt = PolicyTool.getMnemonicInt(key); |
|
1251 if (mnemonicInt > 0) { |
|
1252 button.setMnemonic(mnemonicInt); |
|
1253 button.setDisplayedMnemonicIndex(PolicyTool.getDisplayedMnemonicIndex(key)); |
|
1254 } |
|
1255 } |
|
1256 |
|
1257 static void configureLabelFor(JLabel label, JComponent component, String key) { |
|
1258 label.setText(PolicyTool.getMessage(key)); |
|
1259 label.setLabelFor(component); |
|
1260 |
|
1261 int mnemonicInt = PolicyTool.getMnemonicInt(key); |
|
1262 if (mnemonicInt > 0) { |
|
1263 label.setDisplayedMnemonic(mnemonicInt); |
|
1264 label.setDisplayedMnemonicIndex(PolicyTool.getDisplayedMnemonicIndex(key)); |
|
1265 } |
|
1266 } |
|
1267 |
|
1268 |
1066 /** |
1269 /** |
1067 * Add a component to the PolicyTool window |
1270 * Add a component to the PolicyTool window |
1068 */ |
1271 */ |
1069 void addNewComponent(Container container, Component component, |
1272 void addNewComponent(Container container, JComponent component, |
1070 int index, int gridx, int gridy, int gridwidth, int gridheight, |
1273 int index, int gridx, int gridy, int gridwidth, int gridheight, |
1071 double weightx, double weighty, int fill, Insets is) { |
1274 double weightx, double weighty, int fill, Insets is) { |
|
1275 |
|
1276 if (container instanceof JFrame) { |
|
1277 container = ((JFrame)container).getContentPane(); |
|
1278 } else if (container instanceof JDialog) { |
|
1279 container = ((JDialog)container).getContentPane(); |
|
1280 } |
1072 |
1281 |
1073 // add the component at the specified gridbag index |
1282 // add the component at the specified gridbag index |
1074 container.add(component, index); |
1283 container.add(component, index); |
1075 |
1284 |
1076 // set the constraints |
1285 // set the constraints |
1104 |
1313 |
1105 /** |
1314 /** |
1106 * Init the policy_entry_list TEXTAREA component in the |
1315 * Init the policy_entry_list TEXTAREA component in the |
1107 * PolicyTool window |
1316 * PolicyTool window |
1108 */ |
1317 */ |
1109 void initPolicyList(List policyList) { |
1318 void initPolicyList(JList policyList) { |
1110 |
1319 |
1111 // add the policy list to the window |
1320 // add the policy list to the window |
1112 addNewComponent(this, policyList, MW_POLICY_LIST, |
1321 //policyList.setPreferredSize(new Dimension(500, 350)); |
|
1322 JScrollPane scrollPane = new JScrollPane(policyList); |
|
1323 addNewComponent(this, scrollPane, MW_POLICY_LIST, |
1113 0, 3, 2, 1, 1.0, 1.0, GridBagConstraints.BOTH); |
1324 0, 3, 2, 1, 1.0, 1.0, GridBagConstraints.BOTH); |
1114 } |
1325 } |
1115 |
1326 |
1116 /** |
1327 /** |
1117 * Replace the policy_entry_list TEXTAREA component in the |
1328 * Replace the policy_entry_list TEXTAREA component in the |
1118 * PolicyTool window with an updated one. |
1329 * PolicyTool window with an updated one. |
1119 */ |
1330 */ |
1120 void replacePolicyList(List policyList) { |
1331 void replacePolicyList(JList policyList) { |
1121 |
1332 |
1122 // remove the original list of Policy Entries |
1333 // remove the original list of Policy Entries |
1123 // and add the new list of entries |
1334 // and add the new list of entries |
1124 List list = (List)getComponent(MW_POLICY_LIST); |
1335 JList list = (JList)getComponent(MW_POLICY_LIST); |
1125 list.removeAll(); |
1336 list.setModel(policyList.getModel()); |
1126 String newItems[] = policyList.getItems(); |
|
1127 for (int i = 0; i < newItems.length; i++) |
|
1128 list.add(newItems[i]); |
|
1129 } |
1337 } |
1130 |
1338 |
1131 /** |
1339 /** |
1132 * display the main PolicyTool window |
1340 * display the main PolicyTool window |
1133 */ |
1341 */ |
1134 void displayToolWindow(String args[]) { |
1342 void displayToolWindow(String args[]) { |
1135 |
1343 |
1136 setTitle(PolicyTool.rb.getString("Policy.Tool")); |
1344 setTitle(PolicyTool.getMessage("Policy.Tool")); |
1137 setResizable(true); |
1345 setResizable(true); |
1138 addWindowListener(new ToolWindowListener(this)); |
1346 addWindowListener(new ToolWindowListener(tool, this)); |
1139 setBounds(135, 80, 500, 500); |
1347 //setBounds(135, 80, 500, 500); |
1140 setLayout(new GridBagLayout()); |
1348 getContentPane().setLayout(new GridBagLayout()); |
1141 |
1349 |
1142 initWindow(); |
1350 initWindow(); |
|
1351 pack(); |
|
1352 setLocationRelativeTo(null); |
1143 |
1353 |
1144 // display it |
1354 // display it |
1145 setVisible(true); |
1355 setVisible(true); |
1146 |
1356 |
1147 if (tool.newWarning == true) { |
1357 if (tool.newWarning == true) { |
1148 displayStatusDialog(this, PolicyTool.rb.getString |
1358 displayStatusDialog(this, PolicyTool.getMessage |
1149 ("Errors.have.occurred.while.opening.the.policy.configuration.View.the.Warning.Log.for.more.information.")); |
1359 ("Errors.have.occurred.while.opening.the.policy.configuration.View.the.Warning.Log.for.more.information.")); |
1150 } |
1360 } |
1151 } |
1361 } |
1152 |
1362 |
1153 /** |
1363 /** |
1154 * displays a dialog box describing an error which occurred. |
1364 * displays a dialog box describing an error which occurred. |
1155 */ |
1365 */ |
1156 void displayErrorDialog(Window w, String error) { |
1366 void displayErrorDialog(Window w, String error) { |
1157 ToolDialog ed = new ToolDialog |
1367 ToolDialog ed = new ToolDialog |
1158 (PolicyTool.rb.getString("Error"), tool, this, true); |
1368 (PolicyTool.getMessage("Error"), tool, this, true); |
1159 |
1369 |
1160 // find where the PolicyTool gui is |
1370 // find where the PolicyTool gui is |
1161 Point location = ((w == null) ? |
1371 Point location = ((w == null) ? |
1162 getLocationOnScreen() : w.getLocationOnScreen()); |
1372 getLocationOnScreen() : w.getLocationOnScreen()); |
1163 ed.setBounds(location.x + 50, location.y + 50, 600, 100); |
1373 //ed.setBounds(location.x + 50, location.y + 50, 600, 100); |
1164 ed.setLayout(new GridBagLayout()); |
1374 ed.setLayout(new GridBagLayout()); |
1165 |
1375 |
1166 Label label = new Label(error); |
1376 JLabel label = new JLabel(error); |
1167 addNewComponent(ed, label, 0, |
1377 addNewComponent(ed, label, 0, |
1168 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
1378 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
1169 |
1379 |
1170 Button okButton = new Button(PolicyTool.rb.getString("OK")); |
1380 JButton okButton = new JButton(PolicyTool.getMessage("OK")); |
1171 okButton.addActionListener(new ErrorOKButtonListener(ed)); |
1381 ActionListener okListener = new ErrorOKButtonListener(ed); |
|
1382 okButton.addActionListener(okListener); |
1172 addNewComponent(ed, okButton, 1, |
1383 addNewComponent(ed, okButton, 1, |
1173 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL); |
1384 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL); |
1174 |
1385 |
|
1386 ed.getRootPane().setDefaultButton(okButton); |
|
1387 ed.getRootPane().registerKeyboardAction(okListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW); |
|
1388 |
1175 ed.pack(); |
1389 ed.pack(); |
|
1390 ed.setLocationRelativeTo(w); |
1176 ed.setVisible(true); |
1391 ed.setVisible(true); |
1177 } |
1392 } |
1178 |
1393 |
1179 /** |
1394 /** |
1180 * displays a dialog box describing an error which occurred. |
1395 * displays a dialog box describing an error which occurred. |
1189 /** |
1404 /** |
1190 * displays a dialog box describing the status of an event |
1405 * displays a dialog box describing the status of an event |
1191 */ |
1406 */ |
1192 void displayStatusDialog(Window w, String status) { |
1407 void displayStatusDialog(Window w, String status) { |
1193 ToolDialog sd = new ToolDialog |
1408 ToolDialog sd = new ToolDialog |
1194 (PolicyTool.rb.getString("Status"), tool, this, true); |
1409 (PolicyTool.getMessage("Status"), tool, this, true); |
1195 |
1410 |
1196 // find the location of the PolicyTool gui |
1411 // find the location of the PolicyTool gui |
1197 Point location = ((w == null) ? |
1412 Point location = ((w == null) ? |
1198 getLocationOnScreen() : w.getLocationOnScreen()); |
1413 getLocationOnScreen() : w.getLocationOnScreen()); |
1199 sd.setBounds(location.x + 50, location.y + 50, 500, 100); |
1414 //sd.setBounds(location.x + 50, location.y + 50, 500, 100); |
1200 sd.setLayout(new GridBagLayout()); |
1415 sd.setLayout(new GridBagLayout()); |
1201 |
1416 |
1202 Label label = new Label(status); |
1417 JLabel label = new JLabel(status); |
1203 addNewComponent(sd, label, 0, |
1418 addNewComponent(sd, label, 0, |
1204 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
1419 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
1205 |
1420 |
1206 Button okButton = new Button(PolicyTool.rb.getString("OK")); |
1421 JButton okButton = new JButton(PolicyTool.getMessage("OK")); |
1207 okButton.addActionListener(new StatusOKButtonListener(sd)); |
1422 ActionListener okListener = new StatusOKButtonListener(sd); |
|
1423 okButton.addActionListener(okListener); |
1208 addNewComponent(sd, okButton, 1, |
1424 addNewComponent(sd, okButton, 1, |
1209 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL); |
1425 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL); |
|
1426 |
|
1427 sd.getRootPane().setDefaultButton(okButton); |
|
1428 sd.getRootPane().registerKeyboardAction(okListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW); |
|
1429 |
1210 sd.pack(); |
1430 sd.pack(); |
|
1431 sd.setLocationRelativeTo(w); |
1211 sd.setVisible(true); |
1432 sd.setVisible(true); |
1212 } |
1433 } |
1213 |
1434 |
1214 /** |
1435 /** |
1215 * display the warning log |
1436 * display the warning log |
1216 */ |
1437 */ |
1217 void displayWarningLog(Window w) { |
1438 void displayWarningLog(Window w) { |
1218 |
1439 |
1219 ToolDialog wd = new ToolDialog |
1440 ToolDialog wd = new ToolDialog |
1220 (PolicyTool.rb.getString("Warning"), tool, this, true); |
1441 (PolicyTool.getMessage("Warning"), tool, this, true); |
1221 |
1442 |
1222 // find the location of the PolicyTool gui |
1443 // find the location of the PolicyTool gui |
1223 Point location = ((w == null) ? |
1444 Point location = ((w == null) ? |
1224 getLocationOnScreen() : w.getLocationOnScreen()); |
1445 getLocationOnScreen() : w.getLocationOnScreen()); |
1225 wd.setBounds(location.x + 50, location.y + 50, 500, 100); |
1446 //wd.setBounds(location.x + 50, location.y + 50, 500, 100); |
1226 wd.setLayout(new GridBagLayout()); |
1447 wd.setLayout(new GridBagLayout()); |
1227 |
1448 |
1228 TextArea ta = new TextArea(); |
1449 JTextArea ta = new JTextArea(); |
1229 ta.setEditable(false); |
1450 ta.setEditable(false); |
1230 for (int i = 0; i < tool.warnings.size(); i++) { |
1451 for (int i = 0; i < tool.warnings.size(); i++) { |
1231 ta.append(tool.warnings.elementAt(i)); |
1452 ta.append(tool.warnings.elementAt(i)); |
1232 ta.append(PolicyTool.rb.getString("NEWLINE")); |
1453 ta.append(PolicyTool.getMessage("NEWLINE")); |
1233 } |
1454 } |
1234 addNewComponent(wd, ta, 0, |
1455 addNewComponent(wd, ta, 0, |
1235 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
1456 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
1236 BOTTOM_PADDING); |
1457 BOTTOM_PADDING); |
1237 ta.setFocusable(false); |
1458 ta.setFocusable(false); |
1238 |
1459 |
1239 Button okButton = new Button(PolicyTool.rb.getString("OK")); |
1460 JButton okButton = new JButton(PolicyTool.getMessage("OK")); |
1240 okButton.addActionListener(new CancelButtonListener(wd)); |
1461 ActionListener okListener = new CancelButtonListener(wd); |
|
1462 okButton.addActionListener(okListener); |
1241 addNewComponent(wd, okButton, 1, |
1463 addNewComponent(wd, okButton, 1, |
1242 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
1464 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
1243 LR_PADDING); |
1465 LR_PADDING); |
1244 |
1466 |
|
1467 wd.getRootPane().setDefaultButton(okButton); |
|
1468 wd.getRootPane().registerKeyboardAction(okListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW); |
|
1469 |
1245 wd.pack(); |
1470 wd.pack(); |
|
1471 wd.setLocationRelativeTo(w); |
1246 wd.setVisible(true); |
1472 wd.setVisible(true); |
1247 } |
1473 } |
1248 |
1474 |
1249 char displayYesNoDialog(Window w, String title, String prompt, String yes, String no) { |
1475 char displayYesNoDialog(Window w, String title, String prompt, String yes, String no) { |
1250 |
1476 |
1251 final ToolDialog tw = new ToolDialog |
1477 final ToolDialog tw = new ToolDialog |
1252 (title, tool, this, true); |
1478 (title, tool, this, true); |
1253 Point location = ((w == null) ? |
1479 Point location = ((w == null) ? |
1254 getLocationOnScreen() : w.getLocationOnScreen()); |
1480 getLocationOnScreen() : w.getLocationOnScreen()); |
1255 tw.setBounds(location.x + 75, location.y + 100, 400, 150); |
1481 //tw.setBounds(location.x + 75, location.y + 100, 400, 150); |
1256 tw.setLayout(new GridBagLayout()); |
1482 tw.setLayout(new GridBagLayout()); |
1257 |
1483 |
1258 TextArea ta = new TextArea(prompt, 10, 50, TextArea.SCROLLBARS_VERTICAL_ONLY); |
1484 JTextArea ta = new JTextArea(prompt, 10, 50); |
1259 ta.setEditable(false); |
1485 ta.setEditable(false); |
1260 addNewComponent(tw, ta, 0, |
1486 ta.setLineWrap(true); |
|
1487 ta.setWrapStyleWord(true); |
|
1488 JScrollPane scrollPane = new JScrollPane(ta, |
|
1489 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, |
|
1490 JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); |
|
1491 addNewComponent(tw, scrollPane, 0, |
1261 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
1492 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
1262 ta.setFocusable(false); |
1493 ta.setFocusable(false); |
1263 |
1494 |
1264 Panel panel = new Panel(); |
1495 JPanel panel = new JPanel(); |
1265 panel.setLayout(new GridBagLayout()); |
1496 panel.setLayout(new GridBagLayout()); |
1266 |
1497 |
1267 // StringBuffer to store button press. Must be final. |
1498 // StringBuffer to store button press. Must be final. |
1268 final StringBuffer chooseResult = new StringBuffer(); |
1499 final StringBuffer chooseResult = new StringBuffer(); |
1269 |
1500 |
1270 Button button = new Button(yes); |
1501 JButton button = new JButton(yes); |
1271 button.addActionListener(new ActionListener() { |
1502 button.addActionListener(new ActionListener() { |
1272 public void actionPerformed(ActionEvent e) { |
1503 public void actionPerformed(ActionEvent e) { |
1273 chooseResult.append('Y'); |
1504 chooseResult.append('Y'); |
1274 tw.setVisible(false); |
1505 tw.setVisible(false); |
1275 tw.dispose(); |
1506 tw.dispose(); |
1580 permList.addTaggedItem(ToolDialog.PermissionEntryToUserFriendlyString(nextPerm), nextPerm); |
1832 permList.addTaggedItem(ToolDialog.PermissionEntryToUserFriendlyString(nextPerm), nextPerm); |
1581 } |
1833 } |
1582 } |
1834 } |
1583 |
1835 |
1584 // codebase label and textfield |
1836 // codebase label and textfield |
1585 Label label = new Label(PolicyTool.rb.getString("CodeBase.")); |
1837 JLabel label = new JLabel(); |
1586 tw.addNewComponent(this, label, PE_CODEBASE_LABEL, |
1838 tw.addNewComponent(this, label, PE_CODEBASE_LABEL, |
1587 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
1839 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
1588 TextField tf; |
1840 ToolWindow.R_PADDING); |
|
1841 JTextField tf; |
1589 tf = (edit ? |
1842 tf = (edit ? |
1590 new TextField(entries[listIndex].getGrantEntry().codeBase, 60) : |
1843 new JTextField(entries[listIndex].getGrantEntry().codeBase) : |
1591 new TextField(60)); |
1844 new JTextField()); |
|
1845 ToolWindow.configureLabelFor(label, tf, "CodeBase."); |
|
1846 tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
1592 tf.getAccessibleContext().setAccessibleName( |
1847 tf.getAccessibleContext().setAccessibleName( |
1593 PolicyTool.rb.getString("Code.Base")); |
1848 PolicyTool.getMessage("Code.Base")); |
1594 tw.addNewComponent(this, tf, PE_CODEBASE_TEXTFIELD, |
1849 tw.addNewComponent(this, tf, PE_CODEBASE_TEXTFIELD, |
1595 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
1850 1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH); |
1596 |
1851 |
1597 // signedby label and textfield |
1852 // signedby label and textfield |
1598 label = new Label(PolicyTool.rb.getString("SignedBy.")); |
1853 label = new JLabel(); |
1599 tw.addNewComponent(this, label, PE_SIGNEDBY_LABEL, |
1854 tw.addNewComponent(this, label, PE_SIGNEDBY_LABEL, |
1600 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
1855 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
1856 ToolWindow.R_PADDING); |
1601 tf = (edit ? |
1857 tf = (edit ? |
1602 new TextField(entries[listIndex].getGrantEntry().signedBy, 60) : |
1858 new JTextField(entries[listIndex].getGrantEntry().signedBy) : |
1603 new TextField(60)); |
1859 new JTextField()); |
|
1860 ToolWindow.configureLabelFor(label, tf, "SignedBy."); |
|
1861 tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
1604 tf.getAccessibleContext().setAccessibleName( |
1862 tf.getAccessibleContext().setAccessibleName( |
1605 PolicyTool.rb.getString("Signed.By.")); |
1863 PolicyTool.getMessage("Signed.By.")); |
1606 tw.addNewComponent(this, tf, PE_SIGNEDBY_TEXTFIELD, |
1864 tw.addNewComponent(this, tf, PE_SIGNEDBY_TEXTFIELD, |
1607 1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
1865 1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH); |
1608 |
1866 |
1609 // panel for principal buttons |
1867 // panel for principal buttons |
1610 Panel panel = new Panel(); |
1868 JPanel panel = new JPanel(); |
1611 panel.setLayout(new GridBagLayout()); |
1869 panel.setLayout(new GridBagLayout()); |
1612 |
1870 |
1613 Button button = new Button(PolicyTool.rb.getString("Add.Principal")); |
1871 JButton button = new JButton(); |
|
1872 ToolWindow.configureButton(button, "Add.Principal"); |
1614 button.addActionListener |
1873 button.addActionListener |
1615 (new AddPrinButtonListener(tool, tw, this, edit)); |
1874 (new AddPrinButtonListener(tool, tw, this, edit)); |
1616 tw.addNewComponent(panel, button, PE_ADD_PRIN_BUTTON, |
1875 tw.addNewComponent(panel, button, PE_ADD_PRIN_BUTTON, |
1617 0, 0, 1, 1, 100.0, 0.0, GridBagConstraints.HORIZONTAL); |
1876 0, 0, 1, 1, 100.0, 0.0, GridBagConstraints.HORIZONTAL); |
1618 |
1877 |
1619 button = new Button(PolicyTool.rb.getString("Edit.Principal")); |
1878 button = new JButton(); |
|
1879 ToolWindow.configureButton(button, "Edit.Principal"); |
1620 button.addActionListener(new EditPrinButtonListener |
1880 button.addActionListener(new EditPrinButtonListener |
1621 (tool, tw, this, edit)); |
1881 (tool, tw, this, edit)); |
1622 tw.addNewComponent(panel, button, PE_EDIT_PRIN_BUTTON, |
1882 tw.addNewComponent(panel, button, PE_EDIT_PRIN_BUTTON, |
1623 1, 0, 1, 1, 100.0, 0.0, GridBagConstraints.HORIZONTAL); |
1883 1, 0, 1, 1, 100.0, 0.0, GridBagConstraints.HORIZONTAL); |
1624 |
1884 |
1625 button = new Button(PolicyTool.rb.getString("Remove.Principal")); |
1885 button = new JButton(); |
|
1886 ToolWindow.configureButton(button, "Remove.Principal"); |
1626 button.addActionListener(new RemovePrinButtonListener |
1887 button.addActionListener(new RemovePrinButtonListener |
1627 (tool, tw, this, edit)); |
1888 (tool, tw, this, edit)); |
1628 tw.addNewComponent(panel, button, PE_REMOVE_PRIN_BUTTON, |
1889 tw.addNewComponent(panel, button, PE_REMOVE_PRIN_BUTTON, |
1629 2, 0, 1, 1, 100.0, 0.0, GridBagConstraints.HORIZONTAL); |
1890 2, 0, 1, 1, 100.0, 0.0, GridBagConstraints.HORIZONTAL); |
1630 |
1891 |
1631 tw.addNewComponent(this, panel, PE_PANEL0, |
1892 tw.addNewComponent(this, panel, PE_PANEL0, |
1632 1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.HORIZONTAL); |
1893 1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.HORIZONTAL, |
|
1894 ToolWindow.LITE_BOTTOM_PADDING); |
1633 |
1895 |
1634 // principal label and list |
1896 // principal label and list |
1635 label = new Label(PolicyTool.rb.getString("Principals.")); |
1897 label = new JLabel(); |
1636 tw.addNewComponent(this, label, PE_PRIN_LABEL, |
1898 tw.addNewComponent(this, label, PE_PRIN_LABEL, |
1637 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
1899 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
1900 ToolWindow.R_BOTTOM_PADDING); |
|
1901 JScrollPane scrollPane = new JScrollPane(prinList); |
|
1902 ToolWindow.configureLabelFor(label, scrollPane, "Principals."); |
|
1903 tw.addNewComponent(this, scrollPane, PE_PRIN_LIST, |
|
1904 1, 3, 3, 1, 0.0, prinList.getVisibleRowCount(), GridBagConstraints.BOTH, |
1638 ToolWindow.BOTTOM_PADDING); |
1905 ToolWindow.BOTTOM_PADDING); |
1639 tw.addNewComponent(this, prinList, PE_PRIN_LIST, |
|
1640 1, 3, 3, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
1641 ToolWindow.BOTTOM_PADDING); |
|
1642 |
1906 |
1643 // panel for permission buttons |
1907 // panel for permission buttons |
1644 panel = new Panel(); |
1908 panel = new JPanel(); |
1645 panel.setLayout(new GridBagLayout()); |
1909 panel.setLayout(new GridBagLayout()); |
1646 |
1910 |
1647 button = new Button(PolicyTool.rb.getString(".Add.Permission")); |
1911 button = new JButton(); |
|
1912 ToolWindow.configureButton(button, ".Add.Permission"); |
1648 button.addActionListener(new AddPermButtonListener |
1913 button.addActionListener(new AddPermButtonListener |
1649 (tool, tw, this, edit)); |
1914 (tool, tw, this, edit)); |
1650 tw.addNewComponent(panel, button, PE_ADD_PERM_BUTTON, |
1915 tw.addNewComponent(panel, button, PE_ADD_PERM_BUTTON, |
1651 0, 0, 1, 1, 100.0, 0.0, GridBagConstraints.HORIZONTAL); |
1916 0, 0, 1, 1, 100.0, 0.0, GridBagConstraints.HORIZONTAL); |
1652 |
1917 |
1653 button = new Button(PolicyTool.rb.getString(".Edit.Permission")); |
1918 button = new JButton(); |
|
1919 ToolWindow.configureButton(button, ".Edit.Permission"); |
1654 button.addActionListener(new EditPermButtonListener |
1920 button.addActionListener(new EditPermButtonListener |
1655 (tool, tw, this, edit)); |
1921 (tool, tw, this, edit)); |
1656 tw.addNewComponent(panel, button, PE_EDIT_PERM_BUTTON, |
1922 tw.addNewComponent(panel, button, PE_EDIT_PERM_BUTTON, |
1657 1, 0, 1, 1, 100.0, 0.0, GridBagConstraints.HORIZONTAL); |
1923 1, 0, 1, 1, 100.0, 0.0, GridBagConstraints.HORIZONTAL); |
1658 |
1924 |
1659 |
1925 |
1660 button = new Button(PolicyTool.rb.getString("Remove.Permission")); |
1926 button = new JButton(); |
|
1927 ToolWindow.configureButton(button, "Remove.Permission"); |
1661 button.addActionListener(new RemovePermButtonListener |
1928 button.addActionListener(new RemovePermButtonListener |
1662 (tool, tw, this, edit)); |
1929 (tool, tw, this, edit)); |
1663 tw.addNewComponent(panel, button, PE_REMOVE_PERM_BUTTON, |
1930 tw.addNewComponent(panel, button, PE_REMOVE_PERM_BUTTON, |
1664 2, 0, 1, 1, 100.0, 0.0, GridBagConstraints.HORIZONTAL); |
1931 2, 0, 1, 1, 100.0, 0.0, GridBagConstraints.HORIZONTAL); |
1665 |
1932 |
1666 tw.addNewComponent(this, panel, PE_PANEL1, |
1933 tw.addNewComponent(this, panel, PE_PANEL1, |
1667 0, 4, 2, 1, 0.0, 0.0, GridBagConstraints.HORIZONTAL, |
1934 0, 4, 2, 1, 0.0, 0.0, GridBagConstraints.HORIZONTAL, |
1668 ToolWindow.LITE_BOTTOM_PADDING); |
1935 ToolWindow.LITE_BOTTOM_PADDING); |
1669 |
1936 |
1670 // permission list |
1937 // permission list |
1671 tw.addNewComponent(this, permList, PE_PERM_LIST, |
1938 scrollPane = new JScrollPane(permList); |
1672 0, 5, 3, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
1939 tw.addNewComponent(this, scrollPane, PE_PERM_LIST, |
|
1940 0, 5, 3, 1, 0.0, permList.getVisibleRowCount(), GridBagConstraints.BOTH, |
1673 ToolWindow.BOTTOM_PADDING); |
1941 ToolWindow.BOTTOM_PADDING); |
1674 |
1942 |
1675 |
1943 |
1676 // panel for Done and Cancel buttons |
1944 // panel for Done and Cancel buttons |
1677 panel = new Panel(); |
1945 panel = new JPanel(); |
1678 panel.setLayout(new GridBagLayout()); |
1946 panel.setLayout(new GridBagLayout()); |
1679 |
1947 |
1680 // Done Button |
1948 // Done Button |
1681 button = new Button(PolicyTool.rb.getString("Done")); |
1949 JButton okButton = new JButton(PolicyTool.getMessage("Done")); |
1682 button.addActionListener |
1950 okButton.addActionListener |
1683 (new AddEntryDoneButtonListener(tool, tw, this, edit)); |
1951 (new AddEntryDoneButtonListener(tool, tw, this, edit)); |
1684 tw.addNewComponent(panel, button, PE_DONE_BUTTON, |
1952 tw.addNewComponent(panel, okButton, PE_DONE_BUTTON, |
1685 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
1953 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
1686 ToolWindow.LR_PADDING); |
1954 ToolWindow.LR_PADDING); |
1687 |
1955 |
1688 // Cancel Button |
1956 // Cancel Button |
1689 button = new Button(PolicyTool.rb.getString("Cancel")); |
1957 JButton cancelButton = new JButton(PolicyTool.getMessage("Cancel")); |
1690 button.addActionListener(new CancelButtonListener(this)); |
1958 ActionListener cancelListener = new CancelButtonListener(this); |
1691 tw.addNewComponent(panel, button, PE_CANCEL_BUTTON, |
1959 cancelButton.addActionListener(cancelListener); |
|
1960 tw.addNewComponent(panel, cancelButton, PE_CANCEL_BUTTON, |
1692 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
1961 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
1693 ToolWindow.LR_PADDING); |
1962 ToolWindow.LR_PADDING); |
1694 |
1963 |
1695 // add the panel |
1964 // add the panel |
1696 tw.addNewComponent(this, panel, PE_PANEL2, |
1965 tw.addNewComponent(this, panel, PE_PANEL2, |
1697 0, 6, 2, 1, 0.0, 0.0, GridBagConstraints.VERTICAL); |
1966 0, 6, 2, 1, 0.0, 0.0, GridBagConstraints.VERTICAL); |
1698 |
1967 |
|
1968 getRootPane().setDefaultButton(okButton); |
|
1969 getRootPane().registerKeyboardAction(cancelListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW); |
|
1970 |
|
1971 pack(); |
|
1972 setLocationRelativeTo(tw); |
1699 setVisible(true); |
1973 setVisible(true); |
1700 } |
1974 } |
1701 |
1975 |
1702 /** |
1976 /** |
1703 * Read all the Policy information data in the dialog box |
1977 * Read all the Policy information data in the dialog box |
1752 */ |
2026 */ |
1753 void keyStoreDialog(int mode) { |
2027 void keyStoreDialog(int mode) { |
1754 |
2028 |
1755 // find where the PolicyTool gui is |
2029 // find where the PolicyTool gui is |
1756 Point location = tw.getLocationOnScreen(); |
2030 Point location = tw.getLocationOnScreen(); |
1757 setBounds(location.x + 25, location.y + 100, 500, 300); |
2031 //setBounds(location.x + 25, location.y + 100, 500, 300); |
1758 setLayout(new GridBagLayout()); |
2032 setLayout(new GridBagLayout()); |
1759 |
2033 |
1760 if (mode == EDIT_KEYSTORE) { |
2034 if (mode == EDIT_KEYSTORE) { |
1761 |
2035 |
1762 // KeyStore label and textfield |
2036 // KeyStore label and textfield |
1763 Label label = new Label |
2037 JLabel label = new JLabel(); |
1764 (PolicyTool.rb.getString("KeyStore.URL.")); |
|
1765 tw.addNewComponent(this, label, KSD_NAME_LABEL, |
2038 tw.addNewComponent(this, label, KSD_NAME_LABEL, |
1766 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2039 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
1767 ToolWindow.BOTTOM_PADDING); |
2040 ToolWindow.R_BOTTOM_PADDING); |
1768 TextField tf = new TextField(tool.getKeyStoreName(), 30); |
2041 JTextField tf = new JTextField(tool.getKeyStoreName(), 30); |
|
2042 ToolWindow.configureLabelFor(label, tf, "KeyStore.URL."); |
|
2043 tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
1769 |
2044 |
1770 // URL to U R L, so that accessibility reader will pronounce well |
2045 // URL to U R L, so that accessibility reader will pronounce well |
1771 tf.getAccessibleContext().setAccessibleName( |
2046 tf.getAccessibleContext().setAccessibleName( |
1772 PolicyTool.rb.getString("KeyStore.U.R.L.")); |
2047 PolicyTool.getMessage("KeyStore.U.R.L.")); |
1773 tw.addNewComponent(this, tf, KSD_NAME_TEXTFIELD, |
2048 tw.addNewComponent(this, tf, KSD_NAME_TEXTFIELD, |
1774 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2049 1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
1775 ToolWindow.BOTTOM_PADDING); |
2050 ToolWindow.BOTTOM_PADDING); |
1776 |
2051 |
1777 // KeyStore type and textfield |
2052 // KeyStore type and textfield |
1778 label = new Label(PolicyTool.rb.getString("KeyStore.Type.")); |
2053 label = new JLabel(); |
1779 tw.addNewComponent(this, label, KSD_TYPE_LABEL, |
2054 tw.addNewComponent(this, label, KSD_TYPE_LABEL, |
1780 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2055 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
2056 ToolWindow.R_BOTTOM_PADDING); |
|
2057 tf = new JTextField(tool.getKeyStoreType(), 30); |
|
2058 ToolWindow.configureLabelFor(label, tf, "KeyStore.Type."); |
|
2059 tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
|
2060 tf.getAccessibleContext().setAccessibleName( |
|
2061 PolicyTool.getMessage("KeyStore.Type.")); |
|
2062 tw.addNewComponent(this, tf, KSD_TYPE_TEXTFIELD, |
|
2063 1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
1781 ToolWindow.BOTTOM_PADDING); |
2064 ToolWindow.BOTTOM_PADDING); |
1782 tf = new TextField(tool.getKeyStoreType(), 30); |
|
1783 tf.getAccessibleContext().setAccessibleName( |
|
1784 PolicyTool.rb.getString("KeyStore.Type.")); |
|
1785 tw.addNewComponent(this, tf, KSD_TYPE_TEXTFIELD, |
|
1786 1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
1787 ToolWindow.BOTTOM_PADDING); |
|
1788 |
2065 |
1789 // KeyStore provider and textfield |
2066 // KeyStore provider and textfield |
1790 label = new Label(PolicyTool.rb.getString |
2067 label = new JLabel(); |
1791 ("KeyStore.Provider.")); |
|
1792 tw.addNewComponent(this, label, KSD_PROVIDER_LABEL, |
2068 tw.addNewComponent(this, label, KSD_PROVIDER_LABEL, |
1793 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2069 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
2070 ToolWindow.R_BOTTOM_PADDING); |
|
2071 tf = new JTextField(tool.getKeyStoreProvider(), 30); |
|
2072 ToolWindow.configureLabelFor(label, tf, "KeyStore.Provider."); |
|
2073 tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
|
2074 tf.getAccessibleContext().setAccessibleName( |
|
2075 PolicyTool.getMessage("KeyStore.Provider.")); |
|
2076 tw.addNewComponent(this, tf, KSD_PROVIDER_TEXTFIELD, |
|
2077 1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
1794 ToolWindow.BOTTOM_PADDING); |
2078 ToolWindow.BOTTOM_PADDING); |
1795 tf = new TextField(tool.getKeyStoreProvider(), 30); |
|
1796 tf.getAccessibleContext().setAccessibleName( |
|
1797 PolicyTool.rb.getString("KeyStore.Provider.")); |
|
1798 tw.addNewComponent(this, tf, KSD_PROVIDER_TEXTFIELD, |
|
1799 1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
1800 ToolWindow.BOTTOM_PADDING); |
|
1801 |
2079 |
1802 // KeyStore password URL and textfield |
2080 // KeyStore password URL and textfield |
1803 label = new Label(PolicyTool.rb.getString |
2081 label = new JLabel(); |
1804 ("KeyStore.Password.URL.")); |
|
1805 tw.addNewComponent(this, label, KSD_PWD_URL_LABEL, |
2082 tw.addNewComponent(this, label, KSD_PWD_URL_LABEL, |
1806 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2083 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
2084 ToolWindow.R_BOTTOM_PADDING); |
|
2085 tf = new JTextField(tool.getKeyStorePwdURL(), 30); |
|
2086 ToolWindow.configureLabelFor(label, tf, "KeyStore.Password.URL."); |
|
2087 tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
|
2088 tf.getAccessibleContext().setAccessibleName( |
|
2089 PolicyTool.getMessage("KeyStore.Password.U.R.L.")); |
|
2090 tw.addNewComponent(this, tf, KSD_PWD_URL_TEXTFIELD, |
|
2091 1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
1807 ToolWindow.BOTTOM_PADDING); |
2092 ToolWindow.BOTTOM_PADDING); |
1808 tf = new TextField(tool.getKeyStorePwdURL(), 30); |
|
1809 tf.getAccessibleContext().setAccessibleName( |
|
1810 PolicyTool.rb.getString("KeyStore.Password.U.R.L.")); |
|
1811 tw.addNewComponent(this, tf, KSD_PWD_URL_TEXTFIELD, |
|
1812 1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
|
1813 ToolWindow.BOTTOM_PADDING); |
|
1814 |
2093 |
1815 // OK button |
2094 // OK button |
1816 Button okButton = new Button(PolicyTool.rb.getString("OK")); |
2095 JButton okButton = new JButton(PolicyTool.getMessage("OK")); |
1817 okButton.addActionListener |
2096 okButton.addActionListener |
1818 (new ChangeKeyStoreOKButtonListener(tool, tw, this)); |
2097 (new ChangeKeyStoreOKButtonListener(tool, tw, this)); |
1819 tw.addNewComponent(this, okButton, KSD_OK_BUTTON, |
2098 tw.addNewComponent(this, okButton, KSD_OK_BUTTON, |
1820 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL); |
2099 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL); |
1821 |
2100 |
1822 // cancel button |
2101 // cancel button |
1823 Button cancelButton = new Button(PolicyTool.rb.getString("Cancel")); |
2102 JButton cancelButton = new JButton(PolicyTool.getMessage("Cancel")); |
1824 cancelButton.addActionListener(new CancelButtonListener(this)); |
2103 ActionListener cancelListener = new CancelButtonListener(this); |
|
2104 cancelButton.addActionListener(cancelListener); |
1825 tw.addNewComponent(this, cancelButton, KSD_CANCEL_BUTTON, |
2105 tw.addNewComponent(this, cancelButton, KSD_CANCEL_BUTTON, |
1826 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL); |
2106 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL); |
1827 |
2107 |
1828 } |
2108 getRootPane().setDefaultButton(okButton); |
|
2109 getRootPane().registerKeyboardAction(cancelListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW); |
|
2110 } |
|
2111 |
|
2112 pack(); |
|
2113 setLocationRelativeTo(tw); |
1829 setVisible(true); |
2114 setVisible(true); |
1830 } |
2115 } |
1831 |
2116 |
1832 /** |
2117 /** |
1833 * display a dialog box for the user to input Principal info |
2118 * display a dialog box for the user to input Principal info |
1849 if (edit) { |
2134 if (edit) { |
1850 editMe = (PolicyParser.PrincipalEntry)prinList.getObject(prinIndex); |
2135 editMe = (PolicyParser.PrincipalEntry)prinList.getObject(prinIndex); |
1851 } |
2136 } |
1852 |
2137 |
1853 ToolDialog newTD = new ToolDialog |
2138 ToolDialog newTD = new ToolDialog |
1854 (PolicyTool.rb.getString("Principals"), tool, tw, true); |
2139 (PolicyTool.getMessage("Principals"), tool, tw, true); |
1855 newTD.addWindowListener(new ChildWindowListener(newTD)); |
2140 newTD.addWindowListener(new ChildWindowListener(newTD)); |
1856 |
2141 |
1857 // find where the PolicyTool gui is |
2142 // find where the PolicyTool gui is |
1858 Point location = getLocationOnScreen(); |
2143 Point location = getLocationOnScreen(); |
1859 newTD.setBounds(location.x + 50, location.y + 100, 650, 190); |
2144 //newTD.setBounds(location.x + 50, location.y + 100, 650, 190); |
1860 newTD.setLayout(new GridBagLayout()); |
2145 newTD.setLayout(new GridBagLayout()); |
1861 newTD.setResizable(true); |
2146 newTD.setResizable(true); |
1862 |
2147 |
1863 // description label |
2148 // description label |
1864 Label label = (edit ? |
2149 JLabel label = (edit ? |
1865 new Label(PolicyTool.rb.getString(".Edit.Principal.")) : |
2150 new JLabel(PolicyTool.getMessage(".Edit.Principal.")) : |
1866 new Label(PolicyTool.rb.getString(".Add.New.Principal."))); |
2151 new JLabel(PolicyTool.getMessage(".Add.New.Principal."))); |
1867 tw.addNewComponent(newTD, label, PRD_DESC_LABEL, |
2152 tw.addNewComponent(newTD, label, PRD_DESC_LABEL, |
1868 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2153 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
1869 ToolWindow.TOP_BOTTOM_PADDING); |
2154 ToolWindow.TOP_BOTTOM_PADDING); |
1870 |
2155 |
1871 // principal choice |
2156 // principal choice |
1872 Choice choice = new Choice(); |
2157 JComboBox choice = new JComboBox(); |
1873 choice.add(PRIN_TYPE); |
2158 choice.addItem(PRIN_TYPE); |
1874 choice.getAccessibleContext().setAccessibleName(PRIN_TYPE); |
2159 choice.getAccessibleContext().setAccessibleName(PRIN_TYPE); |
1875 for (int i = 0; i < PRIN_ARRAY.size(); i++) { |
2160 for (int i = 0; i < PRIN_ARRAY.size(); i++) { |
1876 Prin next = PRIN_ARRAY.get(i); |
2161 Prin next = PRIN_ARRAY.get(i); |
1877 choice.add(next.CLASS); |
2162 choice.addItem(next.CLASS); |
1878 } |
2163 } |
1879 |
2164 |
1880 choice.addItemListener(new PrincipalTypeMenuListener(newTD)); |
|
1881 if (edit) { |
2165 if (edit) { |
1882 if (PolicyParser.PrincipalEntry.WILDCARD_CLASS.equals |
2166 if (PolicyParser.PrincipalEntry.WILDCARD_CLASS.equals |
1883 (editMe.getPrincipalClass())) { |
2167 (editMe.getPrincipalClass())) { |
1884 choice.select(PRIN_TYPE); |
2168 choice.setSelectedItem(PRIN_TYPE); |
1885 } else { |
2169 } else { |
1886 Prin inputPrin = getPrin(editMe.getPrincipalClass(), true); |
2170 Prin inputPrin = getPrin(editMe.getPrincipalClass(), true); |
1887 if (inputPrin != null) { |
2171 if (inputPrin != null) { |
1888 choice.select(inputPrin.CLASS); |
2172 choice.setSelectedItem(inputPrin.CLASS); |
1889 } |
2173 } |
1890 } |
2174 } |
1891 } |
2175 } |
|
2176 // Add listener after selected item is set |
|
2177 choice.addItemListener(new PrincipalTypeMenuListener(newTD)); |
1892 |
2178 |
1893 tw.addNewComponent(newTD, choice, PRD_PRIN_CHOICE, |
2179 tw.addNewComponent(newTD, choice, PRD_PRIN_CHOICE, |
1894 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2180 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
1895 ToolWindow.LR_PADDING); |
2181 ToolWindow.LR_PADDING); |
1896 |
2182 |
1897 // principal textfield |
2183 // principal textfield |
1898 TextField tf; |
2184 JTextField tf; |
1899 tf = (edit ? |
2185 tf = (edit ? |
1900 new TextField(editMe.getDisplayClass(), 30) : |
2186 new JTextField(editMe.getDisplayClass(), 30) : |
1901 new TextField(30)); |
2187 new JTextField(30)); |
|
2188 tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
1902 tf.getAccessibleContext().setAccessibleName(PRIN_TYPE); |
2189 tf.getAccessibleContext().setAccessibleName(PRIN_TYPE); |
1903 tw.addNewComponent(newTD, tf, PRD_PRIN_TEXTFIELD, |
2190 tw.addNewComponent(newTD, tf, PRD_PRIN_TEXTFIELD, |
1904 1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2191 1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
1905 ToolWindow.LR_PADDING); |
2192 ToolWindow.LR_PADDING); |
1906 |
2193 |
1907 // name label and textfield |
2194 // name label and textfield |
1908 label = new Label(PRIN_NAME); |
2195 label = new JLabel(PRIN_NAME); |
1909 tf = (edit ? |
2196 tf = (edit ? |
1910 new TextField(editMe.getDisplayName(), 40) : |
2197 new JTextField(editMe.getDisplayName(), 40) : |
1911 new TextField(40)); |
2198 new JTextField(40)); |
|
2199 tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
1912 tf.getAccessibleContext().setAccessibleName(PRIN_NAME); |
2200 tf.getAccessibleContext().setAccessibleName(PRIN_NAME); |
1913 |
2201 |
1914 tw.addNewComponent(newTD, label, PRD_NAME_LABEL, |
2202 tw.addNewComponent(newTD, label, PRD_NAME_LABEL, |
1915 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2203 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
1916 ToolWindow.LR_PADDING); |
2204 ToolWindow.LR_PADDING); |
1917 tw.addNewComponent(newTD, tf, PRD_NAME_TEXTFIELD, |
2205 tw.addNewComponent(newTD, tf, PRD_NAME_TEXTFIELD, |
1918 1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2206 1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
1919 ToolWindow.LR_PADDING); |
2207 ToolWindow.LR_PADDING); |
1920 |
2208 |
1921 // OK button |
2209 // OK button |
1922 Button okButton = new Button(PolicyTool.rb.getString("OK")); |
2210 JButton okButton = new JButton(PolicyTool.getMessage("OK")); |
1923 okButton.addActionListener( |
2211 okButton.addActionListener( |
1924 new NewPolicyPrinOKButtonListener |
2212 new NewPolicyPrinOKButtonListener |
1925 (tool, tw, this, newTD, edit)); |
2213 (tool, tw, this, newTD, edit)); |
1926 tw.addNewComponent(newTD, okButton, PRD_OK_BUTTON, |
2214 tw.addNewComponent(newTD, okButton, PRD_OK_BUTTON, |
1927 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
2215 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
1928 ToolWindow.TOP_BOTTOM_PADDING); |
2216 ToolWindow.TOP_BOTTOM_PADDING); |
1929 // cancel button |
2217 // cancel button |
1930 Button cancelButton = new Button(PolicyTool.rb.getString("Cancel")); |
2218 JButton cancelButton = new JButton(PolicyTool.getMessage("Cancel")); |
1931 cancelButton.addActionListener(new CancelButtonListener(newTD)); |
2219 ActionListener cancelListener = new CancelButtonListener(newTD); |
|
2220 cancelButton.addActionListener(cancelListener); |
1932 tw.addNewComponent(newTD, cancelButton, PRD_CANCEL_BUTTON, |
2221 tw.addNewComponent(newTD, cancelButton, PRD_CANCEL_BUTTON, |
1933 1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
2222 1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
1934 ToolWindow.TOP_BOTTOM_PADDING); |
2223 ToolWindow.TOP_BOTTOM_PADDING); |
1935 |
2224 |
|
2225 newTD.getRootPane().setDefaultButton(okButton); |
|
2226 newTD.getRootPane().registerKeyboardAction(cancelListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW); |
|
2227 |
|
2228 newTD.pack(); |
|
2229 newTD.setLocationRelativeTo(tw); |
1936 newTD.setVisible(true); |
2230 newTD.setVisible(true); |
1937 } |
2231 } |
1938 |
2232 |
1939 /** |
2233 /** |
1940 * display a dialog box for the user to input Permission info |
2234 * display a dialog box for the user to input Permission info |
1956 if (edit) { |
2250 if (edit) { |
1957 editMe = (PolicyParser.PermissionEntry)permList.getObject(permIndex); |
2251 editMe = (PolicyParser.PermissionEntry)permList.getObject(permIndex); |
1958 } |
2252 } |
1959 |
2253 |
1960 ToolDialog newTD = new ToolDialog |
2254 ToolDialog newTD = new ToolDialog |
1961 (PolicyTool.rb.getString("Permissions"), tool, tw, true); |
2255 (PolicyTool.getMessage("Permissions"), tool, tw, true); |
1962 newTD.addWindowListener(new ChildWindowListener(newTD)); |
2256 newTD.addWindowListener(new ChildWindowListener(newTD)); |
1963 |
2257 |
1964 // find where the PolicyTool gui is |
2258 // find where the PolicyTool gui is |
1965 Point location = getLocationOnScreen(); |
2259 Point location = getLocationOnScreen(); |
1966 newTD.setBounds(location.x + 50, location.y + 100, 700, 250); |
2260 //newTD.setBounds(location.x + 50, location.y + 100, 700, 250); |
1967 newTD.setLayout(new GridBagLayout()); |
2261 newTD.setLayout(new GridBagLayout()); |
1968 newTD.setResizable(true); |
2262 newTD.setResizable(true); |
1969 |
2263 |
1970 // description label |
2264 // description label |
1971 Label label = (edit ? |
2265 JLabel label = (edit ? |
1972 new Label(PolicyTool.rb.getString(".Edit.Permission.")) : |
2266 new JLabel(PolicyTool.getMessage(".Edit.Permission.")) : |
1973 new Label(PolicyTool.rb.getString(".Add.New.Permission."))); |
2267 new JLabel(PolicyTool.getMessage(".Add.New.Permission."))); |
1974 tw.addNewComponent(newTD, label, PD_DESC_LABEL, |
2268 tw.addNewComponent(newTD, label, PD_DESC_LABEL, |
1975 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2269 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
1976 ToolWindow.TOP_BOTTOM_PADDING); |
2270 ToolWindow.TOP_BOTTOM_PADDING); |
1977 |
2271 |
1978 // permission choice (added in alphabetical order) |
2272 // permission choice (added in alphabetical order) |
1979 Choice choice = new Choice(); |
2273 JComboBox choice = new JComboBox(); |
1980 choice.add(PERM); |
2274 choice.addItem(PERM); |
1981 choice.getAccessibleContext().setAccessibleName(PERM); |
2275 choice.getAccessibleContext().setAccessibleName(PERM); |
1982 for (int i = 0; i < PERM_ARRAY.size(); i++) { |
2276 for (int i = 0; i < PERM_ARRAY.size(); i++) { |
1983 Perm next = PERM_ARRAY.get(i); |
2277 Perm next = PERM_ARRAY.get(i); |
1984 choice.add(next.CLASS); |
2278 choice.addItem(next.CLASS); |
1985 } |
2279 } |
1986 choice.addItemListener(new PermissionMenuListener(newTD)); |
|
1987 tw.addNewComponent(newTD, choice, PD_PERM_CHOICE, |
2280 tw.addNewComponent(newTD, choice, PD_PERM_CHOICE, |
1988 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2281 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
1989 ToolWindow.LR_PADDING); |
2282 ToolWindow.LR_BOTTOM_PADDING); |
1990 |
2283 |
1991 // permission textfield |
2284 // permission textfield |
1992 TextField tf; |
2285 JTextField tf; |
1993 tf = (edit ? new TextField(editMe.permission, 30) : new TextField(30)); |
2286 tf = (edit ? new JTextField(editMe.permission, 30) : new JTextField(30)); |
|
2287 tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
1994 tf.getAccessibleContext().setAccessibleName(PERM); |
2288 tf.getAccessibleContext().setAccessibleName(PERM); |
1995 if (edit) { |
2289 if (edit) { |
1996 Perm inputPerm = getPerm(editMe.permission, true); |
2290 Perm inputPerm = getPerm(editMe.permission, true); |
1997 if (inputPerm != null) { |
2291 if (inputPerm != null) { |
1998 choice.select(inputPerm.CLASS); |
2292 choice.setSelectedItem(inputPerm.CLASS); |
1999 } |
2293 } |
2000 } |
2294 } |
2001 tw.addNewComponent(newTD, tf, PD_PERM_TEXTFIELD, |
2295 tw.addNewComponent(newTD, tf, PD_PERM_TEXTFIELD, |
2002 1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2296 1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
2003 ToolWindow.LR_PADDING); |
2297 ToolWindow.LR_BOTTOM_PADDING); |
|
2298 choice.addItemListener(new PermissionMenuListener(newTD)); |
2004 |
2299 |
2005 // name label and textfield |
2300 // name label and textfield |
2006 choice = new Choice(); |
2301 choice = new JComboBox(); |
2007 choice.add(PERM_NAME); |
2302 choice.addItem(PERM_NAME); |
2008 choice.getAccessibleContext().setAccessibleName(PERM_NAME); |
2303 choice.getAccessibleContext().setAccessibleName(PERM_NAME); |
2009 choice.addItemListener(new PermissionNameMenuListener(newTD)); |
2304 tf = (edit ? new JTextField(editMe.name, 40) : new JTextField(40)); |
2010 tf = (edit ? new TextField(editMe.name, 40) : new TextField(40)); |
2305 tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
2011 tf.getAccessibleContext().setAccessibleName(PERM_NAME); |
2306 tf.getAccessibleContext().setAccessibleName(PERM_NAME); |
2012 if (edit) { |
2307 if (edit) { |
2013 setPermissionNames(getPerm(editMe.permission, true), choice, tf); |
2308 setPermissionNames(getPerm(editMe.permission, true), choice, tf); |
2014 } |
2309 } |
2015 tw.addNewComponent(newTD, choice, PD_NAME_CHOICE, |
2310 tw.addNewComponent(newTD, choice, PD_NAME_CHOICE, |
2016 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2311 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2017 ToolWindow.LR_PADDING); |
2312 ToolWindow.LR_BOTTOM_PADDING); |
2018 tw.addNewComponent(newTD, tf, PD_NAME_TEXTFIELD, |
2313 tw.addNewComponent(newTD, tf, PD_NAME_TEXTFIELD, |
2019 1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2314 1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
2020 ToolWindow.LR_PADDING); |
2315 ToolWindow.LR_BOTTOM_PADDING); |
|
2316 choice.addItemListener(new PermissionNameMenuListener(newTD)); |
2021 |
2317 |
2022 // actions label and textfield |
2318 // actions label and textfield |
2023 choice = new Choice(); |
2319 choice = new JComboBox(); |
2024 choice.add(PERM_ACTIONS); |
2320 choice.addItem(PERM_ACTIONS); |
2025 choice.getAccessibleContext().setAccessibleName(PERM_ACTIONS); |
2321 choice.getAccessibleContext().setAccessibleName(PERM_ACTIONS); |
2026 choice.addItemListener(new PermissionActionsMenuListener(newTD)); |
2322 tf = (edit ? new JTextField(editMe.action, 40) : new JTextField(40)); |
2027 tf = (edit ? new TextField(editMe.action, 40) : new TextField(40)); |
2323 tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
2028 tf.getAccessibleContext().setAccessibleName(PERM_ACTIONS); |
2324 tf.getAccessibleContext().setAccessibleName(PERM_ACTIONS); |
2029 if (edit) { |
2325 if (edit) { |
2030 setPermissionActions(getPerm(editMe.permission, true), choice, tf); |
2326 setPermissionActions(getPerm(editMe.permission, true), choice, tf); |
2031 } |
2327 } |
2032 tw.addNewComponent(newTD, choice, PD_ACTIONS_CHOICE, |
2328 tw.addNewComponent(newTD, choice, PD_ACTIONS_CHOICE, |
2033 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2329 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2034 ToolWindow.LR_PADDING); |
2330 ToolWindow.LR_BOTTOM_PADDING); |
2035 tw.addNewComponent(newTD, tf, PD_ACTIONS_TEXTFIELD, |
2331 tw.addNewComponent(newTD, tf, PD_ACTIONS_TEXTFIELD, |
2036 1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2332 1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
2037 ToolWindow.LR_PADDING); |
2333 ToolWindow.LR_BOTTOM_PADDING); |
|
2334 choice.addItemListener(new PermissionActionsMenuListener(newTD)); |
2038 |
2335 |
2039 // signedby label and textfield |
2336 // signedby label and textfield |
2040 label = new Label(PolicyTool.rb.getString("Signed.By.")); |
2337 label = new JLabel(PolicyTool.getMessage("Signed.By.")); |
2041 tw.addNewComponent(newTD, label, PD_SIGNEDBY_LABEL, |
2338 tw.addNewComponent(newTD, label, PD_SIGNEDBY_LABEL, |
2042 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2339 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2043 ToolWindow.LR_PADDING); |
2340 ToolWindow.LR_BOTTOM_PADDING); |
2044 tf = (edit ? new TextField(editMe.signedBy, 40) : new TextField(40)); |
2341 tf = (edit ? new JTextField(editMe.signedBy, 40) : new JTextField(40)); |
|
2342 tf.setPreferredSize(new Dimension(tf.getPreferredSize().width, TEXTFIELD_HEIGHT)); |
2045 tf.getAccessibleContext().setAccessibleName( |
2343 tf.getAccessibleContext().setAccessibleName( |
2046 PolicyTool.rb.getString("Signed.By.")); |
2344 PolicyTool.getMessage("Signed.By.")); |
2047 tw.addNewComponent(newTD, tf, PD_SIGNEDBY_TEXTFIELD, |
2345 tw.addNewComponent(newTD, tf, PD_SIGNEDBY_TEXTFIELD, |
2048 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2346 1, 4, 1, 1, 1.0, 0.0, GridBagConstraints.BOTH, |
2049 ToolWindow.LR_PADDING); |
2347 ToolWindow.LR_BOTTOM_PADDING); |
2050 |
2348 |
2051 // OK button |
2349 // OK button |
2052 Button okButton = new Button(PolicyTool.rb.getString("OK")); |
2350 JButton okButton = new JButton(PolicyTool.getMessage("OK")); |
2053 okButton.addActionListener( |
2351 okButton.addActionListener( |
2054 new NewPolicyPermOKButtonListener |
2352 new NewPolicyPermOKButtonListener |
2055 (tool, tw, this, newTD, edit)); |
2353 (tool, tw, this, newTD, edit)); |
2056 tw.addNewComponent(newTD, okButton, PD_OK_BUTTON, |
2354 tw.addNewComponent(newTD, okButton, PD_OK_BUTTON, |
2057 0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
2355 0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
2058 ToolWindow.TOP_BOTTOM_PADDING); |
2356 ToolWindow.TOP_BOTTOM_PADDING); |
2059 |
2357 |
2060 // cancel button |
2358 // cancel button |
2061 Button cancelButton = new Button(PolicyTool.rb.getString("Cancel")); |
2359 JButton cancelButton = new JButton(PolicyTool.getMessage("Cancel")); |
2062 cancelButton.addActionListener(new CancelButtonListener(newTD)); |
2360 ActionListener cancelListener = new CancelButtonListener(newTD); |
|
2361 cancelButton.addActionListener(cancelListener); |
2063 tw.addNewComponent(newTD, cancelButton, PD_CANCEL_BUTTON, |
2362 tw.addNewComponent(newTD, cancelButton, PD_CANCEL_BUTTON, |
2064 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
2363 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL, |
2065 ToolWindow.TOP_BOTTOM_PADDING); |
2364 ToolWindow.TOP_BOTTOM_PADDING); |
2066 |
2365 |
|
2366 newTD.getRootPane().setDefaultButton(okButton); |
|
2367 newTD.getRootPane().registerKeyboardAction(cancelListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW); |
|
2368 |
|
2369 newTD.pack(); |
|
2370 newTD.setLocationRelativeTo(tw); |
2067 newTD.setVisible(true); |
2371 newTD.setVisible(true); |
2068 } |
2372 } |
2069 |
2373 |
2070 /** |
2374 /** |
2071 * construct a Principal object from the Principal Info Dialog Box |
2375 * construct a Principal object from the Principal Info Dialog Box |
2072 */ |
2376 */ |
2073 PolicyParser.PrincipalEntry getPrinFromDialog() throws Exception { |
2377 PolicyParser.PrincipalEntry getPrinFromDialog() throws Exception { |
2074 |
2378 |
2075 TextField tf = (TextField)getComponent(PRD_PRIN_TEXTFIELD); |
2379 JTextField tf = (JTextField)getComponent(PRD_PRIN_TEXTFIELD); |
2076 String pclass = new String(tf.getText().trim()); |
2380 String pclass = new String(tf.getText().trim()); |
2077 tf = (TextField)getComponent(PRD_NAME_TEXTFIELD); |
2381 tf = (JTextField)getComponent(PRD_NAME_TEXTFIELD); |
2078 String pname = new String(tf.getText().trim()); |
2382 String pname = new String(tf.getText().trim()); |
2079 if (pclass.equals("*")) { |
2383 if (pclass.equals("*")) { |
2080 pclass = PolicyParser.PrincipalEntry.WILDCARD_CLASS; |
2384 pclass = PolicyParser.PrincipalEntry.WILDCARD_CLASS; |
2081 } |
2385 } |
2082 if (pname.equals("*")) { |
2386 if (pname.equals("*")) { |
2207 * confirm that the user REALLY wants to remove the Policy Entry |
2511 * confirm that the user REALLY wants to remove the Policy Entry |
2208 */ |
2512 */ |
2209 void displayConfirmRemovePolicyEntry() { |
2513 void displayConfirmRemovePolicyEntry() { |
2210 |
2514 |
2211 // find the entry to be removed |
2515 // find the entry to be removed |
2212 List list = (List)tw.getComponent(ToolWindow.MW_POLICY_LIST); |
2516 JList list = (JList)tw.getComponent(ToolWindow.MW_POLICY_LIST); |
2213 int index = list.getSelectedIndex(); |
2517 int index = list.getSelectedIndex(); |
2214 PolicyEntry entries[] = tool.getEntry(); |
2518 PolicyEntry entries[] = tool.getEntry(); |
2215 |
2519 |
2216 // find where the PolicyTool gui is |
2520 // find where the PolicyTool gui is |
2217 Point location = tw.getLocationOnScreen(); |
2521 Point location = tw.getLocationOnScreen(); |
2218 setBounds(location.x + 25, location.y + 100, 600, 400); |
2522 //setBounds(location.x + 25, location.y + 100, 600, 400); |
2219 setLayout(new GridBagLayout()); |
2523 setLayout(new GridBagLayout()); |
2220 |
2524 |
2221 // ask the user do they really want to do this? |
2525 // ask the user do they really want to do this? |
2222 Label label = new Label |
2526 JLabel label = new JLabel |
2223 (PolicyTool.rb.getString("Remove.this.Policy.Entry.")); |
2527 (PolicyTool.getMessage("Remove.this.Policy.Entry.")); |
2224 tw.addNewComponent(this, label, CRPE_LABEL1, |
2528 tw.addNewComponent(this, label, CRPE_LABEL1, |
2225 0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2529 0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2226 ToolWindow.BOTTOM_PADDING); |
2530 ToolWindow.BOTTOM_PADDING); |
2227 |
2531 |
2228 // display the policy entry |
2532 // display the policy entry |
2229 label = new Label(entries[index].codebaseToString()); |
2533 label = new JLabel(entries[index].codebaseToString()); |
2230 tw.addNewComponent(this, label, CRPE_LABEL2, |
2534 tw.addNewComponent(this, label, CRPE_LABEL2, |
2231 0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
2535 0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
2232 label = new Label(entries[index].principalsToString().trim()); |
2536 label = new JLabel(entries[index].principalsToString().trim()); |
2233 tw.addNewComponent(this, label, CRPE_LABEL2+1, |
2537 tw.addNewComponent(this, label, CRPE_LABEL2+1, |
2234 0, 2, 2, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
2538 0, 2, 2, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
2235 Vector<PolicyParser.PermissionEntry> perms = |
2539 Vector<PolicyParser.PermissionEntry> perms = |
2236 entries[index].getGrantEntry().permissionEntries; |
2540 entries[index].getGrantEntry().permissionEntries; |
2237 for (int i = 0; i < perms.size(); i++) { |
2541 for (int i = 0; i < perms.size(); i++) { |
2238 PolicyParser.PermissionEntry nextPerm = perms.elementAt(i); |
2542 PolicyParser.PermissionEntry nextPerm = perms.elementAt(i); |
2239 String permString = ToolDialog.PermissionEntryToUserFriendlyString(nextPerm); |
2543 String permString = ToolDialog.PermissionEntryToUserFriendlyString(nextPerm); |
2240 label = new Label(" " + permString); |
2544 label = new JLabel(" " + permString); |
2241 if (i == (perms.size()-1)) { |
2545 if (i == (perms.size()-1)) { |
2242 tw.addNewComponent(this, label, CRPE_LABEL2 + 2 + i, |
2546 tw.addNewComponent(this, label, CRPE_LABEL2 + 2 + i, |
2243 1, 3 + i, 1, 1, 0.0, 0.0, |
2547 1, 3 + i, 1, 1, 0.0, 0.0, |
2244 GridBagConstraints.BOTH, |
2548 GridBagConstraints.BOTH, |
2245 ToolWindow.BOTTOM_PADDING); |
2549 ToolWindow.BOTTOM_PADDING); |
2250 } |
2554 } |
2251 } |
2555 } |
2252 |
2556 |
2253 |
2557 |
2254 // add OK/CANCEL buttons in a new panel |
2558 // add OK/CANCEL buttons in a new panel |
2255 Panel panel = new Panel(); |
2559 JPanel panel = new JPanel(); |
2256 panel.setLayout(new GridBagLayout()); |
2560 panel.setLayout(new GridBagLayout()); |
2257 |
2561 |
2258 // OK button |
2562 // OK button |
2259 Button okButton = new Button(PolicyTool.rb.getString("OK")); |
2563 JButton okButton = new JButton(PolicyTool.getMessage("OK")); |
2260 okButton.addActionListener |
2564 okButton.addActionListener |
2261 (new ConfirmRemovePolicyEntryOKButtonListener(tool, tw, this)); |
2565 (new ConfirmRemovePolicyEntryOKButtonListener(tool, tw, this)); |
2262 tw.addNewComponent(panel, okButton, CRPE_PANEL_OK, |
2566 tw.addNewComponent(panel, okButton, CRPE_PANEL_OK, |
2263 0, 0, 1, 1, 0.0, 0.0, |
2567 0, 0, 1, 1, 0.0, 0.0, |
2264 GridBagConstraints.VERTICAL, ToolWindow.LR_PADDING); |
2568 GridBagConstraints.VERTICAL, ToolWindow.LR_PADDING); |
2265 |
2569 |
2266 // cancel button |
2570 // cancel button |
2267 Button cancelButton = new Button(PolicyTool.rb.getString("Cancel")); |
2571 JButton cancelButton = new JButton(PolicyTool.getMessage("Cancel")); |
2268 cancelButton.addActionListener(new CancelButtonListener(this)); |
2572 ActionListener cancelListener = new CancelButtonListener(this); |
|
2573 cancelButton.addActionListener(cancelListener); |
2269 tw.addNewComponent(panel, cancelButton, CRPE_PANEL_CANCEL, |
2574 tw.addNewComponent(panel, cancelButton, CRPE_PANEL_CANCEL, |
2270 1, 0, 1, 1, 0.0, 0.0, |
2575 1, 0, 1, 1, 0.0, 0.0, |
2271 GridBagConstraints.VERTICAL, ToolWindow.LR_PADDING); |
2576 GridBagConstraints.VERTICAL, ToolWindow.LR_PADDING); |
2272 |
2577 |
2273 tw.addNewComponent(this, panel, CRPE_LABEL2 + 2 + perms.size(), |
2578 tw.addNewComponent(this, panel, CRPE_LABEL2 + 2 + perms.size(), |
2274 0, 3 + perms.size(), 2, 1, 0.0, 0.0, |
2579 0, 3 + perms.size(), 2, 1, 0.0, 0.0, |
2275 GridBagConstraints.VERTICAL, ToolWindow.TOP_BOTTOM_PADDING); |
2580 GridBagConstraints.VERTICAL, ToolWindow.TOP_BOTTOM_PADDING); |
2276 |
2581 |
|
2582 getRootPane().setDefaultButton(okButton); |
|
2583 getRootPane().registerKeyboardAction(cancelListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW); |
|
2584 |
2277 pack(); |
2585 pack(); |
|
2586 setLocationRelativeTo(tw); |
2278 setVisible(true); |
2587 setVisible(true); |
2279 } |
2588 } |
2280 |
2589 |
2281 /** |
2590 /** |
2282 * perform SAVE AS |
2591 * perform SAVE AS |
2283 */ |
2592 */ |
2284 void displaySaveAsDialog(int nextEvent) { |
2593 void displaySaveAsDialog(int nextEvent) { |
2285 |
2594 |
2286 // pop up a dialog box for the user to enter a filename. |
2595 // pop up a dialog box for the user to enter a filename. |
2287 FileDialog fd = new FileDialog |
2596 FileDialog fd = new FileDialog |
2288 (tw, PolicyTool.rb.getString("Save.As"), FileDialog.SAVE); |
2597 (tw, PolicyTool.getMessage("Save.As"), FileDialog.SAVE); |
2289 fd.addWindowListener(new WindowAdapter() { |
2598 fd.addWindowListener(new WindowAdapter() { |
2290 public void windowClosing(WindowEvent e) { |
2599 public void windowClosing(WindowEvent e) { |
2291 e.getWindow().setVisible(false); |
2600 e.getWindow().setVisible(false); |
2292 } |
2601 } |
2293 }); |
2602 }); |
2342 |
2651 |
2343 if (tool.modified == true) { |
2652 if (tool.modified == true) { |
2344 |
2653 |
2345 // find where the PolicyTool gui is |
2654 // find where the PolicyTool gui is |
2346 Point location = tw.getLocationOnScreen(); |
2655 Point location = tw.getLocationOnScreen(); |
2347 setBounds(location.x + 75, location.y + 100, 400, 150); |
2656 //setBounds(location.x + 75, location.y + 100, 400, 150); |
2348 setLayout(new GridBagLayout()); |
2657 setLayout(new GridBagLayout()); |
2349 |
2658 |
2350 Label label = new Label |
2659 JLabel label = new JLabel |
2351 (PolicyTool.rb.getString("Save.changes.")); |
2660 (PolicyTool.getMessage("Save.changes.")); |
2352 tw.addNewComponent(this, label, USC_LABEL, |
2661 tw.addNewComponent(this, label, USC_LABEL, |
2353 0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2662 0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.BOTH, |
2354 ToolWindow.L_TOP_BOTTOM_PADDING); |
2663 ToolWindow.L_TOP_BOTTOM_PADDING); |
2355 |
2664 |
2356 Panel panel = new Panel(); |
2665 JPanel panel = new JPanel(); |
2357 panel.setLayout(new GridBagLayout()); |
2666 panel.setLayout(new GridBagLayout()); |
2358 |
2667 |
2359 Button yesButton = new Button(PolicyTool.rb.getString("Yes")); |
2668 JButton yesButton = new JButton(); |
|
2669 ToolWindow.configureButton(yesButton, "Yes"); |
2360 yesButton.addActionListener |
2670 yesButton.addActionListener |
2361 (new UserSaveYesButtonListener(this, tool, tw, select)); |
2671 (new UserSaveYesButtonListener(this, tool, tw, select)); |
2362 tw.addNewComponent(panel, yesButton, USC_YES_BUTTON, |
2672 tw.addNewComponent(panel, yesButton, USC_YES_BUTTON, |
2363 0, 0, 1, 1, 0.0, 0.0, |
2673 0, 0, 1, 1, 0.0, 0.0, |
2364 GridBagConstraints.VERTICAL, |
2674 GridBagConstraints.VERTICAL, |
2365 ToolWindow.LR_BOTTOM_PADDING); |
2675 ToolWindow.LR_BOTTOM_PADDING); |
2366 Button noButton = new Button(PolicyTool.rb.getString("No")); |
2676 JButton noButton = new JButton(); |
|
2677 ToolWindow.configureButton(noButton, "No"); |
2367 noButton.addActionListener |
2678 noButton.addActionListener |
2368 (new UserSaveNoButtonListener(this, tool, tw, select)); |
2679 (new UserSaveNoButtonListener(this, tool, tw, select)); |
2369 tw.addNewComponent(panel, noButton, USC_NO_BUTTON, |
2680 tw.addNewComponent(panel, noButton, USC_NO_BUTTON, |
2370 1, 0, 1, 1, 0.0, 0.0, |
2681 1, 0, 1, 1, 0.0, 0.0, |
2371 GridBagConstraints.VERTICAL, |
2682 GridBagConstraints.VERTICAL, |
2372 ToolWindow.LR_BOTTOM_PADDING); |
2683 ToolWindow.LR_BOTTOM_PADDING); |
2373 Button cancelButton = new Button(PolicyTool.rb.getString("Cancel")); |
2684 JButton cancelButton = new JButton(); |
2374 cancelButton.addActionListener |
2685 ToolWindow.configureButton(cancelButton, "Cancel"); |
2375 (new UserSaveCancelButtonListener(this)); |
2686 ActionListener cancelListener = new CancelButtonListener(this); |
|
2687 cancelButton.addActionListener(cancelListener); |
2376 tw.addNewComponent(panel, cancelButton, USC_CANCEL_BUTTON, |
2688 tw.addNewComponent(panel, cancelButton, USC_CANCEL_BUTTON, |
2377 2, 0, 1, 1, 0.0, 0.0, |
2689 2, 0, 1, 1, 0.0, 0.0, |
2378 GridBagConstraints.VERTICAL, |
2690 GridBagConstraints.VERTICAL, |
2379 ToolWindow.LR_BOTTOM_PADDING); |
2691 ToolWindow.LR_BOTTOM_PADDING); |
2380 |
2692 |
2381 tw.addNewComponent(this, panel, USC_PANEL, |
2693 tw.addNewComponent(this, panel, USC_PANEL, |
2382 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
2694 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH); |
2383 |
2695 |
|
2696 getRootPane().registerKeyboardAction(cancelListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW); |
|
2697 |
2384 pack(); |
2698 pack(); |
|
2699 setLocationRelativeTo(tw); |
2385 setVisible(true); |
2700 setVisible(true); |
2386 } else { |
2701 } else { |
2387 // just do the original request (QUIT, NEW, or OPEN) |
2702 // just do the original request (QUIT, NEW, or OPEN) |
2388 userSaveContinue(tool, tw, this, select); |
2703 userSaveContinue(tool, tw, this, select); |
2389 } |
2704 } |
2452 try { |
2769 try { |
2453 // open the policy file |
2770 // open the policy file |
2454 tool.openPolicy(policyFile); |
2771 tool.openPolicy(policyFile); |
2455 |
2772 |
2456 // display the policy entries via the policy list textarea |
2773 // display the policy entries via the policy list textarea |
2457 list = new List(40, false); |
2774 DefaultListModel listModel = new DefaultListModel(); |
2458 list.addActionListener(new PolicyListListener(tool, tw)); |
2775 list = new JList(listModel); |
|
2776 list.setVisibleRowCount(15); |
|
2777 list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
|
2778 list.addMouseListener(new PolicyListListener(tool, tw)); |
2459 PolicyEntry entries[] = tool.getEntry(); |
2779 PolicyEntry entries[] = tool.getEntry(); |
2460 if (entries != null) { |
2780 if (entries != null) { |
2461 for (int i = 0; i < entries.length; i++) |
2781 for (int i = 0; i < entries.length; i++) { |
2462 list.add(entries[i].headerToString()); |
2782 listModel.addElement(entries[i].headerToString()); |
|
2783 } |
2463 } |
2784 } |
2464 tw.replacePolicyList(list); |
2785 tw.replacePolicyList(list); |
2465 tool.modified = false; |
2786 tool.modified = false; |
2466 |
2787 |
2467 // display the new policy filename |
2788 // display the new policy filename |
2468 newFilename = (TextField)tw.getComponent( |
2789 newFilename = (JTextField)tw.getComponent( |
2469 ToolWindow.MW_FILENAME_TEXTFIELD); |
2790 ToolWindow.MW_FILENAME_TEXTFIELD); |
2470 newFilename.setText(policyFile); |
2791 newFilename.setText(policyFile); |
2471 tw.setVisible(true); |
2792 tw.setVisible(true); |
2472 |
2793 |
2473 // inform user of warnings |
2794 // inform user of warnings |
2474 if (tool.newWarning == true) { |
2795 if (tool.newWarning == true) { |
2475 tw.displayStatusDialog(null, PolicyTool.rb.getString |
2796 tw.displayStatusDialog(null, PolicyTool.getMessage |
2476 ("Errors.have.occurred.while.opening.the.policy.configuration.View.the.Warning.Log.for.more.information.")); |
2797 ("Errors.have.occurred.while.opening.the.policy.configuration.View.the.Warning.Log.for.more.information.")); |
2477 } |
2798 } |
2478 |
2799 |
2479 } catch (Exception e) { |
2800 } catch (Exception e) { |
2480 // add blank policy listing |
2801 // add blank policy listing |
2481 list = new List(40, false); |
2802 list = new JList(new DefaultListModel()); |
2482 list.addActionListener(new PolicyListListener(tool, tw)); |
2803 list.setVisibleRowCount(15); |
|
2804 list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
|
2805 list.addMouseListener(new PolicyListListener(tool, tw)); |
2483 tw.replacePolicyList(list); |
2806 tw.replacePolicyList(list); |
2484 tool.setPolicyFileName(null); |
2807 tool.setPolicyFileName(null); |
2485 tool.modified = false; |
2808 tool.modified = false; |
2486 |
2809 |
2487 // display a null policy filename |
2810 // display a null policy filename |
2488 newFilename = (TextField)tw.getComponent( |
2811 newFilename = (JTextField)tw.getComponent( |
2489 ToolWindow.MW_FILENAME_TEXTFIELD); |
2812 ToolWindow.MW_FILENAME_TEXTFIELD); |
2490 newFilename.setText(""); |
2813 newFilename.setText(""); |
2491 tw.setVisible(true); |
2814 tw.setVisible(true); |
2492 |
2815 |
2493 // display the error |
2816 // display the error |
2494 MessageFormat form = new MessageFormat(PolicyTool.rb.getString |
2817 MessageFormat form = new MessageFormat(PolicyTool.getMessage |
2495 ("Could.not.open.policy.file.policyFile.e.toString.")); |
2818 ("Could.not.open.policy.file.policyFile.e.toString.")); |
2496 Object[] source = {policyFile, e.toString()}; |
2819 Object[] source = {policyFile, e.toString()}; |
2497 tw.displayErrorDialog(null, form.format(source)); |
2820 tw.displayErrorDialog(null, form.format(source)); |
2498 } |
2821 } |
2499 break; |
2822 break; |
2667 if (PolicyTool.collator.compare(e.getActionCommand(), |
2996 if (PolicyTool.collator.compare(e.getActionCommand(), |
2668 ToolWindow.QUIT) == 0) { |
2997 ToolWindow.QUIT) == 0) { |
2669 |
2998 |
2670 // ask user if they want to save changes |
2999 // ask user if they want to save changes |
2671 ToolDialog td = new ToolDialog |
3000 ToolDialog td = new ToolDialog |
2672 (PolicyTool.rb.getString("Save.Changes"), tool, tw, true); |
3001 (PolicyTool.getMessage("Save.Changes"), tool, tw, true); |
2673 td.displayUserSave(ToolDialog.QUIT); |
3002 td.displayUserSave(ToolDialog.QUIT); |
2674 |
3003 |
2675 // the above method will perform the QUIT as long as the |
3004 // the above method will perform the QUIT as long as the |
2676 // user does not CANCEL the request |
3005 // user does not CANCEL the request |
2677 |
3006 |
2678 } else if (PolicyTool.collator.compare(e.getActionCommand(), |
3007 } else if (PolicyTool.collator.compare(e.getActionCommand(), |
2679 ToolWindow.NEW_POLICY_FILE) == 0) { |
3008 ToolWindow.NEW_POLICY_FILE) == 0) { |
2680 |
3009 |
2681 // ask user if they want to save changes |
3010 // ask user if they want to save changes |
2682 ToolDialog td = new ToolDialog |
3011 ToolDialog td = new ToolDialog |
2683 (PolicyTool.rb.getString("Save.Changes"), tool, tw, true); |
3012 (PolicyTool.getMessage("Save.Changes"), tool, tw, true); |
2684 td.displayUserSave(ToolDialog.NEW); |
3013 td.displayUserSave(ToolDialog.NEW); |
2685 |
3014 |
2686 // the above method will perform the NEW as long as the |
3015 // the above method will perform the NEW as long as the |
2687 // user does not CANCEL the request |
3016 // user does not CANCEL the request |
2688 |
3017 |
2689 } else if (PolicyTool.collator.compare(e.getActionCommand(), |
3018 } else if (PolicyTool.collator.compare(e.getActionCommand(), |
2690 ToolWindow.OPEN_POLICY_FILE) == 0) { |
3019 ToolWindow.OPEN_POLICY_FILE) == 0) { |
2691 |
3020 |
2692 // ask user if they want to save changes |
3021 // ask user if they want to save changes |
2693 ToolDialog td = new ToolDialog |
3022 ToolDialog td = new ToolDialog |
2694 (PolicyTool.rb.getString("Save.Changes"), tool, tw, true); |
3023 (PolicyTool.getMessage("Save.Changes"), tool, tw, true); |
2695 td.displayUserSave(ToolDialog.OPEN); |
3024 td.displayUserSave(ToolDialog.OPEN); |
2696 |
3025 |
2697 // the above method will perform the OPEN as long as the |
3026 // the above method will perform the OPEN as long as the |
2698 // user does not CANCEL the request |
3027 // user does not CANCEL the request |
2699 |
3028 |
2700 } else if (PolicyTool.collator.compare(e.getActionCommand(), |
3029 } else if (PolicyTool.collator.compare(e.getActionCommand(), |
2701 ToolWindow.SAVE_POLICY_FILE) == 0) { |
3030 ToolWindow.SAVE_POLICY_FILE) == 0) { |
2702 |
3031 |
2703 // get the previously entered filename |
3032 // get the previously entered filename |
2704 String filename = ((TextField)tw.getComponent( |
3033 String filename = ((JTextField)tw.getComponent( |
2705 ToolWindow.MW_FILENAME_TEXTFIELD)).getText(); |
3034 ToolWindow.MW_FILENAME_TEXTFIELD)).getText(); |
2706 |
3035 |
2707 // if there is no filename, do a SAVE_AS |
3036 // if there is no filename, do a SAVE_AS |
2708 if (filename == null || filename.length() == 0) { |
3037 if (filename == null || filename.length() == 0) { |
2709 // user wants to SAVE AS |
3038 // user wants to SAVE AS |
2710 ToolDialog td = new ToolDialog |
3039 ToolDialog td = new ToolDialog |
2711 (PolicyTool.rb.getString("Save.As"), tool, tw, true); |
3040 (PolicyTool.getMessage("Save.As"), tool, tw, true); |
2712 td.displaySaveAsDialog(ToolDialog.NOACTION); |
3041 td.displaySaveAsDialog(ToolDialog.NOACTION); |
2713 } else { |
3042 } else { |
2714 try { |
3043 try { |
2715 // save the policy entries to a file |
3044 // save the policy entries to a file |
2716 tool.savePolicy(filename); |
3045 tool.savePolicy(filename); |
2717 |
3046 |
2718 // display status |
3047 // display status |
2719 MessageFormat form = new MessageFormat |
3048 MessageFormat form = new MessageFormat |
2720 (PolicyTool.rb.getString |
3049 (PolicyTool.getMessage |
2721 ("Policy.successfully.written.to.filename")); |
3050 ("Policy.successfully.written.to.filename")); |
2722 Object[] source = {filename}; |
3051 Object[] source = {filename}; |
2723 tw.displayStatusDialog(null, form.format(source)); |
3052 tw.displayStatusDialog(null, form.format(source)); |
2724 } catch (FileNotFoundException fnfe) { |
3053 } catch (FileNotFoundException fnfe) { |
2725 if (filename == null || filename.equals("")) { |
3054 if (filename == null || filename.equals("")) { |
2726 tw.displayErrorDialog(null, new FileNotFoundException |
3055 tw.displayErrorDialog(null, new FileNotFoundException |
2727 (PolicyTool.rb.getString("null.filename"))); |
3056 (PolicyTool.getMessage("null.filename"))); |
2728 } else { |
3057 } else { |
2729 tw.displayErrorDialog(null, fnfe); |
3058 tw.displayErrorDialog(null, fnfe); |
2730 } |
3059 } |
2731 } catch (Exception ee) { |
3060 } catch (Exception ee) { |
2732 tw.displayErrorDialog(null, ee); |
3061 tw.displayErrorDialog(null, ee); |
2765 if (PolicyTool.collator.compare(e.getActionCommand(), |
3094 if (PolicyTool.collator.compare(e.getActionCommand(), |
2766 ToolWindow.ADD_POLICY_ENTRY) == 0) { |
3095 ToolWindow.ADD_POLICY_ENTRY) == 0) { |
2767 |
3096 |
2768 // display a dialog box for the user to enter policy info |
3097 // display a dialog box for the user to enter policy info |
2769 ToolDialog td = new ToolDialog |
3098 ToolDialog td = new ToolDialog |
2770 (PolicyTool.rb.getString("Policy.Entry"), tool, tw, true); |
3099 (PolicyTool.getMessage("Policy.Entry"), tool, tw, true); |
2771 td.displayPolicyEntryDialog(false); |
3100 td.displayPolicyEntryDialog(false); |
2772 |
3101 |
2773 } else if (PolicyTool.collator.compare(e.getActionCommand(), |
3102 } else if (PolicyTool.collator.compare(e.getActionCommand(), |
2774 ToolWindow.REMOVE_POLICY_ENTRY) == 0) { |
3103 ToolWindow.REMOVE_POLICY_ENTRY) == 0) { |
2775 |
3104 |
2776 // get the selected entry |
3105 // get the selected entry |
2777 List list = (List)tw.getComponent(ToolWindow.MW_POLICY_LIST); |
3106 JList list = (JList)tw.getComponent(ToolWindow.MW_POLICY_LIST); |
2778 int index = list.getSelectedIndex(); |
3107 int index = list.getSelectedIndex(); |
2779 if (index < 0) { |
3108 if (index < 0) { |
2780 tw.displayErrorDialog(null, new Exception |
3109 tw.displayErrorDialog(null, new Exception |
2781 (PolicyTool.rb.getString("No.Policy.Entry.selected"))); |
3110 (PolicyTool.getMessage("No.Policy.Entry.selected"))); |
2782 return; |
3111 return; |
2783 } |
3112 } |
2784 |
3113 |
2785 // ask the user if they really want to remove the policy entry |
3114 // ask the user if they really want to remove the policy entry |
2786 ToolDialog td = new ToolDialog(PolicyTool.rb.getString |
3115 ToolDialog td = new ToolDialog(PolicyTool.getMessage |
2787 ("Remove.Policy.Entry"), tool, tw, true); |
3116 ("Remove.Policy.Entry"), tool, tw, true); |
2788 td.displayConfirmRemovePolicyEntry(); |
3117 td.displayConfirmRemovePolicyEntry(); |
2789 |
3118 |
2790 } else if (PolicyTool.collator.compare(e.getActionCommand(), |
3119 } else if (PolicyTool.collator.compare(e.getActionCommand(), |
2791 ToolWindow.EDIT_POLICY_ENTRY) == 0) { |
3120 ToolWindow.EDIT_POLICY_ENTRY) == 0) { |
2792 |
3121 |
2793 // get the selected entry |
3122 // get the selected entry |
2794 List list = (List)tw.getComponent(ToolWindow.MW_POLICY_LIST); |
3123 JList list = (JList)tw.getComponent(ToolWindow.MW_POLICY_LIST); |
2795 int index = list.getSelectedIndex(); |
3124 int index = list.getSelectedIndex(); |
2796 if (index < 0) { |
3125 if (index < 0) { |
2797 tw.displayErrorDialog(null, new Exception |
3126 tw.displayErrorDialog(null, new Exception |
2798 (PolicyTool.rb.getString("No.Policy.Entry.selected"))); |
3127 (PolicyTool.getMessage("No.Policy.Entry.selected"))); |
2799 return; |
3128 return; |
2800 } |
3129 } |
2801 |
3130 |
2802 // display the permission list for a policy entry |
3131 // display the permission list for a policy entry |
2803 ToolDialog td = new ToolDialog |
3132 ToolDialog td = new ToolDialog |
2804 (PolicyTool.rb.getString("Policy.Entry"), tool, tw, true); |
3133 (PolicyTool.getMessage("Policy.Entry"), tool, tw, true); |
2805 td.displayPolicyEntryDialog(true); |
3134 td.displayPolicyEntryDialog(true); |
2806 |
3135 |
2807 } else if (PolicyTool.collator.compare(e.getActionCommand(), |
3136 } else if (PolicyTool.collator.compare(e.getActionCommand(), |
2808 ToolWindow.EDIT_KEYSTORE) == 0) { |
3137 ToolWindow.EDIT_KEYSTORE) == 0) { |
2809 |
3138 |
2810 // display a dialog box for the user to enter keystore info |
3139 // display a dialog box for the user to enter keystore info |
2811 ToolDialog td = new ToolDialog |
3140 ToolDialog td = new ToolDialog |
2812 (PolicyTool.rb.getString("KeyStore"), tool, tw, true); |
3141 (PolicyTool.getMessage("KeyStore"), tool, tw, true); |
2813 td.keyStoreDialog(ToolDialog.EDIT_KEYSTORE); |
3142 td.keyStoreDialog(ToolDialog.EDIT_KEYSTORE); |
2814 } |
3143 } |
2815 } |
3144 } |
2816 } |
3145 } |
2817 |
3146 |