Search in sources :

Example 31 with IEntityPart

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

the class DirectEditAction method update.

@Override
public void update() {
    setEnabled(false);
    ESelectionService selectionService = getContext().get(ESelectionService.class);
    if (selectionService.getSelection() instanceof IBindingManager) {
        IBindingManager bm = (IBindingManager) selectionService.getSelection();
        if (bm.wIsSet("viewer")) {
            IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
            IEntity focusEntity = bm.wGet("focusEntity");
            IEntityPart entityPart = viewer.getEditPartRegistry().get(focusEntity);
            setEnabled(entityPart.understandsRequest(request));
        }
    }
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 32 with IEntityPart

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

the class DirectEditAction method run.

@Override
public void run() {
    ESelectionService selectionService = getContext().get(ESelectionService.class);
    IBindingManager bm = (IBindingManager) selectionService.getSelection();
    IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
    IEntity focusEntity = bm.wGet("focusEntity");
    IEntityPart entityPart = viewer.getEditPartRegistry().get(focusEntity);
    try {
        entityPart.performRequest(request);
    } catch (Exception e) {
        e.getCause();
    }
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 33 with IEntityPart

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

the class E4GraphicalViewer method refreshNotation.

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

Example 34 with IEntityPart

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

the class E4GraphicalViewer method reveal.

public void reveal(IEntity entity) {
    IEntityPart entityPart = ModelObserver.getObserver(entity, getEditPartRegistry());
    reveal(entityPart);
}
Also used : IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 35 with IEntityPart

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

the class E4GraphicalViewer method select.

@Override
public void select(List<? extends IEntity> entities, boolean propagate) {
    List<IEntityPart> entityParts = new ArrayList<>();
    for (int i = entities.size() - 1; i >= 0; i--) {
        IEntityPart entityPart = ModelObserver.getObserver(entities.get(i), getEditPartRegistry());
        if (entityPart != null && entityPart.isSelectable())
            entityParts.add(entityPart);
    }
    setSelection(new StructuredSelection(entityParts), propagate);
}
Also used : ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IEntityPart(org.whole.lang.ui.editparts.IEntityPart) Point(org.eclipse.draw2d.geometry.Point)

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