From 535f9bf374ed83a9e4b6dadda96bb313bf47c58b Mon Sep 17 00:00:00 2001 From: Lukas Ladenberger <lukas.ladenberger@googlemail.com> Date: Thu, 23 Aug 2012 14:31:14 +0200 Subject: [PATCH] attribute handling refactoring --- .../gef/editor/AttributeConstants.java | 1 + .../editor/attribute/AbstractAttribute.java | 42 +++- .../gef/editor/attribute/BAttributeAlpha.java | 4 - .../attribute/BAttributeBackgroundColor.java | 4 - .../BAttributeBackgroundVisible.java | 4 - .../attribute/BAttributeButtonGroup.java | 4 - .../editor/attribute/BAttributeChecked.java | 4 - .../editor/attribute/BAttributeColumns.java | 4 - .../attribute/BAttributeConnection.java | 4 - .../BAttributeConnectionSourceDecoration.java | 4 - .../BAttributeConnectionTargetDecoration.java | 4 - .../attribute/BAttributeCoordinates.java | 4 - .../editor/attribute/BAttributeCustom.java | 4 - .../editor/attribute/BAttributeDirection.java | 4 - .../editor/attribute/BAttributeEnabled.java | 4 - .../attribute/BAttributeFalseValue.java | 4 - .../editor/attribute/BAttributeFillType.java | 4 - .../gef/editor/attribute/BAttributeFont.java | 4 - .../attribute/BAttributeForegroundColor.java | 4 - .../editor/attribute/BAttributeHeight.java | 4 - .../gef/editor/attribute/BAttributeID.java | 4 - .../gef/editor/attribute/BAttributeImage.java | 4 - .../gef/editor/attribute/BAttributeLabel.java | 4 - .../editor/attribute/BAttributeLineStyle.java | 4 - .../editor/attribute/BAttributeLineWidth.java | 4 - .../gef/editor/attribute/BAttributeMain.java | 4 - .../gef/editor/attribute/BAttributeMisc.java | 4 - .../editor/attribute/BAttributeOffsetH.java | 4 - .../editor/attribute/BAttributeOffsetV.java | 4 - .../attribute/BAttributeOrientation.java | 4 - .../attribute/BAttributeOutlineAlpha.java | 4 - .../gef/editor/attribute/BAttributeRows.java | 4 - .../gef/editor/attribute/BAttributeShape.java | 4 - .../gef/editor/attribute/BAttributeSize.java | 4 +- .../gef/editor/attribute/BAttributeText.java | 4 - .../editor/attribute/BAttributeTextColor.java | 4 - .../editor/attribute/BAttributeTrueValue.java | 4 - .../gef/editor/attribute/BAttributeValue.java | 4 - .../editor/attribute/BAttributeVisible.java | 4 - .../gef/editor/attribute/BAttributeWidth.java | 4 - .../gef/editor/attribute/BAttributeX.java | 4 - .../gef/editor/attribute/BAttributeY.java | 4 - .../editpolicy/AppEditLayoutPolicy.java | 19 +- .../internal/BControlPropertySource.java | 3 +- .../gef/editor/model/BButton.java | 17 +- .../gef/editor/model/BCheckbox.java | 22 +- .../gef/editor/model/BComposite.java | 8 +- .../gef/editor/model/BConnection.java | 39 ++-- .../gef/editor/model/BControl.java | 188 ++++++++++++++---- .../gef/editor/model/BImage.java | 4 +- .../gef/editor/model/BRadioButton.java | 22 +- .../gef/editor/model/BShape.java | 30 +-- .../gef/editor/model/BTable.java | 25 +-- .../gef/editor/model/BTableCell.java | 30 +-- .../gef/editor/model/BTableColumn.java | 27 +-- .../bmotionstudio/gef/editor/model/BText.java | 19 +- .../gef/editor/model/BTextfield.java | 6 +- .../gef/editor/observer/TableObserver.java | 23 ++- .../observer/wizard/WizardTableObserver.java | 3 +- .../gef/editor/part/BTablePart.java | 2 + 60 files changed, 309 insertions(+), 381 deletions(-) diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AttributeConstants.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AttributeConstants.java index 56ddf9af..b0283c6b 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AttributeConstants.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AttributeConstants.java @@ -51,6 +51,7 @@ public final class AttributeConstants { public static final String ATTRIBUTE_COORDINATES = "de.bmotionstudio.gef.editor.attribute.BAttributeCoordinates"; public static final String ATTRIBUTE_MISC = "de.bmotionstudio.gef.editor.attribute.BAttributeMisc"; public static final String ATTRIBUTE_MAIN = "de.bmotionstudio.gef.editor.attribute.BAttributeMain"; + public static final String ATTRIBUTE_CONNECTION = "de.bmotionstudio.gef.editor.attribute.BAttributeConnection"; public static final String EVENT_MOUSECLICK = "de.bmotionstudio.gef.editor.event.OnClickEvent"; public static final String EVENT_MOUSEDBLCLICK = "de.bmotionstudio.gef.editor.event.OnDblClickEvent"; 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 0de1ef28..a274533a 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 @@ -31,24 +31,30 @@ public abstract class AbstractAttribute implements IPropertySource, Cloneable { private transient BControl control; private transient PropertyDescriptor propertyDescriptor; private transient Object initValue; + private transient Object defaultValue; 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; - public AbstractAttribute(Object value) { - this(value, true, true); - } - - public AbstractAttribute(Object value, boolean isEditable, - boolean showInPropertiesView) { - this.value = value; - this.initValue = value; - this.editable = isEditable; - this.show = showInPropertiesView; + public AbstractAttribute() { } + // public AbstractAttribute(Object value) { + // this(value, true, true); + // } + // + // public AbstractAttribute(Object value, boolean isEditable, + // boolean showInPropertiesView) { + // this.value = value; + // this.initValue = value; + // this.editable = isEditable; + // this.show = showInPropertiesView; + // } + private Object readResolve() { this.initValue = this.value; return this; @@ -202,4 +208,20 @@ public abstract class AbstractAttribute implements IPropertySource, Cloneable { this.control = control; } + public Object getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(Object defaultValue) { + 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/attribute/BAttributeAlpha.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeAlpha.java index fe192157..41eea7fe 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeAlpha.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeAlpha.java @@ -13,10 +13,6 @@ import de.bmotionstudio.gef.editor.property.SliderPropertyDescriptor; public class BAttributeAlpha extends AbstractAttribute { - public BAttributeAlpha(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { SliderPropertyDescriptor descriptor = new SliderPropertyDescriptor( getID(), getName()); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeBackgroundColor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeBackgroundColor.java index 0023246f..a0fc14f9 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeBackgroundColor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeBackgroundColor.java @@ -14,10 +14,6 @@ import de.bmotionstudio.gef.editor.model.BControl; public class BAttributeBackgroundColor extends AbstractAttribute { - public BAttributeBackgroundColor(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { return new ColorPropertyDescriptor(getID(), getName()); } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeBackgroundVisible.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeBackgroundVisible.java index 05c468b6..32054a9b 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeBackgroundVisible.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeBackgroundVisible.java @@ -13,10 +13,6 @@ import de.bmotionstudio.gef.editor.property.CheckboxPropertyDescriptor; public class BAttributeBackgroundVisible extends AbstractAttribute { - public BAttributeBackgroundVisible(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { return new CheckboxPropertyDescriptor(getID(), getName()); } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeButtonGroup.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeButtonGroup.java index e1518271..aefb1043 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeButtonGroup.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeButtonGroup.java @@ -11,10 +11,6 @@ import org.eclipse.ui.views.properties.TextPropertyDescriptor; public class BAttributeButtonGroup extends AbstractAttribute { - public BAttributeButtonGroup(Object value) { - super(value); - } - @Override protected PropertyDescriptor preparePropertyDescriptor() { return new TextPropertyDescriptor(getID(), getName()); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeChecked.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeChecked.java index d3013220..de45a3af 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeChecked.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeChecked.java @@ -13,10 +13,6 @@ import de.bmotionstudio.gef.editor.property.CheckboxPropertyDescriptor; public class BAttributeChecked extends AbstractAttribute { - public BAttributeChecked(Object value) { - super(value); - } - @Override protected PropertyDescriptor preparePropertyDescriptor() { return new CheckboxPropertyDescriptor(getID(), getName()); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeColumns.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeColumns.java index 12a636d1..0ce92a69 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeColumns.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeColumns.java @@ -13,10 +13,6 @@ import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; public class BAttributeColumns extends AbstractAttribute { - public BAttributeColumns(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( getID(), getName()); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnection.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnection.java index 19428d8b..1e5e4a1f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnection.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnection.java @@ -11,10 +11,6 @@ import org.eclipse.ui.views.properties.PropertyDescriptor; public class BAttributeConnection extends AbstractAttribute { - public BAttributeConnection(Object value) { - super(value); - } - @Override public PropertyDescriptor preparePropertyDescriptor() { PropertyDescriptor descriptor = new PropertyDescriptor(getID(), diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnectionSourceDecoration.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnectionSourceDecoration.java index 89a5c58c..f62678f8 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnectionSourceDecoration.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnectionSourceDecoration.java @@ -14,10 +14,6 @@ public class BAttributeConnectionSourceDecoration extends AbstractAttribute { public static int DECORATION_NONE = 0; public static int DECORATION_TRIANGLE = 1; - public BAttributeConnectionSourceDecoration(Object value) { - super(value); - } - @Override protected PropertyDescriptor preparePropertyDescriptor() { return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnectionTargetDecoration.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnectionTargetDecoration.java index fc9f9353..1e22657d 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnectionTargetDecoration.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeConnectionTargetDecoration.java @@ -14,10 +14,6 @@ public class BAttributeConnectionTargetDecoration extends AbstractAttribute { public static int DECORATION_NONE = 0; public static int DECORATION_TRIANGLE = 1; - public BAttributeConnectionTargetDecoration(Object value) { - super(value); - } - @Override protected PropertyDescriptor preparePropertyDescriptor() { return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeCoordinates.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeCoordinates.java index 2aeb359d..01447dc7 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeCoordinates.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeCoordinates.java @@ -14,10 +14,6 @@ import de.bmotionstudio.gef.editor.AttributeConstants; public class BAttributeCoordinates extends AbstractAttribute { - public BAttributeCoordinates(Object value) { - super(value); - } - @Override public PropertyDescriptor preparePropertyDescriptor() { PropertyDescriptor descriptor = new PropertyDescriptor(getID(), diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeCustom.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeCustom.java index a2ff6fa2..3342762e 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeCustom.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeCustom.java @@ -11,10 +11,6 @@ import org.eclipse.ui.views.properties.TextPropertyDescriptor; public class BAttributeCustom extends AbstractAttribute { - public BAttributeCustom(Object value) { - super(value); - } - @Override public PropertyDescriptor preparePropertyDescriptor() { return new TextPropertyDescriptor(getID(), getName()); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeDirection.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeDirection.java index 899f7012..40f9418e 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeDirection.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeDirection.java @@ -16,10 +16,6 @@ public class BAttributeDirection extends AbstractAttribute { public static final int WEST = 2; public static final int EAST = 3; - public BAttributeDirection(Object value) { - super(value); - } - @Override protected PropertyDescriptor preparePropertyDescriptor() { return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeEnabled.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeEnabled.java index 170e1dfd..c8ae7422 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeEnabled.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeEnabled.java @@ -13,10 +13,6 @@ import de.bmotionstudio.gef.editor.property.CheckboxPropertyDescriptor; public class BAttributeEnabled extends AbstractAttribute { - public BAttributeEnabled(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { return new CheckboxPropertyDescriptor(getID(), getName()); } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFalseValue.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFalseValue.java index 74a13b83..6ea18bb0 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFalseValue.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFalseValue.java @@ -5,10 +5,6 @@ import org.eclipse.ui.views.properties.TextPropertyDescriptor; public class BAttributeFalseValue extends AbstractAttribute { - public BAttributeFalseValue(Object value) { - super(value); - } - @Override public PropertyDescriptor preparePropertyDescriptor() { return new TextPropertyDescriptor(getID(), getName()); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFillType.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFillType.java index 81abe496..bd57f9d8 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFillType.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFillType.java @@ -16,10 +16,6 @@ public class BAttributeFillType extends AbstractAttribute { public static final int SHADED = 2; public static final int GRADIENT = 3; - public BAttributeFillType(Object value) { - super(value); - } - @Override protected PropertyDescriptor preparePropertyDescriptor() { return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFont.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFont.java index 85986759..9c89418c 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFont.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeFont.java @@ -12,10 +12,6 @@ import de.bmotionstudio.gef.editor.property.FontPropertyDescriptor; public class BAttributeFont extends AbstractAttribute { - public BAttributeFont(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { return new FontPropertyDescriptor(getID(), getName()); } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeForegroundColor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeForegroundColor.java index cf4abf23..8a17fe13 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeForegroundColor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeForegroundColor.java @@ -14,10 +14,6 @@ import de.bmotionstudio.gef.editor.model.BControl; public class BAttributeForegroundColor extends AbstractAttribute { - public BAttributeForegroundColor(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { return new ColorPropertyDescriptor(getID(), getName()); } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeHeight.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeHeight.java index 5947e5cd..b0a6191a 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeHeight.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeHeight.java @@ -13,10 +13,6 @@ import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; public class BAttributeHeight extends AbstractAttribute { - public BAttributeHeight(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( getID(), getName()); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeID.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeID.java index b181122c..2af7dadd 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeID.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeID.java @@ -13,10 +13,6 @@ import de.bmotionstudio.gef.editor.model.BControl; public class BAttributeID extends AbstractAttribute { - public BAttributeID(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { TextPropertyDescriptor descriptor = new TextPropertyDescriptor(getID(), getName()); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeImage.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeImage.java index 86f1d299..d3938ae2 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeImage.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeImage.java @@ -16,10 +16,6 @@ import de.bmotionstudio.gef.editor.property.ImagePropertyDescriptor; public class BAttributeImage extends AbstractAttribute { - public BAttributeImage(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { return new ImagePropertyDescriptor(getID(), getName()); } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLabel.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLabel.java index a3f962a2..47b72fb4 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLabel.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLabel.java @@ -11,10 +11,6 @@ import org.eclipse.ui.views.properties.TextPropertyDescriptor; public class BAttributeLabel extends AbstractAttribute { - public BAttributeLabel(Object value) { - super(value); - } - @Override protected PropertyDescriptor preparePropertyDescriptor() { return new TextPropertyDescriptor(getID(), getName()); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLineStyle.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLineStyle.java index 9e0132d7..262e5fd9 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLineStyle.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLineStyle.java @@ -17,10 +17,6 @@ public class BAttributeLineStyle extends AbstractAttribute { public static final int DASHED_DOTTED_CONNECTION = 3; public static final int DASHED_DOTTED_DOTTED_CONNECTION = 4; - public BAttributeLineStyle(Object value) { - super(value); - } - @Override protected PropertyDescriptor preparePropertyDescriptor() { return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLineWidth.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLineWidth.java index b9503fbf..b40020c5 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLineWidth.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeLineWidth.java @@ -7,10 +7,6 @@ import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; public class BAttributeLineWidth extends AbstractAttribute { - public BAttributeLineWidth(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( getID(), getName()); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeMain.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeMain.java index 2870f97b..8429e403 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeMain.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeMain.java @@ -11,10 +11,6 @@ import org.eclipse.ui.views.properties.PropertyDescriptor; public class BAttributeMain extends AbstractAttribute { - public BAttributeMain(Object value) { - super(value); - } - @Override public PropertyDescriptor preparePropertyDescriptor() { PropertyDescriptor descriptor = new PropertyDescriptor(getID(), diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeMisc.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeMisc.java index 658f9e91..c32fa268 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeMisc.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeMisc.java @@ -11,10 +11,6 @@ import org.eclipse.ui.views.properties.PropertyDescriptor; public class BAttributeMisc extends AbstractAttribute { - public BAttributeMisc(Object value) { - super(value); - } - @Override public PropertyDescriptor preparePropertyDescriptor() { PropertyDescriptor descriptor = new PropertyDescriptor(getID(), diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOffsetH.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOffsetH.java index f173bbfb..f91d9446 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOffsetH.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOffsetH.java @@ -13,10 +13,6 @@ import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; public class BAttributeOffsetH extends AbstractAttribute { - public BAttributeOffsetH(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( getID(), getName()); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOffsetV.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOffsetV.java index 9fafedfc..6c8ef25c 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOffsetV.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOffsetV.java @@ -13,10 +13,6 @@ import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; public class BAttributeOffsetV extends AbstractAttribute { - public BAttributeOffsetV(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( getID(), getName()); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOrientation.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOrientation.java index 365995bc..ac0656a5 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOrientation.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOrientation.java @@ -8,10 +8,6 @@ public class BAttributeOrientation extends AbstractAttribute { public static final int HORIZONTAL = 0; public static final int VERTICAL = 1; - public BAttributeOrientation(Object value) { - super(value); - } - @Override protected PropertyDescriptor preparePropertyDescriptor() { return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOutlineAlpha.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOutlineAlpha.java index f583a8f0..218e74de 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOutlineAlpha.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeOutlineAlpha.java @@ -13,10 +13,6 @@ import de.bmotionstudio.gef.editor.property.SliderPropertyDescriptor; public class BAttributeOutlineAlpha extends AbstractAttribute { - public BAttributeOutlineAlpha(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { SliderPropertyDescriptor descriptor = new SliderPropertyDescriptor( getID(), getName()); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeRows.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeRows.java index b3df0f42..dbd8fdd4 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeRows.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeRows.java @@ -13,10 +13,6 @@ import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; public class BAttributeRows extends AbstractAttribute { - public BAttributeRows(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( getID(), getName()); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeShape.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeShape.java index b2200082..48547232 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeShape.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeShape.java @@ -16,10 +16,6 @@ public class BAttributeShape extends AbstractAttribute { public static final int SHAPE_TRIANGLE = 2; public static final int SHAPE_DIAMOND = 3; - public BAttributeShape(Object value) { - super(value); - } - @Override protected PropertyDescriptor preparePropertyDescriptor() { return new ComboBoxPropertyDescriptor(getID(), getName(), new String[] { diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeSize.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeSize.java index 1920190f..6244b248 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeSize.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeSize.java @@ -14,9 +14,7 @@ import de.bmotionstudio.gef.editor.AttributeConstants; public class BAttributeSize extends AbstractAttribute { - public BAttributeSize(Object value) { - super(value); - } + public static final String ID = "de.bmotionstudio.gef.editor.attribute.BAttributeSize"; @Override public PropertyDescriptor preparePropertyDescriptor() { diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeText.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeText.java index 97d07163..b5c18d5c 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeText.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeText.java @@ -11,10 +11,6 @@ import org.eclipse.ui.views.properties.TextPropertyDescriptor; public class BAttributeText extends AbstractAttribute { - public BAttributeText(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { return new TextPropertyDescriptor(getID(), getName()); } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeTextColor.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeTextColor.java index dbba315d..d6e64650 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeTextColor.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeTextColor.java @@ -14,10 +14,6 @@ import de.bmotionstudio.gef.editor.model.BControl; public class BAttributeTextColor extends AbstractAttribute { - public BAttributeTextColor(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { return new ColorPropertyDescriptor(getID(), getName()); } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeTrueValue.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeTrueValue.java index 3d58d1fb..27ef95ab 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeTrueValue.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeTrueValue.java @@ -11,10 +11,6 @@ import org.eclipse.ui.views.properties.TextPropertyDescriptor; public class BAttributeTrueValue extends AbstractAttribute { - public BAttributeTrueValue(Object value) { - super(value); - } - @Override public PropertyDescriptor preparePropertyDescriptor() { return new TextPropertyDescriptor(getID(), getName()); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeValue.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeValue.java index 2b0aaf11..f6f62ad7 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeValue.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeValue.java @@ -11,10 +11,6 @@ import org.eclipse.ui.views.properties.TextPropertyDescriptor; public class BAttributeValue extends AbstractAttribute { - public BAttributeValue(Object value) { - super(value); - } - @Override protected PropertyDescriptor preparePropertyDescriptor() { return new TextPropertyDescriptor(getID(), getName()); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeVisible.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeVisible.java index bbf89608..de3ca30f 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeVisible.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeVisible.java @@ -13,10 +13,6 @@ import de.bmotionstudio.gef.editor.property.CheckboxPropertyDescriptor; public class BAttributeVisible extends AbstractAttribute { - public BAttributeVisible(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { return new CheckboxPropertyDescriptor(getID(), getName()); } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeWidth.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeWidth.java index 34844653..78853723 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeWidth.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeWidth.java @@ -13,10 +13,6 @@ import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; public class BAttributeWidth extends AbstractAttribute { - public BAttributeWidth(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( getID(), getName()); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeX.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeX.java index e3f91139..3494ad60 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeX.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeX.java @@ -13,10 +13,6 @@ import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; public class BAttributeX extends AbstractAttribute { - public BAttributeX(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( getID(), getName()); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeY.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeY.java index 45c5959a..1ac07281 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeY.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/attribute/BAttributeY.java @@ -13,10 +13,6 @@ import de.bmotionstudio.gef.editor.property.IntegerPropertyDescriptor; public class BAttributeY extends AbstractAttribute { - public BAttributeY(Object value) { - super(value); - } - public PropertyDescriptor preparePropertyDescriptor() { IntegerPropertyDescriptor descriptor = new IntegerPropertyDescriptor( getID(), getName()); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/AppEditLayoutPolicy.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/AppEditLayoutPolicy.java index d6303ee0..1c9a3355 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/AppEditLayoutPolicy.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/AppEditLayoutPolicy.java @@ -147,6 +147,7 @@ public class AppEditLayoutPolicy extends XYLayoutEditPolicy { (BControl) getHost().getModel()); Rectangle constraint = (Rectangle) getConstraintFor(request); + constraint.x = (constraint.x < 0) ? 0 : constraint.x; constraint.y = (constraint.y < 0) ? 0 : constraint.y; @@ -157,19 +158,21 @@ public class AppEditLayoutPolicy extends XYLayoutEditPolicy { .getAttributes().get( AttributeConstants.ATTRIBUTE_HEIGHT); - if (atrWidth != null && !atrWidth.isEditable()) { - constraint.width = Integer.valueOf(atrWidth.getValue() - .toString()); + Integer cWidth = Integer.valueOf(atrWidth.getDefaultValue() + .toString()); + if (!atrWidth.isEditable()) { + constraint.width = cWidth; } else { - constraint.width = (constraint.width <= 0) ? 100 + constraint.width = (constraint.width <= 0) ? cWidth : constraint.width; } - if (atrHeight != null && !atrHeight.isEditable()) { - constraint.height = Integer.valueOf(atrHeight.getValue() - .toString()); + Integer cHeight = Integer.valueOf(atrHeight.getDefaultValue() + .toString()); + if (!atrHeight.isEditable()) { + constraint.height = cHeight; } else { - constraint.height = (constraint.height <= 0) ? 100 + constraint.height = (constraint.height <= 0) ? cHeight : constraint.height; } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlPropertySource.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlPropertySource.java index 0dffa83a..625d7521 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlPropertySource.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/internal/BControlPropertySource.java @@ -19,9 +19,8 @@ public class BControlPropertySource extends AbstractAttribute { private BAttributeMisc miscAttribute; public BControlPropertySource(BControl control) { - super(null); this.control = control; - this.miscAttribute = new BAttributeMisc(null); + this.miscAttribute = new BAttributeMisc(); addChild(this.miscAttribute); init(); } 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 4e504fe9..2e9945b3 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 @@ -9,10 +9,6 @@ package de.bmotionstudio.gef.editor.model; import org.eclipse.swt.graphics.RGB; import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeEnabled; -import de.bmotionstudio.gef.editor.attribute.BAttributeText; -import de.bmotionstudio.gef.editor.attribute.BAttributeTextColor; /** * @author Lukas Ladenberger @@ -35,12 +31,13 @@ public class BButton extends BControl { @Override protected void initAttributes() { - initAttribute(new BAttributeText(DEFAULT_TEXT)); - initAttribute(new BAttributeBackgroundColor(new RGB(192, 192, 192))); - initAttribute(new BAttributeTextColor(new RGB(0, 0, 0))); - initAttribute(new BAttributeEnabled(true)); - getAttribute(AttributeConstants.ATTRIBUTE_HEIGHT).setValue(25); - getAttribute(AttributeConstants.ATTRIBUTE_WIDTH).setValue(100); + initAttribute(AttributeConstants.ATTRIBUTE_TEXT, DEFAULT_TEXT); + initAttribute(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR, new RGB( + 192, 192, 192)); + initAttribute(AttributeConstants.ATTRIBUTE_TEXT_COLOR, new RGB(0, 0, 0)); + initAttribute(AttributeConstants.ATTRIBUTE_ENABLED, true); + initAttribute(AttributeConstants.ATTRIBUTE_HEIGHT, 25); + initAttribute(AttributeConstants.ATTRIBUTE_WIDTH, 100); } } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BCheckbox.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BCheckbox.java index 32b02350..39cc02f8 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BCheckbox.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BCheckbox.java @@ -9,12 +9,6 @@ package de.bmotionstudio.gef.editor.model; import org.eclipse.swt.graphics.RGB; import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.attribute.BAttributeChecked; -import de.bmotionstudio.gef.editor.attribute.BAttributeEnabled; -import de.bmotionstudio.gef.editor.attribute.BAttributeFalseValue; -import de.bmotionstudio.gef.editor.attribute.BAttributeText; -import de.bmotionstudio.gef.editor.attribute.BAttributeTextColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeTrueValue; /** * @author Lukas Ladenberger @@ -37,14 +31,14 @@ public class BCheckbox extends BControl { @Override protected void initAttributes() { - initAttribute(new BAttributeText(DEFAULT_TEXT)); - initAttribute(new BAttributeTextColor(new RGB(0, 0, 0))); - initAttribute(new BAttributeChecked(true)); - initAttribute(new BAttributeEnabled(true)); - initAttribute(new BAttributeTrueValue("")); - initAttribute(new BAttributeFalseValue("")); - getAttribute(AttributeConstants.ATTRIBUTE_HEIGHT).setValue(21); - getAttribute(AttributeConstants.ATTRIBUTE_HEIGHT).setEditable(false); + initAttribute(AttributeConstants.ATTRIBUTE_TEXT, DEFAULT_TEXT); + initAttribute(AttributeConstants.ATTRIBUTE_TEXT_COLOR, new RGB(0, 0, 0)); + initAttribute(AttributeConstants.ATTRIBUTE_CHECKED, true); + initAttribute(AttributeConstants.ATTRIBUTE_ENABLED, true); + initAttribute(AttributeConstants.ATTRIBUTE_TRUEVALUE, ""); + initAttribute(AttributeConstants.ATTRIBUTE_FALSEVALUE, ""); + initAttribute(AttributeConstants.ATTRIBUTE_HEIGHT, 21, false, false, + AttributeConstants.ATTRIBUTE_SIZE); } @Override diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BComposite.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BComposite.java index bd27178b..8bfb44d6 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BComposite.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BComposite.java @@ -8,8 +8,7 @@ package de.bmotionstudio.gef.editor.model; import org.eclipse.swt.graphics.RGB; -import de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeImage; +import de.bmotionstudio.gef.editor.AttributeConstants; /** * @author Lukas Ladenberger @@ -30,8 +29,9 @@ public class BComposite extends BControl { @Override protected void initAttributes() { - initAttribute(new BAttributeBackgroundColor(new RGB(192, 192, 192))); - initAttribute(new BAttributeImage(null)); + initAttribute(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR, new RGB( + 192, 192, 192)); + initAttribute(AttributeConstants.ATTRIBUTE_IMAGE, null); } @Override diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BConnection.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BConnection.java index 7bc29f41..048da4cf 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BConnection.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BConnection.java @@ -8,14 +8,10 @@ package de.bmotionstudio.gef.editor.model; import org.eclipse.swt.graphics.RGB; -import de.bmotionstudio.gef.editor.attribute.BAttributeConnection; +import de.bmotionstudio.gef.editor.AttributeConstants; import de.bmotionstudio.gef.editor.attribute.BAttributeConnectionSourceDecoration; import de.bmotionstudio.gef.editor.attribute.BAttributeConnectionTargetDecoration; -import de.bmotionstudio.gef.editor.attribute.BAttributeForegroundColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeLabel; import de.bmotionstudio.gef.editor.attribute.BAttributeLineStyle; -import de.bmotionstudio.gef.editor.attribute.BAttributeLineWidth; -import de.bmotionstudio.gef.editor.internal.BControlPropertySource; public class BConnection extends BControl { @@ -121,21 +117,24 @@ public class BConnection extends BControl { @Override protected void initAttributes() { - BAttributeConnection bAttributeConnection = new BAttributeConnection( - null); - initAttribute(bAttributeConnection, BControlPropertySource.ROOT); - initAttribute(new BAttributeLineWidth(1), bAttributeConnection); - initAttribute(new BAttributeLineStyle( - BAttributeLineStyle.SOLID_CONNECTION), bAttributeConnection); - initAttribute(new BAttributeForegroundColor(new RGB(0, 0, 0)), - bAttributeConnection); - initAttribute(new BAttributeConnectionSourceDecoration( - BAttributeConnectionSourceDecoration.DECORATION_NONE), - bAttributeConnection); - initAttribute(new BAttributeConnectionTargetDecoration( - BAttributeConnectionTargetDecoration.DECORATION_NONE), - bAttributeConnection); - initAttribute(new BAttributeLabel("Label..."), bAttributeConnection); + initAttribute(AttributeConstants.ATTRIBUTE_CONNECTION, null); + initAttribute(AttributeConstants.ATTRIBUTE_LINEWIDTH, 1, + AttributeConstants.ATTRIBUTE_CONNECTION); + initAttribute(AttributeConstants.ATTRIBUTE_LINESTYLE, + BAttributeLineStyle.SOLID_CONNECTION, + AttributeConstants.ATTRIBUTE_CONNECTION); + initAttribute(AttributeConstants.ATTRIBUTE_FOREGROUND_COLOR, new RGB(0, + 0, 0), AttributeConstants.ATTRIBUTE_CONNECTION); + initAttribute( + AttributeConstants.ATTRIBUTE_CONNECTION_SOURCE_DECORATION, + BAttributeConnectionSourceDecoration.DECORATION_NONE, + AttributeConstants.ATTRIBUTE_CONNECTION); + initAttribute( + AttributeConstants.ATTRIBUTE_CONNECTION_TARGET_DECORATION, + BAttributeConnectionTargetDecoration.DECORATION_NONE, + AttributeConstants.ATTRIBUTE_CONNECTION); + initAttribute(AttributeConstants.ATTRIBUTE_LABEL, "Label...", + AttributeConstants.ATTRIBUTE_CONNECTION); } } \ No newline at end of file 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 0af0557d..9ca33e48 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 @@ -29,15 +29,6 @@ import de.bmotionstudio.gef.editor.AttributeConstants; import de.bmotionstudio.gef.editor.BMotionEditorPlugin; import de.bmotionstudio.gef.editor.BMotionStudioImage; import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; -import de.bmotionstudio.gef.editor.attribute.BAttributeCoordinates; -import de.bmotionstudio.gef.editor.attribute.BAttributeCustom; -import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; -import de.bmotionstudio.gef.editor.attribute.BAttributeID; -import de.bmotionstudio.gef.editor.attribute.BAttributeSize; -import de.bmotionstudio.gef.editor.attribute.BAttributeVisible; -import de.bmotionstudio.gef.editor.attribute.BAttributeWidth; -import de.bmotionstudio.gef.editor.attribute.BAttributeX; -import de.bmotionstudio.gef.editor.attribute.BAttributeY; import de.bmotionstudio.gef.editor.internal.BControlPropertySource; import de.bmotionstudio.gef.editor.observer.IObserverListener; import de.bmotionstudio.gef.editor.observer.Observer; @@ -102,6 +93,14 @@ public abstract class BControl implements IAdaptable, Cloneable { /** Property ID to use when the list of incoming connections is modified. */ public static final String TARGET_CONNECTIONS_PROP = "BMS.TargetConn"; + public static final String[] standardAttributes = { + AttributeConstants.ATTRIBUTE_X, + AttributeConstants.ATTRIBUTE_Y, AttributeConstants.ATTRIBUTE_WIDTH, + AttributeConstants.ATTRIBUTE_HEIGHT, + AttributeConstants.ATTRIBUTE_ID, + AttributeConstants.ATTRIBUTE_CUSTOM, + AttributeConstants.ATTRIBUTE_VISIBLE }; + public BControl(Visualization visualization) { this.visualization = visualization; this.children = new BControlList(); @@ -172,7 +171,17 @@ public abstract class BControl implements IAdaptable, Cloneable { private void init() { - // Init ID + // Init custom control attributes + initAttributes(); + + // Init standard control attributes + initStandardAttributes(); + + } + + private void initStandardAttributes() { + + // Init unique ID String ID; if (this instanceof Visualization) ID = "visualization"; @@ -180,25 +189,45 @@ public abstract class BControl implements IAdaptable, Cloneable { ID = UUID.randomUUID().toString(); else ID = (visualization.getMaxIDString(type)); - initAttribute(new BAttributeID(ID), AbstractAttribute.ROOT); - - // Init location and dimension attributes - BAttributeCoordinates coordinatesAtr = new BAttributeCoordinates(null); - initAttribute(coordinatesAtr, AbstractAttribute.ROOT); - initAttribute(new BAttributeX(100), coordinatesAtr); - initAttribute(new BAttributeY(100), coordinatesAtr); - - BAttributeSize sizeAtr = new BAttributeSize(null); - initAttribute(sizeAtr, AbstractAttribute.ROOT); - initAttribute(new BAttributeWidth(100), sizeAtr); - initAttribute(new BAttributeHeight(100), sizeAtr); + initAttribute(AttributeConstants.ATTRIBUTE_ID, ID, + AbstractAttribute.ROOT); + + initAttribute(AttributeConstants.ATTRIBUTE_MISC, "", + AbstractAttribute.ROOT); + + // initAttribute(new BAttributeID(ID), AbstractAttribute.ROOT); + + // Init location and size attributes + initAttribute(AttributeConstants.ATTRIBUTE_COORDINATES, null, + AbstractAttribute.ROOT); + initAttribute(AttributeConstants.ATTRIBUTE_X, 100, + AttributeConstants.ATTRIBUTE_COORDINATES); + initAttribute(AttributeConstants.ATTRIBUTE_Y, 100, + AttributeConstants.ATTRIBUTE_COORDINATES); + + // BAttributeCoordinates coordinatesAtr = new + // BAttributeCoordinates(null); + // initAttribute(coordinatesAtr, AbstractAttribute.ROOT); + // initAttribute(new BAttributeX(100), coordinatesAtr); + // initAttribute(new BAttributeY(100), coordinatesAtr); + + initAttribute(AttributeConstants.ATTRIBUTE_SIZE, null, + AbstractAttribute.ROOT); + initAttribute(AttributeConstants.ATTRIBUTE_WIDTH, 100, + AttributeConstants.ATTRIBUTE_SIZE); + initAttribute(AttributeConstants.ATTRIBUTE_HEIGHT, 100, + AttributeConstants.ATTRIBUTE_SIZE); + + // BAttributeSize sizeAtr = new BAttributeSize(null); + // initAttribute(sizeAtr, AbstractAttribute.ROOT); + // initAttribute(new BAttributeWidth(100), sizeAtr); + // initAttribute(new BAttributeHeight(100), sizeAtr); // Init visible and this attribute - initAttribute(new BAttributeVisible(true), AbstractAttribute.ROOT); - initAttribute(new BAttributeCustom(""), AbstractAttribute.ROOT); - - // Init custom control attributes - initAttributes(); + initAttribute(AttributeConstants.ATTRIBUTE_VISIBLE, true, + AbstractAttribute.ROOT); + initAttribute(AttributeConstants.ATTRIBUTE_CUSTOM, 100, + AbstractAttribute.ROOT); } @@ -738,26 +767,103 @@ public abstract class BControl implements IAdaptable, Cloneable { public abstract String getType(); - protected void initAttribute(AbstractAttribute atr) { - AbstractAttribute matr = getAttributes().get(atr.getID()); - if (matr != null) { - matr.setEditable(atr.isEditable()); - matr.setGroup(atr.getGroup()); - matr.setShow(atr.show()); - } else { - getAttributes().put(atr.getID(), atr); - } + protected void initAttribute(String id, Object defaultValue) { + initAttribute(id, defaultValue, true, true, + AttributeConstants.ATTRIBUTE_MISC); } - protected void initAttribute(AbstractAttribute atr, AbstractAttribute group) { - initAttribute(atr, group.getClass().getName()); + protected void initAttribute(String id, Object defaultValue, String groupID) { + initAttribute(id, defaultValue, true, true, groupID); } - protected void initAttribute(AbstractAttribute atr, String group) { - atr.setGroup(group); - initAttribute(atr); + protected void initAttribute(String id, Object defaultValue, + boolean editable, boolean show) { + initAttribute(id, defaultValue, editable, show, + AttributeConstants.ATTRIBUTE_MISC); } + protected void initAttribute(String id, Object defaultValue, + boolean editable, boolean show, String groupID) { + + AbstractAttribute atr = getAttribute(id); + + // If no attribute exists yet, create a new one and set the value + if (atr == null) { + atr = (AbstractAttribute) reflectiveGet(id); + if (atr != null) { + atr.setValue(defaultValue); + getAttributes().put(atr.getID(), atr); + } else { + return; + } + } + + if (!atr.isInitialized()) { + atr.setDefaultValue(defaultValue); + atr.setGroup(groupID); + atr.setEditable(editable); + atr.setShow(show); + atr.setInitialized(true); + } + + } + + // protected void initAttribute(AbstractAttribute atr) { + // AbstractAttribute matr = getAttributes().get(atr.getID()); + // if (matr != null) { + // matr.setEditable(atr.isEditable()); + // matr.setGroup(atr.getGroup()); + // matr.setShow(atr.show()); + // matr.setDefaultValue(atr.getValue()); + // } else { + // atr.setDefaultValue(atr.getValue()); + // getAttributes().put(atr.getID(), atr); + // } + // } + + private Object reflectiveGet(String className) { + Object newInstance = null; + try { + Class<?> forName = Class.forName(className); + newInstance = forName.newInstance(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + return newInstance; + } + + // protected void initAttribute(AbstractAttribute atr, AbstractAttribute + // group) { + // initAttribute(atr, group.getClass().getName()); + // } + // + // protected void initAttribute(AbstractAttribute atr, String group) { + // atr.setGroup(group); + // initAttribute(atr); + // } + // + // protected void initAttribute(AbstractAttribute atr, boolean editable, + // boolean show) { + // atr.setEditable(editable); + // atr.setShow(show); + // initAttribute(atr); + // } + // + // protected void initAttribute(AbstractAttribute atr, boolean editable) { + // atr.setEditable(editable); + // initAttribute(atr); + // } + // + // protected void initAttribute(AbstractAttribute atr, String group, + // boolean editable) { + // atr.setEditable(editable); + // initAttribute(atr, group); + // } + public boolean canHaveChildren() { return false; } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BImage.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BImage.java index 56bfeb04..4a62e449 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BImage.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BImage.java @@ -6,7 +6,7 @@ package de.bmotionstudio.gef.editor.model; -import de.bmotionstudio.gef.editor.attribute.BAttributeImage; +import de.bmotionstudio.gef.editor.AttributeConstants; /** * @author Lukas Ladenberger @@ -27,7 +27,7 @@ public class BImage extends BControl { @Override protected void initAttributes() { - initAttribute(new BAttributeImage(null)); + initAttribute(AttributeConstants.ATTRIBUTE_IMAGE, null); } } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BRadioButton.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BRadioButton.java index a05d99e1..d4fb6291 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BRadioButton.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BRadioButton.java @@ -12,12 +12,6 @@ import org.eclipse.swt.graphics.RGB; import de.bmotionstudio.gef.editor.AttributeConstants; import de.bmotionstudio.gef.editor.ButtonGroupHelper; -import de.bmotionstudio.gef.editor.attribute.BAttributeButtonGroup; -import de.bmotionstudio.gef.editor.attribute.BAttributeChecked; -import de.bmotionstudio.gef.editor.attribute.BAttributeEnabled; -import de.bmotionstudio.gef.editor.attribute.BAttributeText; -import de.bmotionstudio.gef.editor.attribute.BAttributeTextColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeValue; /** * @author Lukas Ladenberger @@ -45,14 +39,14 @@ public class BRadioButton extends BControl { @Override protected void initAttributes() { - initAttribute(new BAttributeText(DEFAULT_TEXT)); - initAttribute(new BAttributeTextColor(new RGB(0, 0, 0))); - initAttribute(new BAttributeChecked(true)); - initAttribute(new BAttributeValue("")); - initAttribute(new BAttributeButtonGroup("")); - initAttribute(new BAttributeEnabled(true)); - getAttribute(AttributeConstants.ATTRIBUTE_HEIGHT).setValue(21); - getAttribute(AttributeConstants.ATTRIBUTE_HEIGHT).setEditable(false); + initAttribute(AttributeConstants.ATTRIBUTE_TEXT, DEFAULT_TEXT); + initAttribute(AttributeConstants.ATTRIBUTE_TEXT_COLOR, new RGB(0, 0, 0)); + initAttribute(AttributeConstants.ATTRIBUTE_CHECKED, true); + initAttribute(AttributeConstants.ATTRIBUTE_ENABLED, true); + initAttribute(AttributeConstants.ATTRIBUTE_VALUE, ""); + initAttribute(AttributeConstants.ATTRIBUTE_BUTTONGROUP, ""); + initAttribute(AttributeConstants.ATTRIBUTE_HEIGHT, 21, false, false, + AttributeConstants.ATTRIBUTE_SIZE); } @Override diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BShape.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BShape.java index 41acfd9a..91d91228 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BShape.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BShape.java @@ -11,14 +11,9 @@ import org.eclipse.swt.graphics.RGB; import de.bmotionstudio.gef.editor.AttributeConstants; import de.bmotionstudio.gef.editor.BMotionStudioImage; -import de.bmotionstudio.gef.editor.attribute.BAttributeAlpha; -import de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundColor; import de.bmotionstudio.gef.editor.attribute.BAttributeDirection; import de.bmotionstudio.gef.editor.attribute.BAttributeFillType; -import de.bmotionstudio.gef.editor.attribute.BAttributeForegroundColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeImage; import de.bmotionstudio.gef.editor.attribute.BAttributeOrientation; -import de.bmotionstudio.gef.editor.attribute.BAttributeOutlineAlpha; import de.bmotionstudio.gef.editor.attribute.BAttributeShape; /** @@ -45,16 +40,21 @@ public class BShape extends BControl { @Override protected void initAttributes() { - initAttribute(new BAttributeBackgroundColor(new RGB(255, 0, 0))); - initAttribute(new BAttributeForegroundColor(new RGB(0, 0, 0))); - initAttribute(new BAttributeImage(null)); - initAttribute(new BAttributeAlpha(255)); - initAttribute(new BAttributeOutlineAlpha(0)); - initAttribute(new BAttributeShape(BAttributeShape.SHAPE_RECTANGLE)); - initAttribute(new BAttributeOrientation( - BAttributeOrientation.HORIZONTAL)); - initAttribute(new BAttributeDirection(BAttributeDirection.NORTH)); - initAttribute(new BAttributeFillType(BAttributeFillType.FILLED)); + initAttribute(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR, new RGB( + 255, 0, 0)); + initAttribute(AttributeConstants.ATTRIBUTE_FOREGROUND_COLOR, new RGB(0, + 0, 0)); + initAttribute(AttributeConstants.ATTRIBUTE_IMAGE, null); + initAttribute(AttributeConstants.ATTRIBUTE_ALPHA, 255); + initAttribute(AttributeConstants.ATTRIBUTE_OUTLINEALPHA, 0); + initAttribute(AttributeConstants.ATTRIBUTE_SHAPE, + BAttributeShape.SHAPE_RECTANGLE); + initAttribute(AttributeConstants.ATTRIBUTE_ORIENTATION, + BAttributeOrientation.HORIZONTAL); + initAttribute(AttributeConstants.ATTRIBUTE_DIRECTION, + BAttributeDirection.NORTH); + initAttribute(AttributeConstants.ATTRIBUTE_FILLTYPE, + BAttributeFillType.FILLED); } @Override diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTable.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTable.java index 0ff983a2..cf3f7cb1 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTable.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTable.java @@ -4,9 +4,7 @@ import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.geometry.Rectangle; import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.attribute.BAttributeColumns; -import de.bmotionstudio.gef.editor.attribute.BAttributeForegroundColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeRows; +import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; import de.bmotionstudio.gef.editor.command.CreateCommand; public class BTable extends BControl { @@ -43,17 +41,16 @@ public class BTable extends BControl { @Override protected void initAttributes() { - initAttribute(new BAttributeForegroundColor( - ColorConstants.black.getRGB())); - initAttribute(new BAttributeColumns(1)); - initAttribute(new BAttributeRows(1)); - getAttributes().get(AttributeConstants.ATTRIBUTE_SIZE).setShow(false); - getAttributes().get(AttributeConstants.ATTRIBUTE_COORDINATES).setShow( - true); - getAttributes().get(AttributeConstants.ATTRIBUTE_HEIGHT).setEditable( - false); - getAttributes().get(AttributeConstants.ATTRIBUTE_WIDTH).setEditable( - false); + initAttribute(AttributeConstants.ATTRIBUTE_SIZE, null, false, false, + AbstractAttribute.ROOT); + initAttribute(AttributeConstants.ATTRIBUTE_WIDTH, 0, false, false, + AttributeConstants.ATTRIBUTE_SIZE); + initAttribute(AttributeConstants.ATTRIBUTE_HEIGHT, 0, false, false, + AttributeConstants.ATTRIBUTE_SIZE); + initAttribute(AttributeConstants.ATTRIBUTE_FOREGROUND_COLOR, + ColorConstants.black.getRGB()); + initAttribute(AttributeConstants.ATTRIBUTE_COLUMNS, 1); + initAttribute(AttributeConstants.ATTRIBUTE_ROWS, 1); } @Override diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTableCell.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTableCell.java index 8ee5ec9f..3a37da71 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTableCell.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTableCell.java @@ -3,10 +3,6 @@ package de.bmotionstudio.gef.editor.model; import org.eclipse.draw2d.ColorConstants; import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeForegroundColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeText; -import de.bmotionstudio.gef.editor.attribute.BAttributeTextColor; public class BTableCell extends BControl { @@ -18,25 +14,15 @@ public class BTableCell extends BControl { @Override protected void initAttributes() { - - initAttribute(new BAttributeBackgroundColor( - ColorConstants.white.getRGB())); - BAttributeForegroundColor bAttributeForegroundColor = new BAttributeForegroundColor( + initAttribute(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR, + ColorConstants.white.getRGB()); + initAttribute(AttributeConstants.ATTRIBUTE_FOREGROUND_COLOR, + ColorConstants.black.getRGB(), true, false); + initAttribute(AttributeConstants.ATTRIBUTE_TEXT_COLOR, ColorConstants.black.getRGB()); - bAttributeForegroundColor.setShow(false); - initAttribute(bAttributeForegroundColor); - initAttribute(new BAttributeTextColor(ColorConstants.black.getRGB())); - initAttribute(new BAttributeText("")); - setAttributeValue(AttributeConstants.ATTRIBUTE_HEIGHT, 20); - setAttributeValue(AttributeConstants.ATTRIBUTE_WIDTH, 50); - getAttributes().get(AttributeConstants.ATTRIBUTE_HEIGHT).setEditable( - false); - getAttributes().get(AttributeConstants.ATTRIBUTE_WIDTH).setEditable( - true); - getAttributes().get(AttributeConstants.ATTRIBUTE_HEIGHT).setShow(false); - getAttributes().get(AttributeConstants.ATTRIBUTE_COORDINATES).setShow( - false); - + initAttribute(AttributeConstants.ATTRIBUTE_TEXT, ""); + initAttribute(AttributeConstants.ATTRIBUTE_HEIGHT, 20, false, false, + AttributeConstants.ATTRIBUTE_SIZE); } @Override diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTableColumn.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTableColumn.java index fc64b9ed..6c4bb368 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTableColumn.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTableColumn.java @@ -3,7 +3,6 @@ package de.bmotionstudio.gef.editor.model; import org.eclipse.draw2d.ColorConstants; import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.attribute.BAttributeForegroundColor; public class BTableColumn extends BControl { @@ -15,28 +14,10 @@ public class BTableColumn extends BControl { @Override protected void initAttributes() { - - // initAttribute(new BAttributeBackgroundColor( - // ColorConstants.white.getRGB())); - BAttributeForegroundColor bAttributeForegroundColor = new BAttributeForegroundColor( - ColorConstants.black.getRGB()); - bAttributeForegroundColor.setShow(false); - initAttribute(bAttributeForegroundColor); - // initAttribute(new - // BAttributeTextColor(ColorConstants.black.getRGB())); - getAttributes().get(AttributeConstants.ATTRIBUTE_HEIGHT).setEditable( - false); - getAttributes().get(AttributeConstants.ATTRIBUTE_HEIGHT).setShow(false); - getAttributes().get(AttributeConstants.ATTRIBUTE_COORDINATES).setShow( - false); - - // Background Color - // Font - // Foreground Color - - // Width - // Height (not editable) --> determined by number of cells - + initAttribute(AttributeConstants.ATTRIBUTE_FOREGROUND_COLOR, + ColorConstants.black.getRGB(), true, false); + initAttribute(AttributeConstants.ATTRIBUTE_HEIGHT, 0, false, false, + AttributeConstants.ATTRIBUTE_SIZE); } @Override diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BText.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BText.java index 0e713693..c74bfa38 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BText.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BText.java @@ -8,11 +8,7 @@ package de.bmotionstudio.gef.editor.model; import org.eclipse.swt.graphics.RGB; -import de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundColor; -import de.bmotionstudio.gef.editor.attribute.BAttributeBackgroundVisible; -import de.bmotionstudio.gef.editor.attribute.BAttributeFont; -import de.bmotionstudio.gef.editor.attribute.BAttributeText; -import de.bmotionstudio.gef.editor.attribute.BAttributeTextColor; +import de.bmotionstudio.gef.editor.AttributeConstants; /** * @author Lukas Ladenberger @@ -35,12 +31,13 @@ public class BText extends BControl { @Override protected void initAttributes() { - initAttribute(new BAttributeText(DEFAULT_TEXT)); - initAttribute(new BAttributeBackgroundColor(new RGB(255, 255, 255))); - initAttribute(new BAttributeTextColor(new RGB(0, 0, 0))); - initAttribute(new BAttributeBackgroundVisible(true)); - initAttribute(new BAttributeFont( - "1||9.75|0|WINDOWS|1|-13|0|0|0|400|0|0|0|0|0|0|0|0|")); + initAttribute(AttributeConstants.ATTRIBUTE_TEXT, DEFAULT_TEXT); + initAttribute(AttributeConstants.ATTRIBUTE_BACKGROUND_COLOR, new RGB( + 255, 255, 255)); + initAttribute(AttributeConstants.ATTRIBUTE_TEXT_COLOR, DEFAULT_TEXT); + initAttribute(AttributeConstants.ATTRIBUTE_BACKGROUND_VISIBLE, true); + initAttribute(AttributeConstants.ATTRIBUTE_FONT, + "1||9.75|0|WINDOWS|1|-13|0|0|0|400|0|0|0|0|0|0|0|0|"); } } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTextfield.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTextfield.java index e0d323c5..d832ef10 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTextfield.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/BTextfield.java @@ -7,7 +7,6 @@ package de.bmotionstudio.gef.editor.model; import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.attribute.BAttributeText; /** * @author Lukas Ladenberger @@ -30,8 +29,9 @@ public class BTextfield extends BControl { @Override protected void initAttributes() { - initAttribute(new BAttributeText(DEFAULT_TEXT)); - getAttribute(AttributeConstants.ATTRIBUTE_HEIGHT).setValue(21); + initAttribute(AttributeConstants.ATTRIBUTE_TEXT, DEFAULT_TEXT); + initAttribute(AttributeConstants.ATTRIBUTE_HEIGHT, 21, + AttributeConstants.ATTRIBUTE_SIZE); } @Override diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/TableObserver.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/TableObserver.java index c872dec8..9ad72ca8 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/TableObserver.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/TableObserver.java @@ -23,10 +23,12 @@ public class TableObserver extends Observer { input = input.replaceAll("(\\{[^\\}]+),([^\\}]+\\})", "$1" + tempReplacement + "$2"); } - String[] split = input.split(","); List<String> output = new LinkedList<String>(); - for (String s : split) { - output.add(s.replaceAll(tempReplacement + "", ",").trim()); + if (input.length() > 0) { + String[] split = input.split(","); + for (String s : split) { + output.add(s.replaceAll(tempReplacement + "", ",").trim()); + } } return output; } @@ -36,10 +38,12 @@ public class TableObserver extends Observer { input = input.replaceAll("(\\([^\\)]+)\\|->([^\\)]+\\))", "$1" + tempReplacement + "$2"); } - String[] split = input.split("\\|->"); List<String> output = new LinkedList<String>(); - for (String s : split) { - output.add(s.replaceAll(tempReplacement + "", "\\|->").trim()); + if (input.length() > 0) { + String[] split = input.split("\\|->"); + for (String s : split) { + output.add(s.replaceAll(tempReplacement + "", "\\|->").trim()); + } } return output; } @@ -58,6 +62,7 @@ public class TableObserver extends Observer { String fEval = BMSUtil.parseExpression(expression, control, animation); + fEval = UnicodeTranslator.toAscii(fEval); fEval = fEval.replaceAll("^\\{", ""); fEval = fEval.replaceAll("\\}$", ""); @@ -92,8 +97,10 @@ public class TableObserver extends Observer { // Set content and the correct number of columns for (int i = numberOfOldRows; i < numberOfNewRows + numberOfOldRows; i++) { - String content = UnicodeTranslator.toAscii(rows.get(i - - numberOfOldRows)); + String content = rows.get(i - numberOfOldRows); + + if (content != null && content.length() > 0) + content = UnicodeTranslator.toAscii(content); content = content.replaceAll("^\\(", ""); content = content.replaceAll("\\)$", ""); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardTableObserver.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardTableObserver.java index a2782d2a..e816e1d3 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardTableObserver.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardTableObserver.java @@ -131,7 +131,8 @@ public class WizardTableObserver extends ObserverWizard { } } - final List list = new List(conRight, SWT.SINGLE | SWT.BORDER); + final List list = new List(conRight, SWT.SINGLE | SWT.BORDER + | SWT.V_SCROLL); list.setLayoutData(new GridData(GridData.FILL_BOTH)); list.setItems(relationList.toArray(new String[relationList.size()])); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTablePart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTablePart.java index ce86dc2c..5d7d2be8 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTablePart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BTablePart.java @@ -138,6 +138,8 @@ public class BTablePart extends AppAbstractEditPart { private void refreshRows(BControl column, int numberOfRows) { + System.out.println(numberOfRows); + Integer numberOfCurrentRows = column.getChildrenArray().size(); if (numberOfRows < numberOfCurrentRows) { -- GitLab