mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 06:45:43 +02:00
[240991] Avoid adding change listener when Workbench is already closing
This commit is contained in:
parent
5a9c8dc1f4
commit
0e39dbbba8
2 changed files with 46 additions and 37 deletions
|
@ -947,12 +947,12 @@ public class SystemRegistry implements ISystemRegistry
|
||||||
if (firstObject == null || secondObject == null){
|
if (firstObject == null || secondObject == null){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// two different message objects should not be considered the same
|
// two different message objects should not be considered the same
|
||||||
if (firstObject instanceof SystemMessageObject){
|
if (firstObject instanceof SystemMessageObject){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ISystemDragDropAdapter adA = null;
|
ISystemDragDropAdapter adA = null;
|
||||||
ISystemDragDropAdapter adB = null;
|
ISystemDragDropAdapter adB = null;
|
||||||
if (firstObjectFullName == null) {
|
if (firstObjectFullName == null) {
|
||||||
|
@ -1617,12 +1617,16 @@ public class SystemRegistry implements ISystemRegistry
|
||||||
throw lastException;
|
throw lastException;
|
||||||
}
|
}
|
||||||
IHost host = op.getHost();
|
IHost host = op.getHost();
|
||||||
ISubSystem[] subsystems = op.getSubSystems();
|
if (modelListenerManager.hasListeners()) {
|
||||||
FireNewHostEvents fire = new FireNewHostEvents(host, subsystems, sr);
|
ISubSystem[] subsystems = op.getSubSystems();
|
||||||
if (modelListenerManager.hasListeners())
|
FireNewHostEvents fire = new FireNewHostEvents(host, subsystems, sr);
|
||||||
|
// FIXME bug 240991: With the current workaround, we might miss events
|
||||||
|
// in SystemPreferencesManager. Instead of Display.getDefault(),
|
||||||
|
// we should use the IRSEInteractionProvider here.
|
||||||
Display.getDefault().asyncExec(fire);
|
Display.getDefault().asyncExec(fire);
|
||||||
|
}
|
||||||
////Listening to FireNewHostEvents now
|
|
||||||
|
// //SystemPreferencesManager listens itself to FireNewHostEvents now
|
||||||
//SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list
|
//SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (c) 2000, 2008 IBM Corporation. All rights reserved.
|
* Copyright (c) 2000, 2008 IBM Corporation. All rights reserved.
|
||||||
* This program and the accompanying materials are made available under the terms
|
* 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
|
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Initial Contributors:
|
* Initial Contributors:
|
||||||
* The following IBM employees contributed to the Remote System Explorer
|
* The following IBM employees contributed to the Remote System Explorer
|
||||||
* component that contains this file: David McKnight, Kushal Munir,
|
* component that contains this file: David McKnight, Kushal Munir,
|
||||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* David Dykstal (IBM) - moved SystemPreferencesManager to a this package, was in
|
* David Dykstal (IBM) - moved SystemPreferencesManager to a this package, was in
|
||||||
* the org.eclipse.rse.core package of the UI plugin.
|
* the org.eclipse.rse.core package of the UI plugin.
|
||||||
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
|
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
|
||||||
* Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
|
* Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
|
||||||
|
@ -33,7 +33,6 @@ import org.eclipse.rse.core.RSECorePlugin;
|
||||||
import org.eclipse.rse.core.events.ISystemModelChangeEvent;
|
import org.eclipse.rse.core.events.ISystemModelChangeEvent;
|
||||||
import org.eclipse.rse.core.events.ISystemModelChangeEvents;
|
import org.eclipse.rse.core.events.ISystemModelChangeEvents;
|
||||||
import org.eclipse.rse.core.events.ISystemModelChangeListener;
|
import org.eclipse.rse.core.events.ISystemModelChangeListener;
|
||||||
import org.eclipse.rse.core.events.ISystemRemoteChangeEvents;
|
|
||||||
import org.eclipse.rse.core.events.ISystemResourceChangeEvent;
|
import org.eclipse.rse.core.events.ISystemResourceChangeEvent;
|
||||||
import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
|
import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
|
||||||
import org.eclipse.rse.core.events.ISystemResourceChangeListener;
|
import org.eclipse.rse.core.events.ISystemResourceChangeListener;
|
||||||
|
@ -56,9 +55,9 @@ import org.eclipse.ui.IWorkbench;
|
||||||
* This class should not be subclassed.
|
* This class should not be subclassed.
|
||||||
*/
|
*/
|
||||||
public class SystemPreferencesManager {
|
public class SystemPreferencesManager {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following are preferences that may be set from the
|
* The following are preferences that may be set from the
|
||||||
* system properties.
|
* system properties.
|
||||||
*/
|
*/
|
||||||
private static boolean showLocalConnection;
|
private static boolean showLocalConnection;
|
||||||
|
@ -71,9 +70,9 @@ public class SystemPreferencesManager {
|
||||||
private static SystemPreferencesManager fInstance = new SystemPreferencesManager();
|
private static SystemPreferencesManager fInstance = new SystemPreferencesManager();
|
||||||
private int fModelChangeListeners = 0;
|
private int fModelChangeListeners = 0;
|
||||||
private ISystemModelChangeListener fModelChangeListener = null;
|
private ISystemModelChangeListener fModelChangeListener = null;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Private Constructor to discourage instance creation other than by ourselves.
|
* Private Constructor to discourage instance creation other than by ourselves.
|
||||||
*/
|
*/
|
||||||
private SystemPreferencesManager() {
|
private SystemPreferencesManager() {
|
||||||
}
|
}
|
||||||
|
@ -83,8 +82,8 @@ public class SystemPreferencesManager {
|
||||||
*/
|
*/
|
||||||
private static void migrateCorePreferences() {
|
private static void migrateCorePreferences() {
|
||||||
String[] keys = {
|
String[] keys = {
|
||||||
IRSEPreferenceNames.ACTIVEUSERPROFILES,
|
IRSEPreferenceNames.ACTIVEUSERPROFILES,
|
||||||
IRSEPreferenceNames.USE_DEFERRED_QUERIES,
|
IRSEPreferenceNames.USE_DEFERRED_QUERIES,
|
||||||
IRSEPreferenceNames.USERIDPERKEY
|
IRSEPreferenceNames.USERIDPERKEY
|
||||||
};
|
};
|
||||||
for (int i = 0; i < keys.length; i++) {
|
for (int i = 0; i < keys.length; i++) {
|
||||||
|
@ -116,7 +115,7 @@ public class SystemPreferencesManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initDefaultsUI() {
|
private static void initDefaultsUI() {
|
||||||
|
|
||||||
//String showProp = System.getProperty("rse.showNewConnectionPrompt");
|
//String showProp = System.getProperty("rse.showNewConnectionPrompt");
|
||||||
RSEUIPlugin ui = RSEUIPlugin.getDefault();
|
RSEUIPlugin ui = RSEUIPlugin.getDefault();
|
||||||
Preferences store = ui.getPluginPreferences();
|
Preferences store = ui.getPluginPreferences();
|
||||||
|
@ -136,7 +135,7 @@ public class SystemPreferencesManager {
|
||||||
store.setDefault(ISystemPreferencesConstants.SHOW_EMPTY_LISTS, ISystemPreferencesConstants.DEFAULT_SHOW_EMPTY_LISTS);
|
store.setDefault(ISystemPreferencesConstants.SHOW_EMPTY_LISTS, ISystemPreferencesConstants.DEFAULT_SHOW_EMPTY_LISTS);
|
||||||
savePreferences();
|
savePreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean getBooleanProperty(String propertyName, boolean defaultValue) {
|
private static boolean getBooleanProperty(String propertyName, boolean defaultValue) {
|
||||||
String property = System.getProperty(propertyName);
|
String property = System.getProperty(propertyName);
|
||||||
boolean value = (property == null) ? defaultValue : property.equals(Boolean.toString(true));
|
boolean value = (property == null) ? defaultValue : property.equals(Boolean.toString(true));
|
||||||
|
@ -220,10 +219,10 @@ public class SystemPreferencesManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets user's preference for the order of the connection names according to the
|
* Sets user's preference for the order of the connection names according to the
|
||||||
* list kept in the system registry.
|
* list kept in the system registry.
|
||||||
* This resets any user-specified ordering of profiles since the SystemRegistry
|
* This resets any user-specified ordering of profiles since the SystemRegistry
|
||||||
* has no concept of ordered profiles. The hosts inside a profile, though,
|
* has no concept of ordered profiles. The hosts inside a profile, though,
|
||||||
* will be ordered according to user preference.
|
* will be ordered according to user preference.
|
||||||
*/
|
*/
|
||||||
public static void setConnectionNamesOrder() {
|
public static void setConnectionNamesOrder() {
|
||||||
|
@ -341,7 +340,7 @@ public class SystemPreferencesManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set if the user has elected to restore the state of the
|
* Set if the user has elected to restore the state of the
|
||||||
* Remote Systems View from cached information
|
* Remote Systems View from cached information
|
||||||
* @param restore whether or not to restore the state of RSE from cached information.
|
* @param restore whether or not to restore the state of RSE from cached information.
|
||||||
*/
|
*/
|
||||||
|
@ -418,8 +417,8 @@ public class SystemPreferencesManager {
|
||||||
public static String[] getWidgetHistory(String key) {
|
public static String[] getWidgetHistory(String key) {
|
||||||
Preferences store = RSEUIPlugin.getDefault().getPluginPreferences();
|
Preferences store = RSEUIPlugin.getDefault().getPluginPreferences();
|
||||||
String result = store.getString(key);
|
String result = store.getString(key);
|
||||||
|
|
||||||
// bug 237300
|
// bug 237300
|
||||||
// don't parse strings if we have ""
|
// don't parse strings if we have ""
|
||||||
if (result == null || result.length() == 0){
|
if (result == null || result.length() == 0){
|
||||||
return null;
|
return null;
|
||||||
|
@ -460,7 +459,7 @@ public class SystemPreferencesManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse out list of multiple values into a string array per value.
|
* Parse out list of multiple values into a string array per value.
|
||||||
* This is the inverse of the {@link #makeString(String[])} operation.
|
* This is the inverse of the {@link #makeString(String[])} operation.
|
||||||
* @param allvalues the string holding the condensed value
|
* @param allvalues the string holding the condensed value
|
||||||
* @return the reconstituted array of strings.
|
* @return the reconstituted array of strings.
|
||||||
|
@ -478,7 +477,7 @@ public class SystemPreferencesManager {
|
||||||
RSEUIPlugin.getDefault().savePluginPreferences();
|
RSEUIPlugin.getDefault().savePluginPreferences();
|
||||||
RSECorePlugin.getDefault().savePluginPreferences();
|
RSECorePlugin.getDefault().savePluginPreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start listening to SystemRegistry model change events
|
* Start listening to SystemRegistry model change events
|
||||||
*/
|
*/
|
||||||
|
@ -491,17 +490,23 @@ public class SystemPreferencesManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!alreadyListening) {
|
if (!alreadyListening) {
|
||||||
|
// FIXME bug 240991: With the current workaround, we might miss events
|
||||||
|
// Instead of adding the listener deferred in a job, the SystemRegistry
|
||||||
|
// should send events via the IRSEInteractionProvider
|
||||||
Job addListenerJob = new Job("Add Listener"){ //$NON-NLS-1$
|
Job addListenerJob = new Job("Add Listener"){ //$NON-NLS-1$
|
||||||
public IStatus run(IProgressMonitor monitor){
|
public IStatus run(IProgressMonitor monitor){
|
||||||
IWorkbench wb = RSEUIPlugin.getDefault().getWorkbench();
|
IWorkbench wb = RSEUIPlugin.getDefault().getWorkbench();
|
||||||
while (wb.getDisplay() == null) {
|
while (wb.getDisplay() == null && !wb.isClosing()) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
//Checks in the loop are fast enough so we can poll often
|
||||||
|
Thread.sleep(100);
|
||||||
}
|
}
|
||||||
catch (InterruptedException e){}
|
catch (InterruptedException e){}
|
||||||
}
|
}
|
||||||
fModelChangeListener = new ModelChangeListener();
|
if (!wb.isClosing()) {
|
||||||
RSECorePlugin.getTheSystemRegistry().addSystemModelChangeListener(fModelChangeListener);
|
fModelChangeListener = new ModelChangeListener();
|
||||||
|
RSECorePlugin.getTheSystemRegistry().addSystemModelChangeListener(fModelChangeListener);
|
||||||
|
}
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -509,7 +514,7 @@ public class SystemPreferencesManager {
|
||||||
addListenerJob.schedule();
|
addListenerJob.schedule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A listener for SystemRegistry Model Change events
|
* A listener for SystemRegistry Model Change events
|
||||||
*/
|
*/
|
||||||
|
@ -550,7 +555,7 @@ public class SystemPreferencesManager {
|
||||||
SystemPreferencesManager.setConnectionNamesOrder();
|
SystemPreferencesManager.setConnectionNamesOrder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue