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


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2007 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 java.util.ArrayList;
013:        import java.util.Iterator;
014:        import java.util.List;
015:
016:        import org.eclipse.jface.action.ActionContributionItem;
017:        import org.eclipse.jface.action.IAction;
018:        import org.eclipse.jface.action.IContributionItem;
019:        import org.eclipse.jface.action.IContributionManager;
020:        import org.eclipse.jface.action.IMenuManager;
021:        import org.eclipse.jface.action.Separator;
022:        import org.eclipse.ui.IWorkbenchWindow;
023:        import org.eclipse.ui.internal.actions.NewWizardShortcutAction;
024:        import org.eclipse.ui.internal.dialogs.WorkbenchWizardElement;
025:        import org.eclipse.ui.internal.registry.WizardsRegistryReader;
026:        import org.eclipse.ui.wizards.IWizardDescriptor;
027:
028:        /**
029:         * A <code>NewWizardMenu</code> augments <code>BaseNewWizardMenu</code> with IDE-specific
030:         * actions: New Project... (always shown) and New Example... (shown only if there are example wizards installed).
031:         */
032:        public class NewWizardMenu extends BaseNewWizardMenu {
033:
034:            private final IAction newExampleAction;
035:            private final IAction newProjectAction;
036:
037:            private boolean enabled = true;
038:
039:            /**
040:             * Creates a new wizard shortcut menu for the IDE.
041:             * 
042:             * @param window
043:             *            the window containing the menu
044:             */
045:            public NewWizardMenu(IWorkbenchWindow window) {
046:                this (window, null);
047:
048:            }
049:
050:            /**
051:             * Creates a new wizard shortcut menu for the IDE.
052:             * 
053:             * @param window
054:             *            the window containing the menu
055:             * @param id
056:             *            the identifier for this contribution item 
057:             */
058:            public NewWizardMenu(IWorkbenchWindow window, String id) {
059:                super (window, id);
060:                newExampleAction = new NewExampleAction(window);
061:                newProjectAction = new NewProjectAction(window);
062:            }
063:
064:            /**
065:             * Create a new wizard shortcut menu.  
066:             * <p>
067:             * If the menu will appear on a semi-permanent basis, for instance within
068:             * a toolbar or menubar, the value passed for <code>register</code> should be true.
069:             * If set, the menu will listen to perspective activation and update itself
070:             * to suit.  In this case clients are expected to call <code>deregister</code> 
071:             * when the menu is no longer needed.  This will unhook any perspective
072:             * listeners.
073:             * </p>
074:             *
075:             * @param innerMgr the location for the shortcut menu contents
076:             * @param window the window containing the menu
077:             * @param register if <code>true</code> the menu listens to perspective changes in
078:             *      the window
079:             * @deprecated use NewWizardMenu(IWorkbenchWindow) instead
080:             */
081:            public NewWizardMenu(IMenuManager innerMgr,
082:                    IWorkbenchWindow window, boolean register) {
083:                this (window, null);
084:                fillMenu(innerMgr);
085:                // Must be done after constructor to ensure field initialization.
086:            }
087:
088:            /* (non-Javadoc)
089:             * Fills the menu with New Wizards.
090:             */
091:            private void fillMenu(IContributionManager innerMgr) {
092:                // Remove all.
093:                innerMgr.removeAll();
094:
095:                IContributionItem[] items = getContributionItems();
096:                for (int i = 0; i < items.length; i++) {
097:                    innerMgr.add(items[i]);
098:                }
099:            }
100:
101:            /**
102:             * Removes all listeners from the containing workbench window.
103:             * <p>
104:             * This method should only be called if the shortcut menu is created with
105:             * <code>register = true</code>.
106:             * </p>
107:             * 
108:             * @deprecated has no effect
109:             */
110:            public void deregisterListeners() {
111:                // do nothing
112:            }
113:
114:            /**
115:             * Return whether or not any examples are in the current install.
116:             * 
117:             * @return boolean
118:             */
119:            private boolean hasExamples() {
120:                return registryHasCategory(WizardsRegistryReader.FULL_EXAMPLES_WIZARD_CATEGORY);
121:            }
122:
123:            /* (non-Javadoc)
124:             * @see org.eclipse.ui.actions.BaseNewWizardMenu#addItems(org.eclipse.jface.action.IContributionManager)
125:             */
126:            protected void addItems(List list) {
127:                ArrayList shortCuts = new ArrayList();
128:                addShortcuts(shortCuts);
129:
130:                for (Iterator iterator = shortCuts.iterator(); iterator
131:                        .hasNext();) {
132:                    Object curr = iterator.next();
133:                    if (curr instanceof  ActionContributionItem
134:                            && isNewProjectWizardAction(((ActionContributionItem) curr)
135:                                    .getAction())) {
136:                        iterator.remove();
137:                        list.add(curr);
138:                    }
139:                }
140:                list.add(new ActionContributionItem(newProjectAction));
141:                list.add(new Separator());
142:                if (!shortCuts.isEmpty()) {
143:                    list.addAll(shortCuts);
144:                    list.add(new Separator());
145:                }
146:                if (hasExamples()) {
147:                    list.add(new ActionContributionItem(newExampleAction));
148:                    list.add(new Separator());
149:                }
150:                list.add(new ActionContributionItem(getShowDialogAction()));
151:            }
152:
153:            private boolean isNewProjectWizardAction(IAction action) {
154:                if (action instanceof  NewWizardShortcutAction) {
155:                    IWizardDescriptor wizardDescriptor = ((NewWizardShortcutAction) action)
156:                            .getWizardDescriptor();
157:                    String[] tags = wizardDescriptor.getTags();
158:                    for (int i = 0; i < tags.length; i++) {
159:                        if (WorkbenchWizardElement.TAG_PROJECT.equals(tags[i])) {
160:                            return true;
161:                        }
162:                    }
163:                }
164:                return false;
165:            }
166:
167:            /* (non-Javadoc)
168:             * Method declared on IContributionItem.
169:             */
170:            public boolean isEnabled() {
171:                return enabled;
172:            }
173:
174:            /**
175:             * Sets the enabled state of the receiver.
176:             * 
177:             * @param enabledValue if <code>true</code> the menu is enabled; else
178:             * 		it is disabled
179:             */
180:            public void setEnabled(boolean enabledValue) {
181:                this .enabled = enabledValue;
182:            }
183:
184:            /* (non-Javadoc)
185:             * @see org.eclipse.ui.actions.BaseNewWizardMenu#getContributionItems()
186:             */
187:            protected IContributionItem[] getContributionItems() {
188:                if (isEnabled()) {
189:                    return super .getContributionItems();
190:                }
191:                return new IContributionItem[0];
192:            }
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.