Search in sources :

Example 1 with BackspaceTextCommand

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;
}
Also used : ITextualEntityPart(org.whole.lang.ui.editparts.ITextualEntityPart) DeleteTextCommand(org.whole.lang.ui.commands.DeleteTextCommand) BackspaceTextCommand(org.whole.lang.ui.commands.BackspaceTextCommand) ITextCommand(org.whole.lang.ui.commands.ITextCommand) InsertTextCommand(org.whole.lang.ui.commands.InsertTextCommand) TextTransactionCommand(org.whole.lang.ui.commands.TextTransactionCommand) OverwriteTextCommand(org.whole.lang.ui.commands.OverwriteTextCommand) Command(org.eclipse.gef.commands.Command) BackspaceTextCommand(org.whole.lang.ui.commands.BackspaceTextCommand)

Example 2 with BackspaceTextCommand

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;
}
Also used : DeleteTextCommand(org.whole.lang.ui.commands.DeleteTextCommand) DeleteTextCommand(org.whole.lang.ui.commands.DeleteTextCommand) BackspaceTextCommand(org.whole.lang.ui.commands.BackspaceTextCommand) ITextCommand(org.whole.lang.ui.commands.ITextCommand) InsertTextCommand(org.whole.lang.ui.commands.InsertTextCommand) TextTransactionCommand(org.whole.lang.ui.commands.TextTransactionCommand) OverwriteTextCommand(org.whole.lang.ui.commands.OverwriteTextCommand) Command(org.eclipse.gef.commands.Command) BackspaceTextCommand(org.whole.lang.ui.commands.BackspaceTextCommand)

Aggregations

Command (org.eclipse.gef.commands.Command)2 BackspaceTextCommand (org.whole.lang.ui.commands.BackspaceTextCommand)2 DeleteTextCommand (org.whole.lang.ui.commands.DeleteTextCommand)2 ITextCommand (org.whole.lang.ui.commands.ITextCommand)2 InsertTextCommand (org.whole.lang.ui.commands.InsertTextCommand)2 OverwriteTextCommand (org.whole.lang.ui.commands.OverwriteTextCommand)2 TextTransactionCommand (org.whole.lang.ui.commands.TextTransactionCommand)2 ITextualEntityPart (org.whole.lang.ui.editparts.ITextualEntityPart)1