Source Code Cross Referenced for ConfigFrame.java in  » IDE » DrJava » edu » rice » cs » drjava » ui » config » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE » DrJava » edu.rice.cs.drjava.ui.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*BEGIN_COPYRIGHT_BLOCK
0002:         *
0003:         * Copyright (c) 2001-2007, JavaPLT group at Rice University (javaplt@rice.edu)
0004:         * All rights reserved.
0005:         * 
0006:         * Redistribution and use in source and binary forms, with or without
0007:         * modification, are permitted provided that the following conditions are met:
0008:         *    * Redistributions of source code must retain the above copyright
0009:         *      notice, this list of conditions and the following disclaimer.
0010:         *    * Redistributions in binary form must reproduce the above copyright
0011:         *      notice, this list of conditions and the following disclaimer in the
0012:         *      documentation and/or other materials provided with the distribution.
0013:         *    * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
0014:         *      names of its contributors may be used to endorse or promote products
0015:         *      derived from this software without specific prior written permission.
0016:         * 
0017:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0018:         * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0019:         * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0020:         * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
0021:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
0022:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
0023:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
0024:         * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
0025:         * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
0026:         * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
0027:         * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0028:         *
0029:         * This software is Open Source Initiative approved Open Source Software.
0030:         * Open Source Initative Approved is a trademark of the Open Source Initiative.
0031:         * 
0032:         * This file is part of DrJava.  Download the current version of this project
0033:         * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
0034:         * 
0035:         * END_COPYRIGHT_BLOCK*/
0036:
0037:        package edu.rice.cs.drjava.ui.config;
0038:
0039:        import javax.swing.*;
0040:        import javax.swing.event.*;
0041:        import javax.swing.border.EmptyBorder;
0042:        import java.awt.event.*;
0043:        import java.awt.*;
0044:        import java.util.Enumeration;
0045:        import java.io.IOException;
0046:        import java.io.File;
0047:        import java.util.TreeSet;
0048:        import java.util.Iterator;
0049:
0050:        import javax.swing.tree.*;
0051:
0052:        import edu.rice.cs.drjava.DrJava;
0053:        import edu.rice.cs.drjava.CodeStatus;
0054:        import edu.rice.cs.drjava.config.FileOption;
0055:        import edu.rice.cs.drjava.config.*;
0056:        import edu.rice.cs.drjava.ui.*;
0057:        import edu.rice.cs.drjava.ui.KeyBindingManager.KeyStrokeData;
0058:        import edu.rice.cs.util.swing.DirectoryChooser;
0059:
0060:        /** The frame for setting Configuration options on the fly
0061:         *  @version $Id: ConfigFrame.java 4287 2007-12-20 21:59:32Z mgricken $
0062:         */
0063:        public class ConfigFrame extends JFrame {
0064:
0065:            private static final int FRAME_WIDTH = 750;
0066:            private static final int FRAME_HEIGHT = 500;
0067:
0068:            private final MainFrame _mainFrame;
0069:
0070:            //  private JSplitPane _splitPane;
0071:            private final JTree _tree;
0072:            private final DefaultTreeModel _treeModel;
0073:            private final PanelTreeNode _rootNode;
0074:
0075:            private final JButton _okButton;
0076:            private final JButton _applyButton;
0077:            private final JButton _cancelButton;
0078:            //  private final JButton _saveSettingsButton;
0079:            private final JPanel _mainPanel;
0080:            private final JFileChooser _fileOptionChooser;
0081:            private final JFileChooser _browserChooser;
0082:            private final DirectoryChooser _dirChooser;
0083:
0084:            private OptionComponent.ChangeListener _changeListener = new OptionComponent.ChangeListener() {
0085:                public Object apply(Object oc) {
0086:                    _applyButton.setEnabled(true);
0087:                    return null;
0088:                }
0089:            };
0090:
0091:            /** Sets up the frame and displays it.  This a Swing view class!  With the exception of initialization,
0092:             *  this code should only be executed in the event-handling thread. */
0093:            public ConfigFrame(MainFrame frame) {
0094:                super ("Preferences");
0095:
0096:                _mainFrame = frame;
0097:
0098:                Action applyAction = new AbstractAction("Apply") {
0099:                    public void actionPerformed(ActionEvent e) {
0100:                        // Always save settings
0101:                        try {
0102:                            //          _mainFrame.enableResetInteractions();
0103:                            saveSettings();
0104:                            _applyButton.setEnabled(false);
0105:
0106:                        } catch (IOException ioe) {
0107:                        }
0108:                    }
0109:                };
0110:
0111:                _applyButton = new JButton(applyAction);
0112:                _applyButton.setEnabled(false);
0113:
0114:                Action okAction = new AbstractAction("OK") {
0115:                    public void actionPerformed(ActionEvent e) {
0116:                        // Always apply and save settings
0117:                        boolean successful = true;
0118:                        try {
0119:                            //          _mainFrame.enableResetInteractions();
0120:                            successful = saveSettings();
0121:                        } catch (IOException ioe) {
0122:                            // oh well...
0123:                        }
0124:                        if (successful)
0125:                            _applyButton.setEnabled(false);
0126:                        ConfigFrame.this .setVisible(false);
0127:                    }
0128:                };
0129:                _okButton = new JButton(okAction);
0130:
0131:                Action cancelAction = new AbstractAction("Cancel") {
0132:                    public void actionPerformed(ActionEvent e) {
0133:                        cancel();
0134:                    }
0135:                };
0136:                _cancelButton = new JButton(cancelAction);
0137:
0138:                File workDir = _getWorkDir();
0139:                _fileOptionChooser = new JFileChooser(workDir);
0140:
0141:                _browserChooser = new JFileChooser(workDir);
0142:
0143:                _dirChooser = new DirectoryChooser(this );
0144:
0145:                /* Create tree and initialize tree. */
0146:                _rootNode = new PanelTreeNode("Preferences");
0147:                _treeModel = new DefaultTreeModel(_rootNode);
0148:                _tree = new JTree(_treeModel);
0149:
0150:                _initTree();
0151:
0152:                /* Create Panels. */
0153:                _createPanels();
0154:
0155:                _mainPanel = new JPanel();
0156:                _mainPanel.setLayout(new BorderLayout());
0157:                _tree
0158:                        .addTreeSelectionListener(new PanelTreeSelectionListener());
0159:
0160:                Container cp = getContentPane();
0161:                cp.setLayout(new BorderLayout());
0162:
0163:                // Select the first panel by default
0164:                if (_rootNode.getChildCount() != 0) {
0165:                    PanelTreeNode firstChild = (PanelTreeNode) _rootNode
0166:                            .getChildAt(0);
0167:                    TreeNode[] firstChildPath = firstChild.getPath();
0168:                    TreePath path = new TreePath(firstChildPath);
0169:                    _tree.expandPath(path);
0170:                    _tree.setSelectionPath(path);
0171:                }
0172:
0173:                JScrollPane treeScroll = new JScrollPane(_tree);
0174:                JPanel treePanel = new JPanel();
0175:                treePanel.setLayout(new BorderLayout());
0176:                treeScroll.setBorder(BorderFactory.createTitledBorder(
0177:                        BorderFactory.createEtchedBorder(), "Categories"));
0178:                treePanel.add(treeScroll, BorderLayout.CENTER);
0179:                cp.add(treePanel, BorderLayout.WEST);
0180:                cp.add(_mainPanel, BorderLayout.CENTER);
0181:
0182:                // Add buttons
0183:                JPanel bottom = new JPanel();
0184:                bottom.setBorder(new EmptyBorder(5, 5, 5, 5));
0185:                bottom.setLayout(new BoxLayout(bottom, BoxLayout.X_AXIS));
0186:                bottom.add(Box.createHorizontalGlue());
0187:                //bottom.add(_saveSettingsButton);
0188:                //bottom.add(Box.createHorizontalGlue());
0189:                bottom.add(_applyButton);
0190:                bottom.add(_okButton);
0191:                bottom.add(_cancelButton);
0192:                bottom.add(Box.createHorizontalGlue());
0193:
0194:                cp.add(bottom, BorderLayout.SOUTH);
0195:
0196:                // Set all dimensions ----
0197:                setSize(FRAME_WIDTH, FRAME_HEIGHT);
0198:
0199:                _mainFrame.setPopupLoc(this );
0200:
0201:                addWindowListener(new WindowAdapter() {
0202:                    public void windowClosing(java.awt.event.WindowEvent e) {
0203:                        cancel();
0204:                    }
0205:                });
0206:
0207:                // Make sure each row is expanded (this is harder than it seems...)
0208:                _tree.expandRow(0);
0209:                _tree.expandRow(1);
0210:                _tree.expandRow(2);
0211:            }
0212:
0213:            /** Performs deferred initialization.  Only runs in the event thread.  Some of this code occasionally generated swing
0214:             *  exceptions  when run in themain thread as part of MainFrame construction prior to making MainFrame visible. */
0215:            public void setUp() {
0216:                assert EventQueue.isDispatchThread();
0217:                /* Set up _fileOptionChooser, _browserChooser, and _dirChooser.  The line _dirChooser.setSelectedFile(...) caused
0218:                 * java.lang.ArrayIndexOutOfBoundsException within swing code in a JUnit test setUp() routine that constructed a
0219:                 * a MainFrame.
0220:                 */
0221:
0222:                _fileOptionChooser.setDialogTitle("Select");
0223:                _fileOptionChooser.setApproveButtonText("Select");
0224:                _fileOptionChooser
0225:                        .setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
0226:                _fileOptionChooser.setFileFilter(ClassPathFilter.ONLY);
0227:
0228:                _browserChooser.setDialogTitle("Select Web Browser");
0229:                _browserChooser.setApproveButtonText("Select");
0230:                _browserChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
0231:
0232:                _dirChooser.setSelectedFile(_getWorkDir());
0233:                _dirChooser.setDialogTitle("Select");
0234:                _dirChooser.setApproveButtonText("Select");
0235:                _dirChooser.setMultiSelectionEnabled(false);
0236:
0237:            }
0238:
0239:            /** Returns the current master working directory, or the user's current directory if none is set. 20040213 Changed default 
0240:             *  value to user's current directory.
0241:             */
0242:            private File _getWorkDir() {
0243:                File workDir = _mainFrame.getModel()
0244:                        .getMasterWorkingDirectory(); // cannot be null
0245:                if (workDir.isDirectory())
0246:                    return workDir;
0247:
0248:                if (workDir.getParent() != null)
0249:                    workDir = workDir.getParentFile();
0250:                return workDir;
0251:            }
0252:
0253:            /** Call the update method to propagate down the tree, parsing input values into their config options. */
0254:            public boolean apply() {
0255:                // returns false if the update did not succeed
0256:                return _rootNode.update();
0257:            }
0258:
0259:            /** Resets the field of each option in the Preferences window to its actual stored value. */
0260:            public void resetToCurrent() {
0261:                _rootNode.resetToCurrent();
0262:            }
0263:
0264:            /** Resets the frame and hides it. */
0265:            public void cancel() {
0266:                resetToCurrent();
0267:                _applyButton.setEnabled(false);
0268:                ConfigFrame.this .setVisible(false);
0269:            }
0270:
0271:            /** Write the configured option values to disk. */
0272:            public boolean saveSettings() throws IOException {
0273:                boolean successful = apply();
0274:                if (successful) {
0275:                    try {
0276:                        DrJava.getConfig().saveConfiguration();
0277:                    } catch (IOException ioe) {
0278:                        JOptionPane.showMessageDialog(this ,
0279:                                "Could not save changes to your '.drjava' file in your home directory. \n\n"
0280:                                        + ioe, "Could Not Save Changes",
0281:                                JOptionPane.ERROR_MESSAGE);
0282:                        //return false;
0283:                        throw ioe;
0284:                    }
0285:                }
0286:                return successful;
0287:            }
0288:
0289:            /** Sets the given ConfigPanel as the visible panel. */
0290:            private void _displayPanel(ConfigPanel cf) {
0291:
0292:                _mainPanel.removeAll();
0293:                _mainPanel.add(cf, BorderLayout.CENTER);
0294:                _mainPanel.revalidate();
0295:                _mainPanel.repaint();
0296:            }
0297:
0298:            /** Creates the JTree to display preferences categories. */
0299:            private void _initTree() {
0300:                _tree.setEditable(false);
0301:                _tree.getSelectionModel().setSelectionMode(
0302:                        TreeSelectionModel.SINGLE_TREE_SELECTION);
0303:                _tree.setShowsRootHandles(true);
0304:                _tree.setRootVisible(false);
0305:
0306:                DefaultTreeCellRenderer dtcr = new DefaultTreeCellRenderer();
0307:                dtcr.setLeafIcon(null);
0308:                dtcr.setOpenIcon(null);
0309:                dtcr.setClosedIcon(null);
0310:                _tree.setCellRenderer(dtcr);
0311:            }
0312:
0313:            /**Creates an individual panel, adds it to the JTree and the list of panels, and returns the tree node.
0314:             * @param t the title of this panel
0315:             * @param parent the parent tree node
0316:             * @return this tree node
0317:             */
0318:            private PanelTreeNode _createPanel(String t, PanelTreeNode parent) {
0319:                PanelTreeNode ptNode = new PanelTreeNode(t);
0320:                //parent.add(ptNode);
0321:                _treeModel.insertNodeInto(ptNode, parent, parent
0322:                        .getChildCount());
0323:
0324:                // Make sure tree node is visible
0325:                TreeNode[] pathArray = ptNode.getPath();
0326:                TreePath path = new TreePath(pathArray);
0327:                //     System.out.println("path has class " + pathArray.getClass());
0328:                //     System.out.println("last path compenent has class " + path.getLastPathComponent().getClass());
0329:                _tree.expandPath(path);
0330:
0331:                return ptNode;
0332:            }
0333:
0334:            /** Creates an individual panel, adds it to the JTree and the list of panels, and returns the tree node. Adds to the root node.
0335:             *  @param t the title of this panel
0336:             *  @return this tree node
0337:             */
0338:            private PanelTreeNode _createPanel(String t) {
0339:                return _createPanel(t, _rootNode);
0340:            }
0341:
0342:            /** Creates all of the panels contained within the frame. */
0343:            private void _createPanels() {
0344:
0345:                PanelTreeNode resourceLocNode = _createPanel("Resource Locations");
0346:                _setupResourceLocPanel(resourceLocNode.getPanel());
0347:
0348:                PanelTreeNode displayNode = _createPanel("Display Options");
0349:                _setupDisplayPanel(displayNode.getPanel());
0350:
0351:                PanelTreeNode fontNode = _createPanel("Fonts", displayNode);
0352:                _setupFontPanel(fontNode.getPanel());
0353:
0354:                PanelTreeNode colorNode = _createPanel("Colors", displayNode);
0355:                _setupColorPanel(colorNode.getPanel());
0356:
0357:                PanelTreeNode keystrokesNode = _createPanel("Key Bindings");
0358:                _setupKeyBindingsPanel(keystrokesNode.getPanel());
0359:
0360:                PanelTreeNode compilerOptionsNode = _createPanel("Compiler Options");
0361:                _setupCompilerPanel(compilerOptionsNode.getPanel());
0362:
0363:                PanelTreeNode debugNode = _createPanel("Debugger");
0364:                _setupDebugPanel(debugNode.getPanel());
0365:
0366:                PanelTreeNode javadocNode = _createPanel("Javadoc");
0367:                _setupJavadocPanel(javadocNode.getPanel());
0368:
0369:                PanelTreeNode notificationsNode = _createPanel("Notifications");
0370:                _setupNotificationsPanel(notificationsNode.getPanel());
0371:
0372:                PanelTreeNode miscNode = _createPanel("Miscellaneous");
0373:                _setupMiscPanel(miscNode.getPanel());
0374:
0375:                // Expand the display options node
0376:                //DrJava.consoleOut().println("expanding path...");
0377:                //_tree.expandPath(new TreePath(fontNode.getPath()));
0378:            }
0379:
0380:            public <X> void addOptionComponent(ConfigPanel panel,
0381:                    OptionComponent<X> oc) {
0382:                panel.addComponent(oc);
0383:                oc.addChangeListener(_changeListener);
0384:            }
0385:
0386:            /** Add all of the components for the Resource Locations panel of the preferences window. */
0387:            private void _setupResourceLocPanel(ConfigPanel panel) {
0388:                FileOptionComponent browserLoc = new FileOptionComponent(
0389:                        OptionConstants.BROWSER_FILE,
0390:                        "Web Browser",
0391:                        this ,
0392:                        "<html>Location of a web browser to use for Javadoc and Help links.<br>"
0393:                                + "If left blank, only the Web Browser Command will be used.<br>"
0394:                                + "This is not necessary if a default browser is available on your system.",
0395:                        _browserChooser);
0396:                addOptionComponent(panel, browserLoc);
0397:
0398:                StringOptionComponent browserCommand = new StringOptionComponent(
0399:                        OptionConstants.BROWSER_STRING,
0400:                        "Web Browser Command",
0401:                        this ,
0402:                        "<html>Command to send to the web browser to view a web location.<br>"
0403:                                + "The string <code>&lt;URL&gt;</code> will be replaced with the URL address.<br>"
0404:                                + "This is not necessary if a default browser is available on your system.");
0405:                addOptionComponent(panel, browserCommand);
0406:
0407:                FileOptionComponent javacLoc = new FileOptionComponent(
0408:                        OptionConstants.JAVAC_LOCATION,
0409:                        "Tools.jar Location",
0410:                        this ,
0411:                        "Optional location of the JDK's tools.jar, which contains the compiler and debugger.",
0412:                        _fileOptionChooser);
0413:                javacLoc.setFileFilter(ClassPathFilter.ONLY);
0414:                addOptionComponent(panel, javacLoc);
0415:
0416:                addOptionComponent(
0417:                        panel,
0418:                        new VectorFileOptionComponent(
0419:                                OptionConstants.EXTRA_CLASSPATH,
0420:                                "Extra Classpath",
0421:                                this ,
0422:                                "<html>Any directories or jar files to add to the classpath<br>"
0423:                                        + "of the Compiler and Interactions Pane.</html>"));
0424:                addOptionComponent(
0425:                        panel,
0426:                        new BooleanOptionComponent(
0427:                                OptionConstants.STICKY_INTERACTIONS_DIRECTORY,
0428:                                "Restore last working directory of the Interactions pane on start up",
0429:                                this ,
0430:                                "<html>Whether to restore the last working directory of the Interaction pane on start up,<br>"
0431:                                        + "or to always use the value of the \"user.home\" Java property<br>"
0432:                                        + "(currently "
0433:                                        + System.getProperty("user.home")
0434:                                        + ")."));
0435:
0436:                panel.displayComponents();
0437:            }
0438:
0439:            /** Add all of the components for the Display Options panel of the preferences window. */
0440:            private void _setupDisplayPanel(ConfigPanel panel) {
0441:
0442:                addOptionComponent(panel, new ForcedChoiceOptionComponent(
0443:                        OptionConstants.LOOK_AND_FEEL, "Look and Feel", this ,
0444:                        "Changes the general appearance of DrJava."));
0445:
0446:                //ToolbarOptionComponent is a degenerate option component
0447:                addOptionComponent(panel, new ToolbarOptionComponent(
0448:                        "Toolbar Buttons", this ,
0449:                        "How to display the toolbar buttons."));
0450:                addOptionComponent(
0451:                        panel,
0452:                        new BooleanOptionComponent(
0453:                                OptionConstants.LINEENUM_ENABLED,
0454:                                "Show All Line Numbers", this ,
0455:                                "Whether to show line numbers on the left side of the Definitions Pane."));
0456:                addOptionComponent(
0457:                        panel,
0458:                        new BooleanOptionComponent(
0459:                                OptionConstants.WINDOW_STORE_POSITION,
0460:                                "Save Main Window Position", this ,
0461:                                "Whether to save and restore the size and position of the main window."));
0462:                addOptionComponent(
0463:                        panel,
0464:                        new BooleanOptionComponent(
0465:                                OptionConstants.DIALOG_CLIPBOARD_HISTORY_STORE_POSITION,
0466:                                "Save \"Clipboard History\" Dialog Position",
0467:                                this ,
0468:                                "Whether to save and restore the size and position of the \"Clipboard History\" dialog."));
0469:                addOptionComponent(panel,
0470:                        new ButtonComponent(
0471:                                new ActionListener() {
0472:                                    public void actionPerformed(ActionEvent e) {
0473:                                        _mainFrame
0474:                                                .resetClipboardHistoryDialogPosition();
0475:                                    }
0476:                                },
0477:                                "Reset \"Clipboard History\" Dialog Position and Size",
0478:                                this ,
0479:                                "This resets the dialog position and size to its default values."));
0480:                addOptionComponent(
0481:                        panel,
0482:                        new IntegerOptionComponent(
0483:                                OptionConstants.CLIPBOARD_HISTORY_SIZE,
0484:                                "Size of Clipboard History", this ,
0485:                                "Determines how many entries are kept in the clipboard history."));
0486:                addOptionComponent(
0487:                        panel,
0488:                        new BooleanOptionComponent(
0489:                                OptionConstants.DIALOG_GOTOFILE_STORE_POSITION,
0490:                                "Save \"Go to File\" Dialog Position",
0491:                                this ,
0492:                                "Whether to save and restore the size and position of the \"Go to File\" dialog."));
0493:                addOptionComponent(
0494:                        panel,
0495:                        new ButtonComponent(new ActionListener() {
0496:                            public void actionPerformed(ActionEvent e) {
0497:                                _mainFrame.resetGotoFileDialogPosition();
0498:                            }
0499:                        }, "Reset \"Go to File\" Dialog Position and Size",
0500:                                this ,
0501:                                "This resets the dialog position and size to its default values."));
0502:                addOptionComponent(
0503:                        panel,
0504:                        new BooleanOptionComponent(
0505:                                OptionConstants.DIALOG_GOTOFILE_FULLY_QUALIFIED,
0506:                                "Display Fully-Qualified Class Names in \"Go to File\" Dialog",
0507:                                this ,
0508:                                "<html>Whether to also display fully-qualified class names in the \"Go to File\" dialog.<br>"
0509:                                        + "Enabling this option on network drives might cause the dialog to display after a slight delay.</html>"));
0510:                addOptionComponent(
0511:                        panel,
0512:                        new BooleanOptionComponent(
0513:                                OptionConstants.DIALOG_COMPLETE_WORD_STORE_POSITION,
0514:                                "Save \"Auto-Complete Word\" Dialog Position",
0515:                                this ,
0516:                                "Whether to save and restore the size and position of the \"Auto-Complete Word\" dialog."));
0517:                addOptionComponent(panel,
0518:                        new ButtonComponent(
0519:                                new ActionListener() {
0520:                                    public void actionPerformed(ActionEvent e) {
0521:                                        _mainFrame
0522:                                                .resetCompleteWordDialogPosition();
0523:                                    }
0524:                                },
0525:                                "Reset \"Auto-Complete Word\" Dialog Position and Size",
0526:                                this ,
0527:                                "This resets the dialog position and size to its default values."));
0528:                addOptionComponent(
0529:                        panel,
0530:                        new BooleanOptionComponent(
0531:                                OptionConstants.DIALOG_JAROPTIONS_STORE_POSITION,
0532:                                "Save \"Create Jar File from Project\" Dialog Position",
0533:                                this ,
0534:                                "Whether to save and restore the position of the \"Create Jar File from Project\" dialog."));
0535:                addOptionComponent(panel,
0536:                        new ButtonComponent(
0537:                                new ActionListener() {
0538:                                    public void actionPerformed(ActionEvent e) {
0539:                                        _mainFrame
0540:                                                .resetJarOptionsDialogPosition();
0541:                                    }
0542:                                },
0543:                                "Reset \"Create Jar File from Project\" Dialog Position",
0544:                                this ,
0545:                                "This resets the dialog position to its default values."));
0546:                addOptionComponent(
0547:                        panel,
0548:                        new BooleanOptionComponent(
0549:                                OptionConstants.DIALOG_OPENJAVADOC_STORE_POSITION,
0550:                                "Save \"Open Javadoc\" Dialog Position",
0551:                                this ,
0552:                                "Whether to save and restore the size and position of the \"Open Javadoc\" dialog."));
0553:                addOptionComponent(
0554:                        panel,
0555:                        new ButtonComponent(new ActionListener() {
0556:                            public void actionPerformed(ActionEvent e) {
0557:                                _mainFrame.resetOpenJavadocDialogPosition();
0558:                            }
0559:                        }, "Reset \"Open Javadoc\" Dialog Position and Size",
0560:                                this ,
0561:                                "This resets the dialog position and size to its default values."));
0562:                addOptionComponent(
0563:                        panel,
0564:                        new BooleanOptionComponent(
0565:                                OptionConstants.DIALOG_AUTOIMPORT_STORE_POSITION,
0566:                                "Save \"Auto Import\" Dialog Position",
0567:                                this ,
0568:                                "Whether to save and restore the size and position of the \"Auto Import\" dialog."));
0569:                addOptionComponent(
0570:                        panel,
0571:                        new ButtonComponent(new ActionListener() {
0572:                            public void actionPerformed(ActionEvent e) {
0573:                                _mainFrame.resetAutoImportDialogPosition();
0574:                            }
0575:                        }, "Reset \"Auto Import\" Dialog Position and Size",
0576:                                this ,
0577:                                "This resets the dialog position and size to its default values."));
0578:                addOptionComponent(
0579:                        panel,
0580:                        new BooleanOptionComponent(
0581:                                OptionConstants.DIALOG_COMPLETE_SCAN_CLASS_FILES,
0582:                                "Scan Class Files After Each Compile For Auto-Completion and Auto-Import",
0583:                                this ,
0584:                                "<html>Whether to scan the class files after a compile to generate class names<br>"
0585:                                        + "used for auto-completion and auto-import.<br>"
0586:                                        + "Enabling this option will slow compiles down.</html>"));
0587:                panel.displayComponents();
0588:            }
0589:
0590:            /** Add all of the components for the Font panel of the preferences window. */
0591:            private void _setupFontPanel(ConfigPanel panel) {
0592:                addOptionComponent(panel, new FontOptionComponent(
0593:                        OptionConstants.FONT_MAIN, "Main Font", this ,
0594:                        "The font used for most text in DrJava."));
0595:                addOptionComponent(
0596:                        panel,
0597:                        new FontOptionComponent(
0598:                                OptionConstants.FONT_LINE_NUMBERS,
0599:                                "Line Numbers Font",
0600:                                this ,
0601:                                "<html>The font for displaying line numbers on the left side of<br>"
0602:                                        + "the Definitions Pane if Show All Line Numbers is enabled.<br>"
0603:                                        + "Cannot be displayed larger than the Main Font.</html>"));
0604:                addOptionComponent(panel, new FontOptionComponent(
0605:                        OptionConstants.FONT_DOCLIST, "Document List Font",
0606:                        this , "The font used in the list of open documents."));
0607:                addOptionComponent(panel, new FontOptionComponent(
0608:                        OptionConstants.FONT_TOOLBAR, "Toolbar Font", this ,
0609:                        "The font used in the toolbar buttons."));
0610:                addOptionComponent(panel, new BooleanOptionComponent(
0611:                        OptionConstants.TEXT_ANTIALIAS,
0612:                        "Use anti-aliased text", this ,
0613:                        "Whether to graphically smooth the text."));
0614:                panel.displayComponents();
0615:            }
0616:
0617:            /**
0618:             * Adds all of the components for the Color panel of the preferences window.
0619:             */
0620:            private void _setupColorPanel(ConfigPanel panel) {
0621:                addOptionComponent(panel, new ColorOptionComponent(
0622:                        OptionConstants.DEFINITIONS_NORMAL_COLOR,
0623:                        "Normal Color", this ,
0624:                        "The default color for text in the Definitions Pane."));
0625:                addOptionComponent(panel, new ColorOptionComponent(
0626:                        OptionConstants.DEFINITIONS_KEYWORD_COLOR,
0627:                        "Keyword Color", this ,
0628:                        "The color for Java keywords in the Definitions Pane."));
0629:                addOptionComponent(
0630:                        panel,
0631:                        new ColorOptionComponent(
0632:                                OptionConstants.DEFINITIONS_TYPE_COLOR,
0633:                                "Type Color", this ,
0634:                                "The color for classes and types in the Definitions Pane."));
0635:                addOptionComponent(panel, new ColorOptionComponent(
0636:                        OptionConstants.DEFINITIONS_COMMENT_COLOR,
0637:                        "Comment Color", this ,
0638:                        "The color for comments in the Definitions Pane."));
0639:                addOptionComponent(
0640:                        panel,
0641:                        new ColorOptionComponent(
0642:                                OptionConstants.DEFINITIONS_DOUBLE_QUOTED_COLOR,
0643:                                "Double-quoted Color", this ,
0644:                                "The color for quoted strings (eg. \"...\") in the Definitions Pane."));
0645:                addOptionComponent(
0646:                        panel,
0647:                        new ColorOptionComponent(
0648:                                OptionConstants.DEFINITIONS_SINGLE_QUOTED_COLOR,
0649:                                "Single-quoted Color", this ,
0650:                                "The color for quoted characters (eg. 'a') in the Definitions Pane."));
0651:                addOptionComponent(panel, new ColorOptionComponent(
0652:                        OptionConstants.DEFINITIONS_NUMBER_COLOR,
0653:                        "Number Color", this ,
0654:                        "The color for numbers in the Definitions Pane."));
0655:                addOptionComponent(panel, new ColorOptionComponent(
0656:                        OptionConstants.DEFINITIONS_BACKGROUND_COLOR,
0657:                        "Background Color", this ,
0658:                        "The background color of the Definitions Pane.", true));
0659:                addOptionComponent(
0660:                        panel,
0661:                        new ColorOptionComponent(
0662:                                OptionConstants.DEFINITIONS_MATCH_COLOR,
0663:                                "Brace-matching Color",
0664:                                this ,
0665:                                "The color for matching brace highlights in the Definitions Pane.",
0666:                                true));
0667:                addOptionComponent(
0668:                        panel,
0669:                        new ColorOptionComponent(
0670:                                OptionConstants.COMPILER_ERROR_COLOR,
0671:                                "Compiler Error Color",
0672:                                this ,
0673:                                "The color for compiler error highlights in the Definitions Pane.",
0674:                                true));
0675:                addOptionComponent(panel, new ColorOptionComponent(
0676:                        OptionConstants.BOOKMARK_COLOR, "Bookmark Color", this ,
0677:                        "The color for bookmarks in the Definitions Pane.",
0678:                        true));
0679:                for (int i = 0; i < OptionConstants.FIND_RESULTS_COLORS.length; ++i) {
0680:                    addOptionComponent(
0681:                            panel,
0682:                            new ColorOptionComponent(
0683:                                    OptionConstants.FIND_RESULTS_COLORS[i],
0684:                                    "Find Results Color " + (i + 1),
0685:                                    this ,
0686:                                    "A color for highlighting find results in the Definitions Pane.",
0687:                                    true));
0688:                }
0689:                addOptionComponent(panel, new ColorOptionComponent(
0690:                        OptionConstants.DEBUG_BREAKPOINT_COLOR,
0691:                        "Debugger Breakpoint Color", this ,
0692:                        "The color for breakpoints in the Definitions Pane.",
0693:                        true));
0694:                addOptionComponent(
0695:                        panel,
0696:                        new ColorOptionComponent(
0697:                                OptionConstants.DEBUG_BREAKPOINT_DISABLED_COLOR,
0698:                                "Disabled Debugger Breakpoint Color",
0699:                                this ,
0700:                                "The color for disabled breakpoints in the Definitions Pane.",
0701:                                true));
0702:                addOptionComponent(
0703:                        panel,
0704:                        new ColorOptionComponent(
0705:                                OptionConstants.DEBUG_THREAD_COLOR,
0706:                                "Debugger Location Color",
0707:                                this ,
0708:                                "The color for the location of the current suspended thread in the Definitions Pane.",
0709:                                true));
0710:                addOptionComponent(
0711:                        panel,
0712:                        new ColorOptionComponent(
0713:                                OptionConstants.SYSTEM_OUT_COLOR,
0714:                                "System.out Color", this ,
0715:                                "The color for System.out in the Interactions and Console Panes."));
0716:                addOptionComponent(
0717:                        panel,
0718:                        new ColorOptionComponent(
0719:                                OptionConstants.SYSTEM_ERR_COLOR,
0720:                                "System.err Color", this ,
0721:                                "The color for System.err in the Interactions and Console Panes."));
0722:                addOptionComponent(panel, new ColorOptionComponent(
0723:                        OptionConstants.SYSTEM_IN_COLOR, "System.in Color",
0724:                        this ,
0725:                        "The color for System.in in the Interactions Pane."));
0726:                addOptionComponent(
0727:                        panel,
0728:                        new ColorOptionComponent(
0729:                                OptionConstants.INTERACTIONS_ERROR_COLOR,
0730:                                "Interactions Error Color",
0731:                                this ,
0732:                                "The color for interactions errors in the Interactions Pane.",
0733:                                false, true));
0734:                addOptionComponent(
0735:                        panel,
0736:                        new ColorOptionComponent(
0737:                                OptionConstants.DEBUG_MESSAGE_COLOR,
0738:                                "Debug Message Color",
0739:                                this ,
0740:                                "The color for debugger messages in the Interactions Pane.",
0741:                                false, true));
0742:                addOptionComponent(
0743:                        panel,
0744:                        new ColorOptionComponent(
0745:                                OptionConstants.DRJAVA_ERRORS_BUTTON_COLOR,
0746:                                "DrJava Errors Button Background Color",
0747:                                this ,
0748:                                "The background color of the \"Errors\" button used to show internal DrJava errors.",
0749:                                true));
0750:
0751:                panel.displayComponents();
0752:            }
0753:
0754:            /**
0755:             * Adds all of the components for the Key Bindings panel of the preferences window.
0756:             */
0757:            private void _setupKeyBindingsPanel(ConfigPanel panel) {
0758:                // using a treeset because it automatically sorts element upon insertion
0759:                TreeSet<KeyStrokeOptionComponent> _comps = new TreeSet<KeyStrokeOptionComponent>();
0760:
0761:                KeyStrokeData tmpKsd;
0762:                KeyStrokeOptionComponent tmpKsoc;
0763:
0764:                Enumeration e = KeyBindingManager.Singleton.getKeyStrokeData();
0765:                while (e.hasMoreElements()) {
0766:                    tmpKsd = (KeyStrokeData) e.nextElement();
0767:                    if (tmpKsd.getOption() != null) {
0768:                        // Get the tooltip, or default to its name, if none
0769:                        //        KeyStroke ks = tmpKsd.getKeyStroke();
0770:                        //        Action a = KeyBindingManager.Singleton.get(ks);
0771:                        Action a = tmpKsd.getAction();
0772:                        String desc = (String) a
0773:                                .getValue(Action.SHORT_DESCRIPTION);
0774:                        if ((desc == null) || (desc.equals(""))) {
0775:                            desc = tmpKsd.getName();
0776:                        }
0777:
0778:                        tmpKsoc = new KeyStrokeOptionComponent(
0779:                                (KeyStrokeOption) tmpKsd.getOption(), tmpKsd
0780:                                        .getName(), this , desc);
0781:                        if (tmpKsoc != null) {
0782:                            _comps.add(tmpKsoc);
0783:                        }
0784:                    }
0785:                }
0786:
0787:                Iterator<KeyStrokeOptionComponent> iter = _comps.iterator();
0788:                while (iter.hasNext()) {
0789:                    KeyStrokeOptionComponent x = iter.next();
0790:                    addOptionComponent(panel, x);
0791:                }
0792:                panel.displayComponents();
0793:            }
0794:
0795:            /**
0796:             * Add all of the components for the Debugger panel of the preferences window.
0797:             */
0798:            private void _setupDebugPanel(ConfigPanel panel) {
0799:                if (!_mainFrame.getModel().getDebugger().isAvailable()) {
0800:                    // Explain how to use debugger
0801:                    String howto = "\nThe debugger is not currently active.  To use the debugger, you\n"
0802:                            + "must include Sun's tools.jar or jpda.jar on your classpath when\n"
0803:                            + "starting DrJava.  Do not use the \"-jar\" option, because it\n"
0804:                            + "overrides the classpath and will not include tools.jar.\n"
0805:                            + "For example, in Windows you might type:\n\n"
0806:                            + "  java -classpath drjava.jar;c:\\path\\tools.jar edu.rice.cs.drjava.DrJava\n\n"
0807:                            + "(Substituting the correct path for tools.jar.)\n"
0808:                            + "See the user documentation for more details.\n";
0809:                    addOptionComponent(panel, new LabelComponent(howto, this ));
0810:                }
0811:
0812:                VectorFileOptionComponent sourcePath = new VectorFileOptionComponent(
0813:                        OptionConstants.DEBUG_SOURCEPATH, "Sourcepath", this ,
0814:                        "<html>Any directories in which to search for source<br>"
0815:                                + "files when stepping in the Debugger.</html>");
0816:                // Source path can only include directories
0817:                sourcePath.setFileFilter(new DirectoryFilter(
0818:                        "Source Directories"));
0819:                addOptionComponent(panel, sourcePath);
0820:                addOptionComponent(
0821:                        panel,
0822:                        new BooleanOptionComponent(
0823:                                OptionConstants.DEBUG_STEP_JAVA,
0824:                                "Step Into Java Classes",
0825:                                this ,
0826:                                "<html>Whether the Debugger should step into Java library classes,<br>"
0827:                                        + "including java.*, javax.*, sun.*, com.sun.*, com.apple.eawt.*, and com.apple.eio.*</html>"));
0828:                addOptionComponent(
0829:                        panel,
0830:                        new BooleanOptionComponent(
0831:                                OptionConstants.DEBUG_STEP_INTERPRETER,
0832:                                "Step Into Interpreter Classes",
0833:                                this ,
0834:                                "<html>Whether the Debugger should step into the classes<br>"
0835:                                        + "used by the Interactions Pane (DynamicJava).</html>"));
0836:                addOptionComponent(
0837:                        panel,
0838:                        new BooleanOptionComponent(
0839:                                OptionConstants.DEBUG_STEP_DRJAVA,
0840:                                "Step Into DrJava Classes", this ,
0841:                                "Whether the Debugger should step into DrJava's own class files."));
0842:                addOptionComponent(
0843:                        panel,
0844:                        new StringOptionComponent(
0845:                                OptionConstants.DEBUG_STEP_EXCLUDE,
0846:                                "Classes/Packages To Exclude",
0847:                                this ,
0848:                                "<html>Any classes that the debuggger should not step into.<br>"
0849:                                        + "Should be a COMMA-separated list of fully-qualified class names.<br>"
0850:                                        + "To exclude a package, specify <code>packagename.*</code> in the list.</html>"));
0851:
0852:                panel.displayComponents();
0853:            }
0854:
0855:            /** Add all of the components for the Javadoc panel of the preferences window. */
0856:            private void _setupJavadocPanel(ConfigPanel panel) {
0857:                addOptionComponent(
0858:                        panel,
0859:                        new ForcedChoiceOptionComponent(
0860:                                OptionConstants.JAVADOC_ACCESS_LEVEL,
0861:                                "Access Level",
0862:                                this ,
0863:                                "<html>Fields and methods with access modifiers at this level<br>"
0864:                                        + "or higher will be included in the generated Javadoc.</html>"));
0865:                addOptionComponent(
0866:                        panel,
0867:                        new ForcedChoiceOptionComponent(
0868:                                OptionConstants.JAVADOC_LINK_VERSION,
0869:                                "Java Version for Javadoc Links", this ,
0870:                                "The version of Java for generating links to online Javadoc documentation."));
0871:                addOptionComponent(
0872:                        panel,
0873:                        new StringOptionComponent(
0874:                                OptionConstants.JAVADOC_1_3_LINK,
0875:                                "Javadoc 1.3 URL", this ,
0876:                                "The URL to the Java 1.3 API, for generating links to library classes."));
0877:                addOptionComponent(
0878:                        panel,
0879:                        new StringOptionComponent(
0880:                                OptionConstants.JAVADOC_1_4_LINK,
0881:                                "Javadoc 1.4 URL", this ,
0882:                                "The URL to the Java 1.4 API, for generating links to library classes."));
0883:                addOptionComponent(
0884:                        panel,
0885:                        new StringOptionComponent(
0886:                                OptionConstants.JAVADOC_1_5_LINK,
0887:                                "Javadoc 1.5 URL", this ,
0888:                                "The URL to the Java 1.5 API, for generating links to library classes."));
0889:
0890:                addOptionComponent(
0891:                        panel,
0892:                        new DirectoryOptionComponent(
0893:                                OptionConstants.JAVADOC_DESTINATION,
0894:                                "Default Destination Directory",
0895:                                this ,
0896:                                "Optional default directory for saving Javadoc documentation.",
0897:                                _dirChooser));
0898:
0899:                addOptionComponent(panel, new StringOptionComponent(
0900:                        OptionConstants.JAVADOC_CUSTOM_PARAMS,
0901:                        "Custom Javadoc Parameters", this ,
0902:                        "Any extra flags or parameters to pass to Javadoc."));
0903:
0904:                addOptionComponent(
0905:                        panel,
0906:                        new BooleanOptionComponent(
0907:                                OptionConstants.JAVADOC_FROM_ROOTS,
0908:                                "Generate Javadoc From Source Roots",
0909:                                this ,
0910:                                "<html>Whether 'Javadoc All' should generate Javadoc for all packages<br>"
0911:                                        + "in an open document's source tree, rather than just the document's<br>"
0912:                                        + "own package and sub-packages.</html>"));
0913:
0914:                panel.displayComponents();
0915:            }
0916:
0917:            /** Adds all of the components for the Prompts panel of the preferences window. */
0918:            private void _setupNotificationsPanel(ConfigPanel panel) {
0919:                // Quit
0920:                addOptionComponent(
0921:                        panel,
0922:                        new BooleanOptionComponent(OptionConstants.QUIT_PROMPT,
0923:                                "Prompt Before Quit", this ,
0924:                                "Whether DrJava should prompt the user before quitting."));
0925:
0926:                // Interactions
0927:                addOptionComponent(
0928:                        panel,
0929:                        new BooleanOptionComponent(
0930:                                OptionConstants.INTERACTIONS_RESET_PROMPT,
0931:                                "Prompt Before Resetting Interactions Pane",
0932:                                this ,
0933:                                "<html>Whether DrJava should prompt the user before<br>"
0934:                                        + "manually resetting the interactions pane.</html>"));
0935:                addOptionComponent(
0936:                        panel,
0937:                        new BooleanOptionComponent(
0938:                                OptionConstants.INTERACTIONS_EXIT_PROMPT,
0939:                                "Prompt if Interactions Pane Exits Unexpectedly",
0940:                                this ,
0941:                                "<html>Whether DrJava should show a dialog box if a program<br>"
0942:                                        + "in the Interactions Pane exits without the user clicking Reset.</html>"));
0943:
0944:                // Javadoc
0945:                addOptionComponent(panel, new BooleanOptionComponent(
0946:                        OptionConstants.JAVADOC_PROMPT_FOR_DESTINATION,
0947:                        "Prompt for Javadoc Destination", this ,
0948:                        "<html>Whether Javadoc should always prompt the user<br>"
0949:                                + "to select a destination directory.</html>"));
0950:
0951:                // Clean
0952:                addOptionComponent(panel, new BooleanOptionComponent(
0953:                        OptionConstants.PROMPT_BEFORE_CLEAN,
0954:                        "Prompt before Cleaning Build Directory", this ,
0955:                        "<html>Whether DrJava should prompt before cleaning the<br>"
0956:                                + "build directory of a project</html>"));
0957:
0958:                // Save before X
0959:                addOptionComponent(
0960:                        panel,
0961:                        new BooleanOptionComponent(
0962:                                OptionConstants.ALWAYS_SAVE_BEFORE_COMPILE,
0963:                                "Automatically Save Before Compiling",
0964:                                this ,
0965:                                "<html>Whether DrJava should automatically save before<br>"
0966:                                        + "recompiling or ask the user each time.</html>"));
0967:
0968:                addOptionComponent(
0969:                        panel,
0970:                        new BooleanOptionComponent(
0971:                                OptionConstants.ALWAYS_COMPILE_BEFORE_JUNIT,
0972:                                "Automatically Compile Before Testing",
0973:                                this ,
0974:                                "<html>Whether DrJava should automatically compile before<br>"
0975:                                        + "testing with JUnit or ask the user each time.</html>"));
0976:
0977:                addOptionComponent(
0978:                        panel,
0979:                        new BooleanOptionComponent(
0980:                                OptionConstants.ALWAYS_SAVE_BEFORE_JAVADOC,
0981:                                "Automatically Save Before Generating Javadoc",
0982:                                this ,
0983:                                "<html>Whether DrJava should automatically save before<br>"
0984:                                        + "generating Javadoc or ask the user each time.</html>"));
0985:
0986:                // These are very problematic features, and so are disabled for the forseeable future.
0987:                //    addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.ALWAYS_SAVE_BEFORE_RUN, "Automatically Save and Compile Before Running Main Method", this,
0988:                //                                                    "<html>Whether DrJava should automatically save and compile before running<br>" +
0989:                //                                                    "a document's main method, or instead should ask the user each time.</html>"));
0990:                //    addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.ALWAYS_SAVE_BEFORE_DEBUG, "Automatically Save and Compile Before Debugging", this,
0991:                //                                                  "<html>Whether DrJava should automatically save and compile before<br>" +
0992:                //                                                  "debugging or ask the user each time.</html>"));
0993:
0994:                // Warnings
0995:                addOptionComponent(
0996:                        panel,
0997:                        new BooleanOptionComponent(
0998:                                OptionConstants.WARN_BREAKPOINT_OUT_OF_SYNC,
0999:                                "Warn on Breakpoint if Out of Sync",
1000:                                this ,
1001:                                "<html>Whether DrJava should warn the user if the class file<br>"
1002:                                        + "is out of sync before setting a breakpoint in that file.</html>"));
1003:                addOptionComponent(
1004:                        panel,
1005:                        new BooleanOptionComponent(
1006:                                OptionConstants.WARN_DEBUG_MODIFIED_FILE,
1007:                                "Warn if Debugging Modified File",
1008:                                this ,
1009:                                "<html>Whether DrJava should warn the user if the file being<br>"
1010:                                        + "debugged has been modified since its last save.</html>"));
1011:                addOptionComponent(
1012:                        panel,
1013:                        new BooleanOptionComponent(
1014:                                OptionConstants.WARN_CHANGE_LAF,
1015:                                "Warn to Restart to Change Look and Feel",
1016:                                this ,
1017:                                "<html>Whether DrJava should warn the user that look and feel.<br>"
1018:                                        + "(Changes will not be applied until DrJava is restarted.)</html>."));
1019:                addOptionComponent(
1020:                        panel,
1021:                        new BooleanOptionComponent(
1022:                                OptionConstants.WARN_PATH_CONTAINS_POUND,
1023:                                "Warn if File's Path Contains a '#' Symbol",
1024:                                this ,
1025:                                "<html>Whether DrJava should warn the user if the file being<br>"
1026:                                        + "saved has a path that contains a '#' symbol.<br>"
1027:                                        + "Users cannot use such files in the Interactions Pane<br>"
1028:                                        + "because of a bug in Java.</html>"));
1029:
1030:                addOptionComponent(
1031:                        panel,
1032:                        new BooleanOptionComponent(
1033:                                OptionConstants.DIALOG_DRJAVA_ERROR_POPUP_ENABLED,
1034:                                "Show a notification window when the first DrJava error occurs",
1035:                                this ,
1036:                                "<html>Whether to show a notification window when the first DrJava error occurs.<br>"
1037:                                        + "If this is disabled, only the \"DrJava Error\" button will appear.</html>"));
1038:
1039:                panel.displayComponents();
1040:            }
1041:
1042:            /** Adds all of the components for the Miscellaneous panel of the preferences window. */
1043:            private void _setupMiscPanel(ConfigPanel panel) {
1044:                /* Dialog box options */
1045:                addOptionComponent(
1046:                        panel,
1047:                        new IntegerOptionComponent(
1048:                                OptionConstants.INDENT_LEVEL, "Indent Level",
1049:                                this ,
1050:                                "The number of spaces to use for each level of indentation."));
1051:                addOptionComponent(
1052:                        panel,
1053:                        new IntegerOptionComponent(
1054:                                OptionConstants.HISTORY_MAX_SIZE,
1055:                                "Size of Interactions History", this ,
1056:                                "The number of interactions to remember in the history."));
1057:                addOptionComponent(
1058:                        panel,
1059:                        new IntegerOptionComponent(
1060:                                OptionConstants.RECENT_FILES_MAX_SIZE,
1061:                                "Recent Files List Size",
1062:                                this ,
1063:                                "<html>The number of files to remember in<br>"
1064:                                        + "the recently used files list in the File menu.</html>"));
1065:                addOptionComponent(panel, new StringOptionComponent(
1066:                        OptionConstants.MASTER_JVM_ARGS,
1067:                        "JVM Args for Main JVM", this ,
1068:                        "The command-line arguments to pass to the Main JVM."));
1069:                addOptionComponent(
1070:                        panel,
1071:                        new StringOptionComponent(
1072:                                OptionConstants.SLAVE_JVM_ARGS,
1073:                                "JVM Args for Interactions JVM", this ,
1074:                                "The command-line arguments to pass to the Interactions JVM."));
1075:                addOptionComponent(
1076:                        panel,
1077:                        new IntegerOptionComponent(
1078:                                OptionConstants.BROWSER_HISTORY_MAX_SIZE,
1079:                                "Maximum Size of Browser History", this ,
1080:                                "Determines how many entries are kept in the browser history."));
1081:
1082:                /* Check box options */
1083:                addOptionComponent(
1084:                        panel,
1085:                        new BooleanOptionComponent(
1086:                                OptionConstants.AUTO_CLOSE_COMMENTS,
1087:                                "Automatically Close Block Comments",
1088:                                this ,
1089:                                "<html>Whether to automatically insert a closing comment tag (\"*/\")<br>"
1090:                                        + "when the enter key is pressed after typing a new block comment<br>"
1091:                                        + "tag (\"/*\" or \"/**\").</html>"));
1092:                addOptionComponent(
1093:                        panel,
1094:                        new BooleanOptionComponent(
1095:                                OptionConstants.RUN_WITH_ASSERT,
1096:                                "Enable Assert Statement Execution",
1097:                                this ,
1098:                                "<html>Whether to execute <code>assert</code> statements in classes running in the interactions pane.</html>"));
1099:                addOptionComponent(
1100:                        panel,
1101:                        new BooleanOptionComponent(
1102:                                OptionConstants.BACKUP_FILES,
1103:                                "Keep Emacs-style Backup Files",
1104:                                this ,
1105:                                "<html>Whether DrJava should keep a backup copy of each file that<br>"
1106:                                        + "the user modifies, saved with a '~' at the end of the filename.</html>"));
1107:                addOptionComponent(
1108:                        panel,
1109:                        new BooleanOptionComponent(
1110:                                OptionConstants.RESET_CLEAR_CONSOLE,
1111:                                "Clear Console After Interactions Reset", this ,
1112:                                "Whether to clear the Console output after resetting the Interactions Pane."));
1113:                addOptionComponent(
1114:                        panel,
1115:                        new BooleanOptionComponent(
1116:                                OptionConstants.ALLOW_PRIVATE_ACCESS,
1117:                                "Allow Access of Private Members in Interactions Pane",
1118:                                this ,
1119:                                "Whether to allow users to access private (and protected) fields and methods."));
1120:                addOptionComponent(
1121:                        panel,
1122:                        new BooleanOptionComponent(
1123:                                OptionConstants.SHOW_SOURCE_WHEN_SWITCHING,
1124:                                "Show sample of source code when fast switching",
1125:                                this ,
1126:                                "Whether to show a sample of the source code under the document's filename when fast switching documents."));
1127:                addOptionComponent(
1128:                        panel,
1129:                        new BooleanOptionComponent(
1130:                                OptionConstants.FORCE_TEST_SUFFIX,
1131:                                "Require test classes in projects to end in \"Test\"",
1132:                                this ,
1133:                                "Whether to force test classes in projects to end in \"Test\"."));
1134:                addOptionComponent(
1135:                        panel,
1136:                        new BooleanOptionComponent(
1137:                                OptionConstants.FIND_REPLACE_FOCUS_IN_DEFPANE,
1138:                                "Put the focus in the definitions pane after find/replace",
1139:                                this ,
1140:                                "<html>Whether to put the focus in the definitions pane after doing a find or replace operation.<br>"
1141:                                        + "If this is not selected, the focus will be in the Find/Replace pane.</html>"));
1142:                addOptionComponent(
1143:                        panel,
1144:                        new BooleanOptionComponent(
1145:                                OptionConstants.SHOW_CODE_PREVIEW_POPUPS,
1146:                                "Show Code Preview Popups",
1147:                                this ,
1148:                                "<html>Whether to show a popup window with a code preview when the mouse is hovering<br>"
1149:                                        + "over an item in the Breakpoints, Bookmarks and Find All panes.</html>"));
1150:                addOptionComponent(
1151:                        panel,
1152:                        new BooleanOptionComponent(
1153:                                OptionConstants.DRJAVA_USE_FORCE_QUIT,
1154:                                "Forcefully Quit DrJava",
1155:                                this ,
1156:                                "<html>On some platforms, DrJava does not shut down properly when files are open<br>"
1157:                                        + "(namely tablet PCs). Check this option to force DrJava to close.</html>"));
1158:                addOptionComponent(
1159:                        panel,
1160:                        new BooleanOptionComponent(
1161:                                OptionConstants.REMOTE_CONTROL_ENABLED,
1162:                                "Enable Remote Control",
1163:                                this ,
1164:                                "<html>Whether DrJava should listen to a socket (see below) so it<br>"
1165:                                        + "can be remote controlled and told to open files.<br>"
1166:                                        + "(Changes will not be applied until DrJava is restarted.)</html>"));
1167:                addOptionComponent(
1168:                        panel,
1169:                        new IntegerOptionComponent(
1170:                                OptionConstants.REMOTE_CONTROL_PORT,
1171:                                "Remote Control Port",
1172:                                this ,
1173:                                "<html>A running instance of DrJava can be remote controlled and<br>"
1174:                                        + "told to open files. This specifies the port used for remote control.</html>"));
1175:                addOptionComponent(
1176:                        panel,
1177:                        new BooleanOptionComponent(
1178:                                OptionConstants.DIALOG_AUTOIMPORT_ENABLED,
1179:                                "Enable the \"Auto Import\" Dialog",
1180:                                this ,
1181:                                "<html>Whether DrJava should open the \"Auto Import\" dialog when<br>"
1182:                                        + "an undefined class is encountered in the Interactions Pane.</html>"));
1183:
1184:                // Any lightweight parsing has been disabled until we have something that is beneficial and works better in the background.
1185:                //    addOptionComponent(panel, new BooleanOptionComponent(OptionConstants.LIGHTWEIGHT_PARSING_ENABLED, 
1186:                //                                                  "Perform lightweight parsing", this,
1187:                //                                                  "<html>Whether to continuously parse the source file for useful information.<br>" +
1188:                //                                                  "Enabling this option might introduce delays when editing files.<html>"));
1189:                //    addOptionComponent(panel, new IntegerOptionComponent(OptionConstants.DIALOG_LIGHTWEIGHT_PARSING_DELAY, "Light-weight parsing delay in milliseconds", this,
1190:                //                                                  "The amount of time DrJava will wait after the last keypress before beginning to parse."));
1191:
1192:                panel.displayComponents();
1193:            }
1194:
1195:            /**
1196:             * Adds all of the components for the Compiler Options Panel of the preferences window
1197:             */
1198:            private void _setupCompilerPanel(ConfigPanel panel) {
1199:                addOptionComponent(
1200:                        panel,
1201:                        new LabelComponent(
1202:                                "Note: Compiler warnings not shown if compiling any Java language level files",
1203:                                this ));
1204:                addOptionComponent(
1205:                        panel,
1206:                        new BooleanOptionComponent(
1207:                                OptionConstants.SHOW_UNCHECKED_WARNINGS,
1208:                                "Show Unchecked Warnings", this ,
1209:                                "<html>Warn about unchecked conversions involving parameterized types.</html>"));
1210:                addOptionComponent(
1211:                        panel,
1212:                        new BooleanOptionComponent(
1213:                                OptionConstants.SHOW_DEPRECATION_WARNINGS,
1214:                                "Show Deprecation Warnings",
1215:                                this ,
1216:                                "<html>Warn about each use or override of a deprecated method, field, or class.</html>"));
1217:                addOptionComponent(
1218:                        panel,
1219:                        new BooleanOptionComponent(
1220:                                OptionConstants.SHOW_PATH_WARNINGS,
1221:                                "Show Path Warnings", this ,
1222:                                "<html>Warn about nonexistent members of the classpath and sourcepath.</html>"));
1223:                addOptionComponent(
1224:                        panel,
1225:                        new BooleanOptionComponent(
1226:                                OptionConstants.SHOW_SERIAL_WARNINGS,
1227:                                "Show Serial Warnings",
1228:                                this ,
1229:                                "<html>Warn about missing <code>serialVersionUID</code> definitions on serializable classes.</html>"));
1230:                addOptionComponent(
1231:                        panel,
1232:                        new BooleanOptionComponent(
1233:                                OptionConstants.SHOW_FINALLY_WARNINGS,
1234:                                "Show Finally Warnings",
1235:                                this ,
1236:                                "<html>Warn about <code>finally</code> clauses that cannot complete normally.</html>"));
1237:                addOptionComponent(
1238:                        panel,
1239:                        new BooleanOptionComponent(
1240:                                OptionConstants.SHOW_FALLTHROUGH_WARNINGS,
1241:                                "Show Fall-Through Warnings",
1242:                                this ,
1243:                                "<html>Warn about <code>switch</code> block cases that fall through to the next case.</html>"));
1244:                panel.displayComponents();
1245:
1246:            }
1247:
1248:            /** Private class to handle rendering of tree nodes, each of which
1249:             *  corresponds to a ConfigPanel.  These nodes should only be accessed
1250:             *  from the event handling thread.
1251:             */
1252:            private class PanelTreeNode extends DefaultMutableTreeNode {
1253:
1254:                private final ConfigPanel _panel;
1255:
1256:                public PanelTreeNode(String t) {
1257:                    super (t);
1258:                    _panel = new ConfigPanel(t);
1259:                }
1260:
1261:                public PanelTreeNode(ConfigPanel c) {
1262:                    super (c.getTitle());
1263:                    _panel = c;
1264:                }
1265:
1266:                private ConfigPanel getPanel() {
1267:                    return _panel;
1268:                }
1269:
1270:                /** Tells its panel to update, and tells all of its child nodes to update their panels.
1271:                 *  @return whether the update succeeded.
1272:                 */
1273:                private boolean update() {
1274:
1275:                    boolean isValidUpdate = _panel.update();
1276:
1277:                    //if this panel encountered an error while attempting to update, return false
1278:                    if (!isValidUpdate) {
1279:                        //System.out.println("Panel.update() returned false");
1280:
1281:                        //TreePath path = new TreePath(this.getPath());
1282:                        // causes ClassCastException under jsr14 v2.0 for no apparent reason.
1283:                        // Workaround:  store result of getPath() to temporary array.
1284:
1285:                        TreeNode[] nodes = getPath();
1286:                        TreePath path = new TreePath(nodes);
1287:                        _tree.expandPath(path);
1288:                        _tree.setSelectionPath(path);
1289:                        return false;
1290:                    }
1291:
1292:                    Enumeration childNodes = children();
1293:                    while (childNodes.hasMoreElements()) {
1294:                        boolean isValidUpdateChildren = ((PanelTreeNode) childNodes
1295:                                .nextElement()).update();
1296:                        //if any of the children nodes encountered an error, return false
1297:                        if (!isValidUpdateChildren) {
1298:                            return false;
1299:                        }
1300:                    }
1301:
1302:                    return true;
1303:                }
1304:
1305:                /**
1306:                 * Tells its panel to reset its displayed value to the currently set value
1307:                 * for this component, and tells all of its children to reset their panels.
1308:                 */
1309:                public void resetToCurrent() {
1310:                    _panel.resetToCurrent();
1311:
1312:                    Enumeration childNodes = this .children();
1313:                    while (childNodes.hasMoreElements()) {
1314:                        ((PanelTreeNode) childNodes.nextElement())
1315:                                .resetToCurrent();
1316:                    }
1317:                }
1318:            }
1319:
1320:            private class PanelTreeSelectionListener implements 
1321:                    TreeSelectionListener {
1322:                public void valueChanged(TreeSelectionEvent e) {
1323:                    Object o = _tree.getLastSelectedPathComponent();
1324:                    //System.out.println("Object o : "+o);
1325:                    if (o instanceof  PanelTreeNode) {
1326:                        //System.out.println("o is instanceof PanelTreeNode");
1327:                        PanelTreeNode child = (PanelTreeNode) _tree
1328:                                .getLastSelectedPathComponent();
1329:                        _displayPanel(child.getPanel());
1330:                    }
1331:                }
1332:            }
1333:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.