Source Code Cross Referenced for ManifestSourcePage.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » editor » plugin » 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 » Eclipse plug in development » org.eclipse.pde.internal.ui.editor.plugin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2003, 2007 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.pde.internal.ui.editor.plugin;
011:
012:        import java.util.ArrayList;
013:
014:        import org.eclipse.jface.action.IMenuManager;
015:        import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
016:        import org.eclipse.jface.viewers.ILabelProvider;
017:        import org.eclipse.jface.viewers.ISelection;
018:        import org.eclipse.jface.viewers.ITreeContentProvider;
019:        import org.eclipse.jface.viewers.LabelProvider;
020:        import org.eclipse.jface.viewers.ViewerComparator;
021:        import org.eclipse.pde.core.plugin.IPluginBase;
022:        import org.eclipse.pde.core.plugin.IPluginModelBase;
023:        import org.eclipse.pde.core.plugin.IPluginObject;
024:        import org.eclipse.pde.internal.core.plugin.ImportObject;
025:        import org.eclipse.pde.internal.core.text.IDocumentElementNode;
026:        import org.eclipse.pde.internal.core.text.IDocumentRange;
027:        import org.eclipse.pde.internal.core.text.plugin.PluginModelBase;
028:        import org.eclipse.pde.internal.ui.PDELabelProvider;
029:        import org.eclipse.pde.internal.ui.PDEPlugin;
030:        import org.eclipse.pde.internal.ui.PDEPluginImages;
031:        import org.eclipse.pde.internal.ui.PDEUIMessages;
032:        import org.eclipse.pde.internal.ui.editor.PDEFormEditor;
033:        import org.eclipse.pde.internal.ui.editor.XMLSourcePage;
034:        import org.eclipse.pde.internal.ui.elements.DefaultContentProvider;
035:        import org.eclipse.pde.internal.ui.search.PluginSearchActionGroup;
036:        import org.eclipse.pde.internal.ui.util.SharedLabelProvider;
037:        import org.eclipse.swt.graphics.Image;
038:        import org.eclipse.swt.widgets.Composite;
039:        import org.eclipse.ui.actions.ActionContext;
040:
041:        public class ManifestSourcePage extends XMLSourcePage {
042:
043:            private Object fLibraries = new Object();
044:            private Object fImports = new Object();
045:            private Object fExtensionPoints = new Object();
046:            private Object fExtensions = new Object();
047:            private ExtensionAttributePointDectector fDetector;
048:            private PluginSearchActionGroup fActionGroup;
049:
050:            class OutlineLabelProvider extends LabelProvider {
051:                private PDELabelProvider fProvider;
052:
053:                public OutlineLabelProvider() {
054:                    fProvider = PDEPlugin.getDefault().getLabelProvider();
055:                }
056:
057:                /* (non-Javadoc)
058:                 * @see org.eclipse.jface.viewers.LabelProvider#dispose()
059:                 */
060:
061:                public String getText(Object obj) {
062:                    if (obj == fLibraries)
063:                        return PDEUIMessages.ManifestSourcePage_libraries;
064:                    if (obj == fImports)
065:                        return PDEUIMessages.ManifestSourcePage_dependencies;
066:                    if (obj == fExtensionPoints)
067:                        return PDEUIMessages.ManifestSourcePage_extensionPoints;
068:                    if (obj == fExtensions)
069:                        return PDEUIMessages.ManifestSourcePage_extensions;
070:                    String text = fProvider.getText(obj);
071:                    if ((text == null || text.trim().length() == 0)
072:                            && obj instanceof  IDocumentElementNode)
073:                        text = ((IDocumentElementNode) obj).getXMLTagName();
074:                    return text;
075:                }
076:
077:                public Image getImage(Object obj) {
078:                    if (obj == fLibraries)
079:                        return fProvider.get(PDEPluginImages.DESC_RUNTIME_OBJ);
080:                    if (obj == fImports)
081:                        return fProvider
082:                                .get(PDEPluginImages.DESC_REQ_PLUGINS_OBJ);
083:                    if (obj == fExtensionPoints)
084:                        return fProvider
085:                                .get(PDEPluginImages.DESC_EXT_POINTS_OBJ);
086:                    if (obj == fExtensions)
087:                        return fProvider
088:                                .get(PDEPluginImages.DESC_EXTENSIONS_OBJ);
089:
090:                    Image image = fProvider.getImage(obj);
091:                    int flags = ((IDocumentElementNode) obj).isErrorNode() ? SharedLabelProvider.F_ERROR
092:                            : 0;
093:                    return (flags == 0) ? image : fProvider.get(image, flags);
094:                }
095:            }
096:
097:            class ContentProvider extends DefaultContentProvider implements 
098:                    ITreeContentProvider {
099:
100:                /* (non-Javadoc)
101:                 * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
102:                 */
103:                public Object[] getChildren(Object parent) {
104:                    PluginModelBase model = (PluginModelBase) getInputContext()
105:                            .getModel();
106:
107:                    ArrayList result = new ArrayList();
108:                    if (parent instanceof  IPluginBase) {
109:                        IPluginBase pluginBase = (IPluginBase) parent;
110:                        if (pluginBase.getLibraries().length > 0)
111:                            result.add(fLibraries);
112:                        if (pluginBase.getImports().length > 0)
113:                            result.add(fImports);
114:                        if (pluginBase.getExtensionPoints().length > 0)
115:                            result.add(fExtensionPoints);
116:                        if (pluginBase.getExtensions().length > 0)
117:                            result.add(fExtensions);
118:                        return result.toArray();
119:                    }
120:                    if (parent == fLibraries)
121:                        return model.getPluginBase().getLibraries();
122:
123:                    if (parent == fImports)
124:                        return model.getPluginBase().getImports();
125:
126:                    if (parent == fExtensionPoints)
127:                        return model.getPluginBase().getExtensionPoints();
128:
129:                    if (parent == fExtensions)
130:                        return model.getPluginBase().getExtensions();
131:
132:                    return new Object[0];
133:                }
134:
135:                /* (non-Javadoc)
136:                 * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
137:                 */
138:                public Object getParent(Object element) {
139:                    if (element instanceof  IDocumentElementNode)
140:                        return ((IDocumentElementNode) element).getParentNode();
141:                    return null;
142:                }
143:
144:                /* (non-Javadoc)
145:                 * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
146:                 */
147:                public boolean hasChildren(Object element) {
148:                    if (element instanceof  IPluginBase) {
149:                        return ((IDocumentElementNode) element).getChildNodes().length > 0;
150:                    }
151:                    return element == fLibraries || element == fImports
152:                            || element == fExtensionPoints
153:                            || element == fExtensions;
154:                }
155:
156:                /* (non-Javadoc)
157:                 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
158:                 */
159:                public Object[] getElements(Object inputElement) {
160:                    if (inputElement instanceof  IPluginModelBase) {
161:                        return new Object[] { ((IPluginModelBase) inputElement)
162:                                .getPluginBase() };
163:                    }
164:                    return new Object[0];
165:                }
166:            }
167:
168:            class OutlineComparator extends ViewerComparator {
169:                /* (non-Javadoc)
170:                 * @see org.eclipse.jface.viewers.ViewerSorter#category(java.lang.Object)
171:                 */
172:                public int category(Object element) {
173:                    if (element == fLibraries)
174:                        return 0;
175:                    if (element == fImports)
176:                        return 1;
177:                    if (element == fExtensionPoints)
178:                        return 2;
179:                    if (element == fExtensions)
180:                        return 3;
181:                    return 4;
182:                }
183:            }
184:
185:            public ManifestSourcePage(PDEFormEditor editor, String id,
186:                    String title) {
187:                super (editor, id, title);
188:                fDetector = new ExtensionAttributePointDectector();
189:                fActionGroup = new PluginSearchActionGroup();
190:            }
191:
192:            public ILabelProvider createOutlineLabelProvider() {
193:                return new OutlineLabelProvider();
194:            }
195:
196:            public ITreeContentProvider createOutlineContentProvider() {
197:                return new ContentProvider();
198:            }
199:
200:            /* (non-Javadoc)
201:             * @see org.eclipse.pde.internal.ui.editor.PDESourcePage#updateSelection(java.lang.Object)
202:             */
203:            public void updateSelection(Object object) {
204:                if ((object instanceof  IDocumentElementNode)
205:                        && !((IDocumentElementNode) object).isErrorNode()) {
206:                    fSelection = object;
207:                    setHighlightRange((IDocumentElementNode) object, true);
208:                    setSelectedRange((IDocumentElementNode) object, false);
209:                } else {
210:                    //resetHighlightRange();
211:                }
212:            }
213:
214:            /* (non-Javadoc)
215:             * @see org.eclipse.pde.internal.ui.editor.PDESourcePage#createOutlineSorter()
216:             */
217:            public ViewerComparator createOutlineComparator() {
218:                return new OutlineComparator();
219:            }
220:
221:            public IDocumentRange getRangeElement(int offset,
222:                    boolean searchChildren) {
223:                IPluginBase base = ((IPluginModelBase) getInputContext()
224:                        .getModel()).getPluginBase();
225:                IDocumentRange node = findNode(base.getLibraries(), offset,
226:                        searchChildren);
227:                if (node == null)
228:                    node = findNode(base.getImports(), offset, searchChildren);
229:                if (node == null)
230:                    node = findNode(base.getExtensionPoints(), offset,
231:                            searchChildren);
232:                if (node == null)
233:                    node = findNode(base.getExtensions(), offset,
234:                            searchChildren);
235:                if (node == null)
236:                    node = findNode(new IPluginObject[] { base }, offset,
237:                            searchChildren);
238:
239:                return node;
240:            }
241:
242:            public IDocumentRange findRange() {
243:                if (fSelection instanceof  ImportObject)
244:                    fSelection = ((ImportObject) fSelection).getImport();
245:                if (fSelection instanceof  IDocumentElementNode)
246:                    return (IDocumentElementNode) fSelection;
247:                return null;
248:            }
249:
250:            protected boolean isSelectionListener() {
251:                return true;
252:            }
253:
254:            public Object getAdapter(Class adapter) {
255:                if (IHyperlinkDetector.class.equals(adapter))
256:                    return new ManifestHyperlinkDetector(this );
257:                return super .getAdapter(adapter);
258:            }
259:
260:            /* (non-Javadoc)
261:             * @see org.eclipse.pde.internal.ui.editor.PDESourcePage#editorContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager)
262:             */
263:            protected void editorContextMenuAboutToShow(IMenuManager menu) {
264:
265:                ISelection selection = fDetector.getSelection();
266:                if (selection != null) {
267:                    fActionGroup.setContext(new ActionContext(selection));
268:                    fActionGroup.fillContextMenu(menu);
269:                }
270:                super .editorContextMenuAboutToShow(menu);
271:            }
272:
273:            /* (non-Javadoc)
274:             * @see org.eclipse.pde.internal.ui.editor.PDEProjectionSourcePage#createPartControl(org.eclipse.swt.widgets.Composite)
275:             */
276:            public void createPartControl(Composite parent) {
277:                super .createPartControl(parent);
278:                // At this point the source page is fully initialized including the 
279:                // underlying text viewer
280:                fDetector.setTextEditor(this );
281:            }
282:
283:            /* (non-Javadoc)
284:             * @see org.eclipse.pde.internal.ui.editor.PDEProjectionSourcePage#isQuickOutlineEnabled()
285:             */
286:            public boolean isQuickOutlineEnabled() {
287:                return true;
288:            }
289:
290:            /* (non-Javadoc)
291:             * @see org.eclipse.pde.internal.ui.editor.PDESourcePage#setActive(boolean)
292:             */
293:            public void setActive(boolean active) {
294:                super .setActive(active);
295:                // Update the text selection if this page is being activated
296:                if (active) {
297:                    updateTextSelection();
298:                }
299:            }
300:
301:        }
w_w___w_.__j___a__v__a2s__._c__o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.