Source Code Cross Referenced for ReadDialog.java in  » Testing » KeY » de » uka » ilkd » key » ocl » gf » 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 » KeY » de.uka.ilkd.key.ocl.gf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //Copyright (c) Janna Khegai 2004, Hans-Joachim Daniels 2005
002:        //
003:        //This program is free software; you can redistribute it and/or modify
004:        //it under the terms of the GNU General Public License as published by
005:        //the Free Software Foundation; either version 2 of the License, or
006:        //(at your option) any later version.
007:        //
008:        //This program is distributed in the hope that it will be useful,
009:        //but WITHOUT ANY WARRANTY; without even the implied warranty of
010:        //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
011:        //GNU General Public License for more details.
012:        //
013:        //You can either finde the file LICENSE or LICENSE.TXT in the source 
014:        //distribution or in the .jar file of this application
015:
016:        package de.uka.ilkd.key.ocl.gf;
017:
018:        import java.awt.BorderLayout;
019:        import java.awt.Dimension;
020:        import java.awt.Font;
021:        import java.awt.GridLayout;
022:        import java.awt.event.ActionEvent;
023:        import java.awt.event.ActionListener;
024:        import java.io.File;
025:        import java.util.logging.Level;
026:        import java.util.logging.Logger;
027:
028:        import javax.swing.*;
029:
030:        /**
031:         * Takes care of reading in Strings that are to be parsed and terms.
032:         * @author daniels
033:         *
034:         */
035:        class ReadDialog implements  ActionListener {
036:            /** XML parsing debug messages  */
037:            private static Logger xmlLogger = Logger.getLogger(GFEditor2.class
038:                    .getName()
039:                    + "_XML");
040:            /** The window to which this class belongs */
041:            private final GFEditor2 owner;
042:            /** is the main thing of this class */
043:            private final JDialog readDialog;
044:            /** main area of the Read dialog (content pane)*/
045:            private final JPanel inputPanel = new JPanel();
046:            /** OK, Cancel, Browse in the Read dialog */
047:            private final JPanel inputPanel2 = new JPanel();
048:            /** in the Read dialog the OK button */
049:            private final JButton ok = new JButton("OK");
050:            /** in the Read dialog the Cancel button */
051:            private final JButton cancel = new JButton("Cancel");
052:            /** in the Read dialog the Browse button */
053:            private final JButton browse = new JButton("Browse...");
054:            /** groups inputField and inputLabel */
055:            private final JPanel inputPanel3 = new JPanel();
056:            /** for 'Read' to get the input */
057:            private final JTextField inputField = new JTextField();
058:            /** "Read: " */
059:            private final JLabel inputLabel = new JLabel("Read: ");
060:            /** the radio group in the Read dialog to select Term or String */
061:            private final ButtonGroup readGroup = new ButtonGroup();
062:            /** to select to input a Term in the Read dialog */
063:            private final JRadioButton termReadButton = new JRadioButton("Term");
064:            /** to select to input a String in the Read dialog */
065:            private final JRadioButton stringReadButton = new JRadioButton(
066:                    "String");
067:            /** used for new Topic, Import and Browse (readDialog) */
068:            private final JFileChooser fc = new JFileChooser("./");
069:            /**
070:             * if a user sends a custom command to GF, he might want to do this 
071:             * again with the same command.
072:             * Therefore it is saved.
073:             */
074:            private String parseInput = "";
075:            /**
076:             * if the user enters a term, he perhaps wants to input the same text again.
077:             * Therefore it is saved.
078:             */
079:            private String termInput = "";
080:
081:            /**
082:             * creates a modal dialog
083:             * @param owner The parent for which this dialog shall be modal.
084:             */
085:            protected ReadDialog(GFEditor2 owner) {
086:                this .owner = owner;
087:                readDialog = new JDialog(owner, "Input", true);
088:                readDialog.setLocationRelativeTo(owner);
089:                readDialog.getContentPane().add(inputPanel);
090:                readDialog.setSize(480, 135);
091:
092:                termReadButton.setActionCommand("term");
093:                stringReadButton.setSelected(true);
094:                stringReadButton.setActionCommand("lin");
095:                // Group the radio buttons.
096:                readGroup.add(stringReadButton);
097:                readGroup.add(termReadButton);
098:                JPanel readButtonPanel = new JPanel();
099:                readButtonPanel.setLayout(new GridLayout(3, 1));
100:                readButtonPanel.setPreferredSize(new Dimension(70, 70));
101:                readButtonPanel.add(new JLabel("Format:"));
102:                readButtonPanel.add(stringReadButton);
103:                readButtonPanel.add(termReadButton);
104:                inputPanel.setLayout(new BorderLayout(10, 10));
105:                inputPanel3.setLayout(new GridLayout(2, 1, 5, 5));
106:                inputPanel3.add(inputLabel);
107:                inputPanel3.add(inputField);
108:                ok.addActionListener(this );
109:                browse.addActionListener(this );
110:                cancel.addActionListener(this );
111:                inputField.setPreferredSize(new Dimension(300, 23));
112:                inputPanel.add(inputPanel3, BorderLayout.CENTER);
113:                inputPanel.add(new JLabel(" "), BorderLayout.WEST);
114:                inputPanel.add(readButtonPanel, BorderLayout.EAST);
115:                inputPanel.add(inputPanel2, BorderLayout.SOUTH);
116:                inputPanel2.add(ok);
117:                inputPanel2.add(cancel);
118:                inputPanel2.add(browse);
119:            }
120:
121:            /**
122:             * Shows this modal dialog.
123:             * The previous input text will be there again.
124:             *
125:             */
126:            protected void show() {
127:                if (stringReadButton.isSelected()) {
128:                    inputField.setText(this .parseInput);
129:                } else {
130:                    inputField.setText(this .termInput);
131:                }
132:                this .readDialog.setVisible(true);
133:            }
134:
135:            /**
136:             * Sets the font of all GUI elements to font
137:             * @param font
138:             */
139:            protected void setFont(Font font) {
140:                ok.setFont(font);
141:                cancel.setFont(font);
142:                inputLabel.setFont(font);
143:                browse.setFont(font);
144:                termReadButton.setFont(font);
145:                stringReadButton.setFont(font);
146:            }
147:
148:            /**
149:             * the ActionListener method that does the user interaction
150:             */
151:            public void actionPerformed(ActionEvent ae) {
152:                Object obj = ae.getSource();
153:
154:                if (obj == cancel) {
155:                    readDialog.setVisible(false);
156:                }
157:
158:                if (obj == browse) {
159:                    if (fc.getChoosableFileFilters().length < 2)
160:                        fc.addChoosableFileFilter(new GrammarFilter());
161:                    int returnVal = fc.showOpenDialog(owner);
162:                    if (returnVal == JFileChooser.APPROVE_OPTION) {
163:                        File file = fc.getSelectedFile();
164:                        inputField.setText(file.getPath().replace('\\', '/'));
165:                    }
166:                }
167:
168:                if (obj == ok) {
169:                    if (termReadButton.isSelected()) {
170:                        termInput = inputField.getText();
171:                        if (termInput.indexOf(File.separatorChar) == -1) {
172:                            owner.send("[t] g " + termInput);
173:                            if (xmlLogger.isLoggable(Level.FINER))
174:                                xmlLogger.finer("sending term  string");
175:                        } else {
176:                            owner.send("[t] tfile " + termInput);
177:                            if (xmlLogger.isLoggable(Level.FINER)) {
178:                                xmlLogger.finer("sending file term: "
179:                                        + termInput);
180:                            }
181:                        }
182:                    } else { //String selected
183:                        parseInput = inputField.getText();
184:                        if (parseInput.indexOf(File.separatorChar) == -1) {
185:                            owner.send("[t] p " + parseInput);
186:                            if (xmlLogger.isLoggable(Level.FINER))
187:                                xmlLogger.finer("sending parse string: "
188:                                        + parseInput);
189:                        } else {
190:                            owner.send("[t] pfile " + parseInput);
191:                            if (xmlLogger.isLoggable(Level.FINER))
192:                                xmlLogger.finer("sending file parse string: "
193:                                        + parseInput);
194:                        }
195:                    }
196:                    readDialog.setVisible(false);
197:                }
198:
199:            }
200:
201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.