- Timestamp:
- 2003-09-26T14:58:33+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java
r5527 r5536 9 9 import javax.swing.event.*; 10 10 import org.greenstone.gatherer.Configuration; 11 import org.greenstone.gatherer.Dictionary; 11 12 import org.greenstone.gatherer.Gatherer; 12 13 import org.greenstone.gatherer.checklist.CheckList; … … 61 62 this.self = this; 62 63 setSize(SIZE); 63 setTitle("Preferences");64 Dictionary.registerText(this, "Preferences"); 64 65 setJMenuBar(new SimpleMenuBar("preferences")); 66 65 67 // Creation 66 68 JPanel content_pane = (JPanel) getContentPane(); 67 69 tab_pane = new JTabbedPane(); 68 tab_pane.add("Preferences.General", createGeneralPreferences()); 70 JPanel general_preferences = createGeneralPreferences(); 71 tab_pane.add("Preferences.General", general_preferences); 69 72 tab_pane.add("Preferences.Workflow", createWorkflowPreferences()); 70 73 tab_pane.add("Preferences.Connection", createConnectionPreferences()); 71 74 tab_pane.add("Preferences.Warnings", createWarningPreferences()); 75 Dictionary.register(tab_pane); 72 76 73 77 JPanel button_pane = new JPanel(); 74 ok_button = new JButton("General.OK"); 75 apply_button = new JButton("General.Apply"); 76 cancel_button = new JButton("General.Cancel"); 78 ok_button = new JButton(); 79 Dictionary.registerBoth(ok_button, "General.OK", "General.OK_Tooltip"); 80 apply_button = new JButton(); 81 Dictionary.registerBoth(apply_button, "General.Apply", "General.Apply_Tooltip"); 82 cancel_button = new JButton(); 83 Dictionary.registerBoth(cancel_button, "General.Cancel", "General.Cancel_Tooltip"); 84 77 85 // Connection 78 Gatherer.dictionary.register(this, null, false);79 Gatherer.dictionary.register(tab_pane, null, false);80 Gatherer.dictionary.register(ok_button, null, false);81 Gatherer.dictionary.register(apply_button, null, false);82 Gatherer.dictionary.register(cancel_button, null, false);83 86 ok_button.addActionListener(new OKButtonListener(true)); 84 87 apply_button.addActionListener(new OKButtonListener(false)); 85 88 cancel_button.addActionListener(new CancelButtonListener()); 89 86 90 // Layout 87 91 button_pane.setBorder(BorderFactory.createEmptyBorder(5,2,2,2)); … … 114 118 JPanel library_path_pane = new JPanel(); 115 119 library_path_pane.setPreferredSize(ROW_SIZE); 116 library_path_label = new JLabel( "Preferences.Connection.Library_Path");120 library_path_label = new JLabel(); 117 121 library_path_label.setPreferredSize(LABEL_SIZE); 122 Dictionary.registerText(library_path_label, "Preferences.Connection.Library_Path"); 118 123 library_path_field = new JTextField(Gatherer.config.getString("general.exec_address", true)); 119 124 library_path_field.setCaretPosition(0); 125 Dictionary.registerTooltip(library_path_field, "Preferences.Connection.Library_Path_Tooltip"); 120 126 121 127 boolean currently_enabled = Gatherer.config.get("general.use_proxy", true); 122 128 // Creation 123 129 JPanel connection_pane = new JPanel(); 124 use_proxy_checkbox = new JCheckBox("Preferences.Connection.Use_Proxy", currently_enabled); 130 use_proxy_checkbox = new JCheckBox(); 131 use_proxy_checkbox.setSelected(currently_enabled); 132 Dictionary.registerText(use_proxy_checkbox, "Preferences.Connection.Use_Proxy"); 133 125 134 use_proxy_checkbox.setPreferredSize(ROW_SIZE); 126 135 JPanel proxy_host_pane = new JPanel(); 127 136 proxy_host_pane.setPreferredSize(ROW_SIZE); 128 proxy_host_label = new JLabel( "Preferences.Connection.Proxy_Host");137 proxy_host_label = new JLabel(); 129 138 proxy_host_label.setPreferredSize(LABEL_SIZE); 139 Dictionary.registerText(proxy_host_label, "Preferences.Connection.Proxy_Host"); 130 140 proxy_host_field = new JTextField(Gatherer.config.getString("general.proxy_host", true)); 131 141 proxy_host_field.setEnabled(currently_enabled); 142 Dictionary.registerTooltip(proxy_host_field, "Preferences.Connection.Proxy_Host_Tooltip"); 132 143 JPanel proxy_port_pane = new JPanel(); 133 144 proxy_port_pane.setPreferredSize(ROW_SIZE); 134 proxy_port_label = new JLabel( "Preferences.Connection.Proxy_Port");145 proxy_port_label = new JLabel(); 135 146 proxy_port_label.setPreferredSize(LABEL_SIZE); 147 Dictionary.registerText(proxy_port_label, "Preferences.Connection.Proxy_Port"); 136 148 proxy_port_field = new NumberField(Gatherer.config.getString("general.proxy_port", true)); 137 149 proxy_port_field.setEnabled(currently_enabled); 150 Dictionary.registerTooltip(proxy_port_field, "Preferences.Connection.Proxy_Port_Tooltip"); 138 151 139 152 // Connection 140 Gatherer.dictionary.register(library_path_label, null, false);141 Gatherer.dictionary.register(use_proxy_checkbox, null, false);142 Gatherer.dictionary.register(proxy_host_label, null, false);143 Gatherer.dictionary.register(proxy_port_label, null, false);144 153 use_proxy_checkbox.addActionListener(new UseProxyListener()); 145 154 … … 214 223 215 224 // Extracted metadata 216 view_extracted_metadata_checkbox = new JCheckBox("Preferences.General.View_Extracted_Metadata", false); 225 view_extracted_metadata_checkbox = new JCheckBox(); 226 view_extracted_metadata_checkbox.setSelected(false); 227 Dictionary.registerText(view_extracted_metadata_checkbox, "Preferences.General.View_Extracted_Metadata"); 217 228 if (Gatherer.config.get("general.view_extracted_metadata", Configuration.COLLECTION_SPECIFIC)) { 218 229 view_extracted_metadata_checkbox.setSelected(true); … … 220 231 221 232 // Show file sizes 222 show_file_size_checkbox = new JCheckBox("Preferences.General.Show_File_Size", false); 233 show_file_size_checkbox = new JCheckBox(); 234 show_file_size_checkbox.setSelected(false); 235 Dictionary.registerText(show_file_size_checkbox, "Preferences.General.Show_File_Size"); 223 236 if (Gatherer.config.get("general.show_file_size", Configuration.COLLECTION_SPECIFIC)) { 224 237 show_file_size_checkbox.setSelected(true); … … 227 240 // Language 228 241 JPanel language_pane = new JPanel(); 229 language_label = new JLabel( "Preferences.General.Interface_Language");242 language_label = new JLabel(); 230 243 language_label.setPreferredSize(LABEL_SIZE); 244 Dictionary.registerText(language_label, "Preferences.General.Interface_Language"); 231 245 language_combobox = new JComboBox(dictionary_model.toArray()); 232 246 233 247 // Connect 234 Gatherer.dictionary.register(view_extracted_metadata_checkbox, null, false);235 Gatherer.dictionary.register(show_file_size_checkbox, null, false);236 Gatherer.dictionary.register(language_label, null, false);237 248 language_combobox.addActionListener(new LanguageComboboxListener()); 238 249 … … 260 271 String value = (String) warning_preferences.get(property); 261 272 // Remove 'warning.' 262 String title = Gatherer.dictionary.get(property.substring(8) + ".Title");273 String title = Dictionary.newget(property.substring(8) + ".Title"); 263 274 Entry entry = new Entry(title, value.equalsIgnoreCase(TRUE)); 264 275 entry.setProperty(property); … … 277 288 278 289 private JPanel createWorkflowPreferences() { 279 // Read in the predefined configurations file .290 // Read in the predefined configurations file 280 291 Vector predefined = new Vector(); 281 292 Document predefined_document = Utility.parse("xml/workflows.xml", true); … … 285 296 predefined.add(new WorkflowElementWrapper((Element)workflow_elements.item(i))); 286 297 } 298 287 299 // Creation 288 300 JPanel workflow_preferences_pane = new JPanel(); 289 301 JPanel checklist_pane = new JPanel(); 290 title_label = new JLabel( "Preferences.Workflow.Title");302 title_label = new JLabel(); 291 303 title_label.setPreferredSize(ROW_SIZE); 292 workflow_browse = new JCheckBox("Preferences.Workflow.Browse", Gatherer.config.get("workflow.browse", false)); 304 Dictionary.registerText(title_label, "Preferences.Workflow.Title"); 305 306 workflow_browse = new JCheckBox(); 307 workflow_browse.setSelected(Gatherer.config.get("workflow.browse", false)); 293 308 workflow_browse.setPreferredSize(ROW_SIZE); 294 workflow_mirror = new JCheckBox("Preferences.Workflow.Mirror", Gatherer.config.get("workflow.mirror", false)); 309 Dictionary.registerText(workflow_browse, "Preferences.Workflow.Browse"); 310 311 workflow_mirror = new JCheckBox(); 312 workflow_mirror.setSelected(Gatherer.config.get("workflow.mirror", false)); 295 313 workflow_mirror.setPreferredSize(ROW_SIZE); 296 workflow_gather = new JCheckBox("Preferences.Workflow.Gather", Gatherer.config.get("workflow.gather", false)); 314 Dictionary.registerText(workflow_mirror, "Preferences.Workflow.Mirror"); 315 316 workflow_gather = new JCheckBox(); 317 workflow_gather.setSelected(Gatherer.config.get("workflow.gather", false)); 297 318 workflow_gather.setPreferredSize(ROW_SIZE); 298 workflow_enrich = new JCheckBox("Preferences.Workflow.Enrich", Gatherer.config.get("workflow.enrich", false)); 319 Dictionary.registerText(workflow_gather, "Preferences.Workflow.Gather"); 320 321 workflow_enrich = new JCheckBox(); 322 workflow_enrich.setSelected(Gatherer.config.get("workflow.enrich", false)); 299 323 workflow_enrich.setPreferredSize(ROW_SIZE); 300 workflow_design = new JCheckBox("Preferences.Workflow.Design", Gatherer.config.get("workflow.design", false)); 324 Dictionary.registerText(workflow_enrich, "Preferences.Workflow.Enrich"); 325 326 workflow_design = new JCheckBox(); 327 workflow_design.setSelected(Gatherer.config.get("workflow.design", false)); 301 328 workflow_design.setPreferredSize(ROW_SIZE); 302 workflow_export = new JCheckBox("Preferences.Workflow.Export", Gatherer.config.get("workflow.export", false)); 329 Dictionary.registerText(workflow_design, "Preferences.Workflow.Design"); 330 331 workflow_export = new JCheckBox(); 332 workflow_export.setSelected(Gatherer.config.get("workflow.export", false)); 303 333 workflow_export.setPreferredSize(ROW_SIZE); 304 workflow_create = new JCheckBox("Preferences.Workflow.Create", Gatherer.config.get("workflow.create", false)); 334 Dictionary.registerText(workflow_export, "Preferences.Workflow.Export"); 335 336 workflow_create = new JCheckBox(); 337 workflow_create.setSelected(Gatherer.config.get("workflow.create", false)); 305 338 workflow_create.setPreferredSize(ROW_SIZE); 306 workflow_preview = new JCheckBox("Preferences.Workflow.Preview", Gatherer.config.get("workflow.preview", false)); 339 Dictionary.registerText(workflow_create, "Preferences.Workflow.Create"); 340 341 workflow_preview = new JCheckBox(); 342 workflow_preview.setSelected(Gatherer.config.get("workflow.preview", false)); 307 343 workflow_preview.setPreferredSize(ROW_SIZE); 344 Dictionary.registerText(workflow_preview, "Preferences.Workflow.Preview"); 345 308 346 JPanel predefined_pane = new JPanel(); 309 predefined_label = new JLabel( "Preferences.Workflow.Predefined.Label");347 predefined_label = new JLabel(); 310 348 predefined_label.setPreferredSize(new Dimension(150,25)); 349 Dictionary.registerText(predefined_label, "Preferences.Workflow.Predefined.Label"); 311 350 JComboBox predefined_combobox = new JComboBox(predefined); 351 312 352 // Connection 313 Gatherer.dictionary.register(title_label, null, false);314 Gatherer.dictionary.register(workflow_browse, null, false);315 Gatherer.dictionary.register(workflow_mirror, null, false);316 Gatherer.dictionary.register(workflow_gather, null, false);317 Gatherer.dictionary.register(workflow_enrich, null, false);318 Gatherer.dictionary.register(workflow_design, null, false);319 Gatherer.dictionary.register(workflow_export, null, false);320 Gatherer.dictionary.register(workflow_create, null, false);321 Gatherer.dictionary.register(workflow_preview, null, false);322 Gatherer.dictionary.register(predefined_label, null, false);323 353 predefined_combobox.addActionListener(new PredefinedActionListener()); 354 324 355 // Layout 325 356 checklist_pane.setLayout(new BoxLayout(checklist_pane, BoxLayout.Y_AXIS)); 326 357 checklist_pane.add(title_label); 327 if (Gatherer.config.get("workflow.browse", true)) {358 if (Gatherer.config.get("workflow.browse", true)) { 328 359 checklist_pane.add(workflow_browse); 329 360 } 330 if (Gatherer.config.get("workflow.mirror", true)) {361 if (Gatherer.config.get("workflow.mirror", true)) { 331 362 checklist_pane.add(workflow_mirror); 332 363 } 333 if (Gatherer.config.get("workflow.gather", true)) {364 if (Gatherer.config.get("workflow.gather", true)) { 334 365 checklist_pane.add(workflow_gather); 335 366 } 336 if (Gatherer.config.get("workflow.enrich", true)) {367 if (Gatherer.config.get("workflow.enrich", true)) { 337 368 checklist_pane.add(workflow_enrich); 338 369 } 339 if (Gatherer.config.get("workflow.design", true)) {370 if (Gatherer.config.get("workflow.design", true)) { 340 371 checklist_pane.add(workflow_design); 341 372 } 342 if (Gatherer.config.get("workflow.export", true)) {373 if (Gatherer.config.get("workflow.export", true)) { 343 374 checklist_pane.add(workflow_export); 344 375 } 345 if (Gatherer.config.get("workflow.create", true)) {376 if (Gatherer.config.get("workflow.create", true)) { 346 377 checklist_pane.add(workflow_create); 347 378 } 348 if (Gatherer.config.get("workflow.preview", true)) {379 if (Gatherer.config.get("workflow.preview", true)) { 349 380 checklist_pane.add(workflow_preview); 350 381 } … … 362 393 363 394 public void dispose() { 364 // Deregister dictionary components365 366 // Connection367 Gatherer.dictionary.deregister(library_path_label);368 Gatherer.dictionary.deregister(use_proxy_checkbox);369 Gatherer.dictionary.deregister(proxy_host_label);370 Gatherer.dictionary.deregister(proxy_port_label);371 372 // General373 Gatherer.dictionary.deregister(view_extracted_metadata_checkbox);374 Gatherer.dictionary.deregister(show_file_size_checkbox);375 Gatherer.dictionary.deregister(language_label);376 377 // Workflow378 Gatherer.dictionary.deregister(title_label);379 Gatherer.dictionary.deregister(workflow_browse);380 Gatherer.dictionary.deregister(workflow_mirror);381 Gatherer.dictionary.deregister(workflow_gather);382 Gatherer.dictionary.deregister(workflow_enrich);383 Gatherer.dictionary.deregister(workflow_design);384 Gatherer.dictionary.deregister(workflow_export);385 Gatherer.dictionary.deregister(workflow_create);386 Gatherer.dictionary.deregister(workflow_preview);387 Gatherer.dictionary.deregister(predefined_label);388 389 // Dialog390 Gatherer.dictionary.deregister(this);391 Gatherer.dictionary.deregister(tab_pane);392 Gatherer.dictionary.deregister(ok_button);393 Gatherer.dictionary.deregister(apply_button);394 Gatherer.dictionary.deregister(cancel_button);395 395 // Dispose 396 396 super.dispose(); … … 534 534 Gatherer.dictionary.changeDictionary(entry.getLocale()); 535 535 // Display message 536 JOptionPane.showMessageDialog(Gatherer.g_man, Gatherer.dictionary.get("Preferences.General.Restart_Required"), Gatherer.dictionary.get("Preferences.General.Restart_Required"), JOptionPane.WARNING_MESSAGE);536 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("Preferences.General.Restart_Required"), Dictionary.newget("Preferences.General.Restart_Required"), JOptionPane.WARNING_MESSAGE); 537 537 } 538 538 }
Note:
See TracChangeset
for help on using the changeset viewer.