Source Code Cross Referenced for JSOptionDialog.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:        /*
002:         *  JSOptionDialog.java - options dialog for JavaStyle option panes
003:         *  Copyright (C) 2001 Dirk Moebius
004:         *
005:         *  jEdit buffer options:
006:         *  :tabSize=4:indentSize=4:noTabs=false:maxLineLen=0:
007:         *
008:         *  This program is free software; you can redistribute it and/or
009:         *  modify it under the terms of the GNU General Public License
010:         *  as published by the Free Software Foundation; either version 2
011:         *  of the License, or any later version.
012:         *
013:         *  This program is distributed in the hope that it will be useful,
014:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         *  GNU General Public License for more details.
017:         *
018:         *  You should have received a copy of the GNU General Public License
019:         *  along with this program; if not, write to the Free Software
020:         *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021:         */
022:        package org.acm.seguin.ide.common.options;
023:
024:        import java.awt.BorderLayout;
025:        import java.awt.event.ActionEvent;
026:        import java.awt.event.ActionListener;
027:
028:        import javax.swing.Box;
029:        import javax.swing.BoxLayout;
030:        import javax.swing.JButton;
031:        import javax.swing.JPanel;
032:        import javax.swing.JTabbedPane;
033:        import javax.swing.JDialog;
034:        import javax.swing.border.EmptyBorder;
035:        import javax.swing.JComboBox;
036:        import java.awt.event.ContainerAdapter;
037:        import java.awt.event.ContainerEvent;
038:        import java.awt.event.KeyAdapter;
039:        import java.awt.event.KeyEvent;
040:        import java.awt.event.WindowAdapter;
041:        import java.awt.event.WindowEvent;
042:        import java.awt.Component;
043:        import java.awt.Container;
044:        import java.awt.Frame;
045:
046:        import org.acm.seguin.ide.common.IDEPlugin;
047:
048:        /**
049:         *  An option dialog for JavaStyle options.
050:         *
051:         *@author     Mike Atkinson (<a href="mailto:javastyle@ladyshot.demon.co.uk">
052:         *      Mike@ladyshot.demon.co.uk</a> )
053:         *@author     Dirk Moebius (<a href="mailto:dmoebius@gmx.net">dmoebius@gmx.net
054:         *      </a>)
055:         *@created    04 September 2003
056:         *@version    $Version: $
057:         *@since      1.0
058:         */
059:        public class JSOptionDialog extends JDialog implements  ActionListener {
060:            private JButton apply;
061:            private JButton cancel;
062:
063:            private JButton ok;
064:            private JSHelpOptionPane[][] optionPanes;
065:            private String[] projects = new String[] { "default" };
066:
067:            //{{{ Private members
068:
069:            private void _init() {
070:                ((Container) getLayeredPane())
071:                        .addContainerListener(new ContainerHandler());
072:                getContentPane().addContainerListener(new ContainerHandler());
073:
074:                keyHandler = new KeyHandler();
075:                addKeyListener(keyHandler);
076:                addWindowListener(new WindowHandler());
077:
078:                setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
079:            }
080:
081:            //}}}
082:
083:            // protected members
084:            protected KeyHandler keyHandler;
085:
086:            // Recursively adds our key listener to sub-components
087:            class ContainerHandler extends ContainerAdapter {
088:                public void componentAdded(ContainerEvent evt) {
089:                    componentAdded(evt.getChild());
090:                }
091:
092:                public void componentRemoved(ContainerEvent evt) {
093:                    componentRemoved(evt.getChild());
094:                }
095:
096:                private void componentAdded(Component comp) {
097:                    comp.addKeyListener(keyHandler);
098:                    if (comp instanceof  Container) {
099:                        Container cont = (Container) comp;
100:                        cont.addContainerListener(this );
101:                        Component[] comps = cont.getComponents();
102:                        for (int i = 0; i < comps.length; i++) {
103:                            componentAdded(comps[i]);
104:                        }
105:                    }
106:                }
107:
108:                private void componentRemoved(Component comp) {
109:                    comp.removeKeyListener(keyHandler);
110:                    if (comp instanceof  Container) {
111:                        Container cont = (Container) comp;
112:                        cont.removeContainerListener(this );
113:                        Component[] comps = cont.getComponents();
114:                        for (int i = 0; i < comps.length; i++) {
115:                            componentRemoved(comps[i]);
116:                        }
117:                    }
118:                }
119:            }
120:
121:            class KeyHandler extends KeyAdapter {
122:                public void keyPressed(KeyEvent evt) {
123:                    if (evt.isConsumed())
124:                        return;
125:
126:                    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
127:                        // crusty workaround
128:                        Component comp = getFocusOwner();
129:                        while (comp != null) {
130:                            if (comp instanceof  JComboBox) {
131:                                JComboBox combo = (JComboBox) comp;
132:                                if (combo.isEditable()) {
133:                                    Object selected = combo.getEditor()
134:                                            .getItem();
135:                                    if (selected != null)
136:                                        combo.setSelectedItem(selected);
137:                                }
138:                                break;
139:                            }
140:
141:                            comp = comp.getParent();
142:                        }
143:
144:                        ok();
145:                        evt.consume();
146:                    } else if (evt.getKeyCode() == KeyEvent.VK_ESCAPE) {
147:                        cancel();
148:                        evt.consume();
149:                    }
150:                }
151:            }
152:
153:            class WindowHandler extends WindowAdapter {
154:                public void windowClosing(WindowEvent evt) {
155:                    cancel();
156:                }
157:            }
158:
159:            /**
160:             *  Constructor for the JSOptionDialog object
161:             *
162:             *@param  view  Description of Parameter
163:             */
164:            public JSOptionDialog(Frame parent) {
165:                super (parent, IDEPlugin.getProperty("options.javastyle.label"),
166:                        true);
167:                _init();
168:                projects = IDEPlugin.getProjects(parent);
169:
170:                IDEPlugin.showWaitCursor(parent);
171:
172:                JPanel content = new JPanel(new BorderLayout());
173:                content.setBorder(new EmptyBorder(5, 8, 8, 8));
174:                content.setLayout(new BorderLayout());
175:                setContentPane(content);
176:
177:                optionPanes = new JSHelpOptionPane[projects.length][];
178:
179:                JTabbedPane mainstage = new JTabbedPane(
180:                        ((projects.length <= 1) ? JTabbedPane.LEFT
181:                                : JTabbedPane.TOP));
182:                for (int proj = 0; proj < projects.length; proj++) {
183:                    optionPanes[proj] = new JSHelpOptionPane[] {
184:                            new JSGeneralOptionPane(projects[proj]),
185:                            new JSIndentOptionPane(projects[proj]),
186:                            new JSSpacingOptionPane(projects[proj]),
187:                            new JSAlignmentOptionPane(projects[proj]),
188:                            new JSSortOptionPane(projects[proj]),
189:                            new JSJavadocOptionPane(projects[proj]),
190:                            new JSStubsOptionPane(projects[proj]),
191:                            new JSStubs2OptionPane(projects[proj]),
192:                            new JSStubsJUnitOptionPane(projects[proj]),
193:                            new JSTagsOptionPane(projects[proj]),
194:                            new JSCommentOptionPane(projects[proj]),
195:                            new PMDOptionPane(projects[proj]),
196:                            new NavigatorOptionPane(projects[proj]), };
197:
198:                    JTabbedPane stage = new JTabbedPane(JTabbedPane.LEFT);
199:                    for (int i = 0; i < optionPanes[proj].length; ++i) {
200:                        optionPanes[proj][i].setBorder(new EmptyBorder(12, 12,
201:                                12, 12));
202:                        optionPanes[proj][i].init();
203:                        if (projects.length <= 1) {
204:                            mainstage.addTab(IDEPlugin
205:                                    .getProperty("options."
206:                                            + optionPanes[proj][i].getName()
207:                                            + ".label"), optionPanes[proj][i]);
208:                        } else {
209:                            stage.addTab(IDEPlugin
210:                                    .getProperty("options."
211:                                            + optionPanes[proj][i].getName()
212:                                            + ".label"), optionPanes[proj][i]);
213:                        }
214:                    }
215:                    if (projects.length > 1) {
216:                        mainstage.addTab(projects[proj], stage);
217:                    }
218:                }
219:                content.add(mainstage, BorderLayout.CENTER);
220:
221:                JPanel buttons = new JPanel();
222:                buttons.setBorder(new EmptyBorder(12, 0, 0, 0));
223:                buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
224:                buttons.add(Box.createGlue());
225:
226:                ok = new JButton(IDEPlugin.getProperty("common.ok"));
227:                ok.addActionListener(this );
228:                buttons.add(ok);
229:                buttons.add(Box.createHorizontalStrut(6));
230:                getRootPane().setDefaultButton(ok);
231:
232:                cancel = new JButton(IDEPlugin.getProperty("common.cancel"));
233:                cancel.addActionListener(this );
234:                buttons.add(cancel);
235:                buttons.add(Box.createHorizontalStrut(6));
236:
237:                apply = new JButton(IDEPlugin.getProperty("common.apply"));
238:                apply.addActionListener(this );
239:                buttons.add(apply);
240:
241:                buttons.add(Box.createGlue());
242:
243:                content.add(buttons, BorderLayout.SOUTH);
244:
245:                IDEPlugin.hideWaitCursor(parent);
246:                pack();
247:                setLocationRelativeTo(parent);
248:                show();
249:            }
250:
251:            /**
252:             *  Description of the Method
253:             *
254:             *@param  evt  Description of Parameter
255:             */
256:            public void actionPerformed(ActionEvent evt) {
257:                Object source = evt.getSource();
258:
259:                if (source == ok) {
260:                    ok();
261:                } else if (source == cancel) {
262:                    cancel();
263:                } else if (source == apply) {
264:                    ok(false);
265:                }
266:            }
267:
268:            /**
269:             *  Description of the Method
270:             */
271:            public void cancel() {
272:                dispose();
273:            }
274:
275:            /**
276:             *  Description of the Method
277:             */
278:            public void ok() {
279:                ok(true);
280:            }
281:
282:            /**
283:             *  Description of the Method
284:             *
285:             *@param  dispose  Description of Parameter
286:             */
287:            public void ok(final boolean dispose) {
288:                for (int proj = 0; proj < optionPanes.length; ++proj) {
289:                    for (int i = 0; i < optionPanes[proj].length; ++i) {
290:                        optionPanes[proj][i].save();
291:                    }
292:                }
293:
294:                IDEPlugin.saveProperties();
295:
296:                // get rid of this dialog if necessary
297:                if (dispose) {
298:                    dispose();
299:                }
300:            }
301:
302:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.