use of org.eclipse.gef.commands.CommandStack in project archi by archimatetool.
the class GenerateViewAction method run.
@Override
public void run() {
List<IArchimateElement> selected = getValidSelectedObjects(getSelection());
if (!selected.isEmpty()) {
GenerateViewCommand command = new GenerateViewCommand(selected);
if (command.openDialog(Display.getCurrent().getActiveShell())) {
CommandStack commandStack = (CommandStack) ((IAdapter) selected.get(0)).getAdapter(CommandStack.class);
commandStack.execute(command);
}
}
}
use of org.eclipse.gef.commands.CommandStack in project archi by archimatetool.
the class DuplicateCommandHandler method duplicate.
/**
* Perform the duplicate command
*/
public void duplicate() {
// 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 asyncronously
UIRequestManager.INSTANCE.fireRequestAsync(new TreeSelectionRequest(this, new StructuredSelection(fNewObjects), true));
dispose();
}
use of org.eclipse.gef.commands.CommandStack in project archi by archimatetool.
the class DuplicateCommandHandler method getCompoundCommand.
/**
* Get, and if need be create, a CompoundCommand to which to add the object to be duplicated command
*/
private CompoundCommand getCompoundCommand(IAdapter object) {
// Get the Command Stack registered to the object
CommandStack stack = (CommandStack) object.getAdapter(CommandStack.class);
if (stack == null) {
// $NON-NLS-1$
System.err.println("CommandStack was null in " + getClass());
return null;
}
// Now get or create a Compound Command
CompoundCommand compoundCommand = fCommandMap.get(stack);
if (compoundCommand == null) {
compoundCommand = new NonNotifyingCompoundCommand(Messages.DuplicateCommandHandler_1);
fCommandMap.put(stack, compoundCommand);
}
return compoundCommand;
}
use of org.eclipse.gef.commands.CommandStack in project archi by archimatetool.
the class SortFolderAction method run.
@Override
public void run() {
Object selected = getSelection().getFirstElement();
if (selected instanceof IFolder) {
IFolder folder = (IFolder) selected;
Command cmd = new SortFolderCommand(folder);
CommandStack commandStack = (CommandStack) folder.getAdapter(CommandStack.class);
commandStack.execute(cmd);
}
}
use of org.eclipse.gef.commands.CommandStack in project archi by archimatetool.
the class TreeModelViewActionFactory method createNewSketchAction.
private IAction createNewSketchAction(final IFolder folder) {
IAction action = new Action(Messages.TreeModelViewActionFactory_2) {
@Override
public void run() {
// Create a new Diagram Model, set its name
ISketchModel sketchModel = IArchimateFactory.eINSTANCE.createSketchModel();
sketchModel.setName(Messages.TreeModelViewActionFactory_3);
// Defaults
int defaultBackground = ArchiPlugin.PREFERENCES.getInt(IPreferenceConstants.SKETCH_DEFAULT_BACKGROUND);
sketchModel.setBackground(defaultBackground);
// Execute Command
Command cmd = new NewDiagramCommand(folder, sketchModel, Messages.TreeModelViewActionFactory_3);
CommandStack commandStack = (CommandStack) folder.getAdapter(CommandStack.class);
commandStack.execute(cmd);
}
};
action.setImageDescriptor(IArchiImages.ImageFactory.getImageDescriptor(IArchiImages.ICON_SKETCH));
return action;
}
Aggregations