Source Code Cross Referenced for BaseMenuCreator.java in  » Net » Terracotta » org » terracotta » dso » actions » 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 » Net » Terracotta » org.terracotta.dso.actions 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice.  All rights reserved.
003:         */
004:        package org.terracotta.dso.actions;
005:
006:        import org.eclipse.core.resources.IProject;
007:        import org.eclipse.jdt.core.IJavaElement;
008:        import org.eclipse.jface.action.ActionContributionItem;
009:        import org.eclipse.jface.action.IAction;
010:        import org.eclipse.jface.action.IMenuCreator;
011:        import org.eclipse.jface.viewers.ISelection;
012:        import org.eclipse.swt.events.MenuAdapter;
013:        import org.eclipse.swt.events.MenuEvent;
014:        import org.eclipse.swt.widgets.Control;
015:        import org.eclipse.swt.widgets.Menu;
016:        import org.eclipse.swt.widgets.MenuItem;
017:        import org.eclipse.ui.IEditorActionDelegate;
018:        import org.eclipse.ui.IEditorPart;
019:        import org.eclipse.ui.IObjectActionDelegate;
020:        import org.eclipse.ui.IViewActionDelegate;
021:        import org.eclipse.ui.IViewPart;
022:        import org.eclipse.ui.IWorkbenchPart;
023:        import org.eclipse.ui.IWorkbenchWindow;
024:        import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
025:        import org.eclipse.ui.texteditor.ITextEditor;
026:        import org.terracotta.dso.ConfigurationHelper;
027:        import org.terracotta.dso.TcPlugin;
028:
029:        /**
030:         * Hackey way to dynamically create popup action submenus.
031:         */
032:
033:        public abstract class BaseMenuCreator implements  IObjectActionDelegate,
034:                IEditorActionDelegate, IViewActionDelegate, IMenuCreator,
035:                IWorkbenchWindowPulldownDelegate2 {
036:            protected IJavaElement m_element;
037:            protected IAction m_delegateAction;
038:            protected ISelection m_selection;
039:            protected IEditorPart m_editorPart;
040:
041:            public BaseMenuCreator() {/**/
042:            }
043:
044:            public void init(IWorkbenchWindow window) {/**/
045:            }
046:
047:            public void run(IAction action) {/**/
048:            }
049:
050:            public void dispose() {/**/
051:            }
052:
053:            public void init(IViewPart view) {/**/
054:            }
055:
056:            public void setActivePart(IAction action, IWorkbenchPart targetPart) {/**/
057:            }
058:
059:            public void setActiveEditor(IAction action, IEditorPart targetEditor) {
060:                m_editorPart = targetEditor;
061:            }
062:
063:            protected IJavaElement getElement(ISelection selection) {
064:                IJavaElement element;
065:
066:                if ((element = getJavaElement(selection)) != null
067:                        && hasTerracottaNature(element)) {
068:                    return element;
069:                }
070:
071:                return null;
072:            }
073:
074:            public void selectionChanged(IAction action, ISelection selection) {
075:                if (m_delegateAction == null) {
076:                    m_delegateAction = action;
077:                    m_delegateAction.setMenuCreator(this );
078:                }
079:                m_selection = selection;
080:            }
081:
082:            public void setJavaElement(IJavaElement javaElement) {
083:                m_element = javaElement;
084:            }
085:
086:            protected abstract IJavaElement getJavaElement(ISelection selection);
087:
088:            protected void buildMenu(Menu menu) {
089:                menu.addMenuListener(new MenuAdapter() {
090:                    public void menuShown(MenuEvent e) {
091:                        Menu m = (Menu) e.widget;
092:                        MenuItem[] items = m.getItems();
093:
094:                        for (int i = 0; i < items.length; i++) {
095:                            items[i].dispose();
096:                        }
097:
098:                        fillMenu(m);
099:                    }
100:                });
101:            }
102:
103:            protected ISelection getSelection() {
104:                if (m_editorPart != null) {
105:                    if (m_editorPart instanceof  ITextEditor) {
106:                        return ((ITextEditor) m_editorPart)
107:                                .getSelectionProvider().getSelection();
108:                    }
109:                }
110:
111:                return m_selection;
112:            }
113:
114:            public Menu getMenu(Control parent) {
115:                Menu menu = null;
116:
117:                m_selection = getSelection();
118:                if ((m_element = getElement(m_selection)) != null) {
119:                    buildMenu(menu = new Menu(parent));
120:                }
121:
122:                return menu;
123:            }
124:
125:            public Menu getMenu(Menu parent) {
126:                Menu menu = null;
127:
128:                m_selection = getSelection();
129:                if ((m_element = getElement(m_selection)) != null) {
130:                    buildMenu(menu = new Menu(parent));
131:                }
132:
133:                return menu;
134:            }
135:
136:            protected abstract void fillMenu(Menu menu);
137:
138:            protected ConfigurationHelper getConfigHelper() {
139:                ConfigurationHelper helper = null;
140:                IProject project = getProject();
141:
142:                if (project != null) {
143:                    helper = TcPlugin.getDefault().getConfigurationHelper(
144:                            project);
145:                }
146:
147:                return helper;
148:            }
149:
150:            protected IProject getProject() {
151:                return (m_element != null) ? m_element.getJavaProject()
152:                        .getProject() : null;
153:            }
154:
155:            protected void addMenuAction(Menu menu, IAction action) {
156:                ActionContributionItem item = new ActionContributionItem(action);
157:                item.fill(menu, -1);
158:            }
159:
160:            protected boolean hasTerracottaNature(IJavaElement element) {
161:                return TcPlugin.getDefault().hasTerracottaNature(element);
162:            }
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.