Search in sources :

Example 26 with IEntityPartViewer

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();
    }
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) ModelTransactionCommand(org.whole.lang.ui.commands.ModelTransactionCommand) IEntity(org.whole.lang.model.IEntity) OperationCanceledException(org.whole.lang.operations.OperationCanceledException) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 27 with IEntityPartViewer

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

Example 28 with IEntityPartViewer

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);
}
Also used : EditPart(org.eclipse.gef.EditPart) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) IEntityPart(org.whole.lang.ui.editparts.IEntityPart) LinkedList(java.util.LinkedList)

Example 29 with IEntityPartViewer

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());
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) ILinkViewerListener(org.whole.lang.e4.ui.actions.ILinkViewerListener) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 30 with IEntityPartViewer

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) {
        }
    });
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) ILinkViewerListener(org.whole.lang.e4.ui.actions.ILinkViewerListener) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Aggregations

IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)55 IEntity (org.whole.lang.model.IEntity)29 IBindingManager (org.whole.lang.bindings.IBindingManager)13 CommandStack (org.eclipse.gef.commands.CommandStack)12 ModelTransactionCommand (org.whole.lang.ui.commands.ModelTransactionCommand)11 OperationCanceledException (org.whole.lang.operations.OperationCanceledException)8 IEntityPart (org.whole.lang.ui.editparts.IEntityPart)8 ESelectionService (org.eclipse.e4.ui.workbench.modeling.ESelectionService)7 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)6 CanExecute (org.eclipse.e4.core.di.annotations.CanExecute)6 Execute (org.eclipse.e4.core.di.annotations.Execute)6 Shell (org.eclipse.swt.widgets.Shell)5 ITextualEntityPart (org.whole.lang.ui.editparts.ITextualEntityPart)5 ITransactionScope (org.whole.lang.bindings.ITransactionScope)3 IEventBroker (org.eclipse.e4.core.services.events.IEventBroker)2 UISynchronize (org.eclipse.e4.ui.di.UISynchronize)2 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)2 Command (org.eclipse.gef.commands.Command)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 Control (org.eclipse.swt.widgets.Control)2