Source Code Cross Referenced for InputCommand.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) 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.util.HashSet;
019:
020:        /**
021:         * @author daniels
022:         *
023:         *  This class represents a fake command, i.e. nothing is send to GF here.
024:         *  Instead this class acts more like a placeholder for the input dialog.
025:         *  This dialog is handled in GFEditor2 when a InputCommand is executed.
026:         *  Reason: No GUI stuff in the command.
027:         */
028:        class InputCommand extends GFCommand {
029:            public static InputCommand intInputCommand = new InputCommand(
030:                    "read in Integer",
031:                    "opens a dialog window in which an Integer can be entered",
032:                    int.class, "Please enter an Integer");
033:            public static InputCommand stringInputCommand = new InputCommand(
034:                    "read in String",
035:                    "opens a dialog window in which a String can be entered",
036:                    String.class, "Please enter a String");
037:
038:            protected InputCommand(final String description, final String ttt,
039:                    Class type, final String title) {
040:                this .type = type;
041:                this .tooltipText = ttt;
042:                this .displayText = description;
043:                this .titleText = title;
044:                this .command = type.getName();
045:            }
046:
047:            protected Class type;
048:
049:            /**
050:             * the text that is to be displayed as the title in the input window 
051:             */
052:            protected final String titleText;
053:
054:            /**
055:             * the text that is to be displayed as the title in the input window 
056:             */
057:            public String getTitleText() {
058:                return titleText;
059:            }
060:
061:            /**
062:             * stores the entered values, so they can be offered to the user
063:             * the next time, in case, he wants them again.
064:             */
065:            protected final HashSet enteredValues = new HashSet();
066:
067:            /**
068:             * the text that is to be displayed as the tooltip 
069:             */
070:            protected final String tooltipText;
071:
072:            /**
073:             * the text that is to be displayed as the tooltip 
074:             */
075:            public String getTooltipText() {
076:                return tooltipText;
077:            }
078:
079:            /** 
080:             * the text that is to be displayed in the refinement lists 
081:             */
082:            protected final String displayText;
083:
084:            /** 
085:             * the text that is to be displayed in the refinement lists 
086:             */
087:            public String getDisplayText() {
088:                return displayText;
089:            }
090:
091:            /** 
092:             * the subcategory of this command 
093:             */
094:            public String getSubcat() {
095:                return null;
096:            }
097:
098:            /**
099:             * Checks if the given String can be converted into
100:             * the Type of this InputCommand (int or String).
101:             * If that is possible, the converted object is saved
102:             * in enteredValues for later redisplay for the user.
103:             * @param o The String the user has typed
104:             * @param reason If the entered String is not parseable as the expected
105:             * type, an error message is appended to this StringBuffer, so better
106:             * give an empty one.
107:             * @return an Object whose toString() should send the right
108:             * thing to GF. 
109:             * Maybe null, if this "conversion" failed.
110:             */
111:            protected Object validate(String o, StringBuffer reason) {
112:                Object result = null;
113:                if (type == int.class) {
114:                    int i;
115:                    try {
116:                        i = Integer.parseInt(o);
117:                        result = new Integer(i);
118:                    } catch (NumberFormatException e) {
119:                        reason.append("Input format error: '" + o
120:                                + "' is no Integer");
121:                    }
122:                } else if (type == String.class) {
123:                    if (o != null) {
124:                        result = "\"" + o.toString() + "\"";
125:                    }
126:                }
127:                if (result != null) {
128:                    this .enteredValues.add(result);
129:                }
130:                return result;
131:            }
132:
133:            /**
134:             * selects the suiting InputCommand for the given full name of a type
135:             * @param typeName at the moment, either int.class.getName() or String.class.getName()
136:             * @return intInputCommand for int, stringInputCommand for String or null otherwise 
137:             */
138:            protected static InputCommand forTypeName(String typeName) {
139:                InputCommand ic = null;
140:                if (typeName.equals(int.class.getName())) {
141:                    ic = InputCommand.intInputCommand;
142:                } else if (typeName.equals(String.class.getName())) {
143:                    ic = InputCommand.stringInputCommand;
144:                }
145:                return ic;
146:            }
147:
148:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.