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


0001:        /*******************************************************************************
0002:         * Copyright (c) 2000, 2007 IBM Corporation and others.
0003:         * All rights reserved. This program and the accompanying materials
0004:         * are made available under the terms of the Eclipse Public License v1.0
0005:         * which accompanies this distribution, and is available at
0006:         * http://www.eclipse.org/legal/epl-v10.html
0007:         *
0008:         * Contributors:
0009:         *     IBM Corporation - initial API and implementation
0010:         *******************************************************************************/package org.eclipse.jdt.ui;
0011:
0012:        import java.net.URL;
0013:        import java.util.ArrayList;
0014:        import java.util.Arrays;
0015:        import java.util.List;
0016:
0017:        import org.eclipse.core.runtime.Assert;
0018:        import org.eclipse.core.runtime.IPath;
0019:
0020:        import org.eclipse.core.resources.IProject;
0021:
0022:        import org.eclipse.swt.dnd.Transfer;
0023:        import org.eclipse.swt.widgets.Shell;
0024:
0025:        import org.eclipse.jface.operation.IRunnableContext;
0026:
0027:        import org.eclipse.ui.IEditorInput;
0028:        import org.eclipse.ui.IEditorPart;
0029:        import org.eclipse.ui.PartInitException;
0030:        import org.eclipse.ui.dialogs.SelectionDialog;
0031:        import org.eclipse.ui.texteditor.IDocumentProvider;
0032:
0033:        import org.eclipse.jdt.core.IClasspathEntry;
0034:        import org.eclipse.jdt.core.ICompilationUnit;
0035:        import org.eclipse.jdt.core.IJavaElement;
0036:        import org.eclipse.jdt.core.IJavaProject;
0037:        import org.eclipse.jdt.core.IPackageFragmentRoot;
0038:        import org.eclipse.jdt.core.ISourceReference;
0039:        import org.eclipse.jdt.core.ITypeRoot;
0040:        import org.eclipse.jdt.core.JavaCore;
0041:        import org.eclipse.jdt.core.JavaModelException;
0042:        import org.eclipse.jdt.core.search.IJavaSearchConstants;
0043:        import org.eclipse.jdt.core.search.IJavaSearchScope;
0044:        import org.eclipse.jdt.core.search.SearchEngine;
0045:
0046:        import org.eclipse.jdt.internal.corext.javadoc.JavaDocLocations;
0047:        import org.eclipse.jdt.internal.corext.refactoring.reorg.JavaElementTransfer;
0048:
0049:        import org.eclipse.jdt.ui.dialogs.TypeSelectionExtension;
0050:        import org.eclipse.jdt.ui.text.IColorManager;
0051:
0052:        import org.eclipse.jdt.internal.ui.JavaPlugin;
0053:        import org.eclipse.jdt.internal.ui.JavaUIMessages;
0054:        import org.eclipse.jdt.internal.ui.SharedImages;
0055:        import org.eclipse.jdt.internal.ui.dialogs.FilteredTypesSelectionDialog;
0056:        import org.eclipse.jdt.internal.ui.dialogs.MainTypeSelectionDialog;
0057:        import org.eclipse.jdt.internal.ui.dialogs.MultiMainTypeSelectionDialog;
0058:        import org.eclipse.jdt.internal.ui.dialogs.PackageSelectionDialog;
0059:        import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
0060:        import org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext;
0061:
0062:        /**
0063:         * Central access point for the Java UI plug-in (id <code>"org.eclipse.jdt.ui"</code>).
0064:         * This class provides static methods for:
0065:         * <ul>
0066:         *  <li> creating various kinds of selection dialogs to present a collection
0067:         *       of Java elements to the user and let them make a selection.</li>
0068:         *  <li> opening a Java editor on a compilation unit.</li> 
0069:         * </ul>
0070:         * <p>
0071:         * This class provides static methods and fields only; it is not intended to be
0072:         * instantiated or subclassed by clients.
0073:         * </p>
0074:         */
0075:        public final class JavaUI {
0076:
0077:            private static ISharedImages fgSharedImages = null;
0078:
0079:            private JavaUI() {
0080:                // prevent instantiation of JavaUI.
0081:            }
0082:
0083:            /**
0084:             * The id of the Java plug-in (value <code>"org.eclipse.jdt.ui"</code>).
0085:             */
0086:            public static final String ID_PLUGIN = "org.eclipse.jdt.ui"; //$NON-NLS-1$
0087:
0088:            /**
0089:             * The id of the Java perspective
0090:             * (value <code>"org.eclipse.jdt.ui.JavaPerspective"</code>).
0091:             */
0092:            public static final String ID_PERSPECTIVE = "org.eclipse.jdt.ui.JavaPerspective"; //$NON-NLS-1$
0093:
0094:            /**
0095:             * The id of the Java hierarchy perspective
0096:             * (value <code>"org.eclipse.jdt.ui.JavaHierarchyPerspective"</code>).
0097:             */
0098:            public static final String ID_HIERARCHYPERSPECTIVE = "org.eclipse.jdt.ui.JavaHierarchyPerspective"; //$NON-NLS-1$
0099:
0100:            /**
0101:             * The id of the Java action set
0102:             * (value <code>"org.eclipse.jdt.ui.JavaActionSet"</code>).
0103:             */
0104:            public static final String ID_ACTION_SET = "org.eclipse.jdt.ui.JavaActionSet"; //$NON-NLS-1$
0105:
0106:            /**
0107:             * The id of the Java Element Creation action set
0108:             * (value <code>"org.eclipse.jdt.ui.JavaElementCreationActionSet"</code>).
0109:             * 
0110:             * @since 2.0
0111:             */
0112:            public static final String ID_ELEMENT_CREATION_ACTION_SET = "org.eclipse.jdt.ui.JavaElementCreationActionSet"; //$NON-NLS-1$
0113:
0114:            /**
0115:             * The id of the Java Coding action set
0116:             * (value <code>"org.eclipse.jdt.ui.CodingActionSet"</code>).
0117:             * 
0118:             * @since 2.0
0119:             */
0120:            public static final String ID_CODING_ACTION_SET = "org.eclipse.jdt.ui.CodingActionSet"; //$NON-NLS-1$
0121:
0122:            /**
0123:             * The id of the Java action set for open actions
0124:             * (value <code>"org.eclipse.jdt.ui.A_OpenActionSet"</code>).
0125:             * 
0126:             * @since 2.0
0127:             */
0128:            public static final String ID_OPEN_ACTION_SET = "org.eclipse.jdt.ui.A_OpenActionSet"; //$NON-NLS-1$
0129:
0130:            /**
0131:             * The id of the Java Search action set
0132:             * (value <code>org.eclipse.jdt.ui.SearchActionSet"</code>).
0133:             * 
0134:             * @since 2.0
0135:             */
0136:            public static final String ID_SEARCH_ACTION_SET = "org.eclipse.jdt.ui.SearchActionSet"; //$NON-NLS-1$
0137:
0138:            /**
0139:             * The editor part id of the editor that presents Java compilation units
0140:             * (value <code>"org.eclipse.jdt.ui.CompilationUnitEditor"</code>).
0141:             */
0142:            public static final String ID_CU_EDITOR = "org.eclipse.jdt.ui.CompilationUnitEditor"; //$NON-NLS-1$
0143:
0144:            /**
0145:             * The editor part id of the editor that presents Java binary class files
0146:             * (value <code>"org.eclipse.jdt.ui.ClassFileEditor"</code>).
0147:             */
0148:            public static final String ID_CF_EDITOR = "org.eclipse.jdt.ui.ClassFileEditor"; //$NON-NLS-1$
0149:
0150:            /**
0151:             * The editor part id of the code snippet editor
0152:             * (value <code>"org.eclipse.jdt.ui.SnippetEditor"</code>).
0153:             */
0154:            public static final String ID_SNIPPET_EDITOR = "org.eclipse.jdt.ui.SnippetEditor"; //$NON-NLS-1$
0155:
0156:            /**
0157:             * The view part id of the Packages view
0158:             * (value <code>"org.eclipse.jdt.ui.PackageExplorer"</code>).
0159:             * <p>
0160:             * When this id is used to access
0161:             * a view part with <code>IWorkbenchPage.findView</code> or 
0162:             * <code>showView</code>, the returned <code>IViewPart</code>
0163:             * can be safely cast to an <code>IPackagesViewPart</code>.
0164:             * </p>
0165:             *
0166:             * @see IPackagesViewPart
0167:             * @see org.eclipse.ui.IWorkbenchPage#findView(java.lang.String)
0168:             * @see org.eclipse.ui.IWorkbenchPage#showView(java.lang.String)
0169:             */
0170:            public static final String ID_PACKAGES = "org.eclipse.jdt.ui.PackageExplorer"; //$NON-NLS-1$
0171:
0172:            /** 
0173:             * The view part id of the type hierarchy part
0174:             * (value <code>"org.eclipse.jdt.ui.TypeHierarchy"</code>).
0175:             * <p>
0176:             * When this id is used to access
0177:             * a view part with <code>IWorkbenchPage.findView</code> or 
0178:             * <code>showView</code>, the returned <code>IViewPart</code>
0179:             * can be safely cast to an <code>ITypeHierarchyViewPart</code>.
0180:             * </p>
0181:             *
0182:             * @see ITypeHierarchyViewPart
0183:             * @see org.eclipse.ui.IWorkbenchPage#findView(java.lang.String)
0184:             * @see org.eclipse.ui.IWorkbenchPage#showView(java.lang.String)
0185:             */
0186:            public static final String ID_TYPE_HIERARCHY = "org.eclipse.jdt.ui.TypeHierarchy"; //$NON-NLS-1$
0187:
0188:            /** 
0189:             * The view part id of the source (declaration) view
0190:             * (value <code>"org.eclipse.jdt.ui.SourceView"</code>).
0191:             *
0192:             * @see org.eclipse.ui.IWorkbenchPage#findView(java.lang.String)
0193:             * @see org.eclipse.ui.IWorkbenchPage#showView(java.lang.String)
0194:             * @since 3.0
0195:             */
0196:            public static final String ID_SOURCE_VIEW = "org.eclipse.jdt.ui.SourceView"; //$NON-NLS-1$
0197:
0198:            /** 
0199:             * The view part id of the Javadoc view
0200:             * (value <code>"org.eclipse.jdt.ui.JavadocView"</code>).
0201:             *
0202:             * @see org.eclipse.ui.IWorkbenchPage#findView(java.lang.String)
0203:             * @see org.eclipse.ui.IWorkbenchPage#showView(java.lang.String)
0204:             * @since 3.0
0205:             */
0206:            public static final String ID_JAVADOC_VIEW = "org.eclipse.jdt.ui.JavadocView"; //$NON-NLS-1$
0207:
0208:            /**
0209:             * The id of the Java Browsing Perspective
0210:             * (value <code>"org.eclipse.jdt.ui.JavaBrowsingPerspective"</code>).
0211:             * 
0212:             * @since 2.0
0213:             */
0214:            public static String ID_BROWSING_PERSPECTIVE = "org.eclipse.jdt.ui.JavaBrowsingPerspective"; //$NON-NLS-1$
0215:
0216:            /**
0217:             * The view part id of the Java Browsing Projects view
0218:             * (value <code>"org.eclipse.jdt.ui.ProjectsView"</code>).
0219:             * 
0220:             * @since 2.0
0221:             */
0222:            public static String ID_PROJECTS_VIEW = "org.eclipse.jdt.ui.ProjectsView"; //$NON-NLS-1$
0223:
0224:            /**
0225:             * The view part id of the Java Browsing Packages view
0226:             * (value <code>"org.eclipse.jdt.ui.PackagesView"</code>).
0227:             * 
0228:             * @since 2.0
0229:             */
0230:            public static String ID_PACKAGES_VIEW = "org.eclipse.jdt.ui.PackagesView"; //$NON-NLS-1$
0231:
0232:            /**
0233:             * The view part id of the Java Browsing Types view
0234:             * (value <code>"org.eclipse.jdt.ui.TypesView"</code>).
0235:             * 
0236:             * @since 2.0
0237:             */
0238:            public static String ID_TYPES_VIEW = "org.eclipse.jdt.ui.TypesView"; //$NON-NLS-1$
0239:
0240:            /**
0241:             * The view part id of the Java Browsing Members view
0242:             * (value <code>"org.eclipse.jdt.ui.MembersView"</code>).
0243:             * 
0244:             * @since 2.0
0245:             */
0246:            public static String ID_MEMBERS_VIEW = "org.eclipse.jdt.ui.MembersView"; //$NON-NLS-1$
0247:
0248:            /**
0249:             * The class org.eclipse.debug.core.model.IProcess allows attaching
0250:             * String properties to processes. The Java UI contributes a property
0251:             * page for IProcess that will show the contents of the property
0252:             * with this key.
0253:             * The intent of this property is to show the command line a process
0254:             * was launched with.
0255:             * @deprecated
0256:             */
0257:            public final static String ATTR_CMDLINE = "org.eclipse.jdt.ui.launcher.cmdLine"; //$NON-NLS-1$
0258:
0259:            /**
0260:             * @deprecated Constant introduced to avoid deprecated warning
0261:             */
0262:            private final static int DEPRECATED_CONSIDER_TYPES = IJavaElementSearchConstants.CONSIDER_TYPES;
0263:
0264:            /**
0265:             * Returns the shared images for the Java UI.
0266:             *
0267:             * @return the shared images manager
0268:             */
0269:            public static ISharedImages getSharedImages() {
0270:                if (fgSharedImages == null)
0271:                    fgSharedImages = new SharedImages();
0272:
0273:                return fgSharedImages;
0274:            }
0275:
0276:            /**
0277:             * Creates a selection dialog that lists all packages of the given Java project.
0278:             * The caller is responsible for opening the dialog with <code>Window.open</code>,
0279:             * and subsequently extracting the selected package (of type
0280:             * <code>IPackageFragment</code>) via <code>SelectionDialog.getResult</code>.
0281:             * 
0282:             * @param parent the parent shell of the dialog to be created
0283:             * @param project the Java project
0284:             * @param style flags defining the style of the dialog; the valid flags are:
0285:             *   <code>IJavaElementSearchConstants.CONSIDER_BINARIES</code>, indicating that 
0286:             *   packages from binary package fragment roots should be included in addition
0287:             *   to those from source package fragment roots;
0288:             *   <code>IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS</code>, indicating that
0289:             *   packages from required projects should be included as well.
0290:             * @param filter the initial pattern to filter the set of packages. For example "com" shows 
0291:             * all packages starting with "com". The meta character '?' representing any character and 
0292:             * '*' representing any string are supported. Clients can pass an empty string if no filtering 
0293:             * is required.
0294:             * @return a new selection dialog
0295:             * @exception JavaModelException if the selection dialog could not be opened
0296:             * 
0297:             * @since 2.0
0298:             */
0299:            public static SelectionDialog createPackageDialog(Shell parent,
0300:                    IJavaProject project, int style, String filter)
0301:                    throws JavaModelException {
0302:                Assert
0303:                        .isTrue((style
0304:                                | IJavaElementSearchConstants.CONSIDER_BINARIES | IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS) == (IJavaElementSearchConstants.CONSIDER_BINARIES | IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS));
0305:
0306:                IPackageFragmentRoot[] roots = null;
0307:                if ((style & IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS) != 0) {
0308:                    roots = project.getAllPackageFragmentRoots();
0309:                } else {
0310:                    roots = project.getPackageFragmentRoots();
0311:                }
0312:
0313:                List consideredRoots = null;
0314:                if ((style & IJavaElementSearchConstants.CONSIDER_BINARIES) != 0) {
0315:                    consideredRoots = Arrays.asList(roots);
0316:                } else {
0317:                    consideredRoots = new ArrayList(roots.length);
0318:                    for (int i = 0; i < roots.length; i++) {
0319:                        IPackageFragmentRoot root = roots[i];
0320:                        if (root.getKind() != IPackageFragmentRoot.K_BINARY)
0321:                            consideredRoots.add(root);
0322:
0323:                    }
0324:                }
0325:
0326:                IJavaSearchScope searchScope = SearchEngine
0327:                        .createJavaSearchScope((IJavaElement[]) consideredRoots
0328:                                .toArray(new IJavaElement[consideredRoots
0329:                                        .size()]));
0330:                BusyIndicatorRunnableContext context = new BusyIndicatorRunnableContext();
0331:                if (style == 0
0332:                        || style == IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS) {
0333:                    return createPackageDialog(parent, context, searchScope,
0334:                            false, true, filter);
0335:                } else {
0336:                    return createPackageDialog(parent, context, searchScope,
0337:                            false, false, filter);
0338:                }
0339:            }
0340:
0341:            /**
0342:             * Creates a selection dialog that lists all packages of the given Java search scope.
0343:             * The caller is responsible for opening the dialog with <code>Window.open</code>,
0344:             * and subsequently extracting the selected package (of type
0345:             * <code>IPackageFragment</code>) via <code>SelectionDialog.getResult</code>.
0346:             * 
0347:             * @param parent the parent shell of the dialog to be created
0348:             * @param context the runnable context to run the search in
0349:             * @param scope the scope defining the available packages.
0350:             * @param multipleSelection true if multiple selection is allowed
0351:             * @param removeDuplicates true if only one package is shown per package name
0352:             * @param filter the initial pattern to filter the set of packages. For example "com" shows 
0353:             * all packages starting with "com". The meta character '?' representing any character and 
0354:             * '*' representing any string are supported. Clients can pass an empty string if no filtering 
0355:             * is required.
0356:             * @return a new selection dialog
0357:             * 
0358:             * @since 3.2
0359:             */
0360:            public static SelectionDialog createPackageDialog(Shell parent,
0361:                    IRunnableContext context, IJavaSearchScope scope,
0362:                    boolean multipleSelection, boolean removeDuplicates,
0363:                    String filter) {
0364:
0365:                int flag = removeDuplicates ? PackageSelectionDialog.F_REMOVE_DUPLICATES
0366:                        : 0;
0367:                PackageSelectionDialog dialog = new PackageSelectionDialog(
0368:                        parent, context, flag, scope);
0369:                dialog.setFilter(filter);
0370:                dialog.setIgnoreCase(false);
0371:                dialog.setMultipleSelection(multipleSelection);
0372:                return dialog;
0373:            }
0374:
0375:            /**
0376:             * Creates a selection dialog that lists all packages of the given Java project.
0377:             * The caller is responsible for opening the dialog with <code>Window.open</code>,
0378:             * and subsequently extracting the selected package (of type
0379:             * <code>IPackageFragment</code>) via <code>SelectionDialog.getResult</code>.
0380:             * 
0381:             * @param parent the parent shell of the dialog to be created
0382:             * @param project the Java project
0383:             * @param style flags defining the style of the dialog; the valid flags are:
0384:             *   <code>IJavaElementSearchConstants.CONSIDER_BINARIES</code>, indicating that 
0385:             *   packages from binary package fragment roots should be included in addition
0386:             *   to those from source package fragment roots;
0387:             *   <code>IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS</code>, indicating that
0388:             *   packages from required projects should be included as well.
0389:             * @return a new selection dialog
0390:             * @exception JavaModelException if the selection dialog could not be opened
0391:             */
0392:            public static SelectionDialog createPackageDialog(Shell parent,
0393:                    IJavaProject project, int style) throws JavaModelException {
0394:                return createPackageDialog(parent, project, style, ""); //$NON-NLS-1$
0395:            }
0396:
0397:            /**
0398:             * Creates a selection dialog that lists all packages under the given package 
0399:             * fragment root.
0400:             * The caller is responsible for opening the dialog with <code>Window.open</code>,
0401:             * and subsequently extracting the selected package (of type
0402:             * <code>IPackageFragment</code>) via <code>SelectionDialog.getResult</code>.
0403:             * 
0404:             * @param parent the parent shell of the dialog to be created
0405:             * @param root the package fragment root
0406:             * @param filter the initial pattern to filter the set of packages. For example "com" shows 
0407:             * all packages starting with "com". The meta character '?' representing any character and 
0408:             * '*' representing any string are supported. Clients can pass an empty string if no filtering 
0409:             * is required.
0410:             * @return a new selection dialog
0411:             * @exception JavaModelException if the selection dialog could not be opened
0412:             * 
0413:             * @since 2.0
0414:             */
0415:            public static SelectionDialog createPackageDialog(Shell parent,
0416:                    IPackageFragmentRoot root, String filter)
0417:                    throws JavaModelException {
0418:                IJavaSearchScope scope = SearchEngine
0419:                        .createJavaSearchScope(new IJavaElement[] { root });
0420:                BusyIndicatorRunnableContext context = new BusyIndicatorRunnableContext();
0421:                return createPackageDialog(parent, context, scope, false, true,
0422:                        filter);
0423:            }
0424:
0425:            /**
0426:             * Creates a selection dialog that lists all packages under the given package 
0427:             * fragment root.
0428:             * The caller is responsible for opening the dialog with <code>Window.open</code>,
0429:             * and subsequently extracting the selected package (of type
0430:             * <code>IPackageFragment</code>) via <code>SelectionDialog.getResult</code>.
0431:             * 
0432:             * @param parent the parent shell of the dialog to be created
0433:             * @param root the package fragment root
0434:             * @return a new selection dialog
0435:             * @exception JavaModelException if the selection dialog could not be opened
0436:             */
0437:            public static SelectionDialog createPackageDialog(Shell parent,
0438:                    IPackageFragmentRoot root) throws JavaModelException {
0439:                return createPackageDialog(parent, root, ""); //$NON-NLS-1$
0440:            }
0441:
0442:            /**
0443:             * Creates a selection dialog that lists all types in the given project.
0444:             * The caller is responsible for opening the dialog with <code>Window.open</code>,
0445:             * and subsequently extracting the selected type(s) (of type
0446:             * <code>IType</code>) via <code>SelectionDialog.getResult</code>.
0447:             * 
0448:             * @param parent the parent shell of the dialog to be created
0449:             * @param context the runnable context used to show progress when the dialog
0450:             *   is being populated
0451:             * @param project the Java project
0452:             * @param style flags defining the style of the dialog; the only valid values are
0453:             *   <code>IJavaElementSearchConstants.CONSIDER_CLASSES</code>,
0454:             *   <code>IJavaElementSearchConstants.CONSIDER_INTERFACES</code>, 
0455:             *   <code>IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES</code>,
0456:             *   <code>IJavaElementSearchConstants.CONSIDER_ENUMS</code>,
0457:             *   <code>IJavaElementSearchConstants.CONSIDER_ALL_TYPES</code>,
0458:             *   <code>IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES</code>
0459:             *   <code>IJavaElementSearchConstants.CONSIDER_CLASSES_AND_ENUMS</code>. Please note that
0460:             *   the bitwise OR combination of the elementary constants is not supported.
0461:             * @param multipleSelection <code>true</code> if multiple selection is allowed
0462:             * 
0463:             * @return a new selection dialog
0464:             * 
0465:             * @exception JavaModelException if the selection dialog could not be opened
0466:             */
0467:            public static SelectionDialog createTypeDialog(Shell parent,
0468:                    IRunnableContext context, IProject project, int style,
0469:                    boolean multipleSelection) throws JavaModelException {
0470:                IJavaSearchScope scope = SearchEngine
0471:                        .createJavaSearchScope(new IJavaProject[] { JavaCore
0472:                                .create(project) });
0473:                return createTypeDialog(parent, context, scope, style,
0474:                        multipleSelection);
0475:            }
0476:
0477:            /**
0478:             * Creates a selection dialog that lists all types in the given scope.
0479:             * The caller is responsible for opening the dialog with <code>Window.open</code>,
0480:             * and subsequently extracting the selected type(s) (of type
0481:             * <code>IType</code>) via <code>SelectionDialog.getResult</code>.
0482:             * 
0483:             * @param parent the parent shell of the dialog to be created
0484:             * @param context the runnable context used to show progress when the dialog
0485:             *   is being populated
0486:             * @param scope the scope that limits which types are included
0487:             * @param style flags defining the style of the dialog; the only valid values are
0488:             *   <code>IJavaElementSearchConstants.CONSIDER_CLASSES</code>,
0489:             *   <code>IJavaElementSearchConstants.CONSIDER_INTERFACES</code>, 
0490:             *   <code>IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES</code>,
0491:             *   <code>IJavaElementSearchConstants.CONSIDER_ENUMS</code>,
0492:             *   <code>IJavaElementSearchConstants.CONSIDER_ALL_TYPES</code>,
0493:             *   <code>IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES</code>
0494:             *   <code>IJavaElementSearchConstants.CONSIDER_CLASSES_AND_ENUMS</code>. Please note that
0495:             *   the bitwise OR combination of the elementary constants is not supported.
0496:             * @param multipleSelection <code>true</code> if multiple selection is allowed
0497:             * 
0498:             * @return a new selection dialog
0499:             * 
0500:             * @exception JavaModelException if the selection dialog could not be opened
0501:             */
0502:            public static SelectionDialog createTypeDialog(Shell parent,
0503:                    IRunnableContext context, IJavaSearchScope scope,
0504:                    int style, boolean multipleSelection)
0505:                    throws JavaModelException {
0506:                return createTypeDialog(parent, context, scope, style,
0507:                        multipleSelection, "");//$NON-NLS-1$
0508:            }
0509:
0510:            /**
0511:             * Creates a selection dialog that lists all types in the given scope.
0512:             * The caller is responsible for opening the dialog with <code>Window.open</code>,
0513:             * and subsequently extracting the selected type(s) (of type
0514:             * <code>IType</code>) via <code>SelectionDialog.getResult</code>.
0515:             * 
0516:             * @param parent the parent shell of the dialog to be created
0517:             * @param context the runnable context used to show progress when the dialog
0518:             *   is being populated
0519:             * @param scope the scope that limits which types are included
0520:             * @param style flags defining the style of the dialog; the only valid values are
0521:             *   <code>IJavaElementSearchConstants.CONSIDER_CLASSES</code>,
0522:             *   <code>IJavaElementSearchConstants.CONSIDER_INTERFACES</code>, 
0523:             *   <code>IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES</code>,
0524:             *   <code>IJavaElementSearchConstants.CONSIDER_ENUMS</code>,
0525:             *   <code>IJavaElementSearchConstants.CONSIDER_ALL_TYPES</code>,
0526:             *   <code>IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES</code>
0527:             *   <code>IJavaElementSearchConstants.CONSIDER_CLASSES_AND_ENUMS</code>. Please note that
0528:             *   the bitwise OR combination of the elementary constants is not supported.
0529:             * @param multipleSelection <code>true</code> if multiple selection is allowed
0530:             * @param filter the initial pattern to filter the set of types. For example "Abstract" shows 
0531:             *  all types starting with "abstract". The meta character '?' representing any character and 
0532:             *  '*' representing any string are supported. Clients can pass an empty string if no filtering 
0533:             *  is required.
0534:             *  
0535:             * @return a new selection dialog
0536:             * 
0537:             * @exception JavaModelException if the selection dialog could not be opened
0538:             * 
0539:             * @since 2.0
0540:             */
0541:            public static SelectionDialog createTypeDialog(Shell parent,
0542:                    IRunnableContext context, IJavaSearchScope scope,
0543:                    int style, boolean multipleSelection, String filter)
0544:                    throws JavaModelException {
0545:                return createTypeDialog(parent, context, scope, style,
0546:                        multipleSelection, filter, null);
0547:            }
0548:
0549:            /**
0550:             * Creates a selection dialog that lists all types in the given scope.
0551:             * The caller is responsible for opening the dialog with <code>Window.open</code>,
0552:             * and subsequently extracting the selected type(s) (of type
0553:             * <code>IType</code>) via <code>SelectionDialog.getResult</code>.
0554:             * 
0555:             * @param parent the parent shell of the dialog to be created
0556:             * @param context the runnable context used to show progress when the dialog
0557:             *   is being populated
0558:             * @param scope the scope that limits which types are included
0559:             * @param style flags defining the style of the dialog; the only valid values are
0560:             *   <code>IJavaElementSearchConstants.CONSIDER_CLASSES</code>,
0561:             *   <code>IJavaElementSearchConstants.CONSIDER_INTERFACES</code>, 
0562:             *   <code>IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES</code>,
0563:             *   <code>IJavaElementSearchConstants.CONSIDER_ENUMS</code>,
0564:             *   <code>IJavaElementSearchConstants.CONSIDER_ALL_TYPES</code>,
0565:             *   <code>IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES</code>
0566:             *   <code>IJavaElementSearchConstants.CONSIDER_CLASSES_AND_ENUMS</code>. Please note that
0567:             *   the bitwise OR combination of the elementary constants is not supported.
0568:             * @param multipleSelection <code>true</code> if multiple selection is allowed
0569:             * @param filter the initial pattern to filter the set of types. For example "Abstract" shows 
0570:             *  all types starting with "abstract". The meta character '?' representing any character and 
0571:             *  '*' representing any string are supported. Clients can pass an empty string if no filtering
0572:             *  is required.
0573:             * @param extension a user interface extension to the type selection dialog or <code>null</code>
0574:             *  if no extension is desired
0575:             *  
0576:             * @return a new selection dialog
0577:             * 
0578:             * @exception JavaModelException if the selection dialog could not be opened
0579:             * 
0580:             * @since 3.2
0581:             */
0582:            public static SelectionDialog createTypeDialog(Shell parent,
0583:                    IRunnableContext context, IJavaSearchScope scope,
0584:                    int style, boolean multipleSelection, String filter,
0585:                    TypeSelectionExtension extension) throws JavaModelException {
0586:                int elementKinds = 0;
0587:                if (style == IJavaElementSearchConstants.CONSIDER_ALL_TYPES) {
0588:                    elementKinds = IJavaSearchConstants.TYPE;
0589:                } else if (style == IJavaElementSearchConstants.CONSIDER_INTERFACES) {
0590:                    elementKinds = IJavaSearchConstants.INTERFACE;
0591:                } else if (style == IJavaElementSearchConstants.CONSIDER_CLASSES) {
0592:                    elementKinds = IJavaSearchConstants.CLASS;
0593:                } else if (style == IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES) {
0594:                    elementKinds = IJavaSearchConstants.ANNOTATION_TYPE;
0595:                } else if (style == IJavaElementSearchConstants.CONSIDER_ENUMS) {
0596:                    elementKinds = IJavaSearchConstants.ENUM;
0597:                } else if (style == IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES) {
0598:                    elementKinds = IJavaSearchConstants.CLASS_AND_INTERFACE;
0599:                } else if (style == IJavaElementSearchConstants.CONSIDER_CLASSES_AND_ENUMS) {
0600:                    elementKinds = IJavaSearchConstants.CLASS_AND_ENUM;
0601:                } else if (style == DEPRECATED_CONSIDER_TYPES) {
0602:                    elementKinds = IJavaSearchConstants.CLASS_AND_INTERFACE;
0603:                } else {
0604:                    throw new IllegalArgumentException(
0605:                            "Invalid style constant."); //$NON-NLS-1$
0606:                }
0607:                FilteredTypesSelectionDialog dialog = new FilteredTypesSelectionDialog(
0608:                        parent, multipleSelection, context, scope,
0609:                        elementKinds, extension);
0610:                dialog.setMessage(JavaUIMessages.JavaUI_defaultDialogMessage);
0611:                dialog.setInitialPattern(filter);
0612:                return dialog;
0613:            }
0614:
0615:            /**
0616:             * Creates a selection dialog that lists all types in the given scope containing 
0617:             * a standard <code>main</code> method.
0618:             * The caller is responsible for opening the dialog with <code>Window.open</code>,
0619:             * and subsequently extracting the selected type(s) (of type
0620:             * <code>IType</code>) via <code>SelectionDialog.getResult</code>.
0621:             * 
0622:             * @param parent the parent shell of the dialog to be created
0623:             * @param context the runnable context used to show progress when the dialog
0624:             *   is being populated
0625:             * @param scope the scope that limits which types are included
0626:             * @param style flags defining the style of the dialog; the only valid values are
0627:             *   <code>IJavaElementSearchConstants.CONSIDER_BINARIES</code>,
0628:             *   <code>CONSIDER_EXTERNAL_JARS</code>, or their bitwise OR, or <code>0</code>
0629:             * @param multipleSelection <code>true</code> if multiple selection is allowed
0630:             * @param filter the initial pattern to filter the set of types containing a main method. For 
0631:             * example "App" shows all types starting with "app". The meta character '?' representing 
0632:             * any character and '*' representing any string are supported. Clients can pass an empty 
0633:             * string if no filtering is required.
0634:             * @return a new selection dialog
0635:             * 
0636:             * @since 2.0
0637:             */
0638:            public static SelectionDialog createMainTypeDialog(Shell parent,
0639:                    IRunnableContext context, IJavaSearchScope scope,
0640:                    int style, boolean multipleSelection, String filter) {
0641:                if (multipleSelection) {
0642:                    MultiMainTypeSelectionDialog dialog = new MultiMainTypeSelectionDialog(
0643:                            parent, context, scope, style);
0644:                    dialog.setFilter(filter);
0645:                    return dialog;
0646:                } else {
0647:                    MainTypeSelectionDialog dialog = new MainTypeSelectionDialog(
0648:                            parent, context, scope, style);
0649:                    dialog.setFilter(filter);
0650:                    return dialog;
0651:                }
0652:            }
0653:
0654:            /**
0655:             * Creates a selection dialog that lists all types in the given scope containing 
0656:             * a standard <code>main</code> method.
0657:             * The caller is responsible for opening the dialog with <code>Window.open</code>,
0658:             * and subsequently extracting the selected type(s) (of type
0659:             * <code>IType</code>) via <code>SelectionDialog.getResult</code>.
0660:             * 
0661:             * @param parent the parent shell of the dialog to be created
0662:             * @param context the runnable context used to show progress when the dialog
0663:             *   is being populated
0664:             * @param scope the scope that limits which types are included
0665:             * @param style flags defining the style of the dialog; the only valid values are
0666:             *   <code>IJavaElementSearchConstants.CONSIDER_BINARIES</code>,
0667:             *   <code>CONSIDER_EXTERNAL_JARS</code>, or their bitwise OR, or <code>0</code>
0668:             * @param multipleSelection <code>true</code> if multiple selection is allowed
0669:             * @return a new selection dialog
0670:             */
0671:            public static SelectionDialog createMainTypeDialog(Shell parent,
0672:                    IRunnableContext context, IJavaSearchScope scope,
0673:                    int style, boolean multipleSelection) {
0674:                return createMainTypeDialog(parent, context, scope, style,
0675:                        multipleSelection, "");//$NON-NLS-1$
0676:            }
0677:
0678:            /**
0679:             * Opens an editor on the given Java element in the active page. Valid elements are all Java elements that are {@link ISourceReference}.
0680:             * For elements inside a compilation unit or class file, the parent is opened in the editor is opened and the element revealed.
0681:             * If there already is an open Java editor for the given element, it is returned.
0682:             *
0683:             * @param element the input element; either a compilation unit 
0684:             *   (<code>ICompilationUnit</code>) or a class file (<code>IClassFile</code>) or source references inside.
0685:             * @return returns the editor part of the opened editor or <code>null</code> if the element is not a {@link ISourceReference} or the
0686:             * file was opened in an external editor.
0687:             * @exception PartInitException if the editor could not be initialized or no workbench page is active
0688:             * @exception JavaModelException if this element does not exist or if an exception occurs while accessing its underlying resource
0689:             */
0690:            public static IEditorPart openInEditor(IJavaElement element)
0691:                    throws JavaModelException, PartInitException {
0692:                return openInEditor(element, true, true);
0693:            }
0694:
0695:            /**
0696:             * Opens an editor on the given Java element in the active page. Valid elements are all Java elements that are {@link ISourceReference}.
0697:             * For elements inside a compilation unit or class file, the parent is opened in the editor is opened.
0698:             * If there already is an open Java editor for the given element, it is returned.
0699:             *
0700:             * @param element the input element; either a compilation unit 
0701:             *   (<code>ICompilationUnit</code>) or a class file (<code>IClassFile</code>) or source references inside.
0702:             * @param activate if set, the editor will be activated.
0703:             * @param reveal if set, the element will be revealed.
0704:             * @return returns the editor part of the opened editor or <code>null</code> if the element is not a {@link ISourceReference} or the
0705:             * file was opened in an external editor.
0706:             * @exception PartInitException if the editor could not be initialized or no workbench page is active
0707:             * @exception JavaModelException if this element does not exist or if an exception occurs while accessing its underlying resource
0708:             * @since 3.3
0709:             */
0710:            public static IEditorPart openInEditor(IJavaElement element,
0711:                    boolean activate, boolean reveal)
0712:                    throws JavaModelException, PartInitException {
0713:                if (!(element instanceof  ISourceReference)) {
0714:                    return null;
0715:                }
0716:                IEditorPart part = EditorUtility
0717:                        .openInEditor(element, activate);
0718:                if (reveal && part != null) {
0719:                    EditorUtility.revealInEditor(part, element);
0720:                }
0721:                return part;
0722:            }
0723:
0724:            /** 
0725:             * Reveals the source range of the given source reference element in the
0726:             * given editor. No checking is done if the editor displays a compilation unit or
0727:             * class file that contains the given source reference. The editor simply reveals
0728:             * the source range denoted by the given source reference.
0729:             *
0730:             * @param part the editor displaying the compilation unit or class file
0731:             * @param element the source reference element defining the source range to be revealed
0732:             * 
0733:             * @deprecated use <code>revealInEditor(IEditorPart, IJavaElement)</code> instead
0734:             */
0735:            public static void revealInEditor(IEditorPart part,
0736:                    ISourceReference element) {
0737:                if (element instanceof  IJavaElement)
0738:                    revealInEditor(part, (IJavaElement) element);
0739:            }
0740:
0741:            /** 
0742:             * Reveals the given java element  in the given editor. If the element is not an instance
0743:             * of <code>ISourceReference</code> this method result in a NOP. If it is a source
0744:             * reference no checking is done if the editor displays a compilation unit or class file that 
0745:             * contains the source reference element. The editor simply reveals the source range 
0746:             * denoted by the given element.
0747:             * 
0748:             * @param part the editor displaying a compilation unit or class file
0749:             * @param element the element to be revealed
0750:             * 
0751:             * @since 2.0
0752:             */
0753:            public static void revealInEditor(IEditorPart part,
0754:                    IJavaElement element) {
0755:                EditorUtility.revealInEditor(part, element);
0756:            }
0757:
0758:            /**
0759:             * Returns the working copy manager for the Java UI plug-in.
0760:             *
0761:             * @return the working copy manager for the Java UI plug-in
0762:             */
0763:            public static IWorkingCopyManager getWorkingCopyManager() {
0764:                return JavaPlugin.getDefault().getWorkingCopyManager();
0765:            }
0766:
0767:            /**
0768:             * Returns the Java element wrapped by the given editor input.
0769:             *
0770:             * @param editorInput the editor input
0771:             * @return the Java element wrapped by <code>editorInput</code> or <code>null</code> if none
0772:             * @since 3.2
0773:             */
0774:            public static IJavaElement getEditorInputJavaElement(
0775:                    IEditorInput editorInput) {
0776:                // Performance: check working copy manager first: this is faster
0777:                IJavaElement je = JavaPlugin.getDefault()
0778:                        .getWorkingCopyManager().getWorkingCopy(editorInput);
0779:                if (je != null)
0780:                    return je;
0781:
0782:                return (IJavaElement) editorInput
0783:                        .getAdapter(IJavaElement.class);
0784:            }
0785:
0786:            /**
0787:             * Returns the {@link ITypeRoot} wrapped by the given editor input.
0788:             *
0789:             * @param editorInput the editor input
0790:             * @return the {@link ITypeRoot} wrapped by <code>editorInput</code> or <code>null</code> if the editor input
0791:             * does not stand for a ITypeRoot
0792:             * 
0793:             * @since 3.4
0794:             */
0795:            public static ITypeRoot getEditorInputTypeRoot(
0796:                    IEditorInput editorInput) {
0797:                // Performance: check working copy manager first: this is faster
0798:                ICompilationUnit cu = JavaPlugin.getDefault()
0799:                        .getWorkingCopyManager().getWorkingCopy(editorInput);
0800:                if (cu != null)
0801:                    return cu;
0802:
0803:                IJavaElement je = (IJavaElement) editorInput
0804:                        .getAdapter(IJavaElement.class);
0805:                if (je instanceof  ITypeRoot)
0806:                    return (ITypeRoot) je;
0807:
0808:                return null;
0809:            }
0810:
0811:            /**
0812:             * Answers the shared working copies currently registered for the Java plug-in.
0813:             * Note that the returned array can include working copies that are
0814:             * not on the class path of a Java project.
0815:             * 
0816:             * @return the list of shared working copies
0817:             * 
0818:             * @see org.eclipse.jdt.core.JavaCore#getSharedWorkingCopies(org.eclipse.jdt.core.IBufferFactory)
0819:             * @since 2.0
0820:             * @deprecated Use {@link JavaCore#getWorkingCopies(org.eclipse.jdt.core.WorkingCopyOwner)} instead with <code>null</code> as
0821:             * argument for owner.
0822:             */
0823:            public static org.eclipse.jdt.core.IWorkingCopy[] getSharedWorkingCopies() {
0824:                return JavaCore.getSharedWorkingCopies(getBufferFactory());
0825:            }
0826:
0827:            /**
0828:             * Answers the shared working copies that are on the class path of a Java
0829:             * project currently registered for the Java plug-in.
0830:             * 
0831:             * 
0832:             * @return the list of shared working copies
0833:             * 
0834:             * @see #getSharedWorkingCopies()
0835:             * @since 2.1
0836:             * @deprecated Use {@link JavaCore#getWorkingCopies(org.eclipse.jdt.core.WorkingCopyOwner)} instead and filter the list
0837:             * with {@link IJavaProject#isOnClasspath(IJavaElement)}.
0838:             */
0839:            public static org.eclipse.jdt.core.IWorkingCopy[] getSharedWorkingCopiesOnClasspath() {
0840:                org.eclipse.jdt.core.IWorkingCopy[] wcs = getSharedWorkingCopies();
0841:                List result = new ArrayList(wcs.length);
0842:                for (int i = 0; i < wcs.length; i++) {
0843:                    org.eclipse.jdt.core.IWorkingCopy wc = wcs[i];
0844:                    if (wc instanceof  IJavaElement) {
0845:                        IJavaElement je = (IJavaElement) wc;
0846:                        if (je.getJavaProject().isOnClasspath(je)) {
0847:                            result.add(wc);
0848:                        }
0849:                    }
0850:                }
0851:                return (org.eclipse.jdt.core.IWorkingCopy[]) result
0852:                        .toArray(new org.eclipse.jdt.core.IWorkingCopy[result
0853:                                .size()]);
0854:            }
0855:
0856:            /**
0857:             * Returns the buffer factory for the Java UI plug-in.
0858:             *
0859:             * @return the buffer factory for the Java UI plug-in
0860:             * 
0861:             * @see org.eclipse.jdt.core.IBufferFactory
0862:             * @since 2.0
0863:             * @deprecated {@link org.eclipse.jdt.core.IBufferFactory} has been replaced by {@link org.eclipse.jdt.core.WorkingCopyOwner}.
0864:             * The Java UI plug-in uses the <i>primary working copy owner</i> that can be accessed with <code>null</code> in
0865:             * API's that require an owner
0866:             */
0867:            public static org.eclipse.jdt.core.IBufferFactory getBufferFactory() {
0868:                return JavaPlugin.getDefault().getBufferFactory();
0869:            }
0870:
0871:            /**
0872:             * Returns the DocumentProvider used for Java compilation units.
0873:             *
0874:             * @return the DocumentProvider for Java compilation units.
0875:             * 
0876:             * @see IDocumentProvider
0877:             * @since 2.0
0878:             */
0879:            public static IDocumentProvider getDocumentProvider() {
0880:                return JavaPlugin.getDefault()
0881:                        .getCompilationUnitDocumentProvider();
0882:            }
0883:
0884:            /**
0885:             * Sets the Javadoc location for an archive with the given path.
0886:             * 
0887:             * @param archivePath the path of the library; this can be an workspace path
0888:             * or an external path in case of an external library.
0889:             * @param url the Javadoc location to set. This location should contain index.html and
0890:             * a file 'package-list'. <code>null</code> clears the current documentation
0891:             * location.
0892:             * @deprecated Javadoc is now attached to the classpath entry. 
0893:             * Evaluate the libraries classpath entry and reconfigure the Javadoc location there.
0894:             * 
0895:             * @since 2.0
0896:             */
0897:            public static void setLibraryJavadocLocation(IPath archivePath,
0898:                    URL url) {
0899:                // deprecated
0900:            }
0901:
0902:            /**
0903:             * Sets the Javadoc locations for archives with the given paths. 
0904:             * 
0905:             * @param archivePaths the paths of the libraries. can be workspace paths
0906:             * or external paths in case of an external library.
0907:             * @param urls the Javadoc locations to set. Each location corresponds to the archive path of the same index. A location should contain index.html and
0908:             * a file 'package-list'. <code>null</code> is a valid location entry and clears the current documentation
0909:             * location. The length of the location array must be equals to the number of archive paths passed.
0910:             * 
0911:             * 	@deprecated Javadoc is now attached to the classpath entry. 
0912:             * Evaluate the libraries classpath entry and reconfigure the Javadoc location there.
0913:             * 
0914:             * @since 3.0
0915:             */
0916:            public static void setLibraryJavadocLocations(IPath[] archivePaths,
0917:                    URL[] urls) {
0918:                // deprecated
0919:            }
0920:
0921:            /**
0922:             * Returns the Javadoc location for an archive or <code>null</code> if no
0923:             * location is available.
0924:             * 
0925:             * @param archivePath the path of the library. This can be an workspace path
0926:             * or an external path in case of an external library.
0927:             * @return the Javadoc location for an archive or <code>null</code>.
0928:             * 
0929:             * @deprecated Javadoc is now attached to the classpath entry. Use {@link #getJavadocBaseLocation(IJavaElement)}
0930:             * with the archive's {@link IPackageFragmentRoot} or use {@link #getLibraryJavadocLocation(IClasspathEntry)}
0931:             * with the archive's {@link IClasspathEntry}.
0932:             * 
0933:             * @since 2.0
0934:             */
0935:            public static URL getLibraryJavadocLocation(IPath archivePath) {
0936:                return null;
0937:            }
0938:
0939:            /**
0940:             * Returns the Javadoc location for library's classpath entry or <code>null</code> if no
0941:             * location is available. Note that only classpath entries of kind {@link IClasspathEntry#CPE_LIBRARY} and
0942:             * {@link IClasspathEntry#CPE_VARIABLE} support Javadoc locations.
0943:             * 
0944:             * @param entry the classpath entry to get the Javadoc location for
0945:             * @return the Javadoc location or<code>null</code> if no Javadoc location is available
0946:             * @throws IllegalArgumentException Thrown when the entry is <code>null</code> or not of kind
0947:             * {@link IClasspathEntry#CPE_LIBRARY} or {@link IClasspathEntry#CPE_VARIABLE}.
0948:             * 
0949:             * @since 3.1
0950:             */
0951:            public static URL getLibraryJavadocLocation(IClasspathEntry entry) {
0952:                return JavaDocLocations.getLibraryJavadocLocation(entry);
0953:            }
0954:
0955:            /**
0956:             * Sets the Javadoc location for a Java project. This location is used for
0957:             * all types located in the project's source folders.
0958:             * 
0959:             * @param project the project
0960:             * @param url the Javadoc location to set. This location should contain index.html and
0961:             * a file 'package-list'. <code>null</code> clears the current documentation
0962:             * location.
0963:             * 
0964:             * @since 2.1
0965:             */
0966:            public static void setProjectJavadocLocation(IJavaProject project,
0967:                    URL url) {
0968:                JavaDocLocations.setProjectJavadocLocation(project, url);
0969:            }
0970:
0971:            /**
0972:             * Returns the Javadoc location for a Java project or <code>null</code> if no
0973:             * location is available. This location is used for all types located in the project's
0974:             * source folders.
0975:             * 
0976:             * @param project the project
0977:             * @return the Javadoc location for a Java project or <code>null</code>
0978:             * 
0979:             * @since 2.1
0980:             */
0981:            public static URL getProjectJavadocLocation(IJavaProject project) {
0982:                return JavaDocLocations.getProjectJavadocLocation(project);
0983:            }
0984:
0985:            /**
0986:             * Returns the Javadoc base URL for an element. The base location contains the
0987:             * index file. This location doesn't have to exist. Returns <code>null</code>
0988:             * if no javadoc location has been attached to the element's library or project.
0989:             * Example of a returned URL is <i>http://www.junit.org/junit/javadoc</i>.
0990:             * 
0991:             * @param element the element for which the documentation URL is requested.
0992:             * @return the base location
0993:             * @throws JavaModelException thrown when the element can not be accessed
0994:             * 
0995:             * @since 2.0
0996:             */
0997:            public static URL getJavadocBaseLocation(IJavaElement element)
0998:                    throws JavaModelException {
0999:                return JavaDocLocations.getJavadocBaseLocation(element);
1000:            }
1001:
1002:            /**
1003:             * Returns the Javadoc URL for an element. Example of a returned URL is
1004:             * <i>http://www.junit.org/junit/javadoc/junit/extensions/TestSetup.html</i>.
1005:             * This returned location doesn't have to exist. Returns <code>null</code>
1006:             * if no javadoc location has been attached to the element's library or
1007:             * project.
1008:             * 
1009:             * @param element the element for which the documentation URL is requested.
1010:             * @param includeAnchor If set, the URL contains an anchor for member references:
1011:             * <i>http://www.junit.org/junit/javadoc/junit/extensions/TestSetup.html#run(junit.framework.TestResult)</i>. Note
1012:             * that this involves type resolving and is a more expensive call than without anchor.
1013:             * @return the Javadoc URL for the element
1014:             * @throws JavaModelException thrown when the element can not be accessed
1015:             * 
1016:             * @since 2.0
1017:             */
1018:            public static URL getJavadocLocation(IJavaElement element,
1019:                    boolean includeAnchor) throws JavaModelException {
1020:                return JavaDocLocations.getJavadocLocation(element,
1021:                        includeAnchor);
1022:            }
1023:
1024:            /**
1025:             * Returns the transfer instance used to copy/paste Java elements to
1026:             * and from the clipboard. Objects managed by this transfer instance
1027:             * are of type <code>IJavaElement[]</code>. So to access data from the
1028:             * clipboard clients should use the following code snippet:
1029:             * <pre>
1030:             *   IJavaElement[] elements=
1031:             *     (IJavaElement[])clipboard.getContents(JavaUI.getJavaElementClipboardTransfer());
1032:             * </pre>  
1033:             * 
1034:             * To put elements into the clipboard use the following snippet:
1035:             * 
1036:             * <pre>
1037:             *    IJavaElement[] javaElements= ...;
1038:             *    clipboard.setContents(
1039:             *     new Object[] { javaElements },
1040:             *     new Transfer[] { JavaUI.getJavaElementClipboardTransfer() } );
1041:             * </pre>
1042:             * 
1043:             * @return returns the transfer object used to copy/paste Java elements
1044:             *  to and from the clipboard
1045:             * 
1046:             * @since 3.0
1047:             */
1048:            public static Transfer getJavaElementClipboardTransfer() {
1049:                return JavaElementTransfer.getInstance();
1050:            }
1051:
1052:            /**
1053:             * Returns the color manager the Java UI plug-in which is used to manage
1054:             * any Java-specific colors needed for such things like syntax highlighting.
1055:             *
1056:             * @return the color manager to be used for Java text viewers
1057:             * @since 3.2
1058:             */
1059:            public static IColorManager getColorManager() {
1060:                return JavaPlugin.getDefault().getJavaTextTools()
1061:                        .getColorManager();
1062:            }
1063:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.