Source Code Cross Referenced for CheatSheetCollectionElement.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) 2002, 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.Iterator;
013:
014:        import org.eclipse.core.runtime.*;
015:        import org.eclipse.ui.IPluginContribution;
016:        import org.eclipse.ui.internal.cheatsheets.ICheatSheetResource;
017:        import org.eclipse.ui.model.AdaptableList;
018:        import org.eclipse.ui.model.IWorkbenchAdapter;
019:
020:        /**
021:         * Instances of this class are a collection of CheatSheetCollectionElements,
022:         * thereby facilitating the definition of tree structures composed of 
023:         * these elements. Instances also store a list of cheatsheets.
024:         */
025:        public class CheatSheetCollectionElement extends AdaptableList
026:                implements  IPluginContribution {
027:            private String pluginId;
028:            private String id;
029:            private String name;
030:            private CheatSheetCollectionElement parent;
031:            private AdaptableList cheatsheets = new AdaptableList();
032:
033:            /**
034:             * Creates a new <code>CheatSheetCollectionElement</code>.  Parent can be null.
035:             *
036:             * @param name java.lang.String
037:             */
038:            public CheatSheetCollectionElement(String pluginId, String id,
039:                    String name, CheatSheetCollectionElement parent) {
040:                this .name = name;
041:                this .pluginId = pluginId;
042:                this .id = id;
043:                this .parent = parent;
044:            }
045:
046:            /**
047:             * Adds a cheatsheet collection to this collection.
048:             */
049:            public AdaptableList add(IAdaptable a) {
050:                if (a instanceof  CheatSheetElement) {
051:                    cheatsheets.add(a);
052:                } else {
053:                    super .add(a);
054:                }
055:                return this ;
056:            }
057:
058:            /**
059:             * Returns the cheatsheet collection child object corresponding to the
060:             * passed path (relative to this object), or <code>null</code> if
061:             * such an object could not be found.
062:             *
063:             * @param searchPath org.eclipse.core.runtime.IPath
064:             * @return CheatSheetCollectionElement
065:             */
066:            public CheatSheetCollectionElement findChildCollection(
067:                    IPath searchPath) {
068:                Object[] children = getChildren(null);
069:                String searchString = searchPath.segment(0);
070:                for (int i = 0; i < children.length; ++i) {
071:                    CheatSheetCollectionElement currentCategory = (CheatSheetCollectionElement) children[i];
072:                    if (currentCategory.getLabel(null).equals(searchString)) {
073:                        if (searchPath.segmentCount() == 1)
074:                            return currentCategory;
075:
076:                        return currentCategory.findChildCollection(searchPath
077:                                .removeFirstSegments(1));
078:                    }
079:                }
080:
081:                return null;
082:            }
083:
084:            /**
085:             * Returns this collection's associated cheatsheet object corresponding to the
086:             * passed id, or <code>null</code> if such an object could not be found.
087:             */
088:            public CheatSheetElement findCheatSheet(String searchId,
089:                    boolean recursive) {
090:                Object[] cheatsheets = getCheatSheets();
091:                for (int i = 0; i < cheatsheets.length; ++i) {
092:                    CheatSheetElement currentCheatSheet = (CheatSheetElement) cheatsheets[i];
093:                    if (currentCheatSheet.getID().equals(searchId))
094:                        return currentCheatSheet;
095:                }
096:                if (!recursive)
097:                    return null;
098:                for (Iterator iterator = children.iterator(); iterator
099:                        .hasNext();) {
100:                    CheatSheetCollectionElement child = (CheatSheetCollectionElement) iterator
101:                            .next();
102:                    CheatSheetElement result = child.findCheatSheet(searchId,
103:                            true);
104:                    if (result != null)
105:                        return result;
106:                }
107:                return null;
108:            }
109:
110:            /**
111:             * Returns an object which is an instance of the given class
112:             * associated with this object. Returns <code>null</code> if
113:             * no such object can be found.
114:             */
115:            public Object getAdapter(Class adapter) {
116:                if (adapter == IWorkbenchAdapter.class) {
117:                    return this ;
118:                }
119:                return Platform.getAdapterManager().getAdapter(this , adapter);
120:            }
121:
122:            /**
123:             * Returns the unique ID of this element.
124:             */
125:            public String getId() {
126:                return id;
127:            }
128:
129:            /**
130:             * Returns the label for this collection.
131:             */
132:            public String getLabel(Object o) {
133:                return name;
134:            }
135:
136:            /**
137:             * Returns the logical parent of the given object in its tree.
138:             */
139:            public Object getParent(Object o) {
140:                return parent;
141:            }
142:
143:            /**
144:             * Returns a path representing this collection's ancestor chain.
145:             */
146:            public IPath getPath() {
147:                if (parent == null)
148:                    return new Path(ICheatSheetResource.EMPTY_STRING);
149:
150:                return parent.getPath().append(name);
151:            }
152:
153:            /**
154:             * Returns this collection element's associated collection of cheatsheets.
155:             */
156:            public Object[] getCheatSheets() {
157:                return cheatsheets.getChildren();
158:            }
159:
160:            /**
161:             * Returns true if this element has no children and no cheatsheets.
162:             */
163:            public boolean isEmpty() {
164:                return size() == 0 && cheatsheets.size() == 0;
165:            }
166:
167:            /**
168:             * Sets this collection's unique id.
169:             */
170:            public void setId(java.lang.String newId) {
171:                id = newId;
172:            }
173:
174:            /**
175:             * Sets the collection of cheatsheets associated with this collection element.
176:             */
177:            public void setCheatSheets(AdaptableList value) {
178:                cheatsheets = value;
179:            }
180:
181:            /**
182:             * For debugging purposes.
183:             */
184:            public String toString() {
185:                StringBuffer buf = new StringBuffer("CheatSheetCollection, "); //$NON-NLS-1$
186:                buf.append(children.size());
187:                buf.append(" children, "); //$NON-NLS-1$
188:                buf.append(cheatsheets.size());
189:                buf.append(" cheatsheets"); //$NON-NLS-1$
190:                return buf.toString();
191:            }
192:
193:            public String getLocalId() {
194:                return getId();
195:            }
196:
197:            public String getPluginId() {
198:                return pluginId;
199:            }
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.