Source Code Cross Referenced for ActiveShellExpression.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 that checks the active shell variable. The variable name is
021:         * <code>ISources.ACTIVE_SHELL_NAME</code> and falls back to
022:         * <code>ISources.ACTIVE_WORKBENCH_WINDOW</code>. That is, if the active
023:         * shell doesn't match, then it will be allowed to match the active workbench
024:         * window.
025:         * </p>
026:         * 
027:         * @since 3.1
028:         */
029:        public final class ActiveShellExpression extends Expression {
030:
031:            /**
032:             * The seed for the hash code for all schemes.
033:             */
034:            private static final int HASH_INITIAL = ActiveShellExpression.class
035:                    .getName().hashCode();
036:
037:            /**
038:             * The sources value to use with this expression.
039:             */
040:            public static final int SOURCES = ISources.ACTIVE_SHELL
041:                    | ISources.ACTIVE_WORKBENCH_WINDOW;
042:
043:            /**
044:             * The shell that must be active for this expression to evaluate to
045:             * <code>true</code>. If this value is <code>null</code>, then any
046:             * shell may be active.
047:             */
048:            private final Shell activeShell;
049:
050:            /**
051:             * Constructs a new instance of <code>ActiveShellExpression</code>
052:             * 
053:             * @param activeShell
054:             *            The shell to match with the active shell; <code>null</code>
055:             *            if it will match any active shell.
056:             */
057:            public ActiveShellExpression(final Shell activeShell) {
058:                this .activeShell = activeShell;
059:            }
060:
061:            /**
062:             * Expression information for this expression.  Namely active shell and 
063:             * active workbench window name.
064:             * 
065:             * @since 3.2
066:             */
067:            public final void collectExpressionInfo(final ExpressionInfo info) {
068:                info.addVariableNameAccess(ISources.ACTIVE_SHELL_NAME);
069:                info
070:                        .addVariableNameAccess(ISources.ACTIVE_WORKBENCH_WINDOW_NAME);
071:            }
072:
073:            protected final int computeHashCode() {
074:                return HASH_INITIAL * HASH_FACTOR + hashCode(activeShell);
075:            }
076:
077:            public final boolean equals(final Object object) {
078:                if (object instanceof  ActiveShellExpression) {
079:                    final ActiveShellExpression that = (ActiveShellExpression) object;
080:                    return equals(this .activeShell, that.activeShell);
081:                }
082:
083:                return false;
084:            }
085:
086:            /**
087:             * Evaluates this expression. If the active shell defined by the context
088:             * matches the shell from this expression, then this evaluates to
089:             * <code>EvaluationResult.TRUE</code>. Similarly, if the active workbench
090:             * window shell defined by the context matches the shell from this
091:             * expression, then this evaluates to <code>EvaluationResult.TRUE</code>.
092:             * 
093:             * @param context
094:             *            The context from which the current state is determined; must
095:             *            not be <code>null</code>.
096:             * @return <code>EvaluationResult.TRUE</code> if the shell is active;
097:             *         <code>EvaluationResult.FALSE</code> otherwise.
098:             */
099:            public final EvaluationResult evaluate(
100:                    final IEvaluationContext context) {
101:                if (activeShell != null) {
102:                    Object value = context
103:                            .getVariable(ISources.ACTIVE_SHELL_NAME);
104:                    if (!activeShell.equals(value)) {
105:                        value = context
106:                                .getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_SHELL_NAME);
107:                        if (!activeShell.equals(value)) {
108:                            return EvaluationResult.FALSE;
109:                        }
110:                    }
111:                }
112:
113:                return EvaluationResult.TRUE;
114:            }
115:
116:            public final String toString() {
117:                final StringBuffer buffer = new StringBuffer();
118:                buffer.append("ActiveShellExpression("); //$NON-NLS-1$
119:                buffer.append(activeShell);
120:                buffer.append(')');
121:                return buffer.toString();
122:            }
123:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.