Search in sources :

Example 6 with EditPartFactory

use of org.eclipse.gef.EditPartFactory in project archi by archimatetool.

the class DiagramUtils method createViewer.

/**
 * Create a GraphicalViewerImpl to show the model. The Viewer has no Scroll Bars
 * @param model
 * @return A Graphical Viewer
 */
public static GraphicalViewerImpl createViewer(IDiagramModel model, Composite parent) {
    EditPartFactory editPartFactory = null;
    if (model instanceof IArchimateDiagramModel) {
        editPartFactory = new ArchimateDiagramEditPartFactory();
    } else if (model instanceof ISketchModel) {
        editPartFactory = new SketchEditPartFactory();
    } else {
        // Extensions
        IDiagramEditorFactory factory = DiagramEditorFactoryExtensionHandler.INSTANCE.getFactory(model);
        if (factory != null) {
            editPartFactory = factory.createEditPartFactory();
        }
    }
    if (editPartFactory == null) {
        // $NON-NLS-1$
        throw new RuntimeException("Unsupported model type");
    }
    GraphicalViewerImpl viewer = new GraphicalViewerImpl();
    viewer.createControl(parent);
    viewer.setEditPartFactory(editPartFactory);
    RootEditPart rootPart = new FreeformGraphicalRootEditPart();
    viewer.setRootEditPart(rootPart);
    viewer.setContents(model);
    viewer.flush();
    return viewer;
}
Also used : IDiagramEditorFactory(com.archimatetool.editor.diagram.IDiagramEditorFactory) ArchimateDiagramEditPartFactory(com.archimatetool.editor.diagram.editparts.ArchimateDiagramEditPartFactory) GraphicalViewerImpl(org.eclipse.gef.ui.parts.GraphicalViewerImpl) SketchEditPartFactory(com.archimatetool.editor.diagram.sketch.editparts.SketchEditPartFactory) SketchEditPartFactory(com.archimatetool.editor.diagram.sketch.editparts.SketchEditPartFactory) EditPartFactory(org.eclipse.gef.EditPartFactory) ArchimateDiagramEditPartFactory(com.archimatetool.editor.diagram.editparts.ArchimateDiagramEditPartFactory) FreeformGraphicalRootEditPart(org.eclipse.gef.editparts.FreeformGraphicalRootEditPart) ISketchModel(com.archimatetool.model.ISketchModel) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) RootEditPart(org.eclipse.gef.RootEditPart) FreeformGraphicalRootEditPart(org.eclipse.gef.editparts.FreeformGraphicalRootEditPart)

Example 7 with EditPartFactory

use of org.eclipse.gef.EditPartFactory in project webtools.sourceediting by eclipse.

the class BaseEditPart method getFigureFactory.

public IFigureFactory getFigureFactory() {
    EditPartFactory factory = getViewer().getEditPartFactory();
    // $NON-NLS-1$
    Assert.isTrue(factory instanceof IFigureFactory, "EditPartFactory must be an instanceof of IFigureFactory");
    return (IFigureFactory) factory;
}
Also used : EditPartFactory(org.eclipse.gef.EditPartFactory) IFigureFactory(org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFigureFactory)

Example 8 with EditPartFactory

use of org.eclipse.gef.EditPartFactory in project webtools.sourceediting by eclipse.

the class XSDEditorConfiguration method updateList.

private void updateList(String ID) {
    IConfigurationElement[] xsdEditorExtensionList = Platform.getExtensionRegistry().getConfigurationElementsFor(ID);
    boolean definedExtensionsExist = (xsdEditorExtensionList != null && xsdEditorExtensionList.length > 0);
    if (definedExtensionsExist) {
        for (int i = 0; i < xsdEditorExtensionList.length; i++) {
            XSDEditorExtensionProperties properties = new XSDEditorExtensionProperties();
            definedExtensionsList.add(properties);
            IConfigurationElement element = xsdEditorExtensionList[i];
            String adapterFactoryClass = element.getAttribute(ADAPTERFACTORY);
            if (adapterFactoryClass != null) {
                Object object = loadClass(element, adapterFactoryClass);
                XSDAdapterFactory adapterFactory = null;
                if (object instanceof XSDAdapterFactory) {
                    adapterFactory = (XSDAdapterFactory) object;
                    properties.setAdapterFactory(adapterFactory);
                }
            }
            String figureFactoryClass = element.getAttribute(FIGUREFACTORY);
            if (figureFactoryClass != null) {
                Object object = loadClass(element, figureFactoryClass);
                IExtendedFigureFactory figureFactory = null;
                if (object instanceof IExtendedFigureFactory) {
                    figureFactory = (IExtendedFigureFactory) object;
                    properties.setFigureFactoryList(figureFactory);
                }
            }
            IConfigurationElement[] toolbarActions = element.getChildren(TOOLBARACTION);
            List actionList = new ArrayList();
            if (toolbarActions != null) {
                for (int j = 0; j < toolbarActions.length; j++) {
                    IConfigurationElement actionElement = toolbarActions[j];
                    String actionClass = actionElement.getAttribute(CLASSNAME);
                    IXSDToolbarAction action = null;
                    if (actionClass != null) {
                        Object object = loadClass(actionElement, actionClass);
                        if (object instanceof IXSDToolbarAction) {
                            action = (IXSDToolbarAction) object;
                            actionList.add(action);
                        }
                    }
                }
            }
            properties.setActionList(actionList);
            String editPartFactoryClass = element.getAttribute(EDITPARTFACTORY);
            if (editPartFactoryClass != null) {
                Object object = loadClass(element, editPartFactoryClass);
                EditPartFactory editPartFactory = null;
                if (object instanceof EditPartFactory) {
                    editPartFactory = (EditPartFactory) object;
                    properties.setEditPartFactoryList(editPartFactory);
                }
            }
        }
    }
}
Also used : XSDAdapterFactory(org.eclipse.wst.xsd.ui.internal.adapters.XSDAdapterFactory) IExtendedFigureFactory(org.eclipse.wst.xsd.ui.internal.design.figures.IExtendedFigureFactory) ArrayList(java.util.ArrayList) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) EditPartFactory(org.eclipse.gef.EditPartFactory) List(java.util.List) ArrayList(java.util.ArrayList) IXSDToolbarAction(org.eclipse.wst.xsd.ui.internal.actions.IXSDToolbarAction)

Aggregations

EditPartFactory (org.eclipse.gef.EditPartFactory)8 Composite (org.eclipse.swt.widgets.Composite)3 IExtendedFigureFactory (org.eclipse.wst.xsd.ui.internal.design.figures.IExtendedFigureFactory)2 IDiagramEditorFactory (com.archimatetool.editor.diagram.IDiagramEditorFactory)1 ArchimateDiagramEditPartFactory (com.archimatetool.editor.diagram.editparts.ArchimateDiagramEditPartFactory)1 SketchEditPartFactory (com.archimatetool.editor.diagram.sketch.editparts.SketchEditPartFactory)1 IArchimateDiagramModel (com.archimatetool.model.IArchimateDiagramModel)1 ISketchModel (com.archimatetool.model.ISketchModel)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 RootEditPart (org.eclipse.gef.RootEditPart)1 FreeformGraphicalRootEditPart (org.eclipse.gef.editparts.FreeformGraphicalRootEditPart)1 GraphicalViewerImpl (org.eclipse.gef.ui.parts.GraphicalViewerImpl)1 ScrollingGraphicalViewer (org.eclipse.gef.ui.parts.ScrollingGraphicalViewer)1 IContentProvider (org.eclipse.jface.viewers.IContentProvider)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 Control (org.eclipse.swt.widgets.Control)1 IXSDToolbarAction (org.eclipse.wst.xsd.ui.internal.actions.IXSDToolbarAction)1