diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AbstractAttribute.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AbstractAttribute.java index b34b32c11d12b243abf922fd0f6a8d0c162ace32..b267dcac6b7cfb1b3521e9a7d086dc8e9e8a685f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AbstractAttribute.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/AbstractAttribute.java @@ -36,7 +36,6 @@ public abstract class AbstractAttribute implements IPropertySource, Cloneable { private transient boolean editable; private transient boolean show; private transient String group; - private transient boolean isInitialized; // The current value of the attribute private Object value; @@ -64,7 +63,7 @@ public abstract class AbstractAttribute implements IPropertySource, Cloneable { public PropertyDescriptor getPropertyDescriptor() { propertyDescriptor = new PropertyDescriptor(getID(), getName()); - if (editable) { + if (isEditable()) { propertyDescriptor = preparePropertyDescriptor(); if (propertyDescriptor != null) { propertyDescriptor.setValidator(new ICellEditorValidator() { @@ -210,12 +209,4 @@ public abstract class AbstractAttribute implements IPropertySource, Cloneable { this.defaultValue = defaultValue; } - public boolean isInitialized() { - return isInitialized; - } - - public void setInitialized(boolean isInitialized) { - this.isInitialized = isInitialized; - } - } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TankFigure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TankFigure.java index 90d50c794fd67e15e9bbad4e3cf73da8602c1077..4f266aef27d7c9cdf5304cd6ca843060118c73de 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TankFigure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/TankFigure.java @@ -121,22 +121,27 @@ public class TankFigure extends AbstractBMotionFigure { if (fillColor != null) fillColor.dispose(); fillColor = new Color(Display.getDefault(), rgb); + repaint(); } public void setFillHeight(Integer height) { this.fill_height = height; + repaint(); } public void setMaxPos(Integer maxPos) { this.positions = maxPos; + repaint(); } public void setInterval(Integer interval) { this.show_pos = interval; + repaint(); } public void setMeasure(Boolean bol) { this.showMeasure = bol; + repaint(); } public void setBackgroundColor(RGB rgb) { diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BButton.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BButton.java index 0c472a56bbf10e4978a3a0029fb2d4895fb9b4cd..64dd3ec4e5451d88a678378f2c8f1cab84dc2c77 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BButton.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BButton.java @@ -48,7 +48,7 @@ public class BButton extends BControl { initAttribute(aHeight); BAttributeWidth aWidth = new BAttributeWidth(100); - aHeight.setGroup(BAttributeSize.ID); + aWidth.setGroup(BAttributeSize.ID); initAttribute(aWidth); } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BControl.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BControl.java index 3b18b6d688076b757ca215ac2b44c34e90472e01..e364f3ab867997dd3b775c6934cdddd33899944c 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BControl.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BControl.java @@ -85,6 +85,8 @@ public abstract class BControl implements IAdaptable, Cloneable { private transient PropertyChangeSupport listeners; private transient ArrayList<IObserverListener> observerListener; + + private transient boolean newControl; private BMotionGuide verticalGuide, horizontalGuide; @@ -121,6 +123,7 @@ public abstract class BControl implements IAdaptable, Cloneable { this.observerListener = new ArrayList<IObserverListener>(); this.sourceConnections = new ArrayList<BConnection>(); this.targetConnections = new ArrayList<BConnection>(); + this.newControl = true; init(); } @@ -128,6 +131,7 @@ public abstract class BControl implements IAdaptable, Cloneable { // Populate parent for (BControl child : getChildrenArray()) child.setParent(this); + this.newControl = false; init(); return this; } @@ -181,12 +185,12 @@ public abstract class BControl implements IAdaptable, Cloneable { private void init() { - // Init custom control attributes - initAttributes(); - // Init standard control attributes initStandardAttributes(); + // Init custom control attributes + initAttributes(); + } private void initStandardAttributes() { @@ -222,6 +226,7 @@ public abstract class BControl implements IAdaptable, Cloneable { initAttribute(aY); BAttributeSize aSize = new BAttributeSize(null); + aSize.setGroup(AbstractAttribute.ROOT); initAttribute(aSize); BAttributeWidth aWidth = new BAttributeWidth(100); @@ -787,21 +792,14 @@ public abstract class BControl implements IAdaptable, Cloneable { AbstractAttribute oldAtr = getAttribute(atr.getID()); - // If no attribute exists yet, create a new one and set the value - if (oldAtr == null) { - oldAtr = atr; - getAttributes().put(oldAtr.getID(), oldAtr); + // If a new control is created via the editor (not from the saved file) + // set the saved value of the file + if (oldAtr != null && !newControl) { + atr.setValue(oldAtr.getValue()); + atr.setDefaultValue(oldAtr.getDefaultValue()); } - if (!oldAtr.isInitialized()) { - - oldAtr.setDefaultValue(atr.getDefaultValue()); - oldAtr.setGroup(atr.getGroup()); - oldAtr.setEditable(atr.isEditable()); - oldAtr.setShow(atr.show()); - oldAtr.setInitialized(true); - - } + getAttributes().put(atr.getID(), atr); } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TankPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TankPart.java index c33c6353128136672806f2b3d7d7088553745b15..6dba32eb15b1fe97cafa0e19c17bc34787dacfff 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TankPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TankPart.java @@ -22,34 +22,45 @@ public class TankPart extends BMSAbstractEditPart { @Override protected IFigure createEditFigure() { - IFigure figure = new TankFigure(); - return figure; + return new TankFigure(); } @Override public void refreshEditFigure(IFigure figure, BControl model, PropertyChangeEvent evt) { - ((TankFigure) figure).setAlpha(Integer.valueOf(model - .getAttributeValue(AttributeConstants.ATTRIBUTE_ALPHA) - .toString())); - ((TankFigure) figure).setFillColor((RGB) model - .getAttributeValue(AttributeConstants.ATTRIBUTE_FILL_COLOR)); - ((TankFigure) figure).setFillHeight(Integer.valueOf(model - .getAttributeValue(AttributeConstants.ATTRIBUTE_FILL_HEIGHT) - .toString())); - ((TankFigure) figure).setMaxPos(Integer.valueOf(model - .getAttributeValue(AttributeConstants.ATTRIBUTE_MEASURE_MAXPOS) - .toString())); - ((TankFigure) figure).setInterval(Integer.valueOf(model - .getAttributeValue( - AttributeConstants.ATTRIBUTE_MEASURE_INTERVAL) - .toString())); - ((TankFigure) figure).setMeasure(Boolean.valueOf(model - .getAttributeValue(AttributeConstants.ATTRIBUTE_SHOWS_MEASURE) - .toString())); - ((TankFigure) figure) - .setBackgroundColor((RGB) model - .getAttributeValue(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR)); + + Object value = evt.getNewValue(); + String aID = evt.getPropertyName(); + + if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) + ((TankFigure) figure).setVisible(Boolean.valueOf(value.toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_ALPHA)) + ((TankFigure) figure).setAlpha(Integer.valueOf(value.toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_FILL_COLOR)) + ((TankFigure) figure).setFillColor((RGB) value); + + if (aID.equals(AttributeConstants.ATTRIBUTE_FILL_HEIGHT)) + ((TankFigure) figure).setFillHeight(Integer.valueOf(value + .toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_MEASURE_MAXPOS)) + ((TankFigure) figure).setMaxPos(Integer.valueOf(model + .getAttributeValue( + AttributeConstants.ATTRIBUTE_MEASURE_MAXPOS) + .toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_MEASURE_INTERVAL)) + ((TankFigure) figure) + .setInterval(Integer.valueOf(value.toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_SHOWS_MEASURE)) + ((TankFigure) figure).setMeasure(Boolean.valueOf(value.toString())); + + if (aID.equals(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR)) + ((TankFigure) figure).setBackgroundColor((RGB) value); + } @Override