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();
}
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);
}
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);
}
Aggregations