Source Code Cross Referenced for LegacyHandlerSubmissionExpression.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » 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 
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;
011:
012:        import org.eclipse.core.expressions.EvaluationResult;
013:        import org.eclipse.core.expressions.Expression;
014:        import org.eclipse.core.expressions.ExpressionInfo;
015:        import org.eclipse.core.expressions.IEvaluationContext;
016:        import org.eclipse.swt.widgets.Shell;
017:
018:        /**
019:         * <p>
020:         * An expression encapsulating all of the information from legacy handler
021:         * submissions.
022:         * </p>
023:         * 
024:         * @since 3.1
025:         */
026:        public final class LegacyHandlerSubmissionExpression extends Expression {
027:
028:            /**
029:             * The seed for the hash code for all schemes.
030:             */
031:            private static final int HASH_INITIAL = LegacyHandlerSubmissionExpression.class
032:                    .getName().hashCode();
033:
034:            /**
035:             * The identifier for the part that must be active for this expression to
036:             * evaluate to <code>true</code>. If this value is <code>null</code>,
037:             * then any part may be active.
038:             */
039:            private final String activePartId;
040:
041:            /**
042:             * The shell that must be active for this expression to evaluate to
043:             * <code>true</code>. If this value is <code>null</code>, then any
044:             * shell may be active.
045:             */
046:            private final Shell activeShell;
047:
048:            /**
049:             * The site that must be active for this expression to evaluate to
050:             * <code>true</code>. If this value is <code>null</code>, then any
051:             * site may be active.
052:             */
053:            private final IWorkbenchPartSite activeSite;
054:
055:            /**
056:             * Constructs a new instance of
057:             * <code>LegacyHandlerSubmissionExpression</code>
058:             * 
059:             * @param activePartId
060:             *            The part identifier to match with the active part;
061:             *            <code>null</code> if it will match any active part.
062:             * @param activeShell
063:             *            The shell to match with the active shell; <code>null</code>
064:             *            if it will match any active shell.
065:             * @param activeSite
066:             *            The site to match with the active site; <code>null</code> if
067:             *            it will match any active site.
068:             */
069:            public LegacyHandlerSubmissionExpression(final String activePartId,
070:                    final Shell activeShell, final IWorkbenchPartSite activeSite) {
071:
072:                this .activePartId = activePartId;
073:                this .activeShell = activeShell;
074:                this .activeSite = activeSite;
075:            }
076:
077:            /**
078:             * Collect expression info for a legacy handler submission.  Namely 
079:             * the active part id and name, active shell name, active workbench
080:             * window shell name and the active site name.
081:             * 
082:             * @since 3.2
083:             */
084:            public final void collectExpressionInfo(final ExpressionInfo info) {
085:                if (activePartId != null) {
086:                    info.addVariableNameAccess(ISources.ACTIVE_PART_ID_NAME);
087:                }
088:                if (activeShell != null) {
089:                    info.addVariableNameAccess(ISources.ACTIVE_SHELL_NAME);
090:                    info
091:                            .addVariableNameAccess(ISources.ACTIVE_WORKBENCH_WINDOW_SHELL_NAME);
092:                }
093:                if (activeSite != null) {
094:                    info.addVariableNameAccess(ISources.ACTIVE_SITE_NAME);
095:                }
096:            }
097:
098:            protected final int computeHashCode() {
099:                int hashCode = HASH_INITIAL * HASH_FACTOR
100:                        + hashCode(activePartId);
101:                hashCode = hashCode * HASH_FACTOR + hashCode(activeShell);
102:                hashCode = hashCode * HASH_FACTOR + hashCode(activeSite);
103:                return hashCode;
104:            }
105:
106:            public final boolean equals(final Object object) {
107:                if (object instanceof  LegacyHandlerSubmissionExpression) {
108:                    final LegacyHandlerSubmissionExpression that = (LegacyHandlerSubmissionExpression) object;
109:                    return equals(this .activePartId, that.activePartId)
110:                            && equals(this .activeShell, that.activeShell)
111:                            && equals(this .activeSite, that.activeSite);
112:                }
113:
114:                return false;
115:            }
116:
117:            /**
118:             * Evaluates this expression. This tests the three conditions against the
119:             * current state of the application (as defined by <code>context</code>).
120:             * If a condition is <code>null</code>, then it matches any possible
121:             * value (i.e., it is not tested at all).
122:             * 
123:             * @param context
124:             *            The context providing the current workbench state; must not be
125:             *            <code>null</code>.
126:             * @return <code>EvaluationResult.TRUE</code> if the conditions all
127:             *         matches; <code>EvaluationResult.FALSE</code> otherwise.
128:             */
129:            public final EvaluationResult evaluate(
130:                    final IEvaluationContext context) {
131:                if (activePartId != null) {
132:                    final Object value = context
133:                            .getVariable(ISources.ACTIVE_PART_ID_NAME);
134:                    if (!activePartId.equals(value)) {
135:                        return EvaluationResult.FALSE;
136:                    }
137:                }
138:
139:                if (activeShell != null) {
140:                    Object value = context
141:                            .getVariable(ISources.ACTIVE_SHELL_NAME);
142:                    if (!activeShell.equals(value)) {
143:                        value = context
144:                                .getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_SHELL_NAME);
145:                        if (!activeShell.equals(value)) {
146:                            return EvaluationResult.FALSE;
147:                        }
148:                    }
149:                }
150:
151:                if (activeSite != null) {
152:                    final Object value = context
153:                            .getVariable(ISources.ACTIVE_SITE_NAME);
154:                    if (!activeSite.equals(value)) {
155:                        return EvaluationResult.FALSE;
156:                    }
157:                }
158:
159:                return EvaluationResult.TRUE;
160:            }
161:
162:            public final String toString() {
163:                final StringBuffer buffer = new StringBuffer();
164:                buffer.append("LegacyHandlerSubmission("); //$NON-NLS-1$
165:                buffer.append(activeShell);
166:                buffer.append(',');
167:                buffer.append(activePartId);
168:                buffer.append(',');
169:                buffer.append(activeSite);
170:                buffer.append(')');
171:                return buffer.toString();
172:            }
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.