Search in sources :

Example 41 with IEntityPart

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();
}
Also used : IActionRedirection(org.whole.lang.ui.actions.IActionRedirection) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 42 with IEntityPart

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;
}
Also used : RootEditPart(org.eclipse.gef.RootEditPart) EditPart(org.eclipse.gef.EditPart) IGEFEditorKit(org.whole.lang.ui.editor.IGEFEditorKit) RootFragment(org.whole.lang.commons.model.RootFragment) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 43 with IEntityPart

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);
}
Also used : ITextualEntityPart(org.whole.lang.ui.editparts.ITextualEntityPart) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) EditPartViewer(org.eclipse.gef.EditPartViewer) IEntityPart(org.whole.lang.ui.editparts.IEntityPart) Point(org.eclipse.draw2d.geometry.Point)

Example 44 with IEntityPart

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]);
}
Also used : EditPart(org.eclipse.gef.EditPart) ArrayList(java.util.ArrayList) File(java.io.File) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 45 with IEntityPart

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();
}
Also used : IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) 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