use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.
the class RedirectableModelTransactionHandler method getActionRedirection.
protected IActionRedirection getActionRedirection(IBindingManager bm) {
if (!bm.wIsSet("focusEntity"))
return NullActionRedirection.instance();
IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
IEntityPart entityPart = viewer.getEditPartRegistry().get(bm.wGet("focusEntity"));
IActionRedirection actionRedirection = (IActionRedirection) entityPart.getAdapter(IActionRedirection.class);
return actionRedirection != null ? actionRedirection : NullActionRedirection.instance();
}
use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.
the class ClipboardUtils method createEditPart.
public static IEntityPart createEditPart(EditPartFactory factory, IEntity entity) {
IGEFEditorKit commonsEditorKit = (IGEFEditorKit) ReflectionFactory.getEditorKit("org.whole.lang.commons.ui.CommonsEditorKit");
RootFragment rootFragment = CommonsEntityFactory.instance.createRootFragment(entity.wGetAdapter(CommonsEntityDescriptorEnum.Any));
EditPart rootFragmentPart = commonsEditorKit.getPartFactory().createEditPart(null, rootFragment);
IEntityPart entityPart = (IEntityPart) factory.createEditPart(rootFragmentPart, entity);
EntityUtils.remove(entity);
return entityPart;
}
use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.
the class TextualDragTracker method performSelectionUpdate.
private void performSelectionUpdate(IWholeSelection selection, Point location, boolean caretOnSelectionEnd) {
EditPartViewer viewer = getCurrentViewer();
IEntityPart focusPart = null;
if (selection.size() > 0) {
IWholeSelection last = selection.get(selection.size() - 1);
int caretPosition = -1;
switch(last.getKind()) {
case RANGE:
caretPosition = last.getEndPosition();
case PART:
IEntityPart lastPart = last.getPart();
if (lastPart instanceof ITextualEntityPart) {
ITextualEntityPart caretPart = (ITextualEntityPart) lastPart;
if (caretOnSelectionEnd) {
caretPosition = caretPosition < 0 ? caretPart.getCaretPositions() : caretPosition;
CaretUpdater.sheduleSyncUpdate(getCurrentViewer(), lastPart.getModelEntity(), caretPosition, true);
} else
CaretUpdater.sheduleSyncUpdate(getCurrentViewer(), lastPart.getModelEntity(), location != null ? location : getLocation(), true);
// update focus only if instance of ICaretEntityPart
focusPart = lastPart;
}
default:
break;
}
}
List<IEntityPart> partList = new ArrayList<IEntityPart>();
for (int i = 0; i < selection.size(); i++) {
IWholeSelection sel = selection.get(i);
switch(sel.getKind()) {
case RANGE:
((ITextualEntityPart) sel.getPart()).setSelectionRange(sel.getStartPosition(), sel.getEndPosition());
partList.add(sel.getPart());
break;
case PART:
IEntityPart part = sel.getPart();
if (part instanceof ITextualEntityPart)
((ITextualEntityPart) part).setSelectionRange(0, ((ITextualEntityPart) part).getCaretPositions());
partList.add(sel.getPart());
break;
default:
break;
}
}
viewer.setSelection(new StructuredSelection(partList));
viewer.setFocus(focusPart);
}
use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.
the class AbstractFileTransferDragSourceListener method createFiles.
protected File[] createFiles() throws Exception {
List<EditPart> selectedEditParts = getSelectedEditParts();
List<File> files = new ArrayList<File>();
for (EditPart editPart : selectedEditParts) {
IEntityPart entityPart = (IEntityPart) editPart;
files.add(createFile(entityPart));
}
return files.toArray(new File[0]);
}
use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.
the class IActionRedirection method getActionRedirection.
public static IActionRedirection getActionRedirection(IBindingManager bm) {
if (!bm.wIsSet("focusEntity"))
return NullActionRedirection.instance();
IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
IEntityPart entityPart = viewer.getEditPartRegistry().get(bm.wGet("focusEntity"));
if (entityPart == null)
return NullActionRedirection.instance();
IActionRedirection actionRedirection = (IActionRedirection) entityPart.getAdapter(IActionRedirection.class);
return actionRedirection != null ? actionRedirection : NullActionRedirection.instance();
}
Aggregations