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;
}
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;
}
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;
}
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;
}
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);
}
}
Aggregations