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());
}
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());
}
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();
}
}
}
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));
}
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);
}
});
}
}
Aggregations