Author: dazarov
Date: 2008-05-27 11:43:12 -0400 (Tue, 27 May 2008)
New Revision: 8374
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/LinkEditPart.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/LinkEditPolicy.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/LinkEndpointEditPolicy.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PageEditPart.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesConnectionDragTracker.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesConnectionHandle.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/xpl/
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/xpl/PagesConnectionRouter.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ConnectionFigure.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/FigureFactory.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/NodeFigure.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/PageFeedbackFigure.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/PageFigure.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/xpl/
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/xpl/FixedConnectionAnchor.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/LinkEditPart.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/LinkEditPart.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/LinkEditPart.java 2008-05-27
15:43:12 UTC (rev 8374)
@@ -0,0 +1,247 @@
+/*******************************************************************************
+ * 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 org.eclipse.draw2d.*;
+import org.eclipse.draw2d.geometry.PointList;
+import org.jboss.tools.common.model.ui.dnd.DnDUtil;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartListener;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.editparts.AbstractConnectionEditPart;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.graphics.Image;
+
+import org.jboss.tools.common.meta.action.XAction;
+import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.gef.GEFGraphicalViewer;
+import org.jboss.tools.common.gef.edit.GEFRootEditPart;
+import org.jboss.tools.common.gef.figures.GEFLabel;
+import org.jboss.tools.common.gef.figures.xpl.CustomLocator;
+import org.jboss.tools.seam.ui.pages.editor.PagesEditor;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.Link;
+import org.jboss.tools.seam.ui.pages.editor.figures.ConnectionFigure;
+import org.jboss.tools.seam.ui.pages.editor.figures.FigureFactory;
+
+public class LinkEditPart extends AbstractConnectionEditPart implements
+ PropertyChangeListener, EditPartListener {
+ public static final Image icon = ImageDescriptor.createFromFile(
+ PagesEditor.class, "icons/shortcut.gif").createImage();
+
+ AccessibleEditPart acc;
+
+ private boolean shortcut;
+
+ private CustomLocator shortcutLocator;
+
+ private GEFLabel shortcutLabel;
+
+ private CustomLocator pathLocator;
+
+ private GEFLabel pathLabel;
+
+ public void activate() {
+ super.activate();
+ addEditPartListener(this);
+ }
+
+ public void activateFigure() {
+ super.activateFigure();
+ getFigure().addPropertyChangeListener(
+ Connection.PROPERTY_CONNECTION_ROUTER, this);
+ }
+
+ /**
+ * Adds extra EditPolicies as required.
+ */
+ protected void createEditPolicies() {
+ installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE,
+ new LinkEndpointEditPolicy());
+ installEditPolicy(EditPolicy.CONNECTION_ROLE, new LinkEditPolicy());
+ }
+
+ protected IFigure createFigure() {
+ if (getLink() == null)
+ return null;
+ ConnectionFigure conn = FigureFactory.createNewBendableWire(this,
+ getLink());
+// PointList list = getLink().getPointList();
+// if (list.size() > 0) {
+// conn.setManual(true);
+// conn.setOldPoints(list.getFirstPoint(), list.getLastPoint());
+// conn.setPoints(list);
+// }
+
+ pathLabel = new GEFLabel(getLink().getName(),
+ FigureFactory.normalColor);
+// pathLabel.setFont(getLink().getJSFModel().getOptions()
+// .getLinkPathFont());
+ pathLabel.setIcon(null);
+ pathLabel.setTextAlignment(Label.LEFT);
+ pathLabel.setLabelAlignment(Label.LEFT);
+
+ pathLocator = new CustomLocator(conn, false);
+ pathLocator.setUDistance(5);
+ pathLocator.setVDistance(-13);
+ if (!getLink().isShortcut())
+ conn.add(pathLabel, pathLocator);
+
+ String text = "";
+// if (getLink().getJSFModel().getOptions().showShortcutPath())
+// text = getLink().getToGroup().getVisiblePath();
+ shortcutLabel = new GEFLabel(text, FigureFactory.normalColor);
+// if (getLink().getJSFModel().getOptions().showShortcutIcon())
+// shortcutLabel.setIcon(icon);
+// shortcutLabel.setFont(getLink().getJSFModel().getOptions()
+// .getLinkPathFont());
+ shortcutLabel.setTextAlignment(Label.LEFT);
+ shortcutLabel.setLabelAlignment(Label.LEFT);
+ shortcutLabel.setIconAlignment(Label.LEFT);
+
+ shortcutLocator = new CustomLocator(conn, false);
+ shortcutLocator.setUDistance(18);
+ shortcutLocator.setVDistance(-6);
+ if (getLink().isShortcut())
+ conn.add(shortcutLabel, shortcutLocator);
+
+ return conn;
+ }
+
+ public Link getLinkModel() {
+ return (Link) getModel();
+ }
+
+ public void save() {
+ PointList list = ((ConnectionFigure) getFigure()).getPoints();
+ //getLink().savePointList(list);
+ }
+
+ public void clear() {
+ //getLink().clearPointList();
+ }
+
+ public void deactivate() {
+ removeEditPartListener(this);
+ //getLink().removePropertyChangeListener(this);
+ super.deactivate();
+ }
+
+ public void deactivateFigure() {
+ getFigure().removePropertyChangeListener(
+ Connection.PROPERTY_CONNECTION_ROUTER, this);
+ super.deactivateFigure();
+ }
+
+ public AccessibleEditPart getAccessibleEditPart() {
+ if (acc == null)
+ acc = new AccessibleGraphicalEditPart() {
+ public void getName(AccessibleEvent e) {
+ e.result = "Link";
+ }
+ };
+ return acc;
+ }
+
+ protected Link getLink() {
+ return (Link) getModel();
+ }
+
+ protected ConnectionFigure getLinkFigure() {
+ return (ConnectionFigure) getFigure();
+ }
+
+ public void propertyChange(PropertyChangeEvent event) {
+ String property = event.getPropertyName();
+ if ("value".equals(property)) //$NON-NLS-1$
+ refreshVisuals();
+ }
+
+ /**
+ * Refreshes the visual aspects of this, based upon the model (Wire). It
+ * changes the wire color depending on the state of Wire.
+ *
+ */
+ protected void refreshVisuals() {
+ }
+
+ public void setModel(Object model) {
+ super.setModel(model);
+ //((ILink) model).addLinkListener(this);
+ shortcut = getLink().isShortcut();
+ }
+
+ public boolean isLinkListenerEnable() {
+ return true;
+ }
+
+ public void linkChange(Link source) {
+ pathLabel.setText(getLink().getName());
+// if (getLinkModel().getJSFModel().getOptions().showShortcutPath())
+// shortcutLabel.setText(getLink().getToGroup().getVisiblePath());
+// else
+// shortcutLabel.setText("");
+// if (getLinkModel().getJSFModel().getOptions().showShortcutIcon())
+// shortcutLabel.setIcon(icon);
+// else
+// shortcutLabel.setIcon(null);
+
+ getLinkFigure().refreshFont();
+ if (shortcut != getLink().isShortcut()) {
+ shortcut = getLink().isShortcut();
+ if (shortcut) {
+ getLinkFigure().add(shortcutLabel, shortcutLocator);
+ getLinkFigure().remove(pathLabel);
+ } else {
+ getLinkFigure().remove(shortcutLabel);
+ getLinkFigure().add(pathLabel, pathLocator);
+ }
+ refresh();
+ }
+
+// if (getLinkFigure().isManual()
+// && getLink().getPathFromModel().equals("")) {
+// getLinkFigure().setManual(false);
+// refresh();
+// } else if (!getLinkFigure().isManual()
+// && !getLink().getPathFromModel().equals("")) {
+// getLinkFigure().setManual(true);
+// refresh();
+// }
+
+ }
+
+ public void childAdded(EditPart child, int index) {
+ }
+
+ public void partActivated(EditPart editpart) {
+ }
+
+ public void partDeactivated(EditPart editpart) {
+ }
+
+ public void removingChild(EditPart child, int index) {
+ }
+
+ public void selectedStateChanged(EditPart editpart) {
+ if (this.getSelected() == EditPart.SELECTED_PRIMARY) {
+ ((GEFRootEditPart) getParent()).setToFront(this);
+
+ }
+ }
+
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/LinkEditPolicy.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/LinkEditPolicy.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/LinkEditPolicy.java 2008-05-27
15:43:12 UTC (rev 8374)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.commands.Command;
+
+import org.eclipse.gef.requests.GroupRequest;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.Link;
+
+
+
+public class LinkEditPolicy
+ extends org.eclipse.gef.editpolicies.ConnectionEditPolicy {
+
+ protected Command getDeleteCommand(GroupRequest request) {
+// ConnectionCommand c = new ConnectionCommand();
+// c.setLink((Link)getHost().getModel());
+// return c;
+ return null;
+ }
+
+}
\ No newline at end of file
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/LinkEndpointEditPolicy.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/LinkEndpointEditPolicy.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/LinkEndpointEditPolicy.java 2008-05-27
15:43:12 UTC (rev 8374)
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * 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.ConnectionLocator;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.DragTracker;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartViewer;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.handles.AbstractHandle;
+import org.eclipse.gef.handles.ConnectionHandle;
+import org.eclipse.gef.tools.ConnectionEndpointTracker;
+import org.jboss.tools.seam.ui.pages.editor.figures.FigureFactory;
+
+
+public class LinkEndpointEditPolicy
+ extends org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy {
+ private List JSFhandles = null;
+
+ private void addJSFHandles() {
+ removeJSFHandles();
+ JSFhandles = createJSFHandles();
+ IFigure layer = getLayer(LayerConstants.HANDLE_LAYER);
+ for (int i = 0; i < JSFhandles.size(); i++)
+ layer.add((IFigure) JSFhandles.get(i));
+
+ }
+
+ private void removeJSFHandles() {
+ if (JSFhandles == null)
+ return;
+ IFigure layer = getLayer(LayerConstants.HANDLE_LAYER);
+ for (int i = 0; i < JSFhandles.size(); i++)
+ layer.remove((IFigure) JSFhandles.get(i));
+ JSFhandles = null;
+ }
+
+ protected void addSelectionHandles() {
+
+ super.addSelectionHandles();
+ addJSFHandles();
+
+ getConnectionFigure().setForegroundColor(FigureFactory.selectedColor);
+ }
+
+ protected PolylineConnection getConnectionFigure() {
+ return (PolylineConnection) ((GraphicalEditPart) getHost()).getFigure();
+ }
+
+ protected void removeSelectionHandles() {
+ super.removeSelectionHandles();
+ removeJSFHandles();
+ getConnectionFigure().setForegroundColor(FigureFactory.normalColor);
+ }
+
+ protected List createSelectionHandles() {
+ List<ConnectionHandle> list = new ArrayList<ConnectionHandle>();
+ list.add(new LinkEndHandle((ConnectionEditPart) getHost()));
+ list.add(new LinkStartHandle((ConnectionEditPart) getHost()));
+ return list;
+ }
+
+ protected List createJSFHandles() {
+ List<AbstractHandle> list = new ArrayList<AbstractHandle>();
+ PolylineConnection conn = getConnectionFigure();
+ boolean flag = true;
+ for (int i = 0; i < conn.getPoints().size() - 3; i++) {
+ if (flag)
+ flag = false;
+ else
+ flag = true;
+ list.add(new PagesConnectionHandle((ConnectionEditPart) getHost(),
+ flag, i + 1));
+ }
+
+ return list;
+ }
+
+ class LinkEndHandle extends ConnectionHandle {
+
+ public LinkEndHandle(ConnectionEditPart owner) {
+ setOwner(owner);
+ setLocator(new ConnectionLocator(getConnection(),
+ ConnectionLocator.TARGET));
+ }
+
+ public LinkEndHandle(ConnectionEditPart owner, boolean fixed) {
+ super(fixed);
+ setOwner(owner);
+ setLocator(new ConnectionLocator(getConnection(),
+ ConnectionLocator.TARGET));
+ }
+
+ public LinkEndHandle() {
+ }
+
+ protected DragTracker createDragTracker() {
+ if (isFixed())
+ return null;
+ ConnectionEndpointTracker tracker;
+ tracker = new LinkEndpointTracker((ConnectionEditPart) getOwner());
+ tracker.setCommandName(RequestConstants.REQ_RECONNECT_TARGET);
+ tracker.setDefaultCursor(getCursor());
+ return tracker;
+ }
+ }
+
+ class LinkStartHandle extends ConnectionHandle {
+
+ public LinkStartHandle(ConnectionEditPart owner) {
+ setOwner(owner);
+ setLocator(new ConnectionLocator(getConnection(),
+ ConnectionLocator.SOURCE));
+ }
+
+ public LinkStartHandle(ConnectionEditPart owner, boolean fixed) {
+ super(fixed);
+ setOwner(owner);
+ setLocator(new ConnectionLocator(getConnection(),
+ ConnectionLocator.SOURCE));
+ }
+
+ public LinkStartHandle() {
+ }
+
+ protected DragTracker createDragTracker() {
+ if (isFixed())
+ return null;
+ ConnectionEndpointTracker tracker;
+ tracker = new LinkEndpointTracker((ConnectionEditPart) getOwner());
+ tracker.setCommandName(RequestConstants.REQ_RECONNECT_SOURCE);
+ tracker.setDefaultCursor(getCursor());
+ return tracker;
+ }
+ }
+
+ class LinkEndpointTracker extends ConnectionEndpointTracker {
+ public LinkEndpointTracker(ConnectionEditPart cpart) {
+ super(cpart);
+ }
+
+ public void mouseDown(MouseEvent me, EditPartViewer epv) {
+ super.mouseDown(me, epv);
+ removeJSFHandles();
+ //DndHelper.drag(((ILink) getHost().getModel()).getSource());
+ }
+
+ public void mouseUp(MouseEvent me, EditPartViewer epv) {
+ super.mouseUp(me, epv);
+ if (getHost().getSelected() != EditPart.SELECTED_NONE)
+ addJSFHandles();
+ }
+
+ protected boolean handleNativeDragFinished(DragSourceEvent event) {
+ //DndHelper.dragEnd();
+ return false;
+ }
+ }
+
+}
\ No newline at end of file
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PageEditPart.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PageEditPart.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PageEditPart.java 2008-05-27
15:43:12 UTC (rev 8374)
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * 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.*;
+
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.jboss.tools.common.model.ui.dnd.DnDUtil;
+import org.eclipse.gef.*;
+import org.eclipse.gef.requests.DropRequest;
+import org.eclipse.swt.accessibility.AccessibleControlEvent;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+
+import org.jboss.tools.common.meta.action.XAction;
+import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.Link;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.Page;
+import org.jboss.tools.seam.ui.pages.editor.figures.PageFigure;
+
+public class PageEditPart extends PagesEditPart implements PropertyChangeListener,
EditPartListener {
+ private PageFigure fig = null;
+
+ private boolean single = true;
+
+ public boolean isSingle() {
+ return single;
+ }
+
+ public void doControlUp() {
+ }
+
+ public void doControlDown() {
+ }
+
+ public void doMouseHover(boolean cf) {
+ }
+
+ public void childAdded(EditPart child, int index) {
+ }
+
+ public void partActivated(EditPart editpart) {
+ }
+
+ public void partDeactivated(EditPart editpart) {
+ }
+
+ public void removingChild(EditPart child, int index) {
+ }
+
+ public void selectedStateChanged(EditPart editpart) {
+ if (this.getSelected() == EditPart.SELECTED_PRIMARY) {
+ ((PagesDiagramEditPart) PageEditPart.this.getParent())
+ .setToFront(this);
+
+ }
+ }
+
+ public boolean isGroupListenerEnable() {
+ return true;
+ }
+
+
+
+ private void refreshTargetLink(Link link) {
+ if (link == null)
+ return;
+ PageEditPart gep = (PageEditPart) getViewer().getEditPartRegistry()
+ .get(link.getToElement());
+ if (gep == null)
+ return;
+ gep.refreshTargetConnections();
+ }
+
+
+ protected AccessibleEditPart createAccessible() {
+ return new AccessibleGraphicalEditPart() {
+
+ public void getName(AccessibleEvent e) {
+ e.result = "EditPart";
+ }
+
+ public void getValue(AccessibleControlEvent e) {
+ }
+
+ };
+ }
+
+ protected List getModelTargetConnections() {
+ return getPageModel().getInputLinks();
+ }
+
+ protected List getModelSourceConnections() {
+ return getPageModel().getOutputLinks();
+ }
+
+ protected void createEditPolicies() {
+ super.createEditPolicies();
+ installEditPolicy(EditPolicy.NODE_ROLE, null);
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, null);
+ //installEditPolicy(EditPolicy.COMPONENT_ROLE, new PageEditPolicy());
+ //installEditPolicy(EditPolicy.LAYOUT_ROLE, new JSFFlowEditPolicy());
+ //installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE,
+ // new PageEditPolicy());
+ }
+
+ /**
+ * Returns a newly created Figure to represent this.
+ *
+ * @return Figure of this.
+ */
+
+ protected IFigure createFigure() {
+ fig = new PageFigure(getPageModel());
+ ((PageFigure) fig).setGroupEditPart(this);
+ return fig;
+ }
+
+ public PageFigure getGroupFigure() {
+ return (PageFigure) getFigure();
+ }
+
+ /**
+ * Returns the model of this as a LED.
+ *
+ * @return Model of this as an LED.
+ */
+ public Page getPageModel() {
+ return (Page) getModel();
+ }
+
+ Dimension size;
+
+
+
+ protected void refreshVisuals() {
+ Point loc = getPageModel().getLocation();
+ loc.x -= loc.x % 8;
+ loc.y -= loc.y % 8;
+
+ Rectangle r = new Rectangle(loc, size);
+
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(this,
+ getFigure(), r);
+ }
+
+ public ConnectionAnchor getTargetConnectionAnchor(
+ ConnectionEditPart connEditPart) {
+ ConnectionAnchor anc = getNodeFigure().getConnectionAnchor("1_IN");
+ return anc;
+ }
+
+ public ConnectionAnchor getTargetConnectionAnchor(Request request) {
+ Point pt = new Point(((DropRequest) request).getLocation());
+ return getNodeFigure().getTargetConnectionAnchorAt(pt);
+ }
+
+ public ConnectionAnchor getSourceConnectionAnchor(
+ ConnectionEditPart connEditPart) {
+ if (single) {
+ Link link = (Link) connEditPart.getModel();
+ int index = getPageModel().getOutputLinks().indexOf(link);
+ return getNodeFigure().getConnectionAnchor((index + 1) + "_OUT");
+ } else
+ return super.getSourceConnectionAnchor(connEditPart);
+ }
+
+ public ConnectionAnchor getSourceConnectionAnchor(Request request) {
+ if (single) {
+ Point pt = new Point(((DropRequest) request).getLocation());
+ return getNodeFigure().getSourceConnectionAnchorAt(pt);
+ } else
+ return super.getSourceConnectionAnchor(request);
+ }
+
+ protected List getModelChildren() {
+ return getPageModel().getChildren();
+ }
+
+ protected void refreshChildren() {
+ super.refreshChildren();
+ for (int i = 0; i < getChildren().size(); i++) {
+ ((PageEditPart) getChildren().get(i)).refresh();
+
+ }
+ }
+
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesConnectionDragTracker.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesConnectionDragTracker.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesConnectionDragTracker.java 2008-05-27
15:43:12 UTC (rev 8374)
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * 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.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.tools.ConnectionEndpointTracker;
+import org.jboss.tools.seam.ui.pages.editor.figures.ConnectionFigure;
+
+
+public class PagesConnectionDragTracker extends ConnectionEndpointTracker {
+ private boolean vertical;
+ private PointList list;
+ private int index1, index2;
+ private Point point1, point2;
+ private boolean first = true;
+
+ public PagesConnectionDragTracker(ConnectionEditPart cep, boolean vertical,
+ int id) {
+ super(cep);
+ this.vertical = vertical;
+ list = getConnection().getPoints();
+ index1 = id;
+ index2 = id + 1;
+ point1 = list.getPoint(index1);
+ point2 = list.getPoint(index2);
+ }
+
+ public void commitDrag() {
+ }
+
+ protected boolean handleDragInProgress() {
+ if (first) {
+ list = getConnection().getPoints();
+ point1 = list.getPoint(index1);
+ point2 = list.getPoint(index2);
+
+ first = false;
+ }
+ Dimension delta = getDragMoveDelta();
+ Point p1, p2;
+ if (vertical) {
+ p1 = new Point(point1.x, point1.y + delta.height);
+ p1.y -= p1.y % 8;
+ p2 = new Point(point2.x, point2.y + delta.height);
+ p2.y -= p2.y % 8;
+ } else {
+ p1 = new Point(point1.x + delta.width, point1.y);
+ p1.x -= p1.x % 8;
+ p2 = new Point(point2.x + delta.width, point2.y);
+ p2.x -= p2.x % 8;
+ if (index1 == 1 && p1.x < list.getPoint(0).x + 5) {
+ p1.x = list.getPoint(0).x + 5;
+ p2.x = list.getPoint(0).x + 5;
+ }
+ if (index2 == list.size() - 2
+ && p1.x > list.getPoint(list.size() - 1).x - 5) {
+ p1.x = list.getPoint(list.size() - 1).x - 5;
+ p2.x = list.getPoint(list.size() - 1).x - 5;
+ }
+
+ }
+ list.removePoint(index1);
+ list.removePoint(index1);
+ list.insertPoint(p1, index1);
+ list.insertPoint(p2, index2);
+
+ getConnection().setPoints(list);
+ ((ConnectionFigure) getConnection()).setManual(true);
+
+ return true;
+ }
+
+ protected boolean handleButtonUp(int button) {
+ if (stateTransition(STATE_DRAG_IN_PROGRESS, STATE_TERMINAL)) {
+ first = true;
+
+ ((LinkEditPart) getConnectionEditPart()).save();
+ }
+ return true;
+ }
+
+ protected Point getLocation() {
+ Point p = new Point(getCurrentInput().getMouseLocation());
+ if (getFlag(1)) {
+ p.x -= p.x % 8;
+ p.y -= p.y % 8;
+ }
+ return p;
+ }
+
+ protected Point getStartLocation() {
+ Point p = super.getStartLocation().getCopy();
+ if (getFlag(1)) {
+ p.x -= p.x % 8;
+ p.y -= p.y % 8;
+ }
+ return p;
+ }
+
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesConnectionHandle.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesConnectionHandle.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PagesConnectionHandle.java 2008-05-27
15:43:12 UTC (rev 8374)
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * 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 org.eclipse.draw2d.Connection;
+import org.eclipse.draw2d.ConnectionLocator;
+import org.eclipse.draw2d.Cursors;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.DragTracker;
+import org.eclipse.gef.handles.SquareHandle;
+import org.eclipse.gef.tools.ConnectionEndpointTracker;
+
+/**
+ * A handle used on a {@link Connection}.
+ */
+public class PagesConnectionHandle extends SquareHandle implements PropertyChangeListener
{
+ private boolean vertical = false;
+ private int index;
+
+ public PagesConnectionHandle(ConnectionEditPart owner, boolean vertical,
+ int index) {
+ this.vertical = vertical;
+ this.index = index;
+ if (vertical)
+ setCursor(Cursors.SIZEN);
+ else
+ setCursor(Cursors.SIZEW);
+
+ setOwner(owner);
+ setLocator(new JSFMidpointLocator(getConnection(), index));
+ }
+
+ protected DragTracker createDragTracker() {
+ ConnectionEndpointTracker tracker;
+ tracker = new PagesConnectionDragTracker((ConnectionEditPart) getOwner(),
+ vertical, index);
+ return tracker;
+ }
+
+ /**
+ * Adds this as a {@link org.eclipse.draw2d.FigureListener} to the owner's
+ * {@link org.eclipse.draw2d.Figure}.
+ */
+ public void addNotify() {
+ super.addNotify();
+ getConnection().addPropertyChangeListener(Connection.PROPERTY_POINTS,
+ this);
+ }
+
+ /**
+ * Returns the Connection this handle is on.
+ */
+ public Connection getConnection() {
+ return (Connection) getOwnerFigure();
+ }
+
+ protected boolean isVertical() {
+ return vertical;
+ }
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getPropertyName().equals(Connection.PROPERTY_POINTS))
+ revalidate();
+ }
+
+ public void removeNotify() {
+ getConnection().removePropertyChangeListener(
+ Connection.PROPERTY_POINTS, this);
+ super.removeNotify();
+ }
+
+ class JSFMidpointLocator extends ConnectionLocator {
+ private int index;
+
+ public JSFMidpointLocator(Connection c, int i) {
+ super(c);
+ index = i;
+ }
+
+ protected int getIndex() {
+ return index;
+ }
+
+ protected Point getReferencePoint() {
+ Connection conn = super.getConnection();
+ if (getIndex() + 1 > conn.getPoints().size() - 2) {
+ PagesConnectionHandle.this.setVisible(false);
+ return new Point(0, 0);
+ }
+ Point p = Point.SINGLETON;
+ Point p1 = conn.getPoints().getPoint(getIndex());
+ Point p2 = conn.getPoints().getPoint(getIndex() + 1);
+ conn.translateToAbsolute(p1);
+ conn.translateToAbsolute(p2);
+ p.x = (p2.x - p1.x) / 2 + p1.x;
+ p.y = (p2.y - p1.y) / 2 + p1.y;
+ return p;
+ }
+ }
+
+}
\ No newline at end of file
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/xpl/PagesConnectionRouter.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/xpl/PagesConnectionRouter.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/xpl/PagesConnectionRouter.java 2008-05-27
15:43:12 UTC (rev 8374)
@@ -0,0 +1,482 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation - initial API and implementation
+ * Exadel, Inc.
+ * Red Hat, Inc.
+ *******************************************************************************/
+package org.jboss.tools.seam.ui.pages.editor.edit.xpl;
+
+import java.util.*;
+
+import org.eclipse.draw2d.AbstractRouter;
+import org.eclipse.draw2d.Connection;
+import org.eclipse.draw2d.IFigure;
+//import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.geometry.*;
+import org.jboss.tools.seam.ui.pages.editor.figures.ConnectionFigure;
+import org.jboss.tools.seam.ui.pages.editor.figures.PageFigure;
+
+
+final public class PagesConnectionRouter
+ extends AbstractRouter
+{
+
+private Set<Integer> rowsUsed = new HashSet<Integer>();
+private Set<Integer> colsUsed = new HashSet<Integer>();
+
+private final static int STEP = 8;
+
+private final static int STATUS_NOTHING = 0;
+private final static int STATUS_HOLD = 2;
+private final static int STATUS_SHIFT = 3;
+
+private Map<Connection,ReservedInfo> reservedInfo = new
HashMap<Connection,ReservedInfo>();
+
+private class ReservedInfo {
+ public List<Integer> reservedRows = new ArrayList<Integer>(2);
+ public List<Integer> reservedCols = new ArrayList<Integer>(2);
+}
+
+private static Ray UP = new Ray(0,-1),
+ DOWN = new Ray(0,1),
+ LEFT = new Ray(-1,0),
+ RIGHT = new Ray(1,0);
+
+
+public void invalidate(Connection connection) {
+ removeReservedLines(connection);
+}
+
+private int getColumnNear(Connection conn, int r, int n, int x, boolean flag){
+ int index=0, size=0;
+ int min = Math.min(n,x),
+ max = Math.max(n,x);
+ if (min > r){
+ max = min;
+ min = r - (min-r);
+ }
+ if (max < r){
+ min = max;
+ max = r + (r-max);
+ }
+ if(flag){
+ if(conn.getSourceAnchor().getOwner() != null){
+ IFigure fig = conn.getSourceAnchor().getOwner();
+ PageFigure group=null;
+ if(fig instanceof PageFigure)group = (PageFigure)fig;
+ else if(fig instanceof PageFigure)group = (PageFigure)fig.getParent();
+ if(group != null){
+ index =
group.page.getOutputLinks().indexOf(((ConnectionFigure)conn).getLinkModel());
+ size = group.page.getOutputLinks().size();
+ }else flag = false;
+ }else flag = false;
+ }
+ if(flag){
+ int value = min+100+(size-index)*STEP-size/2*STEP;
+ if(value <= min) return min+STEP;
+ if(value >= max) return max-STEP;
+ return value;
+ }
+ int proximity = 0;
+ int direction = -1;
+ if (r%2 == 1)
+ r--;
+ Integer i;
+ while (proximity < r){
+ i = Integer.valueOf(r + proximity*direction);
+ if (!colsUsed.contains(i)){
+ colsUsed.add(i);
+ reserveColumn(conn, i);
+ return i.intValue();
+ }
+ int j = i.intValue();
+ if (j <= min)
+ return j+STEP;
+ if (j >= max)
+ return j-STEP;
+ if (direction == 1)
+ direction = -1;
+ else {
+ direction = 1;
+ proximity += STEP;
+ }
+ }
+ return r;
+}
+
+protected Ray getDirection(Rectangle r, Point p){
+ int i, distance = Math.abs(r.x - p.x);
+ Ray direction;
+
+ direction = LEFT;
+
+ i = Math.abs(r.y - p.y);
+ if (i <= distance){
+ distance = i;
+ direction = UP;
+ }
+
+ i = Math.abs(r.bottom()-p.y);
+ if (i <= distance){
+ distance = i;
+ direction = DOWN;
+ }
+
+ i = Math.abs(r.right()-p.x);
+ if (i < distance){
+ distance = i;
+ direction = RIGHT;
+ }
+
+ return direction;
+}
+
+protected Ray getEndDirection(Connection conn){
+ return LEFT;
+}
+
+protected int getRowNear(Connection connection, int r, int n, int x){
+ int min = Math.min(n,x),
+ max = Math.max(n,x);
+ if (min > r){
+ max = min;
+ min = r - (min-r);
+ }
+ if (max < r){
+ min = max;
+ max = r + (r-max);
+ }
+
+ int proximity = 0;
+ int direction = -1;
+ if (r%2 == 1)
+ r--;
+ Integer i;
+ while (proximity < r){
+ i = Integer.valueOf(r + proximity*direction);
+ if (!rowsUsed.contains(i)){
+ rowsUsed.add(i);
+ reserveRow(connection, i);
+ return i.intValue();
+ }
+ int j = i.intValue();
+ if (j <= min)
+ return j+STEP;
+ if (j >= max)
+ return j-STEP;
+ if (direction == 1)
+ direction = -1;
+ else {
+ direction = 1;
+ proximity += STEP;
+ }
+ }
+ return r;
+}
+protected Ray getStartDirection(Connection conn){
+ return RIGHT;
+}
+
+protected void processPositions(Ray start, Ray end, List positions,
+ boolean horizontal, Connection conn) {
+ removeReservedLines(conn);
+
+ int pos[] = new int[positions.size()+2];
+ if (horizontal)
+ pos[0] = start.x;
+ else
+ pos[0] = start.y;
+ int i;
+ for (i=0; i< positions.size(); i++){
+ pos[i+1] = ((Integer)positions.get(i)).intValue();
+ }
+ if (horizontal == (positions.size()%2 == 1))
+ pos[++i] = end.x;
+ else
+ pos[++i] = end.y;
+
+ PointList points = new PointList();
+ points.addPoint(new Point(start.x, start.y));
+ Point p;
+ int current, prev, min, max;
+ boolean adjust;
+ for (i=2; i < pos.length - 1; i++){
+ horizontal = !horizontal;
+ prev = pos[i-1];
+ current = pos[i];
+
+ adjust = (i != pos.length-2);
+ if (horizontal){
+ if (adjust){
+ min = pos[i-2];
+ max = pos[i+2];
+ pos[i] = current = getRowNear(conn,current,min,max);
+ current -= current%STEP;
+ pos[i] -= pos[i]%STEP;
+ }
+ p = new Point(prev,current);
+ }
+ else{
+ if (adjust){
+ min = pos[i-2];
+ max = pos[i+2];
+ boolean flag;
+ if(i == 2 && pos.length == 5){
+ flag = true;
+ }else flag = false;
+ pos[i] = current = getColumnNear(conn, current,min,max,flag);
+ current -= current%STEP;
+ pos[i] -= pos[i]%STEP;
+ }
+ p = new Point(current,prev);
+ }
+ points.addPoint(p);
+ }
+ points.addPoint(new Point(end.x, end.y));
+ conn.setPoints(points);
+}
+
+/**
+ * Removes the given connection from the map of constraints.
+ *
+ * @param connection The connection to remove.
+ */
+public void remove(Connection connection){
+ removeReservedLines(connection);
+}
+
+protected void removeReservedLines(Connection connection) {
+ ReservedInfo rInfo = (ReservedInfo) reservedInfo.get(connection);
+ if (rInfo == null) return;
+
+ for (int i = 0; i < rInfo.reservedRows.size(); i++){
+ rowsUsed.remove(rInfo.reservedRows.get(i));
+ }
+ for (int i = 0; i < rInfo.reservedCols.size(); i++){
+ colsUsed.remove(rInfo.reservedCols.get(i));
+ }
+ reservedInfo.remove(connection);
+}
+
+protected void reserveColumn(Connection connection, Integer column) {
+ ReservedInfo info = (ReservedInfo) reservedInfo.get(connection);
+ if (info == null) {
+ info = new ReservedInfo();
+ reservedInfo.put(connection, info);
+ }
+ info.reservedCols.add(column);
+}
+
+protected void reserveRow(Connection connection, Integer row) {
+ ReservedInfo info = (ReservedInfo) reservedInfo.get(connection);
+ if (info == null) {
+ info = new ReservedInfo();
+ reservedInfo.put(connection, info);
+ }
+ info.reservedRows.add(row);
+}
+
+/**
+ * Routes the {@link Connection}.
+ *
+ * @param conn The {@link Connection} to route.
+ */
+public void route(Connection conn) {
+ if ((conn.getSourceAnchor() == null) || (conn.getTargetAnchor() == null)){
+ return;
+ }
+ if(((ConnectionFigure)conn).getLinkModel() != null &&
((ConnectionFigure)conn).getLinkModel().isShortcut()){
+ Point startPoint = getStartPoint(conn);
+ conn.translateToRelative(startPoint);
+ List<Integer> positions = new ArrayList<Integer>(5);
+ Ray start = new Ray(startPoint);
+ positions.add(Integer.valueOf(start.y));
+
+ Point endPoint = new Point(startPoint.x+18, startPoint.y);
+ Ray end = new Ray(endPoint);
+ processPositions(start, end, positions,true, conn);
+ return;
+ }
+
+// if(((ConnectionFigure)conn).isManual()){
+// if(conn.getPoints().size() < 4){
+// PointList list = ((ConnectionFigure)conn).getLinkModel().getPointList();
+// ((ConnectionFigure)conn).setOldPoints(list.getFirstPoint(), list.getLastPoint());
+// conn.setPoints(list);
+// }
+// if(hold((ConnectionFigure)conn)) return;
+// else{
+// ((ConnectionFigure)conn).setManual(false);
+// ((ConnectionFigure)conn).clear();
+// }
+// }
+ int i;
+ Point startPoint = getStartPoint(conn);
+ conn.translateToRelative(startPoint);
+
+ Point endPoint = getEndPoint(conn);
+ conn.translateToRelative(endPoint);
+
+ Ray start = new Ray(startPoint);
+ Ray end = new Ray(endPoint);
+ Ray average = start.getAveraged(end);
+
+ Ray direction = new Ray(start, end);
+ Ray startNormal = getStartDirection(conn);
+ Ray endNormal = getEndDirection(conn);
+
+ List<Integer> positions = new ArrayList<Integer>(5);
+ boolean horizontal = true;
+ // start horizontal segment
+ positions.add(Integer.valueOf(start.y));
+ horizontal = !horizontal;
+
+ if((start.x > (end.x+20)) && (Math.abs(end.y-start.y) < 100)){
+ i = startNormal.similarity(start.getAdded(startNormal.getScaled(10)));
+ positions.add(Integer.valueOf(i));
+ horizontal = !horizontal;
+
+ if(conn.getSourceAnchor().getOwner() == null){
+ i = average.y;
+ }else{
+ Rectangle rec = conn.getSourceAnchor().getOwner().getBounds();
+
+ i = rec.y+rec.height+8;
+ }
+ i -= i%STEP;
+ positions.add(Integer.valueOf(i));
+ horizontal = !horizontal;
+
+ i = endNormal.similarity(end.getAdded(endNormal.getScaled(10)));
+ i -= i%STEP;
+ positions.add(Integer.valueOf(i));
+ horizontal = !horizontal;
+ }else{
+ // vertical segment
+ if (startNormal.dotProduct(direction) < STEP*2){
+ i = startNormal.similarity(start.getAdded(startNormal.getScaled(10)));
+ i -= i%STEP;
+ positions.add(Integer.valueOf(i));
+ horizontal = !horizontal;
+ }
+
+ // middle vertical or horizontal segment
+ if (horizontal) i = average.y;
+ else i = average.x;
+ i -= i%STEP;
+ positions.add(Integer.valueOf(i));
+ horizontal = !horizontal;
+
+ // vertical segment
+ if (startNormal.dotProduct(direction) < STEP*2){
+ i = endNormal.similarity(end.getAdded(endNormal.getScaled(10)));
+ i -= i%STEP;
+ positions.add(Integer.valueOf(i));
+ horizontal = !horizontal;
+ }
+ }
+ // end horizontal segment
+ positions.add(Integer.valueOf(end.y));
+
+ processPositions(start, end, positions,true, conn);
+ ((ConnectionFigure)conn).setOldPoints(startPoint, endPoint);
+}
+
+private boolean hold(ConnectionFigure conn){
+ Point p1,p2;
+
+ Point startPoint = getStartPoint(conn);
+ conn.translateToRelative(startPoint);
+
+ Point endPoint = getEndPoint(conn);
+ conn.translateToRelative(endPoint);
+
+ int status = check(conn);
+ if(status == STATUS_NOTHING) return true;
+ else if(status == STATUS_SHIFT){
+ shift(conn);
+ conn.setOldPoints(startPoint, endPoint);
+ conn.save();
+ return true;
+ }
+
+ PointList list = conn.getPoints();
+
+ list.removePoint(0);
+ list.insertPoint(startPoint, 0);
+
+ list.removePoint(list.size()-1);
+ list.addPoint(endPoint);
+
+ if(list.size() > 2){
+ p1 = list.getPoint(1);
+
+ p1.y = startPoint.y;
+ if(p1.x <= startPoint.x) return false;
+
+ p2 = list.getPoint(list.size()-2);
+
+ p2.y = endPoint.y;
+ if(p2.x >= endPoint.x) return false;
+
+ list.removePoint(1);
+ list.insertPoint(p1, 1);
+ int index = list.size()-2;
+
+ list.removePoint(index);
+ list.insertPoint(p2, index);
+ }
+ conn.setPoints(list);
+ conn.setOldPoints(startPoint, endPoint);
+ conn.save();
+ return true;
+}
+
+private void shift(ConnectionFigure conn){
+ Point startPoint = getStartPoint(conn);
+ conn.translateToRelative(startPoint);
+
+ Point oldStartPoint = conn.getOldStartPoint();
+
+ Point shiftPoint = new Point(startPoint.x-oldStartPoint.x,
startPoint.y-oldStartPoint.y);
+ Point point;
+
+ PointList list = conn.getPoints();
+ if(list.getPoint(0).x == startPoint.x && list.getPoint(0).y == startPoint.y)
return;
+
+ for(int i=0;i<list.size();i++){
+ point = list.getPoint(i);
+ point.x += shiftPoint.x;
+ point.y += shiftPoint.y;
+ list.removePoint(i);
+ list.insertPoint(point, i);
+ }
+ conn.setPoints(list);
+}
+
+private int check(ConnectionFigure conn){
+ Point startPoint = getStartPoint(conn);
+ conn.translateToRelative(startPoint);
+
+ Point endPoint = getEndPoint(conn);
+ conn.translateToRelative(endPoint);
+
+ Point oldStartPoint = ((ConnectionFigure)conn).getOldStartPoint();
+
+ Point oldEndPoint = ((ConnectionFigure)conn).getOldEndPoint();
+
+ if(startPoint.x == oldStartPoint.x && startPoint.y == oldStartPoint.y &&
endPoint.x == oldEndPoint.x && endPoint.y == oldEndPoint.y)
+ return STATUS_NOTHING;
+
+ if((startPoint.x - oldStartPoint.x) == (endPoint.x - oldEndPoint.x) &&
(startPoint.y - oldStartPoint.y) == (endPoint.y - oldEndPoint.y)){
+ return STATUS_SHIFT;
+ }
+ return STATUS_HOLD;
+}
+}
\ 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/ConnectionFigure.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ConnectionFigure.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ConnectionFigure.java 2008-05-27
15:43:12 UTC (rev 8374)
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * 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.AnchorListener;
+import org.eclipse.draw2d.Connection;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PointList;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.Link;
+import org.jboss.tools.seam.ui.pages.editor.edit.LinkEditPart;
+
+
+public class ConnectionFigure extends PolylineConnection implements Connection,
AnchorListener{
+ private boolean manual = false;
+ private LinkEditPart editPart = null;
+ private Link link = null;
+ private int oldStartPointX = 0, oldStartPointY = 0, oldEndPointX = 0,
+ oldEndPointY = 0;
+
+ public ConnectionFigure(LinkEditPart part) {
+ super();
+ editPart = part;
+ link = part.getLinkModel();
+ }
+
+ public Link getLinkModel() {
+ return link;
+ }
+
+ public ConnectionFigure() {
+ super();
+ }
+
+ public void refreshFont() {
+ if (getChildren().size() > 0 && getChildren().get(0) instanceof Label) {
+ Label label = (Label) getChildren().get(0);
+// label.setFont(editPart.getLinkModel().getJSFModel().getOptions()
+// .getLinkPathFont());
+ label.setSize(label.getPreferredSize());
+ }
+ }
+
+ public void setOldPoints(Point start, Point end) {
+ oldStartPointX = start.x;
+ oldStartPointY = start.y;
+ oldEndPointX = end.x;
+ oldEndPointY = end.y;
+ }
+
+ public Point getOldStartPoint() {
+ return new Point(oldStartPointX, oldStartPointY);
+ }
+
+ public Point getOldEndPoint() {
+ return new Point(oldEndPointX, oldEndPointY);
+ }
+
+ public void setManual(boolean flag) {
+ manual = flag;
+ }
+
+ public boolean isManual() {
+ return manual;
+ }
+
+ public void save() {
+ if (editPart != null)
+ editPart.save();
+ }
+
+ public void clear() {
+ if (editPart != null)
+ editPart.clear();
+ }
+
+ PointList points;
+ Point point;
+ Point beg = new Point(0, 0), end = new Point(0, 0);
+ Point corner = new Point(0, 0);
+ boolean horiz;
+
+ protected void outlineShape(Graphics g) {
+ points = getPoints();
+ point = points.getPoint(0);
+ beg.x = point.x;
+ beg.y = point.y;
+
+ if (points.getFirstPoint().y == points.getLastPoint().y) {
+ super.outlineShape(g);
+ return;
+ }
+
+ for (int i = 1; i < points.size(); i++) {
+ point = points.getPoint(i);
+ end.x = point.x;
+ end.y = point.y;
+
+ if (beg.y == end.y)
+ horiz = true;
+ else
+ horiz = false;
+
+ if (i != 1) {
+ if (horiz) {
+ if (end.x > beg.x) {
+ corner.x = beg.x + 1;
+ beg.x += 2;
+ } else {
+ corner.x = beg.x - 1;
+ beg.x -= 2;
+ }
+ } else {
+ if (end.y > beg.y) {
+ corner.y = beg.y + 1;
+ beg.y += 2;
+ } else {
+ corner.y = beg.y - 1;
+ beg.y -= 2;
+ }
+ }
+ }
+ if (corner.x != 0)
+ g.drawLine(corner, corner);
+ corner.x = 0;
+
+ if (i != points.size() - 1) {
+ if (horiz) {
+ if (end.x > beg.x) {
+ corner.x = end.x - 1;
+ end.x -= 2;
+
+ } else {
+ corner.x = end.x + 1;
+ end.x += 2;
+ }
+ } else {
+ if (end.y > beg.y) {
+ corner.y = end.y - 1;
+ end.y -= 2;
+ } else {
+ corner.y = end.y + 1;
+ end.y += 2;
+ }
+ }
+ }
+
+ g.drawLine(beg, end);
+ point = points.getPoint(i);
+ beg.x = point.x;
+ beg.y = point.y;
+ }
+ }
+
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/FigureFactory.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/FigureFactory.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/FigureFactory.java 2008-05-27
15:43:12 UTC (rev 8374)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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.ManhattanConnectionRouter;
+import org.eclipse.swt.graphics.Color;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.Link;
+import org.jboss.tools.seam.ui.pages.editor.edit.LinkEditPart;
+import org.jboss.tools.seam.ui.pages.editor.edit.xpl.PagesConnectionRouter;
+
+public class FigureFactory {
+ public static final Color normalColor = new Color(null, 0xb5, 0xb5, 0xb5);
+ public static final Color selectedColor = new Color(null, 0x44, 0xa9, 0xf3);
+ public static final Color highlightColor = ColorConstants.black;
+
+ public static ConnectionFigure createNewBendableWire(LinkEditPart part,
+ Link link) {
+ ConnectionFigure conn = new ConnectionFigure(part);
+ conn.setForegroundColor(normalColor);
+ return conn;
+ }
+
+ public static ConnectionFigure createNewLink(Link link) {
+
+ ConnectionFigure conn = new ConnectionFigure();
+ conn.setConnectionRouter(new PagesConnectionRouter());
+ conn.setForegroundColor(selectedColor);
+
+ return conn;
+ }
+}
\ 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/NodeFigure.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/NodeFigure.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/NodeFigure.java 2008-05-27
15:43:12 UTC (rev 8374)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.gef.figures.xpl.BaseNodeFigure;
+import org.jboss.tools.common.model.ui.ModelUIImages;
+
+public class NodeFigure extends
+ BaseNodeFigure {
+ public static final Color blackColor = new Color(null, 0x00, 0x00, 0x00);
+
+ public static final Color whiteColor = new Color(null, 0xff, 0xff, 0xff);
+
+ public static final Color orangeColor = new Color(null, 0xff, 0xea, 0x82);
+
+ public static final Color yellowColor = new Color(null, 0xff, 0xf6, 0xcb);
+
+ public static final Color brownColor = new Color(null, 0xf0, 0xe8, 0xbf);
+
+ public static final Color lightGrayColor = new Color(null, 0xf1, 0xf1, 0xf1);
+
+ public static final Color darkGrayColor = new Color(null, 0xb3, 0xb3, 0xb3);
+
+ public static final Color lightBlueColor = new Color(null, 0xd4, 0xe6, 0xff);
+
+ public static final Color darkBlueColor = new Color(null, 0x97, 0xc4, 0xff);
+
+ public static final Color pattSelected = new Color(null, 0xc6, 0xda, 0xe8);
+
+ public static final Color pattBorder = new Color(null, 0x3e, 0x75, 0x99);
+
+ public static final Color errorColor = new Color(null, 0xff, 0xb9, 0xb9);
+
+ public static final Color errorSelected = new Color(null, 0xff, 0xa2, 0xa2);
+
+ public static final Color errorBorder = new Color(null, 0xc5, 0x63, 0x62);
+
+ public static final Color selectedColor = new Color(null, 0xf0, 0xe8, 0xbf);
+
+ public static final Color borderColor = new Color(null, 0x86, 0x7d, 0x51);
+
+ public final static Color ghostFillColor = new Color(null, 31, 31, 31);
+
+ public static final Image errorIcon = ModelUIImages
+ .getImage("error_co.gif");
+
+ public static final int LINK_HEIGHT = 16;
+}
\ 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/PageFeedbackFigure.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/PageFeedbackFigure.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/PageFeedbackFigure.java 2008-05-27
15:43:12 UTC (rev 8374)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * 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.Graphics;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+/**
+ * @author Daniel
+ *
+ */
+public class PageFeedbackFigure extends PageFigure {
+ public PageFeedbackFigure(){
+ super(null);
+ }
+
+ protected void paintFigure(Graphics g) {
+ g.setXORMode(true);
+ g.setForegroundColor(whiteColor);
+ g.setBackgroundColor(ghostFillColor);
+
+ Rectangle r = getBounds().getCopy();
+ g.translate(r.getLocation());
+ int start=0;
+
+ g.fillRectangle(start+1,1,22,19);
+
+ g.fillPolygon(fillPointlist);
+ }
+
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/PageFigure.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/PageFigure.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/PageFigure.java 2008-05-27
15:43:12 UTC (rev 8374)
@@ -0,0 +1,322 @@
+/*******************************************************************************
+ * 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.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+
+import org.eclipse.draw2d.*;
+import org.eclipse.draw2d.geometry.*;
+
+import org.eclipse.gef.handles.HandleBounds;
+
+import org.jboss.tools.common.gef.GEFGraphicalViewer;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.Page;
+import org.jboss.tools.seam.ui.pages.editor.edit.PageEditPart;
+import org.jboss.tools.seam.ui.pages.editor.figures.xpl.FixedConnectionAnchor;
+
+public class PageFigure extends NodeFigure implements HandleBounds,
+ FigureListener {
+ private static final Dimension SIZE = new Dimension(56, 100);
+
+ private Image icon = null;
+
+ public Page page;
+
+ private Label label = null;
+
+ PointList fillPointlist, fill2Pointlist, shadowPointlist, shadow2Pointlist;
+
+ String path;
+
+ PageEditPart editPart;
+
+ public void setGroupEditPart(PageEditPart part) {
+ editPart = part;
+ }
+
+ public void setBounds(Rectangle rect) {
+ super.setBounds(rect);
+ resizeFigure();
+ }
+
+ public void setConstraint(IFigure child, Object constraint) {
+ super.setConstraint(child, constraint);
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ if (label != null) {
+ label.setText(path);
+ label.setSize(label.getPreferredSize());
+ }
+ }
+
+ public void refreshFont() {
+ if (label != null) {
+ //label.setFont(group.getJSFModel().getOptions().getViewPathFont());
+ label.setSize(label.getPreferredSize());
+ label.setLocation(new Point(getLocation().x - 5, getLocation().y
+ - (12 + 10)));
+ }
+ }
+
+ public void setIcon(Image i) {
+ //icon = PrintIconHelper.getPrintImage(i);
+ }
+
+ public void addNotify() {
+ if (page == null)
+ return;
+ label = new Label(path);
+ //label.setFont(group.getJSFModel().getOptions().getViewPathFont());
+ getParent().add(label);
+ label.setForegroundColor(ColorConstants.black);
+ label.setOpaque(false);
+ label.setText(path);
+ label.setVisible(true);
+ label.setSize(label.getPreferredSize());
+ label.setLocation(new Point(getLocation().x - 5, getLocation().y
+ - (12 + 10)));
+ //label.addMouseListener(this);
+ }
+
+ public void removeNotify() {
+ if (page == null)
+ return;
+ //label.removeMouseListener(this);
+ getParent().remove(label);
+ }
+
+ public void figureMoved(IFigure source) {
+ if (page != null)
+ label.setLocation(new Point(getLocation().x - 5,
+ getLocation().y - 20));
+ }
+
+ public void init(int number) {
+ FixedConnectionAnchor c;
+ if (number == 0)
+ number = 1;
+ for (int i = 0; i < number; i++) {
+ c = new FixedConnectionAnchor(this);
+ c.offsetV = 32 + LINK_HEIGHT * i;
+ c.leftToRight = false;
+ connectionAnchors.put((i + 1) + "_OUT", c);
+ outputConnectionAnchors.addElement(c);
+ }
+ }
+
+ public void addConnectionAnchor(int number) {
+ FixedConnectionAnchor c;
+ if (number == 1)
+ return;
+ c = new FixedConnectionAnchor(this);
+ c.offsetV = 32 + LINK_HEIGHT * (number - 1);
+ // c.offsetH = -1;
+ c.leftToRight = false;
+ connectionAnchors.put(number + "_OUT", c);
+ outputConnectionAnchors.addElement(c);
+ }
+
+ public void removeConnectionAnchor() {
+ if (outputConnectionAnchors.size() == 1)
+ return;
+ outputConnectionAnchors.remove(outputConnectionAnchors.size() - 1);
+ }
+
+ public void removeAllConnectionAnchor() {
+ outputConnectionAnchors.removeAllElements();
+ }
+
+ public PageFigure(Page group) {
+ this.page = group;
+
+ if (group != null) {
+// setIcon(group.getImage());
+// setPath(group.getVisiblePath());
+ }
+
+ setOpaque(false);
+ setLayoutManager(new XYLayout());
+
+ resizeFigure();
+ addFigureListener(this);
+ //addKeyListener(this);
+ setBorder(new GroupBorder(blackColor));
+
+ if (group != null) {
+ FixedConnectionAnchor c;
+ c = new FixedConnectionAnchor(this);
+ c.offsetV = 8;
+ c.offsetH = -1;
+ connectionAnchors.put("1_IN", c);
+ inputConnectionAnchors.addElement(c);
+
+ }
+ }
+
+ /**
+ * @see org.eclipse.gef.handles.HandleBounds#getHandleBounds()
+ */
+ public Rectangle getHandleBounds() {
+ return getBounds().getCropped(new Insets(0, 0, 0, 0));
+ }
+
+ /**
+ * @see org.eclipse.draw2d.Figure#getPreferredSize(int, int)
+ */
+ public Dimension getPreferredSize(int wHint, int hHint) {
+ return SIZE;
+ }
+
+ int width, height;
+
+ private void resizeFigure() {
+ if (width == getSize().width && height == getSize().height)
+ return;
+
+ int start = 0;
+ width = getSize().width - 1;
+ height = getSize().height - 1;
+
+
+ fillPointlist = new PointList();
+
+ fillPointlist.addPoint(start, 20);
+ fillPointlist.addPoint(start + 23, 20);
+ fillPointlist.addPoint(start + 23, 0);
+ fillPointlist.addPoint(width - 15, 0);
+ fillPointlist.addPoint(width - 1, 14);
+ fillPointlist.addPoint(width - 1, height - 1);
+ fillPointlist.addPoint(start, height - 1);
+
+
+
+ shadowPointlist = new PointList();
+
+ shadowPointlist.addPoint(width - 15, 0);
+ shadowPointlist.addPoint(width - 14, 4);
+ shadowPointlist.addPoint(width - 15, 7);
+ shadowPointlist.addPoint(width - 18, 10);
+ shadowPointlist.addPoint(width - 1, 14);
+
+ shadowPointlist.addPoint(width - 9, 14);
+ shadowPointlist.addPoint(width - 16, 13);
+
+ shadowPointlist.addPoint(width - 21, 11);
+ shadowPointlist.addPoint(width - 18, 8);
+ shadowPointlist.addPoint(width - 16, 4);
+
+ shadow2Pointlist = new PointList();
+
+ shadow2Pointlist.addPoint(width - 15, 0);
+ shadow2Pointlist.addPoint(width - 1, 14);
+ shadow2Pointlist.addPoint(width - 3, 14);
+ shadow2Pointlist.addPoint(width - 15, 2);
+ }
+
+ /**
+ * @see org.eclipse.draw2d.Figure#paintFigure(Graphics)
+ */
+ protected void paintFigure(Graphics g) {
+ Rectangle r = getBounds().getCopy();
+ g.translate(r.getLocation());
+
+ int height = r.height - 1;
+ int start = 0;
+
+
+ g.setBackgroundColor(whiteColor);
+
+ g.fillRectangle(start + 1, 1, 22, 19);
+
+ if (icon != null)
+ g.drawImage(icon, start + 4, 2);
+
+
+ if (page != null /*&& group.isConfirmed()*/) {
+ g.setBackgroundColor(yellowColor);
+ } else {
+ g.setBackgroundColor(lightGrayColor);
+ }
+
+ g.fillPolygon(fillPointlist);
+
+
+ if (page != null /*&& group.isConfirmed()*/) {
+ g.setBackgroundColor(orangeColor);
+ } else {
+ g.setBackgroundColor(lightGrayColor);
+ }
+
+ g.fillPolygon(shadowPointlist);
+ g.fillPolygon(shadow2Pointlist);
+ }
+
+ class GroupBorder extends LineBorder {
+ public GroupBorder(Color color) {
+ super(color);
+ }
+
+ public void paint(IFigure figure, Graphics graphics, Insets insets) {
+ Rectangle r = getPaintRectangle(figure, insets).getCopy();
+ graphics.translate(r.getLocation());
+ int start = 0;
+ int width = r.width - 1;
+ int height = r.height - 1;
+
+ if (page != null /*&& group.isConfirmed()*/)
+ graphics.setForegroundColor(blackColor);
+ else
+ graphics.setForegroundColor(darkGrayColor);
+
+ graphics.drawLine(start + 1, 0, width - 15, 0);
+ graphics.drawLine(start, 1, start, height - 2);
+ graphics.drawLine(start + 1, height - 1, width - 2, height - 1);
+ graphics.drawLine(width - 1, 14, width - 1, height - 2);
+ graphics.drawLine(width - 15, 0, width - 1, 14);
+
+ graphics.drawLine(start, 1, start + 1, 0);
+ graphics.drawLine(start, height - 2, start + 1, height - 1);
+ graphics.drawLine(width - 2, height - 1, width - 1, height - 2);
+
+ graphics.drawLine(width - 15, 0, width - 14, 4);
+ graphics.drawLine(width - 14, 4, width - 15, 7);
+ graphics.drawLine(width - 15, 7, width - 18, 10);
+
+ graphics.drawLine(width - 18, 10, width - 1, 14);
+
+ graphics.drawLine(start + 23, 0, start + 23, 19);
+ graphics.drawLine(start, 20, start + 22, 20);
+ graphics.drawLine(start + 22, 20, start + 23, 19);
+
+
+ if (page != null /*&& group.isConfirmed()*/)
+ graphics.setForegroundColor(borderColor);
+ else
+ graphics.setForegroundColor(darkGrayColor);
+
+ }
+
+ public void mouseDoubleClicked(MouseEvent me) {
+ }
+
+ public void mousePressed(MouseEvent me) {
+ if (me.button == 3) {
+ ((GEFGraphicalViewer) editPart.getViewer()).setNoDeselect();
+ editPart.getViewer().select(editPart);
+ }
+ }
+
+
+}
+}
\ 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/xpl/FixedConnectionAnchor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/xpl/FixedConnectionAnchor.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/xpl/FixedConnectionAnchor.java 2008-05-27
15:43:12 UTC (rev 8374)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation - initial API and implementation
+ * Exadel, Inc.
+ * Red Hat, Inc.
+ *******************************************************************************/
+package org.jboss.tools.seam.ui.pages.editor.figures.xpl;
+
+import org.eclipse.draw2d.*;
+import org.eclipse.draw2d.geometry.*;
+
+public class FixedConnectionAnchor extends AbstractConnectionAnchor {
+
+ public boolean leftToRight = true;
+
+ public int offsetH;
+
+ public int offsetV;
+
+ public boolean topDown = true;
+
+ public FixedConnectionAnchor(IFigure owner) {
+ super(owner);
+ }
+
+ /**
+ * @see org.eclipse.draw2d.AbstractConnectionAnchor#ancestorMoved(IFigure)
+ */
+ public void ancestorMoved(IFigure figure) {
+ if (figure instanceof ScalableFreeformLayeredPane)
+ return;
+ super.ancestorMoved(figure);
+ }
+
+ public Point getLocation(Point reference) {
+ Rectangle r = getOwner().getBounds();
+ int x, y;
+ if (topDown)
+ y = r.y + offsetV;
+ else
+ y = r.bottom() - 1 - offsetV;
+
+ if (leftToRight)
+ x = r.x + offsetH;
+ else
+ x = r.right() - 1 - offsetH;
+
+ Point p = new PrecisionPoint(x, y);
+ getOwner().translateToAbsolute(p);
+ return p;
+ }
+
+ public Point getReferencePoint() {
+ return getLocation(null);
+ }
+
+}
\ No newline at end of file