Search in sources :

Example 11 with IEntityPart

use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.

the class XsiSimpleElementPart method addChildVisual.

@Override
protected void addChildVisual(EditPart childEditPart, int index) {
    super.addChildVisual(childEditPart, index);
    IEntity child = ((IEntityPart) childEditPart).getModelEntity();
    if (EntityUtils.isComposite(child))
        child.wAddChangeEventHandler(getRefreshChangeEventHandler());
}
Also used : IEntity(org.whole.lang.model.IEntity) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 12 with IEntityPart

use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.

the class E4Utils method defineSelectionBindings.

@SuppressWarnings("unchecked")
public static void defineSelectionBindings(IBindingManager bm, SelectionChangedEvent event) {
    ISelection selection = event.getSelection();
    List<IEntityPart> selectedEntityParts = selection instanceof IStructuredSelection ? ((IStructuredSelection) selection).toList() : Collections.emptyList();
    defineSelectionBindings(bm, selectedEntityParts, (IEntityPartViewer) event.getSelectionProvider());
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 13 with IEntityPart

use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.

the class E4Utils method defineSelectionBindings.

public static void defineSelectionBindings(IBindingManager bm, List<IEntityPart> selectedEntityParts, IEntityPartViewer viewer) {
    IEntity selectedEntities = BindingManagerFactory.instance.createTuple();
    for (IEntityPart selectedEntityPart : selectedEntityParts) selectedEntities.wAdd(selectedEntityPart.getModelEntity());
    if (viewer != null) {
        bm.wDef("self", EntityUtils.getCompoundRoot(viewer.getEntityContents()));
        bm.wDefValue("viewer", viewer);
        IEntityPart focusEntityPart = viewer.getFocusEntityPart();
        bm.wDef("focusEntity", focusEntityPart.getModelEntity());
    }
    bm.wDef("selectedEntities", selectedEntities);
    IEntityIterator<IEntity> iterator = IteratorFactory.childIterator();
    iterator.reset(selectedEntities);
    if (iterator.hasNext()) {
        IEntity focusEntity = iterator.next();
        bm.wDef("primarySelectedEntity", focusEntity);
        if (!bm.wIsSet("focusEntity"))
            bm.wDef("focusEntity", focusEntity);
        IEntityPart primarySelectedEntityPart = selectedEntityParts.get(0);
        if (primarySelectedEntityPart instanceof IHilightable) {
            final IHilightable hilightable = (IHilightable) primarySelectedEntityPart;
            bm.wDefValue("hilightPosition", -1);
            bm.wGet("hilightPosition").wAddRequestEventHandler(new IdentityRequestEventHandler() {

                public int notifyRequested(IEntity source, FeatureDescriptor feature, int value) {
                    return hilightable.getHilightPosition();
                }
            });
        }
        if (primarySelectedEntityPart instanceof ITextualEntityPart) {
            final ITextualEntityPart textualEntityPart = (ITextualEntityPart) primarySelectedEntityPart;
            bm.wDefValue("selectedText", "");
            bm.wGet("selectedText").wAddRequestEventHandler(new IdentityRequestEventHandler() {

                public String notifyRequested(IEntity source, FeatureDescriptor feature, String value) {
                    return textualEntityPart.hasSelectionRange() ? DataTypeUtils.getAsPresentationString(textualEntityPart.getModelEntity()).substring(textualEntityPart.getSelectionStart(), textualEntityPart.getSelectionEnd()) : "";
                }
            });
        }
    }
}
Also used : ITextualEntityPart(org.whole.lang.ui.editparts.ITextualEntityPart) IEntity(org.whole.lang.model.IEntity) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) IHilightable(org.whole.lang.ui.editpolicies.IHilightable) IEntityPart(org.whole.lang.ui.editparts.IEntityPart) IdentityRequestEventHandler(org.whole.lang.events.IdentityRequestEventHandler)

Example 14 with IEntityPart

use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.

the class E4GraphicalViewer method setFocus.

@Override
public void setFocus(EditPart part) {
    IEntityPart oldPart = getFocusEntityPart();
    super.setFocus(part);
    if (oldPart != part)
        firePartFocusChanged(oldPart, (IEntityPart) part);
}
Also used : IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 15 with IEntityPart

use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.

the class E4GraphicalViewer method rebuildNotation.

public void rebuildNotation(IEntity entity) {
    IEntityPart entityPart = ModelObserver.getObserver(entity, getEditPartRegistry());
    if (entityPart == null) {
        if (EntityUtils.isAncestorOrSelf(entity, getEntityContents()))
            entityPart = ModelObserver.getObserver(getEntityContents(), getEditPartRegistry());
        else
            return;
    }
    entityPart.rebuild();
    invalidateTree();
}
Also used : IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Aggregations

IEntityPart (org.whole.lang.ui.editparts.IEntityPart)49 IEntity (org.whole.lang.model.IEntity)21 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)12 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)7 ArrayList (java.util.ArrayList)6 EditPart (org.eclipse.gef.EditPart)6 Point (org.eclipse.draw2d.geometry.Point)5 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)4 FocusEvent (org.eclipse.swt.events.FocusEvent)4 FocusListener (org.eclipse.swt.events.FocusListener)4 IBindingManager (org.whole.lang.bindings.IBindingManager)4 ActionRegistry (org.whole.lang.e4.ui.actions.ActionRegistry)4 E4KeyHandler (org.whole.lang.e4.ui.actions.E4KeyHandler)4 E4NavigationKeyHandler (org.whole.lang.e4.ui.actions.E4NavigationKeyHandler)4 IPartFocusListener (org.whole.lang.ui.editparts.IPartFocusListener)4 ITextualEntityPart (org.whole.lang.ui.editparts.ITextualEntityPart)4 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)3 ESelectionService (org.eclipse.e4.ui.workbench.modeling.ESelectionService)3