Source Code Cross Referenced for TypesView.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » internal » ui » browsing » 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 » jdt » org.eclipse.jdt.internal.ui.browsing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 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.jdt.internal.ui.browsing;
011:
012:        import java.util.Arrays;
013:        import java.util.List;
014:
015:        import org.eclipse.core.runtime.Assert;
016:
017:        import org.eclipse.swt.widgets.Composite;
018:
019:        import org.eclipse.jface.viewers.ISelection;
020:        import org.eclipse.jface.viewers.IStructuredSelection;
021:        import org.eclipse.jface.viewers.StructuredSelection;
022:        import org.eclipse.jface.viewers.StructuredViewer;
023:        import org.eclipse.jface.viewers.TableViewer;
024:
025:        import org.eclipse.ui.IActionBars;
026:        import org.eclipse.ui.IPageLayout;
027:        import org.eclipse.ui.IWorkbenchPart;
028:        import org.eclipse.ui.actions.ActionFactory;
029:        import org.eclipse.ui.part.IShowInTargetList;
030:
031:        import org.eclipse.jdt.core.IClassFile;
032:        import org.eclipse.jdt.core.ICompilationUnit;
033:        import org.eclipse.jdt.core.IJavaElement;
034:        import org.eclipse.jdt.core.IMember;
035:        import org.eclipse.jdt.core.IPackageFragment;
036:        import org.eclipse.jdt.core.IType;
037:
038:        import org.eclipse.jdt.ui.JavaElementLabels;
039:        import org.eclipse.jdt.ui.JavaUI;
040:        import org.eclipse.jdt.ui.PreferenceConstants;
041:
042:        import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
043:        import org.eclipse.jdt.internal.ui.actions.SelectAllAction;
044:        import org.eclipse.jdt.internal.ui.filters.NonJavaElementFilter;
045:        import org.eclipse.jdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
046:        import org.eclipse.jdt.internal.ui.viewsupport.ColoredViewersManager;
047:        import org.eclipse.jdt.internal.ui.viewsupport.DecoratingJavaLabelProvider;
048:        import org.eclipse.jdt.internal.ui.viewsupport.JavaUILabelProvider;
049:
050:        public class TypesView extends JavaBrowsingPart {
051:
052:            private SelectAllAction fSelectAllAction;
053:
054:            /**
055:             * Creates and returns the label provider for this part.
056:             *
057:             * @return the label provider
058:             * @see org.eclipse.jface.viewers.ILabelProvider
059:             */
060:            protected JavaUILabelProvider createLabelProvider() {
061:                return new AppearanceAwareLabelProvider(
062:                        AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS
063:                                | JavaElementLabels.T_CATEGORY,
064:                        AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS);
065:            }
066:
067:            protected StructuredViewer createViewer(Composite parent) {
068:                StructuredViewer viewer = super .createViewer(parent);
069:                ColoredViewersManager.install(viewer);
070:                return viewer;
071:            }
072:
073:            /* (non-Javadoc)
074:             * @see org.eclipse.jdt.internal.ui.browsing.JavaBrowsingPart#getAdapter(java.lang.Class)
075:             */
076:            public Object getAdapter(Class key) {
077:                if (key == IShowInTargetList.class) {
078:                    return new IShowInTargetList() {
079:                        public String[] getShowInTargetIds() {
080:                            return new String[] { JavaUI.ID_PACKAGES,
081:                                    IPageLayout.ID_RES_NAV };
082:                        }
083:
084:                    };
085:                }
086:                return super .getAdapter(key);
087:            }
088:
089:            /**
090:             * Adds filters the viewer of this part.
091:             */
092:            protected void addFilters() {
093:                super .addFilters();
094:                getViewer().addFilter(new NonJavaElementFilter());
095:            }
096:
097:            /**
098:             * Answers if the given <code>element</code> is a valid
099:             * input for this part.
100:             *
101:             * @param 	element	the object to test
102:             * @return	<true> if the given element is a valid input
103:             */
104:            protected boolean isValidInput(Object element) {
105:                return element instanceof  IPackageFragment;
106:            }
107:
108:            /**
109:             * Answers if the given <code>element</code> is a valid
110:             * element for this part.
111:             *
112:             * @param 	element	the object to test
113:             * @return	<true> if the given element is a valid element
114:             */
115:            protected boolean isValidElement(Object element) {
116:                if (element instanceof  ICompilationUnit)
117:                    return super .isValidElement(((ICompilationUnit) element)
118:                            .getParent());
119:                else if (element instanceof  IType) {
120:                    IType type = (IType) element;
121:                    return type.getDeclaringType() == null
122:                            && isValidElement(type.getCompilationUnit());
123:                }
124:                return false;
125:            }
126:
127:            /**
128:             * Finds the element which has to be selected in this part.
129:             *
130:             * @param je	the Java element which has the focus
131:             * @return the element to select
132:             */
133:            protected IJavaElement findElementToSelect(IJavaElement je) {
134:                if (je == null)
135:                    return null;
136:
137:                switch (je.getElementType()) {
138:                case IJavaElement.TYPE:
139:                    IType type = ((IType) je).getDeclaringType();
140:                    if (type == null)
141:                        type = (IType) je;
142:                    return type;
143:                case IJavaElement.COMPILATION_UNIT:
144:                    return getTypeForCU((ICompilationUnit) je);
145:                case IJavaElement.CLASS_FILE:
146:                    return findElementToSelect(((IClassFile) je).getType());
147:                case IJavaElement.IMPORT_CONTAINER:
148:                case IJavaElement.IMPORT_DECLARATION:
149:                case IJavaElement.PACKAGE_DECLARATION:
150:                    return findElementToSelect(je.getParent());
151:                default:
152:                    if (je instanceof  IMember)
153:                        return findElementToSelect(((IMember) je)
154:                                .getDeclaringType());
155:                    return null;
156:
157:                }
158:            }
159:
160:            /**
161:             * Returns the context ID for the Help system
162:             *
163:             * @return	the string used as ID for the Help context
164:             */
165:            protected String getHelpContextId() {
166:                return IJavaHelpContextIds.TYPES_VIEW;
167:            }
168:
169:            protected String getLinkToEditorKey() {
170:                return PreferenceConstants.LINK_BROWSING_TYPES_TO_EDITOR;
171:            }
172:
173:            protected void createActions() {
174:                super .createActions();
175:                fSelectAllAction = new SelectAllAction(
176:                        (TableViewer) getViewer());
177:            }
178:
179:            protected void fillActionBars(IActionBars actionBars) {
180:                super .fillActionBars(actionBars);
181:
182:                // Add selectAll action handlers.
183:                actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL
184:                        .getId(), fSelectAllAction);
185:            }
186:
187:            /**
188:             * Handles selection of LogicalPackage in Packages view.
189:             *
190:             * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
191:             * @since 2.1
192:             */
193:            public void selectionChanged(IWorkbenchPart part,
194:                    ISelection selection) {
195:                if (!needsToProcessSelectionChanged(part, selection))
196:                    return;
197:
198:                if (selection instanceof  IStructuredSelection) {
199:                    IStructuredSelection sel = (IStructuredSelection) selection;
200:                    Object selectedElement = sel.getFirstElement();
201:                    if (sel.size() == 1
202:                            && (selectedElement instanceof  LogicalPackage)) {
203:                        IPackageFragment[] fragments = ((LogicalPackage) selectedElement)
204:                                .getFragments();
205:                        List selectedElements = Arrays.asList(fragments);
206:                        if (selectedElements.size() > 1) {
207:                            adjustInput(part, selectedElements);
208:                            fPreviousSelectedElement = selectedElements;
209:                            fPreviousSelectionProvider = part;
210:                        } else if (selectedElements.size() == 1)
211:                            super .selectionChanged(part,
212:                                    new StructuredSelection(selectedElements
213:                                            .get(0)));
214:                        else
215:                            Assert.isLegal(false);
216:                        return;
217:                    }
218:                }
219:                super .selectionChanged(part, selection);
220:            }
221:
222:            private void adjustInput(IWorkbenchPart part, List selectedElements) {
223:                Object currentInput = getViewer().getInput();
224:                if (!selectedElements.equals(currentInput))
225:                    setInput(selectedElements);
226:            }
227:
228:            /*
229:             * @see org.eclipse.jdt.internal.ui.browsing.JavaBrowsingPart#createDecoratingLabelProvider(org.eclipse.jdt.internal.ui.viewsupport.JavaUILabelProvider)
230:             */
231:            protected DecoratingJavaLabelProvider createDecoratingLabelProvider(
232:                    JavaUILabelProvider provider) {
233:                DecoratingJavaLabelProvider decoratingLabelProvider = super 
234:                        .createDecoratingLabelProvider(provider);
235:                provider
236:                        .addLabelDecorator(new TopLevelTypeProblemsLabelDecorator(
237:                                null));
238:                return decoratingLabelProvider;
239:            }
240:
241:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.