Source Code Cross Referenced for SimpleEngine.java in  » IDE-Netbeans » performance » org » netbeans » actions » simple » 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 » IDE Netbeans » performance » org.netbeans.actions.simple 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * SimpleEngine.java
003:         *
004:         * Created on January 25, 2004, 1:42 PM
005:         */
006:
007:        package org.netbeans.actions.simple;
008:
009:        import java.awt.Toolkit;
010:        import java.awt.event.ActionEvent;
011:        import java.awt.event.ActionListener;
012:        import java.io.IOException;
013:        import java.io.ObjectInputStream;
014:        import java.io.ObjectOutputStream;
015:        import java.net.URL;
016:        import java.util.Map;
017:        import java.util.ResourceBundle;
018:        import javax.swing.AbstractAction;
019:        import javax.swing.Action;
020:        import javax.swing.ActionMap;
021:        import javax.swing.ComponentInputMap;
022:        import javax.swing.InputMap;
023:        import javax.swing.JComponent;
024:        import javax.swing.KeyStroke;
025:        import javax.swing.Timer;
026:        import javax.swing.text.Keymap;
027:        import org.netbeans.actions.api.ContextProvider;
028:        import org.netbeans.actions.api.Engine;
029:        import org.netbeans.actions.engine.spi.AbstractContextMenuFactory;
030:        import org.netbeans.actions.engine.spi.MenuFactory;
031:        import org.netbeans.actions.engine.spi.ToolbarFactory;
032:        import org.netbeans.actions.engine.spi.AbstractEngine;
033:        import org.netbeans.actions.engine.spi.AbstractMenuFactory;
034:        import org.netbeans.actions.engine.spi.AbstractToolbarFactory;
035:        import org.netbeans.actions.engine.spi.ActionFactory;
036:        import org.netbeans.actions.engine.spi.ContextMenuFactory;
037:        import org.netbeans.actions.spi.ActionProvider;
038:        import org.netbeans.actions.spi.ContainerProvider;
039:
040:        /** A basic test implementation
041:         *
042:         * @author  tim
043:         */
044:        public class SimpleEngine extends AbstractEngine implements 
045:                ActionListener {
046:            Interpreter interp;
047:            ResourceBundle bundle;
048:            private Timer timer = new javax.swing.Timer(100, this );
049:
050:            public static Engine createEngine(URL actionDefs,
051:                    ResourceBundle bundle) {
052:                Interpreter interp = new Interpreter(actionDefs);
053:                return new SimpleEngine(interp, bundle);
054:            }
055:
056:            /** Creates a new instance of SimpleEngine */
057:            private SimpleEngine(Interpreter interp, ResourceBundle bundle) {
058:                super (new SimpleActionProvider(interp, bundle),
059:                        new SimpleContainerProvider(interp, bundle));
060:                this .bundle = bundle;
061:                this .interp = interp;
062:            }
063:
064:            public ContextProvider getContextProvider() {
065:                return super .getContextProvider();
066:            }
067:
068:            protected ActionFactory createActionFactory() {
069:                return new SimpleActionFactory();
070:            }
071:
072:            protected MenuFactory createMenuFactory() {
073:                return new SimpleMenuFactory();
074:            }
075:
076:            protected ToolbarFactory createToolbarFactory() {
077:                return new SimpleToolbarFactory();
078:            }
079:
080:            protected ContextMenuFactory createContextMenuFactory() {
081:                return new SimpleContextMenuFactory();
082:            }
083:
084:            public InputMap createInputMap(JComponent jc) {
085:                return new SimpleInputMap(jc);
086:            }
087:
088:            public ActionMap createActionMap() {
089:                return new SimpleActionMap();
090:            }
091:
092:            private Keymap keymap = null;
093:
094:            public Keymap createKeymap() {
095:                if (keymap == null) {
096:                    keymap = new SimpleKeymap(this , interp);
097:                }
098:                return keymap;
099:            }
100:
101:            boolean updateRecommended = false;
102:
103:            public void recommendUpdate() {
104:                updateRecommended = true;
105:                timer.setRepeats(true);
106:                if (!timer.isRunning()) {
107:                    timer.start();
108:                }
109:            }
110:
111:            public void actionPerformed(ActionEvent e) {
112:                if (updateRecommended) {
113:                    update();
114:                    updateRecommended = false;
115:                } else {
116:                    timer.stop();
117:                }
118:            }
119:
120:            Action getAction(String action) {
121:                //Used by keymap
122:                return getActionFactory().getAction(action, null,
123:                        getContextProvider().getContext());
124:            }
125:
126:            private class SimpleActionFactory implements  ActionFactory {
127:                public Action getAction(final String action,
128:                        String containerCtx, final Map context) {
129:                    return new AbstractAction() {
130:                        public void actionPerformed(ActionEvent ae) {
131:                            SimpleInvoker invoker = interp.getInvoker(action);
132:                            System.err.println("Invoker is " + invoker);
133:                            System.err.println("Invoking " + action + " on "
134:                                    + context);
135:                            if (invoker != null) {
136:                                invoker.invoke(context);
137:                            } else {
138:                                Toolkit.getDefaultToolkit().beep();
139:                            }
140:                        }
141:                    };
142:                }
143:            }
144:
145:            private class SimpleToolbarFactory extends AbstractToolbarFactory {
146:                public SimpleToolbarFactory() {
147:                    super (SimpleEngine.this );
148:                }
149:            }
150:
151:            private class SimpleMenuFactory extends AbstractMenuFactory {
152:                public SimpleMenuFactory() {
153:                    super (SimpleEngine.this );
154:                }
155:            }
156:
157:            private class SimpleContextMenuFactory extends
158:                    AbstractContextMenuFactory {
159:                public SimpleContextMenuFactory() {
160:                    super (SimpleEngine.this );
161:                }
162:            }
163:
164:            private class SimpleInputMap extends ComponentInputMap {
165:                public SimpleInputMap(JComponent jc) {
166:                    super (jc);
167:                }
168:
169:                public Object get(KeyStroke keyStroke) {
170:                    return interp.getActionForKeystroke(keyStroke);
171:                }
172:
173:                public void remove(Object key) {
174:                    throw new UnsupportedOperationException();
175:                }
176:
177:                public KeyStroke[] keys() {
178:                    return interp.getAllKeystrokes();
179:                }
180:
181:                public int size() {
182:                    return super .size() + keys().length;
183:                }
184:
185:                public KeyStroke[] allKeys() {
186:                    return keys(); //XXX merge w/ super
187:                }
188:
189:                private void writeObject(ObjectOutputStream s)
190:                        throws IOException {
191:                    //do nothing
192:                }
193:
194:                private void readObject(ObjectInputStream s)
195:                        throws ClassNotFoundException, IOException {
196:                    //do nothing
197:                }
198:            }
199:
200:            private class SimpleActionMap extends ActionMap {
201:                public Action get(Object key) {
202:                    Action a = super .get(key);
203:                    if (a == null && key instanceof  String) {
204:                        a = getAction((String) key);
205:                    }
206:                    return a;
207:                }
208:
209:                public Object[] keys() {
210:                    return interp.getAllActionsBoundToKeystrokes();
211:                }
212:
213:            }
214:
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.