Source Code Cross Referenced for PMDOptionPane.java in  » UML » jrefactory » org » acm » seguin » ide » common » options » 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 » UML » jrefactory » org.acm.seguin.ide.common.options 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.acm.seguin.ide.common.options;
002:
003:        import org.acm.seguin.pmd.RuleSetNotFoundException;
004:        import org.acm.seguin.pmd.Rule;
005:
006:        import javax.swing.BorderFactory;
007:        import javax.swing.JCheckBox;
008:        import javax.swing.JLabel;
009:        import javax.swing.JList;
010:        import javax.swing.JPanel;
011:        import javax.swing.JLabel;
012:        import javax.swing.JScrollPane;
013:        import javax.swing.JTextArea;
014:        import javax.swing.JTextField;
015:        import javax.swing.ListCellRenderer;
016:        import javax.swing.ListSelectionModel;
017:        import javax.swing.UIManager;
018:        import javax.swing.border.EmptyBorder;
019:        import java.awt.BorderLayout;
020:        import java.awt.Component;
021:        import java.awt.FlowLayout;
022:        import java.awt.GridLayout;
023:        import java.awt.event.MouseAdapter;
024:        import java.awt.event.MouseEvent;
025:
026:        /**
027:         *    Description of the Class
028:         *
029:         * @author      Mike Atkinson
030:         */
031:        public class PMDOptionPane extends JSHelpOptionPane {
032:            JTextField txtMinTileSize;
033:            JTextField txtCustomRules;
034:            private SelectedPanel pnlCustomRules_sp;
035:            private SelectedPanel directoryPopupBox_sp;
036:            private SelectedPanel txtMinTileSize_sp;
037:
038:            private SelectedRules rules;
039:            private JTextArea exampleTextArea = new JTextArea(10, 80);
040:            private JCheckBox directoryPopupBox;
041:
042:            /**
043:             *    Constructor for the PMDOptionPane object
044:             *
045:             * @param    project  Description of Parameter
046:             */
047:            public PMDOptionPane(String project) {
048:                super ("javastyle.pmd", "pmd", project);
049:                try {
050:                    rules = new SelectedRules(((project == null) ? "default"
051:                            : project), this );
052:                } catch (RuleSetNotFoundException rsne) {
053:                    rsne.printStackTrace();
054:                }
055:            }
056:
057:            /**    Description of the Method */
058:            public void _init() {
059:                removeAll();
060:
061:                addComponent(new JLabel(
062:                        getIdeProperty("javastyle.pmd.more.info")));
063:
064:                JPanel rulesPanel = new JPanel(new BorderLayout());
065:                rulesPanel
066:                        .setBorder(BorderFactory
067:                                .createTitledBorder(getIdeProperty("javastyle.pmd.rules")));
068:
069:                JList list = new CheckboxList(rules.getAllBoxes());
070:                list
071:                        .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
072:                rulesPanel.add(new JScrollPane(list), BorderLayout.NORTH);
073:
074:                //Custom Rule Panel Defination.
075:                txtCustomRules = new JTextField(props.getString(
076:                        "pmd.customRulesPath", ""), 30);
077:
078:                directoryPopupBox = new JCheckBox("Ask for directory?", props
079:                        .getBoolean("pmd.ui.directorypopup", false));
080:
081:                JLabel lblMinTileSize = new JLabel("Minimum Tile Size :");
082:                txtMinTileSize = new JTextField(props.getString(
083:                        "pmd.cpd.defMinTileSize", "100"), 5);
084:
085:                addComponent(null, null, rulesPanel);
086:
087:                JPanel textPanel = new JPanel();
088:                exampleTextArea.setEditable(false);
089:                exampleTextArea.setLineWrap(true);
090:                exampleTextArea.setWrapStyleWord(true);
091:                textPanel
092:                        .setBorder(BorderFactory
093:                                .createTitledBorder(getIdeProperty("javastyle.pmd.example")));
094:                textPanel.add(new JScrollPane(exampleTextArea));
095:                addComponent(null, null, textPanel);
096:
097:                addComponent(new JLabel(""));
098:                addComponent(new JLabel(
099:                        getIdeJavaStyleOption("pmd.customRulesPath")));
100:                pnlCustomRules_sp = addComponent("pmd.path", null,
101:                        txtCustomRules);
102:                directoryPopupBox_sp = addComponent("pmd.ask.for.directory",
103:                        "ui.directorypopup", new JCheckBox());
104:                addComponent(new JLabel(
105:                        getIdeJavaStyleOption("cpd.defMinTileSize")));
106:                txtMinTileSize_sp = addComponent("pmd.min.tile.size", null,
107:                        txtMinTileSize);
108:
109:                addHelpArea();
110:            }
111:
112:            /**    Description of the Method */
113:            public void _save() {
114:                rules.save();
115:                pnlCustomRules_sp.save();
116:                directoryPopupBox_sp.save();
117:                txtMinTileSize_sp.save();
118:            }
119:
120:            /**
121:             *    Description of the Class
122:             *
123:             * @author      Chris Seguin
124:             */
125:            public class CheckboxList extends JList {
126:
127:                /**
128:                 *    Constructor for the CheckboxList object
129:                 *
130:                 * @param    args  Description of Parameter
131:                 * @paramargs      Description of Parameter
132:                 * @paramargs      Description of Parameter
133:                 * @paramargs      Description of Parameter
134:                 */
135:                public CheckboxList(Object[] args) {
136:                    super (args);
137:                    setCellRenderer(new CheckboxListCellRenderer());
138:                    addMouseListener(new MyMouseAdapter());
139:                }
140:
141:                /**
142:                 *    Description of the Class
143:                 *
144:                 * @author      Chris Seguin
145:                 */
146:                public class CheckboxListCellRenderer implements 
147:                        ListCellRenderer {
148:                    /**
149:                     *    Gets the ListCellRendererComponent attribute of the
150:                     *    CheckboxListCellRenderer object
151:                     *
152:                     * @param    list          Description of Parameter
153:                     * @param    value         Description of Parameter
154:                     * @param    index         Description of Parameter
155:                     * @param    isSelected    Description of Parameter
156:                     * @param    cellHasFocus  Description of Parameter
157:                     * @return                 The ListCellRendererComponent
158:                     *      value
159:                     */
160:                    public Component getListCellRendererComponent(JList list,
161:                            Object value, int index, boolean isSelected,
162:                            boolean cellHasFocus) {
163:                        JCheckBox box = (JCheckBox) value;
164:
165:                        box.setEnabled(isEnabled());
166:                        box.setFont(getFont());
167:                        box.setFocusPainted(false);
168:                        box.setBorderPainted(true);
169:                        box.setBorder(isSelected ? UIManager
170:                                .getBorder("List.focusCellHighlightBorder")
171:                                : new EmptyBorder(1, 1, 1, 1));
172:                        return box;
173:                    }
174:                }
175:
176:                /**
177:                 *    Description of the Class
178:                 *
179:                 * @author      Chris Seguin
180:                 */
181:                private class MyMouseAdapter extends MouseAdapter {
182:                    String previousExample = "";
183:                    private java.awt.event.MouseMotionAdapter mmma = new java.awt.event.MouseMotionAdapter() {
184:                        public void mouseMoved(MouseEvent e) {
185:                            handleMouseEvent(e);
186:                        }
187:                    };
188:
189:                    /**
190:                     *    Description of the Method
191:                     *
192:                     * @param    e  Description of Parameter
193:                     */
194:                    public void Exited(MouseEvent e) {
195:                        removeMouseMotionListener(mmma);
196:                    }
197:
198:                    /**
199:                     *    Description of the Method
200:                     *
201:                     * @param    e  Description of Parameter
202:                     */
203:                    public void mouseEntered(MouseEvent e) {
204:                        handleMouseEvent(e);
205:                        addMouseMotionListener(mmma);
206:                    }
207:
208:                    /**
209:                     *    Description of the Method
210:                     *
211:                     * @param    e  Description of Parameter
212:                     */
213:                    public void mousePressed(MouseEvent e) {
214:                        int index = locationToIndex(e.getPoint());
215:
216:                        if (index != -1) {
217:                            JCheckBox box = (JCheckBox) getModel()
218:                                    .getElementAt(index);
219:
220:                            box.setSelected(!box.isSelected());
221:                            repaint();
222:                        }
223:                    }
224:
225:                    private void handleMouseEvent(MouseEvent e) {
226:                        int index = locationToIndex(e.getPoint());
227:                        if (index != -1) {
228:                            JCheckBox box = (JCheckBox) getModel()
229:                                    .getElementAt(index);
230:                            Rule rule = rules.getRule(box);
231:                            String example = rule.getExample().trim();
232:                            if (example.startsWith("\r")) {
233:                                example = example.substring(1);
234:                            }
235:                            if (example.startsWith("\n")) {
236:                                example = example.substring(1);
237:                            }
238:                            if (previousExample == null
239:                                    || !previousExample.equals(example)) {
240:                                previousExample = example;
241:                                exampleTextArea.setText(example);
242:                                exampleTextArea.setCaretPosition(0);
243:                                String description = rule.getDescription()
244:                                        .trim();
245:                                char prev = ' ';
246:                                StringBuffer sb = new StringBuffer();
247:                                for (int i = 0; i < description.length(); i++) {
248:                                    char c = description.charAt(i);
249:                                    if (c == '\n') {
250:                                        c = ' ';
251:                                    }
252:                                    if (c == '\r') {
253:                                        c = ' ';
254:                                    }
255:                                    if (!(c == ' ' && c == prev)) {
256:                                        prev = c;
257:                                        sb.append(c);
258:                                    }
259:                                }
260:                                setHelpText(sb.toString());
261:                            }
262:                        }
263:                    }
264:                }
265:
266:            }
267:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.