use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.
the class E4TreeViewer method reveal.
public void reveal(IEntity entity) {
IEntityPart entityPart = ModelObserver.getObserver(entity, getEditPartRegistry());
reveal(entityPart);
}
use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.
the class E4TreeViewer method setSelection.
@Override
public void setSelection(ISelection newSelection, boolean propagate) {
// the underlying TreeViewer keeps an unordered selection
// at least, we have to preserve the old child ordering
List<IEntityPart> previousParts = new ArrayList<>(((IStructuredSelection) getSelection()).toList());
List<IEntityPart> newParts = new ArrayList<>(((IStructuredSelection) newSelection).toList());
previousParts.retainAll(newParts);
newParts.removeAll(previousParts);
List<IEntityPart> orderedParts = new LinkedList<>(newParts);
orderedParts.addAll(previousParts);
super.setSelection(new StructuredSelection(orderedParts), propagate);
}
use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.
the class E4TreeViewer method selectAndReveal.
// End Block Shared With E4GraphicalViewer
public void selectAndReveal(IEntity entity, boolean propagate) {
IEntityPart entityPart = ModelObserver.getObserver(entity, getEditPartRegistry());
if (entityPart != null) {
reveal(entityPart);
select(entityPart, propagate);
}
}
use of org.whole.lang.ui.editparts.IEntityPart 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.editparts.IEntityPart in project whole by wholeplatform.
the class GrammarsKeyHandler method findNeighbour.
public EditPoint findNeighbour(IEditPointProvider editPointProvider, EditPoint editPoint, int direction) {
int caret = editPoint.caret;
IEntityPart focusPart = editPoint.focus;
IEntity focusEntity = focusPart.getModelEntity();
switch(focusEntity.wGetEntityOrd()) {
case GrammarsEntityDescriptorEnum.DataTerminal_ord:
case GrammarsEntityDescriptorEnum.LiteralTerminal_ord:
case GrammarsEntityDescriptorEnum.As_ord:
switch(direction) {
case NORTH:
switch(caret) {
case 0:
case 1:
return findInParent(editPointProvider, editPoint, focusEntity, direction);
case 2:
case 3:
return editPoint.caret(caret - 2);
}
case SOUTH:
switch(caret) {
case 2:
case 3:
return findInParent(editPointProvider, editPoint, focusEntity, direction);
case 0:
case 1:
return editPoint.caret(caret + 2);
}
case EAST:
switch(caret) {
case 0:
return findInChild(editPointProvider, editPoint, focusEntity.wGet(0), direction);
case 2:
return findInChild(editPointProvider, editPoint, focusEntity.wGet(1), direction);
case 1:
case 3:
return findInParent(editPointProvider, editPoint, focusEntity, direction);
}
case WEST:
switch(caret) {
case 1:
return findInChild(editPointProvider, editPoint, focusEntity.wGet(0), direction);
case 3:
return findInChild(editPointProvider, editPoint, focusEntity.wGet(1), direction);
case 0:
case 2:
return findInParent(editPointProvider, editPoint, focusEntity, direction);
}
}
}
return null;
}
Aggregations