Clover coverage report - DrJava Test Coverage (drjava-20110828-r5448)
Coverage timestamp: Sun Aug 28 2011 03:13:33 CDT
file stats: LOC: 1,631   Methods: 87
NCLOC: 1,225   Classes: 3
 
 Source file Conditionals Statements Methods TOTAL
ConfigFrame.java 24.2% 67.3% 52.9% 59.6%
coverage coverage
 1    /*BEGIN_COPYRIGHT_BLOCK
 2    *
 3    * Copyright (c) 2001-2010, JavaPLT group at Rice University (drjava@rice.edu)
 4    * All rights reserved.
 5    *
 6    * Redistribution and use in source and binary forms, with or without
 7    * modification, are permitted provided that the following conditions are met:
 8    * * Redistributions of source code must retain the above copyright
 9    * notice, this list of conditions and the following disclaimer.
 10    * * Redistributions in binary form must reproduce the above copyright
 11    * notice, this list of conditions and the following disclaimer in the
 12    * documentation and/or other materials provided with the distribution.
 13    * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
 14    * names of its contributors may be used to endorse or promote products
 15    * derived from this software without specific prior written permission.
 16    *
 17    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 18    * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 19    * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 20    * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 21    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 22    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 23    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 24    * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 25    * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 26    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 27    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 28    *
 29    * This software is Open Source Initiative approved Open Source Software.
 30    * Open Source Initative Approved is a trademark of the Open Source Initiative.
 31    *
 32    * This file is part of DrJava. Download the current version of this project
 33    * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
 34    *
 35    * END_COPYRIGHT_BLOCK*/
 36   
 37    package edu.rice.cs.drjava.ui.config;
 38   
 39    import javax.swing.*;
 40    import javax.swing.event.*;
 41    import javax.swing.border.EmptyBorder;
 42    import java.awt.event.*;
 43    import java.awt.*;
 44    import java.util.Enumeration;
 45    import java.io.IOException;
 46    import java.io.File;
 47    import java.util.TreeMap;
 48    import java.util.Iterator;
 49   
 50    import javax.swing.tree.*;
 51   
 52    import edu.rice.cs.drjava.DrJava;
 53    import edu.rice.cs.drjava.config.*;
 54    import edu.rice.cs.drjava.ui.*;
 55    import edu.rice.cs.drjava.ui.KeyBindingManager.KeyStrokeData;
 56    import edu.rice.cs.drjava.platform.PlatformFactory;
 57    import edu.rice.cs.util.FileOps;
 58    import edu.rice.cs.util.StringOps;
 59    import edu.rice.cs.util.swing.FileSelectorComponent;
 60    import edu.rice.cs.util.swing.DirectoryChooser;
 61    import edu.rice.cs.util.swing.SwingFrame;
 62    import edu.rice.cs.util.swing.SwingWorker;
 63    import edu.rice.cs.util.swing.ProcessingDialog;
 64    import edu.rice.cs.plt.lambda.Runnable1;
 65    import edu.rice.cs.plt.reflect.JavaVersion;
 66   
 67    import static edu.rice.cs.drjava.ui.config.ConfigDescriptions.*;
 68   
 69    /** The frame for setting Configuration options on the fly
 70    * @version $Id: ConfigFrame.java 5439 2011-08-11 17:13:04Z rcartwright $
 71    */
 72    public class ConfigFrame extends SwingFrame {
 73   
 74    private static final int FRAME_WIDTH = 850;
 75    private static final int FRAME_HEIGHT = 550;
 76   
 77    private final MainFrame _mainFrame;
 78   
 79    // private JSplitPane _splitPane;
 80    private final JTree _tree;
 81    private final DefaultTreeModel _treeModel;
 82    private final PanelTreeNode _rootNode;
 83   
 84    private final JButton _okButton;
 85    private final JButton _applyButton;
 86    private final JButton _cancelButton;
 87    // private final JButton _saveSettingsButton;
 88    private final JPanel _mainPanel;
 89    private final JFileChooser _fileOptionChooser;
 90    private final JFileChooser _browserChooser;
 91    private final JFileChooser _jarChooser;
 92    private final DirectoryChooser _dirChooser;
 93    private final ConfigOptionListeners.RequiresInteractionsRestartListener<Boolean> _junitLocationEnabledListener;
 94    private final ConfigOptionListeners.RequiresInteractionsRestartListener<File> _junitLocationListener;
 95    private final ConfigOptionListeners.RequiresInteractionsRestartListener<String> _concJUnitChecksEnabledListener;
 96    private final ConfigOptionListeners.RequiresInteractionsRestartListener<File> _rtConcJUnitLocationListener;
 97   
 98    private StringOptionComponent javadocCustomParams;
 99   
 100    protected final String SEPS = " \t\n-,;.(";
 101   
 102    private OptionComponent.ChangeListener _changeListener = new OptionComponent.ChangeListener() {
 103  2 public Object value(Object oc) {
 104  2 _applyButton.setEnabled(true);
 105  2 return null;
 106    }
 107    };
 108   
 109    /** Sets up the frame and displays it. This a Swing view class! With the exception of initialization,
 110    * this code should only be executed in the event-handling thread. */
 111  38 public ConfigFrame(MainFrame frame) {
 112  38 super("Preferences");
 113   
 114  38 _mainFrame = frame;
 115  38 _junitLocationEnabledListener = new ConfigOptionListeners.
 116    RequiresInteractionsRestartListener<Boolean>(this, "Use External JUnit");
 117  38 _junitLocationListener = new ConfigOptionListeners.
 118    RequiresInteractionsRestartListener<File>(this, "JUnit Location");
 119  38 _concJUnitChecksEnabledListener = new ConfigOptionListeners.
 120    RequiresInteractionsRestartListener<String>(this, "Enabled ConcJUnit Checks");
 121  38 _rtConcJUnitLocationListener = new ConfigOptionListeners.
 122    RequiresInteractionsRestartListener<File>(this, "ConcJUnit Runtime Location");
 123   
 124  38 Action applyAction = new AbstractAction("Apply") {
 125  0 public void actionPerformed(ActionEvent e) {
 126    // Always save settings
 127  0 try {
 128    // _mainFrame.enableResetInteractions();
 129  0 saveSettings();
 130  0 _applyButton.setEnabled(false);
 131   
 132    }
 133    catch (IOException ioe) {
 134    }
 135    }
 136    };
 137   
 138  38 _applyButton = new JButton(applyAction);
 139  38 _applyButton.setEnabled(false);
 140   
 141  38 Action okAction = new AbstractAction("OK") {
 142  0 public void actionPerformed(ActionEvent e) {
 143    // Always apply and save settings
 144  0 boolean successful = true;
 145  0 try {
 146    // _mainFrame.enableResetInteractions();
 147  0 successful = saveSettings();
 148    }
 149    catch (IOException ioe) {
 150    // oh well...
 151    }
 152  0 if (successful) _applyButton.setEnabled(false);
 153  0 ConfigFrame.this.setVisible(false);
 154    }
 155    };
 156  38 _okButton = new JButton(okAction);
 157   
 158   
 159  38 Action cancelAction = new AbstractAction("Cancel") {
 160  0 public void actionPerformed(ActionEvent e) {
 161  0 cancel();
 162    }
 163    };
 164  38 _cancelButton = new JButton(cancelAction);
 165   
 166  38 File workDir = _getWorkDir();
 167    /* Following line was inserted becuase the statement below it would occasionally cause swing to throw a
 168    NullPointerException. workDir == null is supposed to be impossible. */
 169  0 if (workDir == null || workDir == FileOps.NULL_FILE) workDir = new File(System.getProperty("user.dir"));
 170  38 _fileOptionChooser = new JFileChooser(workDir);
 171  38 _jarChooser = new JFileChooser(workDir);
 172  38 _browserChooser = new JFileChooser(workDir);
 173  38 _dirChooser = new DirectoryChooser(this);
 174   
 175    /* Create tree and initialize tree. */
 176  38 _rootNode = new PanelTreeNode("Preferences");
 177  38 _treeModel = new DefaultTreeModel(_rootNode);
 178  38 _tree = new JTree(_treeModel);
 179   
 180  38 _initTree();
 181   
 182    /* Create Panels. */
 183  38 _createPanels();
 184   
 185  38 _mainPanel= new JPanel();
 186  38 _mainPanel.setLayout(new BorderLayout());
 187  38 _tree.addTreeSelectionListener(new PanelTreeSelectionListener());
 188   
 189  38 Container cp = getContentPane();
 190  38 cp.setLayout(new BorderLayout());
 191   
 192    // Select the first panel by default
 193  38 if (_rootNode.getChildCount() != 0) {
 194  38 PanelTreeNode firstChild = (PanelTreeNode)_rootNode.getChildAt(0);
 195  38 TreeNode[] firstChildPath = firstChild.getPath();
 196  38 TreePath path = new TreePath(firstChildPath);
 197  38 _tree.expandPath(path);
 198  38 _tree.setSelectionPath(path);
 199    }
 200   
 201  38 JScrollPane treeScroll = new JScrollPane(_tree);
 202  38 JPanel treePanel = new JPanel();
 203  38 treePanel.setLayout(new BorderLayout());
 204  38 treeScroll.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Categories"));
 205  38 treePanel.add(treeScroll, BorderLayout.CENTER);
 206  38 cp.add(treePanel, BorderLayout.WEST);
 207  38 cp.add(_mainPanel, BorderLayout.CENTER);
 208   
 209    // Add buttons
 210  38 JPanel bottom = new JPanel();
 211  38 bottom.setBorder(new EmptyBorder(5,5,5,5));
 212  38 bottom.setLayout(new BoxLayout(bottom, BoxLayout.X_AXIS));
 213  38 bottom.add(Box.createHorizontalGlue());
 214    //bottom.add(_saveSettingsButton);
 215    //bottom.add(Box.createHorizontalGlue());
 216  38 bottom.add(_applyButton);
 217  38 bottom.add(_okButton);
 218  38 bottom.add(_cancelButton);
 219  38 bottom.add(Box.createHorizontalGlue());
 220   
 221  38 cp.add(bottom, BorderLayout.SOUTH);
 222   
 223    // Set all dimensions ----
 224  38 Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
 225  38 if (dim.width>FRAME_WIDTH) { dim.width = FRAME_WIDTH; }
 226  0 else { dim.width -= 80; }
 227  38 if (dim.height>FRAME_HEIGHT) { dim.height = FRAME_HEIGHT; }
 228  0 else { dim.height -= 80; }
 229  38 setSize(dim);
 230   
 231  38 _mainFrame.setPopupLoc(this);
 232   
 233    // Make sure each row is expanded
 234  38 int row = 0;
 235  38 while(row<_tree.getRowCount()) {
 236  570 _tree.expandRow(row);
 237  570 ++row;
 238    }
 239   
 240  38 initDone(); // call mandated by SwingFrame contract
 241    }
 242   
 243    /** Performs deferred initialization. Only runs in the event thread. Some of this code occasionally generated swing
 244    * exceptions when run in themain thread as part of MainFrame construction prior to making MainFrame visible. */
 245  0 public void setUp() {
 246  0 assert EventQueue.isDispatchThread();
 247    /* Set up _fileOptionChooser, _browserChooser, and _dirChooser. The line _dirChooser.setSelectedFile(...) caused
 248    * java.lang.ArrayIndexOutOfBoundsException within swing code in a JUnit test setUp() routine that constructed a
 249    * a MainFrame.
 250    */
 251   
 252  0 _fileOptionChooser.setDialogTitle("Select");
 253  0 _fileOptionChooser.setApproveButtonText("Select");
 254  0 _fileOptionChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
 255  0 _fileOptionChooser.setFileFilter(ClassPathFilter.ONLY);
 256   
 257  0 _jarChooser.setDialogTitle("Select");
 258  0 _jarChooser.setApproveButtonText("Select");
 259  0 _jarChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
 260  0 _jarChooser.setFileFilter(ClassPathFilter.ONLY);
 261   
 262  0 _browserChooser.setDialogTitle("Select Web Browser");
 263  0 _browserChooser.setApproveButtonText("Select");
 264  0 _browserChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
 265   
 266  0 _dirChooser.setSelectedFile(_getWorkDir());
 267  0 _dirChooser.setDialogTitle("Select");
 268  0 _dirChooser.setApproveButtonText("Select");
 269  0 _dirChooser.setMultiSelectionEnabled(false);
 270    }
 271   
 272  0 private void enableChangeListeners() {
 273  0 DrJava.getConfig().addOptionListener(OptionConstants.JUNIT_LOCATION_ENABLED,
 274    _junitLocationEnabledListener);
 275  0 DrJava.getConfig().addOptionListener(OptionConstants.JUNIT_LOCATION,
 276    _junitLocationListener);
 277  0 DrJava.getConfig().addOptionListener(OptionConstants.CONCJUNIT_CHECKS_ENABLED,
 278    _concJUnitChecksEnabledListener);
 279  0 DrJava.getConfig().addOptionListener(OptionConstants.RT_CONCJUNIT_LOCATION,
 280    _rtConcJUnitLocationListener);
 281    }
 282   
 283  0 private void disableChangeListeners() {
 284  0 DrJava.getConfig().removeOptionListener(OptionConstants.JUNIT_LOCATION_ENABLED,
 285    _junitLocationEnabledListener);
 286  0 DrJava.getConfig().removeOptionListener(OptionConstants.JUNIT_LOCATION,
 287    _junitLocationListener);
 288  0 DrJava.getConfig().removeOptionListener(OptionConstants.CONCJUNIT_CHECKS_ENABLED,
 289    _concJUnitChecksEnabledListener);
 290  0 DrJava.getConfig().removeOptionListener(OptionConstants.RT_CONCJUNIT_LOCATION,
 291    _rtConcJUnitLocationListener);
 292    }
 293   
 294    /** Returns the current master working directory, or the user's current directory if none is set. 20040213 Changed default
 295    * value to user's current directory.
 296    */
 297  38 private File _getWorkDir() {
 298  38 File workDir = _mainFrame.getModel().getMasterWorkingDirectory(); // cannot be null
 299  38 assert workDir != null;
 300  38 if (workDir.isDirectory()) return workDir;
 301   
 302  0 if (workDir.getParent() != null) workDir = workDir.getParentFile();
 303  0 return workDir;
 304    }
 305   
 306    /** Call the update method to propagate down the tree, parsing input values into their config options. */
 307  0 public boolean apply() {
 308    // returns false if the update did not succeed
 309  0 return _rootNode.update();
 310    }
 311   
 312    /** Resets the field of each option in the Preferences window to its actual stored value. */
 313  0 public void resetToCurrent() {
 314  0 _rootNode.resetToCurrent();
 315    // must reset the "current keystroke map" when resetting
 316  0 VectorKeyStrokeOptionComponent.resetCurrentKeyStrokeMap();
 317    }
 318   
 319    /** Resets the frame and hides it. */
 320  0 public void cancel() {
 321  0 resetToCurrent();
 322  0 _applyButton.setEnabled(false);
 323  0 ConfigFrame.this.setVisible(false);
 324    }
 325   
 326    /** Thunk that calls _cancel. */
 327    protected final Runnable1<WindowEvent> CANCEL = new Runnable1<WindowEvent>() {
 328  0 public void run(WindowEvent e) { cancel(); }
 329    };
 330   
 331    /** Validates before changing visibility. Only runs in the event thread.
 332    * @param vis true if frame should be shown, false if it should be hidden.
 333    */
 334  0 public void setVisible(boolean vis) {
 335  0 assert EventQueue.isDispatchThread();
 336  0 validate();
 337    // made modal for now
 338  0 if (vis) {
 339    // _mainFrame.hourglassOn();
 340    // _mainFrame.installModalWindowAdapter(this, NO_OP, CANCEL);
 341  0 enableChangeListeners();
 342  0 toFront();
 343    }
 344    else {
 345    // _mainFrame.removeModalWindowAdapter(this);
 346    // _mainFrame.hourglassOff();
 347  0 disableChangeListeners();
 348  0 _mainFrame.toFront();
 349    }
 350  0 super.setVisible(vis);
 351    }
 352   
 353    /** Write the configured option values to disk. */
 354  0 public boolean saveSettings() throws IOException {
 355  0 boolean successful = apply();
 356  0 if (successful) {
 357  0 try { DrJava.getConfig().saveConfiguration(); }
 358    catch (IOException ioe) {
 359  0 JOptionPane.showMessageDialog(this,
 360    "Could not save changes to your \".drjava\" file in your home directory. \n\n" + ioe,
 361    "Could Not Save Changes",
 362    JOptionPane.ERROR_MESSAGE);
 363    //return false;
 364  0 throw ioe;
 365    }
 366    }
 367  0 return successful;
 368    }
 369   
 370    /** Sets the given ConfigPanel as the visible panel. */
 371  38 private void _displayPanel(ConfigPanel cf) {
 372   
 373  38 _mainPanel.removeAll();
 374  38 _mainPanel.add(cf, BorderLayout.CENTER);
 375  38 _mainPanel.revalidate();
 376  38 _mainPanel.repaint();
 377    }
 378   
 379    /** Creates the JTree to display preferences categories. */
 380  38 private void _initTree() {
 381  38 _tree.setEditable(false);
 382  38 _tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
 383  38 _tree.setShowsRootHandles(true);
 384  38 _tree.setRootVisible(false);
 385   
 386  38 DefaultTreeCellRenderer dtcr = new DefaultTreeCellRenderer();
 387  38 dtcr.setLeafIcon(null);
 388  38 dtcr.setOpenIcon(null);
 389  38 dtcr.setClosedIcon(null);
 390  38 _tree.setCellRenderer(dtcr);
 391    }
 392   
 393    /**Creates an individual panel, adds it to the JTree and the list of panels, and returns the tree node.
 394    * @param t the title of this panel
 395    * @param parent the parent tree node
 396    * @return this tree node
 397    */
 398  570 private PanelTreeNode _createPanel(String t, PanelTreeNode parent) {
 399  570 PanelTreeNode ptNode = new PanelTreeNode(t);
 400    //parent.add(ptNode);
 401  570 _treeModel.insertNodeInto(ptNode, parent, parent.getChildCount());
 402   
 403    // Make sure tree node is visible
 404  570 TreeNode[] pathArray = ptNode.getPath();
 405  570 TreePath path = new TreePath(pathArray);
 406    // System.out.println("path has class " + pathArray.getClass());
 407    // System.out.println("last path compenent has class " + path.getLastPathComponent().getClass());
 408  570 _tree.expandPath(path);
 409   
 410  570 return ptNode;
 411    }
 412   
 413    /** Creates an individual panel, adds it to the JTree and the list of panels, and returns the tree node. Adds to the root node.
 414    * @param t the title of this panel
 415    * @return this tree node
 416    */
 417  380 private PanelTreeNode _createPanel(String t) { return _createPanel(t, _rootNode); }
 418   
 419    /** Creates all of the panels contained within the frame. */
 420  38 private void _createPanels() {
 421   
 422  38 PanelTreeNode resourceLocNode = _createPanel("Resource Locations");
 423  38 _setupResourceLocPanel(resourceLocNode.getPanel());
 424   
 425  38 PanelTreeNode displayNode = _createPanel("Display Options");
 426  38 _setupDisplayPanel(displayNode.getPanel());
 427   
 428  38 PanelTreeNode fontNode = _createPanel("Fonts", displayNode);
 429  38 _setupFontPanel(fontNode.getPanel());
 430   
 431  38 PanelTreeNode colorNode = _createPanel("Colors", displayNode);
 432  38 _setupColorPanel(colorNode.getPanel());
 433   
 434  38 PanelTreeNode positionsNode = _createPanel("Window Positions", displayNode);
 435  38 _setupPositionsPanel(positionsNode.getPanel());
 436   
 437  38 PanelTreeNode keystrokesNode = _createPanel("Key Bindings");
 438  38 _setupKeyBindingsPanel(keystrokesNode.getPanel());
 439   
 440  38 PanelTreeNode compilerOptionsNode = _createPanel("Compiler Options");
 441  38 _setupCompilerPanel(compilerOptionsNode.getPanel());
 442   
 443  38 PanelTreeNode interactionsNode = _createPanel("Interactions Pane");
 444  38 _setupInteractionsPanel(interactionsNode.getPanel());
 445   
 446  38 PanelTreeNode debugNode = _createPanel("Debugger");
 447  38 _setupDebugPanel(debugNode.getPanel());
 448   
 449  38 PanelTreeNode junitNode = _createPanel("JUnit");
 450  38 _setupJUnitPanel(junitNode.getPanel());
 451   
 452  38 PanelTreeNode javadocNode = _createPanel("Javadoc");
 453  38 _setupJavadocPanel(javadocNode.getPanel());
 454   
 455  38 PanelTreeNode notificationsNode = _createPanel("Notifications");
 456  38 _setupNotificationsPanel(notificationsNode.getPanel());
 457   
 458  38 PanelTreeNode miscNode = _createPanel("Miscellaneous");
 459  38 _setupMiscPanel(miscNode.getPanel());
 460   
 461  38 PanelTreeNode fileTypesNode = _createPanel("File Types", miscNode);
 462  38 _setupFileTypesPanel(fileTypesNode.getPanel());
 463   
 464  38 PanelTreeNode jvmsNode = _createPanel("JVMs", miscNode);
 465  38 _setupJVMsPanel(jvmsNode.getPanel());
 466   
 467    // Expand the display options node
 468    //DrJava.consoleOut().println("expanding path...");
 469    //_tree.expandPath(new TreePath(jvmsNode.getPath()));
 470    }
 471   
 472  18244 public <X,C extends JComponent> void addOptionComponent(ConfigPanel panel, OptionComponent<X,C> oc) {
 473  18244 panel.addComponent(oc);
 474  18244 oc.addChangeListener(_changeListener);
 475    }
 476   
 477  76 protected FileOptionComponent newFileOptionComponent(FileOption o, JFileChooser c) {
 478  76 return new FileOptionComponent(o, CONFIG_DESCRIPTIONS.get(o), this, CONFIG_LONG_DESCRIPTIONS.get(o), c);
 479    }
 480  76 protected FileOptionComponent newFileOptionComponent(FileOption o, FileSelectorComponent c) {
 481  76 return new FileOptionComponent(o, CONFIG_DESCRIPTIONS.get(o), this, CONFIG_LONG_DESCRIPTIONS.get(o), c);
 482    }
 483  304 protected StringOptionComponent newStringOptionComponent(StringOption o) {
 484  304 return new StringOptionComponent(o, CONFIG_DESCRIPTIONS.get(o), this, CONFIG_LONG_DESCRIPTIONS.get(o));
 485    }
 486  988 protected BooleanOptionComponent newBooleanOptionComponent(BooleanOption o) {
 487  988 return newBooleanOptionComponent(o, true);
 488    }
 489  2584 protected BooleanOptionComponent newBooleanOptionComponent(BooleanOption o, boolean left) {
 490  2584 return new BooleanOptionComponent(o, CONFIG_DESCRIPTIONS.get(o), this, CONFIG_LONG_DESCRIPTIONS.get(o), left);
 491    }
 492  76 protected VectorFileOptionComponent newVectorFileOptionComponent(VectorOption<File> o, boolean mbe) {
 493  76 return new VectorFileOptionComponent(o, CONFIG_DESCRIPTIONS.get(o), this, CONFIG_LONG_DESCRIPTIONS.get(o), mbe);
 494    }
 495  38 protected VectorStringOptionComponent newVectorStringOptionComponent(VectorOption<String> o, boolean mbe) {
 496  38 return new VectorStringOptionComponent(o, CONFIG_DESCRIPTIONS.get(o), this, CONFIG_LONG_DESCRIPTIONS.get(o), mbe);
 497    }
 498  456 protected ForcedChoiceOptionComponent newForcedChoiceOptionComponent(ForcedChoiceOption o) {
 499  456 return new ForcedChoiceOptionComponent(o, CONFIG_DESCRIPTIONS.get(o), this, CONFIG_LONG_DESCRIPTIONS.get(o));
 500    }
 501  418 protected IntegerOptionComponent newIntegerOptionComponent(IntegerOption o) {
 502  418 return new IntegerOptionComponent(o, CONFIG_DESCRIPTIONS.get(o), this, CONFIG_LONG_DESCRIPTIONS.get(o));
 503    }
 504  152 protected FontOptionComponent newFontOptionComponent(FontOption o) {
 505  152 return new FontOptionComponent(o, CONFIG_DESCRIPTIONS.get(o), this, CONFIG_LONG_DESCRIPTIONS.get(o));
 506    }
 507  76 protected ColorOptionComponent newColorOptionComponent(ColorOption o, boolean isBackground, boolean isBold) {
 508  76 return new ColorOptionComponent(o, CONFIG_DESCRIPTIONS.get(o), this, CONFIG_LONG_DESCRIPTIONS.get(o),
 509    isBackground, isBold);
 510    }
 511  684 protected ColorOptionComponent newColorOptionComponent(ColorOption o, boolean isBackground) {
 512  684 return new ColorOptionComponent(o, CONFIG_DESCRIPTIONS.get(o), this, CONFIG_LONG_DESCRIPTIONS.get(o),
 513    isBackground, false);
 514    }
 515  418 protected ColorOptionComponent newColorOptionComponent(ColorOption o) {
 516  418 return new ColorOptionComponent(o, CONFIG_DESCRIPTIONS.get(o), this, CONFIG_LONG_DESCRIPTIONS.get(o),
 517    false, false);
 518    }
 519  76 protected DirectoryOptionComponent newDirectoryOptionComponent(FileOption o, DirectoryChooser c) {
 520  76 return new DirectoryOptionComponent(o, CONFIG_DESCRIPTIONS.get(o), this, CONFIG_LONG_DESCRIPTIONS.get(o), c);
 521    }
 522   
 523    /** Add all of the components for the Resource Locations panel of the preferences window. */
 524  38 private void _setupResourceLocPanel(ConfigPanel panel) {
 525  38 FileOptionComponent browserLoc =
 526    newFileOptionComponent(OptionConstants.BROWSER_FILE, _browserChooser);
 527  38 addOptionComponent(panel, browserLoc);
 528   
 529  38 StringOptionComponent browserCommand =
 530    newStringOptionComponent(OptionConstants.BROWSER_STRING);
 531  38 addOptionComponent(panel, browserCommand);
 532   
 533  38 FileOptionComponent javacLoc =
 534    newFileOptionComponent(OptionConstants.JAVAC_LOCATION, _fileOptionChooser);
 535  38 javacLoc.setFileFilter(ClassPathFilter.ONLY);
 536  38 addOptionComponent(panel, javacLoc);
 537   
 538  38 BooleanOptionComponent displayAllCompilerVersions =
 539    newBooleanOptionComponent(OptionConstants.DISPLAY_ALL_COMPILER_VERSIONS);
 540  38 addOptionComponent(panel, displayAllCompilerVersions );
 541   
 542  38 addOptionComponent(panel, newVectorFileOptionComponent(OptionConstants.EXTRA_CLASSPATH, true));
 543   
 544  38 panel.displayComponents();
 545   
 546    }
 547   
 548    /** Add all of the components for the Display Options panel of the preferences window. */
 549  38 private void _setupDisplayPanel(ConfigPanel panel) {
 550   
 551  38 final ForcedChoiceOptionComponent lookAndFeelComponent =
 552    newForcedChoiceOptionComponent(OptionConstants.LOOK_AND_FEEL);
 553  38 addOptionComponent(panel, lookAndFeelComponent);
 554   
 555  38 final ForcedChoiceOptionComponent plasticComponent =
 556    newForcedChoiceOptionComponent(OptionConstants.PLASTIC_THEMES);
 557  38 lookAndFeelComponent.addChangeListener(new OptionComponent.ChangeListener() {
 558  0 public Object value(Object oc) {
 559  0 plasticComponent.getComponent().setEnabled(lookAndFeelComponent.getCurrentComboBoxValue().
 560    startsWith("com.jgoodies.looks.plastic."));
 561  0 return null;
 562    }
 563    });
 564  38 plasticComponent.getComponent().setEnabled(lookAndFeelComponent.getCurrentComboBoxValue().
 565    startsWith("com.jgoodies.looks.plastic."));
 566  38 addOptionComponent(panel, plasticComponent);
 567   
 568    //ToolbarOptionComponent is a degenerate option component
 569  38 addOptionComponent(panel, new ToolbarOptionComponent("Toolbar Buttons", this,
 570    "How to display the toolbar buttons."));
 571  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.LINEENUM_ENABLED));
 572   
 573  38 addOptionComponent(panel,
 574    newBooleanOptionComponent(OptionConstants.SHOW_SOURCE_WHEN_SWITCHING));
 575   
 576  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.SHOW_CODE_PREVIEW_POPUPS));
 577   
 578  38 addOptionComponent(panel, newIntegerOptionComponent(OptionConstants.CLIPBOARD_HISTORY_SIZE));
 579   
 580  38 BooleanOptionComponent checkbox =
 581    newBooleanOptionComponent(OptionConstants.DIALOG_GOTOFILE_FULLY_QUALIFIED);
 582  38 addOptionComponent(panel, checkbox);
 583   
 584  38 checkbox =
 585    newBooleanOptionComponent(OptionConstants.DIALOG_COMPLETE_SCAN_CLASS_FILES);
 586  38 addOptionComponent(panel, checkbox);
 587   
 588  38 checkbox =
 589    newBooleanOptionComponent(OptionConstants.DIALOG_COMPLETE_JAVAAPI);
 590  38 addOptionComponent(panel, checkbox);
 591   
 592  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 593   
 594  38 final BooleanOptionComponent drmComponent =
 595    newBooleanOptionComponent(OptionConstants.DISPLAY_RIGHT_MARGIN);
 596  38 addOptionComponent(panel, drmComponent);
 597  38 final IntegerOptionComponent rmcComponent =
 598    newIntegerOptionComponent(OptionConstants.RIGHT_MARGIN_COLUMNS);
 599  38 addOptionComponent(panel, rmcComponent);
 600   
 601  38 OptionComponent.ChangeListener drmListener = new OptionComponent.ChangeListener() {
 602  38 public Object value(Object oc) {
 603  38 rmcComponent.getComponent().setEnabled(drmComponent.getComponent().isSelected());
 604  38 return null;
 605    }
 606    };
 607  38 drmComponent.addChangeListener(drmListener);
 608  38 drmListener.value(drmComponent);
 609   
 610  38 panel.displayComponents();
 611    }
 612   
 613    /** Add all of the components for the Font panel of the preferences window. */
 614  38 private void _setupFontPanel(ConfigPanel panel) {
 615  38 addOptionComponent(panel, newFontOptionComponent(OptionConstants.FONT_MAIN));
 616  38 addOptionComponent(panel, newFontOptionComponent(OptionConstants.FONT_LINE_NUMBERS));
 617  38 addOptionComponent(panel, newFontOptionComponent(OptionConstants.FONT_DOCLIST));
 618  38 addOptionComponent(panel, newFontOptionComponent(OptionConstants.FONT_TOOLBAR));
 619  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.TEXT_ANTIALIAS));
 620  38 panel.displayComponents();
 621    }
 622   
 623    /** Adds all of the components for the Color panel of the preferences window.
 624    */
 625  38 private void _setupColorPanel(ConfigPanel panel) {
 626  38 addOptionComponent(panel, newColorOptionComponent(OptionConstants.DEFINITIONS_NORMAL_COLOR));
 627  38 addOptionComponent(panel, newColorOptionComponent(OptionConstants.DEFINITIONS_KEYWORD_COLOR));
 628  38 addOptionComponent(panel, newColorOptionComponent(OptionConstants.DEFINITIONS_TYPE_COLOR));
 629  38 addOptionComponent(panel, newColorOptionComponent(OptionConstants.DEFINITIONS_COMMENT_COLOR));
 630  38 addOptionComponent(panel, newColorOptionComponent(OptionConstants.DEFINITIONS_DOUBLE_QUOTED_COLOR));
 631  38 addOptionComponent(panel, newColorOptionComponent(OptionConstants.DEFINITIONS_SINGLE_QUOTED_COLOR));
 632  38 addOptionComponent(panel, newColorOptionComponent(OptionConstants.DEFINITIONS_NUMBER_COLOR));
 633  38 addOptionComponent(panel, newColorOptionComponent(OptionConstants.DEFINITIONS_BACKGROUND_COLOR, true));
 634  38 addOptionComponent(panel, newColorOptionComponent(OptionConstants.DEFINITIONS_LINE_NUMBER_COLOR));
 635  38 addOptionComponent(panel, newColorOptionComponent(OptionConstants.DEFINITIONS_LINE_NUMBER_BACKGROUND_COLOR, true));
 636  38 addOptionComponent(panel, newColorOptionComponent(OptionConstants.DEFINITIONS_MATCH_COLOR,true));
 637  38 addOptionComponent(panel, newColorOptionComponent(OptionConstants.COMPILER_ERROR_COLOR, true));
 638  38 addOptionComponent(panel, newColorOptionComponent(OptionConstants.BOOKMARK_COLOR, true));
 639  38 for (int i = 0; i < OptionConstants.FIND_RESULTS_COLORS.length; ++i) {
 640  304 addOptionComponent(panel, newColorOptionComponent(OptionConstants.FIND_RESULTS_COLORS[i], true));
 641    }
 642  38 addOptionComponent(panel,
 643    newColorOptionComponent(OptionConstants.DEBUG_BREAKPOINT_COLOR, true));
 644  38 addOptionComponent(panel,
 645    newColorOptionComponent(OptionConstants.DEBUG_BREAKPOINT_DISABLED_COLOR, true));
 646  38 addOptionComponent(panel,
 647    newColorOptionComponent(OptionConstants.DEBUG_THREAD_COLOR, true));
 648  38 addOptionComponent(panel, newColorOptionComponent(OptionConstants.SYSTEM_OUT_COLOR));
 649  38 addOptionComponent(panel, newColorOptionComponent(OptionConstants.SYSTEM_ERR_COLOR));
 650  38 addOptionComponent(panel, newColorOptionComponent(OptionConstants.SYSTEM_IN_COLOR));
 651  38 addOptionComponent(panel, newColorOptionComponent(OptionConstants.INTERACTIONS_ERROR_COLOR, false, true));
 652  38 addOptionComponent(panel, newColorOptionComponent(OptionConstants.DEBUG_MESSAGE_COLOR, false, true));
 653  38 addOptionComponent(panel,
 654    newColorOptionComponent(OptionConstants.DRJAVA_ERRORS_BUTTON_COLOR, true));
 655  38 addOptionComponent(panel,
 656    newColorOptionComponent(OptionConstants.RIGHT_MARGIN_COLOR, true));
 657   
 658  38 panel.displayComponents();
 659    }
 660   
 661    /** Add all of the components for the Positions panel of the preferences window. */
 662  38 private void _setupPositionsPanel(ConfigPanel panel) {
 663  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.WINDOW_STORE_POSITION, false)
 664    .setEntireColumn(true));
 665  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 666   
 667  38 addOptionComponent(panel,
 668    newBooleanOptionComponent(OptionConstants.DIALOG_CLIPBOARD_HISTORY_STORE_POSITION,false)
 669    .setEntireColumn(true));
 670  38 addOptionComponent(panel, new ButtonComponent(new ActionListener() {
 671  0 public void actionPerformed(ActionEvent e) { _mainFrame.resetClipboardHistoryDialogPosition(); }
 672    }, "Reset \"Clipboard History\" Dialog Position and Size", this, "This resets the dialog position and size to its default values."));
 673   
 674  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 675  38 addOptionComponent(panel,
 676    newBooleanOptionComponent(OptionConstants.DIALOG_GOTOFILE_STORE_POSITION, false)
 677    .setEntireColumn(true));
 678  38 addOptionComponent(panel, new ButtonComponent(new ActionListener() {
 679  0 public void actionPerformed(ActionEvent e) { _mainFrame.resetGotoFileDialogPosition(); }
 680    }, "Reset \"Go to File\" Dialog Position and Size", this, "This resets the dialog position and size to its default values."));
 681   
 682  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 683   
 684  38 addOptionComponent(panel,
 685    newBooleanOptionComponent(OptionConstants.DIALOG_COMPLETE_WORD_STORE_POSITION,false)
 686    .setEntireColumn(true));
 687   
 688  38 addOptionComponent(panel, new ButtonComponent(new ActionListener() {
 689  0 public void actionPerformed(ActionEvent e) { _mainFrame.resetCompleteWordDialogPosition(); }
 690    },
 691    "Reset \"Auto-Complete Word\" Dialog Position and Size", this,
 692    "This resets the dialog position and size to its default values."));
 693   
 694  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 695  38 addOptionComponent(panel,
 696    newBooleanOptionComponent(OptionConstants.DIALOG_JAROPTIONS_STORE_POSITION,false)
 697    .setEntireColumn(true));
 698  38 addOptionComponent(panel, new ButtonComponent(new ActionListener() {
 699  0 public void actionPerformed(ActionEvent e) {
 700  0 _mainFrame.resetJarOptionsDialogPosition();
 701    }
 702    }, "Reset \"Create Jar File from Project\" Dialog Position", this, "This resets the dialog position to its default values."));
 703   
 704  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 705  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.DIALOG_OPENJAVADOC_STORE_POSITION, false)
 706    .setEntireColumn(true));
 707  38 addOptionComponent(panel, new ButtonComponent(new ActionListener() {
 708  0 public void actionPerformed(ActionEvent e) { _mainFrame.resetOpenJavadocDialogPosition(); }
 709    }, "Reset \"Open Javadoc\" Dialog Position and Size", this, "This resets the dialog position and size to its default values."));
 710   
 711  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 712  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.DIALOG_AUTOIMPORT_STORE_POSITION, false)
 713    .setEntireColumn(true));
 714  38 addOptionComponent(panel, new ButtonComponent(new ActionListener() {
 715  0 public void actionPerformed(ActionEvent e) { _mainFrame.resetAutoImportDialogPosition(); }
 716    }, "Reset \"Auto Import\" Dialog Position and Size", this, "This resets the dialog position and size to its default values."));
 717   
 718  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 719  38 addOptionComponent(panel,
 720    newBooleanOptionComponent(OptionConstants.DIALOG_EXTERNALPROCESS_STORE_POSITION,false)
 721    .setEntireColumn(true));
 722  38 addOptionComponent(panel, new ButtonComponent(new ActionListener() {
 723  0 public void actionPerformed(ActionEvent e) {
 724  0 _mainFrame.resetExecuteExternalProcessPosition();
 725    }
 726    }, "Reset \"Execute External Process\" Dialog Position", this, "This resets the dialog position to its default values."));
 727   
 728  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 729  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.DIALOG_EDITEXTERNALPROCESS_STORE_POSITION, false)
 730    .setEntireColumn(true));
 731  38 addOptionComponent(panel, new ButtonComponent(new ActionListener() {
 732  0 public void actionPerformed(ActionEvent e) {
 733  0 _mainFrame.resetEditExternalProcessPosition();
 734    }
 735    }, "Reset \"Execute External Process\" Dialog Position", this, "This resets the dialog position to its default values."));
 736   
 737  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 738  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.DIALOG_OPENJAVADOC_STORE_POSITION, false)
 739    .setEntireColumn(true));
 740  38 addOptionComponent(panel, new ButtonComponent(new ActionListener() {
 741  0 public void actionPerformed(ActionEvent e) {
 742  0 _mainFrame.resetOpenJavadocDialogPosition();
 743    }
 744    }, "Reset \"Open Javadoc\" Dialog Position", this, "This resets the dialog position to its default values."));
 745   
 746  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 747  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.DIALOG_TABBEDPANES_STORE_POSITION, false)
 748    .setEntireColumn(true));
 749  38 addOptionComponent(panel, new ButtonComponent(new ActionListener() {
 750  0 public void actionPerformed(ActionEvent e) {
 751  0 _mainFrame.resetTabbedPanesFrame();
 752    }
 753    }, "Reset \"Tabbed Panes\" Window Position", this, "This resets the window position to its default values."));
 754   
 755  38 addOptionComponent(panel,
 756    newBooleanOptionComponent(OptionConstants.DETACH_TABBEDPANES,false)
 757    .setEntireColumn(true));
 758   
 759  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 760  38 addOptionComponent(panel,
 761    newBooleanOptionComponent(OptionConstants.DIALOG_DEBUGFRAME_STORE_POSITION,false)
 762    .setEntireColumn(true));
 763  38 addOptionComponent(panel, new ButtonComponent(new ActionListener() {
 764  0 public void actionPerformed(ActionEvent e) {
 765  0 _mainFrame.resetDebugFrame();
 766    }
 767    }, "Reset \"Debugger\" Window Position", this, "This resets the window position to its default values."));
 768   
 769  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.DETACH_DEBUGGER, false)
 770    .setEntireColumn(true));
 771   
 772  38 panel.displayComponents();
 773    }
 774   
 775    /** Adds all of the components for the Key Bindings panel of the preferences window.
 776    */
 777  38 private void _setupKeyBindingsPanel(ConfigPanel panel) {
 778    // using a treemap because it automatically sorts element upon insertion
 779  38 TreeMap<String,VectorKeyStrokeOptionComponent> _comps = new TreeMap<String,VectorKeyStrokeOptionComponent>();
 780   
 781  38 VectorKeyStrokeOptionComponent vksoc;
 782   
 783  38 for (KeyStrokeData ksd: KeyBindingManager.ONLY.getKeyStrokeData()) {
 784  23550 if (ksd.getOption() != null) {
 785    // Get the tooltip, or default to its name, if none
 786  23550 Action a = ksd.getAction();
 787    // pick the short description as name, if available
 788  23550 String name = (String) a.getValue(Action.SHORT_DESCRIPTION);
 789    // if not available, pick the KeyStrokeData name instead
 790  22520 if (name == null || name.trim().equals("")) name = ksd.getName();
 791    // pick the long description as name, if available
 792  23550 String desc = (String) a.getValue(Action.LONG_DESCRIPTION);
 793    // if not available, pick the name from above instead
 794  2950 if (desc == null || desc.trim().equals("")) desc = name;
 795    // if the map already contains this name, use the description instead
 796  23550 if (_comps.containsKey(name)) {
 797  18648 name = desc;
 798    // if the map already contains the description as well (bad developers!), then use the option's name
 799  18648 if (_comps.containsKey(name)) {
 800  15512 name = ksd.getOption().getName();
 801    }
 802    }
 803  23550 vksoc = new VectorKeyStrokeOptionComponent(ksd.getOption(), name, this, desc);
 804  23550 if (vksoc != null) _comps.put(name, vksoc);
 805    }
 806    }
 807   
 808  38 Iterator<VectorKeyStrokeOptionComponent> iter = _comps.values().iterator();
 809  38 while (iter.hasNext()) {
 810  11100 VectorKeyStrokeOptionComponent x = iter.next();
 811  11100 addOptionComponent(panel, x);
 812    }
 813  38 panel.displayComponents();
 814    }
 815   
 816    /** Add all of the components for the Debugger panel of the preferences window. */
 817  38 private void _setupDebugPanel(ConfigPanel panel) {
 818  38 if (!_mainFrame.getModel().getDebugger().isAvailable()) {
 819    // Explain how to use debugger
 820  0 String howto =
 821    "\nThe debugger is not currently available. To use the debugger,\n" +
 822    "you can enter the location of the tools.jar file in the\n" +
 823    "\"Resource Locations\" pane, in case DrJava does not automatically find it.\n" +
 824    "See the user documentation for more details.\n";
 825  0 LabelComponent label = new LabelComponent(howto, this);
 826  0 label.setEntireColumn(true);
 827  0 addOptionComponent(panel, label);
 828    }
 829   
 830  38 VectorFileOptionComponent sourcePath =
 831    newVectorFileOptionComponent(OptionConstants.DEBUG_SOURCEPATH, true);
 832    // Source path can only include directories
 833  38 sourcePath.getFileChooser().setFileFilter(new DirectoryFilter("Source Directories"));
 834  38 addOptionComponent(panel, sourcePath);
 835  38 addOptionComponent(panel,
 836    newBooleanOptionComponent(OptionConstants.DEBUG_STEP_JAVA));
 837  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.DEBUG_STEP_INTERPRETER));
 838  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.DEBUG_STEP_DRJAVA));
 839  38 addOptionComponent(panel,
 840    new LabelComponent("<html>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
 841    "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
 842    "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</html>",
 843    this, true));
 844  38 addOptionComponent(panel,
 845    newVectorStringOptionComponent(OptionConstants.DEBUG_STEP_EXCLUDE, false));
 846  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.DEBUG_AUTO_IMPORT));
 847   
 848  38 addOptionComponent(panel, newIntegerOptionComponent(OptionConstants.AUTO_STEP_RATE));
 849  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.DEBUG_EXPRESSIONS_AND_METHODS_IN_WATCHES));
 850  38 panel.displayComponents();
 851    }
 852   
 853    /** Add all of the components for the Javadoc panel of the preferences window. */
 854  38 private void _setupJavadocPanel(ConfigPanel panel) {
 855  38 addOptionComponent(panel,
 856    newForcedChoiceOptionComponent(OptionConstants.JAVADOC_API_REF_VERSION));
 857  38 addOptionComponent(panel,
 858    newForcedChoiceOptionComponent(OptionConstants.JAVADOC_ACCESS_LEVEL));
 859  38 addOptionComponent(panel,
 860    newForcedChoiceOptionComponent(OptionConstants.JAVADOC_LINK_VERSION));
 861  38 addOptionComponent(panel,
 862    newStringOptionComponent(OptionConstants.JAVADOC_1_5_LINK));
 863  38 addOptionComponent(panel,
 864    newStringOptionComponent(OptionConstants.JAVADOC_1_6_LINK));
 865  38 addOptionComponent(panel,
 866    newStringOptionComponent(OptionConstants.JAVADOC_1_7_LINK));
 867  38 addOptionComponent(panel,
 868    newStringOptionComponent(OptionConstants.JUNIT_LINK));
 869   
 870  38 VectorStringOptionComponent additionalJavadoc =
 871    new VectorStringOptionComponent(OptionConstants.JAVADOC_ADDITIONAL_LINKS,
 872    CONFIG_DESCRIPTIONS.get(OptionConstants.JAVADOC_ADDITIONAL_LINKS),
 873    this,
 874    CONFIG_LONG_DESCRIPTIONS.get(OptionConstants.JAVADOC_ADDITIONAL_LINKS)) {
 875  0 protected boolean verify(String s) {
 876    // verify that the allclasses-frame.html file exists at that URL. do not actually parse it now
 877  0 boolean result = true;
 878  0 try {
 879  0 java.net.URL url = new java.net.URL(s+"/allclasses-frame.html");
 880  0 java.io.InputStream urls = url.openStream();
 881  0 java.io.InputStreamReader is = null;
 882  0 java.io.BufferedReader br = null;
 883  0 try {
 884  0 is = new java.io.InputStreamReader(urls);
 885  0 br = new java.io.BufferedReader(is);
 886  0 String line = br.readLine();
 887  0 if (line == null) { result = false; }
 888    }
 889    finally {
 890  0 if (br != null) { br.close(); }
 891  0 if (is != null) { is.close(); }
 892  0 if (urls != null) { urls.close(); }
 893    }
 894    }
 895  0 catch(java.io.IOException ioe) { result = false; }
 896  0 if (!result) {
 897  0 JOptionPane.showMessageDialog(ConfigFrame.this,
 898    "Could not find the Javadoc at the URL\n"+
 899    s,
 900    "Error Adding Javadoc",
 901    JOptionPane.ERROR_MESSAGE);
 902    }
 903  0 return result;
 904    }
 905    };
 906  38 addOptionComponent(panel, additionalJavadoc);
 907   
 908  38 addOptionComponent(panel,
 909    newDirectoryOptionComponent(OptionConstants.JAVADOC_DESTINATION, _dirChooser));
 910   
 911  38 addOptionComponent(panel,
 912    javadocCustomParams = newStringOptionComponent(OptionConstants.JAVADOC_CUSTOM_PARAMS));
 913   
 914    // Note: JAVADOC_FROM_ROOTS is intended to set the -subpackages flag, but I don't think that's something
 915    // we should support -- in general, we only support performing operations on the files that are open.
 916    // (dlsmith r4189)
 917    // addOptionComponent(panel,
 918    // newBooleanOptionComponent(OptionConstants.JAVADOC_FROM_ROOTS));
 919   
 920  38 panel.displayComponents();
 921    }
 922   
 923    /** Adds all of the components for the Prompts panel of the preferences window. */
 924  38 private void _setupNotificationsPanel(ConfigPanel panel) {
 925    // Quit
 926  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.QUIT_PROMPT, false)
 927    .setEntireColumn(true));
 928   
 929    // Interactions
 930  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.INTERACTIONS_RESET_PROMPT, false)
 931    .setEntireColumn(true));
 932   
 933  38 addOptionComponent(panel,
 934    newBooleanOptionComponent(OptionConstants.INTERACTIONS_EXIT_PROMPT,false)
 935    .setEntireColumn(true));
 936   
 937    // Javadoc
 938  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.JAVADOC_PROMPT_FOR_DESTINATION,false)
 939    .setEntireColumn(true));
 940   
 941   
 942    // Clean
 943  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.PROMPT_BEFORE_CLEAN, false)
 944    .setEntireColumn(true));
 945   
 946    // Prompt to change the language level extensions (.dj0/.dj1->.dj, .dj2->.java)
 947  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.PROMPT_RENAME_LL_FILES, false)
 948    .setEntireColumn(true));
 949   
 950   
 951    // Save before X
 952  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.ALWAYS_SAVE_BEFORE_COMPILE, false)
 953    .setEntireColumn(true));
 954   
 955  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.ALWAYS_COMPILE_BEFORE_JUNIT,false)
 956    .setEntireColumn(true));
 957   
 958  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.ALWAYS_SAVE_BEFORE_JAVADOC, false)
 959    .setEntireColumn(true));
 960   
 961  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.ALWAYS_COMPILE_BEFORE_JAVADOC, false)
 962    .setEntireColumn(true));
 963   
 964   
 965    // These are very problematic features, and so are disabled for the forseeable future.
 966    // addOptionComponent(panel,
 967    // newBooleanOptionComponent(OptionConstants.ALWAYS_SAVE_BEFORE_RUN));
 968    // addOptionComponent(panel,
 969    // newBooleanOptionComponent(OptionConstants.ALWAYS_SAVE_BEFORE_DEBUG));
 970   
 971    // Warnings
 972  38 addOptionComponent(panel,
 973    newBooleanOptionComponent(OptionConstants.WARN_BREAKPOINT_OUT_OF_SYNC,false)
 974    .setEntireColumn(true));
 975  38 addOptionComponent(panel,
 976    newBooleanOptionComponent(OptionConstants.WARN_DEBUG_MODIFIED_FILE,false)
 977    .setEntireColumn(true));
 978  38 addOptionComponent(panel,
 979    newBooleanOptionComponent(OptionConstants.WARN_CHANGE_LAF,false)
 980    .setEntireColumn(true));
 981  38 addOptionComponent(panel,
 982    newBooleanOptionComponent(OptionConstants.WARN_CHANGE_THEME,false)
 983    .setEntireColumn(true));
 984  38 addOptionComponent(panel,
 985    newBooleanOptionComponent(OptionConstants.WARN_CHANGE_DCP,false)
 986    .setEntireColumn(true));
 987  38 addOptionComponent(panel,
 988    newBooleanOptionComponent(OptionConstants.WARN_CHANGE_MISC,false)
 989    .setEntireColumn(true));
 990  38 addOptionComponent(panel,
 991    newBooleanOptionComponent(OptionConstants.WARN_CHANGE_INTERACTIONS,false)
 992    .setEntireColumn(true));
 993  38 addOptionComponent(panel,
 994    newBooleanOptionComponent(OptionConstants.WARN_PATH_CONTAINS_POUND,false)
 995    .setEntireColumn(true));
 996   
 997  38 addOptionComponent(panel,
 998    newBooleanOptionComponent(OptionConstants.DIALOG_DRJAVA_ERROR_POPUP_ENABLED,false)
 999    .setEntireColumn(true));
 1000  38 addOptionComponent(panel,
 1001    newBooleanOptionComponent(OptionConstants.WARN_IF_COMPIZ,false)
 1002    .setEntireColumn(true));
 1003   
 1004   
 1005  38 addOptionComponent(panel,
 1006    new LabelComponent("<html>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
 1007    "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
 1008    "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</html>", this, true));
 1009   
 1010  38 addOptionComponent(panel,
 1011    newForcedChoiceOptionComponent(OptionConstants.DELETE_LL_CLASS_FILES));
 1012   
 1013  38 addOptionComponent(panel,
 1014    new LabelComponent("<html>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
 1015    "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
 1016    "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</html>", this, true));
 1017   
 1018  38 addOptionComponent(panel,
 1019    newForcedChoiceOptionComponent(OptionConstants.NEW_VERSION_NOTIFICATION));
 1020  38 addOptionComponent(panel, newIntegerOptionComponent(OptionConstants.NEW_VERSION_NOTIFICATION_DAYS));
 1021   
 1022  38 panel.displayComponents();
 1023    }
 1024   
 1025    /** Adds all of the components for the Miscellaneous panel of the preferences window. */
 1026  38 private void _setupMiscPanel(ConfigPanel panel) {
 1027    /* Dialog box options */
 1028  38 addOptionComponent(panel, newIntegerOptionComponent(OptionConstants.INDENT_LEVEL));
 1029  38 addOptionComponent(panel, newIntegerOptionComponent(OptionConstants.RECENT_FILES_MAX_SIZE));
 1030  38 addOptionComponent(panel, newIntegerOptionComponent(OptionConstants.BROWSER_HISTORY_MAX_SIZE));
 1031   
 1032    /* Check box options */
 1033  38 addOptionComponent(panel,
 1034    newBooleanOptionComponent(OptionConstants.AUTO_CLOSE_COMMENTS));
 1035  38 addOptionComponent(panel,
 1036    newBooleanOptionComponent(OptionConstants.RUN_WITH_ASSERT));
 1037   
 1038  38 addOptionComponent(panel,
 1039    newBooleanOptionComponent(OptionConstants.BACKUP_FILES));
 1040  38 addOptionComponent(panel,
 1041    newBooleanOptionComponent(OptionConstants.RESET_CLEAR_CONSOLE));
 1042   
 1043  38 addOptionComponent(panel,
 1044    newBooleanOptionComponent(OptionConstants.FIND_REPLACE_FOCUS_IN_DEFPANE));
 1045  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.DRJAVA_USE_FORCE_QUIT));
 1046  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.REMOTE_CONTROL_ENABLED));
 1047  38 addOptionComponent(panel, newIntegerOptionComponent(OptionConstants.REMOTE_CONTROL_PORT));
 1048  38 addOptionComponent(panel, newIntegerOptionComponent(OptionConstants.FOLLOW_FILE_DELAY));
 1049  38 addOptionComponent(panel, newIntegerOptionComponent(OptionConstants.FOLLOW_FILE_LINES));
 1050   
 1051    // Any lightweight parsing has been disabled until we have something that is beneficial and works better in the background.
 1052    // addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.LIGHTWEIGHT_PARSING_ENABLED));
 1053    // addOptionComponent(panel, newIntegerOptionComponent(OptionConstants.DIALOG_LIGHTWEIGHT_PARSING_DELAY));
 1054   
 1055  38 panel.displayComponents();
 1056    }
 1057   
 1058    /** Adds all of the components for the JVMs panel of the preferences window. */
 1059  38 private void _setupJVMsPanel(ConfigPanel panel) {
 1060  38 addOptionComponent(panel,
 1061    newForcedChoiceOptionComponent(OptionConstants.MASTER_JVM_XMX));
 1062  38 addOptionComponent(panel,
 1063    newStringOptionComponent(OptionConstants.MASTER_JVM_ARGS));
 1064  38 addOptionComponent(panel,
 1065    newForcedChoiceOptionComponent(OptionConstants.SLAVE_JVM_XMX));
 1066  38 addOptionComponent(panel,
 1067    newStringOptionComponent(OptionConstants.SLAVE_JVM_ARGS));
 1068  38 panel.displayComponents();
 1069    }
 1070   
 1071    /** Adds all of the components for the file types panel of the preferences window. */
 1072  38 private void _setupFileTypesPanel(ConfigPanel panel) {
 1073  38 if (PlatformFactory.ONLY.canRegisterFileExtensions()) {
 1074  0 addOptionComponent(panel, new LabelComponent("<html>Assign DrJava project files and DrJava extensions<br>"+
 1075    "(with the extensions .drjava and .djapp) to DrJava.<br>"+
 1076    "When double-clicking on a .drjava file, DrJava will open it.</html>", this, true));
 1077   
 1078  0 panel.addComponent(new ButtonComponent(new ActionListener() {
 1079  0 public void actionPerformed(ActionEvent e) {
 1080  0 if (PlatformFactory.ONLY.registerDrJavaFileExtensions()) {
 1081  0 JOptionPane.showMessageDialog(ConfigFrame.this,
 1082    "Successfully set .drjava and .djapp file associations.",
 1083    "Success",
 1084    JOptionPane.INFORMATION_MESSAGE);
 1085    }
 1086    else {
 1087  0 JOptionPane.showMessageDialog(ConfigFrame.this,
 1088    "Could not set .drjava and .djapp file associations.",
 1089    "File Types Error",
 1090    JOptionPane.ERROR_MESSAGE);
 1091    }
 1092    }
 1093    }, "Associate .drjava and .djapp Files with DrJava", this, "This associates .drjava and .djapp files with DrJava."));
 1094   
 1095  0 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 1096   
 1097  0 panel.addComponent(new ButtonComponent(new ActionListener() {
 1098  0 public void actionPerformed(ActionEvent e) {
 1099  0 if (PlatformFactory.ONLY.unregisterDrJavaFileExtensions()) {
 1100  0 JOptionPane.showMessageDialog(ConfigFrame.this,
 1101    "Successfully removed .drjava and .djapp file associations.",
 1102    "Success",
 1103    JOptionPane.INFORMATION_MESSAGE);
 1104    }
 1105    else {
 1106  0 JOptionPane.showMessageDialog(ConfigFrame.this,
 1107    "Could not remove .drjava and .djapp file associations.",
 1108    "File Types Error",
 1109    JOptionPane.ERROR_MESSAGE);
 1110    }
 1111    }
 1112    }, "Remove .drjava and .djapp File Associations", this, "This removes the association of .drjava and .djapp files with DrJava."));
 1113   
 1114  0 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 1115  0 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 1116  0 addOptionComponent(panel, new LabelComponent("<html>Assign Java source files with the<br>"+
 1117    "extension .java to DrJava. When double-clicking<br>"+
 1118    "on a .java file, DrJava will open it.</html>", this, true));
 1119   
 1120  0 panel.addComponent(new ButtonComponent(new ActionListener() {
 1121  0 public void actionPerformed(ActionEvent e) {
 1122  0 if (PlatformFactory.ONLY.registerJavaFileExtension()) {
 1123  0 JOptionPane.showMessageDialog(ConfigFrame.this,
 1124    "Successfully set .java file association.",
 1125    "Success",
 1126    JOptionPane.INFORMATION_MESSAGE);
 1127    }
 1128    else {
 1129  0 JOptionPane.showMessageDialog(ConfigFrame.this,
 1130    "Could not set .java file association.",
 1131    "File Types Error",
 1132    JOptionPane.ERROR_MESSAGE);
 1133    }
 1134    }
 1135    }, "Associate .java Files with DrJava", this, "This associates .java source files with DrJava."));
 1136   
 1137  0 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 1138   
 1139  0 panel.addComponent(new ButtonComponent(new ActionListener() {
 1140  0 public void actionPerformed(ActionEvent e) {
 1141  0 if (PlatformFactory.ONLY.unregisterJavaFileExtension()) {
 1142  0 JOptionPane.showMessageDialog(ConfigFrame.this,
 1143    "Successfully removed .java file association.",
 1144    "Success",
 1145    JOptionPane.INFORMATION_MESSAGE);
 1146    }
 1147    else {
 1148  0 JOptionPane.showMessageDialog(ConfigFrame.this,
 1149    "Could not remove .java file association.",
 1150    "File Types Error",
 1151    JOptionPane.ERROR_MESSAGE);
 1152    }
 1153    }
 1154    }, "Remove .java File Association", this, "This removes the association of .java project files with DrJava."));
 1155   
 1156  0 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 1157  0 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 1158   
 1159  0 addOptionComponent(panel, newForcedChoiceOptionComponent(OptionConstants.FILE_EXT_REGISTRATION));
 1160    }
 1161    else {
 1162  38 addOptionComponent(panel,
 1163    new LabelComponent("<html><br><br>"+
 1164  38 (PlatformFactory.ONLY.isMacPlatform()?
 1165    "File associations are managed automatically by Mac OS.":
 1166  38 (PlatformFactory.ONLY.isWindowsPlatform()?
 1167    "To set file associations, please use the .exe file version of DrJava.<br>"+
 1168    "Configuring file associations is not supported for the .jar file version.":
 1169    "Managing file associations is not supported yet on this operating system."))+
 1170    "</html>",
 1171    this, true));
 1172    }
 1173  38 panel.displayComponents();
 1174    }
 1175   
 1176    /** Adds all of the components for the Compiler Options Panel of the preferences window
 1177    */
 1178  38 private void _setupCompilerPanel(ConfigPanel panel) {
 1179  38 addOptionComponent(panel,
 1180    newBooleanOptionComponent(OptionConstants.SHOW_UNCHECKED_WARNINGS, false)
 1181    .setEntireColumn(true));
 1182   
 1183  38 addOptionComponent(panel,
 1184    newBooleanOptionComponent(OptionConstants.SHOW_DEPRECATION_WARNINGS, false)
 1185    .setEntireColumn(true));
 1186   
 1187  38 addOptionComponent(panel,
 1188    newBooleanOptionComponent(OptionConstants.SHOW_PATH_WARNINGS, false)
 1189    .setEntireColumn(true));
 1190   
 1191  38 addOptionComponent(panel,
 1192    newBooleanOptionComponent(OptionConstants.SHOW_SERIAL_WARNINGS,false)
 1193    .setEntireColumn(true));
 1194   
 1195  38 addOptionComponent(panel,
 1196    newBooleanOptionComponent(OptionConstants.SHOW_FINALLY_WARNINGS, false)
 1197    .setEntireColumn(true));
 1198   
 1199  38 addOptionComponent(panel,
 1200    newBooleanOptionComponent(OptionConstants.SHOW_FALLTHROUGH_WARNINGS, false)
 1201    .setEntireColumn(true));
 1202  38 addOptionComponent(panel,
 1203    new LabelComponent("<html><br><br>Note: Some of these options may not be effective, depending on the<br>"+
 1204    "compiler you are using.</html>",
 1205    this, true));
 1206    /*
 1207    * The drop down box containing the compiler names
 1208    */
 1209  38 final ForcedChoiceOptionComponent CPC =
 1210    newForcedChoiceOptionComponent(OptionConstants.COMPILER_PREFERENCE_CONTROL.evaluate());
 1211   
 1212    /*
 1213    * Action listener that saves the selected compiler name into the DEFAULT_COMPILER_PREFERENCE setting
 1214    */
 1215  38 ActionListener CPCActionListener = new ActionListener() {
 1216  0 public void actionPerformed(ActionEvent e) {
 1217  0 if(!edu.rice.cs.drjava.DrJava.getConfig().getSetting(OptionConstants.DEFAULT_COMPILER_PREFERENCE).equals(CPC.getCurrentComboBoxValue())) {
 1218  0 edu.rice.cs.drjava.DrJava.getConfig().setSetting(OptionConstants.DEFAULT_COMPILER_PREFERENCE,CPC.getCurrentComboBoxValue());
 1219    }
 1220    }
 1221    };
 1222   
 1223    /*
 1224    * insures that the change is made only when the apply or ok button is hit
 1225    */
 1226  38 _applyButton.addActionListener(CPCActionListener);
 1227  38 _okButton.addActionListener(CPCActionListener);
 1228   
 1229    /*
 1230    * adds the drop down box to the panel
 1231    */
 1232  38 addOptionComponent(panel,
 1233    CPC.setEntireColumn(false)
 1234    );
 1235   
 1236  38 addOptionComponent(panel,
 1237    new LabelComponent("<html><br><br>Note: Compiler warnings not shown if compiling any Java language level files.</html>",
 1238    this, true));
 1239  38 panel.displayComponents();
 1240    }
 1241   
 1242    /** Add all of the components for the Interactions panel of the preferences window. */
 1243  38 private void _setupInteractionsPanel(ConfigPanel panel) {
 1244  38 final DirectoryOptionComponent wdComponent =
 1245    newDirectoryOptionComponent(OptionConstants.FIXED_INTERACTIONS_DIRECTORY, _dirChooser);
 1246  38 addOptionComponent(panel, wdComponent);
 1247  38 final BooleanOptionComponent stickyComponent =
 1248    newBooleanOptionComponent(OptionConstants.STICKY_INTERACTIONS_DIRECTORY);
 1249  38 addOptionComponent(panel, stickyComponent);
 1250   
 1251  38 OptionComponent.ChangeListener wdListener = new OptionComponent.ChangeListener() {
 1252  38 public Object value(Object oc) {
 1253  38 File f = wdComponent.getComponent().getFileFromField();
 1254  38 boolean enabled = (f == null) || (f.equals(FileOps.NULL_FILE));
 1255  38 stickyComponent.getComponent().setEnabled(enabled);
 1256  38 return null;
 1257    }
 1258    };
 1259  38 wdComponent.addChangeListener(wdListener);
 1260  38 wdListener.value(wdComponent);
 1261   
 1262  38 addOptionComponent(panel, newBooleanOptionComponent
 1263    (OptionConstants.SMART_RUN_FOR_APPLETS_AND_PROGRAMS));
 1264   
 1265  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 1266  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 1267   
 1268  38 addOptionComponent(panel, newIntegerOptionComponent(OptionConstants.HISTORY_MAX_SIZE));
 1269  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.DIALOG_AUTOIMPORT_ENABLED));
 1270  38 VectorStringOptionComponent autoImportClasses =
 1271    new VectorStringOptionComponent(OptionConstants.INTERACTIONS_AUTO_IMPORT_CLASSES,
 1272    CONFIG_DESCRIPTIONS.get(OptionConstants.INTERACTIONS_AUTO_IMPORT_CLASSES),
 1273    this,
 1274    CONFIG_LONG_DESCRIPTIONS.get(OptionConstants.INTERACTIONS_AUTO_IMPORT_CLASSES)) {
 1275  0 protected boolean verify(String s) {
 1276  0 boolean result = true;
 1277    // verify that the string contains only Java identifier characters, dots and stars
 1278  0 for(int i = 0; i < s.length(); ++i) {
 1279  0 char ch = s.charAt(i);
 1280  0 if ((ch!='.') && (ch!='*') && (!Character.isJavaIdentifierPart(ch))) {
 1281  0 result = false;
 1282  0 break;
 1283    }
 1284    }
 1285  0 if (!result) {
 1286  0 JOptionPane.showMessageDialog(ConfigFrame.this,
 1287    "This is not a valid class name:\n"+
 1288    s,
 1289    "Error Adding Class Name",
 1290    JOptionPane.ERROR_MESSAGE);
 1291    }
 1292  0 return result;
 1293    }
 1294    };
 1295  38 addOptionComponent(panel, autoImportClasses);
 1296   
 1297  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 1298  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 1299   
 1300  38 addOptionComponent(panel,
 1301    newForcedChoiceOptionComponent(OptionConstants.DYNAMICJAVA_ACCESS_CONTROL));
 1302  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.DYNAMICJAVA_REQUIRE_SEMICOLON));
 1303  38 addOptionComponent(panel, newBooleanOptionComponent(OptionConstants.DYNAMICJAVA_REQUIRE_VARIABLE_TYPE));
 1304   
 1305  38 panel.displayComponents();
 1306    }
 1307   
 1308    /** Add all of the components for the JUnit panel of the preferences window. */
 1309  38 private void _setupJUnitPanel(ConfigPanel panel) {
 1310  38 final BooleanOptionComponent junitLocEnabled =
 1311    newBooleanOptionComponent(OptionConstants.JUNIT_LOCATION_ENABLED,false)
 1312    .setEntireColumn(true);
 1313  38 addOptionComponent(panel, junitLocEnabled);
 1314  38 final FileOptionComponent junitLoc =
 1315    newFileOptionComponent(OptionConstants.JUNIT_LOCATION,
 1316    new FileSelectorComponent(this, _jarChooser, 30, 10f) {
 1317  0 public void setFileField(File file) {
 1318  0 if (edu.rice.cs.drjava.model.junit.ConcJUnitUtils.isValidJUnitFile(file) ||
 1319    edu.rice.cs.drjava.model.junit.ConcJUnitUtils.isValidConcJUnitFile(file)) {
 1320  0 super.setFileField(file);
 1321    }
 1322  0 else if (file.exists()) { // invalid JUnit/ConcJUnit file, but exists
 1323  0 new edu.rice.cs.drjava.ui.DrJavaScrollableDialog(_parent, "Invalid JUnit/ConcJUnit File", "Stack trace:",
 1324    edu.rice.cs.util.StringOps.getStackTrace(), 600, 400, false).show();
 1325  0 JOptionPane.showMessageDialog(_parent, "The file '"+ file.getName() + "'\nis not a valid JUnit/ConcJUnit file.",
 1326    "Invalid JUnit/ConcJUnit File", JOptionPane.ERROR_MESSAGE);
 1327  0 resetFileField(); // revert if not valid
 1328    }
 1329    }
 1330  0 public boolean validateTextField() {
 1331  0 String newValue = _fileField.getText().trim();
 1332   
 1333  0 File newFile = FileOps.NULL_FILE;
 1334  0 if (!newValue.equals(""))
 1335  0 newFile = new File(newValue);
 1336   
 1337  0 if (newFile != FileOps.NULL_FILE && !newFile.exists()) {
 1338  0 JOptionPane.showMessageDialog(_parent, "The file '"+ newFile.getName() + "'\nis invalid because it does not exist.",
 1339    "Invalid File Name", JOptionPane.ERROR_MESSAGE);
 1340  0 if (_file != null && ! _file.exists()) _file = FileOps.NULL_FILE;
 1341  0 resetFileField(); // revert if not valid
 1342   
 1343  0 return false;
 1344    }
 1345    else {
 1346  0 if (edu.rice.cs.drjava.model.junit.ConcJUnitUtils.isValidJUnitFile(newFile) ||
 1347    edu.rice.cs.drjava.model.junit.ConcJUnitUtils.isValidConcJUnitFile(newFile) ||
 1348    FileOps.NULL_FILE.equals(newFile)) {
 1349  0 setFileField(newFile);
 1350  0 return true;
 1351    }
 1352    else {
 1353  0 new edu.rice.cs.drjava.ui.DrJavaScrollableDialog(_parent, "Invalid JUnit/ConcJUnit File", "newFile is NULL_FILE? "+(FileOps.NULL_FILE.equals(newFile)),
 1354    edu.rice.cs.util.StringOps.getStackTrace(), 600, 400, false).show();
 1355  0 JOptionPane.showMessageDialog(_parent, "The file '"+ newFile.getName() + "'\nis not a valid JUnit/ConcJUnit file.",
 1356    "Invalid JUnit/ConcJUnit File", JOptionPane.ERROR_MESSAGE);
 1357  0 resetFileField(); // revert if not valid
 1358   
 1359  0 return false;
 1360    }
 1361    }
 1362    }
 1363    });
 1364  38 junitLoc.setFileFilter(ClassPathFilter.ONLY);
 1365  38 addOptionComponent(panel, junitLoc);
 1366   
 1367  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 1368   
 1369  38 boolean javaVersion7 = JavaVersion.CURRENT.supports(JavaVersion.JAVA_7);
 1370  38 if (!javaVersion7) {
 1371  38 final ForcedChoiceOptionComponent concJUnitChecksEnabledComponent =
 1372    newForcedChoiceOptionComponent(OptionConstants.CONCJUNIT_CHECKS_ENABLED);
 1373  38 addOptionComponent(panel, concJUnitChecksEnabledComponent);
 1374   
 1375  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 1376   
 1377  38 final FileOptionComponent rtConcJUnitLoc =
 1378    newFileOptionComponent(OptionConstants.RT_CONCJUNIT_LOCATION,
 1379    new FileSelectorComponent(this, _jarChooser, 30, 10f) {
 1380  0 public void setFileField(File file) {
 1381  0 if (edu.rice.cs.drjava.model.junit.ConcJUnitUtils.isValidRTConcJUnitFile(file)) {
 1382  0 super.setFileField(file);
 1383    }
 1384  0 else if (file.exists()) { // invalid but exists
 1385  0 JOptionPane.showMessageDialog(_parent, "The file '"+ file.getName() + "'\nis not a valid ConcJUnit Runtime file.",
 1386    "Invalid ConcJUnit Runtime File", JOptionPane.ERROR_MESSAGE);
 1387  0 resetFileField(); // revert if not valid
 1388    }
 1389    }
 1390  0 public boolean validateTextField() {
 1391  0 String newValue = _fileField.getText().trim();
 1392   
 1393  0 File newFile = FileOps.NULL_FILE;
 1394  0 if (!newValue.equals(""))
 1395  0 newFile = new File(newValue);
 1396   
 1397  0 if (newFile != FileOps.NULL_FILE && !newFile.exists()) {
 1398  0 JOptionPane.showMessageDialog(_parent, "The file '"+ newFile.getName() + "'\nis invalid because it does not exist.",
 1399    "Invalid File Name", JOptionPane.ERROR_MESSAGE);
 1400  0 if (_file != null && ! _file.exists()) _file = FileOps.NULL_FILE;
 1401  0 resetFileField(); // revert if not valid
 1402   
 1403  0 return false;
 1404    }
 1405    else {
 1406  0 if (edu.rice.cs.drjava.model.junit.ConcJUnitUtils.isValidRTConcJUnitFile(newFile) ||
 1407    FileOps.NULL_FILE.equals(newFile)) {
 1408  0 setFileField(newFile);
 1409  0 return true;
 1410    }
 1411    else {
 1412  0 JOptionPane.showMessageDialog(_parent, "The file '"+ newFile.getName() + "'\nis not a valid ConcJUnit Runtime file.",
 1413    "Invalid ConcJUnit Runtime File", JOptionPane.ERROR_MESSAGE);
 1414  0 resetFileField(); // revert if not valid
 1415   
 1416  0 return false;
 1417    }
 1418    }
 1419    }
 1420    });
 1421  38 rtConcJUnitLoc.setFileFilter(ClassPathFilter.ONLY);
 1422   
 1423  38 ActionListener processRTListener = new ActionListener() {
 1424  0 public void actionPerformed(ActionEvent e) {
 1425  0 File concJUnitJarFile = FileOps.getDrJavaFile();
 1426  0 if (junitLocEnabled.getComponent().isSelected()) {
 1427  0 concJUnitJarFile = junitLoc.getComponent().getFileFromField();
 1428    }
 1429  0 File rtFile = rtConcJUnitLoc.getComponent().getFileFromField();
 1430  0 edu.rice.cs.drjava.model.junit.ConcJUnitUtils.
 1431    showGenerateRTConcJUnitJarFileDialog(ConfigFrame.this,
 1432    rtFile,
 1433    concJUnitJarFile,
 1434    new Runnable1<File>() {
 1435  0 public void run(File targetFile) {
 1436  0 rtConcJUnitLoc.getComponent().setFileField(targetFile);
 1437    }
 1438    },
 1439  0 new Runnable() { public void run() { } });
 1440    }
 1441    };
 1442  38 final ButtonComponent processRT =
 1443    new ButtonComponent(processRTListener, "Generate ConcJUnit Runtime File", this,
 1444    "<html>Generate the ConcJUnit Runtime file specified above.<br>"+
 1445    "This setting is deactivated if the path to ConcJUnit has not been specified above.</html>");
 1446   
 1447  38 OptionComponent.ChangeListener rtConcJUnitListener = new OptionComponent.ChangeListener() {
 1448  38 public Object value(Object oc) {
 1449  38 File f = junitLoc.getComponent().getFileFromField();
 1450  38 boolean enabled = (!junitLocEnabled.getComponent().isSelected()) ||
 1451    edu.rice.cs.drjava.model.junit.ConcJUnitUtils.isValidConcJUnitFile(f);
 1452  38 rtConcJUnitLoc.getComponent().setEnabled(enabled);
 1453  38 processRT.getComponent().setEnabled(enabled);
 1454  38 concJUnitChecksEnabledComponent.getComponent().setEnabled(enabled);
 1455  38 return null;
 1456    }
 1457    };
 1458   
 1459  38 OptionComponent.ChangeListener junitLocListener = new OptionComponent.ChangeListener() {
 1460  38 public Object value(Object oc) {
 1461  38 boolean enabled = junitLocEnabled.getComponent().isSelected();
 1462  38 junitLoc.getComponent().setEnabled(enabled);
 1463  38 return null;
 1464    }
 1465    };
 1466  38 junitLocEnabled.addChangeListener(junitLocListener);
 1467  38 junitLocEnabled.addChangeListener(rtConcJUnitListener);
 1468  38 junitLoc.addChangeListener(rtConcJUnitListener);
 1469  38 addOptionComponent(panel, rtConcJUnitLoc);
 1470  38 addOptionComponent(panel, processRT);
 1471   
 1472  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 1473  38 final LabelComponent internalExternalStatus = new LabelComponent("<html>&nbsp;</html>", this, true);
 1474  38 final LabelComponent threadsStatus = new LabelComponent("<html>&nbsp;</html>", this, true);
 1475  38 final LabelComponent joinStatus = new LabelComponent("<html>&nbsp;</html>", this, true);
 1476  38 final LabelComponent luckyStatus = new LabelComponent("<html>&nbsp;</html>", this, true);
 1477  38 OptionComponent.ChangeListener junitStatusChangeListener = new OptionComponent.ChangeListener() {
 1478  38 public Object value(Object oc) {
 1479  38 File f = junitLoc.getComponent().getFileFromField();
 1480  38 String[] s = new String[] { " ", " ", " ", " " };
 1481  38 boolean isConcJUnit = true;
 1482  38 if ((!junitLocEnabled.getComponent().isSelected()) || (f==null) || FileOps.NULL_FILE.equals(f) || !f.exists()) {
 1483  38 s[0] = "DrJava uses the built-in ConcJUnit framework.";
 1484    }
 1485    else {
 1486  0 String type = "ConcJUnit";
 1487  0 if (!edu.rice.cs.drjava.model.junit.ConcJUnitUtils.isValidConcJUnitFile(f)) {
 1488  0 type = "JUnit";
 1489  0 isConcJUnit = false;
 1490    }
 1491  0 s[0] = "DrJava uses an external "+type+" framework.";
 1492    }
 1493  38 if (!isConcJUnit) {
 1494  0 s[1] = "JUnit does not support all-thread, no-join";
 1495  0 s[2] = "or lucky checks. They are all disabled.";
 1496    }
 1497    else {
 1498  38 s[1] = "All-thread checks are disabled.";
 1499  38 s[2] = "No-join checks are disabled.";
 1500  38 s[3] = "Lucky checks are disabled.";
 1501  38 if (!concJUnitChecksEnabledComponent.getCurrentComboBoxValue().
 1502    equals(OptionConstants.ConcJUnitCheckChoices.NONE)) {
 1503  0 s[1] = "All-thread checks are enabled.";
 1504  0 if (concJUnitChecksEnabledComponent.getCurrentComboBoxValue().
 1505    equals(OptionConstants.ConcJUnitCheckChoices.ALL) ||
 1506    concJUnitChecksEnabledComponent.getCurrentComboBoxValue().
 1507    equals(OptionConstants.ConcJUnitCheckChoices.NO_LUCKY)) {
 1508  0 s[2] = "No-join checks are enabled.";
 1509  0 if (concJUnitChecksEnabledComponent.getCurrentComboBoxValue().
 1510    equals(OptionConstants.ConcJUnitCheckChoices.ALL)) {
 1511  0 File rtf = rtConcJUnitLoc.getComponent().getFileFromField();
 1512  0 if ((rtf!=null) && !FileOps.NULL_FILE.equals(rtf) && rtf.exists() &&
 1513    edu.rice.cs.drjava.model.junit.ConcJUnitUtils.isValidRTConcJUnitFile(rtf)) {
 1514  0 s[3] = "Lucky checks are enabled.";
 1515    }
 1516    }
 1517    }
 1518    }
 1519    }
 1520  38 internalExternalStatus.getComponent().setText(s[0]);
 1521  38 threadsStatus.getComponent().setText(s[1]);
 1522  38 joinStatus.getComponent().setText(s[2]);
 1523  38 luckyStatus.getComponent().setText(s[3]);
 1524  38 return null;
 1525    }
 1526    };
 1527  38 concJUnitChecksEnabledComponent.addChangeListener(junitStatusChangeListener);
 1528  38 junitLocEnabled.addChangeListener(junitStatusChangeListener);
 1529  38 junitLoc.addChangeListener(junitStatusChangeListener);
 1530  38 rtConcJUnitLoc.addChangeListener(junitStatusChangeListener);
 1531  38 addOptionComponent(panel, internalExternalStatus);
 1532  38 addOptionComponent(panel, threadsStatus);
 1533  38 addOptionComponent(panel, joinStatus);
 1534  38 addOptionComponent(panel, luckyStatus);
 1535   
 1536  38 junitLocListener.value(null);
 1537  38 rtConcJUnitListener.value(null);
 1538  38 junitStatusChangeListener.value(null);
 1539    }
 1540    else {
 1541  0 addOptionComponent(panel,
 1542    new LabelComponent("<html><br><br>ConcJUnit is currently not supported on Java 7.<br><br></html>", this, true));
 1543    }
 1544   
 1545  38 addOptionComponent(panel, new LabelComponent("<html>&nbsp;</html>", this, true));
 1546  38 final BooleanOptionComponent forceTestSuffix =
 1547    newBooleanOptionComponent(OptionConstants.FORCE_TEST_SUFFIX,false)
 1548    .setEntireColumn(true);
 1549  38 addOptionComponent(panel, forceTestSuffix);
 1550   
 1551  38 panel.displayComponents();
 1552    }
 1553   
 1554    /** Private class to handle rendering of tree nodes, each of which
 1555    * corresponds to a ConfigPanel. These nodes should only be accessed
 1556    * from the event handling thread.
 1557    */
 1558    private class PanelTreeNode extends DefaultMutableTreeNode {
 1559   
 1560    private final ConfigPanel _panel;
 1561   
 1562  608 public PanelTreeNode(String t) {
 1563  608 super(t);
 1564  608 _panel = new ConfigPanel(t);
 1565    }
 1566   
 1567  0 public PanelTreeNode(ConfigPanel c) {
 1568  0 super(c.getTitle());
 1569  0 _panel = c;
 1570    }
 1571  608 private ConfigPanel getPanel() { return _panel; }
 1572   
 1573    /** Tells its panel to update, and tells all of its child nodes to update their panels.
 1574    * @return whether the update succeeded.
 1575    */
 1576  0 private boolean update() {
 1577   
 1578  0 boolean isValidUpdate = _panel.update();
 1579   
 1580    //if this panel encountered an error while attempting to update, return false
 1581  0 if (!isValidUpdate) {
 1582    //System.out.println("Panel.update() returned false");
 1583   
 1584    //TreePath path = new TreePath(this.getPath());
 1585    // causes ClassCastException under jsr14 v2.0 for no apparent reason.
 1586    // Workaround: store result of getPath() to temporary array.
 1587   
 1588  0 TreeNode[] nodes = getPath();
 1589  0 TreePath path = new TreePath(nodes);
 1590  0 _tree.expandPath(path);
 1591  0 _tree.setSelectionPath(path);
 1592  0 return false;
 1593    }
 1594   
 1595  0 Enumeration<?> childNodes = children();
 1596  0 while (childNodes.hasMoreElements()) {
 1597  0 boolean isValidUpdateChildren = ((PanelTreeNode)childNodes.nextElement()).update();
 1598    //if any of the children nodes encountered an error, return false
 1599  0 if (!isValidUpdateChildren) {
 1600  0 return false;
 1601    }
 1602    }
 1603   
 1604  0 return true;
 1605    }
 1606   
 1607    /** Tells its panel to reset its displayed value to the currently set value for this component, and tells all of
 1608    * its children to reset their panels. Should be performed in the event thread!
 1609    */
 1610  0 public void resetToCurrent() {
 1611  0 _panel.resetToCurrent();
 1612   
 1613  0 Enumeration<?> childNodes = children();
 1614  0 while (childNodes.hasMoreElements()) {
 1615  0 ((PanelTreeNode)childNodes.nextElement()).resetToCurrent();
 1616    }
 1617    }
 1618    }
 1619   
 1620    private class PanelTreeSelectionListener implements TreeSelectionListener {
 1621  38 public void valueChanged(TreeSelectionEvent e) {
 1622  38 Object o = _tree.getLastSelectedPathComponent();
 1623    //System.out.println("Object o : "+o);
 1624  38 if (o instanceof PanelTreeNode) {
 1625    //System.out.println("o is instanceof PanelTreeNode");
 1626  38 PanelTreeNode child = (PanelTreeNode) _tree.getLastSelectedPathComponent();
 1627  38 _displayPanel(child.getPanel());
 1628    }
 1629    }
 1630    }
 1631    }