Search in sources :

Example 46 with CommandStack

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);
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) Before(org.junit.Before)

Example 47 with CommandStack

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();
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) Command(org.eclipse.gef.commands.Command) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 48 with CommandStack

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());
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) IArchiveManager(com.archimatetool.editor.model.IArchiveManager) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 49 with CommandStack

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);
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) IArchiveManager(com.archimatetool.editor.model.IArchiveManager) IArchimateModel(com.archimatetool.model.IArchimateModel) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) Test(org.junit.Test)

Example 50 with CommandStack

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());
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) IArchiveManager(com.archimatetool.editor.model.IArchiveManager) File(java.io.File) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Aggregations

CommandStack (org.eclipse.gef.commands.CommandStack)105 Command (org.eclipse.gef.commands.Command)32 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)14 IArchiveManager (com.archimatetool.editor.model.IArchiveManager)13 AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)13 IArchimateModel (com.archimatetool.model.IArchimateModel)12 ModelTransactionCommand (org.whole.lang.ui.commands.ModelTransactionCommand)12 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)12 NonNotifyingCompoundCommand (com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand)10 EditPart (org.eclipse.gef.EditPart)10 INode (org.talend.core.model.process.INode)10 Node (org.talend.designer.core.ui.editor.nodes.Node)9 IEntity (org.whole.lang.model.IEntity)9 ArrayList (java.util.ArrayList)8 Test (org.junit.Test)8 PersistenceException (org.talend.commons.exception.PersistenceException)8 EObjectFeatureCommand (com.archimatetool.editor.model.commands.EObjectFeatureCommand)7 IFolder (com.archimatetool.model.IFolder)6 IOException (java.io.IOException)6 IEditorPart (org.eclipse.ui.IEditorPart)6