use of org.eclipse.gef.commands.UnexecutableCommand in project cubrid-manager by CUBRID.
the class GefViewerKeyHandler method deleteHANodeByKey.
/**
* delete node by delete key,do not suppurt multi selected.
*
* @param event KeyEvent
* @return if delete node return true,else return false
*/
private boolean deleteHANodeByKey(KeyEvent event) {
if (event.keyCode == SWT.DEL && getViewer().getSelectedEditParts().size() == 1) {
GroupRequest deleteRequest = new GroupRequest(RequestConstants.REQ_DELETE);
GraphicalEditPart editPart = getFocusEditPart();
deleteRequest.setEditParts(editPart);
Command command = editPart.getCommand(deleteRequest);
if (command != null && !(command instanceof UnexecutableCommand)) {
command.execute();
return true;
}
}
return false;
}
use of org.eclipse.gef.commands.UnexecutableCommand in project cubrid-manager by CUBRID.
the class GefViewerKeyHandler method moveHANodesByKey.
/**
* move figures by keyboard.
*
* @param event KeyEvent
* @return if handled the event return true else return false.
*/
private boolean moveHANodesByKey(KeyEvent event) {
List<?> selectedEditParts = getViewer().getSelectedEditParts();
boolean flag = false;
for (Object obj : selectedEditParts) {
if (!(obj instanceof HANodePart)) {
continue;
}
GraphicalEditPart editPart = (GraphicalEditPart) obj;
Command command = null;
if ((event.stateMask & SWT.ALT) == 0 && (event.stateMask & SWT.CTRL) == 0 && (event.stateMask & SWT.SHIFT) == 0 && (event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.ARROW_LEFT || event.keyCode == SWT.ARROW_RIGHT || event.keyCode == SWT.ARROW_UP)) {
HANode node = (HANode) editPart.getModel();
ChangeBoundsRequest request = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
request.setLocation(node.getLocation());
request.setEditParts(editPart);
//get move delta
Point moveDelta = null;
switch(event.keyCode) {
case SWT.ARROW_LEFT:
moveDelta = new Point(-1, 0);
break;
case SWT.ARROW_RIGHT:
moveDelta = new Point(1, 0);
break;
case SWT.ARROW_UP:
moveDelta = new Point(0, -1);
break;
case SWT.ARROW_DOWN:
moveDelta = new Point(0, 1);
break;
default:
return true;
}
request.setMoveDelta(moveDelta);
command = editPart.getCommand(request);
}
if (command != null && !(command instanceof UnexecutableCommand)) {
command.execute();
flag = true;
}
}
return flag;
}
Aggregations