Example #1
0
  public static IResource getSelectedResource(IEvaluationContext evaluationContext) {
    if (evaluationContext == null) {
      return null;
    }

    Object variable = evaluationContext.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
    if (variable instanceof IStructuredSelection) {
      Object selectedObject = ((IStructuredSelection) variable).getFirstElement();
      if (selectedObject instanceof IAdaptable) {
        IResource resource = (IResource) ((IAdaptable) selectedObject).getAdapter(IResource.class);
        if (resource != null) {
          return resource;
        }
      }
    } else {
      // checks the active editor
      variable = evaluationContext.getVariable(ISources.ACTIVE_EDITOR_NAME);
      if (variable instanceof IEditorPart) {
        IEditorInput editorInput = ((IEditorPart) variable).getEditorInput();
        if (editorInput instanceof IFileEditorInput) {
          return ((IFileEditorInput) editorInput).getFile();
        }
      }
    }
    return null;
  }
 private static IStructuredSelection getActiveSelection() {
   IStructuredSelection selection = null;
   IEvaluationService evaluationService =
       (IEvaluationService) PlatformUI.getWorkbench().getService(IEvaluationService.class);
   if (evaluationService != null) {
     IEvaluationContext currentState = evaluationService.getCurrentState();
     Object variable = currentState.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
     if (variable instanceof IStructuredSelection) {
       selection = (IStructuredSelection) variable;
     }
   }
   return (selection == null) ? StructuredSelection.EMPTY : selection;
 }
  @Override
  public final EvaluationResult evaluate(final IEvaluationContext context) throws CoreException {
    final EvaluationResult result = super.evaluate(context);
    if (result == EvaluationResult.FALSE) {
      return result;
    }

    final Object defaultVariable = context.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
    if (defaultVariable instanceof ISelection) {
      final ISelection selection = (ISelection) defaultVariable;
      if (enabler.isEnabledForSelection(selection)) {
        return EvaluationResult.TRUE;
      }
    }

    return EvaluationResult.FALSE;
  }
  @Override
  public Object execute(final ExecutionEvent event) throws ExecutionException {
    final IEvaluationContext context = (IEvaluationContext) event.getApplicationContext();

    /* Get the map */
    final IWorkbenchWindow window =
        (IWorkbenchWindow) context.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME);
    final IWorkbenchPage activePage = window.getActivePage();

    /* set input to gtt tables */
    final IScenarioDataProvider dataProvider = KalypsoAFGUIFrameworkPlugin.getDataProvider();
    final IFolder scenarioFolder = (IFolder) dataProvider.getScenarioFolder();

    KalypsoCorePlugin.getDefault().getSelectionManager().clear();

    WorkflowHandlerUtils.setGttInput(
        activePage,
        "NaNodes",
        "urn:org.kalypso.model.rrm.resultOutputManagement:workflow:NaNodes:gtt",
        Messages.getString("ResultOutputManagementTaskHandler_0"),
        scenarioFolder); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    WorkflowHandlerUtils.setGttInput(
        activePage,
        "Catchments",
        "urn:org.kalypso.model.rrm.resultOutputManagement:workflow:Catchments:gtt",
        Messages.getString("ResultOutputManagementTaskHandler_1"),
        scenarioFolder); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    WorkflowHandlerUtils.setGttInput(
        activePage,
        "StorageChannels",
        "urn:org.kalypso.model.rrm.resultOutputManagement:workflow:StorageChannels:gtt",
        Messages.getString("ResultOutputManagementTaskHandler_2"),
        scenarioFolder); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    WorkflowHandlerUtils.setGftInput(
        activePage,
        "Outputs",
        "urn:org.kalypso.model.rrm.resultOutputManagement:workflow:Outputs:gft",
        Messages.getString("ResultOutputManagementTaskHandler_3"),
        scenarioFolder); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    return null;
  }
  @Override
  public void setEnabled(Object evaluationContext) {
    if (evaluationContext instanceof IEvaluationContext) {
      IEvaluationContext evalContext = (IEvaluationContext) evaluationContext;
      Object selection = evalContext.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
      if (selection instanceof ISelection) {
        IProject[] selectedProjects = getSelectedProjects((ISelection) selection);

        Repository repository = org.eclipse.flux.core.Activator.getDefault().getRepository();
        for (IProject project : selectedProjects) {
          if (repository.isConnected(project)) {
            setBaseEnabled(true);
            return;
          }
        }
      }
    }

    setBaseEnabled(false);
  }
Example #6
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.eclipse.core.expressions.Expression#evaluate(org.eclipse.core
  * .expressions.IEvaluationContext)
  */
 public EvaluationResult evaluate(IEvaluationContext context) {
   Object v = context.getVariable(ISources.ACTIVE_PART_ID_NAME);
   return EvaluationResult.valueOf(partId.equals(v));
 }
Example #7
0
 public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
   String variable = (String) context.getVariable("username");
   return lookFor.equals(variable) ? EvaluationResult.TRUE : EvaluationResult.FALSE;
 }