Search in sources :

Example 6 with IEntityPartViewer

use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.

the class E4FindReplaceDialog method selectAndReveal.

protected void selectAndReveal(IEntity entity) {
    IEntityPartViewer viewer = (IEntityPartViewer) selection.wGetValue("viewer");
    viewer.selectAndReveal(entity);
}
Also used : IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 7 with IEntityPartViewer

use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.

the class ActivateToolAction 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"))
            setEnabled(!tool.isActive((IEntityPartViewer) bm.wGetValue("viewer")));
    }
}
Also used : IBindingManager(org.whole.lang.bindings.IBindingManager) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 8 with IEntityPartViewer

use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.

the class ActivateToolAction method run.

@Override
public void run() {
    ESelectionService selectionService = getContext().get(ESelectionService.class);
    IBindingManager bm = (IBindingManager) selectionService.getSelection();
    IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
    boolean clearCaret = Tools.TEXTUAL != tool && Tools.TEXTUAL.isActive(viewer);
    if (tool.ensureActive(viewer) && clearCaret) {
        IEntity focusEntity = bm.wGet("focusEntity");
        IEntityPart focusPart = viewer.getEditPartRegistry().get(focusEntity);
        if (focusPart instanceof ITextualEntityPart) {
            ITextualEntityPart textualPart = (ITextualEntityPart) focusPart;
            textualPart.setCaretVisible(false);
            viewer.setSelection(new StructuredSelection(textualPart));
        }
    }
}
Also used : ITextualEntityPart(org.whole.lang.ui.editparts.ITextualEntityPart) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 9 with IEntityPartViewer

use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.

the class DerivedLinkableSelectionListener method updateViewerContents.

protected void updateViewerContents(boolean relink) {
    if (lastSelection == null)
        return;
    if (shareEditDomain && relink) {
        IEntityPartViewer toViewer = (IEntityPartViewer) lastSelection.wGetValue("viewer");
        viewer.linkEditDomain(toViewer);
        fireViewerLinked(toViewer);
    }
    if (!changeTracker.testChangedAndUpdate(lastSelection, lastSelection.wGet("self")))
        return;
    if (functionUri != null) {
        ISynchronizableRunnable runnable = new DeriveModelRunnable(context, lastSelection, LABEL, functionUri, functionIsTransactional, resultShowingPolicy) {

            @Override
            protected void updateUI(IEntity result) {
                super.updateUI(result);
                if (result != null)
                    fireContentsDerived(result);
            }
        };
        runnable.asyncExec("Executing " + LABEL + " operation...");
    } else {
        IEntity newContents = lastSelection.wGet("self");
        if (viewer.getEntityContents() != newContents)
            viewer.setContents(newContents);
    }
    if (isSynchronizeSelection() && lastSelection.wIsSet("primarySelectedEntity")) {
        IEntity selectedEntities = lastSelection.wGet("selectedEntities");
        List<IEntity> selection = new ArrayList<>();
        for (int i = 0, size = selectedEntities.wSize(); i < size; i++) selection.add(selectedEntities.wGet(i));
        viewer.selectAndReveal(selection);
    }
}
Also used : ISynchronizableRunnable(org.whole.lang.e4.ui.jobs.ISynchronizableRunnable) IEntity(org.whole.lang.model.IEntity) ArrayList(java.util.ArrayList) DeriveModelRunnable(org.whole.lang.e4.ui.jobs.DeriveModelRunnable) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 10 with IEntityPartViewer

use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.

the class EntityLocationHyperlink method linkActivated.

public void linkActivated() {
    try {
        IEclipseContext context = (IEclipseContext) PlatformUI.getWorkbench().getService(IEclipseContext.class);
        EPartService partService = context.get(EPartService.class);
        Collection<MPart> parts = partService.getParts();
        for (MPart part : parts) {
            IEclipseContext partContext = part.getContext();
            if (partContext == null)
                continue;
            IModelInput modelInput = partContext.get(IModelInput.class);
            if (modelInput != null && ((IFilePersistenceProvider) modelInput.getPersistenceProvider()).getStore().equals(file)) {
                partService.activate(part, true);
                IEntityPartViewer viewer = partContext.get(IEntityPartViewer.class);
                IEntity entityContents = viewer.getEntityContents();
                final IEntity entity = EntityUtils.getEntity(entityContents, location);
                viewer.selectAndReveal(entity);
            }
        }
    } catch (Exception e) {
        E4CompatibilityPlugin.log(e);
    }
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) IModelInput(org.whole.lang.ui.input.IModelInput) IEntity(org.whole.lang.model.IEntity) EPartService(org.eclipse.e4.ui.workbench.modeling.EPartService) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) IFilePersistenceProvider(org.whole.lang.codebase.IFilePersistenceProvider) 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