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


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 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;
011:
012:        import org.eclipse.core.runtime.IConfigurationElement;
013:        import org.eclipse.core.runtime.ISafeRunnable;
014:        import org.eclipse.core.runtime.Platform;
015:        import org.eclipse.jface.viewers.StructuredSelection;
016:        import org.eclipse.ui.IActionDelegate;
017:        import org.eclipse.ui.IObjectActionDelegate;
018:        import org.eclipse.ui.IPartListener2;
019:        import org.eclipse.ui.IWorkbenchPart;
020:        import org.eclipse.ui.IWorkbenchPartReference;
021:
022:        /**
023:         * An object action extension in a popup menu.
024:         * <p>
025:         * For backward compatibility, the delegate object can implement either
026:         * <code>IActionDelegate</code> or <code>IObjectActionDelegate</code>.
027:         * </p>
028:         */
029:        public class ObjectPluginAction extends PluginAction implements 
030:                IPartListener2 {
031:            /**
032:             * The configuration element attribute for the identifier of the action
033:             * which this action is intended to override (i.e., replace).
034:             */
035:            public static final String ATT_OVERRIDE_ACTION_ID = "overrideActionId";//$NON-NLS-1$
036:
037:            private String overrideActionId;
038:
039:            private IWorkbenchPart activePart;
040:
041:            public void partActivated(IWorkbenchPartReference partRef) {
042:            }
043:
044:            public void partBroughtToTop(IWorkbenchPartReference partRef) {
045:            }
046:
047:            public void partClosed(IWorkbenchPartReference partRef) {
048:                if (activePart != null && partRef.getPart(false) == activePart) {
049:                    selectionChanged(StructuredSelection.EMPTY);
050:                    disposeDelegate();
051:                    activePart = null;
052:                }
053:            }
054:
055:            public void partDeactivated(IWorkbenchPartReference partRef) {
056:            }
057:
058:            public void partHidden(IWorkbenchPartReference partRef) {
059:            }
060:
061:            public void partInputChanged(IWorkbenchPartReference partRef) {
062:            }
063:
064:            public void partOpened(IWorkbenchPartReference partRef) {
065:            }
066:
067:            public void partVisible(IWorkbenchPartReference partRef) {
068:            }
069:
070:            /**
071:             * Constructs a new ObjectPluginAction.
072:             * 
073:             * @param actionElement
074:             *            The configuration element used to construct this action; must
075:             *            not be <code>null</code>.
076:             * @param id
077:             *            The identifier for this action; must not be <code>null</code>.
078:             * @param style
079:             *            The style bits
080:             */
081:            public ObjectPluginAction(IConfigurationElement actionElement,
082:                    String id, int style) {
083:                super (actionElement, id, style);
084:                overrideActionId = actionElement
085:                        .getAttribute(ATT_OVERRIDE_ACTION_ID);
086:            }
087:
088:            /* (non-Javadoc)
089:             * Method declared on PluginAction.
090:             */
091:            protected void initDelegate() {
092:                super .initDelegate();
093:                final IActionDelegate actionDelegate = getDelegate();
094:                if (actionDelegate instanceof  IObjectActionDelegate
095:                        && activePart != null) {
096:                    final IObjectActionDelegate objectActionDelegate = (IObjectActionDelegate) actionDelegate;
097:                    final ISafeRunnable runnable = new ISafeRunnable() {
098:                        public void run() throws Exception {
099:                            objectActionDelegate.setActivePart(
100:                                    ObjectPluginAction.this , activePart);
101:                        }
102:
103:                        public void handleException(Throwable exception) {
104:                            // Do nothing.
105:                        }
106:                    };
107:                    Platform.run(runnable);
108:                }
109:            }
110:
111:            /**
112:             * Sets the active part for the delegate.
113:             * <p>
114:             * This method will be called every time the action appears in a popup menu.
115:             * The targetPart may change with each invocation.
116:             * </p>
117:             * 
118:             * @param targetPart
119:             *            the new part target
120:             */
121:            public void setActivePart(IWorkbenchPart targetPart) {
122:                if (activePart != targetPart) {
123:                    if (activePart != null) {
124:                        activePart.getSite().getPage().removePartListener(this );
125:                    }
126:                    if (targetPart != null) {
127:                        targetPart.getSite().getPage().addPartListener(this );
128:                    }
129:                }
130:                activePart = targetPart;
131:                IActionDelegate delegate = getDelegate();
132:                if (delegate instanceof  IObjectActionDelegate
133:                        && activePart != null) {
134:                    final IObjectActionDelegate objectActionDelegate = (IObjectActionDelegate) delegate;
135:                    final ISafeRunnable runnable = new ISafeRunnable() {
136:                        public void run() throws Exception {
137:                            objectActionDelegate.setActivePart(
138:                                    ObjectPluginAction.this , activePart);
139:                        }
140:
141:                        public void handleException(Throwable exception) {
142:                            // Do nothing.
143:                        }
144:                    };
145:                    Platform.run(runnable);
146:                }
147:            }
148:
149:            /**
150:             * Returns the action identifier this action overrides.
151:             * 
152:             * @return the action identifier to override or <code>null</code>
153:             */
154:            public String getOverrideActionId() {
155:                return overrideActionId;
156:            }
157:
158:            /* (non-Javadoc)
159:             * @see org.eclipse.ui.internal.PluginAction#dispose()
160:             */
161:            public void dispose() {
162:                if (activePart != null) {
163:                    activePart.getSite().getPage().removePartListener(this);
164:                    activePart = null;
165:                }
166:                super.dispose();
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.