Skip to content
Snippets Groups Projects
Commit 532a4693 authored by Jens Bendisposto's avatar Jens Bendisposto
Browse files

Merge remote-tracking branch 'origin/develop' into feature/newcore

parents 5920737d 2313c826
No related branches found
No related tags found
No related merge requests found
Showing
with 529 additions and 194 deletions
......@@ -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
......
......@@ -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
......@@ -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);
}
......@@ -433,6 +462,10 @@ public abstract class BControl implements IAdaptable, Cloneable {
}
}
public void removeObserver(Observer observer) {
removeObserver(observer.getID());
}
public void removeObserver(String observerID) {
if (hasObserver(observerID))
observers.get(observerID).beforeDelete(this);
......@@ -738,26 +771,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 {
protected void initAttribute(String id, Object defaultValue) {
initAttribute(id, defaultValue, true, true,
AttributeConstants.ATTRIBUTE_MISC);
}
protected void initAttribute(String id, Object defaultValue, String groupID) {
initAttribute(id, defaultValue, true, true, groupID);
}
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;
}
}
protected void initAttribute(AbstractAttribute atr, AbstractAttribute group) {
initAttribute(atr, group.getClass().getName());
if (!atr.isInitialized()) {
atr.setDefaultValue(defaultValue);
atr.setGroup(groupID);
atr.setEditable(editable);
atr.setShow(show);
atr.setInitialized(true);
}
protected void initAttribute(AbstractAttribute atr, String group) {
atr.setGroup(group);
initAttribute(atr);
}
// 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;
}
......
......@@ -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);
}
}
......@@ -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
......
......@@ -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
......
......@@ -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 {
......@@ -17,8 +15,8 @@ public class BTable extends BControl {
super(visualization);
int numberOfColumns = 2;
int numberOfRows = 2;
int numberOfColumns = 1;
int numberOfRows = 1;
CreateCommand cmd;
for (int i = 0; i < numberOfColumns; i++) {
......@@ -43,17 +41,16 @@ public class BTable extends BControl {
@Override
protected void initAttributes() {
initAttribute(new BAttributeForegroundColor(
ColorConstants.black.getRGB()));
initAttribute(new BAttributeColumns(2));
initAttribute(new BAttributeRows(2));
getAttributes().get(AttributeConstants.ATTRIBUTE_SIZE).setShow(false);
getAttributes().get(AttributeConstants.ATTRIBUTE_COORDINATES).setShow(
false);
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
......
......@@ -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(
false);
getAttributes().get(AttributeConstants.ATTRIBUTE_SIZE).setShow(false);
getAttributes().get(AttributeConstants.ATTRIBUTE_COORDINATES).setShow(
false);
initAttribute(AttributeConstants.ATTRIBUTE_TEXT, "");
initAttribute(AttributeConstants.ATTRIBUTE_HEIGHT, 20, false, false,
AttributeConstants.ATTRIBUTE_SIZE);
}
@Override
......
......@@ -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
......
......@@ -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|");
}
}
......@@ -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
......
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package de.bmotionstudio.gef.editor.model;
import java.util.Collection;
import de.bmotionstudio.gef.editor.observer.Observer;
public class ObserverRootVirtualTreeNode {
private Collection<Observer> observer;
private BControl control;
public ObserverRootVirtualTreeNode(BControl control) {
this.observer = control.getObservers().values();
this.control = control;
}
public Collection<Observer> getObserver() {
return observer;
}
public BControl getControl() {
return control;
}
}
package de.bmotionstudio.gef.editor.observer;
import java.util.LinkedList;
import java.util.List;
import de.bmotionstudio.gef.editor.Animation;
import de.bmotionstudio.gef.editor.AttributeConstants;
import de.bmotionstudio.gef.editor.attribute.AbstractAttribute;
import de.bmotionstudio.gef.editor.model.BControl;
import de.bmotionstudio.gef.editor.observer.wizard.WizardColumnObserver;
import de.bmotionstudio.gef.editor.util.BMSUtil;
import de.prob.unicode.UnicodeTranslator;
public class ColumnObserver extends Observer {
private String expression;
private String predicate;
public static List<String> split(String input, char tempReplacement) {
while (input.matches(".*\"[^\\{\\}]+,[^\\{\\}]+.*")) {
input = input.replaceAll("(\"[^\\{\\}]+),([^\\{\\}]+)", "$1"
+ tempReplacement + "$2");
}
while (input.matches(".*\\{[^\\}]+,[^\\}]+\\}.*")) {
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());
}
return output;
}
@Override
public void check(Animation animation, BControl control) {
......@@ -25,24 +46,29 @@ public class ColumnObserver extends Observer {
String fEval = BMSUtil.parseExpression(expression, control,
animation);
fEval = fEval.replace("}", "").replace("{", "");
String[] splitArray = fEval.split(",");
fEval = UnicodeTranslator.toAscii(fEval);
fEval = fEval.replaceAll("^\\{", "");
fEval = fEval.replaceAll("\\}$", "");
List<String> output = split(fEval, '#');
AbstractAttribute attributeRows = control.getParent().getAttribute(
AttributeConstants.ATTRIBUTE_ROWS);
Integer defaultRows = Integer.valueOf(attributeRows
.getInitValue().toString());
Integer defaultRows = Integer.valueOf(attributeRows.getInitValue()
.toString());
control.getParent().setAttributeValue(
AttributeConstants.ATTRIBUTE_ROWS,
defaultRows + splitArray.length, true, false);
defaultRows + output.size(), true, false);
for (int i = defaultRows; i < splitArray.length + defaultRows; i++) {
for (int i = defaultRows; i < output.size() + defaultRows; i++) {
String val = output.get(i - defaultRows);
if (val != null && val.length() > 0)
val = UnicodeTranslator.toUnicode(val);
control.getChildrenArray()
.get(i)
.setAttributeValue(AttributeConstants.ATTRIBUTE_TEXT,
splitArray[i - defaultRows]);
val);
}
}
......
package de.bmotionstudio.gef.editor.observer;
import java.util.LinkedList;
import java.util.List;
import de.bmotionstudio.gef.editor.Animation;
import de.bmotionstudio.gef.editor.AttributeConstants;
import de.bmotionstudio.gef.editor.attribute.AbstractAttribute;
import de.bmotionstudio.gef.editor.model.BControl;
import de.bmotionstudio.gef.editor.observer.wizard.WizardTableObserver;
import de.bmotionstudio.gef.editor.util.BMSUtil;
import de.prob.unicode.UnicodeTranslator;
public class TableObserver extends Observer {
private String expression;
private String predicate;
private boolean overrideCells;
private boolean keepHeader;
public static List<String> split(String input, char tempReplacement) {
while (input.matches(".*\\{[^\\}]+,[^\\}]+\\}.*")) {
input = input.replaceAll("(\\{[^\\}]+),([^\\}]+\\})", "$1"
+ tempReplacement + "$2");
}
List<String> output = new LinkedList<String>();
if (input.length() > 0) {
String[] split = input.split(",");
for (String s : split) {
output.add(s.replaceAll(tempReplacement + "", ",").trim());
}
}
return output;
}
public static List<String> split2(String input, char tempReplacement) {
while (input.matches(".*\\([^\\)]+\\|->[^\\)]+\\).*")) {
input = input.replaceAll("(\\([^\\)]+)\\|->([^\\)]+\\))", "$1"
+ tempReplacement + "$2");
}
List<String> output = new LinkedList<String>();
if (input.length() > 0) {
String[] split = input.split("\\|->");
for (String s : split) {
output.add(s.replaceAll(tempReplacement + "", "\\|->").trim());
}
}
return output;
}
@Override
public void check(Animation animation, BControl control) {
// First evaluate predicate (predicate field)
String bolValue = "true";
if (predicate != null && predicate.length() > 0) {
bolValue = BMSUtil.parsePredicate(predicate, control, animation);
}
if (Boolean.valueOf(bolValue)) {
String fEval = BMSUtil.parseExpression(expression, control,
animation);
fEval = UnicodeTranslator.toAscii(fEval);
fEval = fEval.replaceAll("^\\{", "");
fEval = fEval.replaceAll("\\}$", "");
String input = fEval;
List<String> rows = split(input, '#');
Integer numberOfOldRows = 0;
Integer numberOfOldColumns = 0;
if (!overrideCells) {
AbstractAttribute attributeRows = control
.getAttribute(AttributeConstants.ATTRIBUTE_ROWS);
numberOfOldRows = Integer.valueOf(attributeRows.getInitValue()
.toString());
AbstractAttribute attributeColumns = control
.getAttribute(AttributeConstants.ATTRIBUTE_COLUMNS);
numberOfOldColumns = Integer.valueOf(attributeColumns
.getInitValue().toString());
} else if (keepHeader) {
numberOfOldRows = 1;
}
int numberOfNewRows = rows.size();
// Set the correct number of rows
control.setAttributeValue(AttributeConstants.ATTRIBUTE_ROWS,
numberOfNewRows + numberOfOldRows, true, false);
boolean setColumns = false;
// Set content and the correct number of columns
for (int i = numberOfOldRows; i < numberOfNewRows + numberOfOldRows; i++) {
String content = rows.get(i - numberOfOldRows);
if (content != null && content.length() > 0)
content = UnicodeTranslator.toAscii(content);
content = content.replaceAll("^\\(", "");
content = content.replaceAll("\\)$", "");
List<String> columns = split2(content, '#');
int numberOfNewColumns = columns.size();
// Set only one time the number of columns!
if (!setColumns) {
int ncolumns = numberOfNewColumns;
if (numberOfOldColumns > numberOfNewColumns)
ncolumns = numberOfOldColumns;
control.setAttributeValue(
AttributeConstants.ATTRIBUTE_COLUMNS, ncolumns,
true, false);
setColumns = true;
}
for (int z = 0; z < numberOfNewColumns; z++) {
String val = columns.get(z);
BControl column = control.getChildrenArray().get(z);
BControl cell = column.getChildrenArray().get(i);
if (val != null && val.length() > 0)
val = UnicodeTranslator.toUnicode(val);
cell.setAttributeValue(AttributeConstants.ATTRIBUTE_TEXT,
val);
}
}
}
}
public void setExpression(String expression) {
this.expression = expression;
}
public String getExpression() {
return expression;
}
public String getPredicate() {
return predicate;
}
public void setPredicate(String predicate) {
this.predicate = predicate;
}
@Override
public ObserverWizard getWizard(BControl control) {
return new WizardTableObserver(control, this);
}
public boolean isOverrideCells() {
return overrideCells;
}
public void setOverrideCells(boolean overrideCells) {
this.overrideCells = overrideCells;
}
public boolean isKeepHeader() {
return keepHeader;
}
public void setKeepHeader(boolean keepHeader) {
this.keepHeader = keepHeader;
}
}
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package de.bmotionstudio.gef.editor.observer.wizard;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.PlatformUI;
import de.bmotionstudio.gef.editor.observer.Observer;
public class AbstractObserverWizardPage extends WizardPage {
private Observer observer;
protected AbstractObserverWizardPage(String pageName, Observer observer) {
super(pageName);
this.observer = observer;
}
@Override
public void createControl(Composite parent) {
PlatformUI.getWorkbench().getHelpSystem()
.setHelp(parent, observer.getClass().getName());
}
}
......@@ -21,7 +21,6 @@ import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
......@@ -55,16 +54,19 @@ public class WizardObserverCSwitchCoordinates extends ObserverWizard {
private String lastChangedControlID;
private class ObserverCSwitchCoordinatesPage extends WizardPage {
private class ObserverCSwitchCoordinatesPage extends
AbstractObserverWizardPage {
private TableViewer tableViewer;
protected ObserverCSwitchCoordinatesPage(final String pageName) {
super(pageName);
super(pageName, getObserver());
}
public void createControl(Composite parent) {
super.createControl(parent);
DataBindingContext dbc = new DataBindingContext();
Composite container = new Composite(parent, SWT.NONE);
......
......@@ -30,7 +30,6 @@ import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.FocusEvent;
......@@ -68,16 +67,19 @@ public class WizardObserverListenOperationByPredicate extends ObserverWizard {
private String lastChangedAttributeID;
private class ObserverListenOperationByPredicatePage extends WizardPage {
private class ObserverListenOperationByPredicatePage extends
AbstractObserverWizardPage {
private TableViewer tableViewer;
protected ObserverListenOperationByPredicatePage(final String pageName) {
super(pageName);
super(pageName, getObserver());
}
public void createControl(final Composite parent) {
super.createControl(parent);
DataBindingContext dbc = new DataBindingContext();
Composite container = new Composite(parent, SWT.NONE);
......
......@@ -29,7 +29,6 @@ import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.FocusEvent;
......@@ -68,18 +67,20 @@ public class WizardObserverSetAttribute extends ObserverWizard {
private String lastChangedAttributeID;
private class WizardSetAttributePage extends WizardPage {
private class WizardSetAttributePage extends AbstractObserverWizardPage {
private WritableList input;
private TableViewer tableViewer;
protected WizardSetAttributePage(final String pageName) {
super(pageName);
super(pageName, getObserver());
}
public void createControl(Composite parent) {
super.createControl(parent);
DataBindingContext dbc = new DataBindingContext();
GridLayout gl = new GridLayout(1, true);
......
......@@ -10,7 +10,6 @@ import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
......@@ -29,7 +28,8 @@ import de.bmotionstudio.gef.editor.observer.SimpleValueDisplay;
public class WizardObserverSimpleValueDisplay extends ObserverWizard {
private class ObserverSimpleValueDisplayPage extends WizardPage {
private class ObserverSimpleValueDisplayPage extends
AbstractObserverWizardPage {
private Text txtReplacementString;
private Text txtExpression;
......@@ -40,11 +40,13 @@ public class WizardObserverSimpleValueDisplay extends ObserverWizard {
}
protected ObserverSimpleValueDisplayPage(final String pageName) {
super(pageName);
super(pageName, getObserver());
}
public void createControl(final Composite parent) {
super.createControl(parent);
final DataBindingContext dbc = new DataBindingContext();
Composite container = new Composite(parent, SWT.NONE);
......
......@@ -22,7 +22,6 @@ import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
......@@ -54,16 +53,19 @@ import de.bmotionstudio.gef.editor.util.BMotionWizardUtil;
public class WizardObserverSwitchCoordinates extends ObserverWizard {
private class ObserverToggleCoordinatesPage extends WizardPage {
private class ObserverToggleCoordinatesPage extends
AbstractObserverWizardPage {
private TableViewer tableViewer;
protected ObserverToggleCoordinatesPage(final String pageName) {
super(pageName);
super(pageName, getObserver());
}
public void createControl(Composite parent) {
super.createControl(parent);
DataBindingContext dbc = new DataBindingContext();
Composite container = new Composite(parent, SWT.NONE);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment