use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.
the class ContentAssistRunnable method run.
@Override
public void run(IOperationProgressMonitor pm) throws InvocationTargetException, InterruptedException {
IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
CommandStack commandStack = viewer.getEditDomain().getCommandStack();
ModelTransactionCommand mtc = new ModelTransactionCommand(bm.wGet("self"), label);
IEntity[] contentAssist = null;
pm.beginTask("Content assit generation...", IOperationProgressMonitor.TOTAL_WORK);
try {
mtc.begin();
contentAssist = ContentAssistOperation.getContentAssist(bm.wGet("focusEntity"), bm);
mtc.commit();
if (mtc.canUndo())
commandStack.execute(mtc);
} catch (OperationCanceledException e) {
mtc.rollbackIfNeeded();
} catch (RuntimeException e) {
mtc.rollbackIfNeeded();
throw e;
} finally {
bm.setResult(BindingManagerFactory.instance.createValue(contentAssist));
pm.endTask();
}
}
use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.
the class E4PaletteGraphicalPart method createEntityViewer.
protected IEntityPartViewer createEntityViewer(Composite parent) {
IEclipseContext params = EclipseContextFactory.create();
params.set("parent", parent);
IEntityPartViewer viewer = ContextInjectionFactory.make(E4PaletteGraphicalViewer.class, context, params);
setSelectionLinkable(createSelectionLinkable(viewer));
return viewer;
}
use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.
the class WholeDragEditPartsTracker method performSelection.
@Override
@SuppressWarnings("unchecked")
protected void performSelection() {
if (!getCurrentInput().isShiftKeyDown())
super.performSelection();
if (hasSelectionOccurred())
return;
setFlag(FLAG_SELECTION_PERFORMED, true);
IEntityPartViewer viewer = (IEntityPartViewer) getCurrentViewer();
List<IEntityPart> selectedParts = viewer.getSelectedEditParts();
IEntityPart startPart = selectedParts.get(selectedParts.size() - 1);
EditPart endPart = getSourceEditPart();
EditPart parentPart = startPart.getParent();
if (parentPart != null && endPart != startPart && parentPart == endPart.getParent()) {
LinkedList<IEntityPart> appendParts = new LinkedList<IEntityPart>();
int endIndex = -1, startIndex = -1;
List<IEntityPart> children = parentPart.getChildren();
for (int i = 0; i < children.size(); i++) {
IEntityPart child = children.get(i);
if (child == startPart)
startIndex = i;
else if (child == endPart)
endIndex = i;
if (startIndex != -1 && endIndex == -1 && i > startIndex)
appendParts.addLast(child);
else if (startIndex == -1 && endIndex != -1)
appendParts.addFirst(child);
else if (startIndex != -1 && endIndex != -1) {
if (startIndex < endIndex)
appendParts.addLast(child);
break;
}
}
for (IEntityPart entityPart : appendParts) viewer.appendSelection(entityPart);
} else
viewer.appendSelection(endPart);
}
use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.
the class DerivedViewPart method createPartControl.
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
getComponent().addLinkViewerListener(new ILinkViewerListener() {
public void viewerLinked(IEntityPartViewer viewer, IEntityPartViewer toViewer) {
redirectCommandStackActions(viewer);
}
public void viewerUnlinked(IEntityPartViewer viewer) {
redirectCommandStackActions(viewer);
}
protected void redirectCommandStackActions(IEntityPartViewer viewer) {
undoAction.redirect(viewer);
redoAction.redirect(viewer);
}
public void contentsDerived(IEntityPartViewer viewer, IBindingManager selection, IEntity result) {
if (disableEditing)
viewer.setInteractive(result, false, true, false);
}
});
linkToEditorAction.setLinkable(getComponent().getSelectionLinkable());
}
use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.
the class OutlineTreeViewPart method createPartControl.
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
getComponent().addLinkViewerListener(new ILinkViewerListener() {
public void viewerLinked(IEntityPartViewer viewer, IEntityPartViewer toViewer) {
redirectCommandStackActions(viewer);
}
public void viewerUnlinked(IEntityPartViewer viewer) {
redirectCommandStackActions(viewer);
}
protected void redirectCommandStackActions(IEntityPartViewer viewer) {
undoAction.redirect(viewer);
redoAction.redirect(viewer);
}
public void contentsDerived(IEntityPartViewer viewer, IBindingManager selection, IEntity result) {
}
});
}
Aggregations