Search in sources :

Example 16 with XSDBaseAdapter

use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.

the class MakeAnonymousTypeGobalHandler method doExecute.

public Object doExecute(ISelection selection, XSDSchema schema) {
    if (selection != null) {
        Object selectedObject = ((StructuredSelection) selection).getFirstElement();
        if (selectedObject instanceof XSDBaseAdapter) {
            selectedObject = ((XSDBaseAdapter) selectedObject).getTarget();
        }
        XSDConcreteComponent concreteComp = null;
        if (selectedObject instanceof Node) {
            Node node = (Node) selectedObject;
            concreteComp = schema.getCorrespondingComponent(node);
        } else if (selectedObject instanceof XSDConcreteComponent) {
            concreteComp = ((XSDConcreteComponent) selectedObject);
        }
        if (concreteComp != null) {
            if (concreteComp instanceof XSDComplexTypeDefinition) {
                isComplexType = true;
                XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) concreteComp;
                XSDConcreteComponent parent = typeDef.getContainer();
                if (parent instanceof XSDElementDeclaration) {
                    parentName = ((XSDElementDeclaration) parent).getName();
                    run(selection, schema, typeDef);
                } else if (concreteComp instanceof XSDSimpleTypeDefinition) {
                    isComplexType = false;
                    XSDSimpleTypeDefinition simpleTypeDef = (XSDSimpleTypeDefinition) concreteComp;
                    XSDConcreteComponent parentComp = simpleTypeDef.getContainer();
                    if (parentComp instanceof XSDElementDeclaration) {
                        parentName = ((XSDElementDeclaration) parent).getName();
                    } else if (parent instanceof XSDAttributeDeclaration) {
                        parentName = ((XSDAttributeDeclaration) parent).getName();
                    }
                    run(selection, schema, simpleTypeDef);
                }
            }
        }
    }
    return null;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) Node(org.w3c.dom.Node) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration)

Example 17 with XSDBaseAdapter

use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.

the class AttributeGroupDefinitionEditPart method getModelChildren.

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;
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) ArrayList(java.util.ArrayList) XSDAttributeGroupDefinitionAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeGroupDefinitionAdapter) Iterator(java.util.Iterator) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) ArrayList(java.util.ArrayList) List(java.util.List) TargetConnectionSpaceFiller(org.eclipse.wst.xsd.ui.internal.design.editparts.model.TargetConnectionSpaceFiller) XSDAttributeGroupContent(org.eclipse.xsd.XSDAttributeGroupContent) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 18 with XSDBaseAdapter

use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.

the class TopLevelComponentEditPart method refreshVisuals.

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));
        }
        if (adapter.isAbstract()) {
            if (italicFont == null) {
                Font font = label.getFont();
                italicFont = getItalicFont(font);
            }
            if (italicFont != null) {
                label.setFont(italicFont);
            }
        } else {
            label.setFont(label.getParent().getFont());
        }
    } else {
        label.setText(Messages._UI_GRAPH_UNKNOWN_OBJECT + getModel().getClass().getName());
    // arrowLabel.setVisible(false);
    }
    if (reselect) {
        getViewer().select(this);
        setReselect(false);
    }
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) Image(org.eclipse.swt.graphics.Image) Font(org.eclipse.swt.graphics.Font)

Example 19 with XSDBaseAdapter

use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.

the class BaseDragAndDropCommand method commonSetup.

protected void commonSetup(List siblings, GraphicalEditPart movingEditPart) {
    closerSibling = ABOVE_IS_CLOSER;
    int pointerYLocation = location.y;
    int index;
    for (index = 0; index < siblings.size(); index++) {
        GraphicalEditPart sibling = (GraphicalEditPart) siblings.get(index);
        if (sibling instanceof BaseFieldEditPart) {
            int siblingYLocation = getZoomedBounds(sibling.getFigure().getBounds()).getCenter().y;
            if (siblingYLocation > pointerYLocation) {
                rightSiblingEditPart = sibling;
                if (index > 0) {
                    leftSiblingEditPart = (GraphicalEditPart) siblings.get(index - 1);
                }
                if (leftSiblingEditPart != null && Math.abs(getZoomedBounds(leftSiblingEditPart.getFigure().getBounds()).getCenter().y - pointerYLocation) > Math.abs(siblingYLocation - pointerYLocation)) {
                    closerSibling = BELOW_IS_CLOSER;
                }
                break;
            }
        }
    }
    boolean isHandled = handleFirstAndLastDropTargets(index, siblings);
    if (!isHandled)
        handleOtherTargets(index);
    calculateLeftAndRightXSDComponents();
    xsdComponentToDrag = (XSDConcreteComponent) ((XSDBaseAdapter) itemToDrag.getModel()).getTarget();
}
Also used : XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) Point(org.eclipse.draw2d.geometry.Point) XSDBaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart) BaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart)

Example 20 with XSDBaseAdapter

use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.

the class BaseDragAndDropCommand method calculateLeftAndRightXSDComponents.

protected void calculateLeftAndRightXSDComponents() {
    if (leftSiblingEditPart instanceof XSDBaseFieldEditPart) {
        Object leftModel = ((XSDBaseFieldEditPart) leftSiblingEditPart).getModel();
        previousRefComponent = null;
        if (leftModel instanceof XSDBaseAdapter) {
            XSDBaseAdapter leftAdapter = (XSDBaseAdapter) leftModel;
            previousRefComponent = (XSDConcreteComponent) leftAdapter.getTarget();
        }
    }
    if (rightSiblingEditPart instanceof XSDBaseFieldEditPart) {
        Object rightModel = ((XSDBaseFieldEditPart) rightSiblingEditPart).getModel();
        nextRefComponent = null;
        if (rightModel instanceof XSDBaseAdapter) {
            XSDBaseAdapter rightAdapter = (XSDBaseAdapter) rightModel;
            nextRefComponent = (XSDConcreteComponent) rightAdapter.getTarget();
        }
    }
}
Also used : XSDBaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)

Aggregations

XSDBaseAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)33 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)23 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)16 Adapter (org.eclipse.emf.common.notify.Adapter)14 XSDSchema (org.eclipse.xsd.XSDSchema)10 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)9 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)8 IEditorPart (org.eclipse.ui.IEditorPart)6 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)5 Iterator (java.util.Iterator)4 XSDAttributeUse (org.eclipse.xsd.XSDAttributeUse)4 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)4 List (java.util.List)3 Point (org.eclipse.draw2d.geometry.Point)3 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)3 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)3 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)3 ArrayList (java.util.ArrayList)2 Image (org.eclipse.swt.graphics.Image)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2