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


001:        /*******************************************************************************
002:         * Copyright (c) 2003, 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.internal.navigator.extensions;
011:
012:        import java.util.HashSet;
013:        import java.util.Properties;
014:        import java.util.Set;
015:
016:        import org.eclipse.core.runtime.IConfigurationElement;
017:        import org.eclipse.core.runtime.IStatus;
018:        import org.eclipse.osgi.util.NLS;
019:        import org.eclipse.ui.internal.navigator.CommonNavigatorMessages;
020:        import org.eclipse.ui.internal.navigator.NavigatorPlugin;
021:        import org.eclipse.ui.navigator.CommonActionProvider;
022:        import org.eclipse.ui.navigator.INavigatorViewerDescriptor;
023:        import org.eclipse.ui.navigator.MenuInsertionPoint;
024:        import org.eclipse.ui.navigator.NavigatorActionService;
025:
026:        /**
027:         * Encapsulates the <code>org.eclipse.ui.navigator.viewer</code> extension.
028:         * <p>
029:         * 
030:         * @since 3.2
031:         */
032:        public final class NavigatorViewerDescriptor implements 
033:                INavigatorViewerDescriptor {
034:
035:            /**
036:             * {@value} (boolean): True indicates the ITreeContentProvider.hasChildren() 
037:             * should force plugins to load if necessary <b>false</b>).
038:             */
039:            public static final String PROP_ENFORCE_HAS_CHILDREN = "org.eclipse.ui.navigator.enforceHasChildren"; //$NON-NLS-1$
040:
041:            static final String TAG_INCLUDES = "includes"; //$NON-NLS-1$
042:
043:            static final String TAG_EXCLUDES = "excludes"; //$NON-NLS-1$
044:
045:            static final String ATT_IS_ROOT = "isRoot"; //$NON-NLS-1$
046:
047:            static final String ATT_PATTERN = "pattern"; //$NON-NLS-1$
048:
049:            private static final String TAG_CONTENT_EXTENSION = "contentExtension"; //$NON-NLS-1$
050:
051:            private static final String TAG_ACTION_EXTENSION = "actionExtension"; //$NON-NLS-1$ 
052:
053:            private final String viewerId;
054:
055:            private String popupMenuId = null;
056:
057:            private Binding actionBinding = new Binding(TAG_ACTION_EXTENSION);
058:
059:            private Binding contentBinding = new Binding(TAG_CONTENT_EXTENSION);
060:
061:            private MenuInsertionPoint[] customInsertionPoints = null;
062:
063:            private boolean allowsPlatformContributions = true;
064:
065:            private final Properties properties = new Properties();
066:
067:            private Set dragAssistants;
068:
069:            /**
070:             * Creates a new content descriptor from a configuration element.
071:             * 
072:             * @param aViewerId
073:             *            The identifier for this descriptor.
074:             */
075:            /* package */NavigatorViewerDescriptor(String aViewerId) {
076:                super ();
077:                this .viewerId = aViewerId;
078:            }
079:
080:            /*
081:             * (non-Javadoc)
082:             * 
083:             * @see org.eclipse.ui.internal.navigator.extensions.INavigatorViewerDescriptor#getViewerId()
084:             */
085:            public String getViewerId() {
086:                return viewerId;
087:            }
088:
089:            /*
090:             * (non-Javadoc)
091:             * 
092:             * @see org.eclipse.ui.internal.navigator.extensions.INavigatorViewerDescriptor#getPopupMenuId()
093:             */
094:            public String getPopupMenuId() {
095:                return popupMenuId != null ? popupMenuId : viewerId;
096:            }
097:
098:            /**
099:             * Consume an action binding for this viewer.
100:             * 
101:             * @param element
102:             *            The IConfigurationElement containing a viewerActionBinding
103:             *            element.
104:             */
105:            public void consumeActionBinding(IConfigurationElement element) {
106:                consumeBinding(element, false);
107:            }
108:
109:            /**
110:             * Consume a content binding for this viewer.
111:             * 
112:             * @param element
113:             *            The IConfigurationElement containing a viewerContentBinding
114:             *            element.
115:             */
116:            public void consumeContentBinding(IConfigurationElement element) {
117:                consumeBinding(element, true);
118:            }
119:
120:            public boolean isRootExtension(String aContentExtensionId) {
121:                return contentBinding.isRootExtension(aContentExtensionId);
122:            }
123:
124:            public boolean allowsPlatformContributionsToContextMenu() {
125:                return allowsPlatformContributions;
126:            }
127:
128:            public boolean isVisibleContentExtension(String aContentExtensionId) {
129:                return contentBinding.isVisibleExtension(aContentExtensionId);
130:            }
131:
132:            public boolean isVisibleActionExtension(String anActionExtensionId) {
133:                return actionBinding.isVisibleExtension(anActionExtensionId);
134:            }
135:
136:            public boolean hasOverriddenRootExtensions() {
137:                return contentBinding.hasOverriddenRootExtensions();
138:            }
139:
140:            public MenuInsertionPoint[] getCustomInsertionPoints() {
141:                return customInsertionPoints;
142:            }
143:
144:            /**
145:             * 
146:             * @param newCustomInsertionPoints
147:             *            The set of custom insertion points, if any. A null list
148:             *            indicates the default set (as defined by
149:             *            {@link NavigatorActionService}) should be used. An empty list
150:             *            indicates there are no declarative insertion points.
151:             */
152:            public void setCustomInsertionPoints(
153:                    MenuInsertionPoint[] newCustomInsertionPoints) {
154:                if (customInsertionPoints != null) {
155:                    NavigatorPlugin
156:                            .logError(
157:                                    0,
158:                                    "Attempt to override custom insertion points denied. Verify there are no colliding org.eclipse.ui.navigator.viewer extension points.", null); //$NON-NLS-1$
159:                    return; // do not let them override the insertion points.
160:                }
161:                customInsertionPoints = newCustomInsertionPoints;
162:            }
163:
164:            /**
165:             * 
166:             * @param toAllowPlatformContributions
167:             *            A value of 'true' enables object/viewer contributions. 'false'
168:             *            will only allow programmatic contributions from
169:             *            {@link CommonActionProvider}s.
170:             */
171:            public void setAllowsPlatformContributions(
172:                    boolean toAllowPlatformContributions) {
173:                allowsPlatformContributions = toAllowPlatformContributions;
174:            }
175:
176:            /*
177:             * (non-Javadoc)
178:             * 
179:             * @see org.eclipse.ui.navigator.INavigatorViewerDescriptor#getStringConfigProperty(java.lang.String)
180:             */
181:            public String getStringConfigProperty(String aPropertyName) {
182:                return properties.getProperty(aPropertyName);
183:            }
184:
185:            /*
186:             * (non-Javadoc)
187:             * 
188:             * @see org.eclipse.ui.navigator.INavigatorViewerDescriptor#getBooleanConfigProperty(java.lang.String)
189:             */
190:            public boolean getBooleanConfigProperty(String aPropertyName) {
191:                String propValue = properties.getProperty(aPropertyName);
192:                if (propValue == null) {
193:                    return false;
194:                }
195:                return Boolean.valueOf(propValue).booleanValue();
196:            }
197:
198:            /* package */void setProperty(String aPropertyName,
199:                    String aPropertyValue) {
200:                properties.setProperty(aPropertyName, aPropertyValue);
201:            }
202:
203:            /*
204:             * (non-Javadoc)
205:             * 
206:             * @see java.lang.Object#toString()
207:             */
208:            public String toString() {
209:                return "ViewerDescriptor[" + viewerId + "]"; //$NON-NLS-1$ //$NON-NLS-2$
210:            }
211:
212:            /**
213:             * Update the popupMenuId. If a value is already set, then a warning message
214:             * will be logged.
215:             * 
216:             * @param newPopupMenuId
217:             *            The new popup menu id.
218:             */
219:            /* package */void setPopupMenuId(String newPopupMenuId) {
220:
221:                if (newPopupMenuId != null) {
222:                    if (popupMenuId != null) {
223:                        NavigatorPlugin
224:                                .log(
225:                                        IStatus.WARNING,
226:                                        0,
227:                                        NLS
228:                                                .bind(
229:                                                        CommonNavigatorMessages.NavigatorViewerDescriptor_Popup_Menu_Overridden,
230:                                                        new Object[] {
231:                                                                getViewerId(),
232:                                                                popupMenuId,
233:                                                                newPopupMenuId }),
234:                                        null);
235:                    }
236:                    popupMenuId = newPopupMenuId;
237:                }
238:            }
239:
240:            /**
241:             * @param descriptor
242:             *            A non-null descriptor to add
243:             */
244:            /* package */void addDragAssistant(
245:                    CommonDragAssistantDescriptor descriptor) {
246:                getDragAssistants().add(descriptor);
247:
248:            }
249:
250:            /**
251:             * 
252:             * @return The set of {@link CommonDragAssistantDescriptor}s for this
253:             *         viewer.
254:             */
255:            public Set getDragAssistants() {
256:                if (dragAssistants == null) {
257:                    dragAssistants = new HashSet();
258:                }
259:                return dragAssistants;
260:            }
261:
262:            private void consumeBinding(IConfigurationElement element,
263:                    boolean isContent) {
264:                IConfigurationElement[] includesElement = element
265:                        .getChildren(TAG_INCLUDES);
266:
267:                if (includesElement.length == 1) {
268:                    if (isContent) {
269:                        contentBinding
270:                                .consumeIncludes(includesElement[0], true);
271:                    } else {
272:                        actionBinding
273:                                .consumeIncludes(includesElement[0], false);
274:                    }
275:                } else if (includesElement.length >= 1) {
276:                    NavigatorPlugin.logError(0, NLS.bind(
277:                            CommonNavigatorMessages.Too_many_elements_Warning,
278:                            new Object[] {
279:                                    TAG_INCLUDES,
280:                                    element.getDeclaringExtension()
281:                                            .getUniqueIdentifier(),
282:                                    element.getDeclaringExtension()
283:                                            .getNamespaceIdentifier() }), null);
284:                }
285:
286:                IConfigurationElement[] excludesElement = element
287:                        .getChildren(TAG_EXCLUDES);
288:
289:                if (excludesElement.length == 1) {
290:
291:                    if (isContent) {
292:                        contentBinding.consumeExcludes(excludesElement[0]);
293:                    } else {
294:                        actionBinding.consumeExcludes(excludesElement[0]);
295:                    }
296:                } else if (excludesElement.length >= 1) {
297:                    NavigatorPlugin.logError(0, NLS.bind(
298:                            CommonNavigatorMessages.Too_many_elements_Warning,
299:                            new Object[] {
300:                                    TAG_EXCLUDES,
301:                                    element.getDeclaringExtension()
302:                                            .getUniqueIdentifier(),
303:                                    element.getDeclaringExtension()
304:                                            .getNamespaceIdentifier() }), null);
305:                }
306:            }
307:
308:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.