diff options
Diffstat (limited to 'bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts')
18 files changed, 0 insertions, 3144 deletions
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/AttributeGroupDefinitionEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/AttributeGroupDefinitionEditPart.java deleted file mode 100644 index 93c4fee761..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/AttributeGroupDefinitionEditPart.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 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.design.editparts; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDAdapterFactory; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeGroupDefinitionAdapter; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.CenteredConnectionAnchor; -import org.eclipse.wst.xsd.ui.internal.design.editparts.model.TargetConnectionSpaceFiller; -import org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure; -import org.eclipse.xsd.XSDAttributeGroupContent; -import org.eclipse.xsd.XSDAttributeGroupDefinition; -import org.eclipse.xsd.XSDAttributeUse; - -public class AttributeGroupDefinitionEditPart extends ConnectableEditPart -{ - public AttributeGroupDefinitionEditPart() - { - super(); - } - - public XSDAttributeGroupDefinition getXSDAttributeGroupDefinition() - { - if (getModel() instanceof XSDAttributeGroupDefinitionAdapter) - { - XSDAttributeGroupDefinitionAdapter adapter = (XSDAttributeGroupDefinitionAdapter) getModel(); - return (XSDAttributeGroupDefinition) adapter.getTarget(); - } -// else if (getModel() instanceof XSDAttributeGroupDefinition) -// { -// return (XSDAttributeGroupDefinition) getModel(); -// } - return null; - - } - - protected IFigure createFigure() - { - GenericGroupFigure figure = new GenericGroupFigure(); - XSDAttributeGroupDefinitionAdapter adapter = (XSDAttributeGroupDefinitionAdapter) getModel(); - figure.getIconFigure().image = adapter.getImage(); - return figure; - } - - protected List getModelChildren() - { - List list = new ArrayList(); - - XSDAttributeGroupDefinitionAdapter adapter = (XSDAttributeGroupDefinitionAdapter)getModel(); - XSDAttributeGroupDefinition attributeGroupDefinition = adapter.getXSDAttributeGroupDefinition(); - Iterator i = attributeGroupDefinition.getResolvedAttributeGroupDefinition().getContents().iterator(); - - while (i.hasNext()) - { - XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent) i.next(); - - if (attrGroupContent instanceof XSDAttributeGroupDefinition) - { - list.add(XSDAdapterFactory.getInstance().adapt(attrGroupContent)); - } - else if (attrGroupContent instanceof XSDAttributeUse) - { - list.add(new TargetConnectionSpaceFiller((XSDBaseAdapter)XSDAdapterFactory.getInstance().adapt(((XSDAttributeUse)attrGroupContent).getAttributeDeclaration()))); - } - else - { - list.add(new TargetConnectionSpaceFiller((XSDBaseAdapter)getModel())); - } - } - - if (list.isEmpty()) - { - list.add(new TargetConnectionSpaceFiller((XSDBaseAdapter)getModel())); - } - - return list; - } - - - public ReferenceConnection createConnectionFigure(BaseEditPart child) - { - ReferenceConnection connectionFigure = new ReferenceConnection(); - - connectionFigure.setSourceAnchor(new CenteredConnectionAnchor(((GenericGroupFigure)getFigure()).getIconFigure(), CenteredConnectionAnchor.RIGHT, 0, 0)); - - if (child instanceof AttributeGroupDefinitionEditPart) - { - connectionFigure.setTargetAnchor(new CenteredConnectionAnchor(((AttributeGroupDefinitionEditPart) child).getTargetFigure(), CenteredConnectionAnchor.LEFT, 0, 0)); - } - else if (child instanceof TargetConnectionSpacingFigureEditPart) - { -// TargetConnectionSpacingFigureEditPart elem = (TargetConnectionSpacingFigureEditPart) child; - connectionFigure.setTargetAnchor(new CenteredConnectionAnchor(((TargetConnectionSpacingFigureEditPart) child).getFigure(), CenteredConnectionAnchor.LEFT, 0, 0)); - } - - connectionFigure.setHighlight(false); - return connectionFigure; - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/CategoryEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/CategoryEditPart.java deleted file mode 100644 index 88f312c90c..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/CategoryEditPart.java +++ /dev/null @@ -1,237 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 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.design.editparts; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.RectangleFigure; -import org.eclipse.draw2d.ScrollPane; -import org.eclipse.draw2d.ToolbarLayout; -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.swt.SWT; -import org.eclipse.wst.xsd.ui.internal.adapters.CategoryAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.EditPartNavigationHandlerUtil; -import org.eclipse.wst.xsd.ui.internal.adt.typeviz.design.figures.HeadingFigure; -import org.eclipse.wst.xsd.ui.internal.adt.typeviz.design.figures.RoundedLineBorder; -import org.eclipse.wst.xsd.ui.internal.design.editpolicies.SelectionHandlesEditPolicyImpl; -import org.eclipse.wst.xsd.ui.internal.design.layouts.ContainerLayout; - -public class CategoryEditPart extends BaseEditPart -{ - protected SelectionHandlesEditPolicyImpl selectionHandlesEditPolicy; - Figure outerPane; - HeadingFigure headingFigure; - protected ScrollPane scrollpane; - protected int minimumHeight = 400; - - public int getType() - { - return ((CategoryAdapter) getModel()).getGroupType(); - } - - protected IFigure createFigure() - { - outerPane = new Figure(); - outerPane.setBorder(new RoundedLineBorder(1, 6)); - - headingFigure = new HeadingFigure(); - outerPane.add(headingFigure); - headingFigure.getLabel().setText(((CategoryAdapter) getModel()).getText()); - headingFigure.getLabel().setIcon(((CategoryAdapter) getModel()).getImage()); - - int minHeight = SWT.DEFAULT; - switch (getType()) - { - case CategoryAdapter.DIRECTIVES: - { - minHeight = 80; - break; - } - case CategoryAdapter.ATTRIBUTES: - case CategoryAdapter.GROUPS: - { - minHeight = 100; - break; - } - } - - final int theMinHeight = minHeight; - - ToolbarLayout outerLayout = new ToolbarLayout(false) - { - protected Dimension calculatePreferredSize(IFigure parent, int width, int height) - { - Dimension d = super.calculatePreferredSize(parent, width, height); - d.union(new Dimension(250, theMinHeight)); - return d; - } - }; - outerLayout.setStretchMinorAxis(true); - outerPane.setLayoutManager(outerLayout); - - RectangleFigure line = new RectangleFigure() - { - public Dimension getPreferredSize(int wHint, int hHint) - { - Dimension d = super.getPreferredSize(wHint, hHint); - d.width += 20; - d.height = 1; - return d; - } - }; - ToolbarLayout lineLayout = new ToolbarLayout(false); - lineLayout.setVertical(true); - lineLayout.setStretchMinorAxis(true); - line.setLayoutManager(lineLayout); - outerPane.add(line); - - scrollpane = new ScrollPane(); - scrollpane.setVerticalScrollBarVisibility(ScrollPane.AUTOMATIC); // ScrollPane.ALWAYS); - outerPane.add(scrollpane); - - Figure pane = new Figure(); - 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); - if (theMinHeight > 0) - d.height = Math.min(d.height, theMinHeight); - else - { - double factor = getZoomManager().getZoom(); - int scaledHeight = (int)Math.round((getViewer().getControl().getBounds().height - minimumHeight) / factor); // adjust for other categories and spaces - d.height = Math.max(250, scaledHeight); - } - d.width = Math.min(d.width, 300); - return d; - } - }; - viewport.setLayoutManager(viewportLayout); - - scrollpane.setViewport(viewport); - scrollpane.setContents(pane); - - return outerPane; - } - - public void refreshVisuals() - { - super.refreshVisuals(); - - RoundedLineBorder border = (RoundedLineBorder) outerPane.getBorder(); - border.setWidth(isSelected ? 2 : 1); - headingFigure.setSelected(isSelected); - outerPane.repaint(); - - headingFigure.getLabel().setText(((CategoryAdapter) getModel()).getText()); - } - - public IFigure getContentPane() - { - return scrollpane.getContents(); - } - - public Label getNameLabel() - { - return headingFigure.getLabel(); - } - - public HeadingFigure getHeadingFigure() - { - return headingFigure; - } - - protected EditPart createChild(Object model) - { - EditPart editPart = new TopLevelComponentEditPart(); - editPart.setModel(model); - editPart.setParent(this); - return editPart; - } - - public EditPart doGetRelativeEditPart(EditPart editPart, int direction) - { - EditPart result = null; - if (editPart instanceof TopLevelComponentEditPart) - { - if (direction == PositionConstants.SOUTH) - { - result = EditPartNavigationHandlerUtil.getNextSibling(editPart); - } - else if (direction == PositionConstants.NORTH) - { - result = EditPartNavigationHandlerUtil.getPrevSibling(editPart); - } - if (result != null) - { - scrollTo((AbstractGraphicalEditPart)editPart); - } - } - else - { - result = ((BaseEditPart)getParent()).doGetRelativeEditPart(editPart, direction); - } - return result; - } - - protected void createEditPolicies() - { - super.createEditPolicies(); - // cs : oddly arrowing up and down true items in the list is not handled nicely - // by the canned GEF GraphicalViewerKeyHandler so this navigation policy is need to fix that - selectionHandlesEditPolicy = new SelectionHandlesEditPolicyImpl(); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, selectionHandlesEditPolicy); - } - - protected List getModelChildren() - { - CategoryAdapter adapter = (CategoryAdapter) getModel(); - List children = new ArrayList(Arrays.asList(adapter.getAllChildren())); - return children; - } - - public void scrollTo(AbstractGraphicalEditPart topLevel) - { - Rectangle topLevelBounds = topLevel.getFigure().getBounds(); - Rectangle categoryBounds = figure.getBounds(); - int scrollValue = scrollpane.getVerticalScrollBar().getValue(); - int location = topLevelBounds.y + scrollValue - categoryBounds.y; - scrollpane.scrollVerticalTo(location - categoryBounds.height / 2); - } - - public void setMinimumHeight(int minimumHeight) - { - this.minimumHeight = minimumHeight; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/ConnectableEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/ConnectableEditPart.java deleted file mode 100644 index 5132936e10..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/ConnectableEditPart.java +++ /dev/null @@ -1,275 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 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.design.editparts; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartFactory; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.LayerConstants; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.CompartmentEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.ADTSelectionFeedbackEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.KeyBoardAccessibilityEditPolicy; -import org.eclipse.wst.xsd.ui.internal.design.figures.CenteredIconFigure; -import org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure; -import org.eclipse.wst.xsd.ui.internal.design.figures.IExtendedFigureFactory; -import org.eclipse.xsd.XSDConcreteComponent; - -public abstract class ConnectableEditPart extends BaseEditPart -{ - protected ArrayList connectionFigures = new ArrayList(); - - public IExtendedFigureFactory getExtendedFigureFactory() - { - EditPartFactory factory = getViewer().getEditPartFactory(); - Assert.isTrue(factory instanceof IExtendedFigureFactory, "EditPartFactory must be an instanceof of IExtendedFigureFactory"); //$NON-NLS-1$ - return (IExtendedFigureFactory)factory; - } - - public ConnectableEditPart() - { - super(); - } - - protected IFigure createFigure() - { - GenericGroupFigure figure = new GenericGroupFigure(); - return figure; - } - - public XSDConcreteComponent getXSDConcreteComponent() - { - return (XSDConcreteComponent)((XSDBaseAdapter)getModel()).getTarget(); - } - - public List getConnectionFigures() - { - return connectionFigures; - } - - public abstract ReferenceConnection createConnectionFigure(BaseEditPart child); - - public void activate() - { - super.activate(); - activateConnection(); - } - - protected void activateConnection() - { - if (connectionFigures == null) - { - connectionFigures = new ArrayList(); - } - for (Iterator i = getChildren().iterator(); i.hasNext();) - { - Object o = i.next(); - if (o instanceof BaseEditPart) - { - BaseEditPart g = (BaseEditPart) o; - ReferenceConnection figure = createConnectionFigure(g); - connectionFigures.add(figure); - figure.setPoints(figure.getPoints()); - - getLayer(LayerConstants.CONNECTION_LAYER).add(figure); - } - } - } - - public void deactivate() - { - super.deactivate(); - deactivateConnection(); - } - - protected void deactivateConnection() - { - // if we have a connection, remove it - ReferenceConnection connectionFigure; - if (connectionFigures != null && !connectionFigures.isEmpty()) - { - for (Iterator i = connectionFigures.iterator(); i.hasNext();) - { - connectionFigure = (ReferenceConnection) i.next(); - - if (getLayer(LayerConstants.CONNECTION_LAYER).getChildren().contains(connectionFigure)) - { - getLayer(LayerConstants.CONNECTION_LAYER).remove(connectionFigure); - } - } - connectionFigures = null; - } - } - - public void refresh() - { - super.refresh(); - refreshConnection(); - } - - protected void refreshConnection() - { - if (!isActive()) - return; - - if (connectionFigures == null || connectionFigures.isEmpty()) - { - activateConnection(); - } - else - { - deactivateConnection(); - activateConnection(); - } - } - - public void addFeedback() - { - ReferenceConnection connectionFigure; - if (connectionFigures != null && !connectionFigures.isEmpty()) - { - for (Iterator i = connectionFigures.iterator(); i.hasNext();) - { - connectionFigure = (ReferenceConnection) i.next(); - connectionFigure.setHighlight(true); - } - } - GenericGroupFigure figure = (GenericGroupFigure)getFigure(); - figure.getIconFigure().setMode(CenteredIconFigure.SELECTED); - figure.getIconFigure().refresh(); - } - - public void removeFeedback() - { - ReferenceConnection connectionFigure; - if (connectionFigures != null && !connectionFigures.isEmpty()) - { - for (Iterator i = connectionFigures.iterator(); i.hasNext();) - { - connectionFigure = (ReferenceConnection) i.next(); - connectionFigure.setHighlight(false); - } - } - GenericGroupFigure figure = (GenericGroupFigure)getFigure(); - figure.getIconFigure().setMode(CenteredIconFigure.NORMAL); - figure.getIconFigure().refresh(); - } - - protected void refreshVisuals() - { - super.refreshVisuals(); - GenericGroupFigure figure = (GenericGroupFigure)getFigure(); - figure.getIconFigure().refresh(); - } - - protected void createEditPolicies() - { - super.createEditPolicies(); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new ADTSelectionFeedbackEditPolicy()); - } - - protected void addChildVisual(EditPart childEditPart, int index) - { - IFigure child = ((GraphicalEditPart) childEditPart).getFigure(); - getContentPane().add(child, index); - } - - protected void removeChildVisual(EditPart childEditPart) - { - IFigure child = ((GraphicalEditPart) childEditPart).getFigure(); - getContentPane().remove(child); - } - - public IFigure getContentPane() - { - return ((GenericGroupFigure)getFigure()).getContentFigure(); - } - - public Figure getTargetFigure() - { - return ((GenericGroupFigure)getFigure()).getTargetFigure(); - } - - public EditPart doGetRelativeEditPart(EditPart editPart, int direction) - { - EditPart result = null; - if (direction == PositionConstants.WEST) - { - if (getParent() instanceof ConnectableEditPart) - { - result = getParent(); - } - else - { - result = this; - } - } - else if (direction == PositionConstants.EAST) - { - result = (EditPart) editPart.getChildren().get(0); - TargetConnectionSpacingFigureEditPart target = null; - boolean foundSelectableGroup = false; - for (Iterator i = editPart.getChildren().iterator(); i.hasNext(); ) - { - EditPart child = (EditPart)i.next(); - if (!(child instanceof TargetConnectionSpacingFigureEditPart)) - { - foundSelectableGroup = true; - result = child; - break; - } - } - if (result instanceof TargetConnectionSpacingFigureEditPart) - { - target = (TargetConnectionSpacingFigureEditPart) result; - } - if (!foundSelectableGroup && target != null) - { - EditPart parent = editPart.getParent(); - while (!(parent instanceof CompartmentEditPart)) - { - parent = parent.getParent(); - if (parent == null) break; - } - for (Iterator i = parent.getChildren().iterator(); i.hasNext(); ) - { - EditPart child = (EditPart) i.next(); - if (child instanceof BaseFieldEditPart && !(child instanceof SpaceFillerForFieldEditPart)) - { - BaseFieldEditPart field = (BaseFieldEditPart) child; - if (field.getFigure().getBounds().getCenter().y < target.getFigure().getBounds().bottom() && - field.getFigure().getBounds().getCenter().y > target.getFigure().getBounds().y) - { - return child; - } - } - } - return editPart; - } - } - else if (direction == KeyBoardAccessibilityEditPolicy.IN_TO_FIRST_CHILD) - { - result = (EditPart) editPart.getChildren().get(0); - } - return result; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/ModelGroupDefinitionReferenceEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/ModelGroupDefinitionReferenceEditPart.java deleted file mode 100644 index 248e6e6074..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/ModelGroupDefinitionReferenceEditPart.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 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.design.editparts; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDAdapterFactory; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDModelGroupDefinitionAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.CenteredConnectionAnchor; -import org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDModelGroupDefinition; - -public class ModelGroupDefinitionReferenceEditPart extends ConnectableEditPart -{ - GenericGroupFigure figure; - - public ModelGroupDefinitionReferenceEditPart() - { - super(); - } - - protected IFigure createFigure() - { - figure = new GenericGroupFigure(); - return figure; - } - - protected void refreshVisuals() - { - super.refreshVisuals(); - XSDModelGroupDefinitionAdapter adapter = (XSDModelGroupDefinitionAdapter)getModel(); - figure.getIconFigure().image = adapter.getImage(); - - GenericGroupFigure groupFigure = (GenericGroupFigure)getFigure(); - String nodeName = ""; - - // TODO: commmon this up with ModelGroupEditPart, XSDParticleAdapter's code - - // -2 means the user didn't specify (so the default is 1) - int minOccurs = adapter.getMinOccurs(); - int maxOccurs = adapter.getMaxOccurs(); - String occurenceDescription = ""; //$NON-NLS-1$ - - if (minOccurs == -3 && maxOccurs == -3) - { - occurenceDescription = nodeName; - groupFigure.setText(null); - } - else if (minOccurs == 0 && (maxOccurs == -2 || maxOccurs == 1)) - { - occurenceDescription = nodeName + " [0..1]"; //$NON-NLS-1$ - groupFigure.setText("0..1"); - } - else if ((minOccurs == 1 && maxOccurs == 1) || - (minOccurs == -2 && maxOccurs == 1) || - (minOccurs == 1 && maxOccurs == -2)) - { - occurenceDescription = nodeName + " [1..1]"; //$NON-NLS-1$ - groupFigure.setText("1..1"); - } - else if (minOccurs == -2 && maxOccurs == -2) - { - occurenceDescription = nodeName; - groupFigure.setText(null); - } - else - { - if (maxOccurs == -2) maxOccurs = 1; - String maxSymbol = maxOccurs == -1 ? "*" : "" + maxOccurs; //$NON-NLS-1$ //$NON-NLS-2$ - - String minSymbol = minOccurs == -2 ? "1" : "" + minOccurs; //$NON-NLS-1$ //$NON-NLS-2$ - occurenceDescription = nodeName + " [" + minSymbol + ".." + maxSymbol + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - groupFigure.setText(minSymbol + ".." + maxSymbol); - } - - groupFigure.getIconFigure().setToolTipText(occurenceDescription); - groupFigure.getIconFigure().repaint(); - - } - - protected List getModelChildren() - { - List list = new ArrayList(); - - XSDModelGroupDefinitionAdapter adapter = (XSDModelGroupDefinitionAdapter)getModel(); - XSDModelGroup xsdModelGroup = ((XSDModelGroupDefinition) adapter.getTarget()).getResolvedModelGroupDefinition().getModelGroup(); - if (xsdModelGroup != null) - list.add(XSDAdapterFactory.getInstance().adapt(xsdModelGroup)); - return list; - } - - public ReferenceConnection createConnectionFigure(BaseEditPart child) - { - ReferenceConnection connectionFigure = new ReferenceConnection(); - - connectionFigure.setSourceAnchor(new CenteredConnectionAnchor(((GenericGroupFigure)getFigure()).getIconFigure(), CenteredConnectionAnchor.RIGHT, 0, 0)); - - if (child instanceof ModelGroupEditPart) - { - connectionFigure.setTargetAnchor(new CenteredConnectionAnchor(((ModelGroupEditPart) child).getTargetFigure(), CenteredConnectionAnchor.LEFT, 0, 0)); - } - connectionFigure.setHighlight(false); - return connectionFigure; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/ModelGroupEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/ModelGroupEditPart.java deleted file mode 100644 index 1a03f37d64..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/ModelGroupEditPart.java +++ /dev/null @@ -1,224 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 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.design.editparts; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDAdapterFactory; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDModelGroupAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.CenteredConnectionAnchor; -import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils; -import org.eclipse.wst.xsd.ui.internal.design.editparts.model.TargetConnectionSpaceFiller; -import org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure; -import org.eclipse.wst.xsd.ui.internal.design.figures.ModelGroupFigure; -import org.eclipse.xsd.XSDCompositor; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDModelGroupDefinition; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDWildcard; -import org.eclipse.xsd.util.XSDConstants; - -public class ModelGroupEditPart extends ConnectableEditPart -{ - protected IFigure createFigure() - { - return getExtendedFigureFactory().createModelGroupFigure(getModel()); - } - - public XSDParticle getXSDParticle() - { - Object o = getXSDModelGroup().getContainer(); - return (o instanceof XSDParticle) ? (XSDParticle) o : null; - } - - public XSDModelGroup getXSDModelGroup() - { - if (getModel() instanceof XSDModelGroupAdapter) - { - XSDModelGroupAdapter adapter = (XSDModelGroupAdapter) getModel(); - return (XSDModelGroup) adapter.getTarget(); - } -// else if (getModel() instanceof XSDModelGroup) -// { -// return (XSDModelGroup) getModel(); -// } - return null; - - } - - - - protected void refreshVisuals() - { - boolean isReadOnly = false; - GenericGroupFigure modelGroupFigure = (GenericGroupFigure)getFigure(); - - XSDModelGroupAdapter adapter = (XSDModelGroupAdapter) getModel(); - isReadOnly = adapter.isReadOnly(); - - String nodeName = ""; - Image image; - switch (getXSDModelGroup().getCompositor().getValue()) - { - case XSDCompositor.ALL: - { - image = isReadOnly ? ModelGroupFigure.ALL_ICON_DISABLED_IMAGE :ModelGroupFigure.ALL_ICON_IMAGE; - modelGroupFigure.getIconFigure().image = XSDCommonUIUtils.getUpdatedImage((XSDConcreteComponent)adapter.getTarget(), image, isReadOnly); - nodeName = XSDConstants.ALL_ELEMENT_TAG; - break; - } - case XSDCompositor.CHOICE: - { - image = isReadOnly ? ModelGroupFigure.CHOICE_ICON_DISABLED_IMAGE : ModelGroupFigure.CHOICE_ICON_IMAGE; - modelGroupFigure.getIconFigure().image = XSDCommonUIUtils.getUpdatedImage((XSDConcreteComponent)adapter.getTarget(), image, isReadOnly); - nodeName = XSDConstants.CHOICE_ELEMENT_TAG; - break; - } - case XSDCompositor.SEQUENCE: - { - image = isReadOnly ? ModelGroupFigure.SEQUENCE_ICON_DISABLED_IMAGE : ModelGroupFigure.SEQUENCE_ICON_IMAGE; - modelGroupFigure.getIconFigure().image = XSDCommonUIUtils.getUpdatedImage((XSDConcreteComponent)adapter.getTarget(), image, isReadOnly); - nodeName = XSDConstants.SEQUENCE_ELEMENT_TAG; - break; - } - } - -// String occurenceDescription = adapter.getNameAnnotationToolTipString(); -// modelGroupFigure.getIconFigure().setToolTip(occurenceDescription); - - // TODO: commmon this up with XSDParticleAdapter's code - - // -2 means the user didn't specify (so the default is 1) - int minOccurs = adapter.getMinOccurs(); - int maxOccurs = adapter.getMaxOccurs(); - String occurenceDescription = ""; //$NON-NLS-1$ - - if (minOccurs == -3 && maxOccurs == -3) - { - occurenceDescription = nodeName; - modelGroupFigure.setText(null); - } - else if (minOccurs == 0 && (maxOccurs == -2 || maxOccurs == 1)) - { - occurenceDescription = nodeName + " [0..1]"; //$NON-NLS-1$ - modelGroupFigure.setText("0..1"); - } - else if ((minOccurs == 1 && maxOccurs == 1) || - (minOccurs == -2 && maxOccurs == 1) || - (minOccurs == 1 && maxOccurs == -2)) - { - occurenceDescription = nodeName + " [1..1]"; //$NON-NLS-1$ - modelGroupFigure.setText("1..1"); - } - else if (minOccurs == -2 && maxOccurs == -2) - { - occurenceDescription = nodeName; - modelGroupFigure.setText(null); - } - else - { - if (maxOccurs == -2) maxOccurs = 1; - String maxSymbol = maxOccurs == -1 ? "*" : "" + maxOccurs; //$NON-NLS-1$ //$NON-NLS-2$ - - String minSymbol = minOccurs == -2 ? "1" : "" + minOccurs; //$NON-NLS-1$ //$NON-NLS-2$ - occurenceDescription = nodeName + " [" + minSymbol + ".." + maxSymbol + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - modelGroupFigure.setText(minSymbol + ".." + maxSymbol); - } - - modelGroupFigure.getIconFigure().setToolTipText(occurenceDescription); - modelGroupFigure.getIconFigure().repaint(); - - refreshConnection(); - } - - protected List getModelChildren() - { -// XSDModelGroupAdapter modelGroupAdapter = (XSDModelGroupAdapter)getModel(); -// ArrayList ch = new ArrayList(); -// ITreeElement [] tree = modelGroupAdapter.getChildren(); -// int length = tree.length; -// for (int i = 0; i < length; i++) -// { -// ch.add(tree[i]); -// } - - List list = new ArrayList(); - XSDModelGroup xsdModelGroup = getXSDModelGroup(); - for (Iterator i = xsdModelGroup.getContents().iterator(); i.hasNext();) - { - XSDParticle next = (XSDParticle) i.next(); - if (next.getContent() instanceof XSDElementDeclaration) - { - XSDElementDeclaration elementDeclaration = (XSDElementDeclaration) next.getContent(); - Adapter adapter = XSDAdapterFactory.getInstance().adapt(elementDeclaration); - list.add(new TargetConnectionSpaceFiller((XSDBaseAdapter)adapter)); - } - if (next.getContent() instanceof XSDModelGroupDefinition) - { - XSDModelGroupDefinition def = (XSDModelGroupDefinition) next.getContent(); - Adapter adapter = XSDAdapterFactory.getInstance().adapt(def); - list.add(adapter); - } - else if (next.getTerm() instanceof XSDModelGroup) - { - XSDModelGroup modelGroup = (XSDModelGroup) next.getTerm(); - Adapter adapter = XSDAdapterFactory.getInstance().adapt(modelGroup); - list.add(adapter); - } - else if (next.getTerm() instanceof XSDWildcard) - { - XSDWildcard wildCard = (XSDWildcard)next.getTerm(); - Adapter adapter = XSDAdapterFactory.getInstance().adapt(wildCard); - list.add(new TargetConnectionSpaceFiller((XSDBaseAdapter)adapter)); - } - } - - if (list.size() == 0) - list.add(new TargetConnectionSpaceFiller(null)); - - return list; -// return ch; - } - - public ReferenceConnection createConnectionFigure(BaseEditPart child) - { - ReferenceConnection connectionFigure = new ReferenceConnection(); - GenericGroupFigure modelGroupFigure = (GenericGroupFigure)getFigure(); - - connectionFigure.setSourceAnchor(new CenteredConnectionAnchor(modelGroupFigure.getIconFigure(), CenteredConnectionAnchor.RIGHT, 0, 0)); - - if (child instanceof ModelGroupEditPart) - { - connectionFigure.setTargetAnchor(new CenteredConnectionAnchor(((ModelGroupEditPart) child).getTargetFigure(), CenteredConnectionAnchor.LEFT, 0, 0)); - } - else if (child instanceof TargetConnectionSpacingFigureEditPart) - { - TargetConnectionSpacingFigureEditPart elem = (TargetConnectionSpacingFigureEditPart) child; - connectionFigure.setTargetAnchor(new CenteredConnectionAnchor(elem.getFigure(), CenteredConnectionAnchor.LEFT, 0, 1)); - } - else if (child instanceof ModelGroupDefinitionReferenceEditPart) - { - ModelGroupDefinitionReferenceEditPart elem = (ModelGroupDefinitionReferenceEditPart) child; - connectionFigure.setTargetAnchor(new CenteredConnectionAnchor(elem.getFigure(), CenteredConnectionAnchor.LEFT, 0, 1)); - } - connectionFigure.setHighlight(false); - return connectionFigure; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/ReferenceConnection.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/ReferenceConnection.java deleted file mode 100644 index fd63dbe166..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/ReferenceConnection.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 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.design.editparts; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.ConnectionRouter; -import org.eclipse.draw2d.PolylineConnection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.widgets.Display; - -public class ReferenceConnection extends PolylineConnection -{ - protected boolean highlight = false; - - protected static final Color activeConnection = ColorConstants.black; - public static final Color inactiveConnection = new Color(null, 198, 195, 198); - - public ReferenceConnection() - { - super(); - setConnectionRouter(new XSDModelGroupRouter()); - } - - public void setConnectionRouter(ConnectionRouter cr) - { - if (cr != null && getConnectionRouter() != null && !(getConnectionRouter() instanceof XSDModelGroupRouter)) - super.setConnectionRouter(cr); - } - - public boolean isHighlighted() - { - return highlight; - } - - public void setHighlight(boolean highlight) - { - this.highlight = highlight; - - boolean highContrast = false; - try - { - highContrast = Display.getDefault().getHighContrast(); - } - catch (Exception e) - { - } - if (highContrast) - { - setForegroundColor(highlight ? Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND) : ColorConstants.lightGray); - } - else - { - setForegroundColor(highlight ? activeConnection : inactiveConnection); - } - setOpaque(highlight); - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/SpaceFillerForFieldEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/SpaceFillerForFieldEditPart.java deleted file mode 100644 index 30f44ee1d0..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/SpaceFillerForFieldEditPart.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 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.design.editparts; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; - -public class SpaceFillerForFieldEditPart extends BaseFieldEditPart -{ - Label space; - public SpaceFillerForFieldEditPart() - { - super(); - } - - protected IFigure createFigure() - { - space = new Label(""); //$NON-NLS-1$ - space.setIcon(XSDEditorPlugin.getXSDImage("icons/Dot.gif")); //$NON-NLS-1$ - space.setBorder(new MarginBorder(3, 0, 3, 0)); - return space; - } - - protected void refreshVisuals() - { - } - - protected void createEditPolicies() - { - - } - - public boolean isSelectable() - { - return false; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/TargetConnectionSpacingFigureEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/TargetConnectionSpacingFigureEditPart.java deleted file mode 100644 index dad1a8b8e8..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/TargetConnectionSpacingFigureEditPart.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 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.design.editparts; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseEditPart; -import org.eclipse.wst.xsd.ui.internal.design.figures.SpacingFigure; - -public class TargetConnectionSpacingFigureEditPart extends BaseEditPart -{ - public TargetConnectionSpacingFigureEditPart() - { - super(); - } - - SpacingFigure figure; - - protected IFigure createFigure() - { - figure = new SpacingFigure(); - return figure; - } - - public IFigure getConnectionFigure() - { - return figure; - } - - protected void createEditPolicies() - { - - } - - public boolean isSelectable() - { - return false; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/TopLevelComponentEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/TopLevelComponentEditPart.java deleted file mode 100644 index 9e4f906013..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/TopLevelComponentEditPart.java +++ /dev/null @@ -1,428 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 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.design.editparts; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.draw2d.ToolbarLayout; -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.commands.Command; -import org.eclipse.gef.editpolicies.SelectionEditPolicy; -import org.eclipse.gef.requests.DirectEditRequest; -import org.eclipse.gef.requests.LocationRequest; -import org.eclipse.gef.ui.actions.ActionRegistry; -import org.eclipse.gef.ui.parts.AbstractEditPartViewer; -import org.eclipse.jface.action.IAction; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.common.uriresolver.internal.util.URIHelper; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDSchemaDirectiveAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.INamedEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IFeedbackHandler; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.ADTDirectEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.IADTUpdateCommand; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.SimpleDirectEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.typeviz.design.figures.FieldFigure; -import org.eclipse.wst.xsd.ui.internal.common.actions.OpenInNewEditor; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand; -import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils; -import org.eclipse.wst.xsd.ui.internal.design.editpolicies.SelectionHandlesEditPolicyImpl; -import org.eclipse.wst.xsd.ui.internal.design.editpolicies.TopLevelComponentLabelCellEditorLocator; -import org.eclipse.wst.xsd.ui.internal.design.editpolicies.TopLevelNameDirectEditManager; -import org.eclipse.wst.xsd.ui.internal.design.figures.HyperLinkLabel; -import org.eclipse.wst.xsd.ui.internal.design.layouts.FillLayout; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.utils.OpenOnSelectionHelper; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDNamedComponent; -import org.eclipse.xsd.XSDSchemaDirective; -import org.eclipse.xsd.impl.XSDImportImpl; - -public class TopLevelComponentEditPart extends BaseEditPart implements IFeedbackHandler, INamedEditPart -{ - protected Label label; - // protected Label arrowLabel; - protected Figure labelHolder = new Figure(); - protected SelectionHandlesEditPolicyImpl selectionHandlesEditPolicy; - protected ADTDirectEditPolicy adtDirectEditPolicy = new ADTDirectEditPolicy(); - protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy(); - protected boolean isReadOnly; - protected boolean isSelected; - - protected IFigure createFigure() - { - Figure typeGroup = new Figure() - { - public void paint(Graphics graphics) - { - super.paint(graphics); - if (hasFocus) - { - try - { - graphics.pushState(); - Rectangle r = getBounds(); - graphics.setXORMode(true); - graphics.drawFocus(r.x, r.y + 1, r.width - 1, r.height - 2); - } - finally - { - graphics.popState(); - } - } - - } - }; - typeGroup.setLayoutManager(new ToolbarLayout()); - - labelHolder = new Figure(); - FillLayout fillLayout = new FillLayout(); - labelHolder.setLayoutManager(fillLayout); - typeGroup.add(labelHolder); - - label = new HyperLinkLabel(); - label.setOpaque(true); - label.setBorder(new MarginBorder(1, 2, 2, 5)); - if (!isHighContrast) - label.setForegroundColor(ColorConstants.black); - labelHolder.add(label); - - return typeGroup; - } - - public void deactivate() - { - super.deactivate(); - } - - public void refreshVisuals() - { - XSDBaseAdapter adapter = (XSDBaseAdapter) getModel(); - if (adapter != null) - { - isReadOnly = adapter.isReadOnly(); - label.setForegroundColor(computeLabelColor()); - label.setText(adapter.getText()); - Image image = adapter.getImage(); - if (image != null) - { - label.setIcon(XSDCommonUIUtils.getUpdatedImage((XSDConcreteComponent) adapter.getTarget(), image, isReadOnly)); - } - // arrowLabel.setVisible(Boolean.TRUE.equals(adapter.getProperty(getModel(), - // "drillDown"))); - } - else - { - label.setText(Messages._UI_GRAPH_UNKNOWN_OBJECT + getModel().getClass().getName()); - // arrowLabel.setVisible(false); - } - - if (reselect) - { - getViewer().select(this); - setReselect(false); - } - } - - public List getModelChildren() - { - return Collections.EMPTY_LIST; - } - - public EditPart doGetRelativeEditPart(EditPart editPart, int direction) - { - return ((BaseEditPart)this.getParent()).doGetRelativeEditPart(editPart, direction); - } - - protected void createEditPolicies() - { - super.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, adtDirectEditPolicy); - } - - public Color computeLabelColor() - { - Color color = ColorConstants.black; - if (isHighContrast) - { - color = Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND); - } - - if (isSelected) - { - if (isHighContrast) - { - color = ColorConstants.listBackground; - } - else - { - color = ColorConstants.black; - } - } - else if (isReadOnly) - { - color = ColorConstants.gray; - } - return color; - } - - public void addFeedback() - { - isSelected = true; - - if (isHighContrast) - { - labelHolder.setBackgroundColor(ColorConstants.listForeground); - } - else - { - labelHolder.setBackgroundColor(FieldFigure.cellColor); - } - 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) - { - // Do not open on or set focus on direct edit type - if (request.getType() == RequestConstants.REQ_OPEN) - { - - Object model = getModel(); - if (model instanceof IGraphElement) - { - if (((IGraphElement)model).isFocusAllowed()) - { - if (request instanceof LocationRequest) - { - LocationRequest locationRequest = (LocationRequest) request; - Point p = locationRequest.getLocation(); - - if (hitTest(labelHolder, p)) - { - performDrillDownAction(); - } - } - } - } - else if (model instanceof XSDSchemaDirectiveAdapter) - { - if (request instanceof LocationRequest) - { - LocationRequest locationRequest = (LocationRequest) request; - Point p = locationRequest.getLocation(); - - if (hitTest(labelHolder, p)) - { - XSDSchemaDirective dir = (XSDSchemaDirective)((XSDSchemaDirectiveAdapter)model).getTarget(); - String schemaLocation = ""; - // force load of imported schema - if (dir instanceof XSDImportImpl) - { - ((XSDImportImpl)dir).importSchema(); - } - if (dir.getResolvedSchema() != null) - { - schemaLocation = URIHelper.removePlatformResourceProtocol(dir.getResolvedSchema().getSchemaLocation()); - if (schemaLocation != null) - { - OpenOnSelectionHelper.openXSDEditor(dir.getResolvedSchema()); - } - } - } - } - } - } - } - - 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() - { - EditPart editPart = ((AbstractEditPartViewer) getViewer()).getRootEditPart().getContents(); - if (editPart instanceof RootContentEditPart) - { - IEditorPart editorPart = getEditorPart(); -// ActionRegistry registry = (ActionRegistry) editorPart.getAdapter(ActionRegistry.class); -// IAction action = registry.getAction(SetInputToGraphView.ID); -// action.run(); - ActionRegistry registry = (ActionRegistry) editorPart.getAdapter(ActionRegistry.class); - if (registry != null) - { - IAction action = registry.getAction(OpenInNewEditor.ID); - if (action != null) - action.run(); - return; - } - } - } - }; - Display.getCurrent().asyncExec(runnable); - } - - public void doEditName(boolean addFromDesign) - { - if (!addFromDesign) return; - -// removeFeedback(); - - Object object = ((XSDBaseAdapter) getModel()).getTarget(); - if (object instanceof XSDNamedComponent) - { - Point p = label.getLocation(); - TopLevelNameDirectEditManager manager = new TopLevelNameDirectEditManager(TopLevelComponentEditPart.this, new TopLevelComponentLabelCellEditorLocator(TopLevelComponentEditPart.this, p), (XSDNamedComponent) object); - NameUpdateCommandWrapper wrapper = new NameUpdateCommandWrapper(); - adtDirectEditPolicy.setUpdateCommand(wrapper); - manager.show(); - } - } - - class NameUpdateCommandWrapper extends Command implements IADTUpdateCommand - { - Command command; - protected DirectEditRequest request; - - public NameUpdateCommandWrapper() - { - super(Messages._UI_ACTION_UPDATE_NAME); - } - - public void setRequest(DirectEditRequest request) - { - this.request = request; - } - - public void execute() - { - XSDBaseAdapter adapter = (XSDBaseAdapter)getModel(); - Object newValue = request.getCellEditor().getValue(); - if (newValue instanceof String && ((String)newValue).length() > 0) - { - UpdateNameCommand command = new UpdateNameCommand(Messages._UI_ACTION_UPDATE_NAME, (XSDNamedComponent)adapter.getTarget(), (String)newValue); - if (command != null) - command.execute(); - } - } - } - - static boolean reselect = false; - - public void setReselect(boolean state) - { - reselect = state; - } - - public Label getNameLabelFigure() - { - return label; - } - - public void performDirectEdit(Point cursorLocation) - { - - } - - public void setSelected(int value) - { - // if it is selected, we want to scroll to it - if (doScroll) - setScroll(true); - super.setSelected(value); - } - - public void setFocus(boolean b) - { - super.setFocus(b); - hasFocus = b; - getFigure().repaint(); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDAttributesForAnnotationEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDAttributesForAnnotationEditPart.java deleted file mode 100644 index 13b4dd5ce4..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDAttributesForAnnotationEditPart.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 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.design.editparts; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.wst.xsd.ui.internal.adapters.XSDComplexTypeDefinitionAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.SectionEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.Annotation; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure; - -public class XSDAttributesForAnnotationEditPart extends SectionEditPart -{ - public XSDAttributesForAnnotationEditPart() - { - super(); - } - - protected List getModelChildren() - { - IStructure structure = ((Annotation)getModel()).getOwner(); - if (structure instanceof IComplexType) - { - complexType = (IComplexType)structure; - if (complexType instanceof XSDComplexTypeDefinitionAdapter) - { - XSDComplexTypeDefinitionAdapter adapter = (XSDComplexTypeDefinitionAdapter) complexType; - return adapter.getAttributeGroupContent(); - } - } - return Collections.EMPTY_LIST; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDBaseFieldEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDBaseFieldEditPart.java deleted file mode 100644 index 6edac9c1c6..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDBaseFieldEditPart.java +++ /dev/null @@ -1,164 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 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.design.editparts; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeDeclarationAdapter; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDElementDeclarationAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.design.IAnnotationProvider; -import org.eclipse.wst.xsd.ui.internal.adt.design.directedit.AttributeReferenceDirectEditManager; -import org.eclipse.wst.xsd.ui.internal.adt.design.directedit.ElementReferenceDirectEditManager; -import org.eclipse.wst.xsd.ui.internal.adt.design.directedit.LabelCellEditorLocator; -import org.eclipse.wst.xsd.ui.internal.adt.design.directedit.LabelEditManager; -import org.eclipse.wst.xsd.ui.internal.adt.design.directedit.ReferenceDirectEditManager; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; -import org.eclipse.wst.xsd.ui.internal.adt.typeviz.design.figures.FieldFigure; -import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils; -import org.eclipse.wst.xsd.ui.internal.design.editpolicies.DragAndDropEditPolicy; -import org.eclipse.wst.xsd.ui.internal.design.editpolicies.SelectionHandlesEditPolicyImpl; -import org.eclipse.xsd.XSDConcreteComponent; - -public class XSDBaseFieldEditPart extends BaseFieldEditPart -{ - - public XSDBaseFieldEditPart() - { - super(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals() - */ - protected void refreshVisuals() - { - IFieldFigure figure = getFieldFigure(); - IField field = (IField) getModel(); - - figure.getNameLabel().setText(field.getName()); - figure.getTypeLabel().setText(field.getTypeName()); - figure.refreshVisuals(getModel()); - if (field.isReadOnly()) - { - figure.setForegroundColor(ColorConstants.darkGray); - } - else - { - if (isHighContrast) - { - figure.setForegroundColor(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND)); - figure.setBackgroundColor(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); - } - else - figure.setForegroundColor(ColorConstants.black); - } - - String occurrenceDescription = ""; //$NON-NLS-1$ - if (field instanceof IAnnotationProvider) - { - occurrenceDescription = ((IAnnotationProvider)field).getNameAnnotationString(); - } - refreshIcon(); - figure.getNameAnnotationLabel().setText(occurrenceDescription); - - figure.recomputeLayout(); - - - if (getRoot() != null) - ((GraphicalEditPart)getRoot()).getFigure().invalidateTree(); - } - - protected void refreshIcon() - { - IFieldFigure figure = getFieldFigure(); - // our model implements ITreeElement - if (getModel() instanceof XSDBaseAdapter) - { - Image image = ((XSDBaseAdapter)getModel()).getImage(); - boolean isReadOnly = ((XSDBaseAdapter)getModel()).isReadOnly(); - figure.getNameLabel().setIcon(image); - - if (image != null) - { - XSDConcreteComponent comp = (XSDConcreteComponent) ((XSDBaseAdapter)getModel()).getTarget(); - figure.getNameLabel().setIcon(XSDCommonUIUtils.getUpdatedImage(comp, image, isReadOnly)); - } - } - } - - public void addNotify() - { - super.addNotify(); - getFieldFigure().editPartAttached(this); - } - - protected SelectionHandlesEditPolicyImpl selectionHandlesEditPolicy = new SelectionHandlesEditPolicyImpl(); - protected void createEditPolicies() - { - super.createEditPolicies(); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, selectionHandlesEditPolicy); - if (!isFileReadOnly()) - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DragAndDropEditPolicy(getViewer(), selectionHandlesEditPolicy)); - } - - protected void directEditNameField() - { - Object model = getModel(); - IFieldFigure fieldFigure = getFieldFigure(); - if ( model instanceof IField) - { - IField field = (IField) model; - if (field.isReference()) - { - ReferenceDirectEditManager manager = null; - if (field instanceof XSDElementDeclarationAdapter) - { - manager = new ElementReferenceDirectEditManager((IField) model, this, fieldFigure.getNameLabel()); - } - else if (field instanceof XSDAttributeDeclarationAdapter) - { - manager = new AttributeReferenceDirectEditManager((IField) model, this, fieldFigure.getNameLabel()); - } - if (manager != null) - { - ReferenceUpdateCommand elementUpdateCommand = new ReferenceUpdateCommand(); - elementUpdateCommand.setDelegate(manager); - adtDirectEditPolicy.setUpdateCommand(elementUpdateCommand); - manager.show(); - } - } - else - { - LabelEditManager manager = new LabelEditManager(this, new LabelCellEditorLocator(this, null)); - NameUpdateCommandWrapper wrapper = new NameUpdateCommandWrapper(); - adtDirectEditPolicy.setUpdateCommand(wrapper); - manager.show(); - } - } - } - - public void setFocus(boolean focus) - { - super.setFocus(focus); - hasFocus = focus; - ((FieldFigure)getFigure()).hasFocus = hasFocus; - getFigure().repaint(); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDEditPartFactory.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDEditPartFactory.java deleted file mode 100644 index 211b7873c8..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDEditPartFactory.java +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 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.design.editparts; - -import org.eclipse.gef.EditPart; -import org.eclipse.wst.xsd.ui.internal.adapters.CategoryAdapter; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeGroupDefinitionAdapter; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDModelGroupAdapter; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDModelGroupDefinitionAdapter; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDSchemaAdapter; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDSimpleTypeDefinitionAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.ADTEditPartFactory; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.ColumnEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.CompartmentEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.Annotation; -import org.eclipse.wst.xsd.ui.internal.adt.design.figures.ICompartmentFigure; -import org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure; -import org.eclipse.wst.xsd.ui.internal.adt.design.figures.IStructureFigure; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; -import org.eclipse.wst.xsd.ui.internal.adt.typeviz.design.figures.TypeVizFigureFactory; -import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils; -import org.eclipse.wst.xsd.ui.internal.design.editparts.model.SpaceFiller; -import org.eclipse.wst.xsd.ui.internal.design.editparts.model.TargetConnectionSpaceFiller; -import org.eclipse.wst.xsd.ui.internal.design.figures.IExtendedFigureFactory; -import org.eclipse.wst.xsd.ui.internal.design.figures.IModelGroupFigure; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDConcreteComponent; - -public class XSDEditPartFactory extends ADTEditPartFactory implements IExtendedFigureFactory -{ - protected IExtendedFigureFactory delegate; - - public XSDEditPartFactory() - { - delegate = XSDEditorPlugin.getPlugin().getXSDEditorConfiguration().getFigureFactory(); - if (delegate == null) - delegate = new TypeVizFigureFactory(); - } - - public XSDEditPartFactory(IExtendedFigureFactory figureFactory) - { - delegate = figureFactory; - } - - - public EditPart doCreateEditPart(EditPart context, Object model) - { - EditPart child = null; - // Override edit part where desired - - if (model instanceof IField) - { - if (model instanceof SpaceFiller) - { - child = new SpaceFillerForFieldEditPart(); - } - else if (context instanceof CompartmentEditPart) - { - child = new XSDBaseFieldEditPart(); - } - } - else if (model instanceof XSDSchemaAdapter) - { - child = new XSDSchemaEditPart(); - } - else if (model instanceof CategoryAdapter) - { - child = new CategoryEditPart(); - } - else if (model instanceof XSDSimpleTypeDefinitionAdapter) - { - child = new XSDSimpleTypeEditPart(); - } - else if (model instanceof XSDModelGroupAdapter) - { - child = new ModelGroupEditPart(); - } - else if (model instanceof Annotation) - { - Annotation annotation = (Annotation) model; - String kind = annotation.getCompartment().getKind(); - if (kind.equals("element")) //$NON-NLS-1$ - { - child = new XSDGroupsForAnnotationEditPart(); - } - else if (kind.equals("attribute")) //$NON-NLS-1$ - { - child = new XSDAttributesForAnnotationEditPart(); - } - } - else if (!(context instanceof ColumnEditPart)) - { - if (model instanceof TargetConnectionSpaceFiller) - { - child = new TargetConnectionSpacingFigureEditPart(); - } - else if (model instanceof XSDModelGroupDefinitionAdapter) - { - child = new ModelGroupDefinitionReferenceEditPart(); - } - else if (model instanceof XSDAttributeGroupDefinitionAdapter) - { - child = new AttributeGroupDefinitionEditPart(); - } - } - // if we don't have a specialzied XSD edit part to create - // then we simply call the super class to create a generic ADT edit part - // - if (child == null) - { - child = super.doCreateEditPart(context, model); - } - - // if at this this point we have not created an edit part we simply - // create a placeholder edit part to provide the most robust behaviour possible - // - if (child == null) - { - // TODO (cs) log an error message here, since we shouldn't really get here - child = new SpaceFillerForFieldEditPart(); - } - return child; - } - - public ICompartmentFigure createCompartmentFigure(Object model) - { - return delegate.createCompartmentFigure(model); - } - - public IStructureFigure createStructureFigure(Object model) - { - IStructureFigure figure = delegate.createStructureFigure(model); - if (model instanceof XSDBaseAdapter) - { - XSDConcreteComponent comp = (XSDConcreteComponent) ((XSDBaseAdapter)model).getTarget(); - boolean isReadOnly = ((XSDBaseAdapter)model).isReadOnly(); - figure.getNameLabel().setIcon(XSDCommonUIUtils.getUpdatedImage( comp, ((XSDBaseAdapter)model).getImage(), isReadOnly)); - } - return figure; - } - - public IFieldFigure createFieldFigure(Object model) - { - return delegate.createFieldFigure(model); - } - - public IModelGroupFigure createModelGroupFigure(Object model) - { - return delegate.createModelGroupFigure(model); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDGroupsForAnnotationEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDGroupsForAnnotationEditPart.java deleted file mode 100644 index c065b36e47..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDGroupsForAnnotationEditPart.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 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.design.editparts; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.wst.xsd.ui.internal.adapters.XSDAdapterFactory; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDComplexTypeDefinitionAdapter; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDModelGroupDefinitionAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.SectionEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.Annotation; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDModelGroupDefinition; - -public class XSDGroupsForAnnotationEditPart extends SectionEditPart -{ - public XSDGroupsForAnnotationEditPart() - { - super(); - } - - protected List getModelChildren() - { - List xsdModelGroupList = new ArrayList(); - List adapterList = new ArrayList(); - - IStructure structure = ((Annotation)getModel()).getOwner(); - if (structure instanceof IComplexType) - { - complexType = (IComplexType)structure; - if (complexType instanceof XSDComplexTypeDefinitionAdapter) - { - XSDComplexTypeDefinitionAdapter adapter = (XSDComplexTypeDefinitionAdapter) complexType; - xsdModelGroupList = adapter.getModelGroups(); - } - - for (Iterator i = xsdModelGroupList.iterator(); i.hasNext(); ) - { - Object obj = i.next(); - if (obj instanceof XSDModelGroup) - { - adapterList.add(XSDAdapterFactory.getInstance().adapt((XSDModelGroup)obj)); - } - else if (obj instanceof XSDModelGroupDefinition) - { - adapterList.add(XSDAdapterFactory.getInstance().adapt((XSDModelGroupDefinition)obj)); - } - } - } - else if (structure instanceof XSDModelGroupDefinitionAdapter) - { - XSDModelGroupDefinitionAdapter adapter = (XSDModelGroupDefinitionAdapter) structure; - XSDModelGroup group = adapter.getXSDModelGroupDefinition().getModelGroup(); - if (group != null) - { - adapterList.add(XSDAdapterFactory.getInstance().adapt(group)); - } - } - - return adapterList; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDModelGroupRouter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDModelGroupRouter.java deleted file mode 100644 index a1957822c7..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDModelGroupRouter.java +++ /dev/null @@ -1,378 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 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.design.editparts; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.draw2d.AbstractRouter; -import org.eclipse.draw2d.Connection; -import org.eclipse.draw2d.ConnectionAnchor; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.PointList; -import org.eclipse.draw2d.geometry.Ray; -import org.eclipse.draw2d.geometry.Rectangle; - -// TODO Manhattan connection router is final -public class XSDModelGroupRouter extends AbstractRouter -{ - public XSDModelGroupRouter() - { - super(); - } - private Map rowsUsed = new HashMap(); - private Map colsUsed = new HashMap(); - - private Map reservedInfo = new HashMap(); - - private class ReservedInfo { - public List reservedRows = new ArrayList(2); - public List reservedCols = new ArrayList(2); - } - - private static Ray UP = new Ray(0, -1), - DOWN = new Ray(0, 1), - LEFT = new Ray(-1, 0), - RIGHT = new Ray(1, 0); - - - /** - * @see org.eclipse.draw2d.ConnectionRouter#invalidate(Connection) - */ - public void invalidate(Connection connection) { - removeReservedLines(connection); - } - - private int getColumnNear(Connection connection, int r, int n, int x) { - int min = Math.min(n, x), - max = Math.max(n, x); - if (min > r) { - max = min; - min = r - (min - r); - } - if (max < r) { - min = max; - max = r + (r - max); - } - int proximity = 0; - int direction = -1; - if (r % 2 == 1) - r--; - Integer i; - while (proximity < r) { - i = new Integer(r + proximity * direction); - if (!colsUsed.containsKey(i)) { - colsUsed.put(i, i); - reserveColumn(connection, i); - return i.intValue(); - } - int j = i.intValue(); - if (j <= min) - return j + 2; - if (j >= max) - return j - 2; - if (direction == 1) - direction = -1; - else { - direction = 1; - proximity += 2; - } - } - return r; - } - - /** - * Returns the direction the point <i>p</i> is in relation to the given rectangle. - * Possible values are LEFT (-1,0), RIGHT (1,0), UP (0,-1) and DOWN (0,1). - * - * @param r the rectangle - * @param p the point - * @return the direction from <i>r</i> to <i>p</i> - */ - protected Ray getDirection(Rectangle r, Point p) { - int i, distance = Math.abs(r.x - p.x); - Ray direction; - - direction = LEFT; - - i = Math.abs(r.y - p.y); - if (i <= distance) { - distance = i; - direction = UP; - } - - i = Math.abs(r.bottom() - p.y); - if (i <= distance) { - distance = i; - direction = DOWN; - } - - i = Math.abs(r.right() - p.x); - if (i < distance) { - distance = i; - direction = RIGHT; - } - - return direction; - } - - protected Ray getEndDirection(Connection conn) { - ConnectionAnchor anchor = conn.getTargetAnchor(); - Point p = getEndPoint(conn); - Rectangle rect; - if (anchor.getOwner() == null) - rect = new Rectangle(p.x - 1, p.y - 1, 2, 2); - else { - rect = conn.getTargetAnchor().getOwner().getBounds().getCopy(); - conn.getTargetAnchor().getOwner().translateToAbsolute(rect); - } - return getDirection(rect, p); - } - - protected int getRowNear(Connection connection, int r, int n, int x) { - int min = Math.min(n, x), - max = Math.max(n, x); - if (min > r) { - max = min; - min = r - (min - r); - } - if (max < r) { - min = max; - max = r + (r - max); - } - - int proximity = 0; - int direction = -1; - if (r % 2 == 1) - r--; - Integer i; - while (proximity < r) { - i = new Integer(r + proximity * direction); - if (!rowsUsed.containsKey(i)) { - rowsUsed.put(i, i); - reserveRow(connection, i); - return i.intValue(); - } - int j = i.intValue(); - if (j <= min) - return j + 2; - if (j >= max) - return j - 2; - if (direction == 1) - direction = -1; - else { - direction = 1; - proximity += 2; - } - } - return r; - } - - protected Ray getStartDirection(Connection conn) { - ConnectionAnchor anchor = conn.getSourceAnchor(); - Point p = getStartPoint(conn); - Rectangle rect; - if (anchor.getOwner() == null) - rect = new Rectangle(p.x - 1, p.y - 1, 2, 2); - else { - rect = conn.getSourceAnchor().getOwner().getBounds().getCopy(); - conn.getSourceAnchor().getOwner().translateToAbsolute(rect); - } - return getDirection(rect, p); - } - - protected void processPositions(Ray start, Ray end, List positions, - boolean horizontal, Connection conn) { - removeReservedLines(conn); - - int pos[] = new int[positions.size() + 2]; - if (horizontal) - pos[0] = start.x; - else - pos[0] = start.y; - int i; - for (i = 0; i < positions.size(); i++) { - pos[i + 1] = ((Integer)positions.get(i)).intValue(); - } - if (horizontal == (positions.size() % 2 == 1)) - pos[++i] = end.x; - else - pos[++i] = end.y; - - PointList points = new PointList(); - points.addPoint(new Point(start.x, start.y)); - Point p; - int current, prev, min, max; - boolean adjust; - for (i = 2; i < pos.length - 1; i++) { - horizontal = !horizontal; - prev = pos[i - 1]; - current = pos[i]; - - adjust = (i != pos.length - 2); - if (horizontal) { - if (adjust) { - min = pos[i - 2]; - max = pos[i + 2]; - pos[i] = current = getRowNear(conn, current, min, max); - } - p = new Point(prev, current); - } else { - if (adjust) { - min = pos[i - 2]; - max = pos[i + 2]; - pos[i] = current = getColumnNear(conn, current, min, max); - } - p = new Point(current, prev); - } - points.addPoint(p); - } - points.addPoint(new Point(end.x, end.y)); - conn.setPoints(points); - } - - /** - * @see org.eclipse.draw2d.ConnectionRouter#remove(Connection) - */ - public void remove(Connection connection) { - removeReservedLines(connection); - } - - protected void removeReservedLines(Connection connection) { - ReservedInfo rInfo = (ReservedInfo) reservedInfo.get(connection); - if (rInfo == null) - return; - - for (int i = 0; i < rInfo.reservedRows.size(); i++) { - rowsUsed.remove(rInfo.reservedRows.get(i)); - } - for (int i = 0; i < rInfo.reservedCols.size(); i++) { - colsUsed.remove(rInfo.reservedCols.get(i)); - } - reservedInfo.remove(connection); - } - - protected void reserveColumn(Connection connection, Integer column) { - ReservedInfo info = (ReservedInfo) reservedInfo.get(connection); - if (info == null) { - info = new ReservedInfo(); - reservedInfo.put(connection, info); - } - info.reservedCols.add(column); - } - - protected void reserveRow(Connection connection, Integer row) { - ReservedInfo info = (ReservedInfo) reservedInfo.get(connection); - if (info == null) { - info = new ReservedInfo(); - reservedInfo.put(connection, info); - } - info.reservedRows.add(row); - } - - /** - * @see org.eclipse.draw2d.ConnectionRouter#route(Connection) - */ - public void route(Connection conn) { - if ((conn.getSourceAnchor() == null) || (conn.getTargetAnchor() == null)) - return; - int i; - Point startPoint = getStartPoint(conn); - conn.translateToRelative(startPoint); - Point endPoint = getEndPoint(conn); - conn.translateToRelative(endPoint); - - Ray start = new Ray(startPoint); - Ray end = new Ray(endPoint); - Ray average = new Ray(startPoint.x + 4, startPoint.y); // start.getAveraged(end); - - Ray direction = new Ray(start, end); - Ray startNormal = getStartDirection(conn); - Ray endNormal = getEndDirection(conn); - - List positions = new ArrayList(5); - boolean horizontal = startNormal.isHorizontal(); - if (horizontal) - positions.add(new Integer(start.y)); - else - positions.add(new Integer(start.x)); - horizontal = !horizontal; - - if (startNormal.dotProduct(endNormal) == 0) { - if ((startNormal.dotProduct(direction) >= 0) - && (endNormal.dotProduct(direction) <= 0)) { - // 0 - } else { - // 2 - if (startNormal.dotProduct(direction) < 0) - i = startNormal.similarity(start.getAdded(startNormal.getScaled(10))); - else { - if (horizontal) - i = average.y; - else - i = average.x; - } - positions.add(new Integer(i)); - horizontal = !horizontal; - - if (endNormal.dotProduct(direction) > 0) - i = endNormal.similarity(end.getAdded(endNormal.getScaled(10))); - else { - if (horizontal) - i = average.y; - else - i = average.x; - } - positions.add(new Integer(i)); - horizontal = !horizontal; - } - } else { - if (startNormal.dotProduct(endNormal) > 0) { - //1 - if (startNormal.dotProduct(direction) >= 0) - i = startNormal.similarity(start.getAdded(startNormal.getScaled(10))); - else - i = endNormal.similarity(end.getAdded(endNormal.getScaled(10))); - positions.add(new Integer(i)); - horizontal = !horizontal; - } else { - //3 or 1 - if (startNormal.dotProduct(direction) < 0) { - i = startNormal.similarity(start.getAdded(startNormal.getScaled(10))); - positions.add(new Integer(i)); - horizontal = !horizontal; - } - - if (horizontal) - i = average.y; - else - i = average.x; - positions.add(new Integer(i)); - horizontal = !horizontal; - - if (startNormal.dotProduct(direction) < 0) { - i = endNormal.similarity(end.getAdded(endNormal.getScaled(10))); - positions.add(new Integer(i)); - horizontal = !horizontal; - } - } - } - if (horizontal) - positions.add(new Integer(end.y)); - else - positions.add(new Integer(end.x)); - - processPositions(start, end, positions, startNormal.isHorizontal(), conn); - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDSchemaEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDSchemaEditPart.java deleted file mode 100644 index bc0ad7a6c1..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDSchemaEditPart.java +++ /dev/null @@ -1,328 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 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.design.editparts; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.LineBorder; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.RectangleFigure; -import org.eclipse.draw2d.ToolbarLayout; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.osgi.util.TextProcessor; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.xsd.ui.internal.adapters.CategoryAdapter; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDSchemaAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.KeyBoardAccessibilityEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.typeviz.design.figures.HeadingFigure; -import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils; -import org.eclipse.wst.xsd.ui.internal.design.editpolicies.SelectionHandlesEditPolicyImpl; -import org.eclipse.wst.xsd.ui.internal.design.layouts.FillLayout; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDSchema; - -public class XSDSchemaEditPart extends BaseEditPart -{ - protected Label label; - - protected Figure outer, contentFigure; - protected HeadingFigure headingFigure; - - public IFigure getContentPane() - { - return contentFigure; - } - - protected IFigure createFigure() - { - outer = new Figure(); - outer.setBorder(new LineBorder(1)); - - FillLayout fillLayout = new FillLayout(4); - outer.setLayoutManager(fillLayout); - - headingFigure = new HeadingFigure(); - outer.add(headingFigure); - - RectangleFigure line = new RectangleFigure() - { - public Dimension getPreferredSize(int wHint, int hHint) - { - Dimension d = super.getPreferredSize(wHint, hHint); - d.height = 1; - return d; - } - }; - ToolbarLayout lineLayout = new ToolbarLayout(false); - lineLayout.setVertical(true); - lineLayout.setStretchMinorAxis(true); - line.setLayoutManager(lineLayout); - outer.add(line); - - contentFigure = new Figure(); - contentFigure.setBorder(new MarginBorder(4)); - fillLayout = new FillLayout(4); - contentFigure.setLayoutManager(fillLayout); - - outer.add(contentFigure); - return outer; - } - - protected List getModelChildren() - { - XSDSchemaAdapter schemaAdapter = (XSDSchemaAdapter) getModel(); - List list = new ArrayList(); - -// Bug 103870: undo blanks out schema view -// schemaAdapter.updateCategories(); - - List templist = new ArrayList(); - templist.add(schemaAdapter.getCategory(CategoryAdapter.DIRECTIVES)); - Holder holder = new Holder(templist); - list.add(holder); - - templist = new ArrayList(); - templist.add(schemaAdapter.getCategory(CategoryAdapter.ELEMENTS)); - templist.add(schemaAdapter.getCategory(CategoryAdapter.TYPES)); - holder = new Holder(templist); - list.add(holder); - - templist = new ArrayList(); - templist.add(schemaAdapter.getCategory(CategoryAdapter.ATTRIBUTES)); - templist.add(schemaAdapter.getCategory(CategoryAdapter.GROUPS)); - holder = new Holder(templist); - list.add(holder); - - return list; - } - - protected EditPart createChild(Object model) - { - CategoryRowEditPart result = new CategoryRowEditPart(); - result.setModel(model); - result.setParent(this); - return result; - } - - protected void refreshVisuals() - { - super.refreshVisuals(); - - LineBorder border = (LineBorder) outer.getBorder(); - border.setWidth(isSelected ? 2 : 1); - headingFigure.setSelected(isSelected); - - XSDSchemaAdapter schemaAdapter = (XSDSchemaAdapter) getModel(); - Image image = schemaAdapter.getImage(); - headingFigure.getLabel().setIcon(image); - if (image != null) - { - headingFigure.getLabel().setIcon(XSDCommonUIUtils.getUpdatedImage((XSDConcreteComponent) schemaAdapter.getTarget(), image, false)); - } - outer.repaint(); - - String targetNamespaceValue = ((XSDSchema) ((XSDSchemaAdapter) getModel()).getTarget()).getTargetNamespace(); - targetNamespaceValue = TextProcessor.process(targetNamespaceValue); - - if (targetNamespaceValue == null || targetNamespaceValue.length() == 0) - { - targetNamespaceValue = Messages._UI_GRAPH_XSDSCHEMA_NO_NAMESPACE; - } - headingFigure.getLabel().setText(Messages._UI_GRAPH_XSDSCHEMA + " : " + targetNamespaceValue); //$NON-NLS-1$ - } - - public EditPart doGetRelativeEditPart(EditPart editPart, int direction) - { - EditPart result = null; - if (editPart instanceof CategoryEditPart) - { - CategoryAdapter adapter = (CategoryAdapter)editPart.getModel(); - switch (adapter.getGroupType()) - { - case CategoryAdapter.DIRECTIVES: - { - if (direction == PositionConstants.SOUTH) - { - result = getCategoryEditPart(CategoryAdapter.ELEMENTS); - } - break; - } - case CategoryAdapter.ELEMENTS: - { - if (direction == PositionConstants.SOUTH) - { - result = getCategoryEditPart(CategoryAdapter.ATTRIBUTES); - } - else if (direction == PositionConstants.NORTH) - { - result = getCategoryEditPart(CategoryAdapter.DIRECTIVES); - } - break; - } - case CategoryAdapter.TYPES: - { - if (direction == PositionConstants.SOUTH) - { - result = getCategoryEditPart(CategoryAdapter.GROUPS); - } - else if (direction == PositionConstants.NORTH) - { - result = getCategoryEditPart(CategoryAdapter.DIRECTIVES); - } - break; - } - case CategoryAdapter.ATTRIBUTES: - { - if (direction == PositionConstants.NORTH) - { - result = getCategoryEditPart(CategoryAdapter.ELEMENTS); - } - break; - } - case CategoryAdapter.GROUPS: - { - if (direction == PositionConstants.NORTH) - { - result = getCategoryEditPart(CategoryAdapter.TYPES); - } - break; - } - } - } - else if (editPart == this) - { - if (direction == KeyBoardAccessibilityEditPolicy.IN_TO_FIRST_CHILD) - { - result = ((CategoryRowEditPart)getChildren().get(0)).doGetRelativeEditPart(editPart, direction); - } - } - return result; - } - - protected EditPart getCategoryEditPart(int kind) - { - for (Iterator j = getChildren().iterator(); j.hasNext(); ) - { - EditPart row = (EditPart)j.next(); - for (Iterator i = row.getChildren().iterator(); i.hasNext(); ) - { - EditPart editPart = (EditPart)i.next(); - if (editPart instanceof CategoryEditPart) - { - CategoryEditPart categoryEditPart = (CategoryEditPart)editPart; - CategoryAdapter adapter = (CategoryAdapter)categoryEditPart.getModel(); - if (adapter.getGroupType() == kind) - { - return editPart; - } - } - } - } - return null; - } - - protected void createEditPolicies() - { - super.createEditPolicies(); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new SelectionHandlesEditPolicyImpl()); - } - - protected class Holder - { - List list; - - public Holder(List list) - { - this.list = list; - } - - public List getList() - { - return list; - } - } - - protected class CategoryRowEditPart extends BaseEditPart - { - protected XSDSchema schema; - protected Figure contentPane; - - protected IFigure createFigure() - { - Figure containerFigure = new Figure(); - containerFigure.setBorder(new MarginBorder(4, 4, 4, 4)); - // containerFigure.setBorder(new LineBorder(1)); - // containerFigure.setBackgroundColor(ColorConstants.green); - - FillLayout fillLayout = new FillLayout(4); - fillLayout.setHorizontal(true); - containerFigure.setLayoutManager(fillLayout); - - return containerFigure; - } - - public EditPart doGetRelativeEditPart(EditPart editPart, int direction) - { - if (editPart instanceof CategoryEditPart) - { - if (direction == KeyBoardAccessibilityEditPolicy.OUT_TO_PARENT) - { - return getParent(); - } - } - else if (editPart instanceof XSDSchemaEditPart) - { - if (direction == KeyBoardAccessibilityEditPolicy.IN_TO_FIRST_CHILD) - { - return (EditPart)getChildren().get(0); - } - } - return ((XSDSchemaEditPart)getParent()).doGetRelativeEditPart(editPart, direction); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getContentPane() - */ - public IFigure getContentPane() - { - return super.getContentPane(); - } - - protected List getModelChildren() - { - Holder holder = (Holder) getModel(); - return holder.getList(); - } - - protected void createEditPolicies() - { - super.createEditPolicies(); - } - - public boolean isSelectable() - { - return false; - } - - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDSimpleTypeEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDSimpleTypeEditPart.java deleted file mode 100644 index c752addb81..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/XSDSimpleTypeEditPart.java +++ /dev/null @@ -1,232 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 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.design.editparts; - -import java.util.Iterator; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.ManhattanConnectionRouter; -import org.eclipse.draw2d.ToolbarLayout; -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.editparts.AbstractGraphicalEditPart; -import org.eclipse.gef.requests.LocationRequest; -import org.eclipse.gef.ui.actions.ActionRegistry; -import org.eclipse.jface.action.IAction; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDSimpleTypeDefinitionAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.actions.SetInputToGraphView; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseTypeConnectingEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.CenteredConnectionAnchor; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.ColumnEditPart; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.TypeReferenceConnection; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.ADTDirectEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.ADTSelectionFeedbackEditPolicy; -import org.eclipse.wst.xsd.ui.internal.adt.design.figures.IStructureFigure; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IType; -import org.eclipse.wst.xsd.ui.internal.adt.typeviz.design.figures.HeadingFigure; -import org.eclipse.wst.xsd.ui.internal.adt.typeviz.design.figures.RoundedLineBorder; -import org.eclipse.wst.xsd.ui.internal.adt.typeviz.design.figures.StructureFigure; -import org.eclipse.wst.xsd.ui.internal.common.actions.OpenInNewEditor; -import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSimpleTypeDefinition; - -public class XSDSimpleTypeEditPart extends BaseTypeConnectingEditPart -{ - protected StructureFigure figure; - protected ADTDirectEditPolicy adtDirectEditPolicy = new ADTDirectEditPolicy(); - - public XSDSimpleTypeEditPart() - { - super(); - } - - public XSDSimpleTypeDefinition getXSDSimpleTypeDefinition() - { - return (XSDSimpleTypeDefinition)((XSDSimpleTypeDefinitionAdapter)getModel()).getTarget(); - } - - protected IFigure createFigure() - { - figure = new StructureFigure(); - figure.setBorder(new RoundedLineBorder(1, 10)); - ToolbarLayout toolbarLayout = new ToolbarLayout(); - toolbarLayout.setStretchMinorAxis(true); - figure.setLayoutManager(toolbarLayout); - return figure; - } - - protected void refreshVisuals() - { - XSDSimpleTypeDefinitionAdapter adapter = (XSDSimpleTypeDefinitionAdapter)getModel(); - String name = adapter.getDisplayName(); - HeadingFigure headingFigure = figure.getHeadingFigure(); - headingFigure.setIsReadOnly(adapter.isReadOnly()); - Label label = headingFigure.getLabel(); - label.setText(name); - label.setIcon(XSDCommonUIUtils.getUpdatedImage(adapter.getXSDTypeDefinition(), adapter.getImage(), adapter.isReadOnly())); - } - - public IStructureFigure getStructureFigure() - { - return (IStructureFigure)getFigure(); - } - - public IFigure getContentPane() - { - return getStructureFigure().getContentPane(); - } - - - protected void createEditPolicies() - { - super.createEditPolicies(); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new ADTSelectionFeedbackEditPolicy()); - installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, adtDirectEditPolicy); - } - - public void addFeedback() - { - getStructureFigure().addSelectionFeedback(); - super.addFeedback(); - } - - public void removeFeedback() - { - getStructureFigure().removeSelectionFeedback(); - super.removeFeedback(); - } - - public ReferenceConnection createConnectionFigure(BaseEditPart child) - { - // TODO Auto-generated method stub - return null; - } - - public TypeReferenceConnection createConnectionFigure() - { - TypeReferenceConnection connectionFigure = null; - XSDSimpleTypeDefinitionAdapter adapter = (XSDSimpleTypeDefinitionAdapter)getModel(); - IType superType = adapter.getSuperType(); - - if (superType != null) - { - AbstractGraphicalEditPart referenceTypePart = (AbstractGraphicalEditPart)getTargetEditPart(superType); - - if (referenceTypePart != null) - { - connectionFigure = new TypeReferenceConnection(true); - // draw a line out from the top - connectionFigure.setSourceAnchor(new CenteredConnectionAnchor(getFigure(), CenteredConnectionAnchor.TOP, 1)); - - // TODO (cs) need to draw the target anchor to look like a UML inheritance relationship - // adding a label to the connection would help to - connectionFigure.setTargetAnchor(new CenteredConnectionAnchor(referenceTypePart.getFigure(), CenteredConnectionAnchor.BOTTOM, 0, 0)); - connectionFigure.setConnectionRouter(new ManhattanConnectionRouter()); - ((CenteredConnectionAnchor)connectionFigure.getSourceAnchor()).setOther((CenteredConnectionAnchor)connectionFigure.getTargetAnchor()); - connectionFigure.setHighlight(false); - - } - } - return connectionFigure; - } - - protected EditPart getTargetEditPart(IType type) - { - ColumnEditPart columnEditPart = null; - for (EditPart editPart = this; editPart != null; editPart = editPart.getParent()) - { - if (editPart instanceof ColumnEditPart) - { - columnEditPart = (ColumnEditPart)editPart; - break; - } - } - if (columnEditPart != null) - { - for (Iterator i = columnEditPart.getChildren().iterator(); i.hasNext(); ) - { - EditPart child = (EditPart)i.next(); - if (child.getModel() == type) - { - return child; - } - } - } - return null; - } - - public void performRequest(Request request) - { - if (request.getType() == RequestConstants.REQ_OPEN) - { - Object model = getModel(); - if (request instanceof LocationRequest) - { - LocationRequest locationRequest = (LocationRequest)request; - Point p = locationRequest.getLocation(); - - if (getStructureFigure().hitTestHeader(p)) - { - // TODO: !!! This should be moved to the adt-xsd package - // - if (model instanceof XSDSimpleTypeDefinitionAdapter) - { - XSDSimpleTypeDefinitionAdapter adapter = (XSDSimpleTypeDefinitionAdapter)model; - XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition)adapter.getTarget(); - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor(); - Object schema = editorPart.getAdapter(XSDSchema.class); - ActionRegistry registry = getEditorActionRegistry(editorPart); - if (registry != null) - { - if (schema == st.getSchema()) - { - IAction action = registry.getAction(SetInputToGraphView.ID); - action.run(); - } - else - { - IAction action = registry.getAction(OpenInNewEditor.ID); - action.run(); - } - } - } - } - } - } - } - - protected ActionRegistry getEditorActionRegistry(IEditorPart editor) - { - return (ActionRegistry) editor.getAdapter(ActionRegistry.class); - } - - protected boolean shouldDrawConnection() - { - if (getModel() instanceof IType) - { - if (((IType)getModel()).getSuperType() != null) - return true; - } - return false; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/model/SpaceFiller.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/model/SpaceFiller.java deleted file mode 100644 index ae847ef035..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/model/SpaceFiller.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 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.design.editparts.model; - -import org.eclipse.gef.commands.Command; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObjectListener; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IType; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; - -/** - * Dummy class to add space to field list - * - */ -public class SpaceFiller implements IField -{ - String kind; - public SpaceFiller(String kind) - { - super(); - this.kind = kind; - } - - public Image getImage() - { - if (kind.equals("attribute")) //$NON-NLS-1$ - { - return XSDEditorPlugin.getXSDImage("icons/XSDAttribute.gif"); //$NON-NLS-1$ - } - else - { - return XSDEditorPlugin.getXSDImage("icons/XSDElement.gif"); //$NON-NLS-1$ - } - } - - public String getKind() - { - return kind; - } - - public void setKind(String kind) - { - this.kind = kind; - } - - public boolean isGlobal() - { - return false; - } - - public IComplexType getContainerType() - { - return null; - } - - public String getName() - { - // TODO Auto-generated method stub - return null; - } - - public String getTypeName() - { - // TODO Auto-generated method stub - return null; - } - - public String getTypeNameQualifier() - { - // TODO Auto-generated method stub - return null; - } - - public IType getType() - { - // TODO Auto-generated method stub - return null; - } - - public int getMinOccurs() - { - // TODO Auto-generated method stub - return 0; - } - - public int getMaxOccurs() - { - // TODO Auto-generated method stub - return 0; - } - - public Command getUpdateMinOccursCommand(int minOccurs) - { - // TODO Auto-generated method stub - return null; - } - - public Command getUpdateMaxOccursCommand(int maxOccurs) - { - // TODO Auto-generated method stub - return null; - } - - public Command getUpdateTypeNameCommand(String typeName, String quailifier) - { - // TODO Auto-generated method stub - return null; - } - - public Command getUpdateNameCommand(String name) - { - // TODO Auto-generated method stub - return null; - } - - public Command getDeleteCommand() - { - // TODO Auto-generated method stub - return null; - } - - public void registerListener(IADTObjectListener listener) - { - // TODO Auto-generated method stub - - } - - public void unregisterListener(IADTObjectListener listener) - { - // TODO Auto-generated method stub - - } - - public boolean isReadOnly() - { - return true; - } - - public IModel getModel() - { - // TODO Auto-generated method stub - return null; - } - - public boolean isReference() - { - // TODO Auto-generated method stub - return false; - } -} - - diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/model/TargetConnectionSpaceFiller.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/model/TargetConnectionSpaceFiller.java deleted file mode 100644 index 73eae5aa24..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/model/TargetConnectionSpaceFiller.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 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.design.editparts.model; - -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObjectListener; - -public class TargetConnectionSpaceFiller implements IADTObject -{ - private XSDBaseAdapter adapter; - - public TargetConnectionSpaceFiller(XSDBaseAdapter adapter) - { - this.adapter = adapter; - } - - public XSDBaseAdapter getAdapter() - { - return adapter; - } - - public void registerListener(IADTObjectListener listener) - { - - } - - public void unregisterListener(IADTObjectListener listener) - { - - } - - public boolean isReadOnly() - { - return false; - } - -} |