1 33 34 package edu.rice.cs.drjava.ui.config; 35 36 import javax.swing.*; 37 import javax.swing.event.*; 38 import javax.swing.border.EmptyBorder ; 39 import java.awt.event.*; 40 import java.awt.*; 41 import java.util.Enumeration ; 42 import java.io.IOException ; 43 import java.io.File ; 44 import java.util.TreeSet ; 45 import java.util.Iterator ; 46 47 import javax.swing.tree.*; 48 49 import edu.rice.cs.drjava.DrJava; 50 import edu.rice.cs.drjava.CodeStatus; 51 import edu.rice.cs.drjava.config.FileOption; 52 import edu.rice.cs.drjava.config.*; 53 import edu.rice.cs.drjava.ui.*; 54 import edu.rice.cs.drjava.ui.KeyBindingManager.KeyStrokeData; 55 import edu.rice.cs.util.swing.DirectoryChooser; 56 57 60 public class ConfigFrame extends JFrame { 61 62 private static final int FRAME_WIDTH = 750; 63 private static final int FRAME_HEIGHT = 500; 64 65 private final MainFrame _mainFrame; 66 67 private final JTree _tree; 69 private final DefaultTreeModel _treeModel; 70 private final PanelTreeNode _rootNode; 71 72 private final JButton _okButton; 73 private final JButton _applyButton; 74 private final JButton _cancelButton; 75 private final JPanel _mainPanel; 77 private final JFileChooser _fileOptionChooser; 78 private final JFileChooser _browserChooser; 79 private final DirectoryChooser _dirChooser; 80 81 private OptionComponent.ChangeListener _changeListener = new OptionComponent.ChangeListener() { 82 public Object apply(Object oc) { 83 _applyButton.setEnabled(true); 84 return null; 85 } 86 }; 87 88 90 public ConfigFrame(MainFrame frame) { 91 super("Preferences"); 92 93 _mainFrame = frame; 94 95 Action applyAction = new AbstractAction("Apply") { 96 public void actionPerformed(ActionEvent e) { 97 try { 99 saveSettings(); 101 _applyButton.setEnabled(false); 102 103 } 104 catch (IOException ioe) { 105 } 106 } 107 }; 108 109 _applyButton = new JButton(applyAction); 110 _applyButton.setEnabled(false); 111 112 Action okAction = new AbstractAction("OK") { 113 public void actionPerformed(ActionEvent e) { 114 boolean successful = true; 116 try { 117 successful = saveSettings(); 119 } 120 catch (IOException ioe) { 121 } 123 if (successful) _applyButton.setEnabled(false); 124 ConfigFrame.this.setVisible(false); 125 } 126 }; 127 _okButton = new JButton(okAction); 128 129 130 Action cancelAction = new AbstractAction("Cancel") { 131 public void actionPerformed(ActionEvent e) { 132 cancel(); 133 } 134 }; 135 _cancelButton = new JButton(cancelAction); 136 137 138 File workDir = _getWorkDir(); 139 _fileOptionChooser = new JFileChooser(workDir); 140 141 _browserChooser = new JFileChooser(workDir); 142 143 144 _dirChooser = new DirectoryChooser(this); 145 146 147 148 _rootNode = new PanelTreeNode("Preferences"); 149 _treeModel = new DefaultTreeModel(_rootNode); 150 _tree = new JTree(_treeModel); 151 152 _initTree(); 153 154 155 _createPanels(); 156 157 _mainPanel= new JPanel(); 158 _mainPanel.setLayout(new BorderLayout()); 159 _tree.addTreeSelectionListener(new PanelTreeSelectionListener()); 160 161 Container cp = getContentPane(); 162 cp.setLayout(new BorderLayout()); 163 164 if (_rootNode.getChildCount() != 0) { 166 PanelTreeNode firstChild = (PanelTreeNode)_rootNode.getChildAt(0); 167 TreeNode[] firstChildPath = firstChild.getPath(); 168 TreePath path = new TreePath(firstChildPath); 169 _tree.expandPath(path); 170 _tree.setSelectionPath(path); 171 } 172 173 JScrollPane treeScroll = new JScrollPane(_tree); 174 JPanel treePanel = new JPanel(); 175 treePanel.setLayout(new BorderLayout()); 176 treeScroll.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Categories")); 177 treePanel.add(treeScroll, BorderLayout.CENTER); 178 cp.add(treePanel, BorderLayout.WEST); 179 cp.add(_mainPanel, BorderLayout.CENTER); 180 181 JPanel bottom = new JPanel(); 183 bottom.setBorder(new EmptyBorder (5,5,5,5)); 184 bottom.setLayout(new BoxLayout(bottom, BoxLayout.X_AXIS)); 185 bottom.add(Box.createHorizontalGlue()); 186 bottom.add(_applyButton); 189 bottom.add(_okButton); 190 bottom.add(_cancelButton); 191 bottom.add(Box.createHorizontalGlue()); 192 193 cp.add(bottom, BorderLayout.SOUTH); 194 195 setSize(FRAME_WIDTH, FRAME_HEIGHT); 197 198 _mainFrame.setPopupLoc(this); 199 200 addWindowListener(new WindowAdapter() { 201 public void windowClosing(java.awt.event.WindowEvent e) { cancel(); } 202 }); 203 204 _tree.expandRow(0); 206 _tree.expandRow(1); 207 _tree.expandRow(2); 208 } 209 210 212 public void setUp() { 213 assert EventQueue.isDispatchThread(); 214 218 219 _fileOptionChooser.setDialogTitle("Select"); 220 _fileOptionChooser.setApproveButtonText("Select"); 221 _fileOptionChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); 222 _fileOptionChooser.setFileFilter(ClassPathFilter.ONLY); 223 224 _browserChooser.setDialogTitle("Select Web Browser"); 225 _browserChooser.setApproveButtonText("Select"); 226 _browserChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); 227 228 _dirChooser.setSelectedFile(_getWorkDir()); 229 _dirChooser.setDialogTitle("Select"); 230 _dirChooser.setApproveButtonText("Select"); 231 _dirChooser.setMultiSelectionEnabled(false); 232 233 234 } 235 236 239 private File _getWorkDir() { 240 File workDir = _mainFrame.getModel().getMasterWorkingDirectory(); if (workDir.isDirectory()) return workDir; 242 243 if (workDir.getParent() != null) workDir = workDir.getParentFile(); 244 return workDir; 245 } 246 247 248 public boolean apply() { 249 return _rootNode.update(); 251 } 252 253 254 public void resetToCurrent() { 255 _rootNode.resetToCurrent(); 256 } 257 258 259 public void cancel() { 260 resetToCurrent(); 261 _applyButton.setEnabled(false); 262 ConfigFrame.this.setVisible(false); 263 } 264 265 266 public boolean saveSettings() throws IOException { 267 boolean successful = apply(); 268 if (successful) { 269 try { 270 DrJava.getConfig().saveConfiguration(); 271 } 272 catch (IOException ioe) { 273 JOptionPane.showMessageDialog(this,"Could not save changes to your '.drjava' file in your home directory. \n\n" + ioe, 274 "Could Not Save Changes", 275 JOptionPane.ERROR_MESSAGE); 276 throw ioe; 278 } 279 } 280 return successful; 281 } 282 283 284 private void _displayPanel(ConfigPanel cf) { 285 286 _mainPanel.removeAll(); 287 _mainPanel.add(cf, BorderLayout.CENTER); 288 _mainPanel.revalidate(); 289 _mainPanel.repaint(); 290 } 291 292 293 private void _initTree() { 294 _tree.setEditable(false); 295 _tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); 296 _tree.setShowsRootHandles(true); 297 _tree.setRootVisible(false); 298 299 DefaultTreeCellRenderer dtcr = new DefaultTreeCellRenderer(); 300 dtcr.setLeafIcon(null); 301 dtcr.setOpenIcon(null); 302 dtcr.setClosedIcon(null); 303 _tree.setCellRenderer(dtcr); 304 } 305 306 311 private PanelTreeNode _createPanel(String t, PanelTreeNode parent) { 312 PanelTreeNode ptNode = new PanelTreeNode(t); 313 _treeModel.insertNodeInto(ptNode, parent, parent.getChildCount()); 315 316 TreeNode[] pathArray = ptNode.getPath(); 318 TreePath path = new TreePath(pathArray); 319 _tree.expandPath(path); 322 323 return ptNode; 324 } 325 326 330 private PanelTreeNode _createPanel(String t) { return _createPanel(t, _rootNode); } 331 332 333 private void _createPanels() { 334 335 PanelTreeNode resourceLocNode = _createPanel("Resource Locations"); 336 _setupResourceLocPanel(resourceLocNode.getPanel()); 337 338 PanelTreeNode displayNode = _createPanel("Display Options"); 339 _setupDisplayPanel(displayNode.getPanel()); 340 341 PanelTreeNode fontNode = _createPanel("Fonts", displayNode); 342 _setupFontPanel(fontNode.getPanel()); 343 344 PanelTreeNode colorNode = _createPanel("Colors", displayNode); 345 _setupColorPanel(colorNode.getPanel()); 346 347 PanelTreeNode keystrokesNode = _createPanel("Key Bindings"); 348 _setupKeyBindingsPanel(keystrokesNode.getPanel()); 349 350 PanelTreeNode compilerOptionsNode = _createPanel("Compiler Options"); 351 _setupCompilerPanel(compilerOptionsNode.getPanel()); 352 353 PanelTreeNode debugNode = _createPanel("Debugger"); 354 _setupDebugPanel(debugNode.getPanel()); 355 356 PanelTreeNode javadocNode = _createPanel("Javadoc"); 357 _setupJavadocPanel(javadocNode.getPanel()); 358 359 PanelTreeNode notificationsNode = _createPanel("Notifications"); 360 _setupNotificationsPanel(notificationsNode.getPanel()); 361 362 PanelTreeNode miscNode = _createPanel("Miscellaneous"); 363 _setupMiscPanel(miscNode.getPanel()); 364 365 } 369 370 public <X> void addOptionComponent(ConfigPanel panel, OptionComponent<X> oc) { 371 panel.addComponent(oc); 372 oc.addChangeListener(_changeListener); 373 } 374 375 376 private void _setupResourceLocPanel(ConfigPanel panel) { 377 FileOptionComponent browserLoc = 378 new FileOptionComponent(OptionConstants.BROWSER_FILE, "Web Browser", this, 379 "<html>Location of a web browser to use for Javadoc and Help links.<br>" + 380 "If left blank, only the Web Browser Command will be used.<br>" + 381 "This is not necessary if a default browser is available on your system.", 382 _browserChooser); 383 addOptionComponent(panel, browserLoc); 384 385 StringOptionComponent browserCommand = 386 new StringOptionComponent(OptionConstants.BROWSER_STRING, "Web Browser Command", this, 387 "<html>Command to send to the web browser to view a web location.<br>" + 388 "The string <code><URL></code> will be replaced with the URL address.<br>" + 389 "This is not necessary if a default browser is available on your system."); 390 addOptionComponent(panel, browserCommand); 391 392 FileOptionComponent javacLoc = 393 new FileOptionComponent(OptionConstants.JAVAC_LOCATION, "Tools.jar Location", this, 394 "Optional location of the JDK's tools.jar, which contains the compiler and debugger.", 395 _fileOptionChooser); 396 javacLoc.setFileFilter(ClassPathFilter.ONLY); 397 addOptionComponent(panel, javacLoc); 398 399 addOptionComponent(panel, new VectorFileOptionComponent(OptionConstants.EXTRA_CLASSPATH, 400 "Extra Classpath", this, 401 "<html>Any directories or jar files to add to the classpath<br>"+ 402 "of the Compiler and Interactions Pane.</html>")); 403 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.STICKY_INTERACTIONS_DIRECTORY, 404 "Restore last working directory of the Interactions pane on start up", this, 405 "<html>Whether to restore the last working directory of the Interaction pane on start up,<br>"+ 406 "or to always use the value of the \"user.home\" Java property<br>"+ 407 "(currently "+System.getProperty("user.home")+").")); 408 409 panel.displayComponents(); 410 } 411 412 413 private void _setupDisplayPanel(ConfigPanel panel) { 414 415 addOptionComponent(panel, new ForcedChoiceOptionComponent(OptionConstants.LOOK_AND_FEEL, "Look and Feel", this, 416 "Changes the general appearance of DrJava.")); 417 418 addOptionComponent(panel, new ToolbarOptionComponent("Toolbar Buttons", this, 420 "How to display the toolbar buttons.")); 421 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.LINEENUM_ENABLED, 422 "Show All Line Numbers", this, 423 "Whether to show line numbers on the left side of the Definitions Pane.")); 424 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.WINDOW_STORE_POSITION, 425 "Save Main Window Position", this, 426 "Whether to save and restore the size and position of the main window.")); 427 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.DIALOG_CLIPBOARD_HISTORY_STORE_POSITION, 428 "Save \"Clipboard History\" Dialog Position", this, 429 "Whether to save and restore the size and position of the \"Clipboard History\" dialog.")); 430 addOptionComponent(panel, new ButtonComponent(new ActionListener() { 431 public void actionPerformed(ActionEvent e) { _mainFrame.resetClipboardHistoryDialogPosition(); } 432 }, "Reset \"Clipboard History\" Dialog Position and Size", this, "This resets the dialog position and size to its default values.")); 433 addOptionComponent(panel, new IntegerOptionComponent(OptionConstants.CLIPBOARD_HISTORY_SIZE, 434 "Size of Clipboard History", this, 435 "Determines how many entries are kept in the clipboard history.")); 436 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.DIALOG_GOTOFILE_STORE_POSITION, 437 "Save \"Go to File\" Dialog Position", this, 438 "Whether to save and restore the size and position of the \"Go to File\" dialog.")); 439 addOptionComponent(panel, new ButtonComponent(new ActionListener() { 440 public void actionPerformed(ActionEvent e) { _mainFrame.resetGotoFileDialogPosition(); } 441 }, "Reset \"Go to File\" Dialog Position and Size", this, "This resets the dialog position and size to its default values.")); 442 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.DIALOG_GOTOFILE_FULLY_QUALIFIED, 443 "Display Fully-Qualified Class Names in \"Go to File\" Dialog", this, 444 "Whether to also display fully-qualified class names in the \"Go to File\" dialog.\n"+ 445 "Enabling this option on network drives might cause the dialog to display after a slight delay.")); 446 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.DIALOG_COMPLETE_WORD_STORE_POSITION, 447 "Save \"Auto-Complete Word\" Dialog Position", this, 448 "Whether to save and restore the size and position of the \"Auto-Complete Word\" dialog.")); 449 addOptionComponent(panel, new ButtonComponent(new ActionListener() { 450 public void actionPerformed(ActionEvent e) { _mainFrame.resetCompleteWordDialogPosition(); } 451 }, "Reset \"Auto-Complete Word\" Dialog Position and Size", this, "This resets the dialog position and size to its default values.")); 452 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.DIALOG_COMPLETE_SCAN_CLASS_FILES, 453 "Scan Class Files For Auto-Completion After Each Compile", this, 454 "Whether to scan the class files after a compile to generate auto-completion class names.\n"+ 455 "Enabling this option will slow compiles down.")); 456 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.DIALOG_JAROPTIONS_STORE_POSITION, 457 "Save \"Create Jar File from Project\" Dialog Position", this, 458 "Whether to save and restore the position of the \"Create Jar File from Project\" dialog.")); 459 addOptionComponent(panel, new ButtonComponent(new ActionListener() { 460 public void actionPerformed(ActionEvent e) { 461 _mainFrame.resetJarOptionsDialogPosition(); 462 } 463 }, "Reset \"Create Jar File from Project\" Dialog Position", this, "This resets the dialog position to its default values.")); 464 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.DIALOG_OPENJAVADOC_STORE_POSITION, 465 "Save \"Open Javadoc\" Dialog Position", this, 466 "Whether to save and restore the size and position of the \"Open Javadoc\" dialog.")); 467 addOptionComponent(panel, new ButtonComponent(new ActionListener() { 468 public void actionPerformed(ActionEvent e) { _mainFrame.resetOpenJavadocDialogPosition(); } 469 }, "Reset \"Open Javadoc\" Dialog Position and Size", this, "This resets the dialog position and size to its default values.")); 470 panel.displayComponents(); 471 } 472 473 474 private void _setupFontPanel(ConfigPanel panel) { 475 addOptionComponent(panel, new FontOptionComponent(OptionConstants.FONT_MAIN, "Main Font", this, 476 "The font used for most text in DrJava.")); 477 addOptionComponent(panel, new FontOptionComponent(OptionConstants.FONT_LINE_NUMBERS, "Line Numbers Font", this, 478 "<html>The font for displaying line numbers on the left side of<br>" + 479 "the Definitions Pane if Show All Line Numbers is enabled.<br>" + 480 "Cannot be displayed larger than the Main Font.</html>")); 481 addOptionComponent(panel, new FontOptionComponent(OptionConstants.FONT_DOCLIST, "Document List Font", this, 482 "The font used in the list of open documents.")); 483 addOptionComponent(panel, new FontOptionComponent(OptionConstants.FONT_TOOLBAR, "Toolbar Font", this, 484 "The font used in the toolbar buttons.")); 485 if (CodeStatus.DEVELOPMENT) { 486 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.TEXT_ANTIALIAS, "Use anti-aliased text", this, 487 "Whether to graphically smooth the text.")); 488 } 489 panel.displayComponents(); 490 } 491 492 495 private void _setupColorPanel(ConfigPanel panel) { 496 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.DEFINITIONS_NORMAL_COLOR, "Normal Color", this, 497 "The default color for text in the Definitions Pane.")); 498 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.DEFINITIONS_KEYWORD_COLOR, "Keyword Color", this, 499 "The color for Java keywords in the Definitions Pane.")); 500 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.DEFINITIONS_TYPE_COLOR, "Type Color", this, 501 "The color for classes and types in the Definitions Pane.")); 502 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.DEFINITIONS_COMMENT_COLOR, "Comment Color", this, 503 "The color for comments in the Definitions Pane.")); 504 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.DEFINITIONS_DOUBLE_QUOTED_COLOR, "Double-quoted Color", this, 505 "The color for quoted strings (eg. \"...\") in the Definitions Pane.")); 506 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.DEFINITIONS_SINGLE_QUOTED_COLOR, "Single-quoted Color", this, 507 "The color for quoted characters (eg. 'a') in the Definitions Pane.")); 508 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.DEFINITIONS_NUMBER_COLOR, "Number Color", this, 509 "The color for numbers in the Definitions Pane.")); 510 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.DEFINITIONS_BACKGROUND_COLOR, "Background Color", this, 511 "The background color of the Definitions Pane.", true)); 512 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.DEFINITIONS_MATCH_COLOR, "Brace-matching Color", this, 513 "The color for matching brace highlights in the Definitions Pane.", true)); 514 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.COMPILER_ERROR_COLOR, "Compiler Error Color", this, 515 "The color for compiler error highlights in the Definitions Pane.", true)); 516 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.BOOKMARK_COLOR, "Bookmark Color", this, 517 "The color for bookmarks in the Definitions Pane.", true)); 518 for (int i=0; i<OptionConstants.FIND_RESULTS_COLORS.length; ++i) { 519 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.FIND_RESULTS_COLORS[i], "Find Results Color "+(i+1), this, 520 "A color for highlighting find results in the Definitions Pane.", true)); 521 } 522 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.DEBUG_BREAKPOINT_COLOR, "Debugger Breakpoint Color", this, 523 "The color for breakpoints in the Definitions Pane.", true)); 524 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.DEBUG_BREAKPOINT_DISABLED_COLOR, "Disabled Debugger Breakpoint Color", this, 525 "The color for disabled breakpoints in the Definitions Pane.", true)); 526 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.DEBUG_THREAD_COLOR, "Debugger Location Color", this, 527 "The color for the location of the current suspended thread in the Definitions Pane.", true)); 528 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.SYSTEM_OUT_COLOR, "System.out Color", this, 529 "The color for System.out in the Interactions and Console Panes.")); 530 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.SYSTEM_ERR_COLOR, "System.err Color", this, 531 "The color for System.err in the Interactions and Console Panes.")); 532 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.SYSTEM_IN_COLOR, "System.in Color", this, 533 "The color for System.in in the Interactions Pane.")); 534 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.INTERACTIONS_ERROR_COLOR, "Interactions Error Color", this, 535 "The color for interactions errors in the Interactions Pane.", false, true)); 536 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.DEBUG_MESSAGE_COLOR, "Debug Message Color", this, 537 "The color for debugger messages in the Interactions Pane.", false, true)); 538 addOptionComponent(panel, new ColorOptionComponent(OptionConstants.DRJAVA_ERRORS_BUTTON_COLOR, "DrJava Errors Button Background Color", this, 539 "The background color of the \"Errors\" button used to show internal DrJava errors.", true)); 540 541 panel.displayComponents(); 542 } 543 544 547 private void _setupKeyBindingsPanel(ConfigPanel panel) { 548 TreeSet <KeyStrokeOptionComponent> _comps = new TreeSet <KeyStrokeOptionComponent>(); 550 551 KeyStrokeData tmpKsd; 552 KeyStrokeOptionComponent tmpKsoc; 553 554 Enumeration e = KeyBindingManager.Singleton.getKeyStrokeData(); 555 while (e.hasMoreElements()) { 556 tmpKsd = (KeyStrokeData) e.nextElement(); 557 if (tmpKsd.getOption() != null) { 558 Action a = tmpKsd.getAction(); 562 String desc = (String ) a.getValue(Action.SHORT_DESCRIPTION); 563 if ((desc == null) || (desc.equals(""))) { 564 desc = tmpKsd.getName(); 565 } 566 567 tmpKsoc = new KeyStrokeOptionComponent((KeyStrokeOption)tmpKsd.getOption(), 568 tmpKsd.getName(), this, desc); 569 if (tmpKsoc != null) { 570 _comps.add(tmpKsoc); 571 } 572 } 573 } 574 575 Iterator <KeyStrokeOptionComponent> iter = _comps.iterator(); 576 while (iter.hasNext()) { 577 KeyStrokeOptionComponent x = iter.next(); 578 addOptionComponent(panel, x); 579 } 580 panel.displayComponents(); 581 } 582 583 586 private void _setupDebugPanel(ConfigPanel panel) { 587 if (!_mainFrame.getModel().getDebugger().isAvailable()) { 588 String howto = 590 "\nThe debugger is not currently active. To use the debugger, you\n" + 591 "must include Sun's tools.jar or jpda.jar on your classpath when\n" + 592 "starting DrJava. Do not use the \"-jar\" option, because it\n" + 593 "overrides the classpath and will not include tools.jar.\n" + 594 "For example, in Windows you might type:\n\n" + 595 " java -classpath drjava.jar;c:\\path\\tools.jar edu.rice.cs.drjava.DrJava\n\n" + 596 "(Substituting the correct path for tools.jar.)\n" + 597 "See the user documentation for more details.\n"; 598 addOptionComponent(panel, new LabelComponent(howto, this)); 599 } 600 601 VectorFileOptionComponent sourcePath = 602 new VectorFileOptionComponent(OptionConstants.DEBUG_SOURCEPATH, "Sourcepath", this, 603 "<html>Any directories in which to search for source<br>" + 604 "files when stepping in the Debugger.</html>"); 605 sourcePath.setFileFilter(new DirectoryFilter("Source Directories")); 607 addOptionComponent(panel, sourcePath); 608 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.DEBUG_STEP_JAVA, 609 "Step Into Java Classes", this, 610 "<html>Whether the Debugger should step into Java library classes,<br>" + 611 "including java.*, javax.*, sun.*, com.sun.*, com.apple.eawt.*, and com.apple.eio.*</html>")); 612 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.DEBUG_STEP_INTERPRETER, 613 "Step Into Interpreter Classes", this, 614 "<html>Whether the Debugger should step into the classes<br>" + 615 "used by the Interactions Pane (DynamicJava).</html>")); 616 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.DEBUG_STEP_DRJAVA, 617 "Step Into DrJava Classes", this, 618 "Whether the Debugger should step into DrJava's own class files.")); 619 addOptionComponent(panel, new StringOptionComponent(OptionConstants.DEBUG_STEP_EXCLUDE, 620 "Classes/Packages To Exclude", this, 621 "<html>Any classes that the debuggger should not step into.<br>" + 622 "Should be a COMMA-separated list of fully-qualified class names.<br>" + 623 "To exclude a package, specify <code>packagename.*</code> in the list.</html>")); 624 625 panel.displayComponents(); 626 } 627 628 629 private void _setupJavadocPanel(ConfigPanel panel) { 630 addOptionComponent(panel, 631 new ForcedChoiceOptionComponent(OptionConstants.JAVADOC_ACCESS_LEVEL, 632 "Access Level", this, 633 "<html>Fields and methods with access modifiers at this level<br>" + 634 "or higher will be included in the generated Javadoc.</html>")); 635 addOptionComponent(panel, 636 new ForcedChoiceOptionComponent(OptionConstants.JAVADOC_LINK_VERSION, 637 "Java Version for Javadoc Links", this, 638 "The version of Java for generating links to online Javadoc documentation.")); 639 addOptionComponent(panel, 640 new StringOptionComponent(OptionConstants.JAVADOC_1_3_LINK, 641 "Javadoc 1.3 URL", this, 642 "The URL to the Java 1.3 API, for generating links to library classes.")); 643 addOptionComponent(panel, 644 new StringOptionComponent(OptionConstants.JAVADOC_1_4_LINK, 645 "Javadoc 1.4 URL", this, 646 "The URL to the Java 1.4 API, for generating links to library classes.")); 647 addOptionComponent(panel, 648 new StringOptionComponent(OptionConstants.JAVADOC_1_5_LINK, 649 "Javadoc 1.5 URL", this, 650 "The URL to the Java 1.5 API, for generating links to library classes.")); 651 652 addOptionComponent(panel, 653 new DirectoryOptionComponent(OptionConstants.JAVADOC_DESTINATION, 654 "Default Destination Directory", this, 655 "Optional default directory for saving Javadoc documentation.", 656 _dirChooser)); 657 658 addOptionComponent(panel, 659 new StringOptionComponent(OptionConstants.JAVADOC_CUSTOM_PARAMS, 660 "Custom Javadoc Parameters", this, 661 "Any extra flags or parameters to pass to Javadoc.")); 662 663 addOptionComponent(panel, 664 new BooleanOptionComponent(OptionConstants.JAVADOC_FROM_ROOTS, 665 "Generate Javadoc From Source Roots", this, 666 "<html>Whether 'Javadoc All' should generate Javadoc for all packages<br>" + 667 "in an open document's source tree, rather than just the document's<br>" + 668 "own package and sub-packages.</html>")); 669 670 panel.displayComponents(); 671 } 672 673 674 private void _setupNotificationsPanel(ConfigPanel panel) { 675 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.QUIT_PROMPT, "Prompt Before Quit", this, 677 "Whether DrJava should prompt the user before quitting.")); 678 679 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.INTERACTIONS_RESET_PROMPT, 681 "Prompt Before Resetting Interactions Pane", this, 682 "<html>Whether DrJava should prompt the user before<br>" + 683 "manually resetting the interactions pane.</html>")); 684 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.INTERACTIONS_EXIT_PROMPT, 685 "Prompt if Interactions Pane Exits Unexpectedly", this, 686 "<html>Whether DrJava should show a dialog box if a program<br>" + 687 "in the Interactions Pane exits without the user clicking Reset.</html>")); 688 689 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.JAVADOC_PROMPT_FOR_DESTINATION, 691 "Prompt for Javadoc Destination", this, 692 "<html>Whether Javadoc should always prompt the user<br>" + 693 "to select a destination directory.</html>")); 694 695 696 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.PROMPT_BEFORE_CLEAN, 698 "Prompt before Cleaning Build Directory", this, 699 "<html>Whether DrJava should prompt before cleaning the<br>" + 700 "build directory of a project</html>")); 701 702 703 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.ALWAYS_SAVE_BEFORE_COMPILE, 705 "Automatically Save Before Compiling", this, 706 "<html>Whether DrJava should automatically save before<br>" + 707 "recompiling or ask the user each time.</html>")); 708 709 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.ALWAYS_COMPILE_BEFORE_JUNIT, "Automatically Compile Before Testing", this, 710 "<html>Whether DrJava should automatically compile before<br>" + 711 "testing with JUnit or ask the user each time.</html>")); 712 713 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.ALWAYS_SAVE_BEFORE_JAVADOC, 714 "Automatically Save Before Generating Javadoc", this, 715 "<html>Whether DrJava should automatically save before<br>" + 716 "generating Javadoc or ask the user each time.</html>")); 717 718 719 727 728 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.WARN_BREAKPOINT_OUT_OF_SYNC, 730 "Warn on Breakpoint if Out of Sync", this, 731 "<html>Whether DrJava should warn the user if the class file<br>" + 732 "is out of sync before setting a breakpoint in that file.</html>")); 733 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.WARN_DEBUG_MODIFIED_FILE, 734 "Warn if Debugging Modified File", this, 735 "<html>Whether DrJava should warn the user if the file being<br>" + 736 "debugged has been modified since its last save.</html>")); 737 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.WARN_CHANGE_LAF, 738 "Warn to Restart to Change Look and Feel", this, 739 "<html>Whether DrJava should warn the user that look and feel<br>" + 740 "changes will not be applied until DrJava is restarted.</html>.")); 741 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.WARN_PATH_CONTAINS_POUND, 742 "Warn if File's Path Contains a '#' Symbol", this, 743 "<html>Whether DrJava should warn the user if the file being<br>" + 744 "saved has a path that contains a '#' symbol.<br>" + 745 "Users cannot use such files in the Interactions Pane<br>" + 746 "because of a bug in Java.</html>")); 747 748 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.DIALOG_DRJAVA_ERROR_POPUP_ENABLED, 749 "Show a notification window when the first DrJava error occurs", this, 750 "<html>Whether to show a notification window when the first DrJava error occurs.<br>"+ 751 "If this is disabled, only the \"DrJava Error\" button will appear.</html>")); 752 753 panel.displayComponents(); 754 } 755 756 757 private void _setupMiscPanel(ConfigPanel panel) { 758 759 addOptionComponent(panel, new IntegerOptionComponent(OptionConstants.INDENT_LEVEL, 760 "Indent Level", this, 761 "The number of spaces to use for each level of indentation.")); 762 addOptionComponent(panel, new IntegerOptionComponent(OptionConstants.HISTORY_MAX_SIZE, "Size of Interactions History", this, 763 "The number of interactions to remember in the history.")); 764 addOptionComponent(panel, new IntegerOptionComponent(OptionConstants.RECENT_FILES_MAX_SIZE, "Recent Files List Size", this, 765 "<html>The number of files to remember in<br>" + 766 "the recently used files list in the File menu.</html>")); 767 addOptionComponent(panel, new StringOptionComponent(OptionConstants.MASTER_JVM_ARGS, "JVM Args for Main JVM", this, 768 "The command-line arguments to pass to the Main JVM.")); 769 addOptionComponent(panel, new StringOptionComponent(OptionConstants.SLAVE_JVM_ARGS, "JVM Args for Interactions JVM", this, 770 "The command-line arguments to pass to the Interactions JVM.")); 771 addOptionComponent(panel, new IntegerOptionComponent(OptionConstants.BROWSER_HISTORY_MAX_SIZE, 772 "Maximum Size of Browser History", this, 773 "Determines how many entries are kept in the browser history.")); 774 775 776 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.AUTO_CLOSE_COMMENTS, "Automatically Close Block Comments", this, 777 "<html>Whether to automatically insert a closing comment tag (\"*/\")<br>" + 778 "when the enter key is pressed after typing a new block comment<br>" + 779 "tag (\"/*\" or \"/**\").</html>")); 780 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.RUN_WITH_ASSERT, "Enable Assert Statement Execution", this, 781 "<html>Whether to execute <code>assert</code> statements in classes running in the interactions pane.</html>")); 782 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.BACKUP_FILES, "Keep Emacs-style Backup Files", this, 783 "<html>Whether DrJava should keep a backup copy of each file that<br>" + 784 "the user modifies, saved with a '~' at the end of the filename.</html>")); 785 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.RESET_CLEAR_CONSOLE, "Clear Console After Interactions Reset", this, 786 "Whether to clear the Console output after resetting the Interactions Pane.")); 787 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.ALLOW_PRIVATE_ACCESS, "Allow Access of Private Members in Interactions Pane", this, 788 "Whether to allow users to access private (and protected) fields and methods.")); 789 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.SHOW_SOURCE_WHEN_SWITCHING, "Show sample of source code when fast switching", this, 790 "Whether to show a sample of the source code under the document's filename when fast switching documents.")); 791 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.FORCE_TEST_SUFFIX, 792 "Require test classes in projects to end in \"Test\"", this, 793 "Whether to force test classes in projects to end in \"Test\".")); 794 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.FIND_REPLACE_FOCUS_IN_DEFPANE, 795 "Put the focus in the definitions pane after find/replace", this, 796 "<html>Whether to put the focus in the definitions pane after doing a find or replace operation.<br>"+ 797 "If this is not selected, the focus will be in the Find/Replace pane.</html>")); 798 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.SHOW_CODE_PREVIEW_POPUPS, 799 "Show Code Preview Popups", this, 800 "<html>Whether to show a popup window with a code preview when the mouse is hovering<br>"+ 801 "over an item in the Breakpoints, Bookmarks and Find All panes.</html>")); 802 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.DRJAVA_USE_FORCE_QUIT, 803 "Forcefully Quit DrJava", this, 804 "<html>On some platforms, DrJava does not shut down properly when files are open<br>"+ 805 "(namely tablet PCs). Check this option to force DrJava to close.</html>")); 806 807 815 panel.displayComponents(); 816 } 817 818 821 private void _setupCompilerPanel(ConfigPanel panel) { 822 addOptionComponent(panel, new LabelComponent("Note: Compiler warnings not shown if compiling any Java language level files", this)); 823 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.SHOW_UNCHECKED_WARNINGS, "Show Unchecked Warnings", this, 824 "<html>Warn about unchecked conversions involving parameterized types.</html>")); 825 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.SHOW_DEPRECATION_WARNINGS, "Show Deprecation Warnings", this, 826 "<html>Warn about each use or override of a deprecated method, field, or class.</html>")); 827 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.SHOW_PATH_WARNINGS, "Show Path Warnings", this, 828 "<html>Warn about nonexistent members of the classpath and sourcepath.</html>")); 829 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.SHOW_SERIAL_WARNINGS, "Show Serial Warnings", this, 830 "<html>Warn about missing <code>serialVersionUID</code> definitions on serializable classes.</html>")); 831 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.SHOW_FINALLY_WARNINGS, "Show Finally Warnings", this, 832 "<html>Warn about <code>finally</code> clauses that cannot complete normally.</html>")); 833 addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.SHOW_FALLTHROUGH_WARNINGS, "Show Fall-Through Warnings", this, 834 "<html>Warn about <code>switch</code> block cases that fall through to the next case.</html>")); 835 panel.displayComponents(); 836 837 } 838 839 843 private class PanelTreeNode extends DefaultMutableTreeNode { 844 845 private final ConfigPanel _panel; 846 847 public PanelTreeNode(String t) { 848 super(t); 849 _panel = new ConfigPanel(t); 850 } 851 852 public PanelTreeNode(ConfigPanel c) { 853 super(c.getTitle()); 854 _panel = c; 855 } 856 private ConfigPanel getPanel() { return _panel; } 857 858 861 private boolean update() { 862 863 boolean isValidUpdate = _panel.update(); 864 865 if (!isValidUpdate) { 867 869 873 TreeNode[] nodes = getPath(); 874 TreePath path = new TreePath(nodes); 875 _tree.expandPath(path); 876 _tree.setSelectionPath(path); 877 return false; 878 } 879 880 Enumeration childNodes = children(); 881 while (childNodes.hasMoreElements()) { 882 boolean isValidUpdateChildren = ((PanelTreeNode)childNodes.nextElement()).update(); 883 if (!isValidUpdateChildren) { 885 return false; 886 } 887 } 888 889 return true; 890 } 891 892 896 public void resetToCurrent() { 897 _panel.resetToCurrent(); 898 899 Enumeration childNodes = this.children(); 900 while (childNodes.hasMoreElements()) { 901 ((PanelTreeNode)childNodes.nextElement()).resetToCurrent(); 902 } 903 } 904 } 905 906 private class PanelTreeSelectionListener implements TreeSelectionListener { 907 public void valueChanged(TreeSelectionEvent e) { 908 Object o = _tree.getLastSelectedPathComponent(); 909 if (o instanceof PanelTreeNode) { 911 PanelTreeNode child = (PanelTreeNode) _tree.getLastSelectedPathComponent(); 913 _displayPanel(child.getPanel()); 914 } 915 } 916 } 917 } 918 | Popular Tags |