Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2011-01-26 01:21:38 -0500
committerzzhongwei2011-01-26 01:21:38 -0500
commit624d5e81544c116dd1852b6df35b3e6fbfad57a2 (patch)
treed8715e456387fd94e58ba27b0100634de81cb292
parent7747df4604eedd6c1cd3a5c90b015eeb686495c5 (diff)
downloadorg.eclipse.pdt-624d5e81544c116dd1852b6df35b3e6fbfad57a2.tar.gz
org.eclipse.pdt-624d5e81544c116dd1852b6df35b3e6fbfad57a2.tar.xz
org.eclipse.pdt-624d5e81544c116dd1852b6df35b3e6fbfad57a2.zip
ZSFB-210 Path mapping is added to wrong server
-rw-r--r--plugins/org.eclipse.php.server.core/src/org/eclipse/php/internal/server/core/manager/ServersManager.java29
1 files changed, 27 insertions, 2 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..d824634a1 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,6 +17,7 @@ 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;
@@ -108,14 +109,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);
@@ -197,6 +208,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 +296,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 +377,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