Search in sources :

Example 1 with ProductCustomizationProvider

use of org.eclipse.wst.xsd.ui.internal.adt.editor.ProductCustomizationProvider in project webtools.sourceediting by eclipse.

the class InternalXSDMultiPageEditor method createNavigationLocation.

public INavigationLocation createNavigationLocation() {
    if (getActivePage() == DESIGN_PAGE_INDEX) {
        try {
            RootEditPart rootEditPart = graphicalViewer.getRootEditPart();
            EditPart editPart = rootEditPart.getContents();
            if (editPart instanceof RootContentEditPart) {
                RootContentEditPart rootContentEditPart = (RootContentEditPart) editPart;
                Object input = rootContentEditPart.getInput();
                if (input instanceof Adapter) {
                    XSDConcreteComponent concreteComponent = (XSDConcreteComponent) ((Adapter) input).getTarget();
                    Object object = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getAdapter(ProductCustomizationProvider.class);
                    if (object instanceof ProductCustomizationProvider) {
                        ProductCustomizationProvider productCustomizationProvider = (ProductCustomizationProvider) object;
                        if (productCustomizationProvider != null) {
                            return productCustomizationProvider.getNavigationLocation(this, concreteComponent, rootContentEditPart);
                        }
                    }
                    return new DesignViewNavigationLocation(this, concreteComponent);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    } else {
        return new MultiPageEditorTextSelectionNavigationLocation(getTextEditor(), true);
    }
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) DesignViewNavigationLocation(org.eclipse.wst.xsd.ui.internal.navigation.DesignViewNavigationLocation) RootEditPart(org.eclipse.gef.RootEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) RootContentEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart) EObject(org.eclipse.emf.ecore.EObject) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) XSDRedefineAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDRedefineAdapter) INodeAdapter(org.eclipse.wst.sse.core.internal.provisional.INodeAdapter) Adapter(org.eclipse.emf.common.notify.Adapter) CategoryAdapter(org.eclipse.wst.xsd.ui.internal.adapters.CategoryAdapter) XSDModelAdapter(org.eclipse.wst.xsd.ui.internal.text.XSDModelAdapter) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) RedefineCategoryAdapter(org.eclipse.wst.xsd.ui.internal.adapters.RedefineCategoryAdapter) RootContentEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart) ProductCustomizationProvider(org.eclipse.wst.xsd.ui.internal.adt.editor.ProductCustomizationProvider) MultiPageEditorTextSelectionNavigationLocation(org.eclipse.wst.xsd.ui.internal.navigation.MultiPageEditorTextSelectionNavigationLocation) RootEditPart(org.eclipse.gef.RootEditPart)

Example 2 with ProductCustomizationProvider

use of org.eclipse.wst.xsd.ui.internal.adt.editor.ProductCustomizationProvider in project webtools.sourceediting by eclipse.

the class InternalXSDMultiPageEditor method createEditorModeManager.

// private boolean isInitializing = false;
protected EditorModeManager createEditorModeManager() {
    final ProductCustomizationProvider productCustomizationProvider = (ProductCustomizationProvider) getAdapter(ProductCustomizationProvider.class);
    EditorModeManager manager = new EditorModeManager(XSD_EDITOR_MODE_EXTENSION_ID) {

        public void init() {
            if (productCustomizationProvider == null || productCustomizationProvider.isEditorModeApplicable(TypeVizEditorMode.ID)) {
                addMode(new TypeVizEditorMode());
            }
            super.init();
        }

        protected EditorMode getDefaultMode() {
            String defaultModeId = XSDEditorPlugin.getPlugin().getPreferenceStore().getString(DEFAULT_EDITOR_MODE_ID);
            if (defaultModeId != null) {
                EditorMode editorMode = getEditorMode(defaultModeId);
                if (editorMode != null) {
                    return editorMode;
                }
            }
            return super.getDefaultMode();
        }
    };
    manager.setProductCustomizationProvider(productCustomizationProvider);
    return manager;
}
Also used : EditorMode(org.eclipse.wst.xsd.ui.internal.adt.editor.EditorMode) TypeVizEditorMode(org.eclipse.wst.xsd.ui.internal.adt.typeviz.TypeVizEditorMode) TypeVizEditorMode(org.eclipse.wst.xsd.ui.internal.adt.typeviz.TypeVizEditorMode) ProductCustomizationProvider(org.eclipse.wst.xsd.ui.internal.adt.editor.ProductCustomizationProvider) EditorModeManager(org.eclipse.wst.xsd.ui.internal.adt.editor.EditorModeManager)

Aggregations

ProductCustomizationProvider (org.eclipse.wst.xsd.ui.internal.adt.editor.ProductCustomizationProvider)2 Adapter (org.eclipse.emf.common.notify.Adapter)1 EObject (org.eclipse.emf.ecore.EObject)1 EditPart (org.eclipse.gef.EditPart)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 RootEditPart (org.eclipse.gef.RootEditPart)1 INodeAdapter (org.eclipse.wst.sse.core.internal.provisional.INodeAdapter)1 CategoryAdapter (org.eclipse.wst.xsd.ui.internal.adapters.CategoryAdapter)1 RedefineCategoryAdapter (org.eclipse.wst.xsd.ui.internal.adapters.RedefineCategoryAdapter)1 XSDBaseAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)1 XSDRedefineAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDRedefineAdapter)1 RootContentEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart)1 EditorMode (org.eclipse.wst.xsd.ui.internal.adt.editor.EditorMode)1 EditorModeManager (org.eclipse.wst.xsd.ui.internal.adt.editor.EditorModeManager)1 IADTObject (org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)1 TypeVizEditorMode (org.eclipse.wst.xsd.ui.internal.adt.typeviz.TypeVizEditorMode)1 DesignViewNavigationLocation (org.eclipse.wst.xsd.ui.internal.navigation.DesignViewNavigationLocation)1 MultiPageEditorTextSelectionNavigationLocation (org.eclipse.wst.xsd.ui.internal.navigation.MultiPageEditorTextSelectionNavigationLocation)1 XSDModelAdapter (org.eclipse.wst.xsd.ui.internal.text.XSDModelAdapter)1 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)1