Skip to content
Snippets Groups Projects
Commit b7487d44 authored by Cristina Cocho's avatar Cristina Cocho
Browse files

Added reset collision status button in CommandZone

parent b22f0c35
No related branches found
No related tags found
No related merge requests found
......@@ -191,7 +191,7 @@ public class ServerCommandZone extends CommandZone implements ServerCommandState
}
collisionStatusProperty.setServerId(serverId);
collisionStatusProperty.addPropertyChangeListener(this);
commandZonePeer.createMessageZone();
commandZonePeer.createMessageZone(collisionStatusProperty);
} catch (PropertyNotFoundException e) {
MainWindow.getInstance().onPropertyNotFoundException(e);
}
......@@ -1027,7 +1027,6 @@ public class ServerCommandZone extends CommandZone implements ServerCommandState
}
}
/**
* Called for simulation tab
*/
......@@ -1047,7 +1046,6 @@ public class ServerCommandZone extends CommandZone implements ServerCommandState
}
}
@Override
public void onAddNewAtomicCommandBoxAtEnd(ContainerType type, int commandBoxId, String controllerName, boolean isSettings, int newCommandBoxId) {
debug("onAddNewAtomicCommandBoxAtEnd BEFORE");
......@@ -1145,10 +1143,8 @@ public class ServerCommandZone extends CommandZone implements ServerCommandState
for (CommandBox commandBox : commandBoxes) {
commandBox.onTokenChangeEvent(event);
}
}
@Override
public void propertyChanged(Property property) {
if (viewStateProperty != null && property.getName().equals(viewStateProperty.getName())) {
......@@ -1156,9 +1152,7 @@ public class ServerCommandZone extends CommandZone implements ServerCommandState
commandWorkspace.switchView(true);
}
} else if (property.getName().equals(collisionStatusProperty.getName())) {
// As the management of the collisions is temporarly moved to the real server, use a variable to avoid displaying the message zone when no desired
commandZonePeer.updateMessageZone(property.getValue());
commandWorkspace.getTabButton().getTabButtonPeer().showWarning(String.valueOf(property.getValue()));
commandWorkspace.getTabButton().getTabButtonPeer().showWarning(String.valueOf(property.getValue()));
}
}
......@@ -1169,8 +1163,7 @@ public class ServerCommandZone extends CommandZone implements ServerCommandState
}
}
}
@Override
public void onCommandBoxDeleted(List<Integer> commandBoxIds) {
for (Integer id : commandBoxIds) {
......
......@@ -27,6 +27,7 @@ import fr.ill.ics.client.view.command.ghost.GhostPeer;
import fr.ill.ics.client.view.command.listener.dnd.CommandZoneDropTargetListener;
import fr.ill.ics.client.view.command.listener.dnd.CommandZoneScrollListener;
import fr.ill.ics.client.view.widget.PContainer;
import fr.ill.ics.core.property.Property;
public abstract class CommandZonePeer {
......@@ -170,8 +171,7 @@ public abstract class CommandZonePeer {
public abstract void onArrow(int keyCode);
public abstract void onHomeEnd(int keyCode);
public abstract void scrollToEnd();
public abstract void createMessageZone();
public abstract void updateMessageZone(String message);
public abstract void createMessageZone(Property collisionProperty);
// H.ORTIZ improve erase editor
//public abstract void eraseContent();
......
......@@ -25,6 +25,7 @@ import fr.ill.ics.client.view.command.content.CommandBoxPeer;
import fr.ill.ics.client.view.command.ghost.GhostPeer;
import fr.ill.ics.client.view.widget.PContainer;
import fr.ill.ics.common.Nomad;
import fr.ill.ics.core.property.Property;
public class ArtificialCommandZonePeer extends CommandZonePeer {
......@@ -193,10 +194,7 @@ public class ArtificialCommandZonePeer extends CommandZonePeer {
}
@Override
public void createMessageZone() {
public void createMessageZone(Property collisionProperty) {
}
@Override
public void updateMessageZone(String message) {
}
}
\ No newline at end of file
......@@ -22,6 +22,8 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
......@@ -31,13 +33,14 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import fr.ill.ics.bridge.command.CommandZoneWrapper;
import fr.ill.ics.client.control.MainWindow;
import fr.ill.ics.client.control.command.CommandWindow;
import fr.ill.ics.client.control.command.content.CommandBox;
import fr.ill.ics.client.control.parser.ControllerViewParser;
import fr.ill.ics.client.control.parser.descriptor.widget.WidgetDescriptor;
import fr.ill.ics.client.control.plugin.selection.CommandsSelectionPlugin;
import fr.ill.ics.client.control.plugin.selection.SelectionTreeData;
import fr.ill.ics.client.control.token.TokenManager;
......@@ -52,7 +55,6 @@ import fr.ill.ics.client.view.command.content.swt.SWTIfCommandBoxPeer;
import fr.ill.ics.client.view.command.content.swt.SWTScanContainerCommandBoxPeer;
import fr.ill.ics.client.view.command.ghost.GhostPeer;
import fr.ill.ics.client.view.command.ghost.swt.SWTGhostPeer;
import fr.ill.ics.client.view.factory.FontFactory;
import fr.ill.ics.client.view.factory.swt.SWTColorFactory;
import fr.ill.ics.client.view.factory.swt.SWTPWidgetFactory;
import fr.ill.ics.client.view.factory.swt.SWTWidgetFactory;
......@@ -63,7 +65,9 @@ import fr.ill.ics.client.view.swt.SWTMainWindowPeer;
import fr.ill.ics.client.view.util.dialog.DialogManager;
import fr.ill.ics.client.view.util.textviewer.swt.SWTFileViewer;
import fr.ill.ics.client.view.widget.PContainer;
import fr.ill.ics.client.view.widget.swt.SWTPushButton;
import fr.ill.ics.common.Constants;
import fr.ill.ics.core.property.Property;
import fr.ill.ics.util.ConfigManager;
public class SWTCommandZonePeer extends CommandZonePeer {
......@@ -81,45 +85,47 @@ public class SWTCommandZonePeer extends CommandZonePeer {
private GridData mainGridData;
private Composite bottomComposite;
private Composite topComposite;
private Composite messageComposite;
private GridData messageGridData;
private Label messageLabel;
public SWTCommandZonePeer(Composite constructionComposite) {
initContentComposite(constructionComposite);
createCommandZoneContent();
}
public void createMessageZone() {
messageComposite = SWTWidgetFactory.getInstance().createComposite(commandsComposite, SWT.NONE);
GridLayout gridLayout = SWTWidgetFactory.getInstance().getGridLayout();
gridLayout.marginLeft = Magnifier.getScaledValue(Constants.PROGRESSION_WIDTH);;
public void createMessageZone(Property collisionProperty) {
Composite messageComposite = SWTWidgetFactory.getInstance().createComposite(commandsComposite, SWT.BORDER);
GridLayout gridLayout = SWTWidgetFactory.getInstance().getGridLayout(3);
gridLayout.marginLeft = Magnifier.getScaledValue(Constants.PROGRESSION_WIDTH);
gridLayout.marginRight = 10;
messageComposite.setLayout(gridLayout);
messageGridData = SWTWidgetFactory.getInstance().getHorizontalGridData();
GridData messageGridData = SWTWidgetFactory.getInstance().getHorizontalGridData();
messageGridData.heightHint = 40;
messageComposite.setLayoutData(messageGridData);
messageComposite.setBackground(SWTColorFactory.getNavigationBarBackgroundColor());
messageLabel = SWTWidgetFactory.getInstance().createLabel(messageComposite, "", 12, FontFactory.BOLD_STYLE);
messageLabel.setLayoutData(SWTWidgetFactory.getInstance().getGridData());
WidgetDescriptor widgetDescriptor = new WidgetDescriptor(ControllerViewParser.TAG_TEXT);
widgetDescriptor.setPrefix("Collision state: ");
widgetDescriptor.setSuffix("");
PContainer messageCompositeContainer = ((SWTPWidgetFactory)SWTPWidgetFactory.getSWTInstance()).convertToPContainer(messageComposite);
// First element: label that displays the collision state
SWTPWidgetFactory.getInstance().createPLabel(messageCompositeContainer, collisionProperty, widgetDescriptor, null) ;
// Second element: button to reset the collision state
SWTPushButton resetCollisionStateButton = (SWTPushButton)SWTPWidgetFactory.getInstance().createPushButton(messageCompositeContainer, "Reset", 20);
resetCollisionStateButton.getButton().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
// reset the collision property to its default value
collisionProperty.setValue("OK");
}
});
GridData gridData = SWTWidgetFactory.getInstance().getGridData();
gridData.horizontalAlignment = SWT.RIGHT;
resetCollisionStateButton.setLayoutData(gridData);
messageComposite.moveBelow(topComposite);
messageGridData.exclude = true;
}
public void updateMessageZone(String message) {
messageLabel.setText("Collision state: " +message);
boolean previousExclude = messageGridData.exclude;
messageGridData.exclude = false;
if (previousExclude != messageGridData.exclude) {
commandsComposite.layout();
}
// messageGridData.exclude = true;
}
protected void initContentComposite(Composite constructionComposite) {
commandsComposite = SWTWidgetFactory.getInstance().createComposite(constructionComposite, SWT.NONE);
commandsComposite.setLayout(SWTWidgetFactory.getInstance().getNoMarginsGridLayout(1));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment