Search in sources :

Example 6 with IEvaluationService

use of org.eclipse.ui.services.IEvaluationService in project hale by halestudio.

the class IOWizardAction method dispose.

/**
 * Disposes this action. Should be called when the action isn't needed
 * anymore.
 */
public void dispose() {
    if (evaluationReference != null) {
        IEvaluationService es = PlatformUI.getWorkbench().getService(IEvaluationService.class);
        es.removeEvaluationListener(evaluationReference);
    }
}
Also used : IEvaluationService(org.eclipse.ui.services.IEvaluationService)

Example 7 with IEvaluationService

use of org.eclipse.ui.services.IEvaluationService in project hale by halestudio.

the class ActionUIWizardPage method acceptWizard.

/**
 * @see ViewerWizardSelectionPage#acceptWizard(IWizardNode)
 */
@Override
protected String acceptWizard(IWizardNode wizardNode) {
    if (wizardNode instanceof ActionUIWizardNode) {
        ActionUI actionUI = ((ActionUIWizardNode) wizardNode).getActionUI();
        Expression enabledWhen = actionUI.getEnabledWhen();
        if (enabledWhen == null) {
            return null;
        }
        IEvaluationService ies = PlatformUI.getWorkbench().getService(IEvaluationService.class);
        try {
            EvaluationResult evalResult = enabledWhen.evaluate(ies.getCurrentState());
            if (evalResult == EvaluationResult.FALSE) {
                // disabled
                return actionUI.getDisabledReason();
            }
            // enabled
            return null;
        } catch (CoreException e) {
            String message = "Could not evaluate enabledWhen expression";
            log.error(message, e);
            return message;
        }
    }
    return super.acceptWizard(wizardNode);
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) Expression(org.eclipse.core.expressions.Expression) ActionUI(eu.esdihumboldt.hale.ui.io.action.ActionUI) IEvaluationService(org.eclipse.ui.services.IEvaluationService) EvaluationResult(org.eclipse.core.expressions.EvaluationResult)

Example 8 with IEvaluationService

use of org.eclipse.ui.services.IEvaluationService in project archi by archimatetool.

the class ShowToolbarAction method isVisible.

private boolean isVisible() {
    boolean isVisible = false;
    IEvaluationService service = PlatformUI.getWorkbench().getService(IEvaluationService.class);
    IEvaluationContext appState = service.getCurrentState();
    Object coolbar = appState.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_IS_COOLBAR_VISIBLE_NAME);
    if (coolbar instanceof Boolean) {
        isVisible = ((Boolean) coolbar).booleanValue();
    }
    return isVisible;
}
Also used : IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) IEvaluationService(org.eclipse.ui.services.IEvaluationService)

Example 9 with IEvaluationService

use of org.eclipse.ui.services.IEvaluationService in project core by jcryptool.

the class RecordHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
    // $NON-NLS-1$
    Command command = service.getCommand("org.jcryptool.actions.recordCommand");
    // $NON-NLS-1$
    State state = command.getState("org.jcryptool.actions.recordCommand.toggleState");
    doRecord = !(Boolean) state.getValue();
    if (doRecord && HandlerUtil.getActivePart(event) instanceof ActionView) {
        boolean launched = startRecording(HandlerUtil.getActiveEditor(event), (ActionView) HandlerUtil.getActivePart(event));
        if (launched) {
            state.setValue(doRecord);
            service.refreshElements(event.getCommand().getId(), null);
        }
    } else {
        state.setValue(doRecord);
        service.refreshElements(event.getCommand().getId(), null);
    }
    final IWorkbenchWindow ww = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    final IEvaluationService evalService = (IEvaluationService) ww.getService(IEvaluationService.class);
    if (evalService != null) {
        // $NON-NLS-1$
        evalService.requestEvaluation("org.jcryptool.actions.isDoRecord");
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Command(org.eclipse.core.commands.Command) State(org.eclipse.core.commands.State) ActionView(org.jcryptool.actions.ui.views.ActionView) ICommandService(org.eclipse.ui.commands.ICommandService) IEvaluationService(org.eclipse.ui.services.IEvaluationService)

Aggregations

IEvaluationService (org.eclipse.ui.services.IEvaluationService)9 Command (org.eclipse.core.commands.Command)4 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)4 ICommandService (org.eclipse.ui.commands.ICommandService)4 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)3 IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)3 CoreException (org.eclipse.core.runtime.CoreException)2 ActionUI (eu.esdihumboldt.hale.ui.io.action.ActionUI)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashMap (java.util.HashMap)1 DatabaseModelBean (net.heartsome.cat.common.bean.DatabaseModelBean)1 Language (net.heartsome.cat.common.locale.Language)1 ConcordanceSearchDialog (net.heartsome.cat.database.ui.tm.dialog.ConcordanceSearchDialog)1 ProjectConfiger (net.heartsome.cat.ts.core.file.ProjectConfiger)1 IXliffEditor (net.heartsome.cat.ts.ui.editors.IXliffEditor)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 NotEnabledException (org.eclipse.core.commands.NotEnabledException)1 NotHandledException (org.eclipse.core.commands.NotHandledException)1 State (org.eclipse.core.commands.State)1 NotDefinedException (org.eclipse.core.commands.common.NotDefinedException)1