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;
}
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;
}
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);
}
}
}
}
}
Aggregations