1 package devisor2.grid.GUI.dialogs; 2 3 4 import java.awt.*; 5 import java.awt.event.*; 6 import javax.swing.*; 7 import javax.swing.filechooser.*; 8 import java.io.*; 9 import java.util.*; 10 11 import devisor2.grid.options.*; 12 import devisor2.grid.GUI.framework.*; 13 import devisor2.grid.GUI.dialogs.*; 14 import devisor2.grid.GUI.event.*; 15 16 /** 17 * This class provides the event handler for the options dialog 18 * (OptionsDialog.java), such as restoring factory defaults, 19 * loading and saving user-defined settings, applying changes 20 * (which is the most important bit here!) and closing the dialog.<br> 21 * <br> 22 * For every button in the OptionsDialog, a unique String 23 * (an ActionCommand) is declared in this class and registered 24 * with the corresponding button in the dialog. The actual event 25 * handling code goes in a corresponding 26 * <code>if e.getActionCommand().equals (blablabla)"<\code> 27 * block in the actionPerformed method. 28 * 29 * @author Dominik Goeddeke 30 * @version 0.5 (for all options availible so far, event handlers have 31 * been added) 32 */ 33 34 class OptionsActionListener implements ActionListener 35 { 36 /** reference to the main window of the application */ 37 private MainFrame parent; 38 39 /** reference to the OptionsDialog this listener is responsible for */ 40 private OptionsDialog dialog; 41 42 /** reference to the ControlCenter */ 43 private ControlCenter cc; 44 45 /** 46 * The constructor just sets the reference correctly 47 * 48 * @param parent - the mainframe instance, the link to the rest 49 * of the application 50 * @param dialog - a reference to the OptionsDialog instance this 51 * class listens to 52 * 53 */ OptionsActionListener(MainFrame parent, OptionsDialog dialog)54 public OptionsActionListener (MainFrame parent, OptionsDialog dialog) 55 { 56 this.parent = parent; 57 this.dialog = dialog; 58 cc = ControlCenter.getMyself (); 59 } 60 61 /** 62 * The actionPerformed() method is just a king-size switch-block 63 * all actions this method performs must be declared as String 64 * constants in this class (see below) 65 * It is called by the JRE everytime an ActionEvent is raised. 66 */ actionPerformed(ActionEvent e)67 public void actionPerformed(ActionEvent e) { 68 /* Action Command ACCEPT */ 69 if (e.getActionCommand ().equals(ACCEPT)) 70 { 71 String oldlf = cc.op.get (Options.other_lookandfeel); 72 dialog.updateOptions(); 73 updateAll (oldlf); 74 // update DrawControl 75 76 int ret1=cc.dc.screen_width; 77 int ret2=cc.dc.screen_height; 78 int ret3=cc.dc.used_screen_width; 79 int ret4=cc.dc.used_screen_height; 80 int ret5=cc.dc.world_x1; 81 int ret6=cc.dc.world_x2; 82 int ret7=cc.dc.world_y1; 83 int ret8=cc.dc.world_y2; 84 int ret9=cc.dc.act_x1; 85 int ret10=cc.dc.act_x2; 86 int ret11=cc.dc.act_y1; 87 int ret12=cc.dc.act_y2; 88 89 cc.dc = new DrawControl (cc.op); 90 cc.dc.tolerance = cc.gc.SingleFromScreenToWorld(cc.dc.tolerance); 91 92 cc.dc.screen_width=ret1; 93 cc.dc.screen_height=ret2; 94 cc.dc.used_screen_width=ret3; 95 cc.dc.used_screen_height=ret4; 96 cc.dc.world_x1=ret5; 97 cc.dc.world_x2=ret6; 98 cc.dc.world_y1=ret7; 99 cc.dc.world_y2=ret8; 100 cc.dc.act_x1=ret9; 101 cc.dc.act_x2=ret10; 102 cc.dc.act_y1=ret11; 103 cc.dc.act_y2=ret12; 104 105 // cc.dc.main_width = parent.getWidth (); 106 // cc.dc.main_height = parent.getHeight (); 107 // cc.dc.screen_height = parent.getToolkit().getScreenSize().getSize().height; 108 // cc.dc.screen_width = parent.getToolkit().getScreenSize().getSize().width; 109 cc.gc.vsnapx = Integer.parseInt (cc.op.get(Options.snap_x)); 110 cc.gc.vsnapy = Integer.parseInt (cc.op.get(Options.snap_y)); 111 cc.gc.snapon = Boolean.valueOf (cc.op.get (Options.snap_enabled)).booleanValue (); 112 113 int eps = Integer.parseInt (cc.op.get (Options.epsilon)); 114 double epsi = 0.01 + ((double)eps)/100 * 0.99; 115 cc.gc.eps = (int)(epsi*(cc.dc.world_x2 - cc.dc.world_x1)); 116 // leave the house... 117 dialog.hide(); 118 parent.getDrawingArea().repaint (); 119 return; 120 } 121 /* Action Command CANCEL */ 122 if (e.getActionCommand ().equals(CANCEL)) 123 { 124 dialog.hide(); 125 return; 126 } 127 /* Action Command LOAD */ 128 if (e.getActionCommand ().equals(LOAD)) 129 { 130 // show a load dialog with supported formats optionfiles 131 FilePicker picker = new FilePicker (parent,(String)cc.rb.getObject ("dialogs_loadoptionsdialog_caption"), (String)cc.rb.getObject ("dialogs_loaddialog_button"), cc.op.get (Options.general_path), new FilePickerFilter (FilePickerFilter.FILTER_ALL), true); 132 int returnvalue = picker.showDialog (); 133 // if user accepted a file in the dialog... 134 if (returnvalue == JFileChooser.APPROVE_OPTION) 135 { 136 // get the file 137 File selectedFile = picker.getSelectedFile (); 138 if (selectedFile != null) 139 { 140 // eventueally add extension 141 142 // and load the file 143 String filepath = selectedFile.getPath (); 144 try 145 { 146 cc.op.load (filepath); 147 } 148 catch (Exception ex) 149 { 150 JOptionPane.showMessageDialog (dialog, ex.getMessage(),(String)cc.rb.getObject ("errors_messageboxheader"),JOptionPane.ERROR_MESSAGE); 151 } 152 } 153 ((OptionsDialog)dialog).updateGUI(); 154 String oldlf = cc.op.get (Options.other_lookandfeel); 155 updateAll ("12345"); 156 return; 157 } 158 } 159 160 /* Action Command SAVE */ 161 if (e.getActionCommand ().equals(SAVE)) 162 { 163 // first, accept without dialog closing 164 String oldlf = cc.op.get (Options.other_lookandfeel); 165 dialog.updateOptions (); 166 updateAll (oldlf); 167 // display dialog 168 FilePicker picker = new FilePicker (parent,(String)cc.rb.getObject ("dialogs_saveoptionsdialog_caption"), (String)cc.rb.getObject ("dialogs_savedialog_button"), cc.op.get (Options.general_path), new FilePickerFilter (FilePickerFilter.FILTER_ALL), true); 169 String os = System.getProperty ("os.name").toUpperCase(); 170 if (os.indexOf ("WIN") != -1) 171 { 172 picker.setSelectedFile (new File(cc.op.get (Options.general_devisorhome)+System.getProperty ("file.separator")+"devisorgrid.conf")); 173 } 174 else 175 { 176 picker.setSelectedFile (new File(System.getProperty("user.home")+System.getProperty ("file.separator")+".devisorgrid")); 177 } 178 int returnvalue = picker.showDialog (); 179 // if user accepted a file in the dialog... 180 if (returnvalue == JFileChooser.APPROVE_OPTION) 181 { 182 File selectedFile = picker.getSelectedFile (); 183 if (selectedFile != null) 184 { 185 String filepath = selectedFile.getPath (); 186 String header = JOptionPane.showInputDialog(dialog, "Please enter the header comment for your Options" , "DeViSoRGrid2 Options file",JOptionPane.QUESTION_MESSAGE) ; 187 cc.op.setHeader (header); 188 try 189 { 190 cc.op.save (filepath); 191 } 192 catch (Exception ex) 193 { 194 JOptionPane.showMessageDialog (dialog, ex.getMessage(),"ERROR",JOptionPane.ERROR_MESSAGE); 195 } 196 197 } 198 else 199 { 200 JOptionPane.showMessageDialog (dialog,"No file selected","Error",JOptionPane.ERROR_MESSAGE); 201 } 202 return; 203 } 204 205 206 } 207 208 /* Action Command RESET */ 209 if (e.getActionCommand().equals(RESET)) 210 { 211 cc.op.resetToDefaults (); 212 ((OptionsDialog)dialog).updateGUI(); 213 updateAll ("12345"); 214 // set DockableDialog positions 215 216 return; 217 } 218 219 220 /* Action Command HELP */ 221 if (e.getActionCommand ().equals(HELP)) 222 { 223 cc.help.show(); 224 return; 225 } 226 227 /* Action Command DEVHOME */ 228 if (e.getActionCommand ().equals(DEVHOME)) 229 { 230 // show a load dialog which allows paths only 231 String initialDirectory = dialog.getDevHomeTextField().getText(); 232 if (initialDirectory == null) 233 initialDirectory = cc.op.get (Options.general_devisorhome); 234 FilePicker picker = new FilePicker (parent,(String)cc.rb.getObject ("options_OptionsDialog_generalPanel_devisorhome_dialogtitle"), (String)cc.rb.getObject ("general_Accept"), initialDirectory, new FilePickerFilter (FilePickerFilter.FILTER_DIRECTORIES), false); 235 int returnvalue = picker.showDialog (); 236 if (returnvalue == JFileChooser.APPROVE_OPTION) 237 { 238 dialog.getDevHomeTextField().setText (picker.getSelectedFile().getAbsolutePath()); 239 } 240 return; 241 } 242 /* Action Command TRIGEN */ 243 if (e.getActionCommand ().equals(TRIGEN)) 244 { 245 // show a load dialog 246 String initialDirectory = dialog.getTrigenTextField().getText(); 247 if (initialDirectory == null) 248 initialDirectory = cc.op.get (Options.general_trigen); 249 FilePicker picker = new FilePicker (parent,(String)cc.rb.getObject ("options_OptionsDialog_generalPanel_trigen_dialogtitle"), (String)cc.rb.getObject ("general_Accept"), initialDirectory, new FilePickerFilter (FilePickerFilter.FILTER_BIN), true); 250 int returnvalue = picker.showDialog (); 251 if (returnvalue == JFileChooser.APPROVE_OPTION) 252 { 253 dialog.getTrigenTextField().setText (picker.getSelectedFile().getAbsolutePath()); 254 } 255 return; 256 } 257 /* Action Command FEATLIB */ 258 if (e.getActionCommand ().equals(FEATLIB)) 259 { 260 // show a load dialog which allows paths only 261 String initialDirectory = dialog.getFeatlibTextField().getText(); 262 if (initialDirectory == null) 263 initialDirectory = cc.op.get (Options.general_featlib); 264 FilePicker picker = new FilePicker (parent,(String)cc.rb.getObject ("options_OptionsDialog_generalPanel_featlib_dialogtitle"), (String)cc.rb.getObject ("general_Accept"), initialDirectory, new FilePickerFilter (FilePickerFilter.FILTER_DIRECTORIES), false); 265 int returnvalue = picker.showDialog (); 266 if (returnvalue == JFileChooser.APPROVE_OPTION) 267 { 268 dialog.getFeatlibTextField().setText (picker.getSelectedFile().getAbsolutePath()); 269 } 270 return; 271 } 272 273 /* Action Command PATH */ 274 if (e.getActionCommand ().equals(PATH)) 275 { 276 // show a load dialog which allows paths only 277 String initialDirectory = dialog.getPathTextField().getText(); 278 if (initialDirectory == null) 279 initialDirectory = cc.op.get (Options.general_path); 280 FilePicker picker = new FilePicker (parent,(String)cc.rb.getObject ("options_OptionsDialog_generalPanel_generalpath_dialogtitle"), (String)cc.rb.getObject ("general_Accept"), initialDirectory, new FilePickerFilter (FilePickerFilter.FILTER_DIRECTORIES), false); 281 int returnvalue = picker.showDialog (); 282 if (returnvalue == JFileChooser.APPROVE_OPTION) 283 { 284 dialog.getPathTextField().setText (picker.getSelectedFile().getAbsolutePath()); 285 } 286 return; 287 } 288 /* Action Command SNAP */ 289 if (e.getActionCommand ().equals (SNAP)) 290 { 291 if (dialog.getSnapCheck().isSelected()) 292 { 293 dialog.getSnapXTF().setEnabled (true); 294 dialog.getSnapXTF().setText (Integer.toString (cc.gc.vsnapx)); 295 dialog.getSnapYTF().setEnabled (true); 296 dialog.getSnapYTF().setText (Integer.toString (cc.gc.vsnapy)); 297 } 298 else 299 { 300 dialog.getSnapXTF().setEnabled (false); 301 dialog.getSnapXTF().setText(""); 302 dialog.getSnapYTF().setEnabled (false); 303 dialog.getSnapYTF().setText (""); 304 } 305 } 306 307 /* Action Command APPLY_ACCELERATOR */ 308 if (e.getActionCommand().equals(APPLY_ACCELERATOR)) 309 { 310 String mod; 311 String key; 312 // step one: extract the selected modifier key 313 if (dialog.getCTRLbutton().isSelected ()) 314 { 315 mod = "CTRL"; 316 } 317 else 318 { 319 if (dialog.getALTbutton().isSelected()) 320 { 321 mod = "ALT"; 322 } 323 else 324 { 325 if (dialog.getSHIFTbutton().isSelected()) 326 { 327 mod = "SHIFT"; 328 } 329 else 330 { 331 mod = "NONE"; 332 } 333 } 334 } 335 // step two: extract key 336 key = (String)dialog.getKeySelectionComboBox().getSelectedItem(); 337 // step three: long boring verification code 338 // luckily implemented in the Accelerators class 339 boolean correctAccelerator = Accelerators.isCorrectAccelerator (mod, key); 340 if (!correctAccelerator) 341 { 342 // a little error message 343 JOptionPane.showMessageDialog (dialog, (String)cc.rb.getObject("options_OptionsDialog_acceleratorPanel_nocorrectaccelerator"),(String)cc.rb.getObject("errors_messageboxheader"), JOptionPane.ERROR_MESSAGE); 344 } 345 else 346 { 347 // step four: is that accelerator already in use 348 String accelerator = mod + "+" + key; 349 if (accelerator.equals("NONE+NONE")) 350 accelerator = "NONE"; 351 boolean isInUse = cc.op.isAlreadyAccelerator (accelerator); 352 if (isInUse) 353 { 354 // a second error message 355 JOptionPane.showMessageDialog (dialog, (String)cc.rb.getObject("options_OptionsDialog_acceleratorPanel_acceleratoralreadyinuse"),(String)cc.rb.getObject("errors_messageboxheader"), JOptionPane.ERROR_MESSAGE); 356 } 357 else 358 { 359 // step five: update the table 360 int row = dialog.getAcceleratorTable().getSelectedRow (); 361 if (row != -1) 362 { 363 ((String[])(dialog.getAcceleratorTableData().elementAt(row)))[1] = accelerator; 364 ((AcceleratorTableModel)dialog.getAcceleratorTable().getModel()).fireTableDataChanged(); 365 } 366 else 367 { 368 JOptionPane.showMessageDialog (dialog, (String)cc.rb.getObject("options_OptionsDialog_acceleratorPanel_youmustselectarow"),(String)cc.rb.getObject("errors_messageboxheader"), JOptionPane.ERROR_MESSAGE); 369 } 370 } 371 } 372 } 373 374 /* Action Command REMOVE_ACCELERATOR */ 375 if (e.getActionCommand ().equals(REMOVE_ACCELERATOR)) 376 { 377 int row = dialog.getAcceleratorTable().getSelectedRow (); 378 if (row != -1) 379 { 380 ((String[])(dialog.getAcceleratorTableData().elementAt(row)))[1] = "NONE"; 381 ((AcceleratorTableModel)dialog.getAcceleratorTable().getModel()).fireTableDataChanged(); 382 } 383 else 384 { 385 JOptionPane.showMessageDialog (dialog, (String)cc.rb.getObject("options_OptionsDialog_acceleratorPanel_youmustselectarow"),(String)cc.rb.getObject("errors_messageboxheader"), JOptionPane.ERROR_MESSAGE); 386 } 387 return; 388 } 389 390 /* Action Command COLORNODE */ 391 if (e.getActionCommand ().equals(COLORNODE)) 392 { 393 dialog.getColornodeLabel().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_objects_node_dialog"), dialog.getColornodeLabel().getBackground(), dialog)); 394 return; 395 } 396 /* Action Command COLOREDGE */ 397 if (e.getActionCommand ().equals(COLOREDGE)) 398 { 399 dialog.getColoredgeLabel().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_objects_edge_dialog"), dialog.getColoredgeLabel().getBackground(), dialog)); 400 return; 401 } 402 /* Action Command COLOREDGEBASE */ 403 if (e.getActionCommand ().equals(COLOREDGEBASE)) 404 { 405 dialog.getColoredgebaseLabel().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_objects_edgebase_dialog"), dialog.getColoredgebaseLabel().getBackground(), dialog)); 406 return; 407 } 408 /* Action Command COLORELEMENT */ 409 if (e.getActionCommand ().equals(COLORELEMENT)) 410 { 411 dialog.getColorelementLabel().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_objects_element_dialog"), dialog.getColorelementLabel().getBackground(), dialog)); 412 return; 413 } 414 /* Action Command NUMBERBOUNDARY */ 415 if (e.getActionCommand ().equals(NUMBERBOUNDARY)) 416 { 417 dialog.getNumberboundaryLabel().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_numbers_boundary_dialog"), dialog.getNumberboundaryLabel().getBackground(), dialog)); 418 return; 419 } 420 /* Action Command NUMBERNODE */ 421 if (e.getActionCommand ().equals(NUMBERNODE)) 422 { 423 dialog.getNumbernodeLabel().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_numbers_node_dialog"), dialog.getNumbernodeLabel().getBackground(), dialog)); 424 return; 425 } 426 /* Action Command NUMBERREDGE */ 427 if (e.getActionCommand ().equals(NUMBEREDGE)) 428 { 429 dialog.getNumberedgeLabel().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_numbers_edge_dialog"), dialog.getNumberedgeLabel().getBackground(), dialog)); 430 return; 431 } 432 /* Action Command NUMBERELEMENT */ 433 if (e.getActionCommand ().equals(NUMBERELEMENT)) 434 { 435 dialog.getNumberelementLabel().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_numbers_element_dialog"), dialog.getNumberelementLabel().getBackground(), dialog)); 436 return; 437 } 438 /* Action Command HIGHLIGHTSELECTION */ 439 if (e.getActionCommand ().equals(HIGHLIGHTSELECTION)) 440 { 441 dialog.getHighlightselectionLabel().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_highlight_selection_dialog"), dialog.getHighlightselectionLabel().getBackground(), dialog)); 442 return; 443 } 444 /* Action Command HIGHLIGHTRECT */ 445 if (e.getActionCommand ().equals(HIGHLIGHTRECT)) 446 { 447 dialog.getHighlightrectLabel().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_highlight_rect_dialog"), dialog.getHighlightrectLabel().getBackground(), dialog)); 448 return; 449 } 450 /* Action Command COLORGRID */ 451 if (e.getActionCommand ().equals(COLORGRID)) 452 { 453 dialog.getMiscgridLabel().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_misc_grid_dialog"), dialog.getMiscgridLabel().getBackground(), dialog)); 454 return; 455 } 456 /* Action Command COLORBACKGROUND */ 457 if (e.getActionCommand ().equals(COLORBACKGROUND)) 458 { 459 dialog.getMiscbackgroundLabel().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_misc_background_dialog"), dialog.getMiscbackgroundLabel().getBackground(), dialog)); 460 return; 461 } 462 /* Action Command COLORLASSO */ 463 if (e.getActionCommand ().equals(COLORLASSO)) 464 { 465 dialog.getMisclassoLabel().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_misc_lasso_dialog"), dialog.getMisclassoLabel().getBackground(), dialog)); 466 return; 467 } 468 /* Action Command FILL0 */ 469 if (e.getActionCommand ().equals(FILL0)) 470 { 471 dialog.getFill0Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_fill0_dialog"), dialog.getFill0Label().getBackground(), dialog)); 472 return; 473 } 474 /* Action Command FILL1 */ 475 if (e.getActionCommand ().equals(FILL1)) 476 { 477 dialog.getFill1Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_fill1_dialog"), dialog.getFill1Label().getBackground(), dialog)); 478 return; 479 } 480 /* Action Command FILL2 */ 481 if (e.getActionCommand ().equals(FILL2)) 482 { 483 dialog.getFill2Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_fill2_dialog"), dialog.getFill2Label().getBackground(), dialog)); 484 return; 485 } 486 /* Action Command FILL3 */ 487 if (e.getActionCommand ().equals(FILL3)) 488 { 489 dialog.getFill3Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_fill3_dialog"), dialog.getFill3Label().getBackground(), dialog)); 490 return; 491 } 492 /* Action Command FILL4 */ 493 if (e.getActionCommand ().equals(FILL4)) 494 { 495 dialog.getFill4Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_fill4_dialog"), dialog.getFill4Label().getBackground(), dialog)); 496 return; 497 } 498 /* Action Command FILL5 */ 499 if (e.getActionCommand ().equals(FILL5)) 500 { 501 dialog.getFill5Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_fill5_dialog"), dialog.getFill5Label().getBackground(), dialog)); 502 return; 503 } 504 /* Action Command FILL6 */ 505 if (e.getActionCommand ().equals(FILL6)) 506 { 507 dialog.getFill6Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_fill6_dialog"), dialog.getFill6Label().getBackground(), dialog)); 508 return; 509 } 510 /* Action Command FILL7 */ 511 if (e.getActionCommand ().equals(FILL7)) 512 { 513 dialog.getFill7Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_fill7_dialog"), dialog.getFill7Label().getBackground(), dialog)); 514 return; 515 } 516 /* Action Command FILL8 */ 517 if (e.getActionCommand ().equals(FILL8)) 518 { 519 dialog.getFill8Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_fill8_dialog"), dialog.getFill8Label().getBackground(), dialog)); 520 return; 521 } 522 /* Action Command FILL9 */ 523 if (e.getActionCommand ().equals(FILL9)) 524 { 525 dialog.getFill9Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_fill9_dialog"), dialog.getFill9Label().getBackground(), dialog)); 526 return; 527 } 528 /* Action Command FILL10 */ 529 if (e.getActionCommand ().equals(FILL10)) 530 { 531 dialog.getFill10Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_fill10_dialog"), dialog.getFill10Label().getBackground(), dialog)); 532 return; 533 } 534 /* Action Command FILL11 */ 535 if (e.getActionCommand ().equals(FILL11)) 536 { 537 dialog.getFill11Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_fill11_dialog"), dialog.getFill11Label().getBackground(), dialog)); 538 return; 539 } 540 /* Action Command FILL12 */ 541 if (e.getActionCommand ().equals(FILL12)) 542 { 543 dialog.getFill12Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_fill12_dialog"), dialog.getFill12Label().getBackground(), dialog)); 544 return; 545 } 546 /* Action Command FILL13 */ 547 if (e.getActionCommand ().equals(FILL13)) 548 { 549 dialog.getFill13Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_fill13_dialog"), dialog.getFill13Label().getBackground(), dialog)); 550 return; 551 } 552 /* Action Command FILL14 */ 553 if (e.getActionCommand ().equals(FILL14)) 554 { 555 dialog.getFill14Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_fill14_dialog"), dialog.getFill14Label().getBackground(), dialog)); 556 return; 557 } 558 /* Action Command FILL15 */ 559 if (e.getActionCommand ().equals(FILL15)) 560 { 561 dialog.getFill15Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_fill15_dialog"), dialog.getFill15Label().getBackground(), dialog)); 562 return; 563 } 564 /* Action Command BOUND0 */ 565 if (e.getActionCommand ().equals(BOUND0)) 566 { 567 dialog.getBound0Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_boundary0_dialog"), dialog.getBound0Label().getBackground(), dialog)); 568 return; 569 } 570 /* Action Command BOUND1 */ 571 if (e.getActionCommand ().equals(BOUND1)) 572 { 573 dialog.getBound1Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_boundary1_dialog"), dialog.getBound1Label().getBackground(), dialog)); 574 return; 575 } 576 /* Action Command BOUND2 */ 577 if (e.getActionCommand ().equals(BOUND2)) 578 { 579 dialog.getBound2Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_boundary2_dialog"), dialog.getBound2Label().getBackground(), dialog)); 580 return; 581 } 582 /* Action Command BOUND3 */ 583 if (e.getActionCommand ().equals(BOUND3)) 584 { 585 dialog.getBound3Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_boundary3_dialog"), dialog.getBound3Label().getBackground(), dialog)); 586 return; 587 } 588 /* Action Command BOUND4 */ 589 if (e.getActionCommand ().equals(BOUND4)) 590 { 591 dialog.getBound4Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_boundary4_dialog"), dialog.getBound4Label().getBackground(), dialog)); 592 return; 593 } 594 /* Action Command BOUND5 */ 595 if (e.getActionCommand ().equals(BOUND5)) 596 { 597 dialog.getBound5Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_boundary5_dialog"), dialog.getBound5Label().getBackground(), dialog)); 598 return; 599 } 600 /* Action Command BOUND6 */ 601 if (e.getActionCommand ().equals(BOUND6)) 602 { 603 dialog.getBound6Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_boundary6_dialog"), dialog.getBound6Label().getBackground(), dialog)); 604 return; 605 } 606 /* Action Command BOUND7 */ 607 if (e.getActionCommand ().equals(BOUND7)) 608 { 609 dialog.getBound7Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_boundary7_dialog"), dialog.getBound7Label().getBackground(), dialog)); 610 return; 611 } 612 /* Action Command BOUND8 */ 613 if (e.getActionCommand ().equals(BOUND8)) 614 { 615 dialog.getBound8Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_boundary8_dialog"), dialog.getBound8Label().getBackground(), dialog)); 616 return; 617 } 618 /* Action Command BOUND9 */ 619 if (e.getActionCommand ().equals(BOUND9)) 620 { 621 dialog.getBound9Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_boundary9_dialog"), dialog.getBound9Label().getBackground(), dialog)); 622 return; 623 } 624 /* Action Command BOUND10 */ 625 if (e.getActionCommand ().equals(BOUND10)) 626 { 627 dialog.getBound10Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_boundary10_dialog"), dialog.getBound10Label().getBackground(), dialog)); 628 return; 629 } 630 /* Action Command BOUND11 */ 631 if (e.getActionCommand ().equals(BOUND11)) 632 { 633 dialog.getBound11Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_boundary11_dialog"), dialog.getBound11Label().getBackground(), dialog)); 634 return; 635 } 636 /* Action Command BOUND12 */ 637 if (e.getActionCommand ().equals(BOUND12)) 638 { 639 dialog.getBound12Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_boundary12_dialog"), dialog.getBound12Label().getBackground(), dialog)); 640 return; 641 } 642 /* Action Command BOUND13 */ 643 if (e.getActionCommand ().equals(BOUND13)) 644 { 645 dialog.getBound13Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_boundary13_dialog"), dialog.getBound13Label().getBackground(), dialog)); 646 return; 647 } 648 /* Action Command BOUND14 */ 649 if (e.getActionCommand ().equals(BOUND14)) 650 { 651 dialog.getBound14Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_boundary14_dialog"), dialog.getBound14Label().getBackground(), dialog)); 652 return; 653 } 654 /* Action Command BOUND15 */ 655 if (e.getActionCommand ().equals(BOUND15)) 656 { 657 dialog.getBound15Label().setBackground (ColorPicker.show ((String)cc.rb.getObject("options_OptionsDialog_colorPanel_boundary15_dialog"), dialog.getBound15Label().getBackground(), dialog)); 658 return; 659 } 660 661 662 663 return; 664 } 665 666 667 /** 668 * updates all GUI elements according to setting in current 669 * Options object in class ControlCenter 670 */ updateAll(String oldlookandfeel)671 public void updateAll (String oldlookandfeel) 672 { 673 updateGeneral (); 674 updateOther (oldlookandfeel); 675 updateAccelerator (); 676 } 677 678 679 // updates everything on the GENERAL tab updateGeneral()680 private void updateGeneral () 681 { 682 683 } 684 685 // update everything changed on the accelerators tab updateAccelerator()686 private void updateAccelerator () 687 { 688 Vector data = dialog.getAcceleratorTableData (); 689 // first the Options instance is updated 690 Enumeration enum = data.elements (); 691 while (enum.hasMoreElements ()) 692 { 693 String[] elem = (String[])enum.nextElement (); 694 cc.op.set (elem[0], elem[1]); 695 } 696 // and now the GUI menu itself 697 parent.getMainMenu().setAccelerators (); 698 } 699 700 701 // updates everything changed on the OTHER tab updateOther(String oldlf)702 private void updateOther (String oldlf) 703 { 704 try 705 { 706 if (!oldlf.equals(cc.op.get(Options.other_lookandfeel))) 707 { 708 // set new l&f 709 UIManager.setLookAndFeel(cc.op.get(Options.other_lookandfeel)); 710 // ... for the main frame 711 SwingUtilities.updateComponentTreeUI(parent); 712 parent.pack(); 713 SwingUtilities.updateComponentTreeUI(dialog); 714 dialog.pack(); 715 SwingUtilities.updateComponentTreeUI(cc.help); 716 cc.help.pack(); 717 // ... and all user-defined dialogs 718 cc.dm.refreshDialogs (); 719 } 720 } 721 catch (Exception ex) 722 { 723 if (!(ex instanceof NullPointerException)) 724 { 725 JOptionPane.showMessageDialog (parent,(String)cc.rb.getObject("errors_lookandfeelnotsupported"),(String)cc.rb.getObject("errors_messageboxheader"),JOptionPane.ERROR_MESSAGE); 726 } 727 } 728 } 729 730 /** 731 * ActionCommand for the ACCEPT button 732 */ 733 public static final String ACCEPT = "ACCEPT"; 734 735 /** 736 * ActionCommand for the CANCEL button 737 */ 738 public static final String CANCEL = "CANCEL"; 739 740 /** 741 * ActionCommand for the LOAD button 742 */ 743 public static final String LOAD = "LOAD"; 744 745 /** 746 * ActionCommand for the SAVE button 747 */ 748 public static final String SAVE = "SAVE"; 749 750 /** 751 * ActionCommand for the RESETTODEFAULTS button 752 */ 753 public static final String RESET = "RESET"; 754 755 /** 756 * ActionCommand for the HELP button 757 */ 758 public static final String HELP = "HELP"; 759 760 /** 761 * ActionCommand for the DEVHOME button on tab GENERAL 762 */ 763 public static final String DEVHOME = "DEVHOME"; 764 /** 765 * ActionCommand for the PATH button on tab GENERAL 766 */ 767 public static final String PATH = "PATH"; 768 /** 769 * ActionCommand for the FEATLIB button on tab GENERAL 770 */ 771 public static final String FEATLIB = "FEATLIB"; 772 /** 773 * ActionCommand for the TRIGEN button on tab GENERAL 774 */ 775 public static final String TRIGEN = "TRIGEN"; 776 /** 777 * ActionCommand for the SNAP check box on DRAW tab 778 */ 779 public static final String SNAP = "SNAP"; 780 /** 781 * ActionCommand for the NODE button on tab COLOR 782 */ 783 public static final String COLORNODE = "COLORNODE"; 784 /** 785 * ActionCommand for the EDGE button on tab COLOR 786 */ 787 public static final String COLOREDGE = "COLOREDGE"; 788 /** 789 * ActionCommand for the EDGEBASE button on tab COLOR 790 */ 791 public static final String COLOREDGEBASE = "COLOREDGEBASE"; 792 /** 793 * ActionCommand for the ELEMENT button on tab COLOR 794 */ 795 public static final String COLORELEMENT = "COLORELEMENT"; 796 /** 797 * ActionCommand for the BOUNDARYNUMBER button on tab COLOR 798 */ 799 public static final String NUMBERBOUNDARY = "NUMBERBOUNDARY"; 800 /** 801 * ActionCommand for the NODENUMBER button on tab COLOR 802 */ 803 public static final String NUMBERNODE = "NUMBERNODE"; 804 /** 805 * ActionCommand for the EDGENUMBER button on tab COLOR 806 */ 807 public static final String NUMBEREDGE = "NUMBEREDGE"; 808 /** 809 * ActionCommand for the ELEMENTNUMBER button on tab COLOR 810 */ 811 public static final String NUMBERELEMENT = "NUMBERELEMENT"; 812 /** 813 * ActionCommand for the HIGHLIGHTSELECTION button on tab COLOR 814 */ 815 public static final String HIGHLIGHTSELECTION = "HIGHLIGHTSELECTION"; 816 /** 817 * ActionCommand for the HIGHLIGHTRECT button on tab COLOR 818 */ 819 public static final String HIGHLIGHTRECT = "HIGHLIGHTRECT"; 820 /** 821 * ActionCommand for the GRID button on tab COLOR 822 */ 823 public static final String COLORGRID = "COLORGRID"; 824 /** 825 * ActionCommand for the BACKGROUND button on tab COLOR 826 */ 827 public static final String COLORBACKGROUND = "COLORBACKGROUND"; 828 /** 829 * ActionCommand for the LASSO button on tab COLOR 830 */ 831 public static final String COLORLASSO = "COLORLASSO"; 832 /** 833 * ActionCommand for the FILL0 button on tab COLOR 834 */ 835 public static final String FILL0 = "FILL0"; 836 /** 837 * ActionCommand for the FILL1 button on tab COLOR 838 */ 839 public static final String FILL1 = "FILL1"; 840 /** 841 * ActionCommand for the FILL2 button on tab COLOR 842 */ 843 public static final String FILL2 = "FILL2"; 844 /** 845 * ActionCommand for the FILL3 button on tab COLOR 846 */ 847 public static final String FILL3 = "FILL3"; 848 /** 849 * ActionCommand for the FILL4 button on tab COLOR 850 */ 851 public static final String FILL4 = "FILL4"; 852 /** 853 * ActionCommand for the FILL5 button on tab COLOR 854 */ 855 public static final String FILL5 = "FILL5"; 856 /** 857 * ActionCommand for the FILL6 button on tab COLOR 858 */ 859 public static final String FILL6 = "FILL6"; 860 /** 861 * ActionCommand for the FILL7 button on tab COLOR 862 */ 863 public static final String FILL7 = "FILL7"; 864 /** 865 * ActionCommand for the FILL8 button on tab COLOR 866 */ 867 public static final String FILL8 = "FILL8"; 868 /** 869 * ActionCommand for the FILL9 button on tab COLOR 870 */ 871 public static final String FILL9 = "FILL9"; 872 /** 873 * ActionCommand for the FILL10 button on tab COLOR 874 */ 875 public static final String FILL10 = "FILL10"; 876 /** 877 * ActionCommand for the FILL11 button on tab COLOR 878 */ 879 public static final String FILL11 = "FILL11"; 880 /** 881 * ActionCommand for the FILL12 button on tab COLOR 882 */ 883 public static final String FILL12 = "FILL12"; 884 /** 885 * ActionCommand for the FILL13 button on tab COLOR 886 */ 887 public static final String FILL13 = "FILL13"; 888 /** 889 * ActionCommand for the FILL14 button on tab COLOR 890 */ 891 public static final String FILL14 = "FILL14"; 892 /** 893 * ActionCommand for the FILL15 button on tab COLOR 894 */ 895 public static final String FILL15 = "FILL15"; 896 897 /** 898 * ActionCommand for the APPLY button on the ACCELERATORS tab 899 */ 900 public static final String APPLY_ACCELERATOR = "APPLY_ACCELERATOR"; 901 902 /** 903 * ActionCommand for the REMOVE button on the ACCELERATORS tab 904 */ 905 public static final String REMOVE_ACCELERATOR = "REMOVE_ACCELERATOR"; 906 /** 907 * ActionCommand for palette color 0 for boundaries 908 */ 909 public static final String BOUND0 = "BOUND0"; 910 /** 911 * ActionCommand for palette color 1 for boundaries 912 */ 913 public static final String BOUND1 = "BOUND1"; 914 /** 915 * ActionCommand for palette color 2 for boundaries 916 */ 917 public static final String BOUND2 = "BOUND2"; 918 /** 919 * ActionCommand for palette color 3 for boundaries 920 */ 921 public static final String BOUND3 = "BOUND3"; 922 /** 923 * ActionCommand for palette color 4 for boundaries 924 */ 925 public static final String BOUND4 = "BOUND4"; 926 /** 927 * ActionCommand for palette color 5 for boundaries 928 */ 929 public static final String BOUND5 = "BOUND5"; 930 /** 931 * ActionCommand for palette color 6 for boundaries 932 */ 933 public static final String BOUND6 = "BOUND6"; 934 /** 935 * ActionCommand for palette color 7 for boundaries 936 */ 937 public static final String BOUND7 = "BOUND7"; 938 /** 939 * ActionCommand for palette color 8 for boundaries 940 */ 941 public static final String BOUND8 = "BOUND8"; 942 /** 943 * ActionCommand for palette color 9 for boundaries 944 */ 945 public static final String BOUND9 = "BOUND9"; 946 /** 947 * ActionCommand for palette color 10 for boundaries 948 */ 949 public static final String BOUND10 = "BOUND10"; 950 /** 951 * ActionCommand for palette color 11 for boundaries 952 */ 953 public static final String BOUND11 = "BOUND11"; 954 /** 955 * ActionCommand for palette color 12 for boundaries 956 */ 957 public static final String BOUND12 = "BOUND12"; 958 /** 959 * ActionCommand for palette color 13 for boundaries 960 */ 961 public static final String BOUND13 = "BOUND13"; 962 /** 963 * ActionCommand for palette color 14 for boundaries 964 */ 965 public static final String BOUND14 = "BOUND14"; 966 /** 967 * ActionCommand for palette color 15 for boundaries 968 */ 969 public static final String BOUND15 = "BOUND15"; 970 971 972 } 973