Commit bf85a382 authored by Locatelli's avatar Locatelli
Browse files

Commit changes:

- cameo v2
- Re-structure configuration
- compute remaining estimated time
parent 69422157
......@@ -575,3 +575,6 @@ fileChooserToolTip=Open file selector
nbBoxesLabel=Current number of command boxes
upDirectoryMessage=Up directory
estimatedRemainingTimeLabel=Estimated remaining time:
\ No newline at end of file
......@@ -355,6 +355,7 @@ public abstract class AbstractCommandZone {
public abstract boolean isInAForLoop();
public abstract boolean dropAllowed();
public abstract void delete(CommandBox commandBox);
public abstract void setComputeEstimatedTimeState(boolean state);
public abstract void ghostEntersCommandBox(CommandBox commandBox, boolean onTopHalf, int x, int y, boolean scrollTo);
public abstract void ghostLeavesTarget();
......
......@@ -183,4 +183,10 @@ public class CommandZone extends ModifiableCommandZone {
commandZonePeer.onHomeEnd(keyCode);
}
@Override
public void setComputeEstimatedTimeState(boolean state) {
// TODO Auto-generated method stub
}
}
\ No newline at end of file
......@@ -130,6 +130,8 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
*/
public final CommandBox addNewCommandBox(SelectionTreeData selectionTreeData) {
setComputeEstimatedTimeState(false);
// Get a CommandBoxPeer instance
CommandBoxPeer commandBoxPeer = commandZonePeer.replaceGhostWithCommandBoxPeer(selectionTreeData.isSettings());
......@@ -158,6 +160,7 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
} else {
commandZonePeer.delete(commandBoxPeer);
}
setComputeEstimatedTimeState(true);
return commandBox;
}
......@@ -167,6 +170,7 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
* @param selectionTreeData
*/
public final void addCommandBoxAtBeginning(SelectionTreeData selectionTreeData) {
setComputeEstimatedTimeState(false);
boolean done = false;
MainWindowPeer.setRefresh(false);
......@@ -196,6 +200,7 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
}
MainWindowPeer.setRefresh(true);
setComputeEstimatedTimeState(true);
if (done) {
refreshZone();
}
......@@ -208,6 +213,7 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
* @return
*/
public final CommandBox addNewScanContainerCommandBox(SelectionTreeData selectionTreeData) {
setComputeEstimatedTimeState(false);
// Get a CommandBoxPeer instance
CommandBoxPeer commandBoxPeer = commandZonePeer.replaceGhostWithScanContainerCommandBoxPeer();
......@@ -234,6 +240,7 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
} else {
commandZonePeer.delete(commandBoxPeer);
}
setComputeEstimatedTimeState(true);
return scanContainerCommandBox;
}
......@@ -244,6 +251,7 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
* @return
*/
public final CommandBox addNewForLoopCommandBox(SelectionTreeData selectionTreeData) {
setComputeEstimatedTimeState(false);
// Get a CommandBoxPeer instance
CommandBoxPeer commandBoxPeer = commandZonePeer.replaceGhostWithForLoopCommandBoxPeer();
......@@ -272,6 +280,7 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
} else {
commandZonePeer.delete(commandBoxPeer);
}
setComputeEstimatedTimeState(true);
return forLoopCommandBox;
}
......@@ -294,6 +303,7 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
*/
public final CommandBox addNewGenericCommandBox(SelectionTreeData selectionTreeData, String controllerName, String propertyName, String value) {
setComputeEstimatedTimeState(false);
// Get a CommandBoxPeer instance
CommandBoxPeer commandBoxPeer = commandZonePeer.replaceGhostWithGenericCommandBoxPeer();
......@@ -333,11 +343,13 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
} else {
commandZonePeer.delete(commandBoxPeer);
}
setComputeEstimatedTimeState(true);
return genericCommandBox;
}
public final IfCommandBox addNewIfCommandBox(SelectionTreeData selectionTreeData) {
setComputeEstimatedTimeState(false);
// Get a CommandBoxPeer instance
CommandBoxPeer commandBoxPeer = commandZonePeer.replaceGhostWithIfCommandBoxPeer();
......@@ -368,6 +380,7 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
} else {
commandZonePeer.delete(commandBoxPeer);
}
setComputeEstimatedTimeState(true);
return ifCommandBox;
}
......@@ -409,6 +422,7 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
public final void moveCommandBox(CommandBox commandBoxToMove, CommandBox commandBoxToShift, boolean above) {
setComputeEstimatedTimeState(false);
commandBoxToMove.getCommandZone().getCommandBoxes().remove(commandBoxToMove);
......@@ -424,6 +438,7 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
// Graphical update
commandZonePeer.moveCommandBoxPeer(commandBoxToMove, commandBoxToShift, above);
refreshZone();
setComputeEstimatedTimeState(true);
}
/**
......@@ -432,6 +447,7 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
* @param commandBoxToShift
*/
public void moveCommandBox(CommandBox commandBoxToMove) {
setComputeEstimatedTimeState(false);
CommandBox commandBoxToShift = null;
boolean above = true;
......@@ -445,6 +461,7 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
// do nothing if moving onto itself
if (commandBoxToMove == commandBoxToShift) {
setComputeEstimatedTimeState(true);
return;
}
......@@ -458,6 +475,7 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
// Graphical update
commandZonePeer.moveCommandBoxPeer(commandBoxToMove, commandBoxToShift, above);
refreshZone();
setComputeEstimatedTimeState(true);
}
/**
......@@ -1204,6 +1222,7 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
*
*/
public void delete(CommandBox commandBox) {
setComputeEstimatedTimeState(false);
if (commandBox.isSelected()) {
selectedCommandBox = null;
}
......@@ -1215,6 +1234,7 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
commandBoxes.remove(commandBox);
refreshZone();
setComputeEstimatedTimeState(true);
}
......@@ -1222,6 +1242,8 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
*
*/
public void delete() {
setComputeEstimatedTimeState(false);
Vector<CommandBox> copyCommandBoxes = new Vector<CommandBox>(commandBoxes);
boolean resetRefresh = false;
......@@ -1240,6 +1262,8 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
MainWindowPeer.setRefresh(true);
}
commandZonePeer.delete();
setComputeEstimatedTimeState(true);
}
......@@ -1501,6 +1525,7 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
* @param commandBox
*/
public final void deleteCommandBoxForSynchronization(CommandBox commandBox) {
setComputeEstimatedTimeState(false);
if (commandBox.isSelected()) {
selectedCommandBox = null;
}
......@@ -1509,6 +1534,7 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
commandZonePeer.delete(commandBox.getCommandBoxPeer());
commandBoxes.remove(commandBox);
refreshZone();
setComputeEstimatedTimeState(true);
}
public void printDebug(String prefix) {
......@@ -1522,6 +1548,11 @@ public abstract class ModifiableCommandZone extends AbstractCommandZone {
return dropState;
}
@Override
public void setComputeEstimatedTimeState(boolean state) {
}
protected abstract CommandZoneIteratorWrapper getCommandZoneIterator();
public abstract void setInParent(ServerAtomicCommandBox commandBox);
protected abstract void setConstructionState(CommandBox commandBox);
......
......@@ -553,6 +553,10 @@ public class ServerCommandZone extends CommandZone implements ServerCommandState
}
}
public void setComputeEstimatedTimeState(boolean state) {
CommandZoneWrapper.getInstance(serverId).setComputeEstimatedTimeState( state);
}
/**
* Implements the ServerProgressChangedListener.
......
......@@ -153,7 +153,7 @@ public class CommandBox {
LOGGER.log(Level.SEVERE, Nomad.getDateAndTime() + " -- SelectionTreeData is null for : " + this);
}
if (isSettings) {
settingsHelper = new SettingsHelper(this);
settingsHelper = new SettingsHelper(this, commandZone);
((ISettingsCommandBoxPeer)commandBoxPeer).setSettingsHelper(settingsHelper);
((ISettingsCommandBoxPeer)commandBoxPeer).loadSettingsFiles();
}
......
......@@ -432,6 +432,7 @@ public class ForLoopCommandBox extends ContainerCommandBox {
* @param mainScanIsEditable
*/
public void loadContents(CommandBox parent, ForLoopDescriptor descriptor, boolean mainScanIsEditable) {
commandZone.setComputeEstimatedTimeState(false);
Set<ForLoopRangeDescriptor> rangeDescriptors = descriptor.getRangeDescriptors();
Iterator<ForLoopRangeDescriptor> it = rangeDescriptors.iterator();
......@@ -446,6 +447,7 @@ public class ForLoopCommandBox extends ContainerCommandBox {
refreshForLoopProperties();
forLoopCommandZone.loadScanOrForLoopContent(parent, descriptor, mainScanIsEditable);
commandZone.setComputeEstimatedTimeState(true);
}
/**
......@@ -579,6 +581,8 @@ public class ForLoopCommandBox extends ContainerCommandBox {
* @param index
*/
private void createLineFrom(ForLoopLine sourceForLoopLine, int index) {
commandZone.setComputeEstimatedTimeState(false);
ForLoopLine forLoopLine = createForLoopLine(index);
forLoopLine.setForLoopLineType(sourceForLoopLine.getForLoopLineType());
......@@ -605,6 +609,7 @@ public class ForLoopCommandBox extends ContainerCommandBox {
forLoopLine.setValues(sourceForLoopLine.getValues());
break;
}
commandZone.setComputeEstimatedTimeState(true);
}
......@@ -614,6 +619,7 @@ public class ForLoopCommandBox extends ContainerCommandBox {
* @param index
*/
private void createLineFrom(SourceForLoopLineInfo sourceForLoopLineInfo, int index) {
commandZone.setComputeEstimatedTimeState(false);
ForLoopLine forLoopLine = createForLoopLine(index);
forLoopLine.setVariableName(sourceForLoopLineInfo.getVariableName());
forLoopLine.setForLoopLineType(sourceForLoopLineInfo.getForLoopLineType());
......@@ -636,6 +642,7 @@ public class ForLoopCommandBox extends ContainerCommandBox {
forLoopLine.setValues(sourceForLoopLineInfo.getValues());
break;
}
commandZone.setComputeEstimatedTimeState(true);
}
......
......@@ -469,4 +469,12 @@ public class ScanCommandZone extends AbstractCommandZone {
public void addCommandBox(CommandBox commandBox) {
commandBoxes.add(commandBox);
}
@Override
public void setComputeEstimatedTimeState(boolean state) {
// TODO Auto-generated method stub
}
}
\ No newline at end of file
......@@ -156,6 +156,7 @@ public class ServerForLoopCommandBox extends ForLoopCommandBox implements IServe
* This method is called only from initiliaseServerScan, that means just to reflect NomadServer's command zone content in the starting client
*/
private void initialiseRanges() {
commandZone.setComputeEstimatedTimeState(false);
for (int i = 0; i < serverCommandWrapper.getNumberOfLines(); i++) {
ForLoopLine forLoopLine = createForLoopLine(i, true);
if (serverCommandWrapper.getForLoopType(i) == LoopType.RANGE) {
......@@ -174,6 +175,7 @@ public class ServerForLoopCommandBox extends ForLoopCommandBox implements IServe
variableNames.add(forLoopLine.getVariableName());
forLoopLine.getForLoopLinePeer().refresh();
}
commandZone.setComputeEstimatedTimeState(true);
}
/**
......
......@@ -24,6 +24,7 @@ import java.util.Map.Entry;
import java.util.logging.Logger;
import fr.ill.ics.client.control.MainWindow;
import fr.ill.ics.client.control.command.AbstractCommandZone;
import fr.ill.ics.client.control.command.CommandWindow;
import fr.ill.ics.client.control.plugin.ControllerPlugin;
import fr.ill.ics.client.control.plugin.selection.SelectionPlugin;
......@@ -45,6 +46,7 @@ public class SettingsHelper implements INewSettingsFileListener, IPropertyChange
protected static final Logger LOGGER = Logger.getLogger(SettingsHelper.class.getName());
private CommandBox commandBox;
protected AbstractCommandZone commandZone;
private String settingsFileName = ""; // current selected settings file
private SettingsControllerSetupPlugin settingsSetupPlugin;
......@@ -57,8 +59,9 @@ public class SettingsHelper implements INewSettingsFileListener, IPropertyChange
*
* @param commandBox
*/
public SettingsHelper(CommandBox commandBox) {
public SettingsHelper(CommandBox commandBox, AbstractCommandZone commandZone) {
this.commandBox = commandBox;
this.commandZone = commandZone;
CommandZoneFileSync.getInstance().addNewSettingsFileListener(this);
}
......@@ -106,6 +109,8 @@ public class SettingsHelper implements INewSettingsFileListener, IPropertyChange
*/
public boolean load(String directory, String fileName) {
commandZone.setComputeEstimatedTimeState(false);
boolean fileLoaded = false;
if (!fileName.trim().equals("")) {
......@@ -162,6 +167,9 @@ public class SettingsHelper implements INewSettingsFileListener, IPropertyChange
}
}
}
commandZone.setComputeEstimatedTimeState(true);
return fileLoaded;
}
......@@ -192,6 +200,8 @@ public class SettingsHelper implements INewSettingsFileListener, IPropertyChange
*/
public void setSettingsFileName(String settingsFileName) {
commandZone.setComputeEstimatedTimeState(false);
if (!propertiesInitialised) {
initProperties();
}
......@@ -221,6 +231,8 @@ public class SettingsHelper implements INewSettingsFileListener, IPropertyChange
if (fileNameProperty != null) {
fileNameProperty.setValue(settingsFileName);
}
commandZone.setComputeEstimatedTimeState(true);
}
......
......@@ -61,4 +61,10 @@ public class EditionState extends SettingsState {
}
return clone;
}
public void removeSettingsController() {
if (clone != null) {
ControllerManager.getInstance().removeController(clone.getName());
}
}
}
......@@ -104,6 +104,7 @@ public class NewSimpleSettingsControllerSetupPlugin extends SettingsControllerSe
State lastState;
if (isInEditionState()) {
lastState = State.EDITION;
editionState.removeSettingsController();
} else {
lastState = State.EXECUTION;
}
......
......@@ -263,6 +263,7 @@ public class Startup {
}
// load server scan details
CommandWindow.getInstance().initialiseServerScan();
MainWindowPeer.getInstance().getCommandBar().createEstimatedTimeLabel();
CommandWindow.getInstance().getCurrentCommandZone().refreshZone(false);
informationKey = "synchroniseTokenState";
break;
......
......@@ -18,15 +18,20 @@
package fr.ill.ics.client.view.bar.command;
import java.time.Duration;
import fr.ill.ics.bridge.command.CommandZoneWrapper;
import fr.ill.ics.bridge.listeners.ServerCommandZoneEstimatedTime;
import fr.ill.ics.client.control.command.CommandWindow;
import fr.ill.ics.client.control.command.commandline.CommandLine;
import fr.ill.ics.client.view.MainWindowPeer;
import fr.ill.ics.client.view.factory.ImageFactory;
import fr.ill.ics.client.view.magnifier.IMagnifyListener;
import fr.ill.ics.client.view.widget.SimpleLabel;
import fr.ill.ics.util.ConfigManager;
public abstract class CommandBar implements IMagnifyListener {
public abstract class CommandBar implements IMagnifyListener, ServerCommandZoneEstimatedTime {
protected boolean initSwitchViewButtonDone = false;
private boolean canGo = true;
......@@ -37,6 +42,8 @@ public abstract class CommandBar implements IMagnifyListener {
protected int pauseButtonWidth;
protected int switchButtonWidth;
protected SimpleLabel estimatedTimeLabel;
public CommandBar() {
}
......@@ -54,6 +61,13 @@ public abstract class CommandBar implements IMagnifyListener {
createStatusBar();
}
public void createEstimatedTimeLabel() {
if (CommandWindow.getInstance().getCurrentCommandZone().isServerCommandZone()) {
createEstimatedTimeBar();
CommandZoneWrapper.getInstance(CommandZoneWrapper.SERVER_ID).addServerCommandZoneEstimatedTimeListener(this);
}
}
protected void createButtons() {
createStartButton();
createStopButton();
......@@ -126,6 +140,15 @@ public abstract class CommandBar implements IMagnifyListener {
forceCommandLineButtonsState(CommandLine.getInstance(CommandZoneWrapper.SERVER_ID).isPaused(), CommandLine.getInstance(CommandZoneWrapper.SERVER_ID).isStarted());
}
public void estimatedTimeChanged(double remainingtime) {
Duration duration = Duration.ofMillis((long) (remainingtime * 1000.));
long HH = duration.toHours();
long MM = duration.toMinutesPart();
long SS = duration.toSecondsPart();
String timeInHHMMSS = String.format("%02d:%02d:%02d", HH, MM, SS);
estimatedTimeLabel.setText(ConfigManager.getInstance().getString("estimatedRemainingTimeLabel") + " " + timeInHHMMSS);
estimatedTimeLabel.getParent().layout();
}
public void forceCommandLineButtonsState(boolean isPaused, boolean isStarted) {
if (isPaused) {
......@@ -147,6 +170,7 @@ public abstract class CommandBar implements IMagnifyListener {
protected abstract void createSwitchViewButton();
protected abstract void hideSwitchViewButton();
protected abstract void createStatusBar();
protected abstract void createEstimatedTimeBar();
public abstract void setVisible(boolean visible);
public abstract void onStateChange(String startImageKey, String stopImageKey, String pauseImageKey);
public abstract void onStopStateChange(String stopImageKey);
......
......@@ -31,12 +31,14 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.ProgressBar;
import fr.ill.ics.client.control.command.CommandWindow;
import fr.ill.ics.client.control.parser.descriptor.widget.WidgetDescriptor;
import fr.ill.ics.client.control.token.TokenManager;
import fr.ill.ics.client.view.MainWindowPeer;
import fr.ill.ics.client.view.bar.command.CommandBar;
import fr.ill.ics.client.view.bar.status.swt.SWTStatusBar;
import fr.ill.ics.client.view.command.listener.CommandBarButtonActionListener;
import fr.ill.ics.client.view.command.listener.swt.SWTCommandBarButtonActionListener;
import fr.ill.ics.client.view.factory.FontFactory;
import fr.ill.ics.client.view.factory.ImageFactory;
import fr.ill.ics.client.view.factory.PWidgetFactory;
import fr.ill.ics.client.view.factory.WidgetFactory;
......@@ -48,6 +50,7 @@ import fr.ill.ics.client.view.magnifier.Magnifier;
import fr.ill.ics.client.view.util.GraphicalUtilities;
import fr.ill.ics.client.view.util.dialog.DialogManager;
import fr.ill.ics.client.view.util.swt.SWTImageUtils;
import fr.ill.ics.client.view.widget.swt.SWTSimpleLabel;
import fr.ill.ics.util.ConfigManager;
/**
......@@ -488,4 +491,9 @@ public class SWTCommandBar extends CommandBar {
pauseCommandLineCanvas.redraw();
}
@Override
protected void createEstimatedTimeBar() {
estimatedTimeLabel = (SWTSimpleLabel) SWTPWidgetFactory.getInstance().createSimpleLabel(((SWTPWidgetFactory)(PWidgetFactory.getInstance())).convertToPContainer(progressComposite), ConfigManager.getInstance().getString("estimatedRemainingTimeLabel") + " ---", FontFactory.titleFontDataHeight,FontFactory.BOLD_STYLE, 1, WidgetDescriptor.RIGHT);
}
}
\ No newline at end of file
......@@ -117,10 +117,10 @@ public class SWTSimulationResultsWindow extends SimulationResultsWindow {
public void updateEstimatedTime() {
if (serverId != null) {
String formatTime = Nomad.convertToHHMMSS(Float.valueOf(CommandZoneWrapper.getInstance(serverId).getEstimatedTime()+""), true);
estimatedTimeLabel.setText(formatTime);
}
// if (serverId != null) {
// String formatTime = Nomad.convertToHHMMSS(Float.valueOf(CommandZoneWrapper.getInstance(serverId).getEstimatedTime()+""), true);
// estimatedTimeLabel.setText(formatTime);
// }
}
protected void updateTable(ServerErrorEvent event) {
......
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