diff --git a/ummisco.gama.ui.shared/src/ummisco/gama/ui/interfaces/IParameterEditor.java b/ummisco.gama.ui.shared/src/ummisco/gama/ui/interfaces/IParameterEditor.java index 38eff3f429..323484e153 100644 --- a/ummisco.gama.ui.shared/src/ummisco/gama/ui/interfaces/IParameterEditor.java +++ b/ummisco.gama.ui.shared/src/ummisco/gama/ui/interfaces/IParameterEditor.java @@ -25,10 +25,6 @@ @SuppressWarnings ({ "rawtypes" }) public interface IParameterEditor extends IScoped { - enum item { - PLUS, MINUS, EDIT, INSPECT, BROWSE, CHANGE, REVERT, DEFINE, VALUE; - } - IType getExpectedType(); boolean isValueModified(); diff --git a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/AbstractEditor.java b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/AbstractEditor.java index 5535aa2b16..4bdd7b3f87 100644 --- a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/AbstractEditor.java +++ b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/AbstractEditor.java @@ -12,7 +12,6 @@ package ummisco.gama.ui.parameters; import static msi.gama.common.util.StringUtils.toGaml; -import static ummisco.gama.ui.resources.GamaIcons.create; import java.util.ArrayList; import java.util.List; @@ -26,14 +25,11 @@ import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.ToolBar; -import org.eclipse.swt.widgets.ToolItem; import com.google.common.primitives.Ints; @@ -51,55 +47,12 @@ import msi.gaml.variables.Variable; import ummisco.gama.ui.interfaces.EditorListener; import ummisco.gama.ui.interfaces.IParameterEditor; -import ummisco.gama.ui.resources.GamaIcons; import ummisco.gama.ui.resources.IGamaColors; -import ummisco.gama.ui.resources.IGamaIcons; import ummisco.gama.ui.utils.WorkbenchHelper; public abstract class AbstractEditor implements SelectionListener, ModifyListener, Comparable>, IParameterEditor { - private class ItemSelectionListener extends SelectionAdapter { - - private final int code; - - ItemSelectionListener(final int code) { - this.code = code; - } - - @Override - public void widgetSelected(final SelectionEvent e) { - switch (code) { - case REVERT: - modifyAndDisplayValue(applyRevert()); - break; - case PLUS: - modifyAndDisplayValue(applyPlus()); - break; - case MINUS: - modifyAndDisplayValue(applyMinus()); - break; - case EDIT: - applyEdit(); - break; - case INSPECT: - applyInspect(); - break; - case BROWSE: - applyBrowse(); - break; - case CHANGE: - if (e.detail != SWT.ARROW) return; - applyChange(); - break; - case DEFINE: - applyDefine(); - break; - } - } - - } - private static int ORDER; private final int order = ORDER++; private final EditorListener listener; @@ -113,15 +66,18 @@ public void widgetSelected(final SelectionEvent e) { protected T originalValue, currentValue, minValue, maxValue, stepValue; // Properties - protected boolean isCombo = false, isEditable = true, isSubParameter = false, noScope = false, acceptNull = true; + protected boolean noScope = false, acceptNull = true; + protected final boolean isCombo; + protected /* almost final */ boolean isSubParameter; + protected final boolean isEditable; protected volatile boolean internalModification; // UI Components protected Combo combo; protected EditorLabel titleLabel; private CLabel fixedValue; - protected Composite composite, parent, toolbar; - protected final ToolItem[] items = new ToolItem[9]; + protected Composite composite, parent; + final EditorToolbar toolbar; public AbstractEditor(final IScope scope, final IParameter variable) { this(scope, null, variable, null); @@ -164,7 +120,7 @@ public AbstractEditor(final IScope scope, final IAgent a, final IParameter varia name = ""; } listener = l; - + toolbar = new EditorToolbar(this); } @Override @@ -183,15 +139,8 @@ public void setActive(final Boolean active) { titleLabel.setInactive(); } } - if (!active) { - for (final ToolItem t : items) { - if (t == null) { continue; } - t.setEnabled(false); - } - } else { - checkButtons(); - } - + toolbar.setActive(active); + if (active) { updateToolbar(); } this.getEditor().setEnabled(active); } @@ -264,29 +213,25 @@ protected Control createEditorControl(final Composite comp) { public void createComposite(final Composite comp) { // Necessary to force SWT to "reskin" and give the right background to the composite (issue in the CSS engine) comp.computeSize(SWT.DEFAULT, SWT.DEFAULT); - this.parent = comp; - internalModification = true; - titleLabel = new EditorLabel(comp, name, computeLabelTooltip(), isSubParameter); try { setOriginalValue(getParameterValue()); + currentValue = getOriginalValue(); } catch (final GamaRuntimeException e1) { e1.addContext("Impossible to obtain the value of " + name); GAMA.reportError(GAMA.getRuntimeScope(), e1, false); } - currentValue = getOriginalValue(); + parent = comp; + internalModification = true; + titleLabel = new EditorLabel(comp, name, computeLabelTooltip(), isSubParameter); composite = new Composite(comp, SWT.NONE); composite.setBackground(getNormalBackground()); final var data = new GridData(SWT.FILL, SWT.CENTER, true, false); - // data.minimumWidth = 150; composite.setLayoutData(data); - final var layout = new GridLayout(2, false); layout.marginWidth = 5; - composite.setLayout(layout); createEditorControl(composite); - toolbar = createToolbar2(); - + toolbar.build(composite); if (isEditable && !isCombo) { displayParameterValueAndCheckButtons(); } internalModification = false; comp.layout(); @@ -329,74 +274,6 @@ protected String typeToDisplay() { return param.getType().serialize(false); } - protected Composite createToolbar2() { - final var t = new ToolBar(composite, SWT.NONE); - final var d = new GridData(SWT.END, SWT.FILL, false, false); - t.setLayoutData(d); - if (isEditable) { - final var codes = this.getToolItems(); - for (final int i : codes) { - ToolItem item = null; - switch (i) { - case REVERT: - item = createItem(t, "Revert to original value", create("small.revert").image()); - break; - case PLUS: - item = createPlusItem(t); - break; - case MINUS: - item = createMinusItem(t); - break; - case EDIT: - item = createItem(t, "Edit the parameter", create("small.edit").image()); - break; - case INSPECT: - item = createItem(t, "Inspect the agent", create("small.inspect").image()); - break; - case BROWSE: - item = createItem(t, "Browse the list of agents", create("small.browse").image()); - break; - case CHANGE: - item = createItem(t, "Choose another agent", create("small.change").image()); - break; - case DEFINE: - item = createItem(t, "Set the parameter to undefined", create("small.undefine").image()); - break; - case VALUE: - item = createItem(t, "Value of the parameter", null); - } - if (item != null) { - items[i] = item; - item.addSelectionListener(new ItemSelectionListener(i)); - - } - } - } - return t; - - } - - protected ToolItem createPlusItem(final ToolBar t) { - return createItem(t, "Increment " + (stepValue == null ? "" : " by " + stepValue), - GamaIcons.create(IGamaIcons.SMALL_PLUS).image()); - } - - protected ToolItem createMinusItem(final ToolBar t) { - return createItem(t, "Decrement " + (stepValue == null ? "" : " by " + stepValue), - GamaIcons.create(IGamaIcons.SMALL_MINUS).image()); - } - - /** - * @param string - * @param image - */ - private ToolItem createItem(final ToolBar t, final String string, final Image image) { - final var i = new ToolItem(t, SWT.FLAT | SWT.PUSH); - i.setToolTipText(string); - i.setImage(image); - return i; - } - @SuppressWarnings ("unchecked") protected T getParameterValue() throws GamaRuntimeException { Object result; @@ -484,12 +361,6 @@ public void widgetSelected(final SelectionEvent me) { protected abstract void displayParameterValue(); - protected void checkButtons() { - final var revert = items[REVERT]; - if (revert == null || revert.isDisposed()) return; - revert.setEnabled(isValueDifferent(originalValue)); - } - @Override public boolean isValueModified() { return isValueDifferent(getOriginalValue()); @@ -561,7 +432,7 @@ public void forceUpdateValueAsynchronously() { combo.select(possibleValues.indexOf(newVal)); } else { displayParameterValue(); - checkButtons(); + updateToolbar(); } composite.update(); internalModification = false; @@ -573,7 +444,7 @@ public void forceUpdateValueAsynchronously() { private void displayParameterValueAndCheckButtons() { WorkbenchHelper.run(() -> { displayParameterValue(); - checkButtons(); + updateToolbar(); }); } @@ -595,12 +466,16 @@ protected final void modifyAndDisplayValue(final T val) { } else { WorkbenchHelper.asyncRun(() -> { displayParameterValue(); - checkButtons(); + updateToolbar(); }); } } + protected void updateToolbar() { + toolbar.update(); + } + protected IAgent getAgent() { if (agent != null) return agent; if (scope == null) return null; diff --git a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/AgentEditor.java b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/AgentEditor.java index 54c94dcdcb..0fd129fbc1 100644 --- a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/AgentEditor.java +++ b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/AgentEditor.java @@ -1,13 +1,12 @@ /********************************************************************************************* * - * 'AgentEditor.java, in plugin ummisco.gama.ui.shared, is part of the source code of the - * GAMA modeling and simulation platform. - * (v. 1.8.1) - * + * 'AgentEditor.java, in plugin ummisco.gama.ui.shared, is part of the source code of the GAMA modeling and simulation + * platform. (v. 1.8.1) + * * (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners * * Visit https://github.com/gama-platform/gama for license information and developers contact. - * + * * **********************************************************************************************/ package ummisco.gama.ui.parameters; @@ -18,6 +17,7 @@ import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; +import org.eclipse.swt.widgets.Shell; import msi.gama.kernel.experiment.IParameter; import msi.gama.metamodel.agent.IAgent; @@ -30,7 +30,7 @@ import ummisco.gama.ui.resources.IGamaIcons; import ummisco.gama.ui.utils.WorkbenchHelper; -@SuppressWarnings({ "unchecked", "rawtypes" }) +@SuppressWarnings ({ "unchecked", "rawtypes" }) public class AgentEditor extends ExpressionBasedEditor { // Label agentDisplayer; @@ -67,11 +67,10 @@ public class AgentEditor extends ExpressionBasedEditor { @Override public void applyChange() { - final Menu old = items[CHANGE].getParent().getShell().getMenu(); - items[CHANGE].getParent().getShell().setMenu(null); - if (old != null) { - old.dispose(); - } + Shell shell = toolbar.getItem(CHANGE).getParent().getShell(); + final Menu old = shell.getMenu(); + shell.setMenu(null); + if (old != null) { old.dispose(); } // FIXME Not adapted to multiple scales ! final MenuAction action = new MenuAction(new SelectionAdapter() { @@ -80,23 +79,22 @@ public void applyChange() { public void widgetSelected(final SelectionEvent e) { final MenuItem mi = (MenuItem) e.widget; final IAgent a = (IAgent) mi.getData("agent"); - if (a != null && !a.dead()) { - modifyAndDisplayValue(a); - } + if (a != null && !a.dead()) { modifyAndDisplayValue(a); } } }, GamaIcons.create(IGamaIcons.MENU_AGENT).image(), "Choose"); - final Menu dropMenu = new Menu(items[CHANGE].getParent().getShell()); + final Menu dropMenu = new Menu(shell); final IAgent a = (IAgent) (currentValue instanceof IAgent ? currentValue : null); if (a != null) { final IAgentMenuFactory factory = WorkbenchHelper.getService(IAgentMenuFactory.class); - if (factory != null) + if (factory != null) { factory.fillPopulationSubMenu(dropMenu, a.getScope().getSimulation().getMicroPopulation(species), null, action); + } } - final Rectangle rect = items[CHANGE].getBounds(); - final Point pt = items[CHANGE].getParent().toDisplay(new Point(rect.x, rect.y)); + final Rectangle rect = toolbar.getItem(CHANGE).getBounds(); + final Point pt = toolbar.getItem(CHANGE).getParent().toDisplay(new Point(rect.x, rect.y)); dropMenu.setLocation(pt.x, pt.y + rect.height); dropMenu.setVisible(true); @@ -122,7 +120,7 @@ public IType getExpectedType() { /** * Method getToolItems() - * + * * @see ummisco.gama.ui.parameters.AbstractEditor#getToolItems() */ @Override @@ -135,9 +133,7 @@ protected void applyInspect() { if (currentValue instanceof IAgent) { final IAgent a = (IAgent) currentValue; - if (!a.dead()) { - getScope().getGui().setSelectedAgent(a); - } + if (!a.dead()) { getScope().getGui().setSelectedAgent(a); } } } diff --git a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/AssertEditor.java b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/AssertEditor.java index f0d4daee14..80f10b953f 100644 --- a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/AssertEditor.java +++ b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/AssertEditor.java @@ -4,7 +4,6 @@ import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.ToolBar; import msi.gama.runtime.GAMA; import msi.gama.runtime.IScope; @@ -39,25 +38,17 @@ public void widgetSelected(final SelectionEvent e) { return textBox; } - @Override - protected ToolBar createToolbar2() { - return null; - } - private GamaUIColor getColor() { GamaUIColor color = GamaColors.get(getStatement().getColor()); - if (color == null) { - color = IGamaColors.NEUTRAL; - } + if (color == null) { color = IGamaColors.NEUTRAL; } return color; } private String getText() { final AbstractSummary summary = getStatement(); - if (summary instanceof AssertionSummary && getStatement().getState() == TestState.ABORTED) { + if (summary instanceof AssertionSummary && getStatement().getState() == TestState.ABORTED) return getStatement().getState().toString() + ": " + ((AssertionSummary) getStatement()).getError() + " "; - } return getStatement().getState().toString() + " "; } diff --git a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/EditorToolbar.java b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/EditorToolbar.java new file mode 100644 index 0000000000..3db1f9cc73 --- /dev/null +++ b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/EditorToolbar.java @@ -0,0 +1,149 @@ +package ummisco.gama.ui.parameters; + +import static ummisco.gama.ui.resources.GamaIcons.create; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.ToolBar; +import org.eclipse.swt.widgets.ToolItem; + +import ummisco.gama.ui.interfaces.IParameterEditor; +import ummisco.gama.ui.resources.IGamaIcons; + +public class EditorToolbar { + + final AbstractEditor editor; + protected final ToolItem[] items; + + EditorToolbar(final AbstractEditor editor) { + this.editor = editor; + this.items = new ToolItem[9]; + } + + void build(final Composite composite) { + final var t = new ToolBar(composite, SWT.NONE); + final var d = new GridData(SWT.END, SWT.FILL, false, false); + t.setLayoutData(d); + if (editor.isEditable) { + final var codes = editor.getToolItems(); + for (final int i : codes) { + ToolItem item = null; + switch (i) { + case IParameterEditor.REVERT: + item = createItem(t, "Revert to original value", create("small.revert").image()); + break; + case IParameterEditor.PLUS: + item = createItem(t, "Increment " + (editor.stepValue == null ? "" : " by " + editor.stepValue), + create(IGamaIcons.SMALL_PLUS).image()); + break; + case IParameterEditor.MINUS: + item = createItem(t, "Decrement " + (editor.stepValue == null ? "" : " by " + editor.stepValue), + create(IGamaIcons.SMALL_MINUS).image()); + break; + case IParameterEditor.EDIT: + item = createItem(t, "Edit the parameter", create("small.edit").image()); + break; + case IParameterEditor.INSPECT: + item = createItem(t, "Inspect the agent", create("small.inspect").image()); + break; + case IParameterEditor.BROWSE: + item = createItem(t, "Browse the list of agents", create("small.browse").image()); + break; + case IParameterEditor.CHANGE: + item = createItem(t, "Choose another agent", create("small.change").image()); + break; + case IParameterEditor.DEFINE: + item = createItem(t, "Set the parameter to undefined", create("small.undefine").image()); + break; + case IParameterEditor.VALUE: + item = createItem(t, "Value of the parameter", null); + } + if (item != null) { + items[i] = item; + item.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(final SelectionEvent e) { + execute(i, e.detail); + } + + }); + + } + } + Color color = editor.parent.getBackground(); + t.setBackground(color); + for (final Control c : t.getChildren()) { + c.setBackground(color); + } + } + + } + + private ToolItem createItem(final ToolBar t, final String string, final Image image) { + final var i = new ToolItem(t, SWT.FLAT | SWT.PUSH); + i.setToolTipText(string); + i.setImage(image); + return i; + } + + private void execute(final int code, final int detail) { + switch (code) { + case IParameterEditor.REVERT: + editor.modifyAndDisplayValue(editor.applyRevert()); + break; + case IParameterEditor.PLUS: + editor.modifyAndDisplayValue(editor.applyPlus()); + break; + case IParameterEditor.MINUS: + editor.modifyAndDisplayValue(editor.applyMinus()); + break; + case IParameterEditor.EDIT: + editor.applyEdit(); + break; + case IParameterEditor.INSPECT: + editor.applyInspect(); + break; + case IParameterEditor.BROWSE: + editor.applyBrowse(); + break; + case IParameterEditor.CHANGE: + if (detail != SWT.ARROW) return; + editor.applyChange(); + break; + case IParameterEditor.DEFINE: + editor.applyDefine(); + break; + } + } + + protected void update() { + final var revert = items[IParameterEditor.REVERT]; + if (revert == null || revert.isDisposed()) return; + revert.setEnabled(editor.isValueModified()); + } + + public void updateValue(final String s) { + final var value = items[IParameterEditor.VALUE]; + if (value == null || value.isDisposed()) return; + value.setText(s); + } + + public void setActive(final Boolean active) { + for (final ToolItem t : items) { + if (t == null) { continue; } + t.setEnabled(active); + } + } + + public ToolItem getItem(final int item) { + return items[item]; + } + +} diff --git a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/ExpressionControl.java b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/ExpressionControl.java index 166d4ee2ef..5a4d659379 100644 --- a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/ExpressionControl.java +++ b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/ExpressionControl.java @@ -168,7 +168,7 @@ public void modifyValue() { } else { editor.modifyValue(evaluateExpression ? expectedType.cast(scope, value, false, false) : value); } - editor.checkButtons(); + editor.updateToolbar(); } catch (final GamaRuntimeException e) { setCurrentValue(oldValue); diff --git a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/FloatEditor.java b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/FloatEditor.java index 8c1bf6ed29..1833bb4709 100644 --- a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/FloatEditor.java +++ b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/FloatEditor.java @@ -97,14 +97,14 @@ protected Double applyMinus() { } @Override - protected void checkButtons() { - super.checkButtons(); - final ToolItem plus = items[PLUS]; + protected void updateToolbar() { + super.updateToolbar(); + final ToolItem plus = toolbar.getItem(PLUS); if (plus != null && !plus.isDisposed()) { plus.setEnabled(param.isDefined() && (getMaxValue() == null || applyPlus() < Cast.asFloat(getScope(), getMaxValue()))); } - final ToolItem minus = items[MINUS]; + final ToolItem minus = toolbar.getItem(MINUS); if (minus != null && !minus.isDisposed()) { minus.setEnabled(param.isDefined() && (getMinValue() == null || applyMinus() > Cast.asFloat(getScope(), getMinValue()))); diff --git a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/IntEditor.java b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/IntEditor.java index 787a088eba..044d3b924a 100644 --- a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/IntEditor.java +++ b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/IntEditor.java @@ -69,14 +69,14 @@ protected boolean modifyValue(final Object val) throws GamaRuntimeException { } @Override - protected void checkButtons() { - super.checkButtons(); - final ToolItem plus = items[PLUS]; + protected void updateToolbar() { + super.updateToolbar(); + final ToolItem plus = toolbar.getItem(PLUS); if (plus != null && !plus.isDisposed()) { plus.setEnabled( param.isDefined() && (maxValue == null || applyPlus() < Cast.asInt(getScope(), getMaxValue()))); } - final ToolItem minus = items[MINUS]; + final ToolItem minus = toolbar.getItem(MINUS); if (minus != null && !minus.isDisposed()) { minus.setEnabled(param.isDefined() && (getMinValue() == null || applyMinus() > Cast.asInt(getScope(), getMinValue()))); diff --git a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/ListEditor.java b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/ListEditor.java index 921597e629..3544c758a6 100644 --- a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/ListEditor.java +++ b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/ListEditor.java @@ -41,8 +41,9 @@ public void applyEdit() { } @Override - protected void checkButtons() { - final ToolItem edit = items[EDIT]; + protected void updateToolbar() { + super.updateToolbar(); + final ToolItem edit = toolbar.getItem(EDIT); if (edit != null && !edit.isDisposed()) { edit.setEnabled(currentValue instanceof IList); } } diff --git a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/MatrixEditor.java b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/MatrixEditor.java index 823628b25b..e1377e3bf0 100644 --- a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/MatrixEditor.java +++ b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/MatrixEditor.java @@ -38,8 +38,9 @@ public void applyEdit() { } @Override - protected void checkButtons() { - final ToolItem edit = items[EDIT]; + protected void updateToolbar() { + super.updateToolbar(); + final ToolItem edit = toolbar.getItem(EDIT); if (edit != null && !edit.isDisposed()) { edit.setEnabled(true); } } diff --git a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/NumberEditor.java b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/NumberEditor.java index 458c3a4d65..b10e694fbd 100644 --- a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/NumberEditor.java +++ b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/NumberEditor.java @@ -53,9 +53,9 @@ public Control createCustomParameterControl(final Composite composite) throws Ga protected abstract Number normalizeValues() throws GamaRuntimeException; @Override - protected void checkButtons() { - super.checkButtons(); - final ToolItem t = items[DEFINE]; + protected void updateToolbar() { + super.updateToolbar(); + final ToolItem t = toolbar.getItem(DEFINE); if (t == null || t.isDisposed()) return; if (param.isDefined()) { t.setToolTipText("Set the parameter to undefined"); @@ -82,7 +82,7 @@ protected void applyDefine() { expression.modifyValue(); internalModification = false; } - checkButtons(); + updateToolbar(); } @Override diff --git a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/SliderEditor.java b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/SliderEditor.java index 61c38e48b4..cd27e0597f 100644 --- a/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/SliderEditor.java +++ b/ummisco.gama.ui.shared/src/ummisco/gama/ui/parameters/SliderEditor.java @@ -145,6 +145,7 @@ protected Control createCustomParameterControl(final Composite comp) throws Gama } } slider = new SimpleSlider(comp, left, right, thumb, false) {}; + slider.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); if (stepValue != null) { final Double realStep = stepValue.doubleValue() @@ -169,24 +170,14 @@ protected GridData getParameterGridData() { result.heightHint = 24; return result; } - - @Override - public void createComposite(final Composite comp) { - super.createComposite(comp); - final GridData data = new GridData(SWT.FILL, SWT.BOTTOM, false, false); - toolbar.setLayoutData(data); - toolbar.layout(); - } - - @Override - protected Composite createToolbar2() { - final Composite t = super.createToolbar2(); - t.setBackground(getNormalBackground()); - for (final Control c : t.getChildren()) { - c.setBackground(getNormalBackground()); - } - return t; - } + // + // @Override + // public void createComposite(final Composite comp) { + // super.createComposite(comp); + // final GridData data = new GridData(SWT.FILL, SWT.CENTER, false, false); + // toolbar.setLayoutData(data); + // toolbar.layout(); + // } protected abstract T computeValue(final double position); @@ -196,7 +187,7 @@ protected void displayParameterValue() { final double position = (Cast.asFloat(getScope(), p) - Cast.asFloat(getScope(), getMinValue())) / (Cast.asFloat(getScope(), getMaxValue()) - Cast.asFloat(getScope(), getMinValue())); slider.updateSlider(position, false); - items[VALUE].setText(truncateCurrentValue()); + toolbar.updateValue(truncateCurrentValue()); composite.layout(); }