Source Code Cross Referenced for Category.java in  » IDE-Eclipse » ui » org » eclipse » ui » internal » cheatsheets » registry » 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.cheatsheets.registry 
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.cheatsheets.registry;
011:
012:        import java.util.ArrayList;
013:        import java.util.StringTokenizer;
014:
015:        import org.eclipse.core.runtime.IAdaptable;
016:        import org.eclipse.core.runtime.IConfigurationElement;
017:        import org.eclipse.jface.resource.ImageDescriptor;
018:        import org.eclipse.ui.IPluginContribution;
019:        import org.eclipse.ui.WorkbenchException;
020:        import org.eclipse.ui.internal.cheatsheets.Messages;
021:        import org.eclipse.ui.model.IWorkbenchAdapter;
022:
023:        /**
024:         * Category provides for hierarchical grouping of elements registered in the
025:         * registry. One extension normally defines a category, and other reference it
026:         * via its ID.
027:         * <p>
028:         * A category may specify its parent category in order to achieve hierarchy.
029:         * </p>
030:         */
031:        public class Category implements  IWorkbenchAdapter,
032:                IPluginContribution, IAdaptable {
033:            /**
034:             * Name of the miscellaneous category
035:             */
036:            public final static String MISC_NAME = Messages.CATEGORY_OTHER;
037:
038:            /**
039:             */
040:            public final static String MISC_ID = "org.eclipse.ui.cheatsheets.otherCategory"; //$NON-NLS-1$
041:
042:            private String id;
043:
044:            private String name;
045:
046:            private String[] parentPath;
047:
048:            private ArrayList elements;
049:
050:            private IConfigurationElement configurationElement;
051:
052:            private String pluginId;
053:
054:            /**
055:             * Creates an instance of <code>Category</code> as a miscellaneous
056:             * category.
057:             */
058:            public Category() {
059:                this .id = MISC_ID;
060:                this .name = MISC_NAME;
061:                this .pluginId = MISC_ID; // TODO: remove hack for bug 55172
062:            }
063:
064:            /**
065:             * Creates an instance of <code>Category</code> with an ID and label.
066:             * 
067:             * @param id
068:             *            the unique identifier for the category
069:             * @param label
070:             *            the presentation label for this category
071:             */
072:            public Category(String id, String label) {
073:                this .id = id;
074:                this .name = label;
075:            }
076:
077:            /**
078:             * Creates an instance of <code>Category</code> using the information from
079:             * the specified configuration element.
080:             * 
081:             * @param configElement
082:             *            the <code>IConfigurationElement<code> containing
083:             * 		the ID, label, and optional parent category path.
084:             * @throws WorkbenchException if the ID or label is <code>null</code
085:             */
086:            public Category(IConfigurationElement configElement)
087:                    throws WorkbenchException {
088:                id = configElement.getAttribute("id"); //$NON-NLS-1$
089:
090:                configurationElement = configElement;
091:                if (id == null || getLabel() == null)
092:                    throw new WorkbenchException("Invalid category: " + id); //$NON-NLS-1$
093:            }
094:
095:            /**
096:             * Add an element to this category.
097:             * 
098:             * @param element
099:             *            the element to add
100:             */
101:            public void addElement(Object element) {
102:                if (elements == null)
103:                    elements = new ArrayList(5);
104:                elements.add(element);
105:            }
106:
107:            /*
108:             * (non-Javadoc) Method declared on IAdaptable.
109:             */
110:            public Object getAdapter(Class adapter) {
111:                if (adapter == IWorkbenchAdapter.class)
112:                    return this ;
113:                else if (adapter == IConfigurationElement.class)
114:                    return configurationElement;
115:                else
116:                    return null;
117:            }
118:
119:            /*
120:             * (non-Javadoc) Method declared on IWorkbenchAdapter.
121:             */
122:            public Object[] getChildren(Object o) {
123:                return getElements().toArray();
124:            }
125:
126:            /*
127:             * (non-Javadoc) Method declared on IWorkbenchAdapter.
128:             */
129:            public ImageDescriptor getImageDescriptor(Object object) {
130:                return null;
131:            }
132:
133:            /*
134:             * (non-Javadoc) Method declared on IWorkbenchAdapter.
135:             */
136:            public String getLabel(Object o) {
137:                return getLabel();
138:            }
139:
140:            /**
141:             * Return the id for this category.
142:             * 
143:             * @return the id
144:             */
145:            public String getId() {
146:                return id;
147:            }
148:
149:            /**
150:             * Return the label for this category.
151:             * 
152:             * @return the label
153:             */
154:            public String getLabel() {
155:                return configurationElement == null ? name
156:                        : configurationElement.getAttribute("name"); //$NON-NLS-1$
157:            }
158:
159:            /**
160:             * Return the parent path for this category.
161:             * 
162:             * @return the parent path
163:             */
164:            public String[] getParentPath() {
165:                if (parentPath != null)
166:                    return parentPath;
167:
168:                String unparsedPath = getRawParentPath();
169:                if (unparsedPath != null) {
170:                    StringTokenizer stok = new StringTokenizer(unparsedPath,
171:                            "/"); //$NON-NLS-1$
172:                    parentPath = new String[stok.countTokens()];
173:                    for (int i = 0; stok.hasMoreTokens(); i++) {
174:                        parentPath[i] = stok.nextToken();
175:                    }
176:                }
177:
178:                return parentPath;
179:            }
180:
181:            /**
182:             * Return the unparsed parent path. May be <code>null</code>.
183:             * 
184:             * @return the unparsed parent path or <code>null</code>
185:             */
186:            public String getRawParentPath() {
187:                return configurationElement == null ? null
188:                        : configurationElement.getAttribute("parentCategory"); //$NON-NLS-1$
189:            }
190:
191:            /**
192:             * Return the root path for this category.
193:             * 
194:             * @return the root path
195:             */
196:            public String getRootPath() {
197:                String[] path = getParentPath();
198:                if (path != null && path.length > 0)
199:                    return path[0];
200:
201:                return id;
202:            }
203:
204:            /**
205:             * Return the elements contained in this category.
206:             * 
207:             * @return the elements
208:             */
209:            public ArrayList getElements() {
210:                return elements;
211:            }
212:
213:            /**
214:             * Return whether a given object exists in this category.
215:             * 
216:             * @param o
217:             *            the object to search for
218:             * @return whether the object is in this category
219:             */
220:            public boolean hasElement(Object o) {
221:                if (elements == null)
222:                    return false;
223:                if (elements.isEmpty())
224:                    return false;
225:                return elements.contains(o);
226:            }
227:
228:            /**
229:             * Return whether this category has child elements.
230:             * 
231:             * @return whether this category has child elements
232:             */
233:            public boolean hasElements() {
234:                if (elements != null)
235:                    return !elements.isEmpty();
236:
237:                return false;
238:            }
239:
240:            /*
241:             * (non-Javadoc)
242:             * 
243:             * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
244:             */
245:            public Object getParent(Object o) {
246:                return null;
247:            }
248:
249:            /*
250:             * (non-Javadoc)
251:             * 
252:             * @see org.eclipse.ui.activities.support.IPluginContribution#getLocalId()
253:             */
254:            public String getLocalId() {
255:                return id;
256:            }
257:
258:            /*
259:             * (non-Javadoc)
260:             * 
261:             * @see org.eclipse.ui.activities.support.IPluginContribution#getPluginId()
262:             */
263:            public String getPluginId() {
264:                return configurationElement == null ? pluginId
265:                        : configurationElement.getContributor().getName();
266:            }
267:
268:            /**
269:             * Clear all elements from this category.
270:             * 
271:             * @since 3.1
272:             */
273:            public void clear() {
274:                if (elements != null) {
275:                    elements.clear();
276:                }
277:            }
278:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.