package com.example.shapeditor.parts; import org.eclipse.draw2d. ; import org.eclipse.gef. ; import org.eclipse.gef.editparts.AbstractGraphicalEditPart; import com.example.shapeditor.figures.RectangleFigure; import com.example.shapeditor.model.Shape;

– Base class for all shapes:

// Getters & Setters with property change firing public int getX() return x; public void setX(int x) int old = this.x; this.x = x; listeners.firePropertyChange(LOCATION_PROP, old, x);

org.eclipse.core.runtime org.eclipse.ui org.eclipse.draw2d org.eclipse.gef org.eclipse.jface org.eclipse.swt org.eclipse.ui.ide Define the data structure.

private Diagram createDiagram() diagram = new Diagram(); RectangleShape rect = new RectangleShape(); rect.setX(100); rect.setY(100); rect.setWidth(80); rect.setHeight(60); diagram.addShape(rect); EllipseShape ellipse = new EllipseShape(); ellipse.setX(250); ellipse.setY(150); ellipse.setWidth(70); ellipse.setHeight(70); diagram.addShape(ellipse); return diagram;

public class ShapeEditPart extends AbstractGraphicalEditPart

(root) – manages children:

public abstract class Shape public static final String LOCATION_PROP = "location"; public static final String SIZE_PROP = "size";