Author: dazarov
Date: 2008-05-26 13:06:31 -0400 (Mon, 26 May 2008)
New Revision: 8337
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ContainerEditPart.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesDiagramEditPart.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesEditPart.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesXYLayoutEditPolicy.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/DiagramFigure.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1189
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ContainerEditPart.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ContainerEditPart.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ContainerEditPart.java 2008-05-26
17:06:31 UTC (rev 8337)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.pages.editor.edit;
+
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+
+/**
+ * Support for containers.
+ */
+abstract public class ContainerEditPart extends PagesEditPart {
+ protected AccessibleEditPart createAccessible() {
+ return new AccessibleGraphicalEditPart() {
+ public void getName(AccessibleEvent event) {
+ }
+ };
+ }
+
+ /**
+ * Installs EditPolicies for container.
+ */
+ protected void createEditPolicies() {
+ super.createEditPolicies();
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, new PagesXYLayoutEditPolicy());
+ }
+
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesDiagramEditPart.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesDiagramEditPart.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesDiagramEditPart.java 2008-05-26
17:06:31 UTC (rev 8337)
@@ -0,0 +1,252 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.pages.editor.edit;
+
+import java.beans.PropertyChangeEvent;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.draw2d.*;
+import org.eclipse.gef.*;
+
+import org.eclipse.gef.requests.SelectionRequest;
+import org.eclipse.gef.rulers.RulerProvider;
+import org.eclipse.gef.tools.DeselectAllTracker;
+import org.eclipse.gef.tools.MarqueeDragTracker;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.jboss.tools.seam.ui.pages.editor.figures.DiagramFigure;
+import org.jboss.tools.seam.ui.pages.editor.model.IPagesModel;
+import org.jboss.tools.seam.ui.pages.editor.model.IPagesModelListener;
+
+public class PagesDiagramEditPart extends ContainerEditPart implements
+ LayerConstants, IPagesModelListener {
+ /*
+ *
+ */
+ private boolean gridVisual = false;
+
+ /*
+ *
+ */
+ private int gridVisualStep = 8;
+
+ /*
+ *
+ */
+ private DiagramFigure fig;
+
+ /**
+ * Public constructor
+ * @return
+ */
+ public boolean isGridVisible() {
+ return gridVisual;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getVisualGridStep() {
+ return gridVisualStep;
+ }
+
+ /**
+ *
+ */
+ public void setModel(Object model) {
+ super.setModel(model);
+ ((IPagesModel) model).addModelListener(this);
+ //gridVisual = getPagesModel().getOptions().isGridVisible();
+ //gridVisualStep = getPagesModel().getOptions().getVisualGridStep();
+ }
+
+ /**
+ *
+ */
+ public IPagesModel getPagesModel() {
+ return (IPagesModel) getModel();
+ }
+
+ /**
+ *
+ */
+ public boolean isStrutsModelListenerEnabled() {
+ return true;
+ }
+
+
+
+ /**
+ *
+ * @param editPart
+ */
+ public void setToFront(EditPart editPart) {
+ int index = getChildren().indexOf(editPart);
+ if (index == -1)
+ return;
+ if (index != getChildren().size() - 1)
+ reorderChild(editPart, getChildren().size() - 1);
+ }
+
+
+ protected AccessibleEditPart createAccessible() {
+ return new AccessibleGraphicalEditPart() {
+ public void getName(AccessibleEvent event) {
+ event.result = "Pages Diagram";
+ }
+ };
+ }
+
+ /**
+ * Installs edit policies for this part.
+ */
+ protected void createEditPolicies() {
+ super.createEditPolicies();
+ installEditPolicy(EditPolicy.NODE_ROLE, null);
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, null);
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, null);
+ //installEditPolicy(EditPolicy.COMPONENT_ROLE, new JSFDiagramEditPolicy());
+ }
+
+ /**
+ * Returns a figure
+ *
+ * @return Figure.
+ */
+ protected IFigure createFigure() {
+ fig = new DiagramFigure(this);
+ return fig;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public FreeformViewport getFreeformViewport() {
+ return (FreeformViewport) getAncestor(fig, FreeformViewport.class);
+ }
+
+ /**
+ *
+ * @param figure
+ * @param cls
+ * @return
+ */
+ public IFigure getAncestor(IFigure figure, Class cls) {
+ IFigure parent = fig;
+ while (parent != null) {
+ if (parent.getClass().equals(cls))
+ return parent;
+ parent = parent.getParent();
+ }
+ return null;
+ }
+
+ /**
+ *
+ */
+ public DragTracker getDragTracker(Request req) {
+ if (req instanceof SelectionRequest
+ && ((SelectionRequest) req).getLastButtonPressed() == 3)
+ return new DeselectAllTracker(this);
+ return new MarqueeDragTracker();
+ }
+
+ /**
+ * it does not hold any connections. .
+ *
+ * @return <code>NULL</code>
+ */
+ public ConnectionAnchor getSourceConnectionAnchor(
+ ConnectionEditPart editPart) {
+ return null;
+ }
+
+ /**
+ * It does not hold any connections.
+ *
+ * @return <code>NULL</code>
+ */
+ public ConnectionAnchor getSourceConnectionAnchor(int x, int y) {
+ return null;
+ }
+
+ /**
+ * It does not hold any connections.
+ *
+ * @return <code>NULL</code>
+ */
+ public ConnectionAnchor getTargetConnectionAnchor(
+ ConnectionEditPart editPart) {
+ return null;
+ }
+
+ /**
+ * It does not hold any connections.
+ *
+ * @return <code>NULL</code>
+ */
+ public ConnectionAnchor getTargetConnectionAnchor(int x, int y) {
+ return null;
+ }
+
+ /**
+ *
+ */
+ public void propertyChange(PropertyChangeEvent evt) {
+ }
+
+ /**
+ *
+ */
+ protected void refreshVisuals() {
+ }
+
+ /**
+ *
+ */
+// protected List getModelChildren() {
+// return getPagesModel().getGroupList().getElements();
+// }
+
+ /**
+ *
+ */
+ public Object getAdapter(Class adapter) {
+ if (adapter == SnapToHelper.class) {
+ List<Object> snapStrategies = new ArrayList<Object>();
+ Boolean val = (Boolean) getViewer().getProperty(
+ RulerProvider.PROPERTY_RULER_VISIBILITY);
+ if (val != null && val.booleanValue())
+ snapStrategies.add(new SnapToGuides(this));
+ val = (Boolean) getViewer().getProperty(
+ SnapToGeometry.PROPERTY_SNAP_ENABLED);
+ if (val != null && val.booleanValue())
+ snapStrategies.add(new SnapToGeometry(this));
+ val = (Boolean) getViewer().getProperty(
+ SnapToGrid.PROPERTY_GRID_ENABLED);
+ if (val != null && val.booleanValue())
+ snapStrategies.add(new SnapToGrid(this));
+
+ if (snapStrategies.size() == 0)
+ return null;
+ if (snapStrategies.size() == 1)
+ return (SnapToHelper) snapStrategies.get(0);
+
+ SnapToHelper ss[] = new SnapToHelper[snapStrategies.size()];
+ for (int i = 0; i < snapStrategies.size(); i++)
+ ss[i] = (SnapToHelper) snapStrategies.get(i);
+ return new CompoundSnapToHelper(ss);
+ }
+ return super.getAdapter(adapter);
+ }
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesEditPart.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesEditPart.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesEditPart.java 2008-05-26
17:06:31 UTC (rev 8337)
@@ -0,0 +1,286 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.pages.editor.edit;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.*;
+
+abstract public class PagesEditPart extends
+ org.eclipse.gef.editparts.AbstractGraphicalEditPart implements
+ NodeEditPart, PropertyChangeListener {
+
+ /*
+ *
+ */
+ private AccessibleEditPart acc;
+
+ /**
+ *
+ */
+ public void activate() {
+ if (isActive())
+ return;
+ super.activate();
+ }
+
+ /**
+ *
+ * @param cf
+ */
+ public void doDoubleClick(boolean cf) { }
+
+ /**
+ *
+ * @param cf
+ */
+ public void doMouseUp(boolean cf) { }
+
+ /**
+ *
+ * @param cf
+ */
+ public void doMouseDown(boolean cf) { }
+
+ /**
+ *
+ * @param cf
+ */
+ public void doMouseHover(boolean cf) { }
+
+ /**
+ *
+ */
+ public void doControlUp() { }
+
+ /**
+ *
+ */
+ public void doControlDown() { }
+
+ /**
+ *
+ */
+ protected void createEditPolicies() {
+// installEditPolicy(EditPolicy.COMPONENT_ROLE, new JSFElementEditPolicy());
+// installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE,
+// new JSFNodeEditPolicy());
+ }
+
+ /**
+ *
+ * @return
+ */
+ abstract protected AccessibleEditPart createAccessible();
+
+ /**
+ * Makes the EditPart insensible to changes in the model by removing itself
+ * from the model's list of listeners.
+ */
+ public void deactivate() {
+ if (!isActive())
+ return;
+ super.deactivate();
+ }
+
+ /**
+ *
+ */
+ protected AccessibleEditPart getAccessibleEditPart() {
+ if (acc == null)
+ acc = createAccessible();
+ return acc;
+ }
+
+
+
+ /**
+ *
+ */
+ public ConnectionAnchor getSourceConnectionAnchor(
+ ConnectionEditPart connEditPart) {
+ return null;
+ }
+
+ /**
+ *
+ */
+ public ConnectionAnchor getSourceConnectionAnchor(Request request) {
+ return null;
+ }
+
+ /**
+ *
+ */
+ public ConnectionAnchor getTargetConnectionAnchor(
+ ConnectionEditPart connEditPart) {
+ return null;
+ }
+
+ /**
+ *
+ */
+ public ConnectionAnchor getTargetConnectionAnchor(Request request) {
+ return null;
+ }
+
+
+
+ /**
+ *
+ */
+ public void propertyChange(PropertyChangeEvent evt) {
+ refreshVisuals();
+ }
+
+ /**
+ *
+ */
+ protected void refreshVisuals() {
+ Point loc = new Point(100, 100);
+ Dimension size = new Dimension(56, 100);
+ Rectangle r = new Rectangle(loc, size);
+
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(this,
+ getFigure(), r);
+ }
+
+ /**
+ *
+ */
+ protected void refreshSourceConnections() {
+ int i;
+ ConnectionEditPart connectEditPart;
+ Object modelEntry;
+
+ Map<Object,ConnectionEditPart> mapModelToPart = new
HashMap<Object,ConnectionEditPart>();
+ List parts = getSourceConnections();
+
+ for (i = 0; i < parts.size(); i++) {
+ connectEditPart = (ConnectionEditPart) parts.get(i);
+ mapModelToPart.put(connectEditPart.getModel(), connectEditPart);
+ }
+
+ List modelEntries = getModelSourceConnections();
+ if (modelEntries == null)
+ modelEntries = new ArrayList();
+
+ for (i = 0; i < modelEntries.size(); i++) {
+ modelEntry = modelEntries.get(i);
+
+ if (i < parts.size()) {
+ connectEditPart = (ConnectionEditPart) parts.get(i);
+ if (connectEditPart.getModel() == modelEntry) {
+ if (connectEditPart.getSource() != this)
+ connectEditPart.setSource(this);
+ continue;
+ }
+ }
+
+ connectEditPart = (ConnectionEditPart) mapModelToPart.get(modelEntry);
+ if (connectEditPart != null)
+ reorderSourceConnection(connectEditPart, i);
+ else {
+ connectEditPart = createOrFindConnection(modelEntry);
+ addSourceConnection(connectEditPart, i);
+ }
+ }
+
+ List<Object> trash = new ArrayList<Object>();
+ for (; i < parts.size(); i++)
+ trash.add(parts.get(i));
+ for (i = 0; i < trash.size(); i++)
+ removeSourceConnection((ConnectionEditPart) trash.get(i));
+ }
+
+ /**
+ *
+ */
+ protected void refreshTargetConnections() {
+ int i;
+ ConnectionEditPart connectEditPart;
+ Object modelEntry;
+
+ Map<Object,ConnectionEditPart> mapModelToEditPart = new
HashMap<Object,ConnectionEditPart>();
+ List connections = getTargetConnections();
+
+ for (i = 0; i < connections.size(); i++) {
+ connectEditPart = (ConnectionEditPart) connections.get(i);
+ mapModelToEditPart.put(connectEditPart.getModel(), connectEditPart);
+ }
+
+ List modelEntries = getModelTargetConnections();
+
+ if (modelEntries == null)
+ modelEntries = new ArrayList();
+
+ for (i = 0; i < modelEntries.size(); i++) {
+ modelEntry = modelEntries.get(i);
+
+ if (i < connections.size()) {
+ connectEditPart = (ConnectionEditPart) connections.get(i);
+ if (connectEditPart.getModel() == modelEntry) {
+ if (connectEditPart.getTarget() != this)
+ connectEditPart.setTarget(this);
+ continue;
+ }
+ }
+
+ connectEditPart = (ConnectionEditPart) mapModelToEditPart.get(modelEntry);
+ if (connectEditPart != null)
+ reorderTargetConnection(connectEditPart, i);
+ else {
+ connectEditPart = createOrFindConnection(modelEntry);
+ addTargetConnection(connectEditPart, i);
+ }
+ }
+
+ List<Object> removed = new ArrayList<Object>();
+ for (; i < connections.size(); i++)
+ removed.add(connections.get(i));
+ for (i = 0; i < removed.size(); i++)
+ removeTargetConnection((ConnectionEditPart) removed.get(i));
+ }
+
+ /**
+ *
+ */
+ protected void removeSourceConnection(ConnectionEditPart connection) {
+ if (connection.getSource() != this)
+ return;
+ fireRemovingSourceConnection(connection, getSourceConnections()
+ .indexOf(connection));
+ connection.deactivate();
+ connection.setSource(null);
+ primRemoveSourceConnection(connection);
+ }
+
+ /**
+ *
+ */
+ protected void removeTargetConnection(ConnectionEditPart connection) {
+ if (connection.getTarget() != this)
+ return;
+ fireRemovingTargetConnection(connection, getTargetConnections()
+ .indexOf(connection));
+ connection.setTarget(null);
+ primRemoveTargetConnection(connection);
+ }
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesXYLayoutEditPolicy.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesXYLayoutEditPolicy.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesXYLayoutEditPolicy.java 2008-05-26
17:06:31 UTC (rev 8337)
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.pages.editor.edit;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.RectangleFigure;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Handle;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.SharedCursors;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
+import org.eclipse.gef.editpolicies.XYLayoutEditPolicy;
+import org.eclipse.gef.handles.ResizeHandle;
+import org.eclipse.gef.internal.ui.palette.editparts.GroupEditPart;
+import org.eclipse.gef.requests.CreateRequest;
+
+/**
+ *
+ * @author eskimo(dgolovin(a)exadel.com)
+ *
+ */
+public class PagesXYLayoutEditPolicy extends XYLayoutEditPolicy {
+
+ /**
+ *
+ */
+ protected Command createAddCommand(EditPart childEditPart, Object constraint) {
+// SetConstraintCommand setConstraint = new SetConstraintCommand();
+// setConstraint.setLocation((Rectangle) constraint);
+// setConstraint.setPart((IJSFElement) childEditPart.getModel());
+// setConstraint.setLabel(JSFUIMessages.REPARENTING_JSFSUBPART);
+// setConstraint.setDebugLabel("LogicXYEP setConstraint");//$NON-NLS-1$*/
+// return setConstraint;
+ return null;
+ }
+
+ protected Command createChangeConstraintCommand(EditPart child,
+ Object constraint) {
+// SetConstraintCommand locationCommand = new SetConstraintCommand();
+// locationCommand.setShell(child.getViewer().getControl().getShell());
+// locationCommand.setPart((IJSFElement) child.getModel());
+// locationCommand.setLocation((Rectangle) constraint);
+// return locationCommand;
+ return null;
+ }
+
+ protected EditPolicy createChildEditPolicy(EditPart child) {
+ return new CustomPolicy();
+ }
+
+ protected Command getCreateCommand(CreateRequest request) {
+ return null;
+ }
+
+ protected Command getDeleteDependantCommand(Request request) {
+ return null;
+ }
+
+ protected Command getOrphanChildrenCommand(Request request) {
+ return null;
+ }
+
+ class CustomPolicy extends NonResizableEditPolicy {
+// protected IFigure createDragSourceFeedbackFigure() {
+// GroupEditPart part = (GroupEditPart) getHost();
+// IFigure child = getCustomFeedbackFigure(part.getModel());
+// addFeedback(child);
+// Rectangle childBounds = part.getFigure().getBounds().getCopy();
+// IFigure walker = part.getFigure().getParent();
+//
+// while (walker != ((GraphicalEditPart) part.getParent()).getFigure()) {
+// walker.translateToParent(childBounds);
+// walker = walker.getParent();
+// }
+//
+// child.setBounds(childBounds);
+//
+// return child;
+// }
+
+ protected IFigure getFeedbackLayer() {
+ return getLayer(LayerConstants.SCALED_FEEDBACK_LAYER);
+ }
+
+// protected IFigure getCustomFeedbackFigure(Object modelPart) {
+// IFigure figure;
+//
+// if (modelPart instanceof IGroup)
+// figure = new GroupFeedbackFigure();
+// else {
+// figure = new RectangleFigure();
+// ((RectangleFigure) figure).setXOR(true);
+// ((RectangleFigure) figure).setFill(true);
+// figure.setBackgroundColor(NodeFigure.ghostFillColor);
+// figure.setForegroundColor(NodeFigure.whiteColor);
+// }
+//
+// return figure;
+// }
+
+ protected List createSelectionHandles() {
+ List<Handle> list = new ArrayList<Handle>();
+ list.add(createHandle((GraphicalEditPart) getHost(),
+ PositionConstants.SOUTH_EAST));
+ list.add(createHandle((GraphicalEditPart) getHost(),
+ PositionConstants.SOUTH_WEST));
+ list.add(createHandle((GraphicalEditPart) getHost(),
+ PositionConstants.NORTH_WEST));
+ list.add(createHandle((GraphicalEditPart) getHost(),
+ PositionConstants.NORTH_EAST));
+
+ return list;
+ }
+
+ Handle createHandle(GraphicalEditPart owner, int direction) {
+ ResizeHandle handle = new ResizeHandle(owner, direction);
+ handle.setCursor(SharedCursors.SIZEALL);
+ return handle;
+ }
+ }
+}
\ No newline at end of file
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/DiagramFigure.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/DiagramFigure.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/DiagramFigure.java 2008-05-26
17:06:31 UTC (rev 8337)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.pages.editor.figures;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.FreeformLayer;
+import org.eclipse.draw2d.FreeformLayout;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.PrinterGraphics;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.graphics.Color;
+import org.jboss.tools.seam.ui.pages.editor.edit.PagesDiagramEditPart;
+
+
+
+public class DiagramFigure extends FreeformLayer implements IFigure {
+ public static final Color lightGrayColor = new Color(null, 0xf1, 0xf1, 0xf1);
+ private PagesDiagramEditPart editPart;
+
+ public DiagramFigure(PagesDiagramEditPart editPart) {
+ super();
+ this.editPart = editPart;
+ setLayoutManager(new FreeformLayout());
+ setBorder(new MarginBorder(5));
+ setBackgroundColor(ColorConstants.white);
+ setOpaque(true);
+ }
+
+ protected void paintFigure(Graphics g) {
+ super.paintFigure(g);
+ Rectangle r = getBounds().getCopy();
+ g.translate(r.getLocation());
+ int width = r.width;
+ int height = r.height;
+
+ if (editPart.isGridVisible() && !(g instanceof PrinterGraphics)) {
+ g.setLineStyle(Graphics.LINE_DOT);
+ g.setForegroundColor(lightGrayColor);
+ g.setBackgroundColor(ColorConstants.white);
+ for (int i = 0; i < width; i += editPart.getVisualGridStep()) {
+ g.drawLine(i, 0, i, height - 1);
+ }
+ for (int i = 0; i < height; i += editPart.getVisualGridStep()) {
+ g.drawLine(0, i, width, i);
+ }
+ g.setLineStyle(Graphics.LINE_SOLID);
+ }
+ }
+
+}