Commit afbb1a7b authored by Hélène Ortiz's avatar Hélène Ortiz

Merge branch 'multi-client2'

parents 833dd693 e49c472c
3.6.0 10/02/2020
-----
* Fix bug.
3.5.0 07/02/2020
-----
* Last changes before monday's meeting following Paolo's remarks.
3.4.0 05/02/2020
-----
* Token implementation.
* Chat.
3.3.11 dd/mm/yyyy
------
* Change the way from/to/step/nbpoints values are checked in forloopline: following crashes which occurred when checking those values,
......@@ -11,6 +27,7 @@
* Fix bug in settings command box within an user's script: when file was not loaded, command box wasn't added to commandBoxes vector
of ScanCommandZone (#crash #figaro #Mon Feb 3 11:02:07 CET 2020)
3.3.9 22/01/2020
-----
* Problem while creating version 3.3.8.
......@@ -87,7 +104,6 @@ First multiclient version (merged with V3)
* Add a log message for size property leading to a NumberFormatException in PropertyComboFiller.
* Add a test on currentTreeItem != null in SWTSelectionTree.setSelection because tree.getTopItem may be null if the user clicked on a ButtonSelectionPlugin while tree is reloading (for a change of sample environment for example)
* PropertyPlotData now clones optimization properties to force commandBox to false to ensure to get the value from the database
>>>>>>> V3.2
3.2.14 05/09/2019
......
......@@ -7,6 +7,7 @@ initialiseCommandSelectionAreaMessage=Initialising command selection area...
clientInitialisingPluginManagerMessage=Initialising plugin manager...
initialiseServerScanMessage=Initialising launch pad...
clientReadingPropertiesMessage=Loading properties from client side...
synchroniseTokenState=Synchronising token state...
initialiseSpiesMessage=Initialising spies...
clientReadyMessage=Ready !
clientAboutMessage=About Nomad
......@@ -47,7 +48,7 @@ noCommandPluginMessage=No command plugin exists for this controller
noCommandPluginPeerMessage=No command plugin peer exists for this controller
noCommandInScanMessage=Script is empty. Nothing to save.
noCommandInScanTitle=Wrong action
quitNomadMessage=Are you sure you want to quit NOMAD ?
quitNomadMessage=Are you sure you want to quit Nomad GUI ?
quitNomadMessageTitle=Confirm close
closeTabMessage=You are about to close this tab, all its content will be lost.\nAre you sure you want to continue ?
closeTabMessageTitle=Confirm close
......@@ -291,4 +292,30 @@ unableToLoadScanMessage=Unable to load this script:
warningExpressionMessage=Warning!
badSettingsFileMessage=Wrong content in settings file.\nFile is not going to be loaded.
loadTitle=Load file
\ No newline at end of file
loadTitle=Load file
multiClient.tokenFreeMessage=No client controls Nomad. Click to take Nomad control.
multiClient.tokenOwnedByOtherMessage=Another client already controls Nomad. Click to ask for control.
multiClient.tokenOwnedByMeMessage=You own control over Nomad. Click to give it back.
multiClient.tokenOwnedByOtherShortMessage=Another client already controls Nomad!
cannotModifyLaunchPadWithoutTokenMessage=You don't have the rights to modify launch pad content.\nAsk for token.
cannotChangeProposalWithoutTokenMessage=You don't have the rights to change proposal.\nAsk for token.
cannotChangeProposalWhileSomethingRunningMessage=Proposal can not be changed while commands are running!
addToLaunchPadMessage=Add to launch pad
changeProposalMessage=Change proposal
closeChatMessage=Close chat
openChatMessage=Open chat
chatSendMessageLabel=Send a message
chatShellTitle=Online chat
incomingChatMessage=You have a new message!
serverEndedOnErrorMessage=An error occurred, the server is no longer running.\nThe client is going to be shutdown.
serverEndedOnKilledMessage=Nomad server has been killed.\nThe client is going to be shutdown.
serverEndedOnSuccessMessage=Nomad server has ended.\nThe client is going to be shutdown.
serverEndedOnStoppedMessage=Nomad server has been stopped.\nThe client is going to be shutdown.
serverNoLongerRunningMessage=Server state
tokenIsFreeMessage=Token is free
tokenIsOwnedByOtherMessage=Token is owned by
tokenIsOwnedByMe=You now own the token
......@@ -2,10 +2,10 @@ commandLineLabel=Command :
loginLabel=LOGIN
passwordLabel=PASSWD
loadingLabel=LOADING
loginButtonLabel=Login
selectProposalLabel=Select proposal
exitButtonLabel=Exit
loginLabelKey=Login
loginLabelKey=User
passwordLabelKey=Password
selectAProposalLabelKey=Select a proposal from the list below:
proposalCodeLabel=Code
......@@ -74,7 +74,6 @@ menu.spy.restoreFavoriteSpiesCommand=&Restore favorites
menu.user=&User
menu.user.login=&Login
menu.user.logout=&Logout
menu.user.changeProposal=&Change proposal
menu.user.admin=&Administrator
menu.user.adminLogout=Logout &Administrator
......@@ -539,6 +538,7 @@ variableSelectorMessage=Open the variable selector
variableSelectorTitleMessage=Variable selector
propertySelectorMessage=Open the property selector
constantSelectorMessage=Open the constant selector
conditionsPropertySelectorMessage=Open assistant
showInSpyLabel=Show in spy
variablesExpressionLabel=Expression
......
......@@ -42,7 +42,6 @@
</menu>
<menu key="menu.user">
<item key="menu.user.login" action="fr.ill.ics.client.view.menu.LoginAction"/>
<item key="menu.user.changeProposal" action="fr.ill.ics.client.view.menu.ChangeProposalAction"/>
<item key="menu.user.admin" action="fr.ill.ics.client.view.menu.AdministrationLoginAction"/>
</menu>
<menu key="menu.zoom">
......
......@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fr.ill.ics</groupId>
<artifactId>nomadgui</artifactId>
<version>3.3.11-SNAPSHOT</version>
<version>3.6.0</version>
<name>NomadGUI</name>
<description>Graphical user interface for Nomad</description>
<scm>
......@@ -135,7 +135,7 @@
<dependency>
<groupId>fr.ill.ics</groupId>
<artifactId>nomadcommandsystem</artifactId>
<version>3.3.4</version>
<version>3.4.0</version>
</dependency>
<!-- **************************************************************** JFACE ****************************************************************
......
......@@ -31,10 +31,12 @@ import java.util.logging.Logger;
import fr.ill.ics.bridge.ChangeManager;
import fr.ill.ics.bridge.ControllerManager;
import fr.ill.ics.bridge.ErrorManager;
import fr.ill.ics.bridge.LoginManager;
import fr.ill.ics.bridge.command.CommandZoneWrapper;
import fr.ill.ics.bridge.commandline.CommandLineProxyWrapper;
import fr.ill.ics.bridge.events.ServerEndedEvent;
import fr.ill.ics.bridge.listeners.ServerConfigurationChangeListener;
import fr.ill.ics.bridge.listeners.ServerEndedListener;
import fr.ill.ics.cameo.Application;
import fr.ill.ics.cameo.Application.Instance;
import fr.ill.ics.cameo.Server;
......@@ -59,6 +61,7 @@ import fr.ill.ics.client.view.util.dialog.DialogManager;
import fr.ill.ics.client.view.util.listener.INewCountRepeaterFileListener;
import fr.ill.ics.client.view.util.listener.INewSlicesFileListener;
import fr.ill.ics.common.Nomad;
import fr.ill.ics.nscclient.serverconnection.ServerConnection;
import fr.ill.ics.nscclient.serverconnection.ServerInstance;
import fr.ill.ics.util.ConfigManager;
import fr.ill.ics.util.ServerException;
......@@ -68,7 +71,7 @@ import fr.ill.ics.util.exception.ExitException;
import fr.ill.ics.util.exception.ParticularWidgetNotFoundException;
import fr.ill.ics.util.exception.PropertyNotFoundException;
public class MainWindow implements ServerConfigurationChangeListener {
public class MainWindow implements ServerConfigurationChangeListener, ServerEndedListener {
private final static String NOMADLOGS_APP_NAME = "nlogs";
private final static String NOMAD_ADMINISTRATOR = "nomadAdministrator";
......@@ -187,6 +190,8 @@ public class MainWindow implements ServerConfigurationChangeListener {
} finally {
ServerConnection.getInstance(CommandZoneWrapper.SERVER_ID).reset();
System.out.println("Resetting Cameo application");
MainWindow.getInstance().reset();
......@@ -244,6 +249,12 @@ public class MainWindow implements ServerConfigurationChangeListener {
// Perform startup operations
startup.run();
/*
if (!TokenManager.getInstance().isMainClient()) {
// Ask the user to login and to choose an instrument
}
*/
if (!commandLineOk) {
// Prevent user to switch to text mode
......@@ -264,12 +275,13 @@ public class MainWindow implements ServerConfigurationChangeListener {
MainWindowPeer.getInstance().getCommandBar().onSwitchViewButtonClick();
}
else {
CommandLineProxyWrapper.getInstance(CommandZoneWrapper.SERVER_ID).setCommandLineState(false);
// TODO The change of state for the command line spy must be done in the client and not in the server.
//CommandLineProxyWrapper.getInstance(CommandZoneWrapper.SERVER_ID).setCommandLineState(false);
}
UserConnection.getInstance().loginIfUserPreviouslyConnected();
ControllerManager.getInstance().addConfigurationChangeListener(this);
ErrorManager.getInstance(CommandZoneWrapper.SERVER_ID).addServerEndedListener(this);
initOk = true;
}
......@@ -777,10 +789,14 @@ public class MainWindow implements ServerConfigurationChangeListener {
public void onProposalChange(String selectedProposalId) {
if (initOk && nomadLogsIsOpen()) { // Prevent initial call when proposal property is set
stopNomadLogs();
startNomadLogs();
// Warn NomadLogs (if open) that proposal has changed
if (MainWindow.useNomadLogs()) {
if (initOk && nomadLogsIsOpen()) { // Prevent initial call when proposal property is set
stopNomadLogs();
startNomadLogs();
}
}
MainWindow.getInstance().onProposalChange(Long.valueOf(selectedProposalId));
}
......@@ -790,4 +806,36 @@ public class MainWindow implements ServerConfigurationChangeListener {
// do not restart it, when the user changes, the proposal changes just after and will restart logs if necessary
}
}
public void onTokenStateChange() {
MainWindowPeer.getInstance().onTokenStateChange();
}
public void onProposalChange(long selectedProposalId) {
MainWindowPeer.getInstance().onProposalChange(selectedProposalId);
}
public void closeChat() {
MainWindowPeer.getInstance().closeChat();
}
public void onProposalChange() {
authentication.updateProposal();
// this call will open chat's file for current proposal
onProposalChange(ExperimentData.getInstance().getProposalId());
}
@Override
public void serverEnded(ServerEndedEvent event) {
MainWindowPeer.getInstance().addAsyncRunnable(new Runnable() {
@Override
public void run() {
DialogManager.getInstance().nomadMessageDialog(event.getMessage(), "serverNoLongerRunningMessage");
close();
}
});
}
}
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package fr.ill.ics.client.control.chat;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
import fr.ill.ics.bridge.ResourceManager;
import fr.ill.ics.bridge.command.CommandZoneWrapper;
import fr.ill.ics.bridge.events.ChatEvent;
import fr.ill.ics.client.control.experiment.ExperimentData;
import fr.ill.ics.nscclient.servant.ResourceNotFoundException;
import fr.ill.ics.nscclient.sessionmanagement.SessionManager;
import fr.ill.ics.util.ConfigManager;
/**
*
* @author ortizh
*/
public class ChatFileManager {
private final static String CHAT_DELIMITER = "|";
private final static String MESSAGE_PREFIX = "message:";
private final static String SENDER_PREFIX = "sender:";
private final static String TIMESTAMP_PREFIX = "timestamp:";
private final static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
private static ChatFileManager instance = null;
private ChatFileManager() {
}
public static ChatFileManager getInstance() {
if (instance == null) {
instance = new ChatFileManager();
// Create chat files directory if missing
ResourceManager.getInstance().createDirectory(ConfigManager.DOT_NOMAD_DIRECTORY, ConfigManager.NOMAD_CHAT_FILES);
}
return instance;
}
public List<ChatEvent> getChat(long proposNo) {
String filePath = getFilePath(proposNo);
String chatContent;
try {
chatContent = ResourceManager.getInstance().getFileContent(filePath);
if (chatContent != null && !chatContent.isEmpty()) {
BufferedReader reader = new BufferedReader(new StringReader(chatContent));
String line;
try {
List<ChatEvent> messages = new ArrayList<ChatEvent>();
while((line = reader.readLine()) != null) {
try {
if (!line.isEmpty()) {
StringTokenizer tokenizer = new StringTokenizer(line, CHAT_DELIMITER);
String message = tokenizer.nextToken();
message = message.replace(MESSAGE_PREFIX, "");
String sender = tokenizer.nextToken();
sender = sender.replace(SENDER_PREFIX, "");
String timestampString = tokenizer.nextToken();
timestampString = timestampString.replace(TIMESTAMP_PREFIX, "");
LocalDateTime timestamp = LocalDateTime.parse(timestampString, formatter);
ChatEvent event = new ChatEvent(sender, message, timestamp);
messages.add(event);
}
} catch (NoSuchElementException e) {
System.err.println("Malformed message in chat file: " + line);
}
}
return messages;
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (ResourceNotFoundException e) {
e.printStackTrace();
}
return null;
}
public void addChat(ChatEvent event) {
String filePath = getFilePath(ExperimentData.getInstance().getProposalId());
// In case user has entered a CHAT_DELIMITER in his/her message
String message = event.getMessage();
message = message.replace(CHAT_DELIMITER, " ");
String chatLine = MESSAGE_PREFIX + message + CHAT_DELIMITER + SENDER_PREFIX + event.getSender() + CHAT_DELIMITER + TIMESTAMP_PREFIX + formatter.format(event.getTimestamp());
// Update chat's file
ResourceManager.getInstance().appendToFile(filePath, chatLine);
// Inform other clients that there is a new message in chat
SessionManager.getInstance(CommandZoneWrapper.SERVER_ID).sendChatMessage(event.getSender(), message);
}
public String getFilePath(long proposNo) {
return ConfigManager.DOT_NOMAD_DIRECTORY + ConfigManager.FILE_SEPARATOR + ConfigManager.NOMAD_CHAT_FILES + ConfigManager.FILE_SEPARATOR + "chat"+ proposNo + ".xml";
}
}
......@@ -548,6 +548,16 @@ public class CommandWindow {
return null;
}
}
}
/*
public void onTokenStateChange() {
CommandWindowPeer.getInstance().onTokenStateChange();
}
public void onProposalChange(long selectedProposalId) {
CommandWindowPeer.getInstance().onProposalChange(selectedProposalId);
}
public void closeChat() {
CommandWindowPeer.getInstance().closeChat();
}*/
}
......@@ -71,6 +71,7 @@ import fr.ill.ics.client.control.parser.descriptor.command.SetPointDescriptor;
import fr.ill.ics.client.control.parser.descriptor.command.SettingsDescriptor;
import fr.ill.ics.client.control.plugin.selection.ScanSelectionTreeData;
import fr.ill.ics.client.control.plugin.selection.SelectionTreeData;
import fr.ill.ics.client.control.token.TokenManager;
import fr.ill.ics.client.view.MainWindowPeer;
import fr.ill.ics.client.view.command.CommandZonePeer;
import fr.ill.ics.client.view.command.clipboard.ClipboardManager;
......@@ -1168,6 +1169,9 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
commandBox.init();
commandBox.endInit();
commandBoxes.add(commandBox);
// Take into account token state
commandBox.onTokenChangeEvent();
}
}
}
......@@ -1324,21 +1328,34 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
* @param ctrlActive
*/
public boolean drop(SelectionTreeData selectionTreeData, boolean ctrlActive) {
if (dropAllowed()) {
if (CommandWindow.getInstance().getCurrentCommandZone().isServerCommandZone() && CommandWindow.getInstance().getCurrentCommandZone().atLeastOneUnknownCommandBoxInCommandZone()) {
DialogManager.getInstance().nomadMessageDialog("impossibleDropBecauseUnknownCommandsMessage", "impossibleDropBecauseUnknownCommandsTitle");
} else {
// Before continuing, check that this node can be dropped
if (!selectionTreeData.isClipboardParentNode() && !selectionTreeData.isScan() && !selectionTreeData.isForLoop() && !selectionTreeData.isIf() && !selectionTreeData.isBreakIf() && !selectionTreeData.isGeneric() && selectionTreeData.getPluginClass() == null) {
DialogManager.getInstance().nomadMessageDialog("noCommandPluginMessage", "");
} else {
boolean goOn = true;
if (CommandWindow.getInstance().getCurrentCommandZone().isServerCommandZone()) {
if (!TokenManager.getInstance().tokenIsOwnedByMe()) {
DialogManager.getInstance().nomadMessageDialog("cannotModifyLaunchPadWithoutTokenMessage", "addToLaunchPadMessage");
goOn = false;
}
}
if (ctrlActive) {
CommandWindow.getInstance().getSelectedTab().onCtrlDrop(this);
if (goOn) {
if (dropAllowed()) {
if (CommandWindow.getInstance().getCurrentCommandZone().isServerCommandZone() && CommandWindow.getInstance().getCurrentCommandZone().atLeastOneUnknownCommandBoxInCommandZone()) {
DialogManager.getInstance().nomadMessageDialog("impossibleDropBecauseUnknownCommandsMessage", "impossibleDropBecauseUnknownCommandsTitle");
} else {
// Before continuing, check that this node can be dropped
if (!selectionTreeData.isClipboardParentNode() && !selectionTreeData.isScan() && !selectionTreeData.isForLoop() && !selectionTreeData.isIf() && !selectionTreeData.isBreakIf() && !selectionTreeData.isGeneric() && selectionTreeData.getPluginClass() == null) {
DialogManager.getInstance().nomadMessageDialog("noCommandPluginMessage", "");
} else {
if (ctrlActive) {
CommandWindow.getInstance().getSelectedTab().onCtrlDrop(this);
}
verifyAndDropCommandBox(selectionTreeData, ctrlActive);
}
verifyAndDropCommandBox(selectionTreeData, ctrlActive);
return true;
}
return true;
}
}
return false;
......
......@@ -34,6 +34,7 @@ import fr.ill.ics.bridge.command.IServerCommand;
import fr.ill.ics.bridge.command.ScanCommandWrapper;
import fr.ill.ics.bridge.events.ServerCommandStateChangeEvent;
import fr.ill.ics.bridge.events.ServerResetCommandEvent;
import fr.ill.ics.bridge.events.TokenEvent;
import fr.ill.ics.bridge.listeners.ServerCommandStateChangeListener;
import fr.ill.ics.bridge.listeners.ServerCommandZoneErrorListener;
import fr.ill.ics.bridge.listeners.ServerCommandZoneSyncListener;
......@@ -60,6 +61,7 @@ import fr.ill.ics.client.control.command.executionstate.ServerCommandZoneTermina
import fr.ill.ics.client.control.command.multiclient.CommandZoneSynchronizer;
import fr.ill.ics.client.control.plugin.selection.GenericSelectionTreeData;
import fr.ill.ics.client.control.plugin.selection.SelectionTreeData;
import fr.ill.ics.client.control.token.TokenManager;
import fr.ill.ics.client.view.MainWindowPeer;
import fr.ill.ics.client.view.command.CommandZonePeer;
import fr.ill.ics.client.view.command.content.CommandBoxPeer;
......@@ -83,7 +85,7 @@ public class ServerCommandZone extends CommandZone implements ServerCommandState
private int databaseId = 0;
private boolean clearAsked = false;
private CommandZoneSynchronizer commandZoneSynchronizer;
public ServerCommandZone(CommandWorkspace commandWorkspace, CommandZonePeer commandZonePeer, String serverId) {
super(commandWorkspace, commandZonePeer);
......@@ -102,7 +104,7 @@ public class ServerCommandZone extends CommandZone implements ServerCommandState
CommandZoneWrapper.getInstance(serverId).addServerProgressChangeListener(this);
CommandZoneWrapper.getInstance(serverId).addServerResetCommandListener(this);
CommandZoneWrapper.getInstance(serverId).addServerCommandZoneErrorListener(this);
// The command zone sync listener is only registered for real server.
if (serverId.equals(CommandZoneWrapper.SERVER_ID)) {
CommandZoneWrapper.getInstance(serverId).addServerCommandZoneSyncListener(this);
......@@ -439,13 +441,15 @@ public class ServerCommandZone extends CommandZone implements ServerCommandState
* Overloaded. Uses the current execution state to determine what to do.
*/
public void onStartPressed() {
if (!commandBoxes.isEmpty()) {
if (contentOkToStart()) {
if (Nomad.isLite()) {
// In "nomad lite" commandWorkspace is null
serverCommandZoneExecutionState.onStartButtonPressed(true);
} else {
serverCommandZoneExecutionState.onStartButtonPressed(commandWorkspace.isInTextMode());
if (TokenManager.getInstance().tokenIsOwnedByMe()) {
if (!commandBoxes.isEmpty()) {
if (contentOkToStart()) {
if (Nomad.isLite()) {
// In "nomad lite" commandWorkspace is null
serverCommandZoneExecutionState.onStartButtonPressed(true);
} else {
serverCommandZoneExecutionState.onStartButtonPressed(commandWorkspace.isInTextMode());
}
}
}
}
......@@ -456,12 +460,14 @@ public class ServerCommandZone extends CommandZone implements ServerCommandState
* Overloaded. Uses the current execution state to determine what to do.
*/
public void onStopPressed() {
if (!commandBoxes.isEmpty()) {
if (Nomad.isLite()) {
// In "nomad lite" commandWorkspace is null
serverCommandZoneExecutionState.onStopButtonPressed(true);
} else {
serverCommandZoneExecutionState.onStopButtonPressed(commandWorkspace.isInTextMode());
if (TokenManager.getInstance().tokenIsOwnedByMe()) {
if (!commandBoxes.isEmpty()) {
if (Nomad.isLite()) {
// In "nomad lite" commandWorkspace is null
serverCommandZoneExecutionState.onStopButtonPressed(true);
} else {
serverCommandZoneExecutionState.onStopButtonPressed(commandWorkspace.isInTextMode());
}
}
}
}
......@@ -471,9 +477,11 @@ public class ServerCommandZone extends CommandZone implements ServerCommandState
* Overloaded. Uses the current execution state to determine what to do.
*/
public void onPausePressed() {
//if (!commandBoxes.isEmpty()) {
serverCommandZoneExecutionState.onPauseButtonPressed();
//}
if (TokenManager.getInstance().tokenIsOwnedByMe()) {
//if (!commandBoxes.isEmpty()) {
serverCommandZoneExecutionState.onPauseButtonPressed();
//}
}
}
......@@ -856,22 +864,24 @@ public class ServerCommandZone extends CommandZone implements ServerCommandState
* Stop current running commands.
*/
public void onStopCurrentCommand() {
if (somethingRunning()) {
Iterator<CommandBox> it = commandBoxes.iterator();
Set<CommandBox> runningCommandBoxes = new HashSet<CommandBox>();
// Get running commands
while (it.hasNext()) {
CommandBox commandBox = it.next();
if (commandBox.getExecutionPhaseState().isRunning()) {
runningCommandBoxes.addAll(commandBox.getRunningCommandBox());
}
}
if (!runningCommandBoxes.isEmpty()) {
// Stop running commands
it = runningCommandBoxes.iterator();
if (TokenManager.getInstance().tokenIsOwnedByMe()) {
if (somethingRunning()) {
Iterator<CommandBox> it = commandBoxes.iterator();
Set<CommandBox> runningCommandBoxes = new HashSet<CommandBox>();
// Get running commands
while (it.hasNext()) {
CommandBox commandBox = it.next();
commandBox.stop();
if (commandBox.getExecutionPhaseState().isRunning()) {
runningCommandBoxes.addAll(commandBox.getRunningCommandBox());
}
}
if (!runningCommandBoxes.isEmpty()) {
// Stop running commands
it = runningCommandBoxes.iterator();
while (it.hasNext()) {
CommandBox commandBox = it.next();
commandBox.stop();
}
}
}
}
......@@ -882,7 +892,9 @@ public class ServerCommandZone extends CommandZone implements ServerCommandState
* Stop running commands at end.
*/
public void onStopCommandAtEnd() {
CommandZoneWrapper.getInstance(serverId).stopAtEnd();
if (TokenManager.getInstance().tokenIsOwnedByMe()) {
CommandZoneWrapper.getInstance(serverId).stopAtEnd();
}
}
......@@ -929,14 +941,14 @@ public class ServerCommandZone extends CommandZone implements ServerCommandState
public void print() {
//commandZonePeer.print(serverId);
}
private void debug(String message) {
if (debugSynchro) {
System.out.println(message);
printDebug("");
}
}
@Override
public void onAddNewAtomicCommandBoxAtEnd(ContainerType type, int commandBoxId, int commandId, boolean isSettings, int newCommandBoxId) {
......@@ -1019,7 +1031,7 @@ public class ServerCommandZone extends CommandZone implements ServerCommandState
public void onAddNewScanCommandBox(ContainerType type, int commandBoxId, String scanName, int commandBoxIdToMove, boolean above, int newCommandBoxId) {
debug("onAddNewScanCommandBox BEFORE");
System.out.println("CODE METHOD onAddNewScanCommandBox in " + getClass().getCanonicalName());
// commandZoneSynchronizer.onAddNewScanCommandBox(newCommandBoxId, scanName, commandBoxIdToMove, above, type, commandBoxId);
// commandZoneSynchronizer.onAddNewScanCommandBox(newCommandBoxId, scanName, commandBoxIdToMove, above, type, commandBoxId);
debug("onAddNewScanCommandBox AFTER");
}
......@@ -1029,4 +1041,11 @@ public class ServerCommandZone extends CommandZone implements ServerCommandState
commandZoneSynchronizer.addNewScanCommandBoxAtEnd(newCommandBoxId, type, scanName, commandBoxId);
debug("onAddNewScanCommandBoxAtEnd AFTER");
}
public void onTokenChangeEvent(TokenEvent event) {
for (CommandBox commandBox : commandBoxes) {
commandBox.onTokenChangeEvent(event);
}
}
}
\ No newline at end of file
......@@ -20,6 +20,7 @@ package fr.ill.ics.client.control.command;
import java.util.logging.Logger;
import fr.ill.ics.bridge.events.TokenEvent;