Source Code Cross Referenced for AbstractWorkingSet.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) 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;
011:
012:        import java.util.ArrayList;
013:
014:        import org.eclipse.core.runtime.Assert;
015:        import org.eclipse.core.runtime.IAdaptable;
016:        import org.eclipse.core.runtime.Platform;
017:        import org.eclipse.jface.resource.ImageDescriptor;
018:        import org.eclipse.ui.IMemento;
019:        import org.eclipse.ui.IPersistableElement;
020:        import org.eclipse.ui.IWorkingSet;
021:        import org.eclipse.ui.IWorkingSetManager;
022:        import org.eclipse.ui.internal.util.Util;
023:
024:        /**
025:         * Abstract baseclass for IWorkingSet implementations.
026:         * 
027:         * @since 3.2
028:         */
029:        public abstract class AbstractWorkingSet implements  IAdaptable,
030:                IWorkingSet {
031:
032:            protected static final String FACTORY_ID = "org.eclipse.ui.internal.WorkingSetFactory"; //$NON-NLS-1$
033:
034:            static final String TAG_AGGREGATE = "aggregate"; //$NON-NLS-1$
035:
036:            private String name;
037:
038:            protected ArrayList elements;
039:
040:            private IWorkingSetManager manager;
041:
042:            protected IMemento workingSetMemento;
043:
044:            private String label;
045:
046:            /**
047:             * Whether or not the label value should follow the name value. It should do
048:             * this until a call to setLabel() differentiates it from the name.
049:             */
050:            private boolean labelBoundToName;
051:
052:            /**
053:             * Create a new instance of this class
054:             * 
055:             * @param name the unique name for this working set
056:             * @param label the user-friendly name for this working set
057:             */
058:            public AbstractWorkingSet(String name, String label) {
059:                Assert.isNotNull(name, "name must not be null"); //$NON-NLS-1$
060:                this .name = name;
061:                this .label = label;
062:                labelBoundToName = Util.equals(name, label);
063:            }
064:
065:            /**
066:             * Returns the receiver if the requested type is either IWorkingSet 
067:             * or IPersistableElement.
068:             * 
069:             * @param adapter the requested type
070:             * @return the receiver if the requested type is either IWorkingSet 
071:             * 	or IPersistableElement.
072:             */
073:            public Object getAdapter(Class adapter) {
074:                if (adapter == IWorkingSet.class
075:                        || adapter == IPersistableElement.class) {
076:                    return this ;
077:                }
078:                return Platform.getAdapterManager().getAdapter(this , adapter);
079:            }
080:
081:            public String getName() {
082:                return name;
083:            }
084:
085:            public void setName(String newName) {
086:                Assert.isNotNull(newName, "Working set name must not be null"); //$NON-NLS-1$
087:
088:                name = newName;
089:                fireWorkingSetChanged(
090:                        IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE, null);
091:
092:                if (labelBoundToName) {
093:                    label = newName;
094:                    fireWorkingSetChanged(
095:                            IWorkingSetManager.CHANGE_WORKING_SET_LABEL_CHANGE,
096:                            null);
097:                }
098:            }
099:
100:            /**
101:             * Connect this working set to a manger. 
102:             * 
103:             * @param manager the manager to connect to
104:             */
105:            public void connect(IWorkingSetManager manager) {
106:                Assert.isTrue(this .manager == null,
107:                        "A working set can only be connected to one manager"); //$NON-NLS-1$
108:                this .manager = manager;
109:            }
110:
111:            /**
112:             * Disconnet this working set from its manager, if any.
113:             */
114:            public void disconnect() {
115:                this .manager = null;
116:            }
117:
118:            protected void fireWorkingSetChanged(String property,
119:                    Object oldValue) {
120:                AbstractWorkingSetManager receiver = manager != null ? (AbstractWorkingSetManager) manager
121:                        : (AbstractWorkingSetManager) WorkbenchPlugin
122:                                .getDefault().getWorkingSetManager();
123:                receiver.workingSetChanged(this , property, oldValue);
124:            }
125:
126:            /**
127:             * Create a copy of the elements to store in the receiver.
128:             * 
129:             * @param elements the elements to store a copy of in the 
130:             * 	receiver.
131:             */
132:            protected void internalSetElements(IAdaptable[] newElements) {
133:                Assert.isNotNull(newElements,
134:                        "Working set elements array must not be null"); //$NON-NLS-1$
135:
136:                elements = new ArrayList(newElements.length);
137:                for (int i = 0; i < newElements.length; i++) {
138:                    elements.add(newElements[i]);
139:                }
140:            }
141:
142:            public IAdaptable[] getElements() {
143:                ArrayList list = getElementsArray();
144:                return (IAdaptable[]) list.toArray(new IAdaptable[list.size()]);
145:            }
146:
147:            /**
148:             * Returns the elements array list. Lazily restores the elements from
149:             * persistence memento. 
150:             * 
151:             * @return the elements array list
152:             */
153:            protected ArrayList getElementsArray() {
154:                if (elements == null) {
155:                    restoreWorkingSet();
156:                    workingSetMemento = null;
157:                }
158:                return elements;
159:            }
160:
161:            abstract void restoreWorkingSet();
162:
163:            protected IWorkingSetManager getManager() {
164:                return manager;
165:            }
166:
167:            public String getFactoryId() {
168:                return FACTORY_ID;
169:            }
170:
171:            public String getLabel() {
172:                return label;
173:            }
174:
175:            public void setLabel(String label) {
176:                this .label = label == null ? getName() : label;
177:                labelBoundToName = Util.equals(label, name); // rebind the label to the name
178:
179:                fireWorkingSetChanged(
180:                        IWorkingSetManager.CHANGE_WORKING_SET_LABEL_CHANGE,
181:                        null);
182:            }
183:
184:            public boolean isEmpty() {
185:                return getElementsArray().isEmpty();
186:            }
187:
188:            /*
189:             * (non-Javadoc)
190:             * @see org.eclipse.ui.IWorkingSet#getImage()
191:             */
192:            public final ImageDescriptor getImage() {
193:                return getImageDescriptor();
194:            }
195:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.