Author: dazarov
Date: 2008-05-28 12:01:26 -0400 (Wed, 28 May 2008)
New Revision: 8408
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ExceptionEditPart.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ExceptionFigure.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesEditor.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/SeamPagesGuiEditor.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/GraphicalPartFactory.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/PageFigure.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1189
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesEditor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesEditor.java 2008-05-28
14:47:27 UTC (rev 8407)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesEditor.java 2008-05-28
16:01:26 UTC (rev 8408)
@@ -113,6 +113,7 @@
import org.jboss.tools.seam.ui.pages.editor.ecore.pages.PagesModel;
import org.jboss.tools.seam.ui.pages.editor.ecore.pages.PagesModelListener;
import org.jboss.tools.seam.ui.pages.editor.edit.GraphicalPartFactory;
+import org.jboss.tools.seam.ui.pages.editor.edit.xpl.PagesConnectionRouter;
import org.jboss.tools.seam.ui.pages.editor.palette.PagesPaletteViewerPreferences;
public class PagesEditor extends GEFEditor implements PagesModelListener{
@@ -420,10 +421,10 @@
// (TransferDropTargetListener) new JSFTemplateTransferDropTargetListener(
// getGraphicalViewer()));
-// ((ConnectionLayer) ((ScalableFreeformRootEditPart) getGraphicalViewer()
-// .getRootEditPart())
-// .getLayer(ScalableFreeformRootEditPart.CONNECTION_LAYER))
-// .setConnectionRouter(new JSFConnectionRouter());
+ ((ConnectionLayer) ((ScalableFreeformRootEditPart) getGraphicalViewer()
+ .getRootEditPart())
+ .getLayer(ScalableFreeformRootEditPart.CONNECTION_LAYER))
+ .setConnectionRouter(new PagesConnectionRouter());
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE,
Boolean.TRUE);
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_ENABLED,
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/SeamPagesGuiEditor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/SeamPagesGuiEditor.java 2008-05-28
14:47:27 UTC (rev 8407)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/SeamPagesGuiEditor.java 2008-05-28
16:01:26 UTC (rev 8408)
@@ -116,10 +116,23 @@
private PagesModel getFakeModel(){
PagesModel model = PagesFactory.eINSTANCE.createPagesModel();
+
+ Link link = PagesFactory.eINSTANCE.createLink();
+
+ link.setName("page1");
+
+ PgException ex = PagesFactory.eINSTANCE.createPgException();
+ ex.setName("Exception");
+ ex.setLocation(new Point(10,100));
+ ex.setSize(new Dimension(300,21));
+ ex.getOutputLinks().add(link);
+ model.getChildren().add(ex);
+
Page page = PagesFactory.eINSTANCE.createPage();
page.setName("page1");
- page.setLocation(new Point(10,10));
+ page.setLocation(new Point(500,150));
page.setSize(new Dimension(100,100));
+ page.getInputLinks().add(link);
model.getChildren().add(page);
return model;
}
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ExceptionEditPart.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ExceptionEditPart.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ExceptionEditPart.java 2008-05-28
16:01:26 UTC (rev 8408)
@@ -0,0 +1,243 @@
+/*******************************************************************************
+ * 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.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.Notifier;
+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.ecore.pages.PgException;
+import org.jboss.tools.seam.ui.pages.editor.figures.ExceptionFigure;
+import org.jboss.tools.seam.ui.pages.editor.figures.PageFigure;
+
+public class ExceptionEditPart extends PagesEditPart implements PropertyChangeListener,
EditPartListener, Adapter {
+ private ExceptionFigure 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) ExceptionEditPart.this.getParent())
+ .setToFront(this);
+
+ }
+ }
+
+ public boolean isGroupListenerEnable() {
+ return true;
+ }
+
+
+
+ private void refreshTargetLink(Link link) {
+ if (link == null)
+ return;
+ ExceptionEditPart gep = (ExceptionEditPart) 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 getExceptionModel().getInputLinks();
+ }
+
+ protected List getModelSourceConnections() {
+ return getExceptionModel().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 ExceptionFigure(getExceptionModel());
+ ((ExceptionFigure) fig).setEditPart(this);
+ return fig;
+ }
+
+ /**
+ * Returns the model of this as a LED.
+ *
+ * @return Model of this as an LED.
+ */
+ public PgException getExceptionModel() {
+ return (PgException) getModel();
+ }
+
+ Dimension size;
+
+
+
+ protected void refreshVisuals() {
+ Point loc = getExceptionModel().getLocation();
+ size = new Dimension(150, 21);
+ 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 = getExceptionModel().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 getExceptionModel().getChildren();
+ }
+
+ protected void refreshChildren() {
+ super.refreshChildren();
+ for (int i = 0; i < getChildren().size(); i++) {
+ ((ExceptionEditPart) getChildren().get(i)).refresh();
+
+ }
+ }
+
+ /**
+ * @see org.eclipse.gef.EditPart#activate()
+ */
+ public void activate() {
+ if (isActive())
+ return;
+ ((Notifier) getModel()).eAdapters().add(this);
+ super.activate();
+ }
+
+ /**
+ * @see
org.eclipse.emf.common.notify.Adapter#notifyChanged(org.eclipse.emf.common.notify.Notification)
+ */
+ public void notifyChanged(Notification notification) {
+ refresh();
+ refreshVisuals();
+ }
+ /**
+ * )
+ *
+ * @see org.eclipse.emf.common.notify.Adapter#getTarget()
+ */
+ public Notifier getTarget() {
+
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.emf.common.notify.Adapter#isAdapterForType(java.lang.Object)
+ */
+ public boolean isAdapterForType(Object type) {
+ return false;
+ }
+
+ /**
+ * @see
org.eclipse.emf.common.notify.Adapter#setTarget(org.eclipse.emf.common.notify.Notifier)
+ */
+ public void setTarget(Notifier newTarget) {
+ }
+}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/GraphicalPartFactory.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/GraphicalPartFactory.java 2008-05-28
14:47:27 UTC (rev 8407)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/GraphicalPartFactory.java 2008-05-28
16:01:26 UTC (rev 8408)
@@ -15,6 +15,7 @@
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.ecore.pages.PagesModel;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.PgException;
public class GraphicalPartFactory implements EditPartFactory {
@@ -27,6 +28,8 @@
child = new PagesDiagramEditPart();
else if (model instanceof Page)
child = new PageEditPart();
+ else if (model instanceof PgException)
+ child = new ExceptionEditPart();
else if (model instanceof Link)
child = new LinkEditPart();
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ExceptionFigure.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ExceptionFigure.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ExceptionFigure.java 2008-05-28
16:01:26 UTC (rev 8408)
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * 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.IFigure;
+import org.eclipse.draw2d.LineBorder;
+import org.eclipse.draw2d.MouseEvent;
+import org.eclipse.draw2d.XYLayout;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Insets;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.handles.HandleBounds;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.gef.GEFGraphicalViewer;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.PgException;
+import org.jboss.tools.seam.ui.pages.editor.edit.ExceptionEditPart;
+import org.jboss.tools.seam.ui.pages.editor.figures.xpl.FixedConnectionAnchor;
+
+public class ExceptionFigure extends NodeFigure implements HandleBounds {
+ private static final Dimension SIZE = new Dimension(56, 100);
+
+ private Image icon = null;
+
+ public PgException exc;
+
+ ExceptionEditPart editPart;
+
+ public void setEditPart(ExceptionEditPart part) {
+ editPart = part;
+ }
+
+ public void setConstraint(IFigure child, Object constraint) {
+ super.setConstraint(child, constraint);
+ }
+
+ public void setIcon(Image i) {
+ //icon = PrintIconHelper.getPrintImage(i);
+ }
+
+
+ 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 ExceptionFigure(PgException group) {
+ this.exc = group;
+
+ setOpaque(false);
+ setLayoutManager(new XYLayout());
+
+ setBorder(new GroupBorder(blackColor));
+
+ if (group != null) {
+ FixedConnectionAnchor c;
+ c = new FixedConnectionAnchor(this);
+ c.offsetV = 10;
+ //c.offsetH = -1;
+ connectionAnchors.put("1_IN", c);
+ inputConnectionAnchors.addElement(c);
+
+ c = new FixedConnectionAnchor(this);
+ c.offsetV = 10;
+ c.leftToRight = false;
+ connectionAnchors.put("1_OUT", c);
+ outputConnectionAnchors.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;
+
+ /**
+ * @see org.eclipse.draw2d.Figure#paintFigure(Graphics)
+ */
+ protected void paintFigure(Graphics g) {
+ Rectangle r = getBounds().getCopy();
+ g.translate(r.getLocation());
+
+ int start = 0;
+
+
+ g.setBackgroundColor(whiteColor);
+
+ g.fillRectangle(start + 1, 1, 22, 19);
+
+ if (icon != null)
+ g.drawImage(icon, start + 4, 2);
+
+
+ if (exc != null /*&& group.isConfirmed()*/) {
+ g.setBackgroundColor(exceptionBackgroundColor);
+ g.setForegroundColor(exceptionForegroundColor);
+ } else {
+ g.setBackgroundColor(lightGrayColor);
+ }
+
+ }
+
+ 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 width = r.width - 1;
+ int height = r.height - 1;
+
+ if (exc != null)
+ graphics.setForegroundColor(blackColor);
+ else
+ graphics.setForegroundColor(darkGrayColor);
+
+ graphics.drawLine(1, 0, width-1, 0);
+ graphics.drawLine(0, 1, 0, height - 1);
+ graphics.drawLine(1, height, width-1, height);
+ graphics.drawLine(width, 1, width, height - 1);
+ graphics.drawLine(23 , 0, 23, height);
+
+
+ }
+
+ 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
Modified:
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 2008-05-28
14:47:27 UTC (rev 8407)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/NodeFigure.java 2008-05-28
16:01:26 UTC (rev 8408)
@@ -50,6 +50,10 @@
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 Color exceptionBackgroundColor = new Color(null, 0xff, 0xe3, 0xe7);
+
+ public static final Color exceptionForegroundColor = new Color(null, 0x99, 0x07, 0x02);
public static final Image errorIcon = ModelUIImages
.getImage("error_co.gif");
Modified:
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 2008-05-28
14:47:27 UTC (rev 8407)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/PageFigure.java 2008-05-28
16:01:26 UTC (rev 8408)
@@ -142,7 +142,7 @@
if (group != null) {
// setIcon(group.getImage());
-// setPath(group.getVisiblePath());
+ setPath(group.getName());
}
setOpaque(false);