Search in sources :

Example 1 with IStructure

use of org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure in project webtools.sourceediting by eclipse.

the class ReferencedTypeColumn method getChildren.

public List getChildren() {
    List result = new ArrayList();
    if (model instanceof IStructure) {
        IStructure structure = (IStructure) model;
        for (Iterator i = structure.getFields().iterator(); i.hasNext(); ) {
            IField field = (IField) i.next();
            IType type = field.getType();
            if (// && type.isComplexType())
            type != null) {
                if (!result.contains(type)) {
                    if (type instanceof IGraphElement) {
                        if (((IGraphElement) type).isFocusAllowed())
                            result.add(type);
                    }
                }
            }
        }
    } else if (model instanceof IField) {
        IField field = (IField) model;
        IType type = field.getType();
        if (// && type.isComplexType())
        type != null) {
            if (type instanceof IGraphElement) {
                if (((IGraphElement) type).isFocusAllowed())
                    result.add(type);
            }
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) IStructure(org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure) IField(org.eclipse.wst.xsd.ui.internal.adt.facade.IField) IType(org.eclipse.wst.xsd.ui.internal.adt.facade.IType)

Example 2 with IStructure

use of org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure in project webtools.sourceediting by eclipse.

the class FocusTypeColumn method getChildren.

public List getChildren() {
    List result = new ArrayList();
    if (model instanceof IType) {
        IType type = (IType) model;
        if (type.getSuperType() != null) {
            result.add(type.getSuperType());
        }
        result.add(type);
    } else if (model instanceof IField || model instanceof IStructure) {
        result.add(model);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) IStructure(org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure) IField(org.eclipse.wst.xsd.ui.internal.adt.facade.IField) IType(org.eclipse.wst.xsd.ui.internal.adt.facade.IType)

Example 3 with IStructure

use of org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure in project webtools.sourceediting by eclipse.

the class XSDGroupsForAnnotationEditPart method getModelChildren.

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;
}
Also used : XSDComplexTypeDefinitionAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDComplexTypeDefinitionAdapter) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDModelGroupDefinitionAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDModelGroupDefinitionAdapter) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) IStructure(org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) Annotation(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.Annotation) IComplexType(org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType)

Example 4 with IStructure

use of org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure in project webtools.sourceediting by eclipse.

the class StructureFigure method refreshVisuals.

public void refreshVisuals(Object model) {
    IStructure structure = (IStructure) model;
    getNameLabel().setText(structure.getName());
    getHeadingFigure().setIsReadOnly(structure.isReadOnly());
}
Also used : IStructure(org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure)

Example 5 with IStructure

use of org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure in project webtools.sourceediting by eclipse.

the class DesignViewGraphicalViewer method selectionChanged.

// this method is called when something changes in the selection manager
// (e.g. a selection occured from another view)
public void selectionChanged(SelectionChangedEvent event) {
    Object selectedObject = null;
    ISelection eventSelection = event.getSelection();
    if (eventSelection instanceof StructuredSelection) {
        selectedObject = ((StructuredSelection) eventSelection).getFirstElement();
    }
    // if (event.getSource() instanceof ADTContentOutlinePage)
    if (selectedObject != null) {
        if (event.getSource() != internalSelectionProvider) {
            if (selectedObject instanceof IStructure) {
                if (((getInput() instanceof IModel) && (event.getSource() instanceof ADTContentOutlinePage)) || (!(getInput() instanceof IModel))) {
                    if ((selectedObject instanceof IGraphElement) && ((IGraphElement) selectedObject).isFocusAllowed()) {
                        if (!(event.getSource() instanceof org.eclipse.jface.viewers.IPostSelectionProvider)) {
                            setInputAndMarkLocation((IStructure) selectedObject);
                        }
                    }
                }
            } else if (selectedObject instanceof IGraphElement) {
                if (((IGraphElement) selectedObject).isFocusAllowed() && ((event.getSource() instanceof ADTContentOutlinePage))) {
                    setInputAndMarkLocation((IADTObject) selectedObject);
                } else if (!((IGraphElement) selectedObject).isFocusAllowed()) {
                    // We encountered an object that is not a valid input to the graph viewer
                    // Now find the top container that can be a valid input
                    IADTObject obj = ((IGraphElement) selectedObject).getTopContainer();
                    if (event.getSource() instanceof ADTContentOutlinePage) {
                        // change the inputs
                        if (// Don't change inputs if the obj is already the input
                        obj != null && getInput() != obj)
                            setInputAndMarkLocation(obj);
                    } else if (event.getSource() instanceof CommonSelectionManager) {
                        // otherwise, inputs will change unexpectedly!!
                        if (getInput() instanceof IModel) {
                            if (obj != null)
                                setInput(obj);
                        }
                    } else if (event.getSource() instanceof org.eclipse.jface.viewers.IPostSelectionProvider) {
                        // of anonymous types
                        if (obj != null)
                            setInput(obj);
                    } else {
                        if (obj != null && getInput() instanceof IModel)
                            setInputAndMarkLocation(obj);
                    }
                }
                if (selectedObject instanceof IField) {
                    IField field = (IField) selectedObject;
                    if ((!field.isGlobal() && getInput() instanceof IModel) || (!field.isGlobal() && !(event.getSource() instanceof CommonSelectionManager))) {
                        IADTObject obj = ((IGraphElement) selectedObject).getTopContainer();
                        if (obj != null)
                            setInputAndMarkLocation(obj);
                    } else if (field.isGlobal() && !(getInput() instanceof IModel)) {
                        if (event.getSource() instanceof org.eclipse.jface.viewers.IPostSelectionProvider)
                            setInput(field);
                        else
                            setInputAndMarkLocation(field);
                    }
                }
            } else if (selectedObject instanceof IField) {
                IField field = (IField) selectedObject;
                if ((field.isGlobal() && (getInput() instanceof IModel) && (event.getSource() instanceof ADTContentOutlinePage)) || ((field.isGlobal() && !(getInput() instanceof IModel)))) {
                    setInputAndMarkLocation(field);
                }
            } else if (selectedObject instanceof IModelProxy) {
                IModelProxy adapter = (IModelProxy) selectedObject;
                if (selectedObject instanceof RedefineCategoryAdapter) {
                    RedefineCategoryAdapter selectionAdapter = (RedefineCategoryAdapter) selectedObject;
                    XSDRedefineAdapter selectionParentAdapter = selectionAdapter.getXsdRedefineAdapter();
                    setInputAndMarkLocation(selectionParentAdapter);
                } else if (getInput() != adapter.getModel())
                    setInput(adapter.getModel());
            } else if (selectedObject instanceof IModel) {
                if (getInput() != selectedObject)
                    setInput((IModel) selectedObject);
            }
            EditPart editPart = getEditPart(getRootEditPart(), selectedObject);
            if (editPart != null) {
                setSelection(new StructuredSelection(editPart));
                setFocus(editPart);
            }
        }
    }
}
Also used : IModel(org.eclipse.wst.xsd.ui.internal.adt.facade.IModel) IModelProxy(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IModelProxy) IGraphElement(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RootContentEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart) IHolderEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.IHolderEditPart) StructureEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.StructureEditPart) EditPart(org.eclipse.gef.EditPart) CommonSelectionManager(org.eclipse.wst.xsd.ui.internal.adt.editor.CommonSelectionManager) IStructure(org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure) IField(org.eclipse.wst.xsd.ui.internal.adt.facade.IField) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) RedefineCategoryAdapter(org.eclipse.wst.xsd.ui.internal.adapters.RedefineCategoryAdapter) ISelection(org.eclipse.jface.viewers.ISelection) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) ADTContentOutlinePage(org.eclipse.wst.xsd.ui.internal.adt.outline.ADTContentOutlinePage) XSDRedefineAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDRedefineAdapter)

Aggregations

IStructure (org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure)6 ArrayList (java.util.ArrayList)4 IField (org.eclipse.wst.xsd.ui.internal.adt.facade.IField)4 List (java.util.List)3 IType (org.eclipse.wst.xsd.ui.internal.adt.facade.IType)3 Iterator (java.util.Iterator)2 IGraphElement (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement)2 IADTObject (org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)2 IModel (org.eclipse.wst.xsd.ui.internal.adt.facade.IModel)2 EditPart (org.eclipse.gef.EditPart)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 RedefineCategoryAdapter (org.eclipse.wst.xsd.ui.internal.adapters.RedefineCategoryAdapter)1 XSDComplexTypeDefinitionAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDComplexTypeDefinitionAdapter)1 XSDModelGroupDefinitionAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDModelGroupDefinitionAdapter)1 XSDRedefineAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDRedefineAdapter)1 IHolderEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.IHolderEditPart)1 RootContentEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart)1 StructureEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.StructureEditPart)1