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


001:        /*******************************************************************************
002:         * Copyright (c) 2005, 2006 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.internal.navigator.wizards;
011:
012:        import java.util.Iterator;
013:
014:        import org.eclipse.core.expressions.ElementHandler;
015:        import org.eclipse.core.expressions.EvaluationContext;
016:        import org.eclipse.core.expressions.EvaluationResult;
017:        import org.eclipse.core.expressions.Expression;
018:        import org.eclipse.core.expressions.ExpressionConverter;
019:        import org.eclipse.core.expressions.IEvaluationContext;
020:        import org.eclipse.core.runtime.CoreException;
021:        import org.eclipse.core.runtime.IConfigurationElement;
022:        import org.eclipse.core.runtime.IStatus;
023:        import org.eclipse.jface.viewers.IStructuredSelection;
024:        import org.eclipse.ui.IPluginContribution;
025:        import org.eclipse.ui.WorkbenchException;
026:        import org.eclipse.ui.internal.navigator.NavigatorPlugin;
027:        import org.eclipse.ui.internal.navigator.extensions.INavigatorContentExtPtConstants;
028:
029:        /**
030:         * <p>
031:         * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
032:         * part of a work in progress. There is a guarantee neither that this API will
033:         * work nor that it will remain the same. Please do not use this API without
034:         * consulting with the Platform/UI team.
035:         * </p>
036:         * 
037:         * @since 3.2
038:         */
039:        public class CommonWizardDescriptor implements 
040:                INavigatorContentExtPtConstants, IPluginContribution {
041:
042:            /** The default menu group id for commonWizards without a menuGroupId attribute. */
043:            public static final String DEFAULT_MENU_GROUP_ID = "all-uncategorized"; //$NON-NLS-1$
044:
045:            private String id;
046:
047:            private String wizardId;
048:
049:            private String menuGroupId;
050:
051:            private String type;
052:
053:            private Expression enablement;
054:
055:            private IConfigurationElement configElement;
056:
057:            /**
058:             * @param aConfigElement The configuration element from the extension point. 
059:             * @throws WorkbenchException
060:             *             if the configuration element could not be parsed. Reasons
061:             *             include:
062:             *             <ul>
063:             *             <li>A required attribute is missing.</li>
064:             *             <li>More elements are define than is allowed.</li>
065:             *             </ul>
066:             */
067:            public CommonWizardDescriptor(IConfigurationElement aConfigElement)
068:                    throws WorkbenchException {
069:                super ();
070:                configElement = aConfigElement;
071:                init();
072:            }
073:
074:            /**
075:             * @param aConfigElement The configuration element from the extension point.
076:             * @param anId the identifier for visibility purposes.
077:             *  
078:             * @throws WorkbenchException
079:             *             if the configuration element could not be parsed. Reasons
080:             *             include:
081:             *             <ul>
082:             *             <li>A required attribute is missing.</li>
083:             *             <li>More elements are define than is allowed.</li>
084:             *             </ul>
085:             */
086:            public CommonWizardDescriptor(IConfigurationElement aConfigElement,
087:                    String anId) throws WorkbenchException {
088:                super ();
089:                configElement = aConfigElement;
090:                id = anId;
091:                init();
092:
093:            }
094:
095:            /**
096:             * Determine if this content extension is enabled for the given selection.
097:             * The content extension is enabled for the selection if and only if it is
098:             * enabled for each element in the selection.
099:             * 
100:             * @param aStructuredSelection
101:             *            The selection from the viewer
102:             * @return True if and only if the extension is enabled for each element in
103:             *         the selection.
104:             */
105:            public boolean isEnabledFor(
106:                    IStructuredSelection aStructuredSelection) {
107:                if (enablement == null) {
108:                    return false;
109:                }
110:
111:                IEvaluationContext context = null;
112:
113:                Iterator elements = aStructuredSelection.iterator();
114:                while (elements.hasNext()) {
115:                    context = new EvaluationContext(null, elements.next());
116:                    context.setAllowPluginActivation(true);
117:                    try {
118:                        if (enablement.evaluate(context) == EvaluationResult.FALSE) {
119:                            return false;
120:                        }
121:                    } catch (CoreException e) {
122:                        NavigatorPlugin
123:                                .log(IStatus.ERROR, 0, e.getMessage(), e);
124:                        return false;
125:                    }
126:                }
127:                return true;
128:            }
129:
130:            /**
131:             * Determine if this content extension is enabled for the given element.
132:             * 
133:             * @param anElement
134:             *            The element that should be used for the evaluation.
135:             * @return True if and only if the extension is enabled for the element.
136:             */
137:            public boolean isEnabledFor(Object anElement) {
138:
139:                if (enablement == null) {
140:                    return false;
141:                }
142:
143:                try {
144:                    EvaluationContext context = new EvaluationContext(null,
145:                            anElement);
146:                    context.setAllowPluginActivation(true);
147:                    return (enablement.evaluate(context) == EvaluationResult.TRUE);
148:                } catch (CoreException e) {
149:                    NavigatorPlugin.log(IStatus.ERROR, 0, e.getMessage(), e);
150:                }
151:                return false;
152:            }
153:
154:            void init() throws WorkbenchException {
155:                wizardId = configElement.getAttribute(ATT_WIZARD_ID);
156:                type = configElement.getAttribute(ATT_TYPE);
157:
158:                menuGroupId = configElement.getAttribute(ATT_MENU_GROUP_ID);
159:                if (menuGroupId == null) {
160:                    menuGroupId = DEFAULT_MENU_GROUP_ID;
161:                }
162:
163:                /* 
164:                 * The id defaults to the id of the enclosing navigatorContent extension, if any
165:                 * If not enclosed, this can be null initially, so it will default to the 
166:                 * value of the associatedExtensionId
167:                 *  
168:                 * Code elsewhere anticipates that this attribute may be null, so there is 
169:                 * no need to set it to a default non-null value. Indeed, this will cause
170:                 * incorrect behavior. 
171:                 * */
172:                if (id == null) {
173:                    id = configElement
174:                            .getAttribute(ATT_ASSOCIATED_EXTENSION_ID);
175:                }
176:
177:                if (wizardId == null || wizardId.length() == 0) {
178:                    throw new WorkbenchException("Missing attribute: " + //$NON-NLS-1$
179:                            ATT_WIZARD_ID
180:                            + " in common wizard extension: " + //$NON-NLS-1$
181:                            configElement.getDeclaringExtension()
182:                                    .getNamespaceIdentifier());
183:                }
184:
185:                if (type == null || type.length() == 0) {
186:                    throw new WorkbenchException("Missing attribute: " + //$NON-NLS-1$
187:                            ATT_TYPE
188:                            + " in common wizard extension: " + //$NON-NLS-1$
189:                            configElement.getDeclaringExtension()
190:                                    .getNamespaceIdentifier());
191:                }
192:
193:                IConfigurationElement[] children = configElement
194:                        .getChildren(TAG_ENABLEMENT);
195:                if (children.length == 1) {
196:                    try {
197:                        enablement = ElementHandler.getDefault().create(
198:                                ExpressionConverter.getDefault(), children[0]);
199:                    } catch (CoreException e) {
200:                        NavigatorPlugin
201:                                .log(IStatus.ERROR, 0, e.getMessage(), e);
202:                    }
203:                } else if (children.length > 1) {
204:                    throw new WorkbenchException("More than one element: " + //$NON-NLS-1$
205:                            TAG_ENABLEMENT
206:                            + " in common wizard extension: " + //$NON-NLS-1$
207:                            configElement.getDeclaringExtension()
208:                                    .getUniqueIdentifier());
209:                }
210:            }
211:
212:            /**
213:             * 
214:             * @return Returns the common wizard wizardId
215:             */
216:            public String getWizardId() {
217:                return wizardId;
218:            }
219:
220:            /**
221:             * @return Returns the type.
222:             */
223:            public String getType() {
224:                return type;
225:            }
226:
227:            /**
228:             * @return the declaring namespace.
229:             */
230:            public String getNamespace() {
231:                return configElement.getDeclaringExtension()
232:                        .getNamespaceIdentifier();
233:            }
234:
235:            /**
236:             * 
237:             * @return The identifier of the wizard descriptor for visiblity purposes (or null) if none.
238:             */
239:            public String getId() {
240:                return id;
241:            }
242:
243:            /**
244:             * 
245:             * @return A developer-defined logical group that this wizard menu option and 
246:             * 	others like it should be rendered in a localized manner.
247:             */
248:            public String getMenuGroupId() {
249:                return menuGroupId;
250:            }
251:
252:            public String toString() {
253:                return "CommonWizardDescriptor[" + getId() + ", wizardId=" + getWizardId() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
254:            }
255:
256:            /* (non-Javadoc)
257:             * @see org.eclipse.ui.IPluginContribution#getLocalId()
258:             */
259:            public String getLocalId() {
260:                return getId();
261:            }
262:
263:            /* (non-Javadoc)
264:             * @see org.eclipse.ui.IPluginContribution#getPluginId()
265:             */
266:            public String getPluginId() {
267:                return (configElement != null) ? configElement
268:                        .getNamespaceIdentifier() : null;
269:            }
270:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.