use of com.archimatetool.model.IArchimateModel in project archi-modelrepository-plugin by archi-contribs.
the class AbortChangesHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IArchimateModel model = getActiveArchimateModel();
if (model != null) {
AbortChangesAction action = new AbortChangesAction(HandlerUtil.getActiveWorkbenchWindowChecked(event), model);
action.run();
}
return null;
}
use of com.archimatetool.model.IArchimateModel in project archi-modelrepository-plugin by archi-contribs.
the class DeleteModelAction method run.
@Override
public void run() {
boolean confirm = MessageDialog.openConfirm(fWindow.getShell(), Messages.DeleteModelAction_0, Messages.DeleteModelAction_2);
if (!confirm) {
return;
}
try {
// See if the model is open and close it if it is
IArchimateModel model = getRepository().locateModel();
if (model != null) {
boolean didClose = IEditorModelManager.INSTANCE.closeModel(model);
if (!didClose) {
return;
}
}
// Delete folder
FileUtils.deleteFolder(getRepository().getLocalRepositoryFolder());
// Notify
RepositoryListenerManager.INSTANCE.fireRepositoryChangedEvent(IRepositoryListener.REPOSITORY_DELETED, getRepository());
} catch (IOException ex) {
displayErrorDialog(Messages.DeleteModelAction_0, ex);
}
}
use of com.archimatetool.model.IArchimateModel in project archi-modelrepository-plugin by archi-contribs.
the class DeleteModelHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IArchimateModel model = getActiveArchimateModel();
if (model != null) {
DeleteModelAction action = new DeleteModelAction(HandlerUtil.getActiveWorkbenchWindowChecked(event), model);
action.run();
}
return null;
}
use of com.archimatetool.model.IArchimateModel in project archi-modelrepository-plugin by archi-contribs.
the class ExtractModelFromCommitAction method run.
@Override
public void run() {
File tempOutputFolder = getTempFolder();
deleteFolder(tempOutputFolder);
// Wlak the tree and get the contents of the commit
try (Repository repository = Git.open(getRepository().getLocalRepositoryFolder()).getRepository()) {
try (TreeWalk treeWalk = new TreeWalk(repository)) {
treeWalk.addTree(fCommit.getTree());
treeWalk.setRecursive(true);
while (treeWalk.next()) {
ObjectId objectId = treeWalk.getObjectId(0);
ObjectLoader loader = repository.open(objectId);
File file = new File(tempOutputFolder, treeWalk.getPathString());
file.getParentFile().mkdirs();
try (FileOutputStream out = new FileOutputStream(file)) {
loader.copyTo(out);
}
}
}
} catch (IOException ex) {
displayErrorDialog(Messages.ExtractModelFromCommitAction_1, ex);
}
// Open the model with no file name
try {
GraficoModelImporter importer = new GraficoModelImporter(tempOutputFolder);
IArchimateModel graficoModel = importer.importAsModel();
if (graficoModel != null) {
// Open it, this will do the necessary checks and add a command stack and an archive manager
IEditorModelManager.INSTANCE.openModel(graficoModel);
// Set model name
// $NON-NLS-1$ //$NON-NLS-2$
graficoModel.setName(graficoModel.getName() + " (" + fCommit.getName().substring(0, 8) + ")");
} else {
MessageDialog.openError(fWindow.getShell(), Messages.ExtractModelFromCommitAction_1, Messages.ExtractModelFromCommitAction_2);
}
} catch (IOException ex) {
displayErrorDialog(Messages.ExtractModelFromCommitAction_1, ex);
}
// Clean up
deleteFolder(tempOutputFolder);
}
use of com.archimatetool.model.IArchimateModel in project archi-modelrepository-plugin by archi-contribs.
the class LoadModelFromRepositoryProvider method loadModel.
private IArchimateModel loadModel(File folder) throws IOException {
GraficoModelImporter importer = new GraficoModelImporter(folder);
IArchimateModel model = importer.importAsModel();
if (importer.getUnresolvedObjects() != null) {
throw new IOException(Messages.LoadModelFromRepositoryProvider_8);
}
// Add an Archive Manager and load images
IArchiveManager archiveManager = IArchiveManager.FACTORY.createArchiveManager(model);
model.setAdapter(IArchiveManager.class, archiveManager);
archiveManager.loadImages();
CommandLineState.setModel(model);
return model;
}
Aggregations