Search in sources :

Example 1 with UISynchronize

use of org.eclipse.e4.ui.di.UISynchronize in project whole by wholeplatform.

the class DeriveModelRunnable method run.

@Override
public void run(IOperationProgressMonitor pm) throws InvocationTargetException, InterruptedException {
    pm.beginTask("Deriving...", IOperationProgressMonitor.TOTAL_WORK);
    try {
        bm.wEnterScope();
        bm.wDefValue("debug#reportModeEnabled", false);
        final IEntity result = BehaviorUtils.apply(functionUri, bm.wGet("self"), bm);
        UISynchronize synchronize = context.get(UISynchronize.class);
        if (synchronize == null)
            return;
        synchronize.asyncExec(new Runnable() {

            public void run() {
                updateUI(result);
            }
        });
    } catch (OperationCanceledException e) {
    // gracefully terminate execution
    } finally {
        bm.wExitScope();
        pm.endTask();
    }
}
Also used : IEntity(org.whole.lang.model.IEntity) OperationCanceledException(org.whole.lang.operations.OperationCanceledException) UISynchronize(org.eclipse.e4.ui.di.UISynchronize)

Example 2 with UISynchronize

use of org.eclipse.e4.ui.di.UISynchronize in project whole by wholeplatform.

the class SelectNotationHandler method execute.

@Execute
public void execute(@Optional @Named(EDITORKIT_ID_PARAMETER_ID) String editorKitId, @Named(IServiceConstants.ACTIVE_SELECTION) IBindingManager bm, final IEntityPartViewer viewer, UISynchronize synchronize) {
    IEditorKit editorKit = ReflectionFactory.getEditorKit(editorKitId);
    final IEntity focusEntity = bm.wGet("focusEntity");
    focusEntity.wGetModel().setEditorKit(editorKit);
    ModelTransactionCommand command = new ModelTransactionCommand(focusEntity);
    try {
        command.begin();
        IEntity fragmentRoot = EntityUtils.getLanguageFragmentRoot(focusEntity);
        viewer.rebuildNotation(fragmentRoot);
        command.commit();
        if (command.canUndo())
            viewer.getEditDomain().getCommandStack().execute(command);
    } catch (Exception e) {
        command.rollbackIfNeeded();
    }
    synchronize.asyncExec(new Runnable() {

        public void run() {
            viewer.selectAndReveal(focusEntity);
        }
    });
}
Also used : ModelTransactionCommand(org.whole.lang.ui.commands.ModelTransactionCommand) IEntity(org.whole.lang.model.IEntity) IEditorKit(org.whole.lang.reflect.IEditorKit) CanExecute(org.eclipse.e4.core.di.annotations.CanExecute) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 3 with UISynchronize

use of org.eclipse.e4.ui.di.UISynchronize in project whole by wholeplatform.

the class AbstractRunnableWithProgress method syncExec.

public synchronized IBindingScope syncExec(long timeout) {
    IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
    EntityEditDomain editDomain = viewer.getEditDomain();
    UISynchronize uiSynchronize = context.get(UISynchronize.class);
    try {
        context.set(UISynchronize.class, NoUISynchronize.instance);
        EntityEditDomainJob.syncExec("boh", editDomain, this);
    } finally {
        context.set(UISynchronize.class, uiSynchronize);
    }
    return bm;
}
Also used : EntityEditDomain(org.whole.lang.ui.viewers.EntityEditDomain) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) UISynchronize(org.eclipse.e4.ui.di.UISynchronize)

Example 4 with UISynchronize

use of org.eclipse.e4.ui.di.UISynchronize in project whole by wholeplatform.

the class ModelMergeViewer method fireDirtyState.

protected void fireDirtyState(boolean state) {
    final PropertyChangeEvent event = new PropertyChangeEvent(this, CompareEditorInput.DIRTY_STATE, false, state);
    if (listenerList == null || listenerList.isEmpty())
        return;
    Runnable runnable = new Runnable() {

        public void run() {
            for (IPropertyChangeListener listener : listenerList) {
                final IPropertyChangeListener propertyChangeListener = listener;
                SafeRunner.run(new ISafeRunnable() {

                    public void run() throws Exception {
                        propertyChangeListener.propertyChange(event);
                    }

                    public void handleException(Throwable exception) {
                    }
                });
            }
        }
    };
    UISynchronize uiSynchronize = getContext().get(UISynchronize.class);
    if (uiSynchronize != null)
        uiSynchronize.syncExec(runnable);
    else
        runnable.run();
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) UISynchronize(org.eclipse.e4.ui.di.UISynchronize)

Example 5 with UISynchronize

use of org.eclipse.e4.ui.di.UISynchronize in project whole by wholeplatform.

the class ValidateModelRunnable method run.

@Override
public void run(IOperationProgressMonitor pm) throws InvocationTargetException, InterruptedException {
    pm.beginTask("Validating...", IOperationProgressMonitor.TOTAL_WORK);
    try {
        UISynchronize synchronize = context.get(UISynchronize.class);
        bm.wDefValue("decorationManager", new E4UIDecorationManager(synchronize, bm));
        HandlersBehavior.validateModel(bm);
        if (MarkerUtils.findMarkers((IResource) bm.wGetValue("file"), true).length > 0)
            E4Utils.revealPart(context, "org.eclipse.ui.views.ProblemView");
    } catch (OperationCanceledException e) {
    // gracefully terminate execution
    } finally {
        pm.endTask();
    }
}
Also used : E4UIDecorationManager(org.whole.lang.e4.ui.operations.E4UIDecorationManager) OperationCanceledException(org.whole.lang.operations.OperationCanceledException) UISynchronize(org.eclipse.e4.ui.di.UISynchronize)

Aggregations

UISynchronize (org.eclipse.e4.ui.di.UISynchronize)5 IEntity (org.whole.lang.model.IEntity)2 OperationCanceledException (org.whole.lang.operations.OperationCanceledException)2 EntityEditDomain (org.whole.lang.ui.viewers.EntityEditDomain)2 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)2 ISafeRunnable (org.eclipse.core.runtime.ISafeRunnable)1 CanExecute (org.eclipse.e4.core.di.annotations.CanExecute)1 Execute (org.eclipse.e4.core.di.annotations.Execute)1 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)1 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)1 E4UIDecorationManager (org.whole.lang.e4.ui.operations.E4UIDecorationManager)1 IEditorKit (org.whole.lang.reflect.IEditorKit)1 ModelTransactionCommand (org.whole.lang.ui.commands.ModelTransactionCommand)1