Author: dazarov
Date: 2008-05-30 11:08:10 -0400 (Fri, 30 May 2008)
New Revision: 8481
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PageWrapper.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ParamEditPart.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ParamListEditPart.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ParamFigure.java
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ParamListFigure.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/GraphicalPartFactory.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/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-30
14:45:42 UTC (rev 8480)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/GraphicalPartFactory.java 2008-05-30
15:08:10 UTC (rev 8481)
@@ -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.Param;
import org.jboss.tools.seam.ui.pages.editor.ecore.pages.PgException;
@@ -30,6 +31,10 @@
child = new PageEditPart();
else if (model instanceof PgException)
child = new ExceptionEditPart();
+ else if (model instanceof PageWrapper)
+ child = new ParamListEditPart();
+ else if (model instanceof Param)
+ child = new ParamEditPart();
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/edit/PageWrapper.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PageWrapper.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/PageWrapper.java 2008-05-30
15:08:10 UTC (rev 8481)
@@ -0,0 +1,15 @@
+package org.jboss.tools.seam.ui.pages.editor.edit;
+
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.Page;
+
+public class PageWrapper {
+ private Page page;
+
+ public PageWrapper(Page page){
+ this.page = page;
+ }
+
+ public Page getPage(){
+ return page;
+ }
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ParamEditPart.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ParamEditPart.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ParamEditPart.java 2008-05-30
15:08:10 UTC (rev 8481)
@@ -0,0 +1,255 @@
+/*******************************************************************************
+ * 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.PropertyChangeListener;
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.FigureUtilities;
+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.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartListener;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DropRequest;
+import org.eclipse.swt.accessibility.AccessibleControlEvent;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.Link;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.Param;
+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.NodeFigure;
+import org.jboss.tools.seam.ui.pages.editor.figures.ParamFigure;
+
+public class ParamEditPart extends PagesEditPart implements PropertyChangeListener,
EditPartListener, Adapter {
+ private ParamFigure 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) ParamEditPart.this.getParent())
+ .setToFront(this);
+
+ }
+ }
+
+ public boolean isGroupListenerEnable() {
+ return true;
+ }
+
+
+
+ private void refreshTargetLink(Link link) {
+ if (link == null)
+ return;
+ ParamEditPart gep = (ParamEditPart) 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 ParamFigure(getExceptionModel());
+ ((ParamFigure) fig).setEditPart(this);
+ return fig;
+ }
+
+ /**
+ * Returns the model of this as a LED.
+ *
+ * @return Model of this as an LED.
+ */
+ public Param getExceptionModel() {
+ return (Param) getModel();
+ }
+
+ Dimension size;
+
+
+
+ protected void refreshVisuals() {
+ Point loc = getExceptionModel().getLocation();
+ String text = getExceptionModel().getName();
+ if(text == null) text="Exception";
+ int width = 30+FigureUtilities.getTextExtents(text, NodeFigure.exceptionFont).width;
+ size = new Dimension(width, 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++) {
+ ((ParamEditPart) getChildren().get(i)).refresh();
+
+ }
+ }
+
+ /**
+ * @see org.eclipse.gef.EditPart#activate()
+ */
+ public void activate() {
+ if (isActive())
+ return;
+ ((Notifier) getModel()).eAdapters().add(this);
+ super.activate();
+ }
+
+ public void deactivate(){
+ if (!isActive())
+ return;
+ ((Notifier) getModel()).eAdapters().remove(this);
+ super.deactivate();
+ }
+
+ /**
+ * @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) {
+ }
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ParamListEditPart.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ParamListEditPart.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ParamListEditPart.java 2008-05-30
15:08:10 UTC (rev 8481)
@@ -0,0 +1,233 @@
+/*******************************************************************************
+ * 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.PropertyChangeListener;
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.FigureUtilities;
+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.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartListener;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DropRequest;
+import org.eclipse.swt.accessibility.AccessibleControlEvent;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.jboss.tools.seam.ui.pages.editor.ecore.pages.Link;
+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.NodeFigure;
+import org.jboss.tools.seam.ui.pages.editor.figures.ParamListFigure;
+
+public class ParamListEditPart extends PagesEditPart implements PropertyChangeListener,
EditPartListener, Adapter {
+ private ParamListFigure 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) ParamListEditPart.this.getParent())
+ .setToFront(this);
+
+ }
+ }
+
+ public boolean isGroupListenerEnable() {
+ return true;
+ }
+
+
+
+ private void refreshTargetLink(Link link) {
+ if (link == null)
+ return;
+ ParamListEditPart gep = (ParamListEditPart) 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 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 ParamListFigure(getExceptionModel());
+ ((ParamListFigure) fig).setEditPart(this);
+ return fig;
+ }
+
+ /**
+ * Returns the model of this as a LED.
+ *
+ * @return Model of this as an LED.
+ */
+ public PageWrapper getExceptionModel() {
+ return (PageWrapper) getModel();
+ }
+
+ Dimension size;
+
+
+
+ protected void refreshVisuals() {
+ Point loc = new Point(1,1);
+ size = new Dimension(10, 10);
+ 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(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().getPage().getChildren();
+ }
+
+ protected void refreshChildren() {
+ super.refreshChildren();
+ for (int i = 0; i < getChildren().size(); i++) {
+ ((ParamListEditPart) getChildren().get(i)).refresh();
+
+ }
+ }
+
+ /**
+ * @see org.eclipse.gef.EditPart#activate()
+ */
+ public void activate() {
+ if (isActive())
+ return;
+ ((Notifier) getModel()).eAdapters().add(this);
+ super.activate();
+ }
+
+ public void deactivate(){
+ if (!isActive())
+ return;
+ ((Notifier) getModel()).eAdapters().remove(this);
+ super.deactivate();
+ }
+
+ /**
+ * @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) {
+ }
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ParamFigure.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ParamFigure.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ParamFigure.java 2008-05-30
15:08:10 UTC (rev 8481)
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * 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.Param;
+import org.jboss.tools.seam.ui.pages.editor.edit.ParamEditPart;
+import org.jboss.tools.seam.ui.pages.editor.figures.xpl.FixedConnectionAnchor;
+
+public class ParamFigure extends NodeFigure implements HandleBounds {
+ private static final Dimension SIZE = new Dimension(56, 100);
+
+ private Image icon = null;
+
+ public Param exc;
+
+ ParamEditPart editPart;
+
+ public void setEditPart(ParamEditPart 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 ParamFigure(Param 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.offsetH = -1;
+ 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());
+
+ if (exc != null) {
+ g.setBackgroundColor(exceptionBackgroundColor);
+ g.setForegroundColor(exceptionForegroundColor);
+ } else {
+ g.setBackgroundColor(lightGrayColor);
+ }
+
+ g.fillRectangle(1, 1, r.width-2, r.height-2);
+
+ g.setBackgroundColor(whiteColor);
+
+ g.fillRectangle(1, 1, 22, 19);
+
+ if (icon != null)
+ g.drawImage(icon, 4, 2);
+
+ if(exc != null){
+ g.setFont(exceptionFont);
+ if(exc.getName() != null)
+ g.drawString(exc.getName(), 27, 3);
+ else
+ g.drawString("Exception", 27, 3);
+ }
+
+
+ }
+
+ 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
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ParamListFigure.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ParamListFigure.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/figures/ParamListFigure.java 2008-05-30
15:08:10 UTC (rev 8481)
@@ -0,0 +1,173 @@
+/*******************************************************************************
+ * 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.PageWrapper;
+import org.jboss.tools.seam.ui.pages.editor.edit.ParamListEditPart;
+import org.jboss.tools.seam.ui.pages.editor.figures.xpl.FixedConnectionAnchor;
+
+public class ParamListFigure extends NodeFigure implements HandleBounds {
+ private static final Dimension SIZE = new Dimension(56, 100);
+
+ private Image icon = null;
+
+ public PageWrapper paramList;
+
+ ParamListEditPart editPart;
+
+ public void setEditPart(ParamListEditPart 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 ParamListFigure(PageWrapper paramList) {
+ this.paramList = paramList;
+
+ setOpaque(false);
+ setLayoutManager(new XYLayout());
+
+ setBorder(new GroupBorder(blackColor));
+ }
+
+ /**
+ * @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());
+
+ if (paramList != null) {
+ g.setBackgroundColor(exceptionBackgroundColor);
+ g.setForegroundColor(exceptionForegroundColor);
+ } else {
+ g.setBackgroundColor(lightGrayColor);
+ }
+
+ g.fillRectangle(1, 1, r.width-2, r.height-2);
+
+ g.setBackgroundColor(whiteColor);
+
+ g.fillRectangle(1, 1, 22, 19);
+
+ if (icon != null)
+ g.drawImage(icon, 4, 2);
+ }
+
+ 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 (paramList != 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