Source Code Cross Referenced for NewWizardDropDownAction.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » 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 » IDE Eclipse » ui workbench » org.eclipse.ui.actions 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2005 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.actions;
011:
012:        import org.eclipse.jface.action.Action;
013:        import org.eclipse.jface.action.ActionContributionItem;
014:        import org.eclipse.jface.action.IContributionItem;
015:        import org.eclipse.jface.action.IMenuCreator;
016:        import org.eclipse.jface.action.MenuManager;
017:        import org.eclipse.swt.widgets.Control;
018:        import org.eclipse.swt.widgets.Menu;
019:        import org.eclipse.ui.ISharedImages;
020:        import org.eclipse.ui.IWorkbenchWindow;
021:        import org.eclipse.ui.internal.PerspectiveTracker;
022:        import org.eclipse.ui.internal.WorkbenchMessages;
023:
024:        /**
025:         * Action which, when run, will open the new wizard dialog.
026:         * In addition, it has a drop-down showing the new wizard shortcuts
027:         * associated with the current perspective.
028:         * <p>
029:         * This class may be instantiated; it is not intended to be subclassed.
030:         * </p>
031:         *
032:         * @since 3.1
033:         */
034:        public class NewWizardDropDownAction extends Action implements 
035:                ActionFactory.IWorkbenchAction {
036:
037:            /**
038:             * The workbench window; or <code>null</code> if this
039:             * action has been <code>dispose</code>d.
040:             */
041:            private IWorkbenchWindow workbenchWindow;
042:
043:            /**
044:             * Tracks perspective activation, to update this action's
045:             * enabled state.
046:             */
047:            private PerspectiveTracker tracker;
048:
049:            private ActionFactory.IWorkbenchAction showDlgAction;
050:
051:            private IContributionItem newWizardMenu;
052:
053:            private IMenuCreator menuCreator = new IMenuCreator() {
054:
055:                private MenuManager dropDownMenuMgr;
056:
057:                /**
058:                 * Creates the menu manager for the drop-down.
059:                 */
060:                private void createDropDownMenuMgr() {
061:                    if (dropDownMenuMgr == null) {
062:                        dropDownMenuMgr = new MenuManager();
063:                        dropDownMenuMgr.add(newWizardMenu);
064:                    }
065:                }
066:
067:                /* (non-Javadoc)
068:                 * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control)
069:                 */
070:                public Menu getMenu(Control parent) {
071:                    createDropDownMenuMgr();
072:                    return dropDownMenuMgr.createContextMenu(parent);
073:                }
074:
075:                /* (non-Javadoc)
076:                 * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu)
077:                 */
078:                public Menu getMenu(Menu parent) {
079:                    createDropDownMenuMgr();
080:                    Menu menu = new Menu(parent);
081:                    IContributionItem[] items = dropDownMenuMgr.getItems();
082:                    for (int i = 0; i < items.length; i++) {
083:                        IContributionItem item = items[i];
084:                        IContributionItem newItem = item;
085:                        if (item instanceof  ActionContributionItem) {
086:                            newItem = new ActionContributionItem(
087:                                    ((ActionContributionItem) item).getAction());
088:                        }
089:                        newItem.fill(menu, -1);
090:                    }
091:                    return menu;
092:                }
093:
094:                /* (non-Javadoc)
095:                 * @see org.eclipse.jface.action.IMenuCreator#dispose()
096:                 */
097:                public void dispose() {
098:                    if (dropDownMenuMgr != null) {
099:                        dropDownMenuMgr.dispose();
100:                        dropDownMenuMgr = null;
101:                    }
102:                }
103:            };
104:
105:            /**
106:             * Create a new <code>NewWizardDropDownAction</code>, with the default
107:             * action for opening the new wizard dialog, and the default contribution item
108:             * for populating the drop-down menu.
109:             * 
110:             * @param window the window in which this action appears
111:             */
112:            public NewWizardDropDownAction(IWorkbenchWindow window) {
113:                this (window, ActionFactory.NEW.create(window),
114:                        ContributionItemFactory.NEW_WIZARD_SHORTLIST
115:                                .create(window));
116:            }
117:
118:            /**
119:             * Create a new <code>NewWizardDropDownAction</code>.
120:             * 
121:             * @param window the window in which this action appears
122:             * @param showDlgAction the action to delegate to when this action is run directly, 
123:             *   rather than being dropped down
124:             * @param newWizardMenu the contribution item that adds the contents to the drop-down menu
125:             */
126:            public NewWizardDropDownAction(IWorkbenchWindow window,
127:                    ActionFactory.IWorkbenchAction showDlgAction,
128:                    IContributionItem newWizardMenu) {
129:                super (WorkbenchMessages.NewWizardDropDown_text);
130:                if (window == null) {
131:                    throw new IllegalArgumentException();
132:                }
133:                this .workbenchWindow = window;
134:                this .showDlgAction = showDlgAction;
135:                this .newWizardMenu = newWizardMenu;
136:                tracker = new PerspectiveTracker(window, this );
137:
138:                setToolTipText(showDlgAction.getToolTipText());
139:
140:                ISharedImages sharedImages = window.getWorkbench()
141:                        .getSharedImages();
142:                setImageDescriptor(sharedImages
143:                        .getImageDescriptor(ISharedImages.IMG_TOOL_NEW_WIZARD));
144:                setDisabledImageDescriptor(sharedImages
145:                        .getImageDescriptor(ISharedImages.IMG_TOOL_NEW_WIZARD_DISABLED));
146:
147:                setMenuCreator(menuCreator);
148:            }
149:
150:            /* (non-Javadoc)
151:             * @see org.eclipse.ui.actions.ActionFactory.IWorkbenchAction#dispose()
152:             */
153:            public void dispose() {
154:                if (workbenchWindow == null) {
155:                    // action has already been disposed
156:                    return;
157:                }
158:                tracker.dispose();
159:                showDlgAction.dispose();
160:                newWizardMenu.dispose();
161:                menuCreator.dispose();
162:                workbenchWindow = null;
163:            }
164:
165:            /**
166:             * Runs the action, which opens the New wizard dialog.
167:             */
168:            public void run() {
169:                if (workbenchWindow == null) {
170:                    // action has been disposed
171:                    return;
172:                }
173:                showDlgAction.run();
174:            }
175:
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.