use of com.archimatetool.model.IArchimateDiagramModel in project archi by archimatetool.
the class EditorModelManagerTests method createNewModel_IsValid.
@Test
public void createNewModel_IsValid() {
IArchimateModel model = editorModelManager.createNewModel();
assertNotNull(model);
// Has default folders
assertFalse(model.getFolders().isEmpty());
// Has One Default View
// $NON-NLS-1$
assertTrue(model.getFolder(FolderType.DIAGRAMS).getElements().get(0) instanceof IArchimateDiagramModel);
// Has a Command Stack
assertTrue(model.getAdapter(CommandStack.class) instanceof CommandStack);
// Has an Archive Manager
assertTrue(model.getAdapter(IArchiveManager.class) instanceof IArchiveManager);
// Has an ECore Adapter
assertTrue(hasECoreAdapter(model));
}
use of com.archimatetool.model.IArchimateDiagramModel 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.IArchimateDiagramModel in project archi by archimatetool.
the class CopySnapshotTests method testCanPasteToDiagram_DifferentModelDiagramReference.
@Test
public void testCanPasteToDiagram_DifferentModelDiagramReference() throws IOException {
loadTestModel1();
// Test can't paste IDiagramModelReference to another Archimate model
// Source model
IDiagramModelReference reference = IArchimateFactory.eINSTANCE.createDiagramModelReference();
reference.setReferencedModel(model.getDiagramModels().get(0));
sourceDiagramModel.getChildren().add(reference);
// Target model
IArchimateModel model2 = IArchimateFactory.eINSTANCE.createArchimateModel();
IArchimateDiagramModel targetDiagramModel2 = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
model2.getDefaultFolderForObject(targetDiagramModel2).getElements().add(targetDiagramModel2);
List<IDiagramModelComponent> selected = new ArrayList<IDiagramModelComponent>();
selected.add(reference);
CopySnapshot snapshot = new CopySnapshot(selected);
assertFalse(snapshot.canPasteToDiagram(targetDiagramModel2));
// Should be OK if other objects added
selected.addAll(sourceDiagramModel.getChildren());
snapshot = new CopySnapshot(selected);
assertTrue(snapshot.canPasteToDiagram(targetDiagramModel2));
}
use of com.archimatetool.model.IArchimateDiagramModel 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.IArchimateDiagramModel in project archi by archimatetool.
the class MagicConnectionCreationTool method isAllowedTargetTypeInViewpoint.
/**
* @return True if type is an allowed target type for a given Viewpoint
*/
private boolean isAllowedTargetTypeInViewpoint(IDiagramModelArchimateComponent diagramComponent, EClass type) {
if (!Preferences.STORE.getBoolean(IPreferenceConstants.VIEWPOINTS_HIDE_MAGIC_CONNECTOR_ELEMENTS)) {
return true;
}
IArchimateDiagramModel dm = (IArchimateDiagramModel) diagramComponent.getDiagramModel();
String id = dm.getViewpoint();
IViewpoint viewpoint = ViewpointManager.INSTANCE.getViewpoint(id);
return viewpoint == null ? true : viewpoint.isAllowedConcept(type);
}
Aggregations