Source Code Cross Referenced for LinkHelperDescriptor.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) 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.extensions;
011:
012:        import org.eclipse.core.expressions.EvaluationContext;
013:        import org.eclipse.core.expressions.EvaluationResult;
014:        import org.eclipse.core.expressions.Expression;
015:        import org.eclipse.core.expressions.IEvaluationContext;
016:        import org.eclipse.core.runtime.Assert;
017:        import org.eclipse.core.runtime.CoreException;
018:        import org.eclipse.core.runtime.IConfigurationElement;
019:        import org.eclipse.core.runtime.IStatus;
020:        import org.eclipse.ui.IEditorInput;
021:        import org.eclipse.ui.internal.navigator.CustomAndExpression;
022:        import org.eclipse.ui.internal.navigator.NavigatorPlugin;
023:        import org.eclipse.ui.navigator.ILinkHelper;
024:
025:        /**
026:         * Provides a wrapper around
027:         * <b>org.eclipse.ui.navigator.navigatorContent/linkHelper</b> extensions.
028:         * 
029:         * @since 3.2
030:         * 
031:         */
032:        public class LinkHelperDescriptor implements  ILinkHelperExtPtConstants {
033:
034:            private final IConfigurationElement configElement;
035:
036:            private String id;
037:
038:            private Expression editorInputEnablement;
039:
040:            /* The following field may be null */
041:            private Expression selectionEnablement;
042:
043:            private boolean hasLinkHelperFailedCreation;
044:
045:            /* package */LinkHelperDescriptor(
046:                    IConfigurationElement aConfigElement) {
047:                Assert
048:                        .isNotNull(aConfigElement,
049:                                "LinkHelperRegistry.Descriptor objects cannot be null."); //$NON-NLS-1$
050:                Assert
051:                        .isLegal(LINK_HELPER.equals(aConfigElement.getName()),
052:                                "LinkHelperRegistry.Descriptor objects must have the name \"linkHelper\"."); //$NON-NLS-1$
053:                configElement = aConfigElement;
054:                init();
055:            }
056:
057:            void init() {
058:                id = configElement.getAttribute(ATT_ID);
059:                IConfigurationElement[] expressions = this .configElement
060:                        .getChildren(EDITOR_INPUT_ENABLEMENT);
061:                Assert
062:                        .isLegal(
063:                                expressions.length == 1,
064:                                "The linkHelper extension point requires exactly one editorInputEnablement child."); //$NON-NLS-1$
065:
066:                editorInputEnablement = new CustomAndExpression(expressions[0]);
067:
068:                expressions = configElement.getChildren(SELECTION_ENABLEMENT);
069:                if (expressions.length > 0) {
070:                    /* The following attribute is optional */
071:                    // navigatorContentExtensionId = expressions[0]
072:                    // .getAttribute(ATT_NAVIGATOR_CONTENT_EXTENSION_ID);
073:                    if (expressions[0].getChildren() != null
074:                            && expressions[0].getChildren().length > 0) {
075:
076:                        selectionEnablement = new CustomAndExpression(
077:                                expressions[0]);
078:
079:                    }
080:                }
081:            }
082:
083:            /**
084:             * @return Returns the id.
085:             */
086:            public String getId() {
087:                return id;
088:            }
089:
090:            /**
091:             * Create a link helper instance from this descriptors class attribute.
092:             * 
093:             * @return An instance of the helper that is defined by the extension, or a
094:             *         Skeleton Link Helper.
095:             */
096:            public ILinkHelper createLinkHelper() {
097:                if (hasLinkHelperFailedCreation)
098:                    return SkeletonLinkHelper.INSTANCE;
099:                try {
100:                    return (ILinkHelper) configElement
101:                            .createExecutableExtension(ATT_CLASS);
102:                } catch (Throwable t) {
103:                    hasLinkHelperFailedCreation = true;
104:                    NavigatorPlugin.logError(0, t.getMessage(), t);
105:                }
106:                return SkeletonLinkHelper.INSTANCE;
107:            }
108:
109:            /**
110:             * 
111:             * @param anInput
112:             *            The editor input from the editor that was activated.
113:             * @return True if this linkHelper descriptor can produce a selection from
114:             *         the editor input.
115:             */
116:            public boolean isEnabledFor(IEditorInput anInput) {
117:
118:                if (editorInputEnablement == null || anInput == null) {
119:                    return false;
120:                }
121:
122:                try {
123:                    EvaluationContext context = new EvaluationContext(null,
124:                            anInput);
125:                    context.setAllowPluginActivation(true);
126:                    return (editorInputEnablement.evaluate(context) == EvaluationResult.TRUE);
127:                } catch (CoreException e) {
128:                    NavigatorPlugin.log(IStatus.ERROR, 0, e.getMessage(), e);
129:                }
130:                return false;
131:            }
132:
133:            /**
134:             * @param anObject
135:             *            The selection from the CommonViewer
136:             * @return True if this dscriptor can determine a valid editor to activate
137:             *         from the selection.
138:             */
139:            public boolean isEnabledFor(Object anObject) {
140:                if (selectionEnablement == null) {
141:                    return false;
142:                }
143:
144:                IEvaluationContext context = new EvaluationContext(null,
145:                        anObject);
146:                context.setAllowPluginActivation(true);
147:                try {
148:                    if (selectionEnablement.evaluate(context) != EvaluationResult.TRUE) {
149:                        return false;
150:                    }
151:                } catch (CoreException e) {
152:                    NavigatorPlugin.log(IStatus.ERROR, 0, e.getMessage(), e);
153:                    return false;
154:                }
155:                return true;
156:            }
157:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.