Search in sources :

Example 71 with IArchimateModel

use of com.archimatetool.model.IArchimateModel in project archi by archimatetool.

the class MRUMenuManagerTests method testModelPropertChange.

@Test
public void testModelPropertChange() {
    List<File> list = menuManager.getMRUList();
    assertTrue(list.isEmpty());
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    // Open File event - but file does not exist so not on MRU list when opened
    File file = new File("aFile");
    assertFalse(file.exists());
    model.setFile(file);
    IEditorModelManager.INSTANCE.firePropertyChange(this, IEditorModelManager.PROPERTY_MODEL_OPENED, null, model);
    assertTrue(list.isEmpty());
    // Open File event - file does exist so it is added to MRU list
    model.setFile(TestData.TEST_MODEL_FILE_ARCHISURANCE);
    IEditorModelManager.INSTANCE.firePropertyChange(this, IEditorModelManager.PROPERTY_MODEL_OPENED, null, model);
    assertEquals(1, list.size());
    // Save File event - file does exist so it is added to MRU list
    model.setFile(TestSupport.TEST_MODEL_FILE_1);
    IEditorModelManager.INSTANCE.firePropertyChange(this, IEditorModelManager.PROPERTY_MODEL_SAVED, null, model);
    assertEquals(2, list.size());
}
Also used : File(java.io.File) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 72 with IArchimateModel

use of com.archimatetool.model.IArchimateModel in project archi by archimatetool.

the class CommandLineStateTests method getModel_IsSet.

@Test
public void getModel_IsSet() {
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    CommandLineState.setModel(model);
    assertSame(model, CommandLineState.getModel());
    CommandLineState.setModel(null);
    assertNull(CommandLineState.getModel());
}
Also used : IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 73 with IArchimateModel

use of com.archimatetool.model.IArchimateModel in project archi by archimatetool.

the class MRUMenuManager method propertyChange.

/**
 * User opened or saved a model to file.
 * Update list and menu items
 */
@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (IEditorModelManager.PROPERTY_MODEL_OPENED == evt.getPropertyName() || IEditorModelManager.PROPERTY_MODEL_SAVED == evt.getPropertyName()) {
        IArchimateModel model = (IArchimateModel) evt.getNewValue();
        if (model != null && model.getFile() != null && !isTempFile(model.getFile()) && model.getFile().exists()) {
            addToList(model.getFile());
            createMenuItems();
        }
    }
}
Also used : IArchimateModel(com.archimatetool.model.IArchimateModel)

Example 74 with IArchimateModel

use of com.archimatetool.model.IArchimateModel in project archi by archimatetool.

the class NewArchimateModelAction method run.

@Override
public void run() {
    // Create new Model
    IArchimateModel model = IEditorModelManager.INSTANCE.createNewModel();
    // Open Diagram Editor
    EditorManager.openDiagramEditor(model.getDefaultDiagramModel());
    // Edit in-place in Tree
    UIRequestManager.INSTANCE.fireRequest(new TreeEditElementRequest(this, model));
}
Also used : TreeEditElementRequest(com.archimatetool.editor.views.tree.TreeEditElementRequest) IArchimateModel(com.archimatetool.model.IArchimateModel)

Example 75 with IArchimateModel

use of com.archimatetool.model.IArchimateModel in project archi by archimatetool.

the class OpenModelAction method run.

@Override
public void run() {
    FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN);
    // $NON-NLS-1$ //$NON-NLS-2$
    dialog.setFilterExtensions(new String[] { IEditorModelManager.ARCHIMATE_FILE_WILDCARD, "*.xml", "*.*" });
    String path = dialog.open();
    if (path != null) {
        // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=527306
        if (PlatformUtils.isMac()) {
            while (Display.getCurrent().readAndDispatch()) ;
        }
        final File file = new File(path);
        // Check it's not already open
        IArchimateModel model = getModel(file);
        if (model != null) {
            MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Messages.OpenModelAction_2, NLS.bind(Messages.OpenModelAction_3, file.getName(), model.getName()));
            return;
        }
        BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

            public void run() {
                IEditorModelManager.INSTANCE.openModel(file);
            }
        });
    }
}
Also used : FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) IArchimateModel(com.archimatetool.model.IArchimateModel)

Aggregations

IArchimateModel (com.archimatetool.model.IArchimateModel)124 Test (org.junit.Test)51 File (java.io.File)35 IOException (java.io.IOException)22 IArchimateElement (com.archimatetool.model.IArchimateElement)14 EObject (org.eclipse.emf.ecore.EObject)14 IArchiveManager (com.archimatetool.editor.model.IArchiveManager)13 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)13 IDiagramModel (com.archimatetool.model.IDiagramModel)12 CommandStack (org.eclipse.gef.commands.CommandStack)11 IFolder (com.archimatetool.model.IFolder)10 ArrayList (java.util.ArrayList)10 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)9 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)9 IArchimateModelObject (com.archimatetool.model.IArchimateModelObject)7 IArchimateDiagramModel (com.archimatetool.model.IArchimateDiagramModel)6 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)6 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)5 IIdentifier (com.archimatetool.model.IIdentifier)5 GraficoModelLoader (org.archicontribs.modelrepository.grafico.GraficoModelLoader)5