use of org.eclipse.gef.commands.CommandStack in project archi by archimatetool.
the class CSVImporterTests method runOnceBeforeEachTest.
@Before
public void runOnceBeforeEachTest() {
model = IArchimateFactory.eINSTANCE.createArchimateModel();
model.setDefaults();
model.setAdapter(CommandStack.class, new CommandStack());
importer = new CSVImporter(model);
}
use of org.eclipse.gef.commands.CommandStack in project archi by archimatetool.
the class EditorModelManagerTests method isModelDirty_Model.
@Test
public void isModelDirty_Model() {
IArchimateModel model = editorModelManager.createNewModel();
assertFalse(editorModelManager.isModelDirty(model));
// Execute simple command on Command Stack
Command cmd = new EObjectFeatureCommand("", model, IArchimatePackage.Literals.NAMEABLE__NAME, "Hello");
CommandStack stack = (CommandStack) model.getAdapter(CommandStack.class);
stack.execute(cmd);
assertTrue(editorModelManager.isModelDirty(model));
// Flush the Command Stack so we can close the model without a dialog asking us to save
stack.flush();
}
use of org.eclipse.gef.commands.CommandStack in project archi by archimatetool.
the class EditorModelManagerTests method openModel_Model.
@Test
public void openModel_Model() {
IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
model.setDefaults();
model.setName("Test");
editorModelManager.openModel(model);
// Has a Command Stack
assertTrue(model.getAdapter(CommandStack.class) instanceof CommandStack);
// Has an Archive Manager
assertTrue(model.getAdapter(IArchiveManager.class) instanceof IArchiveManager);
// Is registered
assertEquals(1, editorModelManager.getModels().size());
assertTrue(editorModelManager.getModels().contains(model));
// Is not registered twice
editorModelManager.openModel(model);
assertEquals(1, editorModelManager.getModels().size());
}
use of org.eclipse.gef.commands.CommandStack 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);
}
use of org.eclipse.gef.commands.CommandStack in project archi by archimatetool.
the class EditorModelManagerTests method loadModel_File.
@Test
public void loadModel_File() {
File file = TestData.TEST_MODEL_FILE_ARCHISURANCE;
IArchimateModel model = editorModelManager.loadModel(file);
assertNotNull(model);
// File
assertEquals(file, model.getFile());
// Has a Command Stack
assertTrue(model.getAdapter(CommandStack.class) instanceof CommandStack);
// Has an Archive Manager
assertTrue(model.getAdapter(IArchiveManager.class) instanceof IArchiveManager);
// Is registered
assertEquals(1, editorModelManager.getModels().size());
assertTrue(editorModelManager.getModels().contains(model));
// Do it again, should be the same
IArchimateModel model2 = editorModelManager.loadModel(file);
assertEquals(model2, model);
// Is not registered twice
editorModelManager.openModel(model);
assertEquals(1, editorModelManager.getModels().size());
}
Aggregations