Search in sources :

Example 1 with TreeEditElementRequest

use of com.archimatetool.editor.views.tree.TreeEditElementRequest in project archi by archimatetool.

the class NewElementCommand method execute.

@Override
public void execute() {
    redo();
    // Edit in-place
    UIRequestManager.INSTANCE.fireRequest(new TreeEditElementRequest(this, fElement));
}
Also used : TreeEditElementRequest(com.archimatetool.editor.views.tree.TreeEditElementRequest)

Example 2 with TreeEditElementRequest

use of com.archimatetool.editor.views.tree.TreeEditElementRequest in project archi by archimatetool.

the class NewArchimateModelFromTemplateWizard method performFinish.

@Override
public boolean performFinish() {
    // Get template
    ITemplate template = fMainPage.getSelectedTemplate();
    if (template == null) {
        return false;
    }
    getContainer().getShell().setVisible(false);
    fErrorMessage = null;
    final File zipFile = template.getFile();
    if (zipFile != null && zipFile.exists()) {
        BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

            @Override
            public void run() {
                try {
                    // $NON-NLS-1$
                    File tmp = File.createTempFile("~architemplate", null);
                    tmp.deleteOnExit();
                    File file = ZipUtils.extractZipEntry(zipFile, TemplateManager.ZIP_ENTRY_MODEL, tmp);
                    if (file != null && file.exists()) {
                        IArchimateModel model = IEditorModelManager.INSTANCE.openModel(file);
                        if (model != null) {
                            // New name
                            // $NON-NLS-1$
                            model.setName(Messages.NewArchimateModelFromTemplateWizard_1 + " " + model.getName());
                            // Set latest model version (need to do this in case we immediately save as Template)
                            model.setVersion(ModelVersion.VERSION);
                            // Set file to null
                            model.setFile(null);
                            // New IDs
                            model.setId(model.getIDAdapter().getNewID());
                            for (Iterator<EObject> iter = model.eAllContents(); iter.hasNext(); ) {
                                EObject eObject = iter.next();
                                if (eObject instanceof IIdentifier) {
                                    ((IIdentifier) eObject).setId(model.getIDAdapter().getNewID());
                                }
                            }
                            // Edit in-place in Tree
                            UIRequestManager.INSTANCE.fireRequest(new TreeEditElementRequest(this, model));
                        } else {
                            fErrorMessage = Messages.NewArchimateModelFromTemplateWizard_2;
                        }
                    } else {
                        fErrorMessage = Messages.NewArchimateModelFromTemplateWizard_2;
                    }
                    tmp.delete();
                } catch (IOException ex) {
                    ex.printStackTrace();
                    fErrorMessage = ex.getMessage();
                }
            }
        });
    }
    if (fErrorMessage != null) {
        MessageDialog.openError(getShell(), Messages.NewArchimateModelFromTemplateWizard_3, fErrorMessage);
        getContainer().getShell().setVisible(true);
    }
    return fErrorMessage == null;
}
Also used : IIdentifier(com.archimatetool.model.IIdentifier) EObject(org.eclipse.emf.ecore.EObject) Iterator(java.util.Iterator) TreeEditElementRequest(com.archimatetool.editor.views.tree.TreeEditElementRequest) ITemplate(com.archimatetool.templates.model.ITemplate) IOException(java.io.IOException) File(java.io.File) IArchimateModel(com.archimatetool.model.IArchimateModel)

Example 3 with TreeEditElementRequest

use of com.archimatetool.editor.views.tree.TreeEditElementRequest 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 4 with TreeEditElementRequest

use of com.archimatetool.editor.views.tree.TreeEditElementRequest in project archi by archimatetool.

the class NewDiagramCommand method execute.

@Override
public void execute() {
    redo();
    // Edit in-place
    UIRequestManager.INSTANCE.fireRequest(new TreeEditElementRequest(this, fDiagramModel));
}
Also used : TreeEditElementRequest(com.archimatetool.editor.views.tree.TreeEditElementRequest)

Example 5 with TreeEditElementRequest

use of com.archimatetool.editor.views.tree.TreeEditElementRequest in project archi by archimatetool.

the class NewFolderCommand method execute.

@Override
public void execute() {
    redo();
    // Edit in-place
    UIRequestManager.INSTANCE.fireRequest(new TreeEditElementRequest(this, fFolder));
}
Also used : TreeEditElementRequest(com.archimatetool.editor.views.tree.TreeEditElementRequest)

Aggregations

TreeEditElementRequest (com.archimatetool.editor.views.tree.TreeEditElementRequest)5 IArchimateModel (com.archimatetool.model.IArchimateModel)2 IIdentifier (com.archimatetool.model.IIdentifier)1 ITemplate (com.archimatetool.templates.model.ITemplate)1 File (java.io.File)1 IOException (java.io.IOException)1 Iterator (java.util.Iterator)1 EObject (org.eclipse.emf.ecore.EObject)1