Source Code Cross Referenced for MouseEventRecordableEditor.java in  » Testing » jacareto » jacareto » editor » 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.editor 
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.editor;
025:
026:        import jacareto.record.MouseEventRecordable;
027:        import jacareto.struct.StructureElement;
028:        import jacareto.system.Environment;
029:        import jacareto.system.Language;
030:        import jacareto.toolkit.event.TextValueListener;
031:        import jacareto.toolkit.swing.IntegerTextField;
032:
033:        import java.awt.event.ActionEvent;
034:        import java.awt.event.ActionListener;
035:        import java.awt.event.MouseEvent;
036:
037:        import javax.swing.JComboBox;
038:        import javax.swing.event.DocumentEvent;
039:
040:        /**
041:         * An editor for mouse events which are not mouse motions.
042:         *
043:         * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
044:         * @version 1.02
045:         */
046:        public class MouseEventRecordableEditor extends
047:                InputEventRecordableEditor {
048:            /** The text field for the x position. */
049:            private IntegerTextField xPosField;
050:
051:            /** The text field for the y position. */
052:            private IntegerTextField yPosField;
053:
054:            /** The text field for the root x position. */
055:            private IntegerTextField rootXPosField;
056:
057:            /** The text field for the root y position. */
058:            private IntegerTextField rootYPosField;
059:
060:            /** The text field for the click count. */
061:            private IntegerTextField clickCountField;
062:
063:            /** The popup Trigger box. */
064:            private JComboBox popupTriggerBox;
065:
066:            /** The type box. */
067:            private JComboBox typeBox;
068:
069:            /**
070:             * Create a new mouse event recordable editor.
071:             *
072:             * @param env the environment
073:             */
074:            public MouseEventRecordableEditor(Environment env) {
075:                super (env);
076:
077:                Language language = getLanguage();
078:
079:                // The type box
080:                typeBox = addComboBoxRow(language
081:                        .getString("Events.MouseEvent.Type"));
082:                typeBox.addItem(language
083:                        .getString("Events.MouseEvent.MousePressed"));
084:                typeBox.addItem(language
085:                        .getString("Events.MouseEvent.MouseReleased"));
086:                typeBox.addItem(language
087:                        .getString("Events.MouseEvent.MouseClicked"));
088:                typeBox.addItem(language
089:                        .getString("Events.MouseEvent.MouseEntered"));
090:                typeBox.addItem(language
091:                        .getString("Events.MouseEvent.MouseExited"));
092:                typeBox.addItem(language
093:                        .getString("Events.MouseEvent.MouseMoved"));
094:                typeBox.addItem(language
095:                        .getString("Events.MouseEvent.MouseDragged"));
096:                typeBox.addActionListener(new ActionListener() {
097:                    public void actionPerformed(ActionEvent e) {
098:                        MouseEventRecordable mRecordable = (MouseEventRecordable) getElement();
099:
100:                        if (isUpdateOnChange && (mRecordable != null)) {
101:                            switch (typeBox.getSelectedIndex()) {
102:                            case 0:
103:                                mRecordable.setID(MouseEvent.MOUSE_PRESSED);
104:
105:                                break;
106:
107:                            case 1:
108:                                mRecordable.setID(MouseEvent.MOUSE_RELEASED);
109:
110:                                break;
111:
112:                            case 2:
113:                                mRecordable.setID(MouseEvent.MOUSE_CLICKED);
114:
115:                                break;
116:
117:                            case 3:
118:                                mRecordable.setID(MouseEvent.MOUSE_ENTERED);
119:
120:                                break;
121:
122:                            case 4:
123:                                mRecordable.setID(MouseEvent.MOUSE_EXITED);
124:
125:                                break;
126:
127:                            case 5:
128:                                mRecordable.setID(MouseEvent.MOUSE_MOVED);
129:
130:                                break;
131:
132:                            case 6:
133:                                mRecordable.setID(MouseEvent.MOUSE_DRAGGED);
134:
135:                                break;
136:                            }
137:                        }
138:                    }
139:                });
140:
141:                // The x pos field
142:                xPosField = addIntegerTextFieldRow(language
143:                        .getString("Events.MouseEvent.XPosition"), 5);
144:                xPosField.getDocument().addDocumentListener(
145:                        new TextValueListener() {
146:                            public void textValueChanged(DocumentEvent e) {
147:                                if (isUpdateOnChange && (getElement() != null)) {
148:                                    MouseEventRecordable meRecordable = (MouseEventRecordable) getElement();
149:                                    int diffX = xPosField.getValue()
150:                                            - meRecordable.getX();
151:                                    meRecordable.setX(xPosField.getValue());
152:                                    meRecordable.setRootX(meRecordable
153:                                            .getRootX()
154:                                            + diffX);
155:                                    rootXPosField.setValue(meRecordable
156:                                            .getRootX());
157:                                }
158:                            }
159:                        });
160:
161:                // The y pos field
162:                yPosField = addIntegerTextFieldRow(language
163:                        .getString("Events.MouseEvent.YPosition"), 5);
164:                yPosField.getDocument().addDocumentListener(
165:                        new TextValueListener() {
166:                            public void textValueChanged(DocumentEvent e) {
167:                                if (isUpdateOnChange && (getElement() != null)) {
168:                                    MouseEventRecordable meRecordable = (MouseEventRecordable) getElement();
169:                                    int diffY = yPosField.getValue()
170:                                            - meRecordable.getY();
171:                                    meRecordable.setY(yPosField.getValue());
172:                                    meRecordable.setRootY(meRecordable
173:                                            .getRootY()
174:                                            + diffY);
175:                                    rootYPosField.setValue(meRecordable
176:                                            .getRootY());
177:                                }
178:                            }
179:                        });
180:
181:                // The root x pos field
182:                rootXPosField = addIntegerTextFieldRow(language
183:                        .getString("Events.MouseEvent.RootXPosition"), 5);
184:                rootXPosField.setEditable(false);
185:
186:                // The root y pos field
187:                rootYPosField = addIntegerTextFieldRow(language
188:                        .getString("Events.MouseEvent.RootYPosition"), 5);
189:                rootYPosField.setEditable(false);
190:
191:                // The click count field
192:                clickCountField = addIntegerTextFieldRow(language
193:                        .getString("Events.MouseEvent.ClickCount"), 5);
194:                clickCountField.getDocument().addDocumentListener(
195:                        new TextValueListener() {
196:                            public void textValueChanged(DocumentEvent e) {
197:                                if (isUpdateOnChange && (getElement() != null)) {
198:                                    ((MouseEventRecordable) getElement())
199:                                            .setClickCount(clickCountField
200:                                                    .getValue());
201:                                }
202:                            }
203:                        });
204:
205:                // The is popup trigger box
206:                popupTriggerBox = addComboBoxRow(language
207:                        .getString("Events.MouseEvent.PopupTrigger"));
208:                popupTriggerBox.addItem(language.getString("General.True"));
209:                popupTriggerBox.addItem(language.getString("General.False"));
210:                popupTriggerBox.addActionListener(new ActionListener() {
211:                    public void actionPerformed(ActionEvent e) {
212:                        if (isUpdateOnChange && (getElement() != null)) {
213:                            if (popupTriggerBox.getSelectedIndex() == 0) {
214:                                ((MouseEventRecordable) getElement())
215:                                        .setConsumed(true);
216:                            } else {
217:                                ((MouseEventRecordable) getElement())
218:                                        .setConsumed(false);
219:                            }
220:                        }
221:                    }
222:                });
223:            }
224:
225:            /**
226:             * Returns whether this editor is responsible for a given structure element. This editor is
227:             * responsible for all event recordables.
228:             *
229:             * @param element the structure element
230:             *
231:             * @return <code>true</code> if <i>element</i> is a mouse event recordable and not
232:             *         <code>null</code>, otherwise <code>false</code>
233:             */
234:            public boolean handlesElement(StructureElement element) {
235:                return (element != null)
236:                        && (element instanceof  MouseEventRecordable);
237:            }
238:
239:            /**
240:             * Sets the element to edit.
241:             *
242:             * @param element DOCUMENT ME!
243:             */
244:            public void setElement(StructureElement element) {
245:                super .setElement(element);
246:
247:                MouseEventRecordable mRecordable = (MouseEventRecordable) element;
248:                xPosField.setValue(mRecordable.getX());
249:                yPosField.setValue(mRecordable.getY());
250:                rootXPosField.setValue(mRecordable.getRootX());
251:                rootYPosField.setValue(mRecordable.getRootY());
252:                clickCountField.setValue(mRecordable.getClickCount());
253:
254:                if (mRecordable.isPopupTrigger()) {
255:                    popupTriggerBox.setSelectedIndex(0);
256:                } else {
257:                    popupTriggerBox.setSelectedIndex(1);
258:                }
259:
260:                switch (mRecordable.getID()) {
261:                case MouseEvent.MOUSE_PRESSED:
262:                    typeBox.setSelectedIndex(0);
263:
264:                    break;
265:
266:                case MouseEvent.MOUSE_RELEASED:
267:                    typeBox.setSelectedIndex(1);
268:
269:                    break;
270:
271:                case MouseEvent.MOUSE_CLICKED:
272:                    typeBox.setSelectedIndex(2);
273:
274:                    break;
275:
276:                case MouseEvent.MOUSE_ENTERED:
277:                    typeBox.setSelectedIndex(3);
278:
279:                    break;
280:
281:                case MouseEvent.MOUSE_EXITED:
282:                    typeBox.setSelectedIndex(4);
283:
284:                    break;
285:
286:                case MouseEvent.MOUSE_MOVED:
287:                    typeBox.setSelectedIndex(5);
288:
289:                    break;
290:
291:                case MouseEvent.MOUSE_DRAGGED:
292:                    typeBox.setSelectedIndex(6);
293:
294:                    break;
295:                }
296:            }
297:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.