diff --git a/de.bmotionstudio.gef.editor/plugin.xml b/de.bmotionstudio.gef.editor/plugin.xml index 07bd7797aed6059c533439e5d67be458ab8235ff..3fbc75d6831e88d07320f34784eabfb2dc0965e4 100644 --- a/de.bmotionstudio.gef.editor/plugin.xml +++ b/de.bmotionstudio.gef.editor/plugin.xml @@ -216,9 +216,16 @@ <control groupid="de.bmotionstudio.gef.editor.group.main" icon="icons/icon_rectangle.gif" - id="de.bmotionstudio.gef.editor.shape" - name="Shape" - service="de.bmotionstudio.gef.editor.service.BShapeService"> + id="de.bmotionstudio.gef.editor.rectangle" + name="Rectanlge" + service="de.bmotionstudio.gef.editor.service.BRectangleService"> + </control> + <control + groupid="de.bmotionstudio.gef.editor.group.main" + icon="icons/icon_ellipse.gif" + id="de.bmotionstudio.gef.editor.ellipse" + name="Ellipse" + service="de.bmotionstudio.gef.editor.service.BEllipseService"> </control> <control groupid="de.bmotionstudio.gef.editor.group.main" @@ -275,7 +282,7 @@ class="de.bmotionstudio.gef.editor.scheduler.ExecuteAnimationScript" description="Execute an animation script" menu="true" - name="Execute Scheduler (Multi)"> + name="Execute Scheduler"> </schedulerEvent> <schedulerEvent class="de.bmotionstudio.gef.editor.scheduler.ExecuteOperationByPredicateMulti" @@ -331,7 +338,7 @@ id="de.bmotionstudio.gef.editor.ellipse"> </control> <control - id="de.bmotionstudio.gef.editor.shape"> + id="de.bmotionstudio.gef.editor.rectangle"> </control> <control id="de.bmotionstudio.gef.editor.radiobutton"> @@ -343,15 +350,6 @@ id="de.bmotionstudio.gef.editor.connection"> </control> </observer> - <observer - id="de.bmotionstudio.gef.editor.observer.CloneObserver"> - <control - id="de.bmotionstudio.gef.editor.composite"> - </control> - <control - id="de.bmotionstudio.gef.editor.visualization"> - </control> - </observer> <observer id="de.bmotionstudio.gef.editor.observer.SwitchCoordinates"> <control @@ -367,7 +365,7 @@ id="de.bmotionstudio.gef.editor.text"> </control> <control - id="de.bmotionstudio.gef.editor.shape"> + id="de.bmotionstudio.gef.editor.rectangle"> </control> <control id="de.bmotionstudio.gef.editor.radiobutton"> @@ -394,15 +392,6 @@ id="de.bmotionstudio.gef.editor.button"> </control> </observer> - <observer - id="de.bmotionstudio.gef.editor.observer.SwitchImage"> - <control - id="de.bmotionstudio.gef.editor.image"> - </control> - <control - id="de.bmotionstudio.gef.editor.composite"> - </control> - </observer> <observer id="de.bmotionstudio.gef.editor.observer.SetAttribute"> <control @@ -418,7 +407,7 @@ id="de.bmotionstudio.gef.editor.text"> </control> <control - id="de.bmotionstudio.gef.editor.shape"> + id="de.bmotionstudio.gef.editor.rectangle"> </control> <control id="de.bmotionstudio.gef.editor.radiobutton"> @@ -454,7 +443,7 @@ id="de.bmotionstudio.gef.editor.text"> </control> <control - id="de.bmotionstudio.gef.editor.shape"> + id="de.bmotionstudio.gef.editor.rectangle"> </control> <control id="de.bmotionstudio.gef.editor.radiobutton"> @@ -466,6 +455,21 @@ id="de.bmotionstudio.gef.editor.connection"> </control> </observer> + <observer + id="de.bmotionstudio.gef.editor.observer.SwitchImage"> + <control + id="de.bmotionstudio.gef.editor.image"> + </control> + <control + id="de.bmotionstudio.gef.editor.composite"> + </control> + <control + id="de.bmotionstudio.gef.editor.rectangle"> + </control> + <control + id="de.bmotionstudio.gef.editor.ellipse"> + </control> + </observer> </include> </extension> </plugin> diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AbstractBControlService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AbstractBControlService.java index 5eacc4c6d570539eb13aafaaa034ea4a9924e101..f0a5f6c8febb8efdc0da4eb6b840e2d4792b7c50 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AbstractBControlService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/AbstractBControlService.java @@ -27,9 +27,9 @@ public abstract class AbstractBControlService { String type = configurationElement.getAttribute("id"); // Get the source plug-in (from the control extension) String sourcePluginID = configurationElement.getContributor().getName(); - return new CombinedTemplateCreationEntry(name, - "Create Control " + name, new BControlTemplate(type), - new BControlCreationFactory(type, visualization), + return new CombinedTemplateCreationEntry(name, "Create " + name, + new BControlTemplate(type), new BControlCreationFactory(type, + visualization), AbstractUIPlugin .imageDescriptorFromPlugin(sourcePluginID, icon), AbstractUIPlugin diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/Animation.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/Animation.java index a109c4607913a05e6d4fe78fc30c85aef14dc384..736d82ce4494168f138ef4a9d5975d56b4a8084e 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/Animation.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/Animation.java @@ -90,7 +90,7 @@ public class Animation implements IAnimationListener { } } - public void collectAllBControls(List<BControl> allBControls, + private void collectAllBControls(List<BControl> allBControls, BControl control) { if (control.getChildrenArray().isEmpty()) diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioEditorPage.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioEditorPage.java index 42bd71995f9fb48c2e2577ce96b83326065e1b6e..6fb06c9db4e6fee602bb85500ddfb0720370fbfb 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioEditorPage.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/BMotionStudioEditorPage.java @@ -6,6 +6,8 @@ package de.bmotionstudio.gef.editor; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -42,6 +44,7 @@ import org.eclipse.gef.SnapToGrid; import org.eclipse.gef.commands.CommandStack; import org.eclipse.gef.commands.CommandStackListener; import org.eclipse.gef.dnd.TemplateTransferDragSourceListener; +import org.eclipse.gef.editparts.GridLayer; import org.eclipse.gef.editparts.ScalableRootEditPart; import org.eclipse.gef.editparts.ZoomManager; import org.eclipse.gef.palette.PaletteRoot; @@ -71,6 +74,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; @@ -93,8 +97,8 @@ import com.thoughtworks.xstream.XStream; import de.bmotionstudio.gef.editor.action.CopyAction; import de.bmotionstudio.gef.editor.action.OpenObserverAction; -import de.bmotionstudio.gef.editor.action.PasteAction; import de.bmotionstudio.gef.editor.action.OpenSchedulerEventAction; +import de.bmotionstudio.gef.editor.action.PasteAction; import de.bmotionstudio.gef.editor.internal.BControlTransferDropTargetListener; import de.bmotionstudio.gef.editor.library.AttributeTransferDropTargetListener; import de.bmotionstudio.gef.editor.model.BMotionRuler; @@ -121,9 +125,24 @@ public class BMotionStudioEditorPage extends GraphicalEditorWithFlyoutPalette { private BMotionSelectionSynchronizer bmotionSelectionSynchronizer; + private Color gridColor = new Color(null, 240, 240, 240); + /** Palette component, holding the tools and b-controls. */ private PaletteRoot palette; + private PropertyChangeListener viewerListener = new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent event) { + String propertyName = event.getPropertyName(); + if (propertyName.equals(SnapToGrid.PROPERTY_GRID_VISIBLE) + || propertyName.equals(SnapToGrid.PROPERTY_GRID_ENABLED)) { + setDirty(true); + } + } + + }; + public BMotionStudioEditorPage(Visualization visualization, BMotionStudioEditor bmotionStudioEditor) { this.visualization = visualization; @@ -235,6 +254,10 @@ public class BMotionStudioEditorPage extends GraphicalEditorWithFlyoutPalette { public void dispose() { // remove CommandStackListener getCommandStack().removeCommandStackListener(getCommandStackListener()); + + // remove PropertyChangeListener from graphical viewer + getGraphicalViewer().removePropertyChangeListener(viewerListener); + // important: always call super implementation of dispose super.dispose(); } @@ -475,6 +498,9 @@ public class BMotionStudioEditorPage extends GraphicalEditorWithFlyoutPalette { viewer.setEditPartFactory(new AppEditPartFactory()); ScalableRootEditPart rootEditPart = new ScalableRootEditPart(); + GridLayer gridLayer = (GridLayer) rootEditPart + .getLayer(ScalableRootEditPart.GRID_LAYER); + gridLayer.setForegroundColor(gridColor); viewer.setRootEditPart(rootEditPart); ZoomManager manager = rootEditPart.getZoomManager(); @@ -510,6 +536,8 @@ public class BMotionStudioEditorPage extends GraphicalEditorWithFlyoutPalette { ContextMenuProvider provider = new AppContextMenuProvider(viewer, getActionRegistry()); viewer.setContextMenu(provider); + + viewer.addPropertyChangeListener(viewerListener); } @@ -756,6 +784,7 @@ public class BMotionStudioEditorPage extends GraphicalEditorWithFlyoutPalette { public void dispose() { unhookOutlineViewer(); + gridColor.dispose(); super.dispose(); } 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 af18c06a0b60a1dfce1c2a76944e42cf6701466f..adbacbd3e26882d6e7fe7085f04fae428e96f784 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 @@ -29,19 +29,24 @@ public abstract class AbstractAttribute implements IPropertySource, Cloneable { private transient HashMap<String, AbstractAttribute> children; private transient BControl control; - private String group; - private boolean editable; - private boolean show; - private Object value; - private transient PropertyDescriptor propertyDescriptor; private transient Object initValue; + private transient boolean editable; + private transient boolean show; + private transient String group; + + 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 = true; - this.show = true; + this.editable = isEditable; + this.show = showInPropertiesView; } private Object readResolve() { diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/ShapeFigure.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/ShapeFigure.java index beb832c773d4bd6903080049af74f4c51dff4645..6d647b3b55834a52d4ab578cbab7fe4cdd4bf469 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/ShapeFigure.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/figure/ShapeFigure.java @@ -6,7 +6,6 @@ package de.bmotionstudio.gef.editor.figure; -import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.Figure; import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.IFigure; @@ -150,7 +149,9 @@ public class ShapeFigure extends AbstractBMotionFigure { g.fillRectangle(this.getBounds()); break; case SHAPE_TYPE_OVAL: - g.fillOval(this.getBounds()); + g.fillOval(this.getBounds().x, this.getBounds().y, + this.getBounds().width - 3, + this.getBounds().height - 3); break; case SHAPE_TYPE_TRIANGLE: g.fillPolygon(triangle); @@ -172,6 +173,7 @@ public class ShapeFigure extends AbstractBMotionFigure { g.setForegroundColor(this.getForegroundColor()); float lineInset = Math.max(1.0f, getLineWidthFloat()) / 2.0f; + int inset1 = (int) Math.floor(lineInset); int inset2 = (int) Math.ceil(lineInset); @@ -186,6 +188,8 @@ public class ShapeFigure extends AbstractBMotionFigure { g.drawRectangle(r); break; case SHAPE_TYPE_OVAL: + r.width -= 2; + r.height -= 2; g.drawOval(r); break; case SHAPE_TYPE_TRIANGLE: @@ -201,7 +205,7 @@ public class ShapeFigure extends AbstractBMotionFigure { } }; - shapeFigure.setForegroundColor(ColorConstants.blue); + // shapeFigure.setForegroundColor(ColorConstants.blue); // setOpaque(true); add(shapeFigure); } 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 ee137bd0948a34c01e7235d085ecab7b8e3dcce4..45668cb3ee28a5360e114ad5fc944d3c2b059541 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 @@ -22,11 +22,13 @@ import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.swt.graphics.Image; import org.eclipse.ui.views.properties.IPropertySource; import de.bmotionstudio.gef.editor.Animation; import de.bmotionstudio.gef.editor.AttributeConstants; import de.bmotionstudio.gef.editor.BMotionEditorPlugin; +import de.bmotionstudio.gef.editor.BMotionStudioImage; import de.bmotionstudio.gef.editor.IBControlService; import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; import de.bmotionstudio.gef.editor.attribute.BAttributeCoordinates; @@ -119,6 +121,7 @@ public abstract class BControl implements IAdaptable, Cloneable { // Populate parent for (BControl child : getChildrenArray()) child.setParent(this); + init(); return this; } @@ -278,14 +281,22 @@ public abstract class BControl implements IAdaptable, Cloneable { } public Rectangle getLayout() { - int width = Integer.valueOf(getAttributeValue( - AttributeConstants.ATTRIBUTE_WIDTH).toString()); - int height = Integer.valueOf(getAttributeValue( - AttributeConstants.ATTRIBUTE_HEIGHT).toString()); - int x = Integer.valueOf(getAttributeValue( - AttributeConstants.ATTRIBUTE_X).toString()); - int y = Integer.valueOf(getAttributeValue( - AttributeConstants.ATTRIBUTE_Y).toString()); + + String widthStr = getAttributeValue(AttributeConstants.ATTRIBUTE_WIDTH) + .toString(); + String heightStr = getAttributeValue( + AttributeConstants.ATTRIBUTE_HEIGHT).toString(); + String xStr = getAttributeValue(AttributeConstants.ATTRIBUTE_X) + .toString(); + String yStr = getAttributeValue(AttributeConstants.ATTRIBUTE_Y) + .toString(); + + // TODO: check if strings are a correct integers + + int width = Integer.valueOf(widthStr); + int height = Integer.valueOf(heightStr); + int x = Integer.valueOf(xStr); + int y = Integer.valueOf(yStr); if (layout == null) { layout = new Rectangle(x, y, width, height); } else { @@ -295,6 +306,7 @@ public abstract class BControl implements IAdaptable, Cloneable { layout.height = height; } return layout; + } public void setLocation(Point newLocation) { @@ -716,7 +728,14 @@ public abstract class BControl implements IAdaptable, Cloneable { public abstract String getType(); protected void initAttribute(AbstractAttribute atr) { - getAttributes().put(atr.getID(), 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(AbstractAttribute atr, AbstractAttribute group) { @@ -737,4 +756,8 @@ public abstract class BControl implements IAdaptable, Cloneable { .toString(); } + public Image getIcon() { + return BMotionStudioImage.getBControlImage(getType()); + } + } 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 66ac95f8112f3c36d1cd99bf05c8f2df5f760b7c..41acfd9a9e617e68f29573b442f1dc28934534ea 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 @@ -6,8 +6,11 @@ package de.bmotionstudio.gef.editor.model; +import org.eclipse.swt.graphics.Image; 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; @@ -24,7 +27,8 @@ import de.bmotionstudio.gef.editor.attribute.BAttributeShape; */ public class BShape extends BControl { - public static transient String TYPE = "de.bmotionstudio.gef.editor.shape"; + public static transient String TYPE_RECTANGLE = "de.bmotionstudio.gef.editor.rectangle"; + public static transient String TYPE_OVAL = "de.bmotionstudio.gef.editor.ellipse"; public BShape(Visualization visualization) { super(visualization); @@ -32,7 +36,11 @@ public class BShape extends BControl { @Override public String getType() { - return TYPE; + if (getAttributeValue(AttributeConstants.ATTRIBUTE_SHAPE).equals( + BAttributeShape.SHAPE_OVAL)) + return TYPE_OVAL; + else + return TYPE_RECTANGLE; } @Override @@ -41,7 +49,7 @@ public class BShape extends BControl { initAttribute(new BAttributeForegroundColor(new RGB(0, 0, 0))); initAttribute(new BAttributeImage(null)); initAttribute(new BAttributeAlpha(255)); - initAttribute(new BAttributeOutlineAlpha(255)); + initAttribute(new BAttributeOutlineAlpha(0)); initAttribute(new BAttributeShape(BAttributeShape.SHAPE_RECTANGLE)); initAttribute(new BAttributeOrientation( BAttributeOrientation.HORIZONTAL)); @@ -49,4 +57,13 @@ public class BShape extends BControl { initAttribute(new BAttributeFillType(BAttributeFillType.FILLED)); } + @Override + public Image getIcon() { + if (getAttributeValue(AttributeConstants.ATTRIBUTE_SHAPE).equals( + BAttributeShape.SHAPE_OVAL)) + return BMotionStudioImage.getBControlImage(TYPE_OVAL); + else + return super.getIcon(); + } + } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ObserverCloneObject.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ObserverCloneObject.java deleted file mode 100644 index 480e1686b521fdba41307d7d1b1fcc5b7cad7802..0000000000000000000000000000000000000000 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ObserverCloneObject.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * (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; - -/** - * @author Lukas Ladenberger - * - */ -public class ObserverCloneObject extends ObserverEvalObject implements - Cloneable { - - private String controlId; - - private int counter; - - public ObserverCloneObject() { - super(); - } - - public void setControlId(String controlId) { - Object oldValue = this.controlId; - this.controlId = controlId; - firePropertyChange("controlId", oldValue, this.controlId); - } - - public String getControlId() { - return controlId; - } - - public void setCounter(int counter) { - Object oldValue = this.counter; - this.counter = counter; - firePropertyChange("counter", oldValue, this.counter); - } - - public int getCounter() { - return counter; - } - - public ObserverCloneObject clone() throws CloneNotSupportedException { - return (ObserverCloneObject) super.clone(); - } - -} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchChildCoordinates.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchChildCoordinates.java index da5a59e940a7199f771aec0a77892b2d2d05e937..4b765982254fe01c171f19ef7b63c22f4ef1a084 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchChildCoordinates.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchChildCoordinates.java @@ -11,7 +11,6 @@ import java.util.List; import de.bmotionstudio.gef.editor.Animation; import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.animation.AnimationMove; import de.bmotionstudio.gef.editor.model.BControl; import de.bmotionstudio.gef.editor.observer.wizard.WizardObserverCSwitchCoordinates; import de.bmotionstudio.gef.editor.util.BMSUtil; @@ -74,21 +73,21 @@ public class SwitchChildCoordinates extends Observer { if (!obj.hasError()) { if (Boolean.valueOf(bolValue)) { // If true - if (obj.getAnimate()) { - - AnimationMove aMove = new AnimationMove(500, true, - toggleControl, parsedX, parsedY); - // aMove.addAnimationListener(animationListener); - aMove.start(); - - } else { - - toggleControl.setAttributeValue( - AttributeConstants.ATTRIBUTE_X, parsedX); - toggleControl.setAttributeValue( - AttributeConstants.ATTRIBUTE_Y, parsedY); - - } + // if (obj.getAnimate()) { + // + // AnimationMove aMove = new AnimationMove(500, true, + // toggleControl, parsedX, parsedY); + // // aMove.addAnimationListener(animationListener); + // aMove.start(); + // + // } else { + + toggleControl.setAttributeValue( + AttributeConstants.ATTRIBUTE_X, parsedX); + toggleControl.setAttributeValue( + AttributeConstants.ATTRIBUTE_Y, parsedY); + + // } } } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchCoordinates.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchCoordinates.java index 5a850642ff9fba70d00e951922aea57f75c3fc75..f1fff2ff1fb4bbc46553c31bec0c30213e44fb27 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchCoordinates.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/SwitchCoordinates.java @@ -11,7 +11,6 @@ import java.util.List; import de.bmotionstudio.gef.editor.Animation; import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.animation.AnimationMove; import de.bmotionstudio.gef.editor.model.BControl; import de.bmotionstudio.gef.editor.observer.wizard.WizardObserverSwitchCoordinates; import de.bmotionstudio.gef.editor.util.BMSUtil; @@ -73,24 +72,24 @@ public class SwitchCoordinates extends Observer { // setCallBack(false); // If true - if (obj.getAnimate()) { - - // if (!checked) - // return; - - AnimationMove aMove = new AnimationMove(5000, true, - control, parsedX, parsedY); - // aMove.addAnimationListener(animationListener); - aMove.start(); - - } else { - control.setAttributeValue( - AttributeConstants.ATTRIBUTE_X, parsedX); - control.setAttributeValue( - AttributeConstants.ATTRIBUTE_Y, parsedY); - // setCallBack(true); - // checked = false; - } + // if (obj.getAnimate()) { + + // if (!checked) + // return; + + // AnimationMove aMove = new AnimationMove(5000, true, + // control, parsedX, parsedY); + // aMove.addAnimationListener(animationListener); + // aMove.start(); + + // } else { + control.setAttributeValue(AttributeConstants.ATTRIBUTE_X, + parsedX); + control.setAttributeValue(AttributeConstants.ATTRIBUTE_Y, + parsedY); + // setCallBack(true); + // checked = false; + // } } // else { diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ToggleObjectCoordinates.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ToggleObjectCoordinates.java index 2d9bd952c607c2a18a8171f360314c089f2610d0..0ebd9af41725df1c3d7b59819f7534bfa0846886 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ToggleObjectCoordinates.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/ToggleObjectCoordinates.java @@ -12,27 +12,28 @@ public class ToggleObjectCoordinates extends ObserverEvalObject implements private String bcontrol; private String x; private String y; - private Boolean animate; + + // private Boolean animate; public ToggleObjectCoordinates() { super(); this.x = ""; this.y = ""; - this.animate = false; + // this.animate = false; } public ToggleObjectCoordinates(String type, String bcontrol, String x, - String y, String eval, Boolean animate) { + String y, String eval) { super(type, eval); this.bcontrol = bcontrol; this.x = x; this.y = y; - this.animate = animate; + // this.animate = animate; } public ToggleObjectCoordinates(String type, String x, String y, - String eval, Boolean animate) { - this(type, null, x, y, eval, animate); + String eval) { + this(type, null, x, y, eval); } public String getBcontrol() { @@ -47,9 +48,9 @@ public class ToggleObjectCoordinates extends ObserverEvalObject implements return y; } - public Boolean getAnimate() { - return animate; - } + // public Boolean getAnimate() { + // return animate; + // } public void setBcontrol(String bcontrol) { Object oldValue = this.bcontrol; @@ -69,11 +70,11 @@ public class ToggleObjectCoordinates extends ObserverEvalObject implements firePropertyChange("y", oldValue, this.y); } - public void setAnimate(Boolean animate) { - Object oldValue = this.animate; - this.animate = animate; - firePropertyChange("animate", oldValue, this.animate); - } + // public void setAnimate(Boolean animate) { + // Object oldValue = this.animate; + // this.animate = animate; + // firePropertyChange("animate", oldValue, this.animate); + // } public ToggleObjectCoordinates clone() throws CloneNotSupportedException { return (ToggleObjectCoordinates) super.clone(); diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverCSwitchCoordinates.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverCSwitchCoordinates.java index 48002be9092b2f094f42efc5e28ed6ecb81bd075..6df01de5a50d435b92bd3ce6b7f0214055af63df 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverCSwitchCoordinates.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverCSwitchCoordinates.java @@ -13,9 +13,6 @@ import org.eclipse.core.databinding.observable.map.IObservableMap; import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.CheckboxCellEditor; -import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITableColorProvider; @@ -52,7 +49,6 @@ import de.bmotionstudio.gef.editor.observer.ObserverEvalObject; import de.bmotionstudio.gef.editor.observer.ObserverWizard; import de.bmotionstudio.gef.editor.observer.SwitchChildCoordinates; import de.bmotionstudio.gef.editor.observer.ToggleObjectCoordinates; -import de.bmotionstudio.gef.editor.property.CheckboxCellEditorHelper; import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; public class WizardObserverCSwitchCoordinates extends ObserverWizard { @@ -132,38 +128,38 @@ public class WizardObserverCSwitchCoordinates extends ObserverWizard { column.setEditingSupport(new TextEditingSupport(tableViewer, dbc, "y")); - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Animate?"); - column.getColumn().setWidth(75); - column.setEditingSupport(new EditingSupport(tableViewer) { - - private CellEditor cellEditor = new CheckboxCellEditor( - (Composite) tableViewer.getControl()); - - @Override - protected void setValue(Object element, Object value) { - ((ToggleObjectCoordinates) element).setAnimate(Boolean - .valueOf(String.valueOf(value))); - } - - @Override - protected Object getValue(Object element) { - Boolean b = ((ToggleObjectCoordinates) element) - .getAnimate(); - return b != null ? b : false; - } - - @Override - protected CellEditor getCellEditor(Object element) { - return cellEditor; - } - - @Override - protected boolean canEdit(Object element) { - return true; - } - - }); + // column = new TableViewerColumn(tableViewer, SWT.NONE); + // column.getColumn().setText("Animate?"); + // column.getColumn().setWidth(75); + // column.setEditingSupport(new EditingSupport(tableViewer) { + // + // private CellEditor cellEditor = new CheckboxCellEditor( + // (Composite) tableViewer.getControl()); + // + // @Override + // protected void setValue(Object element, Object value) { + // ((ToggleObjectCoordinates) element).setAnimate(Boolean + // .valueOf(String.valueOf(value))); + // } + // + // @Override + // protected Object getValue(Object element) { + // Boolean b = ((ToggleObjectCoordinates) element) + // .getAnimate(); + // return b != null ? b : false; + // } + // + // @Override + // protected CellEditor getCellEditor(Object element) { + // return cellEditor; + // } + // + // @Override + // protected boolean canEdit(Object element) { + // return true; + // } + // + // }); ObservableListContentProvider contentProvider = new ObservableListContentProvider(); tableViewer.setContentProvider(contentProvider); @@ -207,7 +203,7 @@ public class WizardObserverCSwitchCoordinates extends ObserverWizard { @Override public void widgetSelected(SelectionEvent e) { ToggleObjectCoordinates toggleObj = new ToggleObjectCoordinates( - BParser.PREDICATE_PREFIX, "", "", "", "", false); + BParser.PREDICATE_PREFIX, "", "", "", ""); input.add(toggleObj); } }); @@ -289,11 +285,11 @@ public class WizardObserverCSwitchCoordinates extends ObserverWizard { @Override public Image getColumnImage(Object element, int columnIndex) { - if (columnIndex == 4) { - return CheckboxCellEditorHelper - .getCellEditorImage(((ToggleObjectCoordinates) element) - .getAnimate()); - } + // if (columnIndex == 4) { + // return CheckboxCellEditorHelper + // .getCellEditorImage(((ToggleObjectCoordinates) element) + // .getAnimate()); + // } return null; } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSwitchCoordinates.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSwitchCoordinates.java index cbc251e3eeb3d7dc09526acd3007f377865e0aa7..6915a2c1658ef89ab358ae982bb18312dee1d799 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSwitchCoordinates.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/observer/wizard/WizardObserverSwitchCoordinates.java @@ -13,9 +13,6 @@ import org.eclipse.core.databinding.observable.map.IObservableMap; import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.CheckboxCellEditor; -import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITableColorProvider; @@ -53,7 +50,6 @@ import de.bmotionstudio.gef.editor.observer.ObserverEvalObject; import de.bmotionstudio.gef.editor.observer.ObserverWizard; import de.bmotionstudio.gef.editor.observer.SwitchCoordinates; import de.bmotionstudio.gef.editor.observer.ToggleObjectCoordinates; -import de.bmotionstudio.gef.editor.property.CheckboxCellEditorHelper; import de.bmotionstudio.gef.editor.util.BMotionWizardUtil; public class WizardObserverSwitchCoordinates extends ObserverWizard { @@ -119,45 +115,45 @@ public class WizardObserverSwitchCoordinates extends ObserverWizard { column.setEditingSupport(new TextEditingSupport(tableViewer, dbc, "y")); - column = new TableViewerColumn(tableViewer, SWT.NONE); - column.getColumn().setText("Animate?"); - column.getColumn().setWidth(75); - column.setEditingSupport(new EditingSupport(tableViewer) { - - private CellEditor cellEditor = new CheckboxCellEditor( - (Composite) tableViewer.getControl()); - - @Override - protected void setValue(Object element, Object value) { - ((ToggleObjectCoordinates) element).setAnimate(Boolean - .valueOf(String.valueOf(value))); - } - - @Override - protected Object getValue(Object element) { - Boolean b = ((ToggleObjectCoordinates) element) - .getAnimate(); - return b != null ? b : false; - } - - @Override - protected CellEditor getCellEditor(Object element) { - return cellEditor; - } - - @Override - protected boolean canEdit(Object element) { - return true; - } - - }); + // column = new TableViewerColumn(tableViewer, SWT.NONE); + // column.getColumn().setText("Animate?"); + // column.getColumn().setWidth(75); + // column.setEditingSupport(new EditingSupport(tableViewer) { + // + // private CellEditor cellEditor = new CheckboxCellEditor( + // (Composite) tableViewer.getControl()); + // + // @Override + // protected void setValue(Object element, Object value) { + // ((ToggleObjectCoordinates) element).setAnimate(Boolean + // .valueOf(String.valueOf(value))); + // } + // + // @Override + // protected Object getValue(Object element) { + // Boolean b = ((ToggleObjectCoordinates) element) + // .getAnimate(); + // return b != null ? b : false; + // } + // + // @Override + // protected CellEditor getCellEditor(Object element) { + // return cellEditor; + // } + // + // @Override + // protected boolean canEdit(Object element) { + // return true; + // } + // + // }); ObservableListContentProvider contentProvider = new ObservableListContentProvider(); tableViewer.setContentProvider(contentProvider); tableViewer.setLabelProvider(new ObserverLabelProvider( BeansObservables.observeMaps( contentProvider.getKnownElements(), new String[] { - "eval", "x", "y", "animate" }))); + "eval", "x", "y" }))); final WritableList input = new WritableList( ((SwitchCoordinates) getObserver()).getToggleObjects(), @@ -192,7 +188,9 @@ public class WizardObserverSwitchCoordinates extends ObserverWizard { @Override public void widgetSelected(SelectionEvent e) { ToggleObjectCoordinates toggleObj = new ToggleObjectCoordinates( - BParser.PREDICATE_PREFIX, "", "", "", false); + BParser.PREDICATE_PREFIX, "", String + .valueOf(getBControl().getLayout().x), + String.valueOf(getBControl().getLayout().y), ""); input.add(toggleObj); tableViewer .setSelection(new StructuredSelection(toggleObj)); @@ -267,11 +265,11 @@ public class WizardObserverSwitchCoordinates extends ObserverWizard { @Override public Image getColumnImage(Object element, int columnIndex) { - if (columnIndex == 3) { - return CheckboxCellEditorHelper - .getCellEditorImage(((ToggleObjectCoordinates) element) - .getAnimate()); - } + // if (columnIndex == 3) { + // return CheckboxCellEditorHelper + // .getCellEditorImage(((ToggleObjectCoordinates) element) + // .getAnimate()); + // } return null; } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/AppEditPartFactory.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/AppEditPartFactory.java index 93e767184f18e07a80fb64947372129e022cf25f..ed44ebee49f3f665eec1254841f206e51380b760 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/AppEditPartFactory.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/AppEditPartFactory.java @@ -7,6 +7,7 @@ package de.bmotionstudio.gef.editor.part; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.gef.EditPart; import org.eclipse.gef.EditPartFactory; import org.eclipse.gef.editparts.AbstractGraphicalEditPart; @@ -29,10 +30,13 @@ public class AppEditPartFactory implements EditPartFactory { part = new VisualizationPart(); } else { try { - IBControlService service = (IBControlService) BMotionEditorPlugin - .getControlServices().get(control.getType()) - .createExecutableExtension("service"); - part = service.createEditPart(); + IConfigurationElement configElement = BMotionEditorPlugin + .getControlServices().get(control.getType()); + if (configElement != null) { + IBControlService service = (IBControlService) configElement + .createExecutableExtension("service"); + part = service.createEditPart(); + } } catch (CoreException e) { e.printStackTrace(); } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BControlTreeEditPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BControlTreeEditPart.java index 2daad4048612c7d6328f84acf178e3e5e0f9d041..74522c772573b325aa2e4779a577f256327334f1 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BControlTreeEditPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BControlTreeEditPart.java @@ -13,7 +13,6 @@ import java.util.List; import java.util.Set; import de.bmotionstudio.gef.editor.AttributeConstants; -import de.bmotionstudio.gef.editor.BMotionStudioImage; import de.bmotionstudio.gef.editor.model.BConnection; import de.bmotionstudio.gef.editor.model.BControl; import de.bmotionstudio.gef.editor.model.Visualization; @@ -47,8 +46,7 @@ public class BControlTreeEditPart extends AppAbstractTreeEditPart { || evt.getPropertyName().equals(BControl.PROPERTY_REMOVE)) { refreshChildren(); } - if (evt.getPropertyName().equals(AttributeConstants.ATTRIBUTE_ID)) - refreshVisuals(); + refreshVisuals(); } @Override @@ -57,8 +55,7 @@ public class BControlTreeEditPart extends AppAbstractTreeEditPart { if (!(bcontrol instanceof Visualization)) { setWidgetText(bcontrol.getAttributeValue( AttributeConstants.ATTRIBUTE_ID).toString()); - setWidgetImage(BMotionStudioImage.getBControlImage(bcontrol - .getType())); + setWidgetImage(bcontrol.getIcon()); } } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/service/BConnectionService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/service/BConnectionService.java index f7637a477ae0ca73637f32d42bd9bdefbdc066c5..6d88ddebb508cdb3ccbcf52694e68b9c3ace855d 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/service/BConnectionService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/service/BConnectionService.java @@ -33,7 +33,7 @@ public class BConnectionService extends AbstractBControlService implements String sourcePluginID = configurationElement.getContributor().getName(); String name = configurationElement.getAttribute("name"); String icon = configurationElement.getAttribute("icon"); - return new ConnectionCreationToolEntry(name, "Create Control " + name, + return new ConnectionCreationToolEntry(name, "Create " + name, new BControlCreationFactory(BConnection.TYPE, visualization), AbstractUIPlugin .imageDescriptorFromPlugin(sourcePluginID, icon), diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/service/BEllipseService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/service/BEllipseService.java new file mode 100644 index 0000000000000000000000000000000000000000..40de317b91f70560053cf0bc8bb4a292974d6bb8 --- /dev/null +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/service/BEllipseService.java @@ -0,0 +1,33 @@ +package de.bmotionstudio.gef.editor.service; + +import de.bmotionstudio.gef.editor.AbstractBControlService; +import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.IBControlService; +import de.bmotionstudio.gef.editor.attribute.BAttributeShape; +import de.bmotionstudio.gef.editor.model.BControl; +import de.bmotionstudio.gef.editor.model.BShape; +import de.bmotionstudio.gef.editor.model.Visualization; +import de.bmotionstudio.gef.editor.part.AppAbstractEditPart; +import de.bmotionstudio.gef.editor.part.BShapePart; + +public class BEllipseService extends AbstractBControlService implements + IBControlService { + + public BEllipseService() { + // TODO Auto-generated constructor stub + } + + @Override + public BControl createControl(Visualization visualization) { + BShape ellipse = new BShape(visualization); + ellipse.setAttributeValue(AttributeConstants.ATTRIBUTE_SHAPE, + BAttributeShape.SHAPE_OVAL); + return ellipse; + } + + @Override + public AppAbstractEditPart createEditPart() { + return new BShapePart(); + } + +} diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/service/BShapeService.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/service/BRectangleService.java similarity index 90% rename from de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/service/BShapeService.java rename to de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/service/BRectangleService.java index c8951fbd8a55a24b89d34014ec331e7206fc44eb..4f74a1bab73bda064da23af7bf5914915a4347f0 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/service/BShapeService.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/service/BRectangleService.java @@ -18,7 +18,7 @@ import de.bmotionstudio.gef.editor.part.BShapePart; * @author Lukas Ladenberger * */ -public class BShapeService extends AbstractBControlService implements +public class BRectangleService extends AbstractBControlService implements IBControlService { /*