1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-03 14:25:37 +02:00

[228353] Asynchronously initialize the remote edit project

This commit is contained in:
Martin Oberhuber 2008-05-06 19:41:31 +00:00
parent 7322cfb231
commit bda7058954

View file

@ -7,20 +7,26 @@
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
*
* Contributors:
* Martin Oberhuber (Wind River) - [180519][api] declaratively register adapter factories
* David McKnight (IBM) - [205820] create the temp files project (if not there) when files.ui is loaded
* David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
* Martin Oberhuber (Wind River) - [228353] Asynchronously initialize the remote edit project
*******************************************************************************/
package org.eclipse.rse.internal.files.ui;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.rse.files.ui.resources.SystemUniversalTempFileListener;
@ -28,7 +34,6 @@ import org.eclipse.rse.internal.files.ui.propertypages.SystemCachePreferencePage
import org.eclipse.rse.internal.files.ui.propertypages.UniversalPreferencePage;
import org.eclipse.rse.internal.files.ui.resources.SystemRemoteEditManager;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemBasePlugin;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@ -41,12 +46,12 @@ public class Activator extends AbstractUIPlugin
//The shared instance.
private static Activator plugin;
private static SystemUniversalTempFileListener _tempFileListener;
public final static String PLUGIN_ID = "org.eclipse.rse.files.ui"; //$NON-NLS-1$
public static final String HELPPREFIX = "org.eclipse.rse.files.ui."; //$NON-NLS-1$
/**
* The constructor.
*/
@ -54,34 +59,54 @@ public class Activator extends AbstractUIPlugin
plugin = this;
}
private class InitRemoteEditJob extends Job {
public InitRemoteEditJob() {
super("InitRemoteEditJob"); //$NON-NLS-1$
}
protected IStatus run(IProgressMonitor monitor) {
// create the temp files project if it doesn't exist
// fix for bug 205820
SystemRemoteEditManager.getInstance().getRemoteEditProject();
// refresh the remote edit project at plugin startup, to ensure
// it's never closed
SystemRemoteEditManager.getInstance().refreshRemoteEditProject();
// universal temp file listener
_tempFileListener = SystemUniversalTempFileListener.getListener();
// add listener for temp files
int eventMask = IResourceChangeEvent.POST_CHANGE;
IWorkspace ws = ResourcesPlugin.getWorkspace();
ws.addResourceChangeListener(_tempFileListener, eventMask);
return Status.OK_STATUS;
}
}
/**
* This method is called upon plug-in activation
*/
public void start(BundleContext context) throws Exception {
super.start(context);
super.start(context);
// create the temp files project if it doesn't exist
// fix for bug 205820
SystemRemoteEditManager.getInstance().getRemoteEditProject();
// refresh the remote edit project at plugin startup, to ensure
// it's never closed
SystemRemoteEditManager.getInstance().refreshRemoteEditProject();
// universal temp file listener
_tempFileListener = SystemUniversalTempFileListener.getListener();
// add listener for temp files
int eventMask = IResourceChangeEvent.POST_CHANGE;
IWorkspace ws = SystemBasePlugin.getWorkspace();
ws.addResourceChangeListener(_tempFileListener, eventMask);
// DKM - workaround for issue in 175295
// I had tried SystemFilePreferenceInitializer but it was not being started by the platform because
// the preference store is rse.ui. In order to fix that, we'd have to migrate the
// preferences for files to the files.ui preference store.
// preferences for files to the files.ui preference store.
// Instead calling this directly at startup.
initializeDefaultRSEPreferences();
//Bug 228353: Initialize remote edit project in a Job
//The Job must run AFTER initializeDefaultRSEPreferences(), because that one
//needs some classes loaded, and the class loader could fall into a deadlock
//when the deferred Job also wants to load some classes but cannot continue
//because the start() method is not yet finished
InitRemoteEditJob job = new InitRemoteEditJob();
job.setRule(ResourcesPlugin.getWorkspace().getRoot());
job.schedule();
}
/**
@ -89,21 +114,24 @@ public class Activator extends AbstractUIPlugin
*/
public void initializeDefaultRSEPreferences()
{
//FIXME This should really be migrated into a Preferences Initializer Extension
//in order to avoid unnecessary plugin activation
IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore();
SystemCachePreferencePage.initDefaults(store);
UniversalPreferencePage.initDefaults(store);
UniversalPreferencePage.initDefaults(store);
}
/**
* This method is called when the plug-in is stopped
*/
public void stop(BundleContext context) throws Exception
public void stop(BundleContext context) throws Exception
{
super.stop(context);
IWorkspace ws = SystemBasePlugin.getWorkspace();
ws.removeResourceChangeListener(_tempFileListener);
_tempFileListener = null;
if (_tempFileListener != null) {
IWorkspace ws = ResourcesPlugin.getWorkspace();
ws.removeResourceChangeListener(_tempFileListener);
_tempFileListener = null;
}
plugin = null;
}
@ -124,5 +152,5 @@ public class Activator extends AbstractUIPlugin
public static ImageDescriptor getImageDescriptor(String path) {
return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.rse.files.ui", path); //$NON-NLS-1$
}
}