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


001:        /*
002:         * AbstractEngine.java
003:         *
004:         * Created on January 24, 2004, 1:36 PM
005:         */
006:
007:        package org.netbeans.actions.engine.spi;
008:
009:        import java.util.HashSet;
010:        import java.util.Map;
011:        import java.util.Set;
012:        import javax.swing.Action;
013:        import javax.swing.JComponent;
014:        import javax.swing.JMenu;
015:        import javax.swing.JMenuBar;
016:        import javax.swing.JMenuItem;
017:        import javax.swing.JPopupMenu;
018:        import javax.swing.JToolBar;
019:        import org.netbeans.actions.api.ContextProvider;
020:        import org.netbeans.actions.api.Engine;
021:        import org.netbeans.actions.engine.spi.MenuFactory;
022:        import org.netbeans.actions.engine.spi.ToolbarFactory;
023:        import org.netbeans.actions.spi.ActionProvider;
024:        import org.netbeans.actions.spi.ContainerProvider;
025:
026:        /** Convenience basic impl of Engine. Mostly it connects individual 
027:         * infrastructure pieces with each other.
028:         *
029:         * @author  Tim Boudreau
030:         */
031:        public abstract class AbstractEngine extends Engine {
032:            private ActionProvider actionProvider;
033:            private ContainerProvider containerProvider;
034:            private MenuFactory menuFactory = null;
035:            private ToolbarFactory toolbarFactory = null;
036:            private ActionFactory actionFactory = null;
037:
038:            /** Creates a new instance of AbstractEngine */
039:            protected AbstractEngine(ActionProvider actionProvider,
040:                    ContainerProvider containerProvider) {
041:                this .actionProvider = actionProvider;
042:                this .containerProvider = containerProvider;
043:            }
044:
045:            private ContextProvider contextProvider;
046:
047:            public void setContextProvider(ContextProvider ctx) {
048:                this .contextProvider = ctx;
049:            }
050:
051:            public ContextProvider getContextProvider() {
052:                return contextProvider;
053:            }
054:
055:            protected final ActionProvider getActionProvider() {
056:                return actionProvider;
057:            }
058:
059:            protected final ContainerProvider getContainerProvider() {
060:                return containerProvider;
061:            }
062:
063:            protected Action getAction(String containerCtx, String action) {
064:                return getActionFactory().getAction(action, containerCtx,
065:                        getContextProvider().getContext());
066:            }
067:
068:            protected abstract MenuFactory createMenuFactory();
069:
070:            protected abstract ToolbarFactory createToolbarFactory();
071:
072:            protected abstract ActionFactory createActionFactory();
073:
074:            protected abstract ContextMenuFactory createContextMenuFactory();
075:
076:            void notifyWillPerform(String action, String containerCtx) {
077:
078:            }
079:
080:            void notifyPerformed(String action, String containerCtx) {
081:                update();
082:            }
083:
084:            private ContextMenuFactory contextMenuFactory = null;
085:
086:            public final ContextMenuFactory getContextMenuFactory() {
087:                if (contextMenuFactory == null) {
088:                    contextMenuFactory = createContextMenuFactory();
089:                }
090:                return contextMenuFactory;
091:            }
092:
093:            public final MenuFactory getMenuFactory() {
094:                if (menuFactory == null) {
095:                    menuFactory = createMenuFactory();
096:                }
097:                return menuFactory;
098:            }
099:
100:            public final ToolbarFactory getToolbarFactory() {
101:                if (toolbarFactory == null) {
102:                    toolbarFactory = createToolbarFactory();
103:                }
104:                return toolbarFactory;
105:            }
106:
107:            public final ActionFactory getActionFactory() {
108:                if (actionFactory == null) {
109:                    actionFactory = createActionFactory();
110:                }
111:                return actionFactory;
112:            }
113:
114:            void notifyOpened(String containerCtx, Object type) {
115:
116:            }
117:
118:            void notifyClosed(String containerCtx, Object type) {
119:
120:            }
121:
122:            boolean isOpen(String containerCtx, Object type) {
123:                if (type == ContainerProvider.TYPE_MENU) {
124:                    return showingMenus.contains(containerCtx);
125:                } else if (type == ContainerProvider.TYPE_TOOLBAR) {
126:                    return showingToolbars.contains(containerCtx);
127:                } else {
128:                    return false;
129:                }
130:            }
131:
132:            /** Indicates a menu has been displayed onscreen, not that it has been opened.
133:             */
134:            protected void notifyMenuShown(String containerCtx, JMenu menu) {
135:                showingMenus.add(containerCtx);
136:            }
137:
138:            protected void notifyMenuHidden(String containerCtx, JMenu menu) {
139:                showingMenus.remove(containerCtx);
140:            }
141:
142:            protected void notifyToolbarShown(String containerCtx,
143:                    JToolBar toolbar) {
144:                showingToolbars.add(containerCtx);
145:            }
146:
147:            protected void notifyToolbarHidden(String containerCtx,
148:                    JToolBar toolbar) {
149:                showingToolbars.remove(containerCtx);
150:            }
151:
152:            public void update() {
153:                updateToolbars();
154:                updateMenus();
155:            }
156:
157:            protected void updateToolbars() {
158:                int count = showingToolbars.size();
159:                String[] toolbars = new String[count];
160:                toolbars = (String[]) showingToolbars.toArray(toolbars);
161:                for (int i = 0; i < count; i++) {
162:                    getToolbarFactory().update(toolbars[i]);
163:                }
164:            }
165:
166:            protected void updateMenus() {
167:                int count = showingMenus.size();
168:                String[] menus = new String[count];
169:                menus = (String[]) showingMenus.toArray(menus);
170:                for (int i = 0; i < count; i++) {
171:                    getMenuFactory().update(menus[i]);
172:                }
173:            }
174:
175:            public final JMenuBar createMenuBar() {
176:                JMenuBar result = new JMenuBar();
177:                ContainerProvider cp = getContainerProvider();
178:                String[] menus = cp.getMenuContainerContexts();
179:                for (int i = 0; i < menus.length; i++) {
180:                    JMenu menu = getMenuFactory().createMenu(menus[i]);
181:                    result.add(menu);
182:                }
183:                return result;
184:            }
185:
186:            public final JToolBar[] createToolbars() {
187:                ContainerProvider cp = getContainerProvider();
188:                String[] toolbars = cp.getToolbarContainerContexts();
189:                JToolBar[] result = new JToolBar[toolbars.length];
190:                for (int i = 0; i < toolbars.length; i++) {
191:                    result[i] = getToolbarFactory().createToolbar(toolbars[i]);
192:                }
193:                return result;
194:            }
195:
196:            public JPopupMenu createPopupMenu() {
197:                return getContextMenuFactory().createMenu(
198:                        getContextProvider().getContext());
199:            }
200:
201:            private Set showingMenus = new HashSet();
202:            private Set showingToolbars = new HashSet();
203:
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.