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


001:        /*******************************************************************************
002:         * Copyright (c) 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;
011:
012:        import java.util.HashSet;
013:        import java.util.Set;
014:
015:        import org.eclipse.core.runtime.Assert;
016:        import org.eclipse.core.runtime.ListenerList;
017:        import org.eclipse.ui.navigator.IExtensionActivationListener;
018:        import org.eclipse.ui.navigator.INavigatorActivationService;
019:        import org.eclipse.ui.navigator.INavigatorContentDescriptor;
020:        import org.eclipse.ui.navigator.INavigatorContentService;
021:        import org.eclipse.ui.navigator.INavigatorViewerDescriptor;
022:
023:        /**
024:         * Stores information about programmatic bindings and activation settings.
025:         * 
026:         */
027:        public class VisibilityAssistant implements 
028:                IExtensionActivationListener {
029:
030:            private final INavigatorViewerDescriptor viewerDescriptor;
031:
032:            private final Set programmaticVisibilityBindings = new HashSet();
033:
034:            private final Set programmaticRootBindings = new HashSet();
035:
036:            private final ListenerList listeners = new ListenerList();
037:
038:            private final INavigatorActivationService activationService;
039:
040:            /**
041:             * Notifies clients of changes in extension visibility or activation.
042:             * 
043:             */
044:            public interface VisibilityListener {
045:
046:                /**
047:                 * Respond to the change in visibility or activation.
048:                 * 
049:                 */
050:                void onVisibilityOrActivationChange();
051:            }
052:
053:            /**
054:             * Create a visibility assistant for the given viewer descriptor.
055:             * 
056:             * @param aViewerDescriptor
057:             *            A non-nullviewer descriptor.
058:             * @param anActivationService
059:             *            The activation service associated with the content service.
060:             */
061:            public VisibilityAssistant(
062:                    INavigatorViewerDescriptor aViewerDescriptor,
063:                    INavigatorActivationService anActivationService) {
064:                Assert.isNotNull(aViewerDescriptor);
065:                viewerDescriptor = aViewerDescriptor;
066:
067:                activationService = anActivationService;
068:                activationService.addExtensionActivationListener(this );
069:            }
070:
071:            /**
072:             * Dispose of any resources held onto by this assistant.
073:             * 
074:             */
075:            public void dispose() {
076:                activationService.removeExtensionActivationListener(this );
077:            }
078:
079:            /**
080:             * 
081:             * @param theExtensions
082:             *            The extensions that should be made visible to the viewer.
083:             * @param isRoot
084:             */
085:            public void bindExtensions(String[] theExtensions, boolean isRoot) {
086:                if (theExtensions == null) {
087:                    return;
088:                }
089:                for (int i = 0; i < theExtensions.length; i++) {
090:                    programmaticVisibilityBindings.add(theExtensions[i]);
091:                    if (isRoot) {
092:                        programmaticRootBindings.add(theExtensions[i]);
093:                    }
094:                }
095:                notifyClients();
096:            }
097:
098:            /**
099:             * Add a listener to be notified when the visibility or activation state
100:             * associated with this assistant changes.
101:             * 
102:             * @param aListener
103:             *            a listener to be notified when the visibility or activation
104:             *            state associated with this assistant changes.
105:             */
106:            public void addListener(VisibilityListener aListener) {
107:                listeners.add(aListener);
108:            }
109:
110:            /**
111:             * Remove a listener to be notified when the visibility or activation state
112:             * associated with this assistant changes.
113:             * 
114:             * @param aListener
115:             *            a listener to be notified when the visibility or activation
116:             *            state associated with this assistant changes.
117:             */
118:            public void removeListener(VisibilityListener aListener) {
119:                listeners.remove(aListener);
120:            }
121:
122:            private void notifyClients() {
123:                Object[] clients = listeners.getListeners();
124:                for (int i = 0; i < clients.length; i++) {
125:                    ((VisibilityListener) clients[i])
126:                            .onVisibilityOrActivationChange();
127:                }
128:            }
129:
130:            /**
131:             * 
132:             * @param aContentDescriptor
133:             *            The content descriptor of inquiry
134:             * @return True if and only if the content descriptor is <i>active</i> and
135:             *         <i>visible</i> for the viewer descriptor and enabled for the
136:             *         given element.
137:             */
138:            public boolean isVisibleAndActive(
139:                    INavigatorContentDescriptor aContentDescriptor) {
140:                return isActive(aContentDescriptor)
141:                        && isVisible(aContentDescriptor);
142:            }
143:
144:            /**
145:             * 
146:             * @param aContentDescriptor
147:             *            The content descriptor of inquiry
148:             * @return True if and only if the given extension is <i>active</i>
149:             * 
150:             * @see INavigatorContentService For more information on what <i>active</i>
151:             *      means.
152:             * @see INavigatorActivationService#activateExtensions(String[], boolean)
153:             * @see INavigatorActivationService#deactivateExtensions(String[], boolean)
154:             */
155:            public boolean isActive(
156:                    INavigatorContentDescriptor aContentDescriptor) {
157:                return activationService
158:                        .isNavigatorExtensionActive(aContentDescriptor.getId());
159:            }
160:
161:            /**
162:             * 
163:             * @param aContentExtensionId
164:             *            The unique id of the content extension
165:             * @return True if and only if the given extension is <i>active</i>
166:             * @see INavigatorContentService For more information on what <i>active</i>
167:             *      means.
168:             * @see INavigatorActivationService#activateExtensions(String[], boolean)
169:             * @see INavigatorActivationService#deactivateExtensions(String[], boolean)
170:             */
171:            public boolean isActive(String aContentExtensionId) {
172:                return activationService
173:                        .isNavigatorExtensionActive(aContentExtensionId);
174:            }
175:
176:            /**
177:             * 
178:             * @param aContentDescriptor
179:             *            The content descriptor of inquiry
180:             * @return True if and only if the given content extension is declaratively
181:             *         or programmatically made visible to the viewer.
182:             * @see INavigatorContentService#bindExtensions(String[], boolean) For more
183:             *      information on what <i>visible</i> means.
184:             */
185:            public boolean isVisible(
186:                    INavigatorContentDescriptor aContentDescriptor) {
187:                return programmaticVisibilityBindings
188:                        .contains(aContentDescriptor.getId())
189:                        || viewerDescriptor
190:                                .isVisibleContentExtension(aContentDescriptor
191:                                        .getId());
192:            }
193:
194:            /**
195:             * 
196:             * @param aContentExtensionId
197:             *            The unique id of the content extension
198:             * @return True if and only if the given content extension is declaratively
199:             *         or programmatically made visible to the viewer.
200:             * @see INavigatorContentService#bindExtensions(String[], boolean) For more
201:             *      information on what <i>visible</i> means.
202:             */
203:            public boolean isVisible(String aContentExtensionId) {
204:                return programmaticVisibilityBindings
205:                        .contains(aContentExtensionId)
206:                        || viewerDescriptor
207:                                .isVisibleContentExtension(aContentExtensionId);
208:            }
209:
210:            /**
211:             * Return whether the given content extension is a root extension.
212:             * 
213:             * @param aContentExtensionId
214:             *            the id of the content extension.
215:             * @return whether the given content extension is a root extension
216:             */
217:            public boolean isRootExtension(String aContentExtensionId) {
218:                return programmaticRootBindings.contains(aContentExtensionId)
219:                        || viewerDescriptor
220:                                .isRootExtension(aContentExtensionId);
221:            }
222:
223:            /*
224:             * (non-Javadoc)
225:             * 
226:             * @see org.eclipse.ui.navigator.IExtensionActivationListener#onExtensionActivation(java.lang.String,
227:             *      java.lang.String[], boolean)
228:             */
229:            public void onExtensionActivation(String aViewerId,
230:                    String[] theNavigatorExtensionIds, boolean isActive) {
231:                if (aViewerId.equals(viewerDescriptor.getViewerId())) {
232:                    notifyClients();
233:                }
234:
235:            }
236:
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.