setHoverActive(false);
if ((e.stateMask & SWT.ALT) != 0) {
return false;
}
Command command = null;
KeyboardData keyCode = null;
switch (e.keyCode) {
case SWT.F2:
command = new SwitchSelectionCommand((IHTMLGraphicalViewer) this
.getCurrentViewer());
break;
case SWT.ARROW_UP:
command = new VerticalMoveCommand((IHTMLGraphicalViewer) this
.getCurrentViewer(), true, (e.stateMask & SWT.SHIFT) != 0);
break;
case SWT.ARROW_DOWN:
command = new VerticalMoveCommand((IHTMLGraphicalViewer) this
.getCurrentViewer(), false, (e.stateMask & SWT.SHIFT) != 0);
break;
case SWT.ARROW_LEFT:
command = new HorizontalMoveCommand((IHTMLGraphicalViewer) this
.getCurrentViewer(), false, (e.stateMask & SWT.SHIFT) != 0);
break;
case SWT.ARROW_RIGHT:
command = new HorizontalMoveCommand((IHTMLGraphicalViewer) this
.getCurrentViewer(), true, (e.stateMask & SWT.SHIFT) != 0);
break;
case SWT.DEL:
if ((e.stateMask & SWT.SHIFT) == 0) {
if (getCurrentViewer().getSelection() != null) {
ISelection selection = getCurrentViewer().getSelection();
if (selection instanceof StructuredSelection) {
Object object = ((StructuredSelection) selection)
.getFirstElement();
if (!(object instanceof DocumentEditPart)) {
// "delete node"
command = new DeleteNodeCommand(
(IHTMLGraphicalViewer) getCurrentViewer());
}
}
}
if (command == null) {
// "delete"
command = new DeleteCommand(true,
(IHTMLGraphicalViewer) this.getCurrentViewer());
}
} else {
// "cut"
command = new CutCommand((IHTMLGraphicalViewer) this
.getCurrentViewer());
e.doit = false;
}
break;
case SWT.BS:
// "delete"
command = new DeleteCommand(false, (IHTMLGraphicalViewer) this
.getCurrentViewer());
e.doit = false;
break;
case SWT.INSERT:
if ((e.stateMask & SWT.SHIFT) != 0) {
// "paste"
command = new PasteCommand((IHTMLGraphicalViewer) this
.getCurrentViewer());
e.doit = false;
break;
} else if ((e.stateMask & SWT.CONTROL) != 0) {
// "copy"
command = new CopyCommand((IHTMLGraphicalViewer) this
.getCurrentViewer());
e.doit = false;
break;
}
break;
case SWT.LF:
case SWT.CR:
// "insert"
keyCode = new KeyboardData(e.character, e.stateMask,
(IHTMLGraphicalViewer) getCurrentViewer());
command = new InsertCommand(
PageDesignerResources.getInstance().getString(
"RangeSelectionTool.CommandLabel.Insert"), (IHTMLGraphicalViewer) this.getCurrentViewer(), keyCode); //$NON-NLS-1$
e.doit = false;
break;
default:
if (e.keyCode == 'a' && (e.stateMask & SWT.CTRL) != 0) {
command = new SelectAllCommand("selectAll", //$NON-NLS-1$
(IHTMLGraphicalViewer) this.getCurrentViewer());
e.doit = false;
} else {
if (getCurrentViewer() instanceof IHTMLGraphicalViewer
&& ((IHTMLGraphicalViewer) getCurrentViewer())
.isInRangeMode()
&& (!Character.isIdentifierIgnorable(e.character) && !Character
.isISOControl(e.character))
|| (e.character == '\r')) {
keyCode = new KeyboardData(e.character, e.stateMask,
(IHTMLGraphicalViewer) getCurrentViewer());
// "insert"
command = new InsertCommand(
PageDesignerResources.getInstance().getString(
"RangeSelectionTool.CommandLabel.Insert"), (IHTMLGraphicalViewer) this.getCurrentViewer(), keyCode); //$NON-NLS-1$
e.doit = false;
break;
}
return super.handleKeyDown(e);
}
}
if (command != null) {
command.execute();
e.doit = false;
if (command instanceof ICaretPositionMover) {
if (getCurrentViewer() instanceof IHTMLGraphicalViewer) {
((IHTMLGraphicalViewer) getCurrentViewer())
.updateHorizontalPos();