Search in sources :

Example 1 with InsertTextCommand

use of org.whole.lang.ui.commands.InsertTextCommand in project whole by wholeplatform.

the class TextualDirectEditEditPolicy method createInsertOverSelectionCommand.

private Command createInsertOverSelectionCommand(ITextualEntityPart textualEntityPart, String contentToInsert) {
    IEntity textEntity = textualEntityPart.getModelTextEntity();
    TextTransactionCommand transactionCommand = new TextTransactionCommand();
    transactionCommand.setModel(textEntity);
    transactionCommand.merge((ITextCommand) createDeleteSelectionCommand(textualEntityPart));
    InsertTextCommand insert = new InsertTextCommand();
    insert.setEntity(textEntity);
    insert.setViewer(textualEntityPart.getViewer());
    insert.setData(contentToInsert);
    transactionCommand.merge(insert);
    transactionCommand.setLabel(insert.getLabel());
    return transactionCommand;
}
Also used : InsertTextCommand(org.whole.lang.ui.commands.InsertTextCommand) IEntity(org.whole.lang.model.IEntity) TextTransactionCommand(org.whole.lang.ui.commands.TextTransactionCommand)

Example 2 with InsertTextCommand

use of org.whole.lang.ui.commands.InsertTextCommand in project whole by wholeplatform.

the class TextualDirectEditEditPolicy method getInsertTextCommand.

private Command getInsertTextCommand(TextualRequest request) {
    Command command;
    ITextualEntityPart textualEntityPart = (ITextualEntityPart) getHost();
    String contentToInsert = request.getContent();
    if (textualEntityPart.hasSelectionRange()) {
        command = createInsertOverSelectionCommand(textualEntityPart, contentToInsert);
    } else {
        InsertTextCommand insert = new InsertTextCommand();
        insert.setEntity(textualEntityPart.getModelTextEntity());
        insert.setViewer(textualEntityPart.getViewer());
        insert.setData(contentToInsert);
        command = insert;
    }
    return command;
}
Also used : InsertTextCommand(org.whole.lang.ui.commands.InsertTextCommand) 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)

Aggregations

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