Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqiwang2011-02-23 03:23:29 +0000
committerqiwang2011-02-23 03:23:29 +0000
commit438fb31a78d581ab5c4801e7bd3506c07abec8f1 (patch)
treefb6a58281be7920caa5ab63e74c4e25fefb6cf80
parent6027e73a3c0a708c4ac27eb68967b178e328d373 (diff)
downloadorg.eclipse.pdt-438fb31a78d581ab5c4801e7bd3506c07abec8f1.tar.gz
org.eclipse.pdt-438fb31a78d581ab5c4801e7bd3506c07abec8f1.tar.xz
org.eclipse.pdt-438fb31a78d581ab5c4801e7bd3506c07abec8f1.zip
Removed the wrong assumption in the remove method
-rw-r--r--plugins/org.eclipse.php.server.core/src/org/eclipse/php/internal/server/core/manager/ServersManager.java46
1 files changed, 37 insertions, 9 deletions
diff --git a/plugins/org.eclipse.php.server.core/src/org/eclipse/php/internal/server/core/manager/ServersManager.java b/plugins/org.eclipse.php.server.core/src/org/eclipse/php/internal/server/core/manager/ServersManager.java
index 437fd91a1..d2035f218 100644
--- a/plugins/org.eclipse.php.server.core/src/org/eclipse/php/internal/server/core/manager/ServersManager.java
+++ b/plugins/org.eclipse.php.server.core/src/org/eclipse/php/internal/server/core/manager/ServersManager.java
@@ -17,10 +17,14 @@ import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.Iterator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IScopeContext;
@@ -108,14 +112,24 @@ public class ServersManager implements PropertyChangeListener, IAdaptable {
if (server == null) {
return;
}
+
ServersManager manager = getInstance();
- Server oldValue = (Server) manager.servers
- .put(server.getName(), server);
+ Server oldValue = ServersManager.getServer(server);
+ if (server != oldValue) {
+ manager.servers.remove(oldValue.getName());
+ oldValue.removePropertyChangeListener(manager);
+ ServerManagerEvent event = new ServerManagerEvent(
+ ServerManagerEvent.MANAGER_EVENT_REMOVED, oldValue);
+ manager.fireEvent(event);
+ }
+ oldValue = (Server) manager.servers.put(server.getName(), server);
if (oldValue != null) {
oldValue.removePropertyChangeListener(manager);
ServerManagerEvent event = new ServerManagerEvent(
ServerManagerEvent.MANAGER_EVENT_REMOVED, oldValue);
manager.fireEvent(event);
+ } else {
+
}
ServerManagerEvent event = new ServerManagerEvent(
ServerManagerEvent.MANAGER_EVENT_ADDED, server);
@@ -143,12 +157,12 @@ public class ServersManager implements PropertyChangeListener, IAdaptable {
ServersManager manager = ServersManager.getInstance();
Server removedServer = (Server) manager.servers.remove(serverName);
Server workspaceDefault = getDefaultServer(null);
- if (workspaceDefault == null) {
- // Should not happen
- Logger.log(IStatus.ERROR,
- "There is no defined default server for the workspace.");
- return null;
- }
+ // if (workspaceDefault == null) {
+ // // Should not happen
+ // Logger.log(IStatus.ERROR,
+ // "There is no defined default server for the workspace.");
+ // return null;
+ // }
if (removedServer == null) {
// if the name is not existing, just quit.
return null;
@@ -197,6 +211,18 @@ public class ServersManager implements PropertyChangeListener, IAdaptable {
return (Server) manager.servers.get(serverName);
}
+ public static Server getServer(Server oldServer) {
+ ServersManager manager = getInstance();
+ for (Iterator iterator = manager.servers.values().iterator(); iterator
+ .hasNext();) {
+ Server server = (Server) iterator.next();
+ if (server.getBaseURL().equals(oldServer.getBaseURL())) {
+ return server;
+ }
+ }
+ return oldServer;
+ }
+
/**
* Returns all the Servers that are managed by this manager.
*
@@ -273,6 +299,7 @@ public class ServersManager implements PropertyChangeListener, IAdaptable {
// project server (can be the same).
try {
server = createServer(Default_Server_Name, BASE_URL);
+
} catch (MalformedURLException e) {
// safe server creation
}
@@ -353,6 +380,7 @@ public class ServersManager implements PropertyChangeListener, IAdaptable {
public static Server createServer(String name, String baseURL)
throws MalformedURLException {
Server server = new Server(name, "localhost", baseURL, "");
+ server = ServersManager.getServer(server);
addServer(server);
return server;
}

Back to the top