use of org.whole.lang.ui.editparts.ITextualEntityPart in project whole by wholeplatform.
the class CutHandler method execute.
@Override
@Execute
public void execute(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) IBindingManager bm) {
if (bm.wIsSet("viewer") && ClipboardUtils.hasTextSeletion((IEntityPartViewer) bm.wGetValue("viewer"))) {
HandlersBehavior.copy(bm);
IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
IEntity focusEntity = bm.wGet("focusEntity");
ITextualEntityPart focusPart = (ITextualEntityPart) viewer.getEditPartRegistry().get(focusEntity);
Command command = focusPart.getCommand(TextualRequest.createDeleteRequest());
command.setLabel(getLabel(bm) + " text");
CommandStack commandStack = viewer.getEditDomain().getCommandStack();
commandStack.execute(command);
return;
}
super.execute(bm);
}
use of org.whole.lang.ui.editparts.ITextualEntityPart in project whole by wholeplatform.
the class AbstractModelTextAction method calculateEnabled.
protected boolean calculateEnabled(IBindingManager bm) {
IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
if (!Tools.TEXTUAL.isActive(viewer) || !(ModelObserver.getObserver(bm.wGet("focusEntity"), viewer.getEditPartRegistry()) instanceof ITextualEntityPart))
return false;
IEclipseContext context = (IEclipseContext) bm.wGetValue("eclipse#eclipseContext");
ISynchronizableRunnable runnable = new FunctionRunnable(context, bm, getText(), getEnablementUri());
IEntity result = runnable.syncExec(3000).getResult();
return result != null && result.wBooleanValue();
}
use of org.whole.lang.ui.editparts.ITextualEntityPart in project whole by wholeplatform.
the class ClipboardUtils method hasTextSeletion.
public static boolean hasTextSeletion(EditPartViewer viewer, ISelection selection) {
List<EditPart> selectedParts = getSelectedEditParts(selection);
if (selectedParts.size() != 1)
return false;
EditPart selectedPart = selectedParts.get(0);
return Tools.TEXTUAL.isActive(viewer) && selectedPart instanceof ITextualEntityPart && ((ITextualEntityPart) selectedPart).hasSelectionRange();
}
use of org.whole.lang.ui.editparts.ITextualEntityPart in project whole by wholeplatform.
the class CaretUpdater method record.
public static CaretUpdater record(EditPartViewer viewer) {
ITextualEntityPart focusPart = getFocusedTextualPart(viewer);
if (focusPart == null)
return NULL_UPDATER;
int start, end;
if (focusPart.hasSelectionRange()) {
start = focusPart.getSelectionStart();
end = focusPart.getSelectionEnd();
} else
start = end = focusPart.getCaretPosition();
return createCU(viewer, focusPart.getModelEntity(), start, end);
}
use of org.whole.lang.ui.editparts.ITextualEntityPart in project whole by wholeplatform.
the class CaretUpdater method updateCaret.
@SuppressWarnings("unchecked")
private static void updateCaret(final EditPart entityPart, EditPartViewer viewer, int start, int end, Point location, boolean deselectAll) {
if (entityPart instanceof ITextualEntityPart) {
List<EditPart> selectedParts = viewer.getSelectedEditParts();
if (deselectAll && !selectedParts.isEmpty())
viewer.deselectAll();
viewer.setFocus(entityPart);
ITextualEntityPart caretPart = ((ITextualEntityPart) entityPart);
if (start != -1 && end != -1) {
caretPart.setCaretPosition(end);
if (start != end) {
caretPart.setSelectionRange(start, end);
viewer.appendSelection(caretPart);
}
} else if (location != null)
caretPart.updateCaret(location);
}
}
Aggregations