Search in sources :

Example 1 with TreeSelectionRequest

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

the class DuplicateCommandHandler method duplicate.

/**
 * Perform the duplicate command
 */
public void duplicate() {
    // Gather the elements to duplicate
    getElementsToDuplicate();
    // Create the Commands
    createCommands();
    // Execute the Commands on the CommandStack(s) - there could be more than one if more than one model open in the Tree
    for (Entry<CommandStack, CompoundCommand> entry : fCommandMap.entrySet()) {
        entry.getKey().execute(entry.getValue());
    }
    // Select new objects in Tree
    UIRequestManager.INSTANCE.fireRequest(new TreeSelectionRequest(this, new StructuredSelection(fNewObjects), true));
    dispose();
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) TreeSelectionRequest(com.archimatetool.editor.views.tree.TreeSelectionRequest) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) NonNotifyingCompoundCommand(com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand)

Example 2 with TreeSelectionRequest

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

the class NewDiagramCommand method redo.

@Override
public void redo() {
    fFolder.getElements().add(fDiagramModel);
    // Select
    UIRequestManager.INSTANCE.fireRequest(new TreeSelectionRequest(this, new StructuredSelection(fDiagramModel), true));
    // Open Editor
    EditorManager.openDiagramEditor(fDiagramModel);
}
Also used : TreeSelectionRequest(com.archimatetool.editor.views.tree.TreeSelectionRequest) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Example 3 with TreeSelectionRequest

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

the class NewDiagramCommand method undo.

@Override
public void undo() {
    // Close the Editor FIRST!
    EditorManager.closeDiagramEditor(fDiagramModel);
    fFolder.getElements().remove(fDiagramModel);
    // Select the parent node if no node is selected (this happens when the node is deleted)
    TreeSelectionRequest request = new TreeSelectionRequest(this, new StructuredSelection(fFolder), true) {

        @Override
        public boolean shouldSelect(Viewer viewer) {
            return viewer.getSelection().isEmpty();
        }
    };
    UIRequestManager.INSTANCE.fireRequest(request);
}
Also used : TreeSelectionRequest(com.archimatetool.editor.views.tree.TreeSelectionRequest) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Viewer(org.eclipse.jface.viewers.Viewer)

Example 4 with TreeSelectionRequest

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

the class NewElementCommand method undo.

@Override
public void undo() {
    fFolder.getElements().remove(fElement);
    // Select the parent node if no node is selected (this happens when the node is deleted)
    TreeSelectionRequest request = new TreeSelectionRequest(this, new StructuredSelection(fFolder), true) {

        @Override
        public boolean shouldSelect(Viewer viewer) {
            return viewer.getSelection().isEmpty();
        }
    };
    UIRequestManager.INSTANCE.fireRequest(request);
}
Also used : TreeSelectionRequest(com.archimatetool.editor.views.tree.TreeSelectionRequest) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Viewer(org.eclipse.jface.viewers.Viewer)

Example 5 with TreeSelectionRequest

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

the class NewFolderCommand method redo.

@Override
public void redo() {
    fParent.getFolders().add(fFolder);
    // Select
    UIRequestManager.INSTANCE.fireRequest(new TreeSelectionRequest(this, new StructuredSelection(fFolder), true));
}
Also used : TreeSelectionRequest(com.archimatetool.editor.views.tree.TreeSelectionRequest) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Aggregations

TreeSelectionRequest (com.archimatetool.editor.views.tree.TreeSelectionRequest)7 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)7 Viewer (org.eclipse.jface.viewers.Viewer)3 NonNotifyingCompoundCommand (com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand)1 CommandStack (org.eclipse.gef.commands.CommandStack)1 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1