Search in sources :

Example 16 with ITextualEntityPart

use of org.whole.lang.ui.editparts.ITextualEntityPart 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)

Example 17 with ITextualEntityPart

use of org.whole.lang.ui.editparts.ITextualEntityPart 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 18 with ITextualEntityPart

use of org.whole.lang.ui.editparts.ITextualEntityPart in project whole by wholeplatform.

the class TextualDirectEditEditPolicy method getDeleteCommand.

private Command getDeleteCommand(TextualRequest request) {
    Command command;
    ITextualEntityPart textualEntityPart = (ITextualEntityPart) getHost();
    if (textualEntityPart.hasSelectionRange()) {
        command = createDeleteSelectionCommand(textualEntityPart);
    } else {
        DeleteTextCommand delete = new DeleteTextCommand();
        delete.setEntity(textualEntityPart.getModelTextEntity());
        delete.setViewer(textualEntityPart.getViewer());
        delete.setLength(1);
        command = delete;
    }
    return command;
}
Also used : DeleteTextCommand(org.whole.lang.ui.commands.DeleteTextCommand) 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)

Example 19 with ITextualEntityPart

use of org.whole.lang.ui.editparts.ITextualEntityPart in project whole by wholeplatform.

the class TextualHilightEditPolicy method moveCaretHorizontally.

public boolean moveCaretHorizontally(int positions) {
    ITextualEntityPart textualHost = getTextualHost();
    if (!textualHost.hasFocus())
        return false;
    int newPosition = textualHost.getCaretPosition() + positions;
    if (newPosition < 0 || newPosition > textualHost.getCaretPositions())
        return false;
    CaretUpdater.sheduleSyncUpdate(textualHost.getViewer(), textualHost.getModelEntity(), newPosition, true);
    return true;
}
Also used : ITextualEntityPart(org.whole.lang.ui.editparts.ITextualEntityPart) Point(org.eclipse.draw2d.geometry.Point)

Example 20 with ITextualEntityPart

use of org.whole.lang.ui.editparts.ITextualEntityPart in project whole by wholeplatform.

the class TextualHilightEditPolicy method showCaret.

private void showCaret() {
    if (isTextToolActive()) {
        IBindingManager bm = getCurrentViewer().getContextBindings();
        IEntity focusEntity = bm.wGet("focusEntity");
        ITextualEntityPart textualHost = getTextualHost();
        if (focusEntity != null && textualHost.getModelEntity() != focusEntity && !Matcher.match(CommonsEntityDescriptorEnum.RootFragment, focusEntity)) {
            // FIXME workaround for focusEntity == RootFragment after a focus lost
            IGraphicalEntityPart focusPart = (IGraphicalEntityPart) ModelObserver.getObserver(focusEntity, getCurrentViewer().getEditPartRegistry());
            if (focusPart != null) {
                int position = FigureUtils.getPositionOf(textualHost.getFigure(), focusPart.getFigure());
                textualHost.setCaretPosition(position == PositionConstants.EAST ? 0 : textualHost.getCaretPositions());
            }
        }
        textualHost.setCaretVisible(true);
    }
}
Also used : ITextualEntityPart(org.whole.lang.ui.editparts.ITextualEntityPart) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) IGraphicalEntityPart(org.whole.lang.ui.editparts.IGraphicalEntityPart) Point(org.eclipse.draw2d.geometry.Point)

Aggregations

ITextualEntityPart (org.whole.lang.ui.editparts.ITextualEntityPart)29 Point (org.eclipse.draw2d.geometry.Point)8 IEntity (org.whole.lang.model.IEntity)8 Command (org.eclipse.gef.commands.Command)6 ITextCommand (org.whole.lang.ui.commands.ITextCommand)5 TextTransactionCommand (org.whole.lang.ui.commands.TextTransactionCommand)5 IEntityPart (org.whole.lang.ui.editparts.IEntityPart)5 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)5 EditPart (org.eclipse.gef.EditPart)4 BackspaceTextCommand (org.whole.lang.ui.commands.BackspaceTextCommand)4 DeleteTextCommand (org.whole.lang.ui.commands.DeleteTextCommand)4 InsertTextCommand (org.whole.lang.ui.commands.InsertTextCommand)4 OverwriteTextCommand (org.whole.lang.ui.commands.OverwriteTextCommand)4 Rectangle (org.eclipse.draw2d.geometry.Rectangle)3 IGEFEditorKit (org.whole.lang.ui.editor.IGEFEditorKit)3 ITextualFigure (org.whole.lang.ui.figures.ITextualFigure)3 IKeyHandler (org.whole.lang.ui.keys.IKeyHandler)3 EditPoint (org.whole.lang.ui.tools.EditPoint)3 CanExecute (org.eclipse.e4.core.di.annotations.CanExecute)2 Execute (org.eclipse.e4.core.di.annotations.Execute)2