use of org.whole.lang.ui.commands.BackspaceTextCommand in project whole by wholeplatform.
the class TextualDirectEditEditPolicy method getBackspaceCommand.
private Command getBackspaceCommand(TextualRequest request) {
Command command;
ITextualEntityPart textualEntityPart = (ITextualEntityPart) getHost();
if (textualEntityPart.hasSelectionRange()) {
command = createDeleteSelectionCommand(textualEntityPart);
} else {
BackspaceTextCommand backspace = new BackspaceTextCommand();
backspace.setEntity(textualEntityPart.getModelTextEntity());
backspace.setViewer(textualEntityPart.getViewer());
backspace.setLength(1);
command = backspace;
}
return command;
}
use of org.whole.lang.ui.commands.BackspaceTextCommand in project whole by wholeplatform.
the class TextualDirectEditEditPolicy method createDeleteSelectionCommand.
private Command createDeleteSelectionCommand(ITextualEntityPart textualEntityPart) {
Command command;
int start = textualEntityPart.getSelectionStart();
int end = textualEntityPart.getSelectionEnd();
int length = end - start;
int caretPosition = textualEntityPart.getCaretPosition();
if (caretPosition >= end) {
BackspaceTextCommand backspace = new BackspaceTextCommand();
backspace.setEntity(textualEntityPart.getModelTextEntity());
backspace.setViewer(textualEntityPart.getViewer());
backspace.setLength(length);
command = backspace;
} else {
DeleteTextCommand delete = new DeleteTextCommand();
delete.setEntity(textualEntityPart.getModelTextEntity());
delete.setViewer(textualEntityPart.getViewer());
delete.setLength(length);
command = delete;
}
return command;
}
Aggregations