Source Code Cross Referenced for DependencyExtentSearchResultPage.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » search » dependencies » 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.search.dependencies 
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.pde.internal.ui.search.dependencies;
011:
012:        import org.eclipse.jdt.core.IJavaElement;
013:        import org.eclipse.jdt.core.IType;
014:        import org.eclipse.jdt.core.JavaModelException;
015:        import org.eclipse.jdt.ui.JavaElementLabelProvider;
016:        import org.eclipse.jdt.ui.actions.FindReferencesInWorkingSetAction;
017:        import org.eclipse.jdt.ui.actions.JavaSearchActionGroup;
018:        import org.eclipse.jface.action.Action;
019:        import org.eclipse.jface.action.IMenuManager;
020:        import org.eclipse.jface.action.Separator;
021:        import org.eclipse.jface.viewers.ILabelProvider;
022:        import org.eclipse.jface.viewers.IStructuredSelection;
023:        import org.eclipse.jface.viewers.ViewerComparator;
024:        import org.eclipse.pde.core.plugin.IPluginExtension;
025:        import org.eclipse.pde.core.plugin.IPluginExtensionPoint;
026:        import org.eclipse.pde.core.plugin.IPluginObject;
027:        import org.eclipse.pde.internal.ui.PDEPlugin;
028:        import org.eclipse.pde.internal.ui.PDEUIMessages;
029:        import org.eclipse.pde.internal.ui.search.AbstractSearchResultPage;
030:        import org.eclipse.pde.internal.ui.search.ManifestEditorOpener;
031:        import org.eclipse.pde.internal.ui.search.PluginSearchActionGroup;
032:        import org.eclipse.search.ui.text.Match;
033:        import org.eclipse.swt.graphics.Image;
034:        import org.eclipse.ui.IWorkingSet;
035:        import org.eclipse.ui.IWorkingSetManager;
036:        import org.eclipse.ui.PartInitException;
037:        import org.eclipse.ui.PlatformUI;
038:        import org.eclipse.ui.actions.ActionContext;
039:
040:        public class DependencyExtentSearchResultPage extends
041:                AbstractSearchResultPage {
042:
043:            class Comparator extends ViewerComparator {
044:                /* (non-Javadoc)
045:                 * @see org.eclipse.jface.viewers.ViewerSorter#category(java.lang.Object)
046:                 */
047:                public int category(Object element) {
048:                    try {
049:                        if (element instanceof  IType) {
050:                            if (((IType) element).isClass())
051:                                return 1;
052:                            return 0;
053:                        }
054:                    } catch (JavaModelException e) {
055:                    }
056:                    return 2;
057:                }
058:            }
059:
060:            class LabelProvider extends JavaElementLabelProvider {
061:                /* (non-Javadoc)
062:                 * @see org.eclipse.jdt.ui.JavaElementLabelProvider#getImage(java.lang.Object)
063:                 */
064:                public Image getImage(Object element) {
065:                    if (element instanceof  IPluginObject)
066:                        return PDEPlugin.getDefault().getLabelProvider()
067:                                .getImage(element);
068:                    return super .getImage(element);
069:                }
070:
071:                /* (non-Javadoc)
072:                 * @see org.eclipse.jdt.ui.JavaElementLabelProvider#getText(java.lang.Object)
073:                 */
074:                public String getText(Object element) {
075:                    if (element instanceof  IPluginExtensionPoint)
076:                        return ((IPluginExtensionPoint) element).getFullId();
077:
078:                    if (element instanceof  IPluginExtension)
079:                        return ((IPluginExtension) element).getPoint();
080:
081:                    if (element instanceof  IJavaElement) {
082:                        IJavaElement javaElement = (IJavaElement) element;
083:                        String text = super .getText(javaElement)
084:                                + " - " //$NON-NLS-1$
085:                                + javaElement.getAncestor(
086:                                        IJavaElement.PACKAGE_FRAGMENT)
087:                                        .getElementName();
088:                        if (!(javaElement instanceof  IType)) {
089:                            IJavaElement ancestor = javaElement
090:                                    .getAncestor(IJavaElement.TYPE);
091:                            if (ancestor == null)
092:                                ancestor = javaElement
093:                                        .getAncestor(IJavaElement.CLASS_FILE);
094:                            if (ancestor == null)
095:                                ancestor = javaElement
096:                                        .getAncestor(IJavaElement.COMPILATION_UNIT);
097:                            if (ancestor != null)
098:                                text += "." + ancestor.getElementName(); //$NON-NLS-1$
099:                        }
100:                        return text;
101:                    }
102:                    return super .getText(element);
103:                }
104:            }
105:
106:            public DependencyExtentSearchResultPage() {
107:                PDEPlugin.getDefault().getLabelProvider().connect(this );
108:            }
109:
110:            /* (non-Javadoc)
111:             * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#dispose()
112:             */
113:            public void dispose() {
114:                PDEPlugin.getDefault().getLabelProvider().disconnect(this );
115:                super .dispose();
116:            }
117:
118:            /* (non-Javadoc)
119:             * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#fillContextMenu(org.eclipse.jface.action.IMenuManager)
120:             */
121:            protected void fillContextMenu(IMenuManager mgr) {
122:                super .fillContextMenu(mgr);
123:                mgr.add(new Separator());
124:                JavaSearchActionGroup group = new JavaSearchActionGroup(this );
125:                group.setContext(new ActionContext(getViewer().getSelection()));
126:                group.fillContextMenu(mgr);
127:                addJavaSearchGroup(mgr);
128:                PluginSearchActionGroup actionGroup = new PluginSearchActionGroup();
129:                actionGroup.setContext(new ActionContext(getViewer()
130:                        .getSelection()));
131:                actionGroup.fillContextMenu(mgr);
132:            }
133:
134:            private void addJavaSearchGroup(IMenuManager mgr) {
135:                IStructuredSelection ssel = (IStructuredSelection) getViewer()
136:                        .getSelection();
137:                if (ssel.size() == 1) {
138:                    final Object object = ssel.getFirstElement();
139:                    if (object instanceof  IType) {
140:                        mgr.add(new Separator());
141:                        mgr
142:                                .add(new Action(
143:                                        PDEUIMessages.DependencyExtentSearchResultPage_referencesInPlugin) {
144:                                    public void run() {
145:                                        DependencyExtentQuery query = (DependencyExtentQuery) getInput()
146:                                                .getQuery();
147:                                        IWorkingSetManager manager = PlatformUI
148:                                                .getWorkbench()
149:                                                .getWorkingSetManager();
150:                                        IWorkingSet set = manager
151:                                                .createWorkingSet(
152:                                                        "temp", query.getDirectRoots()); //$NON-NLS-1$
153:                                        new FindReferencesInWorkingSetAction(
154:                                                getViewPart().getSite(),
155:                                                new IWorkingSet[] { set })
156:                                                .run((IType) object);
157:                                        manager.removeWorkingSet(set);
158:                                    }
159:                                });
160:                    }
161:                }
162:            }
163:
164:            /* (non-Javadoc)
165:             * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#showMatch(org.eclipse.search.ui.text.Match, int, int, boolean)
166:             */
167:            protected void showMatch(Match match, int currentOffset,
168:                    int currentLength, boolean activate)
169:                    throws PartInitException {
170:                if (match.getElement() instanceof  IPluginObject) {
171:                    ManifestEditorOpener.open(match, activate);
172:                } else {
173:                    try {
174:                        JavaEditorOpener.open(match, currentOffset,
175:                                currentLength, activate);
176:                    } catch (PartInitException e) {
177:                    } catch (JavaModelException e) {
178:                    }
179:                }
180:            }
181:
182:            /* (non-Javadoc)
183:             * @see org.eclipse.pde.internal.ui.search.AbstractSearchResultPage#createLabelProvider()
184:             */
185:            protected ILabelProvider createLabelProvider() {
186:                return new LabelProvider();
187:            }
188:
189:            /* (non-Javadoc)
190:             * @see org.eclipse.pde.internal.ui.search.AbstractSearchResultPage#createViewerSorter()
191:             */
192:            protected ViewerComparator createViewerComparator() {
193:                return new Comparator();
194:            }
195:
196:        }
w___w_w_._j___ava2s._c___om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.