Search in sources :

Example 6 with ILockable

use of com.archimatetool.model.ILockable in project archi by archimatetool.

the class SendBackwardAction method createCommand.

private Command createCommand(List<?> selection) {
    GraphicalViewer viewer = getWorkbenchPart().getAdapter(GraphicalViewer.class);
    CompoundCommand result = new CompoundCommand(TEXT);
    for (Object object : selection) {
        if (object instanceof GraphicalEditPart) {
            GraphicalEditPart editPart = (GraphicalEditPart) object;
            Object model = editPart.getModel();
            // This can happen if we do things wrong
            if (viewer != editPart.getViewer()) {
                // $NON-NLS-1$
                System.err.println("Wrong selection for Viewer in " + getClass());
            }
            // Locked
            if (model instanceof ILockable && ((ILockable) model).isLocked()) {
                continue;
            }
            if (model instanceof IDiagramModelObject) {
                IDiagramModelObject diagramObject = (IDiagramModelObject) model;
                IDiagramModelContainer parent = (IDiagramModelContainer) diagramObject.eContainer();
                /*
                     * Parent can be null when objects are selected (with marquee tool) and transferred from one container
                     * to another and the Diagram Editor updates the enablement state of Actions.
                     */
                if (parent == null) {
                    continue;
                }
                int originalPos = parent.getChildren().indexOf(diagramObject);
                if (originalPos > 0) {
                    result.add(new SendBackwardCommand(parent, originalPos));
                }
            }
        }
    }
    return result.unwrap();
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IDiagramModelContainer(com.archimatetool.model.IDiagramModelContainer) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) ILockable(com.archimatetool.model.ILockable)

Example 7 with ILockable

use of com.archimatetool.model.ILockable in project archi by archimatetool.

the class PartComponentEditPolicy method createDeleteCommand.

@Override
protected Command createDeleteCommand(GroupRequest request) {
    IDiagramModelObject object = (IDiagramModelObject) getHost().getModel();
    boolean isLocked = object instanceof ILockable && ((ILockable) object).isLocked();
    return isLocked ? null : DiagramCommandFactory.createDeleteDiagramObjectCommand(object);
}
Also used : IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) ILockable(com.archimatetool.model.ILockable)

Example 8 with ILockable

use of com.archimatetool.model.ILockable 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

ILockable (com.archimatetool.model.ILockable)8 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)6 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)6 Command (org.eclipse.gef.commands.Command)4 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)3 LockObjectCommand (com.archimatetool.editor.diagram.commands.LockObjectCommand)2 SetConstraintObjectCommand (com.archimatetool.editor.diagram.commands.SetConstraintObjectCommand)2 IBounds (com.archimatetool.model.IBounds)2 IDiagramModelContainer (com.archimatetool.model.IDiagramModelContainer)2 Dimension (org.eclipse.draw2d.geometry.Dimension)2 EditPart (org.eclipse.gef.EditPart)2 GraphicalViewer (org.eclipse.gef.GraphicalViewer)2 DiagramImageEditPart (com.archimatetool.editor.diagram.editparts.diagram.DiagramImageEditPart)1 IDiagramModelObjectFigure (com.archimatetool.editor.diagram.figures.IDiagramModelObjectFigure)1 DiagramImageFigure (com.archimatetool.editor.diagram.figures.diagram.DiagramImageFigure)1 IDiagramModelComponent (com.archimatetool.model.IDiagramModelComponent)1 ArrayList (java.util.ArrayList)1 IFigure (org.eclipse.draw2d.IFigure)1 EObject (org.eclipse.emf.ecore.EObject)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1