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);
}
}
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);
}
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;
}
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;
}
Aggregations