Search in sources :

Example 6 with IADTObject

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

the class ADTContentOutlineProvider method removeListener.

/**
 * @param model
 */
private void removeListener(IADTObject model) {
    model.unregisterListener(this);
    Object[] children = null;
    if (model instanceof ITreeElement) {
        children = ((ITreeElement) model).getChildren();
    }
    if (children != null) {
        int length = children.length;
        for (int i = 0; i < length; i++) {
            Object child = children[i];
            if (child instanceof IADTObject && model != child) {
                removeListener((IADTObject) child);
            }
        }
    }
}
Also used : IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)

Example 7 with IADTObject

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

the class BaseEditPart method deactivate.

public void deactivate() {
    try {
        Object model = getModel();
        if (model instanceof IADTObject) {
            IADTObject object = (IADTObject) model;
            object.unregisterListener(this);
        }
        if (getZoomManager() != null)
            getZoomManager().removeZoomListener(zoomListener);
    } finally {
        super.deactivate();
    }
}
Also used : IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)

Example 8 with IADTObject

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

the class DeleteAction method run.

public void run() {
    for (Iterator i = ((IStructuredSelection) getSelection()).iterator(); i.hasNext(); ) {
        Object selection = i.next();
        Command command = null;
        boolean doSetInput = false;
        boolean doSetModelAsInput = false;
        IADTObject topLevelContainer = null;
        IModel model = null;
        if (selection instanceof IGraphElement) {
            IGraphElement xsdObj = (IGraphElement) selection;
            if (xsdObj instanceof XSDBaseAdapter) {
                XSDBaseAdapter baseAdapter = (XSDBaseAdapter) xsdObj;
                // is null and the read only check cannot be completed
                if (baseAdapter == null || baseAdapter.isReadOnly()) {
                    continue;
                }
                topLevelContainer = xsdObj.getTopContainer();
                if (topLevelContainer == selection) {
                    doSetInput = true;
                    doSetModelAsInput = true;
                }
                command = xsdObj.getDeleteCommand();
                model = xsdObj.getModel();
            }
        }
        if (command != null) {
            IWorkbench workbench = PlatformUI.getWorkbench();
            if (workbench != null) {
                IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
                if (workbenchWindow != null && workbenchWindow.getActivePage() != null) {
                    IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor();
                    if (editorPart != null) {
                        Object viewer = editorPart.getAdapter(GraphicalViewer.class);
                        if (viewer instanceof DesignViewGraphicalViewer) {
                            Object input = ((DesignViewGraphicalViewer) viewer).getInput();
                            if (input != selection) {
                                // Bug 86218 : Don't switch to top level view if the object we're deleting
                                // is not the input to the viewer
                                doSetInput = false;
                            }
                        }
                    }
                }
            }
            command.execute();
            if (doSetInput) {
                if (model != null && doSetModelAsInput)
                    provider.setSelection(new StructuredSelection(model));
                else if (topLevelContainer != null && !doSetModelAsInput)
                    provider.setSelection(new StructuredSelection(topLevelContainer));
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IModel(org.eclipse.wst.xsd.ui.internal.adt.facade.IModel) IGraphElement(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) IWorkbench(org.eclipse.ui.IWorkbench) DesignViewGraphicalViewer(org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer) Command(org.eclipse.gef.commands.Command) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) Iterator(java.util.Iterator) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)

Example 9 with IADTObject

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

the class RootContentEditPart method activate.

// https://bugs.eclipse.org/bugs/show_bug.cgi?id=252589
public void activate() {
    super.activate();
    Object model = getModel();
    // The schema adapter doesn't have to notify the RootContentEditPart of it changes
    if (model instanceof IADTObject) {
        IADTObject object = (IADTObject) model;
        object.unregisterListener(this);
    }
}
Also used : IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)

Example 10 with IADTObject

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

the class RootHolderEditPart method getModelChildren.

protected List getModelChildren() {
    List collections = new ArrayList();
    RootHolder holder = (RootHolder) getModel();
    IADTObject focusObject = holder.getModel();
    collections.add(new FocusTypeColumn(focusObject));
    collections.add(new ReferencedTypeColumn(focusObject));
    return collections;
}
Also used : IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) ReferencedTypeColumn(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.ReferencedTypeColumn) ArrayList(java.util.ArrayList) FocusTypeColumn(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.FocusTypeColumn) List(java.util.List) ArrayList(java.util.ArrayList) RootHolder(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.RootHolder)

Aggregations

IADTObject (org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)23 Adapter (org.eclipse.emf.common.notify.Adapter)9 Iterator (java.util.Iterator)7 ArrayList (java.util.ArrayList)5 DesignViewGraphicalViewer (org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer)4 IModel (org.eclipse.wst.xsd.ui.internal.adt.facade.IModel)4 IGraphElement (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement)3 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)3 List (java.util.List)2 EditPart (org.eclipse.gef.EditPart)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 IWorkbench (org.eclipse.ui.IWorkbench)2 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)2 RootContentEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart)2 RootHolder (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.RootHolder)2 IField (org.eclipse.wst.xsd.ui.internal.adt.facade.IField)2 IStructure (org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure)2 ADTContentOutlinePage (org.eclipse.wst.xsd.ui.internal.adt.outline.ADTContentOutlinePage)2 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)2