Search in sources :

Example 1 with LockObjectCommand

use of com.archimatetool.editor.diagram.commands.LockObjectCommand in project archi by archimatetool.

the class LockObjectAction method createLockCommand.

private Command createLockCommand(List<?> objects) {
    CompoundCommand command = new CompoundCommand();
    boolean lock = isToLock();
    for (Object object : objects) {
        if (object instanceof EditPart) {
            EditPart part = (EditPart) object;
            if (part.getModel() instanceof ILockable) {
                ILockable model = (ILockable) part.getModel();
                if (model.isLocked() != lock) {
                    Command cmd = new LockObjectCommand(model, lock);
                    command.add(cmd);
                }
            }
        }
    }
    return command.unwrap();
}
Also used : Command(org.eclipse.gef.commands.Command) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) LockObjectCommand(com.archimatetool.editor.diagram.commands.LockObjectCommand) LockObjectCommand(com.archimatetool.editor.diagram.commands.LockObjectCommand) EditPart(org.eclipse.gef.EditPart) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) ILockable(com.archimatetool.model.ILockable)

Example 2 with LockObjectCommand

use of com.archimatetool.editor.diagram.commands.LockObjectCommand in project archi by archimatetool.

the class LockedSection method createControls.

@Override
protected void createControls(Composite parent) {
    createLabel(parent, Messages.LockedSection_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
    fButtonLocked = new Button(parent, SWT.CHECK);
    fButtonLocked.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CompoundCommand result = new CompoundCommand();
            for (EObject lockable : getEObjects()) {
                if (isAlive(lockable)) {
                    Command cmd = new LockObjectCommand((ILockable) lockable, fButtonLocked.getSelection());
                    if (cmd.canExecute()) {
                        result.add(cmd);
                    }
                }
            }
            executeCommand(result.unwrap());
        }
    });
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
}
Also used : Button(org.eclipse.swt.widgets.Button) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) LockObjectCommand(com.archimatetool.editor.diagram.commands.LockObjectCommand) Command(org.eclipse.gef.commands.Command) LockObjectCommand(com.archimatetool.editor.diagram.commands.LockObjectCommand) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) EObject(org.eclipse.emf.ecore.EObject) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) ILockable(com.archimatetool.model.ILockable)

Aggregations

LockObjectCommand (com.archimatetool.editor.diagram.commands.LockObjectCommand)2 ILockable (com.archimatetool.model.ILockable)2 Command (org.eclipse.gef.commands.Command)2 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)2 EObject (org.eclipse.emf.ecore.EObject)1 EditPart (org.eclipse.gef.EditPart)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Button (org.eclipse.swt.widgets.Button)1