Source Code Cross Referenced for FindDialog.java in  » Testing » jacareto » jacareto » cleverphl » gui » 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 » Testing » jacareto » jacareto.cleverphl.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Jacareto Copyright (c) 2002-2005
003:         * Applied Computer Science Research Group, Darmstadt University of
004:         * Technology, Institute of Mathematics & Computer Science,
005:         * Ludwigsburg University of Education, and Computer Based
006:         * Learning Research Group, Aachen University. All rights reserved.
007:         *
008:         * Jacareto is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public
010:         * License as published by the Free Software Foundation; either
011:         * version 2 of the License, or (at your option) any later version.
012:         *
013:         * Jacareto 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 GNU
016:         * General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public
019:         * License along with Jacareto; if not, write to the Free
020:         * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021:         *
022:         */
023:
024:        package jacareto.cleverphl.gui;
025:
026:        import com.jgoodies.forms.builder.PanelBuilder;
027:        import com.jgoodies.forms.layout.CellConstraints;
028:        import com.jgoodies.forms.layout.FormLayout;
029:
030:        import jacareto.cleverphl.CleverPHL;
031:        import jacareto.system.Language;
032:
033:        import org.apache.regexp.RE;
034:        import org.apache.regexp.RESyntaxException;
035:
036:        import java.awt.BorderLayout;
037:        import java.awt.FlowLayout;
038:        import java.awt.Point;
039:        import java.awt.event.ActionEvent;
040:        import java.awt.event.ActionListener;
041:
042:        import javax.swing.ButtonGroup;
043:        import javax.swing.JButton;
044:        import javax.swing.JCheckBox;
045:        import javax.swing.JComponent;
046:        import javax.swing.JDialog;
047:        import javax.swing.JPanel;
048:        import javax.swing.JRadioButton;
049:        import javax.swing.JTextField;
050:
051:        /**
052:         * Dialog for the search.
053:         *
054:         * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
055:         * @version 1.0
056:         */
057:        public class FindDialog extends JDialog implements  ActionListener {
058:            public static final int SCOPE_ACTUAL_SESSION = 0;
059:            public static final int SCOPE_ALL_SESSIONS = 1;
060:
061:            /** The CleverPHL instance. */
062:            private CleverPHL cleverPHL;
063:
064:            /** The regular expression field. */
065:            private JTextField findwhatField;
066:
067:            /** The button testing the regexp */
068:            private JButton regexpTestButton;
069:            private JCheckBox regexpCheckBox;
070:
071:            /** JRadiobuttons for the scope. */
072:            private JRadioButton scopeActualSessionButton;
073:            private JRadioButton scopeAllSessionsButton;
074:
075:            /** The buttons. */
076:            private JButton okButton;
077:
078:            /** The buttons. */
079:            private JButton cancelButton;
080:
081:            /** The results. */
082:            private boolean okButtonPressed;
083:            private String searchString;
084:            private boolean isRegExp;
085:            private int scope;
086:
087:            /**
088:             * Creates a new dialog (visible).
089:             *
090:             * @param cleverPHL the CleverPHL instance
091:             */
092:            public FindDialog(CleverPHL cleverPHL) {
093:                super (cleverPHL.getMainFrame(), true);
094:                this .cleverPHL = cleverPHL;
095:                setName(cleverPHL.getCustomization().getString(
096:                        "Components.JacaretoComponent", "JACARETO_COMPONENT"));
097:
098:                Language language = cleverPHL.getLanguage();
099:
100:                //setLocationRelativeTo ( cleverPHL.getMainFrame() );
101:                setTitle(language.getString("CleverPHL.FindDialog.Title"));
102:
103:                okButton = new JButton(language.getString("General.Ok"));
104:                cancelButton = new JButton(language.getString("General.Cancel"));
105:                okButton.addActionListener(this );
106:                cancelButton.addActionListener(this );
107:
108:                JPanel buttonPanel = new JPanel(new FlowLayout(
109:                        FlowLayout.CENTER));
110:                buttonPanel.add(okButton);
111:                buttonPanel.add(cancelButton);
112:
113:                getContentPane().setLayout(new BorderLayout());
114:                getContentPane().add(getSearchPanel(), BorderLayout.NORTH);
115:                getContentPane().add(buttonPanel, BorderLayout.CENTER);
116:
117:                Point ownerLoc = cleverPHL.getMainFrame().getLocation();
118:                setLocation(((int) ownerLoc.getX()) + 30, ((int) ownerLoc
119:                        .getY()) + 30);
120:
121:                pack();
122:                setResizable(false);
123:                setVisible(true);
124:            }
125:
126:            /**
127:             * Returns the main panel of the dialog.
128:             *
129:             * @return the component
130:             */
131:            private JComponent getSearchPanel() {
132:                FormLayout layout = new FormLayout("10dlu,p,3dlu,left:p",
133:                        "p,3dlu,p,3dlu,p,7dlu,p,3dlu,p,3dlu,p");
134:                PanelBuilder builder = new PanelBuilder(layout);
135:                builder.setDefaultDialogBorder();
136:
137:                CellConstraints cc = new CellConstraints();
138:
139:                findwhatField = new JTextField(20);
140:                regexpTestButton = new JButton(this .cleverPHL.getLanguage()
141:                        .getString("CleverPHL.FindDialog.Test"));
142:                regexpTestButton.addActionListener(this );
143:                regexpCheckBox = new JCheckBox(this .cleverPHL.getLanguage()
144:                        .getString("CleverPHL.FindDialog.RegularExpression"));
145:
146:                regexpTestButton.setEnabled(regexpCheckBox.isSelected());
147:                regexpCheckBox.addActionListener(new ActionListener() {
148:                    public void actionPerformed(ActionEvent event) {
149:                        regexpTestButton
150:                                .setEnabled(regexpCheckBox.isSelected());
151:                    }
152:                });
153:
154:                scopeActualSessionButton = new JRadioButton(this .cleverPHL
155:                        .getLanguage().getString(
156:                                "CleverPHL.FindDialog.ScopeActualSession"));
157:                scopeAllSessionsButton = new JRadioButton(this .cleverPHL
158:                        .getLanguage().getString(
159:                                "CleverPHL.FindDialog.ScopeAllSessions"));
160:                scopeActualSessionButton.setSelected(true);
161:
162:                ButtonGroup scopeGroup = new ButtonGroup();
163:                scopeGroup.add(scopeActualSessionButton);
164:                scopeGroup.add(scopeAllSessionsButton);
165:
166:                builder.addSeparator(this .cleverPHL.getLanguage().getString(
167:                        "CleverPHL.FindDialog.Search"), cc.xyw(1, 1, 4));
168:                builder.addLabel(this .cleverPHL.getLanguage().getString(
169:                        "CleverPHL.FindDialog.FindWhat")
170:                        + " :", cc.xy(2, 3));
171:                builder.add(findwhatField, cc.xy(4, 3));
172:                builder.add(regexpCheckBox, cc.xy(2, 5));
173:                builder.add(regexpTestButton, cc.xy(4, 5));
174:
175:                builder.addSeparator(this .cleverPHL.getLanguage().getString(
176:                        "CleverPHL.FindDialog.Scope"), cc.xyw(1, 7, 4));
177:                builder.add(scopeActualSessionButton, cc.xy(2, 9));
178:                builder.add(scopeAllSessionsButton, cc.xy(2, 11));
179:
180:                JPanel panel = builder.getPanel();
181:
182:                return panel;
183:            }
184:
185:            /**
186:             * Called when a button has been pressed.
187:             *
188:             * @param event DOCUMENT ME!
189:             */
190:            public void actionPerformed(ActionEvent event) {
191:                if (event.getSource() == regexpTestButton) {
192:                    testRegEx();
193:                } else {
194:                    if (event.getSource() == okButton) {
195:                        okButtonPressed = true;
196:                    } else {
197:                        okButtonPressed = false;
198:                    }
199:
200:                    searchString = findwhatField.getText();
201:                    isRegExp = regexpCheckBox.isSelected();
202:
203:                    if (scopeActualSessionButton.isSelected()) {
204:                        scope = SCOPE_ACTUAL_SESSION;
205:                    } else if (scopeAllSessionsButton.isSelected()) {
206:                        scope = SCOPE_ALL_SESSIONS;
207:                    }
208:
209:                    dispose();
210:                }
211:            }
212:
213:            /**
214:             * Tests the regular expression.
215:             */
216:            private void testRegEx() {
217:                try {
218:                    RE re = new RE(findwhatField.getText());
219:                } catch (RESyntaxException res) {
220:                    cleverPHL
221:                            .getLogger()
222:                            .info(
223:                                    cleverPHL
224:                                            .getLanguage()
225:                                            .getString(
226:                                                    "CleverPHL.FindDialog.SyntaxCheck.NotCorrect"),
227:                                    res);
228:
229:                    return;
230:                }
231:
232:                cleverPHL.getLogger().info(
233:                        cleverPHL.getLanguage().getString(
234:                                "CleverPHL.FindDialog.SyntaxCheck.Correct"));
235:            }
236:
237:            /**
238:             * Returns whether or not the ok button has been pressed.
239:             *
240:             * @return <code>true</code> if the ok button has been pressed, otherwise <code>false</code>
241:             */
242:            public boolean okButtonPressed() {
243:                return okButtonPressed;
244:            }
245:
246:            /**
247:             * Returns the search string.
248:             *
249:             * @return the string
250:             */
251:            public String getSearchString() {
252:                return searchString;
253:            }
254:
255:            /**
256:             * Returns whether or not the search string is a regular expression.
257:             *
258:             * @return <code>true</code> if the search string is a regular expression, otherwise
259:             *         <code>false</code>
260:             */
261:            public boolean isRegExp() {
262:                return isRegExp;
263:            }
264:
265:            /**
266:             * Returns the scope of the search.
267:             *
268:             * @return the scope.
269:             */
270:            public int getScope() {
271:                return scope;
272:            }
273:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.