Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts')
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/BaseEditPart.java86
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/CategoryEditPart.java187
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComplexTypeDefinitionEditPart.java214
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComplexTypeInheritedContentEditPart.java149
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComponentViewerRootEditPart.java76
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ElementDeclarationEditPart.java460
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ExpandableGraphNodeEditPart.java189
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/GraphNodeEditPart.java144
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/IFeedbackHandler.java17
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/MessageEditPart.java38
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ModelGroupDefinitionEditPart.java204
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ModelGroupEditPart.java187
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RepeatableGraphNodeEditPart.java72
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RootComplexTypeDefinitionEditPart.java121
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RootModelGroupDefinitionEditPart.java105
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SchemaDirectiveEditPart.java60
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SchemaEditPart.java206
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SimpleTypeDefinitionEditPart.java69
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SubstitutionGroupViewerRootEditPart.java76
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/TopLevelComponentEditPart.java319
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/TypeEditPart.java72
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/WildcardEditPart.java85
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/XSDEditPartFactory.java102
23 files changed, 0 insertions, 3238 deletions
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/BaseEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/BaseEditPart.java
deleted file mode 100644
index f98da1abb1..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/BaseEditPart.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.GraphicsConstants;
-import org.eclipse.wst.xsd.ui.internal.graph.model.ModelAdapterListener;
-import org.eclipse.wst.xsd.ui.internal.graph.model.XSDModelAdapterFactory;
-
-
-public abstract class BaseEditPart extends AbstractGraphicalEditPart implements ModelAdapterListener, GraphicsConstants, IFeedbackHandler
-{
- protected boolean isSelected = false;
- /**
- * Activates the <code>EditPart</code> by setting the
- * appropriate flags, and activating its children.
- * activation signals to the EditPart that is should start observing
- * it's model, and that is should support editing at this time.
- * An EditPart will have a parent prior to activiation.
- * @see #deactivate()
- */
- public void activate()
- {
- super.activate();
- XSDModelAdapterFactory.addModelAdapterListener(getModel(), this);
- }
- /**
- * Apart from the deactivation done in super, the source
- * and target connections are deactivated, and the visual
- * part of the this is removed.
- *
- * @see #activate()
- */
- public void deactivate()
- {
- XSDModelAdapterFactory.removeModelAdapterListener(getModel(), this);
- super.deactivate();
- }
-
- protected void createEditPolicies()
- {
- }
-
- protected EditPart createChild(Object model)
- {
- return XSDEditPartFactory.getInstance().createEditPart(this, model);
- }
-
- public void propertyChanged(Object object, String property)
- {
- refresh();
- }
-
- //public BaseGraphicalViewer getBaseGraphicalViewer()
- //{
- // return (BaseGraphicalViewer)getViewer();
- //}
-
- public IFigure getSelectionFigure()
- {
- return getFigure();
- }
-
-
- public void addFeedback()
- {
- isSelected = true;
- refreshVisuals();
- }
-
- public void removeFeedback()
- {
- isSelected = false;
- refreshVisuals();
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/CategoryEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/CategoryEditPart.java
deleted file mode 100644
index afffaad700..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/CategoryEditPart.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import java.util.List;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.ScrollPane;
-import org.eclipse.draw2d.Viewport;
-import org.eclipse.draw2d.ViewportLayout;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.GraphicsConstants;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SelectionHandlesEditPolicyImpl;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerLayout;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.FillLayout;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RoundedLineBorder;
-import org.eclipse.wst.xsd.ui.internal.graph.model.Category;
-
-
-public class CategoryEditPart extends BaseEditPart
-{
- protected ScrollPane scrollpane;
- protected Label label;
- protected ContainerFigure outerPane, r;
- protected SelectionHandlesEditPolicyImpl selectionHandlesEditPolicy;
-
- public int getType()
- {
- return ((Category)getModel()).getGroupType();
- }
-
- protected IFigure createFigure()
- {
- outerPane = new ContainerFigure();
- outerPane.setBorder(new RoundedLineBorder(1, 6));
- outerPane.setForegroundColor(categoryBorderColor);
-
- r = new ContainerFigure();
- r.setOutline(false);
- r.setMinimumSize(new Dimension(0, 0));
- r.setFill(true);
- r.setBackgroundColor(GraphicsConstants.elementBackgroundColor);
- outerPane.add(r);
-
- int minHeight = 250;
- switch (getType())
- {
- case Category.DIRECTIVES :
- case Category.NOTATIONS :
- {
- minHeight = 50;
- break;
- }
- case Category.ATTRIBUTES :
- case Category.GROUPS :
- {
- minHeight = 100;
- break;
- }
- }
-
- final int theMinHeight = minHeight;
- FillLayout outerLayout = new FillLayout()
- {
- protected Dimension calculatePreferredSize(IFigure parent, int width, int height)
- {
- Dimension d = super.calculatePreferredSize(parent, width, height);
- d.union(new Dimension(100, theMinHeight));
- return d;
- }
- };
- //outerLayout.setHorizontal(false);
- outerPane.setLayoutManager(outerLayout);
-
-
- label = new Label();
- label.setForegroundColor(ColorConstants.black);
- label.setBorder(new MarginBorder(2, 4, 2, 4));
- r.add(label); //Holder);
-
- RectangleFigure line = new RectangleFigure();
- line.setPreferredSize(20, 1);
- outerPane.add(line);
-
-
- scrollpane = new ScrollPane();
- scrollpane.setForegroundColor(ColorConstants.black);
- scrollpane.setVerticalScrollBarVisibility(ScrollPane.AUTOMATIC); //ScrollPane.ALWAYS);
- outerPane.add(scrollpane);
-
- ContainerFigure pane = new ContainerFigure();
- pane.setBorder(new MarginBorder(5, 8, 5, 8));
- ContainerLayout layout = new ContainerLayout();
- layout.setHorizontal(false);
- layout.setSpacing(0);
- pane.setLayoutManager(layout);
-
- Viewport viewport = new Viewport();
- viewport.setContentsTracksHeight(true);
- ViewportLayout viewportLayout = new ViewportLayout()
- {
- protected Dimension calculatePreferredSize(IFigure parent, int width, int height)
- {
- Dimension d = super.calculatePreferredSize(parent, width, height);
- d.height = Math.min(d.height, theMinHeight - 25); //getViewer().getControl().getBounds().height);
- return d;
- }
- };
- viewport.setLayoutManager(viewportLayout);
-
- scrollpane.setViewport(viewport);
- scrollpane.setContents(pane);
-
- return outerPane;
- }
-
- protected List getModelChildren()
- {
- return ((Category)getModel()).getChildren();
- }
-
- public void refreshVisuals()
- {
- outerPane.setBorder(new RoundedLineBorder(isSelected ? ColorConstants.black : categoryBorderColor, isSelected ? 1 : 1, 6));
- outerPane.repaint();
-// Uncomment this for coloured titles
-// r.setBackgroundColor(isSelected ? ColorConstants.blue : GraphicsConstants.elementBackgroundColor);
-// label.setForegroundColor(isSelected ? ColorConstants.white : ColorConstants.black);
-// r.repaint();
-// outerPane.setForegroundColor(isSelected ? ColorConstants.black : elementBorderColor);
-
- Category category = (Category)getModel();
- // temp hack --- added empty space to make the min width of groups bigger
- label.setText(" " + category.getName() + " ");
- }
-
- public ScrollPane getScrollPane()
- {
- return scrollpane;
- }
-
- public IFigure getContentPane()
- {
- return scrollpane.getContents();
- }
-
- public void scrollTo(AbstractGraphicalEditPart topLevel)
- {
- Rectangle topLevelBounds = topLevel.getFigure().getBounds();
- Rectangle categoryBounds = getFigure().getBounds();
- int scrollValue = scrollpane.getVerticalScrollBar().getValue();
- int location = topLevelBounds.y + scrollValue - categoryBounds.y;
- scrollpane.scrollVerticalTo(location - categoryBounds.height/2);
- }
-
- protected EditPart createChild(Object model)
- {
- EditPart editPart = new TopLevelComponentEditPart();
- editPart.setModel(model);
- editPart.setParent(this);
- return editPart;
- }
-
- protected void createEditPolicies()
- {
- selectionHandlesEditPolicy = new SelectionHandlesEditPolicyImpl();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, selectionHandlesEditPolicy);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComplexTypeDefinitionEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComplexTypeDefinitionEditPart.java
deleted file mode 100644
index 620cdc5278..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComplexTypeDefinitionEditPart.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.gef.requests.LocationRequest;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDChildUtility;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDGraphUtil;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.ComponentNameDirectEditManager;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SimpleDirectEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.CenteredIconFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.FillLayout;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RoundedLineBorder;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-
-
-
-public class ComplexTypeDefinitionEditPart extends GraphNodeEditPart
-{
- protected ContainerFigure contentFigure;
- protected Label label;
- protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy();
- protected CenteredIconFigure centeredIconFigure;
- protected RectangleFigure preceedingSpace;
- protected ContainerFigure contentPane;
-
- public XSDComplexTypeDefinition getXSDComplexTypeDefinition()
- {
- return (XSDComplexTypeDefinition)getModel();
- }
-
- protected boolean isConnectedEditPart()
- {
- return false;
- }
-
- protected GraphNodeFigure createGraphNodeFigure()
- {
- GraphNodeFigure figure = new GraphNodeFigure();
-
- figure.getOutlinedArea().setBorder(new RoundedLineBorder(1, 6));
- figure.getOutlinedArea().setFill(true);
- figure.getOutlinedArea().setLayoutManager(new FillLayout(true));
-
- figure.getInnerContentArea().getContainerLayout().setHorizontal(true);
-
- preceedingSpace = new RectangleFigure();
- preceedingSpace.setVisible(false);
- figure.getInnerContentArea().add(preceedingSpace, 0);
-
- contentPane = new ContainerFigure();
- contentPane.getContainerLayout().setHorizontal(false);
- contentPane.getContainerLayout().setSpacing(5);
- contentPane.setBorder(new MarginBorder(5, 5, 5, 5));
- figure.getInnerContentArea().add(contentPane);
-
- label = new Label();
- label.setBorder(new MarginBorder(0, 5, 5, 5));
- figure.getIconArea().add(label);
- label.setFont(mediumBoldFont);
-
- figure.getInnerContentArea().getContainerLayout().setSpacing(5);
- figure.getInnerContentArea().setBorder(new MarginBorder(5, 5, 5, 5));
-
- return figure;
- }
-
- protected EditPart createChild(Object model)
- {
- EditPart editPart = null;
- if (model == getModel())
- {
- editPart = new ComplexTypeInheritedContentEditPart();
- editPart.setModel(model);
- editPart.setParent(this);
- }
- else
- {
- editPart = super.createChild(model);
- }
- return editPart;
- }
-
- protected List getModelChildren()
- {
- List list = new ArrayList();
-
- XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition)getModel();
-
- if (ct.getDerivationMethod().getName().equals("extension"))
- {
- list.add(getModel());
- }
-
- list.addAll(XSDChildUtility.getModelChildren(getModel()));
- return list;
- }
-
- public IFigure getContentPane()
- {
- return contentPane;
- }
-
- protected void refreshVisuals()
- {
- XSDComplexTypeDefinition ctd = (XSDComplexTypeDefinition)getModel();
-
- String name = ctd.getName();
- if (name == null)
- {
- try
- {
- if (label != null)
- {
- graphNodeFigure.getIconArea().remove(label);
- }
- label = null;
- }
- catch (Exception e)
- {
- }
- }
- else
- {
- if (label == null)
- {
- label = new Label();
- label.setBorder(new MarginBorder(0, 5, 5, 5));
- ((GraphNodeFigure)getFigure()).getIconArea().add(label);
- label.setFont(mediumBoldFont);
- }
- graphNodeFigure.getIconArea().add(label);
- label.setText(name);
- }
-
- // provides some room if we need to draw lines for the inherited
- boolean includesInheritedContent = getModelChildren().contains(getModel());
- preceedingSpace.setPreferredSize(includesInheritedContent ? new Dimension(10, 1) : new Dimension(0, 0));
-
- if (XSDGraphUtil.isEditable(getModel()))
- {
- graphNodeFigure.setForegroundColor(isSelected ? ColorConstants.black : elementBorderColor);
- if (label != null)
- label.setForegroundColor(elementBorderColor);
- }
- else
- {
- graphNodeFigure.setForegroundColor(isSelected ? ColorConstants.black : readOnlyBorderColor);
- if (label != null)
- label.setForegroundColor(readOnlyBorderColor);
- }
- }
-
- protected void performDirectEdit()
- {
- ComponentNameDirectEditManager manager = new ComponentNameDirectEditManager(this, label, (XSDComplexTypeDefinition)getModel());
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
-
-
- protected void createEditPolicies()
- {
- super.createEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, simpleDirectEditPolicy);
- }
-
-
- public void performRequest(Request request)
- {
- if (request.getType() == RequestConstants.REQ_DIRECT_EDIT ||
- request.getType() == RequestConstants.REQ_OPEN)
- {
- if (XSDGraphUtil.isEditable(getModel()))
- {
- LocationRequest locationRequest = (LocationRequest)request;
- Point p = locationRequest.getLocation();
-
- if (label != null && hitTest(label, p))
- {
- performDirectEdit();
- }
- }
- }
- }
-
- public void doEditName()
- {
- performDirectEdit();
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComplexTypeInheritedContentEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComplexTypeInheritedContentEditPart.java
deleted file mode 100644
index 02952650a2..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComplexTypeInheritedContentEditPart.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDChildUtility;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDGraphUtil;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.ComponentNameDirectEditManager;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SimpleDirectEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RoundedLineBorder;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-
-
-// This is a dashed box that displays the inherited content of a complex type
-//
-public class ComplexTypeInheritedContentEditPart extends BaseEditPart
-{
- protected Label label;
- protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy();
- protected boolean isParentExpanded;
-
- public ComplexTypeInheritedContentEditPart()
- {
- super();
- }
-
- public XSDComplexTypeDefinition getXSDComplexTypeDefinition()
- {
- return (XSDComplexTypeDefinition)getModel();
- }
-
- protected IFigure createFigure()
- {
- ContainerFigure figure = new ContainerFigure();
- figure.getContainerLayout().setHorizontal(false);
- figure.getContainerLayout().setBorder(5);
- figure.getContainerLayout().setSpacing(5);
- figure.setBorder(new RoundedLineBorder(ColorConstants.gray, 1, 6, Graphics.LINE_DASH));
- return figure;
- }
-
- protected List getModelChildren()
- {
- XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition)getModel();
-
- List list = new ArrayList();
-
- if (ct.getDerivationMethod().getName().equals("extension") && !isParentExpanded)
- {
- XSDTypeDefinition type = ct.getBaseTypeDefinition();
- Iterator iter = XSDChildUtility.getModelChildren(type).iterator();
- boolean cont = true;
- while (cont)
- {
- while (iter.hasNext())
- {
- list.add(0, iter.next());
- }
-
- if (type instanceof XSDComplexTypeDefinition)
- {
- XSDComplexTypeDefinition ctd = (XSDComplexTypeDefinition)type;
- type = ctd.getBaseTypeDefinition();
-
- // defect 264957 - workbench hangs when modifying complex content
- // Since we don't filter out the current complexType from
- // the combobox, we can potentially have an endless loop
- if (ctd == type)
- {
- cont = false;
- break;
- }
-
- if (ctd.getDerivationMethod().getName().equals("extension"))
- {
- iter = XSDChildUtility.getModelChildren(type).iterator();
- }
- else
- {
- cont = false;
- }
- }
- else
- {
- cont = false;
- }
- }
- }
- return list;
- }
-
- protected void refreshVisuals()
- {
- List children = getModelChildren();
- figure.setVisible(children.size() > 0);
- // todo set preferredSize to 0 ?
- }
-
- protected void performDirectEdit()
- {
- // Why are we allowing direct editing when the label is null?
- // Should remove the policy
- if (label != null)
- {
- ComponentNameDirectEditManager manager = new ComponentNameDirectEditManager(this, label, (XSDComplexTypeDefinition)getModel());
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
- }
-
-
- protected void createEditPolicies()
- {
- super.createEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, simpleDirectEditPolicy);
- }
-
-
- public void performRequest(Request request)
- {
- if (request.getType() == RequestConstants.REQ_DIRECT_EDIT)
- {
- if (XSDGraphUtil.isEditable(getModel()))
- {
- performDirectEdit();
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComponentViewerRootEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComponentViewerRootEditPart.java
deleted file mode 100644
index fa8d191fd4..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComponentViewerRootEditPart.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Panel;
-import org.eclipse.gef.EditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerLayout;
-
-
-
-public class ComponentViewerRootEditPart extends BaseEditPart
-{
- protected final static String MESSAGE_PLACE_HOLDER = "MESSAGE_PLACE_HOLDER";
- protected Object input;
-
- public void setInput(Object input)
- {
- this.input = input;
- refreshChildren();
- }
-
- protected IFigure createFigure()
- {
- Panel panel = new Panel();
- ContainerLayout layout = new ContainerLayout();
- layout.setBorder(60);
- panel.setLayoutManager(layout);
- return panel;
- }
-
-
- protected List getModelChildren()
- {
- List list = new ArrayList();
- if (input != null)
- {
- list.add(input);
- }
- else
- {
- list.add(MESSAGE_PLACE_HOLDER);
- }
- return list;
- }
-
- protected EditPart createChild(Object model)
- {
- EditPart editPart = null;
- if (model == MESSAGE_PLACE_HOLDER)
- {
- editPart = new MessageEditPart();
- editPart.setModel(model);
- }
- else
- {
- editPart = super.createChild(model);
- }
- return editPart;
- }
-
- protected void createEditPolicies()
- {
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ElementDeclarationEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ElementDeclarationEditPart.java
deleted file mode 100644
index 249c88b893..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ElementDeclarationEditPart.java
+++ /dev/null
@@ -1,460 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.LineBorder;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.gef.requests.LocationRequest;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xsd.XSDComponentSelectionDialog;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xsd.XSDComponentSelectionProvider;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xsd.XSDSetTypeHelper;
-import org.eclipse.wst.xsd.ui.internal.gef.util.figures.SpacingFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDChildUtility;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDGraphUtil;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDSubstitutionGroupChildUtility;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDSubstitutionGroupsViewer;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.ComboBoxCellEditorManager;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.ComponentNameDirectEditManager;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SimpleDirectEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ExpandableGraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.FillLayout;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.model.XSDModelAdapterFactory;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.w3c.dom.Element;
-
-
-
-public class ElementDeclarationEditPart extends ExpandableGraphNodeEditPart
-{
- public Label label;
- protected Label contentIconLabel;
- protected Label typeValueLabel;
- protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy();
- protected boolean isContentIconLabelSelected = false;
-
- protected final static String ELEMENT_TYPE_PLACE_HOLDER = "ELEMENT_TYPE_PLACE_HOLDER";
-
- public XSDParticle getXSDParticle()
- {
- Object o = getXSDElementDeclaration().getContainer();
- return (o instanceof XSDParticle) ? (XSDParticle)o : null;
- }
-
- public XSDElementDeclaration getXSDElementDeclaration()
- {
- return (XSDElementDeclaration)getModel();
- }
-
- protected boolean isDefaultExpanded()
- {
- // hack to expand up to its content. The previous test didn't appear to work
- int depth = 0;
- for (EditPart part = this; part != null; part = part.getParent())
- {
- depth++;
- }
- return depth <= 3;
- }
-
- protected GraphNodeFigure createGraphNodeFigure()
- {
- ExpandableGraphNodeFigure figure = new ExpandableGraphNodeFigure();
-
- figure.getOutlinedArea().setFill(true);
- figure.getOutlinedArea().setLayoutManager(new FillLayout());
-
- label = new Label();
- figure.getIconArea().add(label);
- label.setFont(mediumBoldFont);
-
- SpacingFigure spacingFigure = new SpacingFigure();
- figure.getIconArea().add(spacingFigure);
-
- contentIconLabel = new Label();
- //contentIcon.setBorder(new MarginBorder(2, 2, 2, 10));
- figure.getIconArea().add(contentIconLabel);
-
- // A sneaky null check.... getViewer() does a getRoot(), but getRoot() might be null
- // same with getParent()
- if (getParent() != null && getRoot() != null && getViewer() instanceof XSDSubstitutionGroupsViewer)
- {
- figure.getOuterContentArea().getContainerLayout().setSpacing(5);
- }
- else
- {
- RectangleFigure line = new RectangleFigure();
- line.setPreferredSize(20, 1);
- figure.getOutlinedArea().add(line, 1);
-
- figure.getInnerContentArea().setLayoutManager(new FillLayout(2));
- figure.getInnerContentArea().setBorder(new MarginBorder(2,2,2,1));
-
- ContainerFigure labelGroup = new ContainerFigure();
- Label typeLabel = new Label("type");
- labelGroup.add(typeLabel);
- labelGroup.setBorder(new MarginBorder(0, 4, 0, 4));
-
- Label equalsLabel = new Label(" = ");
- labelGroup.add(equalsLabel);
-
- typeValueLabel = new Label();
- labelGroup.add(typeValueLabel);
- figure.getOutlinedArea().add(labelGroup, 2);
- }
- return figure;
- }
-
- protected ExpandableGraphNodeFigure getExpandableGraphNodeFigure()
- {
- return (ExpandableGraphNodeFigure)graphNodeFigure;
- }
-
- protected List getModelChildren()
- {
- XSDTypeDefinition typeDef = getXSDElementDeclaration().getTypeDefinition();
-
- // Special case simple type. Need to add it to the list as well
- List list = new ArrayList();
- if (typeDef instanceof XSDSimpleTypeDefinition)
- {
- list.add((XSDSimpleTypeDefinition)typeDef);
- if (getExpandableGraphNodeFigure().isExpanded())
- {
- list.addAll(getModelChildrenHelper());
- }
- return list;
- }
- return getExpandableGraphNodeFigure().isExpanded() ? getModelChildrenHelper() : Collections.EMPTY_LIST;
- }
-
- protected List getModelChildrenHelper()
- {
- if (getViewer() instanceof XSDSubstitutionGroupsViewer)
- {
- return XSDSubstitutionGroupChildUtility.getModelChildren(getXSDElementDeclaration().getResolvedElementDeclaration());
- }
- else
- {
- return XSDChildUtility.getModelChildren(getXSDElementDeclaration().getResolvedElementDeclaration());
- }
- }
-
- protected void refreshContentIcon()
- {
- String iconName = null;
- XSDTypeDefinition td = getXSDElementDeclaration().getResolvedElementDeclaration().getTypeDefinition();
-
- if (td instanceof XSDComplexTypeDefinition)
- {
- XSDComplexTypeDefinition complexTypeDefinition = (XSDComplexTypeDefinition)td;
- if (complexTypeDefinition.getAttributeUses().size() > 0)
- {
- iconName = "icons/XSDAttribute.gif";
- }
- }
- Image image = iconName != null ? XSDEditorPlugin.getXSDImage(iconName) : null;
- contentIconLabel.setIcon(image);
- }
-
- protected void refreshVisuals()
- {
- String text = getXSDElementDeclaration().isElementDeclarationReference() ?
- getXSDElementDeclaration().getResolvedElementDeclaration().getQName(getXSDElementDeclaration().getSchema()) :
- getXSDElementDeclaration().getName();
-
- label.setText(text);
-
- ContainerFigure rectangle = graphNodeFigure.getOutlinedArea();
- if (XSDGraphUtil.isEditable(getXSDElementDeclaration()))
- {
- rectangle.setBorder(new LineBorder(isSelected ? ColorConstants.black : elementBorderColor, 2));
- rectangle.setBackgroundColor(elementBackgroundColor);
- rectangle.setForegroundColor(elementBorderColor);
-
- graphNodeFigure.getInnerContentArea().setForegroundColor(ColorConstants.black);
- if (XSDGraphUtil.isEditable(getXSDElementDeclaration().getResolvedElementDeclaration()))
- {
- // give label 'editable' colour
- graphNodeFigure.getInnerContentArea().setForegroundColor(elementLabelColor);
- }
- else
- {
- // give label 'read only' colour
- graphNodeFigure.getInnerContentArea().setForegroundColor(elementBorderColor);
- }
- label.setBackgroundColor(elementBackgroundColor);
- label.setForegroundColor(elementLabelColor);
- }
- else
- {
- rectangle.setBorder(new LineBorder(isSelected ? ColorConstants.black : readOnlyBorderColor, 2));
- rectangle.setBackgroundColor(readOnlyBackgroundColor);
- rectangle.setForegroundColor(readOnlyBorderColor);
- graphNodeFigure.getInnerContentArea().setForegroundColor(readOnlyBorderColor);
- label.setBackgroundColor(readOnlyBackgroundColor);
- }
-
- if (getXSDElementDeclaration().isElementDeclarationReference())
- {
- label.setIcon(XSDEditorPlugin.getXSDImage("icons/GraphViewElementRef.gif"));
- label.setBorder(new MarginBorder(0, 0, 0, 4));
- }
- else
- {
- label.setIcon(null);
- label.setBorder(new MarginBorder(0, 6, 0, 4));
- }
-
- if (getXSDParticle() != null)
- {
- refreshOccurenceLabel(getXSDParticle().getMinOccurs(), getXSDParticle().getMaxOccurs());
- }
-
-
- if (typeValueLabel != null)
- {
- XSDElementDeclaration ed = getXSDElementDeclaration();
- if (ed.getElement() != null)
- {
- String type = ed.getElement().getAttribute("type");
- if (type == null)
- {
- type = "";
- }
- if (!getXSDElementDeclaration().isElementDeclarationReference())
- {
- typeValueLabel.setText(type.equals("") ? "<anonymous>" : type);
- }
- else // if it is a ref, we show the resolved type
- {
- String resolvedType = "";
- if (ed.getResolvedElementDeclaration() != null)
- {
- if (ed.getResolvedElementDeclaration().getTypeDefinition() != null)
- {
- resolvedType = ed.getResolvedElementDeclaration().getTypeDefinition().getQName(ed.getSchema());
-
- // if null, it has an anonymous type that has no resolved type
- if (resolvedType == null)
- {
- resolvedType = "<anonymous>";
- }
- }
- }
- typeValueLabel.setText(resolvedType);
- }
- }
- }
- refreshContentIcon();
- }
-
-
- public void performRequest(Request request)
- {
- if (request.getType() == RequestConstants.REQ_DIRECT_EDIT ||
- request.getType() == RequestConstants.REQ_OPEN)
- {
- if (XSDGraphUtil.isEditable(getXSDElementDeclaration()))
- {
- if (request instanceof LocationRequest)
- {
- LocationRequest locationRequest = (LocationRequest)request;
- Point p = locationRequest.getLocation();
- isContentIconLabelSelected = false;
-
- if (hitTest(label, p))
- {
- performDirectEditForLabel();
- }
- else if (hitTest(typeValueLabel, p))
- {
- performDirectEditForTypeValueLabel();
- }
- }
- }
- }
- }
-
- private void performDirectEditForTypeValueLabel()
- {
- if (!getXSDElementDeclaration().isElementDeclarationReference())
- {
-// TypeReferenceDirectEditManager manager = new TypeReferenceDirectEditManager(this, getXSDElementDeclaration(), typeValueLabel);
-// simpleDirectEditPolicy.setDelegate(manager);
-// manager.show();
-//TODO remove TypeReferenceDirectEditManager since it is not used any longer
-
- Shell shell = Display.getCurrent().getActiveShell();
- IWorkbench workbench = XSDEditorPlugin.getPlugin().getWorkbench();
- IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
- IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor();
- IFile currentIFile = ((IFileEditorInput)editorPart.getEditorInput()).getFile();
-
- XSDSchema schema = getXSDElementDeclaration().getSchema();
-
- XSDComponentSelectionProvider provider = new XSDComponentSelectionProvider(currentIFile, schema);
- XSDComponentSelectionDialog dialog = new XSDComponentSelectionDialog(shell, XSDEditorPlugin.getXSDString("_UI_LABEL_SET_TYPE"), provider);
- provider.setDialog(dialog);
-
- dialog.setBlockOnOpen(true);
- dialog.create();
-
- if (dialog.open() == Window.OK) {
- Element element = getXSDElementDeclaration().getElement();
- XSDSetTypeHelper helper = new XSDSetTypeHelper(currentIFile, schema);
- helper.setType(element, "type", dialog.getSelection());
- }
-
-
- }
- // just ignore type edit for element ref's
- }
-
-
- private void performDirectEditForLabel()
- {
- if (getXSDElementDeclaration().isElementDeclarationReference())
- {
- ComboBoxCellEditorManager manager = new ComboBoxCellEditorManager(this, label)
- {
- protected List computeComboContent()
- {
- XSDSchema schema = getXSDElementDeclaration().getSchema();
- List globalElementNameList = new ArrayList();
- if (schema != null)
- {
- TypesHelper typesHelper = new TypesHelper(schema);
- globalElementNameList = typesHelper.getGlobalElements();
- }
- return globalElementNameList;
- }
-
- public void performModify(String value)
- {
- getXSDElementDeclaration().getElement().setAttribute("ref", value);
- }
- };
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
- else
- {
- ComponentNameDirectEditManager manager = new ComponentNameDirectEditManager(this, label, getXSDElementDeclaration());
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
- }
-
-
- protected void createEditPolicies()
- {
- super.createEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, simpleDirectEditPolicy);
- }
-
-
- public void activate()
- {
- super.activate();
- if (getXSDParticle() != null)
- {
- XSDModelAdapterFactory.addModelAdapterListener(getXSDParticle(), this);
- }
- }
- /**
- * Apart from the deactivation done in super, the source
- * and target connections are deactivated, and the visual
- * part of the this is removed.
- *
- * @see #activate()
- */
- public void deactivate()
- {
- if (getXSDParticle() != null)
- {
- XSDModelAdapterFactory.removeModelAdapterListener(getXSDParticle(), this);
- }
- super.deactivate();
- }
-
- public boolean isContentIconLabelSelected()
- {
- return isContentIconLabelSelected;
- }
-
- protected void addChildVisual(EditPart childEditPart, int index)
- {
- IFigure child = ((GraphicalEditPart)childEditPart).getFigure();
- if (childEditPart instanceof SimpleTypeDefinitionEditPart)
- {
- graphNodeFigure.getIconArea().add(child, index+ 1);
- SpacingFigure spacingFigure = new SpacingFigure();
- graphNodeFigure.getIconArea().add(spacingFigure, index+1);
- }
- else
- {
- getContentPane().add(child, index);
- }
- }
-
- protected void removeChildVisual(EditPart childEditPart)
- {
- IFigure child = ((GraphicalEditPart)childEditPart).getFigure();
- if (childEditPart instanceof SimpleTypeDefinitionEditPart)
- {
- graphNodeFigure.getIconArea().remove(child);
- }
- else
- {
- super.removeChildVisual(childEditPart);
- }
- }
-
- public void doEditName()
- {
- ComponentNameDirectEditManager manager = new ComponentNameDirectEditManager(this, label, getXSDElementDeclaration());
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ExpandableGraphNodeEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ExpandableGraphNodeEditPart.java
deleted file mode 100644
index 1ad4057fed..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ExpandableGraphNodeEditPart.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.draw2d.ActionEvent;
-import org.eclipse.draw2d.ActionListener;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.LayoutManager;
-import org.eclipse.draw2d.MouseEvent;
-import org.eclipse.draw2d.MouseListener;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ExpandableGraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-
-
-
-public abstract class ExpandableGraphNodeEditPart extends RepeatableGraphNodeEditPart implements MouseListener, ActionListener
-{
- protected boolean needToPerformDefaultExpansion = true;
-
- protected GraphNodeFigure createGraphNodeFigure()
- {
- return new ExpandableGraphNodeFigure();
- }
-
- protected void addGraphNodeFigureListeners()
- {
- getExpandableGraphNodeFigure().getInteractor().addMouseListener(this);
- }
-
- protected ExpandableGraphNodeFigure getExpandableGraphNodeFigure()
- {
- return (ExpandableGraphNodeFigure)graphNodeFigure;
- }
-
- public IFigure getContentPane()
- {
- return getExpandableGraphNodeFigure().getOuterContentArea();
- }
-
- protected boolean isDefaultExpanded()
- {
- return false;
- }
-
- protected boolean hasChildren()
- {
- return getModelChildrenHelper().size() > 0;
- }
-
- protected abstract List getModelChildrenHelper();
-
-
- protected List getModelChildren()
- {
- return getExpandableGraphNodeFigure().isExpanded() ? getModelChildrenHelper() : Collections.EMPTY_LIST;
- }
-
- protected void refreshChildren()
- {
- if (needToPerformDefaultExpansion && isDefaultExpanded())
- {
- needToPerformDefaultExpansion = false;
- performExpandOrCollapseHelper();
-
- super.refreshChildren();
-
- EditPart root = getRoot();
- if (root instanceof AbstractGraphicalEditPart)
- {
- getContentPane().setVisible(true);
-
- IFigure rootFigure = ((AbstractGraphicalEditPart)root).getFigure();
- invalidateAll(rootFigure);
- rootFigure.validate();
- rootFigure.repaint();
- }
- getExpandableGraphNodeFigure().getInteractor().repaint();
- }
- else
- {
- super.refreshChildren();
- }
- getExpandableGraphNodeFigure().getInteractor().setVisible(hasChildren());
- }
-
-
- protected void performExpandOrCollapseHelper()
- {
- boolean isButtonExpanded = !getExpandableGraphNodeFigure().isExpanded();
- getExpandableGraphNodeFigure().setExpanded(isButtonExpanded);
- }
-
- public void doPerformExpandOrCollapse()
- {
- performExpandOrCollapse();
- }
-
- public boolean isExpanded()
- {
- return getExpandableGraphNodeFigure().isExpanded();
- }
-
- protected void performExpandOrCollapse()
- {
- performExpandOrCollapseHelper();
-
- boolean isButtonExpanded = getExpandableGraphNodeFigure().isExpanded();
-
- refreshChildren();
-
- EditPart root = getRoot();
- if (root instanceof AbstractGraphicalEditPart)
- {
- getContentPane().setVisible(isButtonExpanded);
-
- IFigure rootFigure = ((AbstractGraphicalEditPart)root).getFigure();
- invalidateAll(rootFigure);
- rootFigure.validate();
- rootFigure.repaint();
- }
- getExpandableGraphNodeFigure().getInteractor().repaint();
- }
-
-
- protected void refreshOccurenceLabel(int min, int max)
- {
- super.refreshOccurenceLabel(min, max);
-
- // TODO: revisit the 'hack' to understand why we need to do this
- // in order to get the view to layout propetly
- //
- IFigure thisFigure = getFigure();
- invalidateAll(thisFigure);
- thisFigure.validate();
- thisFigure.repaint();
- }
-
- protected void invalidateAll(IFigure figure)
- {
- figure.invalidate();
- LayoutManager manager = figure.getLayoutManager();
- if (manager != null)
- {
- manager.invalidate();
- }
- for (Iterator i = figure.getChildren().iterator(); i.hasNext(); )
- {
- IFigure child = (IFigure)i.next();
- invalidateAll(child);
- }
- }
-
-
- // implements MouseListener
- //
- public void mouseDoubleClicked(MouseEvent me)
- {
- }
-
- public void mousePressed(MouseEvent me)
- {
- me.consume();
- needToPerformDefaultExpansion = false;
- performExpandOrCollapse();
- }
-
- public void mouseReleased(MouseEvent me)
- {
- }
-
- public void actionPerformed(ActionEvent event)
- {
- performExpandOrCollapse();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/GraphNodeEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/GraphNodeEditPart.java
deleted file mode 100644
index ce6ad0a9cb..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/GraphNodeEditPart.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.DragTracker;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.requests.LocationRequest;
-import org.eclipse.wst.xsd.ui.internal.gef.util.figures.ConnectedEditPartFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.GraphNodeDragTracker;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SelectionHandlesEditPolicyImpl;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-
-
-
-public abstract class GraphNodeEditPart extends BaseEditPart
-{
- protected GraphNodeFigure graphNodeFigure;
- protected SelectionHandlesEditPolicyImpl selectionHandlesEditPolicy;
-
- protected boolean isConnectedEditPart()
- {
- return true;
- }
-
- protected IFigure createFigure()
- {
- IFigure result = graphNodeFigure = createGraphNodeFigure();
- addGraphNodeFigureListeners();
-
- if (isConnectedEditPart())
- {
- ConnectedEditPartFigure connectedEditPartFigure = createConnectedEditPartFigure();
- connectedEditPartFigure.add(graphNodeFigure);
- result = connectedEditPartFigure;
- }
- return result;
- }
-
- protected ConnectedEditPartFigure createConnectedEditPartFigure()
- {
- ConnectedEditPartFigure connectedEditPartFigure = new ConnectedEditPartFigure(this)
- {
- public IFigure getSelectionFigure()
- {
- return graphNodeFigure.getOutlinedArea();
- }
-
- public IFigure getConnectionFigure()
- {
- return graphNodeFigure.getConnectionFigure();
- }
- };
- return connectedEditPartFigure;
- }
-
- protected abstract GraphNodeFigure createGraphNodeFigure();
-
- protected void addGraphNodeFigureListeners()
- {
- }
-
- public IFigure getSelectionFigure()
- {
- return graphNodeFigure.getOutlinedArea();
- }
-
- public Rectangle getConnectionRectangle()
- {
- return graphNodeFigure.getConnectionRectangle();
- }
-
- protected void createEditPolicies()
- {
- //installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new NonResizableEditPolicy());
- selectionHandlesEditPolicy = new SelectionHandlesEditPolicyImpl();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, selectionHandlesEditPolicy);
- }
-
- public DragTracker getDragTracker(Request request)
- {
- return new GraphNodeDragTracker((EditPart)this);
- }
-
- protected EditPart getApplicableEditPart(EditPart editPart, Point p)
- {
- while (true)
- {
- EditPart parent = null;
- if (editPart instanceof GraphNodeEditPart)
- {
- IFigure f = ((GraphNodeEditPart)editPart).getSelectionFigure();
- if (!hitTest(f, p))
- {
- parent = editPart.getParent();
- }
- }
-
- if (parent != null)
- {
- editPart = parent;
- }
- else
- {
- break;
- }
- }
- return editPart;
- }
-
- public EditPart getTargetEditPart(Request request)
- {
- EditPart editPart = null;
- if (request.getType() == REQ_SELECTION)
- {
- if (request instanceof LocationRequest)
- {
- LocationRequest locationRequest = (LocationRequest)request;
- Point p = locationRequest.getLocation();
- editPart = getApplicableEditPart(this, p);
- }
- }
- return (editPart != null) ? editPart : super.getTargetEditPart(request);
- }
-
- public boolean hitTest(IFigure target, Point location)
- {
- Rectangle b = target.getBounds().getCopy();
- target.translateToAbsolute(b);
- return b.contains(location);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/IFeedbackHandler.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/IFeedbackHandler.java
deleted file mode 100644
index 24a05377c7..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/IFeedbackHandler.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-public interface IFeedbackHandler
-{
- public void addFeedback();
- public void removeFeedback();
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/MessageEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/MessageEditPart.java
deleted file mode 100644
index bbb7f92dd2..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/MessageEditPart.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-
-
-
-public class MessageEditPart extends BaseEditPart
-{
- public MessageEditPart()
- {
- }
-
- protected IFigure createFigure()
- {
- Label label = new Label(XSDEditorPlugin.getXSDString("_UI_GRAPH_VIEW_NOT_AVAILABLE"));
- return label;
- }
-
- protected List getModelChildren()
- {
- return Collections.EMPTY_LIST;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ModelGroupDefinitionEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ModelGroupDefinitionEditPart.java
deleted file mode 100644
index af5804abb2..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ModelGroupDefinitionEditPart.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDChildUtility;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDGraphUtil;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.ComboBoxCellEditorManager;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.ComponentNameDirectEditManager;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SimpleDirectEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RepeatableGraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RoundedLineBorder;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDSchema;
-
-
-public class ModelGroupDefinitionEditPart extends RepeatableGraphNodeEditPart
-{
- protected Label label;
- protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy();
-
- public XSDModelGroupDefinition getXSDModelGroupDefinition()
- {
- return (XSDModelGroupDefinition)getModel();
- }
-
- protected boolean isConnectedEditPart()
- {
- return false;
- }
-
- public XSDParticle getXSDParticle()
- {
- Object o = getXSDModelGroupDefinition().getContainer();
- return (o instanceof XSDParticle) ? (XSDParticle)o : null;
- }
-
- protected GraphNodeFigure createGraphNodeFigure()
- {
- RepeatableGraphNodeFigure figure = new RepeatableGraphNodeFigure();
- figure.getOutlinedArea().setBorder(new RoundedLineBorder(1, 6));
- figure.getInnerContentArea().setBorder(new MarginBorder(10, 0, 10, 0));
-
- label = new Label();
- label.setFont(mediumBoldFont);
- figure.getIconArea().add(label);
-
-
- return figure;
- }
-
- public IFigure getContentPane()
- {
- return graphNodeFigure.getInnerContentArea();
- }
-
- protected List getModelChildren()
- {
- return XSDChildUtility.getModelChildren(getModel());
- }
-
- protected void createEditPolicies()
- {
- super.createEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, simpleDirectEditPolicy);
- }
-
- protected void refreshVisuals()
- {
- super.refreshVisuals();
-
- if (getXSDModelGroupDefinition().isModelGroupDefinitionReference())
- {
- label.setText(getXSDModelGroupDefinition().getResolvedModelGroupDefinition().getQName());
- label.setIcon(XSDEditorPlugin.getXSDImage("icons/GraphViewElementRef.gif"));
- label.setBorder(new MarginBorder(0, 0, 0, 4));
-
- // todo update occurence label
- //
- }
- else
- {
- label.setText(getXSDModelGroupDefinition().getName());
- label.setIcon(null);
- label.setBorder(new MarginBorder(0, 6, 0, 4));
- }
-
- if (XSDGraphUtil.isEditable(getModel()))
- {
- graphNodeFigure.getOutlinedArea().setForegroundColor(isSelected ? ColorConstants.black : elementBorderColor);
- label.setForegroundColor(elementLabelColor);
- }
- else
- {
- graphNodeFigure.getOutlinedArea().setForegroundColor(readOnlyBackgroundColor);
- label.setForegroundColor(readOnlyBackgroundColor);
- }
-
- refreshOccurenceLabel(getXSDParticle());
- }
-
-
- protected void performDirectEdit()
- {
- if (getXSDModelGroupDefinition().isModelGroupDefinitionReference())
- {
- ComboBoxCellEditorManager manager = new ComboBoxCellEditorManager(this, label)
- {
- protected List computeComboContent()
- {
- XSDSchema schema = getXSDModelGroupDefinition().getSchema();
- List nameList = new ArrayList();
- if (schema != null)
- {
- TypesHelper typesHelper = new TypesHelper(schema);
- nameList = typesHelper.getModelGroups();
- }
- return nameList;
- }
-
- public void performModify(String value)
- {
- Display.getCurrent().asyncExec(new DelayedModelGroupRenameAction(getXSDModelGroupDefinition(), value));
- }
- };
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
- else
- {
- ComponentNameDirectEditManager manager = new ComponentNameDirectEditManager(this, label, getXSDModelGroupDefinition());
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
- }
-
-
- protected class DelayedModelGroupRenameAction implements Runnable
- {
- XSDModelGroupDefinition modelGroupDefinition;
- String value;
-
- DelayedModelGroupRenameAction(XSDModelGroupDefinition modelGroupDefinition, String value)
- {
- this.modelGroupDefinition = modelGroupDefinition;
- this.value = value;
- }
-
- public void run()
- {
- modelGroupDefinition.getElement().setAttribute("ref", value);
- }
- }
-
-
- public void performRequest(Request request)
- {
- if (request.getType() == RequestConstants.REQ_DIRECT_EDIT)
- {
- if (XSDGraphUtil.isEditable(getModel()))
- {
- performDirectEdit();
- }
- }
- }
-
- // TODO... I added this as a quick fix to makesure the title gets redrawn when the groupRef is changed
- // we should probably fix the ModelListenerUtil to fire both call both 'change' methods for the ref property
- //public void modelChildrenChanged()
- //{
- // super.modelChildrenChanged();
- // refreshVisuals();
- //}
-
- public void doEditName()
- {
- ComponentNameDirectEditManager manager = new ComponentNameDirectEditManager(this, label, getXSDModelGroupDefinition());
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ModelGroupEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ModelGroupEditPart.java
deleted file mode 100644
index b793ebab46..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ModelGroupEditPart.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import java.util.List;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDChildUtility;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDGraphUtil;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.DragAndDropEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.CenteredIconFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ExpandableGraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RoundedLineBorder;
-import org.eclipse.wst.xsd.ui.internal.graph.model.XSDModelAdapterFactory;
-import org.eclipse.xsd.XSDCompositor;
-import org.eclipse.xsd.XSDModelGroup;
-import org.eclipse.xsd.XSDParticle;
-
-
-
-public class ModelGroupEditPart extends ExpandableGraphNodeEditPart
-{
- protected CenteredIconFigure centeredIconFigure;
-
- protected static Color editableBackgroundColor = null;
- protected static Color editableForegroundColor = null;
- protected static Color nonEditableForegroundColor = null;
-
- public XSDParticle getXSDParticle()
- {
- Object o = getXSDModelGroup().getContainer();
- return (o instanceof XSDParticle) ? (XSDParticle)o : null;
- }
-
- public XSDModelGroup getXSDModelGroup()
- {
- return (XSDModelGroup)getModel();
- }
-
- protected GraphNodeFigure createGraphNodeFigure()
- {
- ExpandableGraphNodeFigure figure = new ExpandableGraphNodeFigure();
-
- centeredIconFigure = new CenteredIconFigure();
- centeredIconFigure.setPreferredSize(new Dimension(32, 20));
- //centeredIconFigure.setBackgroundColor(new Color(Display.getCurrent(), 255, 0, 0));
- figure.getIconArea().add(centeredIconFigure);
- //figure.getIconArea().setLayout(new CenterLayout());
-
- ContainerFigure outlinedArea = figure.getOutlinedArea();
- outlinedArea.setBorder(new RoundedLineBorder(1, 10));
- //outlinedArea.setPreferredSize(new Dimension(32, 20));
-
- // set layout so that children are aligned vertically with some spacing
- //
- figure.getOuterContentArea().getContainerLayout().setHorizontal(false);
- figure.getOuterContentArea().getContainerLayout().setSpacing(10);
-
- return figure;
- }
-
- protected List getModelChildrenHelper()
- {
- return XSDChildUtility.getModelChildren(getXSDModelGroup());
- }
-
- protected void refreshVisuals()
- {
- String iconName = "icons/XSDSequence.gif";
- switch (getXSDModelGroup().getCompositor().getValue())
- {
- case XSDCompositor.ALL : { iconName = "icons/XSDAll.gif"; break; }
- case XSDCompositor.CHOICE : { iconName = "icons/XSDChoice.gif"; break; }
- case XSDCompositor.SEQUENCE : { iconName = "icons/XSDSequence.gif"; break; }
- }
- centeredIconFigure.image = XSDEditorPlugin.getXSDImage(iconName);
- centeredIconFigure.repaint();
-
-
- ContainerFigure outlinedArea = graphNodeFigure.getOutlinedArea() ;
- if (XSDGraphUtil.isEditable(getXSDModelGroup()))
- {
- if (editableForegroundColor == null)
- editableForegroundColor = new Color(Display.getCurrent(), 120, 152, 184);
-
- if (editableBackgroundColor == null)
- editableBackgroundColor = new Color(Display.getCurrent(), 232, 240, 248);
-
- outlinedArea.setForegroundColor(isSelected ? ColorConstants.black : editableForegroundColor);
- outlinedArea.setBackgroundColor(editableBackgroundColor);
- }
- else
- {
- if (nonEditableForegroundColor == null)
- nonEditableForegroundColor = new Color(Display.getCurrent(), 164, 164, 164);
-
- outlinedArea.setForegroundColor(isSelected ? ColorConstants.black : nonEditableForegroundColor);
- outlinedArea.setBackgroundColor(ColorConstants.white);
- }
-
- refreshOccurenceLabel(getXSDParticle());
- }
-
- protected boolean isChildLayoutHorizontal()
- {
- return false;
- }
-
- protected boolean isDefaultExpanded()
- {
- return isPossibleCycle() ? false : true;
- }
-
- // This test ensures that we don't end up with an infinite default expansion (e.g. when a group contains a cyclic group ref)
- // TODO... we probably need some more extensible 'OO' way of computing this information
- protected boolean isPossibleCycle()
- {
- boolean result = false;
- if (getParent() instanceof ModelGroupDefinitionEditPart)
- {
- ModelGroupDefinitionEditPart group = (ModelGroupDefinitionEditPart)getParent();
- for (EditPart parent = group.getParent(); parent != null; parent = parent.getParent())
- {
- if (parent.getModel() instanceof ElementDeclarationEditPart)
- {
- break;
- }
- else
- {
- if (parent.getModel() == group.getModel())
- {
- result = true;
- break;
- }
- }
- }
- }
- return result;
- }
-
- protected void createEditPolicies()
- {
- super.createEditPolicies();
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DragAndDropEditPolicy(getViewer(), selectionHandlesEditPolicy));
- }
-
- public void activate()
- {
- super.activate();
- if (getXSDParticle() != null)
- {
- XSDModelAdapterFactory.addModelAdapterListener(getXSDParticle(), this);
- }
- }
- /**
- * Apart from the deactivation done in super, the source
- * and target connections are deactivated, and the visual
- * part of the this is removed.
- *
- * @see #activate()
- */
- public void deactivate()
- {
- if (getXSDParticle() != null)
- {
- XSDModelAdapterFactory.removeModelAdapterListener(getXSDParticle(), this);
- }
- super.deactivate();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RepeatableGraphNodeEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RepeatableGraphNodeEditPart.java
deleted file mode 100644
index 6fdf7d61ca..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RepeatableGraphNodeEditPart.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.DragAndDropEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RepeatableGraphNodeFigure;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDSchema;
-
-
-
-public class RepeatableGraphNodeEditPart extends GraphNodeEditPart
-{
- protected RepeatableGraphNodeFigure getRepeatableGraphNodeFigure()
- {
- return (RepeatableGraphNodeFigure)graphNodeFigure;
- }
-
- protected GraphNodeFigure createGraphNodeFigure()
- {
- return new RepeatableGraphNodeFigure();
- }
-
- protected void refreshOccurenceLabel(XSDParticle particle)
- {
- if (particle != null)
- {
- refreshOccurenceLabel(particle.getMinOccurs(), particle.getMaxOccurs());
- }
- }
-
- protected void refreshOccurenceLabel(int min, int max)
- {
- if (min == 1 && max == 1)
- {
- getRepeatableGraphNodeFigure().getOccurenceLabel().setText("");
- }
- else
- {
- String maxString = max == -1 ? "*" : "" + max;
- getRepeatableGraphNodeFigure().getOccurenceLabel().setText(min + ".." + maxString);
- }
- getRepeatableGraphNodeFigure().getOccurenceLabel().repaint();
- }
-
- protected void createEditPolicies()
- {
- super.createEditPolicies();
-
- if (getModel() instanceof XSDElementDeclaration) {
- Object parent = ((XSDElementDeclaration) getModel()).eContainer();
-
- if (!(parent instanceof XSDSchema)) {
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DragAndDropEditPolicy(getViewer(), selectionHandlesEditPolicy));
- }
- }
- else {
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DragAndDropEditPolicy(getViewer(), selectionHandlesEditPolicy));
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RootComplexTypeDefinitionEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RootComplexTypeDefinitionEditPart.java
deleted file mode 100644
index 853a2dfa19..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RootComplexTypeDefinitionEditPart.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import java.util.List;
-
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDChildUtility;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDGraphUtil;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDInheritanceViewer;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.ComponentNameDirectEditManager;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SelectionHandlesEditPolicyImpl;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SimpleDirectEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ExpandableGraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.FillLayout;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RoundedLineBorder;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-
-
-
-public class RootComplexTypeDefinitionEditPart extends ExpandableGraphNodeEditPart
-{
- public Label label;
- protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy();
-
-
- protected GraphNodeFigure createGraphNodeFigure()
- {
- ExpandableGraphNodeFigure figure = new ExpandableGraphNodeFigure();
- figure.getOutlinedArea().setBorder(new RoundedLineBorder(1, 6));
- figure.getOutlinedArea().setLayoutManager(new FillLayout());
- figure.getOutlinedArea().setFill(true);
-
- if (getViewer() instanceof XSDInheritanceViewer)
- {
- figure.getOuterContentArea().getContainerLayout().setSpacing(10);
- }
-
- label = new Label();
- label.setFont(mediumBoldFont);
- label.setBorder(new MarginBorder(5, 8, 5, 8));
- figure.getIconArea().add(label);
-
- return figure;
- }
-
-
- protected void refreshVisuals()
- {
- super.refreshVisuals();
-
- XSDComplexTypeDefinition ctd = (XSDComplexTypeDefinition)getModel();
- label.setText(ctd.getName() != null ? ctd.getName(): "");
-
- if (XSDGraphUtil.isEditable(ctd))
- {
- figure.setForegroundColor(elementBorderColor);
- label.setForegroundColor(elementBorderColor);
- }
- else
- {
- figure.setForegroundColor(readOnlyBorderColor);
- label.setForegroundColor(readOnlyBorderColor);
- }
- }
-
-
- protected List getModelChildrenHelper()
- {
- XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition)getModel();
- if (getViewer() instanceof XSDInheritanceViewer)
- {
- return XSDChildUtility.getImmediateDerivedTypes(ct);
- }
- else
- {
- return XSDChildUtility.getModelChildren(getModel());
- }
- }
-
-
- protected void createEditPolicies()
- {
- SelectionHandlesEditPolicyImpl policy = new SelectionHandlesEditPolicyImpl();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, policy);
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, simpleDirectEditPolicy);
- }
-
-
- protected void performDirectEdit()
- {
- ComponentNameDirectEditManager manager = new ComponentNameDirectEditManager(this, label, (XSDComplexTypeDefinition)getModel());
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
-
-
- public void performRequest(Request request)
- {
- if (request.getType() == RequestConstants.REQ_DIRECT_EDIT)
- {
- if (XSDGraphUtil.isEditable(getModel()))
- {
- performDirectEdit();
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RootModelGroupDefinitionEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RootModelGroupDefinitionEditPart.java
deleted file mode 100644
index 35f4486708..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RootModelGroupDefinitionEditPart.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import java.util.List;
-
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDChildUtility;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDGraphUtil;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.ComponentNameDirectEditManager;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SelectionHandlesEditPolicyImpl;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SimpleDirectEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ExpandableGraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.FillLayout;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RoundedLineBorder;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-
-
-public class RootModelGroupDefinitionEditPart extends ExpandableGraphNodeEditPart
-{
- public Label label;
- protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy();
-
-
- protected GraphNodeFigure createGraphNodeFigure()
- {
- ExpandableGraphNodeFigure figure = new ExpandableGraphNodeFigure();
- figure.getOutlinedArea().setBorder(new RoundedLineBorder(1, 6));
- figure.getOutlinedArea().setLayoutManager(new FillLayout());
- figure.getOutlinedArea().setFill(true);
-
- label = new Label();
- label.setFont(mediumBoldFont);
- label.setBorder(new MarginBorder(5, 8, 5, 8));
- figure.getIconArea().add(label);
-
- return figure;
- }
-
- protected void refreshVisuals()
- {
- super.refreshVisuals();
-
- XSDModelGroupDefinition mgd = (XSDModelGroupDefinition)getModel();
- String name = mgd.getResolvedModelGroupDefinition().getName();
- label.setText(name);
-
- if (XSDGraphUtil.isEditable(getModel()))
- {
- figure.setForegroundColor(elementBorderColor);
- label.setForegroundColor(elementBorderColor);
- }
- else
- {
- figure.setForegroundColor(readOnlyBorderColor);
- label.setForegroundColor(readOnlyBorderColor);
- }
- }
-
- protected List getModelChildrenHelper()
- {
- return XSDChildUtility.getModelChildren(getModel());
- }
-
-
- protected void createEditPolicies()
- {
- SelectionHandlesEditPolicyImpl policy = new SelectionHandlesEditPolicyImpl();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, policy);
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, simpleDirectEditPolicy);
- }
-
-
- protected void performDirectEdit()
- {
- ComponentNameDirectEditManager manager = new ComponentNameDirectEditManager(this, label, ((XSDModelGroupDefinition)getModel()).getResolvedModelGroupDefinition());
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
-
-
- public void performRequest(Request request)
- {
- if (request.getType() == RequestConstants.REQ_DIRECT_EDIT)
- {
- if (XSDGraphUtil.isEditable(getModel()))
- {
- performDirectEdit();
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SchemaDirectiveEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SchemaDirectiveEditPart.java
deleted file mode 100644
index c0697d5fc5..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SchemaDirectiveEditPart.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.CenteredIconFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.FillLayout;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RoundedLineBorder;
-import org.eclipse.xsd.XSDSchemaDirective;
-
-
-public class SchemaDirectiveEditPart extends BaseEditPart
-{
- protected CenteredIconFigure centeredIconFigure;
- protected Label label;
- /**
- * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
- */
- protected IFigure createFigure()
- {
-
- ContainerFigure figure = new ContainerFigure();
-
- figure.setLayoutManager(new FillLayout());
- figure.setBorder(new RoundedLineBorder(1, 8));
-
- ContainerFigure fig = new ContainerFigure();
- fig.setLayoutManager(new FillLayout());
- fig.setBorder(new MarginBorder(10, 0, 10, 0));
- figure.add(fig);
-
-
- label = new Label();
- label.setBorder(new MarginBorder(4, 2, 2, 10));
- fig.add(label);
-
- return figure;
- }
-
- public void refreshVisuals()
- {
- XSDSchemaDirective directive = (XSDSchemaDirective)getModel();
- String schemaLocation = directive.getSchemaLocation();
- if (schemaLocation == null) schemaLocation = "(" + XSDEditorPlugin.getXSDString("_UI_LABEL_NO_LOCATION_SPECIFIED") + ")";
- if (schemaLocation.equals("")) schemaLocation = "(" + XSDEditorPlugin.getXSDString("_UI_LABEL_NO_LOCATION_SPECIFIED") + ")";
- label.setText(" " + directive.getElement().getLocalName() + " " + schemaLocation);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SchemaEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SchemaEditPart.java
deleted file mode 100644
index ad1f64b55d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SchemaEditPart.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.Figure;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.gef.EditPart;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.graph.GraphicsConstants;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.FillLayout;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RoundedLineBorder;
-import org.eclipse.wst.xsd.ui.internal.graph.model.Category;
-import org.eclipse.wst.xsd.ui.internal.graph.model.XSDModelAdapterFactory;
-import org.eclipse.xsd.XSDSchema;
-
-public class SchemaEditPart extends BaseEditPart
-{
- protected ContainerFigure containerFigure;
- protected Label label;
-
- //protected ContainerFigure childExpansionContainer;
- public IFigure getContentPane()
- {
- return containerFigure;
- }
-
- protected IFigure createFigure()
- {
- ContainerFigure outer = new ContainerFigure();
- outer.setBorder(new RoundedLineBorder(1, 6));
- outer.setForegroundColor(categoryBorderColor);
- FillLayout fillLayout = new FillLayout(4);
- outer.setLayoutManager(fillLayout);
- //outer.getContainerLayout().setHorizontal(false);
-
- ContainerFigure r = new ContainerFigure();
- r.setOutline(false);
- r.setMinimumSize(new Dimension(0, 0));
- r.setFill(true);
- r.setBackgroundColor(GraphicsConstants.elementBackgroundColor);
- outer.add(r);
-
- final int theMinHeight = 200;
- FillLayout outerLayout = new FillLayout()
- {
- protected Dimension calculatePreferredSize(IFigure parent, int width, int height)
- {
- Dimension d = super.calculatePreferredSize(parent, width, height);
- d.union(new Dimension(100, theMinHeight));
- return d;
- }
- };
- outerLayout.setHorizontal(false);
- outer.setLayoutManager(outerLayout);
-
- label = new Label();
- label.setForegroundColor(ColorConstants.black);
- label.setBorder(new MarginBorder(2, 4, 2, 4));
- r.add(label);
-
- RectangleFigure line = new RectangleFigure();
- line.setPreferredSize(20, 1);
- outer.add(line);
-
- containerFigure = new ContainerFigure();
- //containerFigure.setBackgroundColor(ColorConstants.red);
- containerFigure.setBorder(new MarginBorder(4, 4, 4, 4));
- fillLayout = new FillLayout(4);
- containerFigure.setLayoutManager(fillLayout);
- //containerFigure.setLayoutManager(new FillLayout(false));
- /*
- * FlowLayout layout1 = new FlowLayout(false); layout1.setMajorSpacing(0);
- * layout1.setMinorSpacing(0); layout1.setStretchMinorAxis(true);
- * containerFigure.setLayoutManager(layout1);
- */
- outer.add(containerFigure);
- //childExpansionContainer = new ContainerFigure();
- //childExpansionContainer.getContainerLayout().setHorizontal(false);
- //childExpansionContainer.setOutlined(true);
- return outer;
- }
-
- protected List getModelChildren()
- {
- List list = new ArrayList();
- list.add(CategoryRowEditPart.DIRECTIVES_AND_NOTATIONS);
- list.add(CategoryRowEditPart.ELEMENTS_AND_TYPES);
- list.add(CategoryRowEditPart.MODEL_GROUPS_AND_ATTRIBUTES);
- return list;
- }
-
- protected EditPart createChild(Object model)
- {
- CategoryRowEditPart result = new CategoryRowEditPart();
- result.setModel(model);
- result.setParent(this);
- result.setSchema((XSDSchema)getModel());
- return result;
- }
-
-
- protected void refreshVisuals()
- {
- super.refreshVisuals();
- String targetNamespaceValue = ((XSDSchema)getModel()).getTargetNamespace();
- if (targetNamespaceValue == null || targetNamespaceValue.length() == 0)
- {
- targetNamespaceValue = XSDEditorPlugin.getXSDString("_UI_GRAPH_XSDSCHEMA_NO_NAMESPACE");
- }
- label.setText(XSDEditorPlugin.getXSDString("_UI_GRAPH_XSDSCHEMA") + " : " + targetNamespaceValue);
- }
-}
-
-class CategoryRowEditPart extends BaseEditPart
-{
- public static final int[] ELEMENTS_AND_TYPES = {Category.ELEMENTS, Category.TYPES };
- public static final int[] DIRECTIVES_AND_NOTATIONS = {Category.DIRECTIVES, Category.NOTATIONS };
- public static final int[] MODEL_GROUPS_AND_ATTRIBUTES = {Category.GROUPS, Category.ATTRIBUTES};//, Category.COMPLEX_TYPES };
-
- protected XSDSchema schema;
- protected Figure contentPane;
-
- protected IFigure createFigure()
- {
- ContainerFigure containerFigure = new ContainerFigure();
- //containerFigure.setBackgroundColor(ColorConstants.red);
- containerFigure.setFill(true);
- containerFigure.setBorder(new MarginBorder(4, 4, 4, 4));
- org.eclipse.wst.xsd.ui.internal.gef.util.figures.FillLayout fillLayout = new org.eclipse.wst.xsd.ui.internal.gef.util.figures.FillLayout(4);
- fillLayout.setHorizontal(true);
- containerFigure.setLayoutManager(fillLayout);
- //containerFigure.setLayoutManager(new FillLayout(4));
- return containerFigure;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getContentPane()
- */
- public IFigure getContentPane()
- {
- return super.getContentPane();
- }
-
- public XSDSchema getSchema()
- {
- return schema;
- }
-
- public void setSchema(XSDSchema schema)
- {
- this.schema = schema;
- }
-
-
- protected List getModelChildren()
- {
- List categoryList = (List) XSDModelAdapterFactory.getAdapter(schema).getProperty(schema, "groups");
- return filterCategoryList(categoryList);
- }
-
- protected List filterCategoryList(List list)
- {
- List result = new ArrayList();
- int[] categoryTypes = (int[])getModel();
- for (Iterator i = list.iterator(); i.hasNext(); )
- {
- Category category = (Category)i.next();
- if (isMatching(categoryTypes, category))
- {
- result.add(category);
- }
- }
- return result;
- }
-
- private boolean isMatching(int[] categoryTypes, Category category)
- {
- boolean result = false;
- for (int i = 0; i < categoryTypes.length; i++)
- {
- if (categoryTypes[i] == category.getGroupType())
- {
- result = true;
- break;
- }
- }
- return result;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SimpleTypeDefinitionEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SimpleTypeDefinitionEditPart.java
deleted file mode 100644
index df1afad070..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SimpleTypeDefinitionEditPart.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.ImageFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SelectionHandlesEditPolicyImpl;
-
-public class SimpleTypeDefinitionEditPart extends BaseEditPart
-{
- protected Label label;
- protected SelectionHandlesEditPolicyImpl selectionHandlesEditPolicy;
-
- ImageFigure figure;
- Image image;
-
- protected IFigure createFigure()
- {
- String iconName = "icons/XSDSimpleTypeForEditPart.gif";
- image = XSDEditorPlugin.getXSDImage(iconName);
-
- figure = new ImageFigure(image);
- return figure;
- }
-
- protected void refreshVisuals()
- {
- if (isSelected)
- {
- image = XSDEditorPlugin.getXSDImage("icons/XSDSimpleTypeForEditPart.gif");
- }
- else
- {
- image = XSDEditorPlugin.getXSDImage("icons/XSDSimpleType.gif");
- }
- figure.setImage(image);
- figure.repaint();
- }
-
- protected boolean isConnectedEditPart()
- {
- return false;
- }
-
- public void deactivate()
- {
- super.deactivate();
- image = null; // where do we dispose the image?
- }
-
-
- protected void createEditPolicies()
- {
- selectionHandlesEditPolicy = new SelectionHandlesEditPolicyImpl();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, selectionHandlesEditPolicy);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SubstitutionGroupViewerRootEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SubstitutionGroupViewerRootEditPart.java
deleted file mode 100644
index 3899e8e6f3..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SubstitutionGroupViewerRootEditPart.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Panel;
-import org.eclipse.gef.EditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerLayout;
-
-
-
-public class SubstitutionGroupViewerRootEditPart extends BaseEditPart
-{
- protected final static String MESSAGE_PLACE_HOLDER = "MESSAGE_PLACE_HOLDER";
- protected Object input;
-
- public void setInput(Object input)
- {
- this.input = input;
- refreshChildren();
- }
-
- protected IFigure createFigure()
- {
- Panel panel = new Panel();
- ContainerLayout layout = new ContainerLayout();
- layout.setBorder(60);
- panel.setLayoutManager(layout);
- return panel;
- }
-
-
- protected List getModelChildren()
- {
- List list = new ArrayList();
- if (input != null)
- {
- list.add(input);
- }
- else
- {
- list.add(MESSAGE_PLACE_HOLDER);
- }
- return list;
- }
-
- protected EditPart createChild(Object model)
- {
- EditPart editPart = null;
- if (model == MESSAGE_PLACE_HOLDER)
- {
- editPart = new MessageEditPart();
- editPart.setModel(model);
- }
- else
- {
- editPart = super.createChild(model);
- }
- return editPart;
- }
-
- protected void createEditPolicies()
- {
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/TopLevelComponentEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/TopLevelComponentEditPart.java
deleted file mode 100644
index 04b686af7e..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/TopLevelComponentEditPart.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.gef.editpolicies.SelectionEditPolicy;
-import org.eclipse.gef.requests.LocationRequest;
-import org.eclipse.gef.ui.parts.AbstractEditPartViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.gef.util.editparts.AbstractComponentViewerRootEditPart;
-import org.eclipse.wst.xsd.ui.internal.gef.util.figures.FillLayout;
-import org.eclipse.wst.xsd.ui.internal.graph.GraphicsConstants;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDComponentViewer;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDGraphUtil;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.ComponentNameDirectEditManager;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SelectionHandlesEditPolicyImpl;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SimpleDirectEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.model.ModelAdapter;
-import org.eclipse.wst.xsd.ui.internal.graph.model.XSDModelAdapterFactory;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDNamedComponent;
-
-
-public class TopLevelComponentEditPart extends BaseEditPart implements IFeedbackHandler
-{
- protected Label label;
- //protected Label arrowLabel;
- protected ContainerFigure labelHolder = new ContainerFigure();
- protected SelectionHandlesEditPolicyImpl selectionHandlesEditPolicy;
- protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy();
- protected boolean isReadOnly;
- protected boolean isSelected;
- protected Font font;
-
- protected IFigure createFigure()
- {
- ContainerFigure typeGroup = new ContainerFigure();
- typeGroup.getContainerLayout().setHorizontal(true);
-
- //arrowLabel = new Label();
- //arrowLabel.setIcon(XSDEditorPlugin.getPlugin().getImage("icons/forward.gif"));
- //typeGroup.add(arrowLabel);
-
- labelHolder = new ContainerFigure();
- FillLayout fillLayout = new FillLayout();
- labelHolder.setLayoutManager(fillLayout);
- labelHolder.setFill(true);
- typeGroup.add(labelHolder);
-
- label = new Label();
- label.setBorder(new MarginBorder(0, 2, 2, 1));
- label.setForegroundColor(ColorConstants.black);
- labelHolder.add(label);
-
- try
- {
- // evil hack to provide underlines
- Object model = getModel();
-
- boolean isLinux = java.io.File.separator.equals("/");
- if (model instanceof XSDComplexTypeDefinition ||
- model instanceof XSDElementDeclaration ||
- model instanceof XSDModelGroupDefinition)
- {
- if (!isLinux)
- {
- FontData oldData = GraphicsConstants.medium.getFontData()[0];
- FontData fontData = new FontData(oldData.getName(), oldData.getHeight(), SWT.NONE);
-
- // TODO... clean this awful code up... we seem to be leaking here too
- // we can't call this directly since the methods are OS dependant
- // fontData.data.lfUnderline = 1
- // so instead we use reflection
- Object data = fontData.getClass().getField("data").get(fontData);
-// System.out.println("data" + data.getClass());
- data.getClass().getField("lfUnderline").setByte(data, (byte)1);
- font = new Font(Display.getCurrent(), fontData);
- label.setFont(font);
- }
- }
- }
- catch (Exception e)
- {
-
- }
-
- return typeGroup;
- }
-
- public void deactivate()
- {
- super.deactivate();
- if (font != null)
- {
- font.dispose();
- font = null;
- }
- }
-
- public void refreshVisuals()
- {
- ModelAdapter adapter = XSDModelAdapterFactory.getAdapter(getModel());
- if (adapter != null)
- {
- // isReadOnly = Boolean.TRUE.equals(adapter.getProperty(getModel(), "isReadOnly"));
- isReadOnly = !XSDGraphUtil.isEditable(getModel());
- label.setForegroundColor(computeLabelColor());
- label.setText((String)adapter.getProperty(getModel(), ModelAdapter.LABEL_PROPERTY));
- Image image = (Image)adapter.getProperty(getModel(), ModelAdapter.IMAGE_PROPERTY);
- if (image != null) label.setIcon(image);
- //arrowLabel.setVisible(Boolean.TRUE.equals(adapter.getProperty(getModel(), "drillDown")));
- }
- else
- {
- label.setText(XSDEditorPlugin.getXSDString("_UI_GRAPH_UNKNOWN_OBJECT") + getModel().getClass().getName());
- //arrowLabel.setVisible(false);
- }
-
- if (reselect)
- {
- getViewer().select(this);
- setReselect(false);
- }
- }
-
-
- public XSDNamedComponent getXSDNamedComponent()
- {
- return (XSDNamedComponent) getModel();
- }
-
- public List getModelChildren()
- {
- return Collections.EMPTY_LIST;
- }
-
- protected void createEditPolicies()
- {
- //installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new NonResizableEditPolicy());
- //selectionHandlesEditPolicy = new SelectionHandlesEditPolicyImpl();
- //installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, selectionHandlesEditPolicy);
-
- SelectionHandlesEditPolicyImpl policy = new SelectionHandlesEditPolicyImpl();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, policy);
-
- SelectionEditPolicy feedBackSelectionEditPolicy = new SelectionEditPolicy()
- {
- protected void hideSelection()
- {
- EditPart editPart = getHost();
- if (editPart instanceof IFeedbackHandler)
- {
- ((IFeedbackHandler)editPart).removeFeedback();
- }
- }
-
- protected void showSelection()
- {
- EditPart editPart = getHost();
- if (editPart instanceof IFeedbackHandler)
- {
- ((IFeedbackHandler)editPart).addFeedback();
- }
- }
- };
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, feedBackSelectionEditPolicy);
-
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, simpleDirectEditPolicy);
- }
-
- public Color computeLabelColor()
- {
- Color color = ColorConstants.black;
- if (isSelected)
- {
- color = ColorConstants.white;
- }
- else if (isReadOnly)
- {
- color = ColorConstants.gray;
- }
- return color;
- }
-
-
- public void addFeedback()
- {
- isSelected = true;
-
- labelHolder.setBackgroundColor(ColorConstants.black);
- label.setForegroundColor(computeLabelColor());
- labelHolder.setFill(true);
-
- if (doScroll)
- {
- CategoryEditPart categoryEP = (CategoryEditPart)getParent();
- categoryEP.scrollTo(this);
- setScroll(false);
- }
- }
-
- private boolean doScroll = false;
- public void setScroll(boolean doScroll)
- {
- this.doScroll = doScroll;
- }
-
- public void removeFeedback()
- {
- isSelected = false;
- labelHolder.setBackgroundColor(null);
- label.setForegroundColor(computeLabelColor());
- labelHolder.setFill(false);
- }
-
- public void performRequest(Request request)
- {
- if (request.getType() == RequestConstants.REQ_DIRECT_EDIT ||
- request.getType() == RequestConstants.REQ_OPEN)
- {
-
- Object model = getModel();
- if (model instanceof XSDComplexTypeDefinition ||
- model instanceof XSDElementDeclaration ||
- model instanceof XSDModelGroupDefinition)
- {
- if (request instanceof LocationRequest)
- {
- LocationRequest locationRequest = (LocationRequest)request;
- Point p = locationRequest.getLocation();
-
- if (hitTest(labelHolder, p))
- {
- performDrillDownAction();
- }
- }
- }
- }
- }
-
- public boolean hitTest(IFigure target, Point location)
- {
- Rectangle b = target.getBounds().getCopy();
- target.translateToAbsolute(b);
- return b.contains(location);
- }
-
- protected void performDrillDownAction()
- {
- Runnable runnable = new Runnable()
- {
- public void run()
- {
- //((XSDComponentViewer)getViewer()).setInput((XSDConcreteComponent)getModel());
-
- EditPart editPart = ((AbstractEditPartViewer)getViewer()).getRootEditPart().getContents();
- if (editPart instanceof AbstractComponentViewerRootEditPart)
- {
- AbstractComponentViewerRootEditPart rootEditPart = (AbstractComponentViewerRootEditPart)editPart;
- rootEditPart.setInput((XSDConcreteComponent)getModel());
- }
- else if (editPart instanceof BaseEditPart)
- {
- ((XSDComponentViewer)getViewer()).setInput((XSDConcreteComponent)getModel());
- }
- }
- };
- Display.getCurrent().asyncExec(runnable);
- }
-
- public void doEditName()
- {
- removeFeedback();
- Object object = getModel();
- if (object instanceof XSDNamedComponent)
- {
- ComponentNameDirectEditManager manager = new ComponentNameDirectEditManager(this, label, (XSDNamedComponent)object);
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
- }
-
-
- static boolean reselect = false;
-
- public void setReselect(boolean state)
- {
- reselect = state;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/TypeEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/TypeEditPart.java
deleted file mode 100644
index 37a83e11ba..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/TypeEditPart.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SelectionHandlesEditPolicyImpl;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SimpleDirectEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.xsd.XSDTypeDefinition;
-
-
-public class TypeEditPart extends BaseEditPart
-{
- protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy();
-
- protected IFigure createFigure()
- {
- ContainerFigure typeGroup = new ContainerFigure();
-// typeGroup.setBorder(new SimpleRaisedBorder(1));
-// typeGroup.setBorder(new LineBorder(1));
-// typeGroup.setBorder(new RoundedLineBorder(1,5));
-
- Label typeLabel = new Label("type");
- typeLabel.setBorder(new MarginBorder(0,2,2,1));
- typeGroup.add(typeLabel);
-
- return typeGroup;
- }
-
- protected void refreshVisuals()
- {
- super.refreshVisuals();
- }
-
- public XSDTypeDefinition getXSDTypeDefinition()
- {
- return (XSDTypeDefinition)getModel();
- }
-
-
- public List getModelChildren()
- {
- return Collections.EMPTY_LIST;
- }
-
- protected void createEditPolicies()
- {
- SelectionHandlesEditPolicyImpl policy = new SelectionHandlesEditPolicyImpl();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, policy);
- }
-
-
- public void performRequest(Request request)
- {
- super.performRequest(request);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/WildcardEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/WildcardEditPart.java
deleted file mode 100644
index 53a86a19d0..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/WildcardEditPart.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.LineBorder;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDGraphUtil;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RepeatableGraphNodeFigure;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDWildcard;
-
-
-public class WildcardEditPart extends RepeatableGraphNodeEditPart
-{
- protected Label label;
-
-
- public XSDParticle getXSDParticle()
- {
- Object o = getXSDWildcard().getContainer();
- return (o instanceof XSDParticle) ? (XSDParticle)o : null;
- }
-
-
- public XSDWildcard getXSDWildcard()
- {
- return (XSDWildcard)getModel();
- }
-
-
- protected GraphNodeFigure createGraphNodeFigure()
- {
- RepeatableGraphNodeFigure figure = new RepeatableGraphNodeFigure();
- figure.setConnected(true);
- figure.getOutlinedArea().setFill(true);
-
- label = new Label();
- label.setText(XSDEditorPlugin.getXSDString("_UI_ANY_ELEMENT"));
- label.setBorder(new MarginBorder(0, 6, 0, 4));
- label.setFont(mediumBoldFont);
-
- figure.getIconArea().add(label);
-
- return figure;
- }
-
-
- protected void refreshVisuals()
- {
- ContainerFigure rectangle = graphNodeFigure.getOutlinedArea();
- if (XSDGraphUtil.isEditable(getModel()))
- {
- rectangle.setBorder(new LineBorder(2));
- rectangle.setBackgroundColor(elementBackgroundColor);
- rectangle.setForegroundColor(isSelected ? ColorConstants.black : elementBorderColor);
-
- label.setBackgroundColor(elementBackgroundColor);
- label.setForegroundColor(elementLabelColor);
- }
- else
- {
- rectangle.setBorder(new LineBorder(readOnlyBorderColor, 2));
- rectangle.setBackgroundColor(readOnlyBackgroundColor);
- rectangle.setForegroundColor(isSelected ? ColorConstants.black : readOnlyBorderColor);
-
- label.setBackgroundColor(readOnlyBackgroundColor);
- label.setForegroundColor(readOnlyBorderColor);
- }
-
- refreshOccurenceLabel(getXSDParticle());
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/XSDEditPartFactory.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/XSDEditPartFactory.java
deleted file mode 100644
index 5d6ed1e13b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/XSDEditPartFactory.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.graph.editparts;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPartFactory;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDInheritanceViewer;
-import org.eclipse.wst.xsd.ui.internal.graph.model.Category;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroup;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDWildcard;
-
-
-
-public class XSDEditPartFactory implements EditPartFactory
-{
- protected static XSDEditPartFactory instance;
-
- public static XSDEditPartFactory getInstance()
- {
- if (instance == null)
- {
- instance = new XSDEditPartFactory();
- }
- return instance;
- }
-
- public EditPart createEditPart(EditPart parent, Object model)
- {
- EditPart editPart = null;
-
- if (model instanceof Category)
- {
- editPart = new CategoryEditPart();
- }
- else if (model instanceof XSDElementDeclaration)
- {
- editPart = new ElementDeclarationEditPart();
- }
- else if (model instanceof XSDComplexTypeDefinition)
- {
- if (parent.getViewer() instanceof XSDInheritanceViewer)
- {
- editPart = new RootComplexTypeDefinitionEditPart();
- }
- else
- {
- if (parent instanceof CategoryEditPart)
- editPart = new RootComplexTypeDefinitionEditPart();
- else
- editPart = new ComplexTypeDefinitionEditPart();
- }
- }
- else if (model instanceof XSDModelGroup)
- {
- editPart = new ModelGroupEditPart();
- }
- else if (model instanceof XSDModelGroupDefinition)
- {
- if (parent instanceof CategoryEditPart)
- editPart = new RootModelGroupDefinitionEditPart();
- else
- editPart = new ModelGroupDefinitionEditPart();
- }
- else if (model instanceof XSDSchema)
- {
- editPart = new SchemaEditPart();
- }
- else if (model instanceof XSDWildcard)
- {
- editPart = new WildcardEditPart();
- }
- else if (model instanceof XSDSimpleTypeDefinition)
- {
- editPart = new SimpleTypeDefinitionEditPart();
- }
-
- if (editPart != null)
- {
- editPart.setModel(model);
- editPart.setParent(parent);
- }
- else
- {
-// System.out.println("can't create editPart for " + model);
-// Thread.dumpStack();
- }
- return editPart;
- }
-}

Back to the top