use of com.archimatetool.model.ISketchModel in project archi by archimatetool.
the class TreeModelViewActionFactory method createNewSketchAction.
private IAction createNewSketchAction(final IFolder folder) {
IAction action = new Action(Messages.TreeModelViewActionFactory_2) {
@Override
public void run() {
// Create a new Diagram Model, set its name
ISketchModel sketchModel = IArchimateFactory.eINSTANCE.createSketchModel();
sketchModel.setName(Messages.TreeModelViewActionFactory_3);
// Defaults
int defaultBackground = Preferences.STORE.getInt(IPreferenceConstants.SKETCH_DEFAULT_BACKGROUND);
sketchModel.setBackground(defaultBackground);
// Execute Command
Command cmd = new NewDiagramCommand(folder, sketchModel, Messages.TreeModelViewActionFactory_3);
CommandStack commandStack = (CommandStack) folder.getAdapter(CommandStack.class);
commandStack.execute(cmd);
}
};
action.setImageDescriptor(IArchiImages.ImageFactory.getImageDescriptor(IArchiImages.ICON_SKETCH));
return action;
}
use of com.archimatetool.model.ISketchModel in project archi by archimatetool.
the class ArchiLabelProviderTests method testGetLabel.
@Test
public void testGetLabel() {
// Null object
assertEquals("", ArchiLabelProvider.INSTANCE.getLabel(null));
// Any object
assertEquals("", ArchiLabelProvider.INSTANCE.getLabel(""));
// Nameable
INameable nameable = IArchimateFactory.eINSTANCE.createBusinessActor();
nameable.setName("Hello");
assertEquals("Hello", ArchiLabelProvider.INSTANCE.getLabel(nameable));
// View
IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
assertEquals("View", ArchiLabelProvider.INSTANCE.getLabel(dm));
// Sketch
ISketchModel sm = IArchimateFactory.eINSTANCE.createSketchModel();
assertEquals("Sketch", ArchiLabelProvider.INSTANCE.getLabel(sm));
// Image
IDiagramModelImage di = IArchimateFactory.eINSTANCE.createDiagramModelImage();
assertEquals("Image", ArchiLabelProvider.INSTANCE.getLabel(di));
}
use of com.archimatetool.model.ISketchModel in project archi by archimatetool.
the class SketchEditor method updateBackgroundImage.
public void updateBackgroundImage() {
ISketchModel model = getModel();
if (fBackgroundImageLayer == null) {
fBackgroundImageLayer = new BackgroundImageLayer();
fScalableFreeformLayeredPane.add(fBackgroundImageLayer, BackgroundImageLayer.NAME, 0);
}
switch(model.getBackground()) {
case 0:
fBackgroundImageLayer.setImage(null);
break;
case 1:
Image img = IArchiImages.ImageFactory.getImage(IArchiImages.BROWN_PAPER_BACKGROUND);
fBackgroundImageLayer.setImage(img);
break;
case 2:
img = IArchiImages.ImageFactory.getImage(IArchiImages.CORK_BACKGROUND);
fBackgroundImageLayer.setImage(img);
break;
default:
break;
}
}
use of com.archimatetool.model.ISketchModel in project archi by archimatetool.
the class EditorManager method openDiagramEditor.
/**
* Open the Diagram Editor for a given DiagramModel Model
* @param name
*/
public static IDiagramModelEditor openDiagramEditor(IDiagramModel model) {
if (model == null || model.eContainer() == null || !PlatformUI.isWorkbenchRunning()) {
return null;
}
String id = null;
IEditorInput editorInput = null;
if (model instanceof IArchimateDiagramModel) {
id = IArchimateDiagramEditor.ID;
editorInput = new DiagramEditorInput(model);
} else if (model instanceof ISketchModel) {
id = ISketchEditor.ID;
editorInput = new DiagramEditorInput(model);
} else {
IDiagramEditorFactory factory = DiagramEditorFactoryExtensionHandler.INSTANCE.getFactory(model);
if (factory != null) {
id = factory.getEditorID();
editorInput = factory.createEditorInput(model);
}
}
if (id == null || editorInput == null) {
// $NON-NLS-1$
throw new RuntimeException("Unsupported model type");
}
IEditorPart part = openEditor(editorInput, id);
// Check it actually is IDiagramModelEditor, it could be an org.eclipse.ui.internal.ErrorEditorPart if an error occurs
return part instanceof IDiagramModelEditor ? (IDiagramModelEditor) part : null;
}
use of com.archimatetool.model.ISketchModel 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;
}
Aggregations