Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 53562 Details for
Bug 160905
Need better validateEdit api
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch to org.eclipse.core.resources and org.eclipse.ui.ide
patch.txt (text/plain), 33.38 KB, created by
John Arthorne
on 2006-11-09 13:46:51 EST
(
hide
)
Description:
Patch to org.eclipse.core.resources and org.eclipse.ui.ide
Filename:
MIME Type:
Creator:
John Arthorne
Created:
2006-11-09 13:46:51 EST
Size:
33.38 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.resources >Index: src/org/eclipse/core/resources/ResourcesPlugin.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/resources/ResourcesPlugin.java,v >retrieving revision 1.48 >diff -u -r1.48 ResourcesPlugin.java >--- src/org/eclipse/core/resources/ResourcesPlugin.java 26 Oct 2006 16:14:17 -0000 1.48 >+++ src/org/eclipse/core/resources/ResourcesPlugin.java 9 Nov 2006 18:48:34 -0000 >@@ -92,7 +92,7 @@ > * @since 3.2 > */ > public static final String PT_MODEL_PROVIDERS = "modelProviders"; //$NON-NLS-1$ >- >+ > /** > * Constant identifying the job family identifier for the background autobuild job. > * >@@ -100,15 +100,15 @@ > * @since 3.0 > */ > public static final Object FAMILY_AUTO_BUILD = new Object(); >- >+ > /** > * Constant identifying the job family identifier for the background auto-refresh job. > * > * @see IJobManager#join(Object, IProgressMonitor) > * @since 3.1 > */ >- public static final Object FAMILY_AUTO_REFRESH = new Object(); >- >+ public static final Object FAMILY_AUTO_REFRESH = new Object(); >+ > /** > * Constant identifying the job family identifier for a background build job. All clients > * that schedule background jobs for performing builds should include this job >@@ -360,7 +360,7 @@ > // make it easier to debug cases where open() is failing. > workspace = new Workspace(); > PlatformURLResourceConnection.startup(workspace.getRoot().getLocation()); >- IStatus result = workspace.open(null); >+ IStatus result = workspace.open(context, null); > if (!result.isOK()) > getLog().log(result); > } >Index: src/org/eclipse/core/resources/IWorkspace.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/resources/IWorkspace.java,v >retrieving revision 1.77 >diff -u -r1.77 IWorkspace.java >--- src/org/eclipse/core/resources/IWorkspace.java 13 Jul 2006 17:42:24 -0000 1.77 >+++ src/org/eclipse/core/resources/IWorkspace.java 9 Nov 2006 18:48:34 -0000 >@@ -80,6 +80,16 @@ > public static final int AVOID_UPDATE = 1; > > /** >+ * A marker object used when calling {@link #validateEdit(IFile[], Object)} >+ * to indicate that an attempt should be made to locate an appropriate >+ * shell for performing validation. >+ * >+ * @see IWorkspace#validateEdit(IFile[], Object) >+ * @since 3.3 >+ */ >+ public static final Object FIND_UI_CONTEXT = new Object(); >+ >+ /** > * Adds the given listener for resource change events to this workspace. Has > * no effect if an identical listener is already registered. > * <p> >Index: src/org/eclipse/core/internal/resources/Workspace.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java,v >retrieving revision 1.209 >diff -u -r1.209 Workspace.java >--- src/org/eclipse/core/internal/resources/Workspace.java 31 Oct 2006 17:16:28 -0000 1.209 >+++ src/org/eclipse/core/internal/resources/Workspace.java 9 Nov 2006 18:48:34 -0000 >@@ -29,6 +29,7 @@ > import org.eclipse.core.runtime.jobs.Job; > import org.eclipse.osgi.util.NLS; > import org.osgi.framework.Bundle; >+import org.osgi.framework.BundleContext; > import org.xml.sax.InputSource; > > public class Workspace extends PlatformObject implements IWorkspace, ICoreConstants { >@@ -114,6 +115,11 @@ > protected IFileModificationValidator validator = null; > > /** >+ * The manager in charge of accessing and exposing resource services. >+ */ >+ private ServiceManager serviceManager; >+ >+ /** > * Deletes all the files and directories from the given root down (inclusive). > * Returns false if we could not delete some file or an exception occurred > * at any point in the deletion. >@@ -1634,7 +1640,7 @@ > * </ul> > * @see ResourcesPlugin#getWorkspace() > */ >- public IStatus open(IProgressMonitor monitor) throws CoreException { >+ public IStatus open(BundleContext context, IProgressMonitor monitor) throws CoreException { > // This method is not inside an operation because it is the one responsible for > // creating the WorkManager object (who takes care of operations). > String message = Messages.resources_workspaceOpen; >@@ -1655,8 +1661,7 @@ > // create root location > localMetaArea.locationFor(getRoot()).toFile().mkdirs(); > >- IProgressMonitor nullMonitor = Policy.monitorFor(null); >- startup(nullMonitor); >+ startup(context, Policy.monitorFor(null)); > //restart the notification manager so it is initialized with the right tree > notificationManager.startup(null); > openFlag = true; >@@ -1821,7 +1826,7 @@ > protected void shutdown(IProgressMonitor monitor) throws CoreException { > monitor = Policy.monitorFor(monitor); > try { >- IManager[] managers = {buildManager, propertyManager, pathVariableManager, charsetManager, fileSystemManager, markerManager, _workManager, aliasManager, refreshManager, contentDescriptionManager}; >+ IManager[] managers = {buildManager, propertyManager, pathVariableManager, charsetManager, fileSystemManager, markerManager, _workManager, aliasManager, refreshManager, contentDescriptionManager, serviceManager}; > monitor.beginTask("", managers.length); //$NON-NLS-1$ > String message = Messages.resources_shutdownProblems; > MultiStatus status = new MultiStatus(ResourcesPlugin.PI_RESOURCES, IResourceStatus.INTERNAL_ERROR, message, null); >@@ -1852,6 +1857,7 @@ > refreshManager = null; > charsetManager = null; > contentDescriptionManager = null; >+ serviceManager = null; > if (!status.isOK()) > throw new CoreException(status); > } finally { >@@ -1866,7 +1872,7 @@ > return natureManager.sortNatureSet(natureIds); > } > >- protected void startup(IProgressMonitor monitor) throws CoreException { >+ protected void startup(BundleContext context, IProgressMonitor monitor) throws CoreException { > // ensure the tree is locked during the startup notification > try { > _workManager = new WorkManager(this); >@@ -1897,6 +1903,8 @@ > charsetManager.startup(null); > contentDescriptionManager = new ContentDescriptionManager(); > contentDescriptionManager.startup(null); >+ serviceManager = new ServiceManager(context); >+ serviceManager.startup(null); > } finally { > //unlock tree even in case of failure, otherwise shutdown will also fail > treeLocked = null; >@@ -1927,7 +1935,7 @@ > /* (non-javadoc) > * @see IWorkspace#validateEdit(IFile[], Object) > */ >- public IStatus validateEdit(final IFile[] files, final Object context) { >+ public IStatus validateEdit(final IFile[] files, Object inputContext) { > // if validation is turned off then just return > if (!shouldValidate) { > String message = Messages.resources_readOnly2; >@@ -1948,7 +1956,8 @@ > // a warning has already been logged so just return. > if (validator == null) > return Status.OK_STATUS; >- // otherwise call the API and throw an exception if appropriate >+ //use the shell finder service if the caller could not provide one >+ final Object context = inputContext == FIND_UI_CONTEXT ? serviceManager.findShell() : inputContext; > final IStatus[] status = new IStatus[1]; > ISafeRunnable body = new ISafeRunnable() { > public void handleException(Throwable exception) { >Index: src/org/eclipse/core/internal/resources/mapping/ResourceChangeDescriptionFactory.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/mapping/ResourceChangeDescriptionFactory.java,v >retrieving revision 1.11 >diff -u -r1.11 ResourceChangeDescriptionFactory.java >--- src/org/eclipse/core/internal/resources/mapping/ResourceChangeDescriptionFactory.java 12 May 2006 16:45:56 -0000 1.11 >+++ src/org/eclipse/core/internal/resources/mapping/ResourceChangeDescriptionFactory.java 9 Nov 2006 18:48:34 -0000 >@@ -62,7 +62,9 @@ > if (delta.getKind() == 0) > delta.setKind(IResourceDelta.CHANGED); > //the CONTENT flag only applies to the changed and moved from cases >- if (delta.getKind() == IResourceDelta.CHANGED || (delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) >+ if (delta.getKind() == IResourceDelta.CHANGED >+ || (delta.getFlags() & IResourceDelta.MOVED_FROM) != 0 >+ || (delta.getFlags() & IResourceDelta.COPIED_FROM) != 0) > delta.addFlags(IResourceDelta.CONTENT); > } > >Index: src/org/eclipse/core/internal/resources/ServiceManager.java >=================================================================== >RCS file: src/org/eclipse/core/internal/resources/ServiceManager.java >diff -N src/org/eclipse/core/internal/resources/ServiceManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/resources/ServiceManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,51 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.core.internal.resources; >+ >+import org.eclipse.core.resources.team.IShellFinder; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.osgi.framework.BundleContext; >+import org.osgi.util.tracker.ServiceTracker; >+ >+/** >+ * This class tracks services consumed and exposed by the resources plugin. >+ */ >+public class ServiceManager implements IManager { >+ private final BundleContext context; >+ private ServiceTracker shellFinder; >+ >+ public ServiceManager(BundleContext context) { >+ this.context = context; >+ >+ } >+ >+ public Object findShell() { >+ if (shellFinder == null) { >+ shellFinder = new ServiceTracker(context, IShellFinder.class.getName(), null); >+ shellFinder.open(); >+ } >+ IShellFinder finder = (IShellFinder) shellFinder.getService(); >+ if (finder != null) >+ return finder.findShell(); >+ return null; >+ } >+ >+ public void shutdown(IProgressMonitor monitor) { >+ if (shellFinder != null) { >+ shellFinder.close(); >+ shellFinder = null; >+ } >+ } >+ >+ public void startup(IProgressMonitor monitor) { >+ //nothing to do >+ } >+} >Index: src/org/eclipse/core/resources/team/IShellFinder.java >=================================================================== >RCS file: src/org/eclipse/core/resources/team/IShellFinder.java >diff -N src/org/eclipse/core/resources/team/IShellFinder.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/resources/team/IShellFinder.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,30 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.core.resources.team; >+ >+import org.eclipse.core.resources.IFileModificationValidator; >+ >+/** >+ * A sevice used to find a shell. >+ */ >+public interface IShellFinder { >+ /** >+ * Returns a shell suitable for use by an {@link IFileModificationValidator} >+ * to prompt a user to confirm writing a file. Returns <code>null</code> >+ * if no suitable shell can be found. >+ * <p> >+ * The returned object must be a <code>org.eclipse.swt.widgets.Shell</code> (declared >+ * as an <code>Object</code> to avoid any direct references on the SWT component) >+ * </p> >+ * @return A UI context, or <code>null</code>. >+ */ >+ public Object findShell(); >+} >#P org.eclipse.ui.ide >Index: src/org/eclipse/ui/internal/ide/IDEWorkbenchPlugin.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchPlugin.java,v >retrieving revision 1.41 >diff -u -r1.41 IDEWorkbenchPlugin.java >--- src/org/eclipse/ui/internal/ide/IDEWorkbenchPlugin.java 8 May 2006 20:54:09 -0000 1.41 >+++ src/org/eclipse/ui/internal/ide/IDEWorkbenchPlugin.java 9 Nov 2006 18:48:36 -0000 >@@ -17,6 +17,7 @@ > > import org.eclipse.core.resources.IWorkspace; > import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.resources.team.IShellFinder; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IBundleGroup; > import org.eclipse.core.runtime.IBundleGroupProvider; >@@ -30,6 +31,8 @@ > import org.eclipse.ui.internal.ide.registry.ProjectImageRegistry; > import org.eclipse.ui.plugin.AbstractUIPlugin; > import org.osgi.framework.Bundle; >+import org.osgi.framework.BundleContext; >+import org.osgi.framework.ServiceRegistration; > > /** > * This internal class represents the top of the IDE workbench. >@@ -43,46 +46,48 @@ > * @since 3.0 > */ > public class IDEWorkbenchPlugin extends AbstractUIPlugin { >- // Default instance of the receiver >- private static IDEWorkbenchPlugin inst; >+ // Default instance of the receiver >+ private static IDEWorkbenchPlugin inst; > >- // Global workbench ui plugin flag. Only workbench implementation is allowed to use this flag >- // All other plugins, examples, or test cases must *not* use this flag. >- public static boolean DEBUG = false; >+ // Global workbench ui plugin flag. Only workbench implementation is allowed to use this flag >+ // All other plugins, examples, or test cases must *not* use this flag. >+ public static boolean DEBUG = false; > >- /** >- * The IDE workbench plugin ID. >- */ >- public static final String IDE_WORKBENCH = "org.eclipse.ui.ide"; //$NON-NLS-1$ >+ /** >+ * The IDE workbench plugin ID. >+ */ >+ public static final String IDE_WORKBENCH = "org.eclipse.ui.ide"; //$NON-NLS-1$ >+ >+ /** >+ * The ID of the default text editor. >+ * This must correspond to EditorsUI.DEFAULT_TEXT_EDITOR_ID. >+ */ >+ public static final String DEFAULT_TEXT_EDITOR_ID = "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$ > >- /** >- * The ID of the default text editor. >- * This must correspond to EditorsUI.DEFAULT_TEXT_EDITOR_ID. >- */ >- public static final String DEFAULT_TEXT_EDITOR_ID = "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$ >+ // IDE workbench extension point names >+ public static final String PL_MARKER_IMAGE_PROVIDER = "markerImageProviders"; //$NON-NLS-1$ > >- // IDE workbench extension point names >- public static final String PL_MARKER_IMAGE_PROVIDER = "markerImageProviders"; //$NON-NLS-1$ >+ public static final String PL_MARKER_HELP = "markerHelp"; //$NON-NLS-1$ > >- public static final String PL_MARKER_HELP = "markerHelp"; //$NON-NLS-1$ >+ public static final String PL_MARKER_RESOLUTION = "markerResolution"; //$NON-NLS-1$ > >- public static final String PL_MARKER_RESOLUTION = "markerResolution"; //$NON-NLS-1$ >+ public static final String PL_CAPABILITIES = "capabilities"; //$NON-NLS-1$ > >- public static final String PL_CAPABILITIES = "capabilities"; //$NON-NLS-1$ >+ public static final String PL_PROJECT_NATURE_IMAGES = "projectNatureImages"; //$NON-NLS-1$ > >- public static final String PL_PROJECT_NATURE_IMAGES = "projectNatureImages"; //$NON-NLS-1$ >- > private final static String ICONS_PATH = "$nl$/icons/full/";//$NON-NLS-1$ > >- /** >- * Project image registry; lazily initialized. >- */ >- private ProjectImageRegistry projectImageRegistry = null; >- >- /** >- * Marker image registry; lazily initialized. >- */ >- private MarkerImageProviderRegistry markerImageProviderRegistry = null; >+ /** >+ * Project image registry; lazily initialized. >+ */ >+ private ProjectImageRegistry projectImageRegistry = null; >+ >+ /** >+ * Marker image registry; lazily initialized. >+ */ >+ private MarkerImageProviderRegistry markerImageProviderRegistry = null; >+ >+ private ServiceRegistration shellFinder; > > /** > * Create an instance of the receiver. >@@ -91,17 +96,18 @@ > super(); > inst = this; > } >- /** >- * Creates an extension. If the extension plugin has not >- * been loaded a busy cursor will be activated during the duration of >- * the load. >- * >- * @param element the config element defining the extension >- * @param classAttribute the name of the attribute carrying the class >- * @return Object the extension object >- * @throws CoreException >- */ >- public static Object createExtension(final IConfigurationElement element, >+ >+ /** >+ * Creates an extension. If the extension plugin has not >+ * been loaded a busy cursor will be activated during the duration of >+ * the load. >+ * >+ * @param element the config element defining the extension >+ * @param classAttribute the name of the attribute carrying the class >+ * @return Object the extension object >+ * @throws CoreException >+ */ >+ public static Object createExtension(final IConfigurationElement element, > final String classAttribute) throws CoreException { > // If plugin has been loaded create extension. > // Otherwise, show busy cursor then create extension. >@@ -109,201 +115,219 @@ > if (plugin.getState() == Bundle.ACTIVE) { > return element.createExecutableExtension(classAttribute); > } else { >- final Object[] ret = new Object[1]; >- final CoreException[] exc = new CoreException[1]; >- BusyIndicator.showWhile(null, new Runnable() { >- public void run() { >- try { >- ret[0] = element >- .createExecutableExtension(classAttribute); >- } catch (CoreException e) { >- exc[0] = e; >- } >- } >- }); >- if (exc[0] != null) { >+ final Object[] ret = new Object[1]; >+ final CoreException[] exc = new CoreException[1]; >+ BusyIndicator.showWhile(null, new Runnable() { >+ public void run() { >+ try { >+ ret[0] = element >+ .createExecutableExtension(classAttribute); >+ } catch (CoreException e) { >+ exc[0] = e; >+ } >+ } >+ }); >+ if (exc[0] != null) { > throw exc[0]; > } else { > return ret[0]; > } >- } >- } >+ } >+ } >+ >+ /* Return the default instance of the receiver. This represents the runtime plugin. >+ * >+ * @see AbstractPlugin for the typical implementation pattern for plugin classes. >+ */ >+ public static IDEWorkbenchPlugin getDefault() { >+ return inst; >+ } >+ >+ /** >+ * Return the workspace used by the workbench >+ * >+ * This method is internal to the workbench and must not be called >+ * by any plugins. >+ */ >+ public static IWorkspace getPluginWorkspace() { >+ return ResourcesPlugin.getWorkspace(); >+ } >+ >+ /** >+ * Logs the given message to the platform log. >+ * >+ * If you have an exception in hand, call log(String, Throwable) instead. >+ * >+ * If you have a status object in hand call log(String, IStatus) instead. >+ * >+ * This convenience method is for internal use by the IDE Workbench only and >+ * must not be called outside the IDE Workbench. >+ * >+ * @param message >+ * A high level UI message describing when the problem happened. >+ */ >+ public static void log(String message) { >+ getDefault().getLog().log( >+ StatusUtil.newStatus(IStatus.ERROR, message, null)); >+ } >+ >+ /** >+ * Logs the given message and throwable to the platform log. >+ * >+ * If you have a status object in hand call log(String, IStatus) instead. >+ * >+ * This convenience method is for internal use by the IDE Workbench only and >+ * must not be called outside the IDE Workbench. >+ * >+ * @param message >+ * A high level UI message describing when the problem happened. >+ * @param t >+ * The throwable from where the problem actually occurred. >+ */ >+ public static void log(String message, Throwable t) { >+ IStatus status = StatusUtil.newStatus(IStatus.ERROR, message, t); >+ log(message, status); >+ } >+ >+ /** >+ * Logs the given throwable to the platform log, indicating the class and >+ * method from where it is being logged (this is not necessarily where it >+ * occurred). >+ * >+ * This convenience method is for internal use by the IDE Workbench only and >+ * must not be called outside the IDE Workbench. >+ * >+ * @param clazz >+ * The calling class. >+ * @param methodName >+ * The calling method name. >+ * @param t >+ * The throwable from where the problem actually occurred. >+ */ >+ public static void log(Class clazz, String methodName, Throwable t) { >+ String msg = MessageFormat.format("Exception in {0}.{1}: {2}", //$NON-NLS-1$ >+ new Object[] { clazz.getName(), methodName, t }); >+ log(msg, t); >+ } > >- /* Return the default instance of the receiver. This represents the runtime plugin. >- * >- * @see AbstractPlugin for the typical implementation pattern for plugin classes. >- */ >- public static IDEWorkbenchPlugin getDefault() { >- return inst; >- } >- >- /** >- * Return the workspace used by the workbench >- * >- * This method is internal to the workbench and must not be called >- * by any plugins. >- */ >- public static IWorkspace getPluginWorkspace() { >- return ResourcesPlugin.getWorkspace(); >- } >- >- /** >- * Logs the given message to the platform log. >- * >- * If you have an exception in hand, call log(String, Throwable) instead. >- * >- * If you have a status object in hand call log(String, IStatus) instead. >- * >- * This convenience method is for internal use by the IDE Workbench only and >- * must not be called outside the IDE Workbench. >- * >- * @param message >- * A high level UI message describing when the problem happened. >- */ >- public static void log(String message) { >- getDefault().getLog().log( >- StatusUtil.newStatus(IStatus.ERROR, message, null)); >- } >- >- /** >- * Logs the given message and throwable to the platform log. >- * >- * If you have a status object in hand call log(String, IStatus) instead. >- * >- * This convenience method is for internal use by the IDE Workbench only and >- * must not be called outside the IDE Workbench. >- * >- * @param message >- * A high level UI message describing when the problem happened. >- * @param t >- * The throwable from where the problem actually occurred. >- */ >- public static void log(String message, Throwable t) { >- IStatus status = StatusUtil.newStatus(IStatus.ERROR, message, t); >- log(message, status); >- } >- >- /** >- * Logs the given throwable to the platform log, indicating the class and >- * method from where it is being logged (this is not necessarily where it >- * occurred). >- * >- * This convenience method is for internal use by the IDE Workbench only and >- * must not be called outside the IDE Workbench. >- * >- * @param clazz >- * The calling class. >- * @param methodName >- * The calling method name. >- * @param t >- * The throwable from where the problem actually occurred. >- */ >- public static void log(Class clazz, String methodName, Throwable t) { >- String msg = MessageFormat.format("Exception in {0}.{1}: {2}", //$NON-NLS-1$ >- new Object[] { clazz.getName(), methodName, t }); >- log(msg, t); >- } >- >- /** >- * Logs the given message and status to the platform log. >- * >- * This convenience method is for internal use by the IDE Workbench only and >- * must not be called outside the IDE Workbench. >- * >- * @param message >- * A high level UI message describing when the problem happened. >- * May be <code>null</code>. >- * @param status >- * The status describing the problem. Must not be null. >- */ >- public static void log(String message, IStatus status) { >- >- //1FTUHE0: ITPCORE:ALL - API - Status & logging - loss of semantic info >- >- if (message != null) { >- getDefault().getLog().log( >- StatusUtil.newStatus(IStatus.ERROR, message, null)); >- } >- >- getDefault().getLog().log(status); >- } >- >- /* (non-javadoc) >- * Method declared on AbstractUIPlugin >- */ >- protected void refreshPluginActions() { >- // do nothing >- } >- >- >- /** >- * Return the manager that maps project nature ids to images. >- */ >- public ProjectImageRegistry getProjectImageRegistry() { >- if (projectImageRegistry == null) { >- projectImageRegistry = new ProjectImageRegistry(); >- projectImageRegistry.load(); >- } >- return projectImageRegistry; >- } >- >- /** >- * Returns the marker image provider registry for the workbench. >- * >- * @return the marker image provider registry >- */ >- public MarkerImageProviderRegistry getMarkerImageProviderRegistry() { >- if (markerImageProviderRegistry == null) { >- markerImageProviderRegistry = new MarkerImageProviderRegistry(); >- } >- return markerImageProviderRegistry; >- } >- >- >- /** >- * Returns the about information of all known features, >- * omitting any features which are missing this information. >- * >- * @return a possibly empty list of about infos >- */ >- public AboutInfo[] getFeatureInfos() { >- // cannot be cached since bundle groups come and go >- List infos = new ArrayList(); >- >- // add an entry for each bundle group >- IBundleGroupProvider[] providers = Platform.getBundleGroupProviders(); >- if (providers != null) { >+ /** >+ * Logs the given message and status to the platform log. >+ * >+ * This convenience method is for internal use by the IDE Workbench only and >+ * must not be called outside the IDE Workbench. >+ * >+ * @param message >+ * A high level UI message describing when the problem happened. >+ * May be <code>null</code>. >+ * @param status >+ * The status describing the problem. Must not be null. >+ */ >+ public static void log(String message, IStatus status) { >+ >+ //1FTUHE0: ITPCORE:ALL - API - Status & logging - loss of semantic info >+ >+ if (message != null) { >+ getDefault().getLog().log( >+ StatusUtil.newStatus(IStatus.ERROR, message, null)); >+ } >+ >+ getDefault().getLog().log(status); >+ } >+ >+ /* (non-javadoc) >+ * Method declared on AbstractUIPlugin >+ */ >+ protected void refreshPluginActions() { >+ // do nothing >+ } >+ >+ /** >+ * Return the manager that maps project nature ids to images. >+ */ >+ public ProjectImageRegistry getProjectImageRegistry() { >+ if (projectImageRegistry == null) { >+ projectImageRegistry = new ProjectImageRegistry(); >+ projectImageRegistry.load(); >+ } >+ return projectImageRegistry; >+ } >+ >+ /** >+ * Returns the marker image provider registry for the workbench. >+ * >+ * @return the marker image provider registry >+ */ >+ public MarkerImageProviderRegistry getMarkerImageProviderRegistry() { >+ if (markerImageProviderRegistry == null) { >+ markerImageProviderRegistry = new MarkerImageProviderRegistry(); >+ } >+ return markerImageProviderRegistry; >+ } >+ >+ /** >+ * Returns the about information of all known features, >+ * omitting any features which are missing this information. >+ * >+ * @return a possibly empty list of about infos >+ */ >+ public AboutInfo[] getFeatureInfos() { >+ // cannot be cached since bundle groups come and go >+ List infos = new ArrayList(); >+ >+ // add an entry for each bundle group >+ IBundleGroupProvider[] providers = Platform.getBundleGroupProviders(); >+ if (providers != null) { > for (int i = 0; i < providers.length; ++i) { >- IBundleGroup[] bundleGroups = providers[i].getBundleGroups(); >- for (int j = 0; j < bundleGroups.length; ++j) { >+ IBundleGroup[] bundleGroups = providers[i].getBundleGroups(); >+ for (int j = 0; j < bundleGroups.length; ++j) { > infos.add(new AboutInfo(bundleGroups[j])); > } >- } >+ } > } > >- return (AboutInfo[]) infos.toArray(new AboutInfo[infos.size()]); >- } >+ return (AboutInfo[]) infos.toArray(new AboutInfo[infos.size()]); >+ } >+ >+ /** >+ * Returns the about information of the primary feature. >+ * >+ * @return info about the primary feature, or <code>null</code> if there >+ * is no primary feature or if this information is unavailable >+ */ >+ public AboutInfo getPrimaryInfo() { >+ IProduct product = Platform.getProduct(); >+ return product == null ? null : new AboutInfo(product); >+ } > >- /** >- * Returns the about information of the primary feature. >- * >- * @return info about the primary feature, or <code>null</code> if there >- * is no primary feature or if this information is unavailable >- */ >- public AboutInfo getPrimaryInfo() { >- IProduct product = Platform.getProduct(); >- return product == null ? null : new AboutInfo(product); >- } >- > /** > * Get the workbench image with the given path relative to > * ICON_PATH. > * @param relativePath > * @return ImageDescriptor > */ >- public static ImageDescriptor getIDEImageDescriptor(String relativePath){ >- return imageDescriptorFromPlugin(IDE_WORKBENCH, ICONS_PATH + relativePath); >+ public static ImageDescriptor getIDEImageDescriptor(String relativePath) { >+ return imageDescriptorFromPlugin(IDE_WORKBENCH, ICONS_PATH >+ + relativePath); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) >+ */ >+ public void start(BundleContext context) throws Exception { >+ super.start(context); >+ String serviceName = IShellFinder.class.getName(); >+ shellFinder = context.registerService(serviceName, >+ new IDEShellFinder(), null); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) >+ */ >+ public void stop(BundleContext context) throws Exception { >+ super.stop(context); >+ if (shellFinder != null) { >+ shellFinder.unregister(); >+ shellFinder = null; >+ } > } >- >- > } >Index: src/org/eclipse/ui/internal/ide/IDEShellFinder.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/ide/IDEShellFinder.java >diff -N src/org/eclipse/ui/internal/ide/IDEShellFinder.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/ide/IDEShellFinder.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,78 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal.ide; >+ >+import org.eclipse.core.resources.team.IShellFinder; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.IWorkbench; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.PlatformUI; >+ >+/** >+ * IDE implementation of {@link IShellFinder}. >+ * @since 3.3 >+ */ >+public class IDEShellFinder implements IShellFinder { >+ >+ /** >+ * Return the modal shell that is currently open. If there isn't one then >+ * return null. >+ * >+ * @return Shell or <code>null</code>. >+ */ >+ public static Shell getModalShell() { >+ IWorkbench workbench = PlatformUI.getWorkbench(); >+ Shell[] shells = workbench.getDisplay().getShells(); >+ int modal = SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL >+ | SWT.PRIMARY_MODAL; >+ for (int i = 0; i < shells.length; i++) { >+ // Do not worry about shells that will not block the user. >+ if (shells[i].isVisible()) { >+ if ((shells[i].getStyle() & modal) != 0) { >+ return shells[i]; >+ } >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * Get the active non modal shell. If there isn't one return null. >+ * >+ * @return Shell >+ */ >+ public static Shell getNonModalShell() { >+ IWorkbenchWindow window = PlatformUI.getWorkbench() >+ .getActiveWorkbenchWindow(); >+ if (window == null) { >+ IWorkbenchWindow[] windows = PlatformUI.getWorkbench() >+ .getWorkbenchWindows(); >+ if (windows.length > 0) >+ return windows[0].getShell(); >+ } else >+ return window.getShell(); >+ >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.resources.team.IShellFinder#findShell() >+ */ >+ public Object findShell() { >+ Shell modal = getModalShell(); >+ if (modal != null) { >+ return modal; >+ } >+ return getNonModalShell(); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 160905
: 53562 |
60001
|
60006
|
60025
|
60068
|
60101