Commit 7e0f4138 authored by helene ortiz's avatar helene ortiz
Browse files

fix bug when dnd'ing a command box in a simulation tab

parent e2e5771d
......@@ -33,6 +33,7 @@ public class Command extends CommandAction implements ServerCommandStateChangeLi
private int id;
private int databaseId;
private String serverId;
// package protected constructor (have to be created by CommandManager)
Command(int databaseId, int id, String commandName) {
......@@ -41,12 +42,13 @@ public class Command extends CommandAction implements ServerCommandStateChangeLi
this.databaseId = databaseId;
DataNotificationClient.getInstance().addCommandStateChangeListener(this);
DataNotificationClient.getInstance().addCommandProgressionChangeListener(this);
this.isRunning = (DataAccessor.getInstance("real").getCommandState(databaseId, id) == ClientCommandState.ACTIVE);
serverId = DataAccessor.getServerId(databaseId);
this.isRunning = (DataAccessor.getInstance(serverId).getCommandState(0, id) == ClientCommandState.ACTIVE);
}
public ClientCommandState getCommandState() {
return DataAccessor.getInstance("real").getCommandState(databaseId, id);
return DataAccessor.getInstance(serverId).getCommandState(0, id);
}
/**
......@@ -60,7 +62,7 @@ public class Command extends CommandAction implements ServerCommandStateChangeLi
this.isRunning = false;
try {
DataAccessor.getInstance("real").execute(databaseId, id);
DataAccessor.getInstance(serverId).execute(databaseId, id);
showStartingCommandMessage();
} catch (UnknownCommandException e) {
LOGGER.logp(Level.SEVERE, this.getClass().getName(), "execute", "Unknown command: " + this.id);
......@@ -72,7 +74,7 @@ public class Command extends CommandAction implements ServerCommandStateChangeLi
*
*/
public void stop() {
DataAccessor.getInstance("real").stop(databaseId, id);
DataAccessor.getInstance(serverId).stop(databaseId, id);
showStoppingCommandMessage();
}
......
......@@ -23,6 +23,7 @@ import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import fr.ill.ics.bridge.command.CommandZoneWrapper;
import fr.ill.ics.nomadserver.core.DatabaseAccessor;
import fr.ill.ics.nomadserver.core.DatabaseAccessorHelper;
import fr.ill.ics.nomadserver.core.DatabaseAccessorPackage.BadPropertyTypeException;
......@@ -546,4 +547,11 @@ public class DataAccessor {
return databaseAccessor.getWholeScannableProperties(databaseID);
}
public static String getServerId(int databaseId) {
if (databaseId == 0) {
return CommandZoneWrapper.SERVER_ID;
}
return String.valueOf(databaseId);
}
}
\ No newline at end of file
......@@ -66,7 +66,8 @@ public class CorbaServant implements Controller {
int commandId = CommandDatabase.getInstance().getCommandId(servantId, commandName);
if (commandId != -1) {
return DataAccessor.getInstance("real").getCommandState(databaseId, commandId);
String serverId = DataAccessor.getServerId(databaseId);
return DataAccessor.getInstance(serverId).getCommandState(0, commandId);
}
throw new UnknownCommandException();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment