Пример #1
0
  /* (non-Javadoc)
   * @see org.eclipse.tcf.te.tcf.ui.dialogs.AbstractArraySelectionDialog#getInput()
   */
  @Override
  protected Object[] getInput() {
    final IPeerNode peerNode =
        ServiceManager.getInstance()
            .getService(IDefaultContextService.class)
            .getDefaultContext(null);

    IService[] services =
        ServiceManager.getInstance().getServices(peerNode, IDelegateService.class, false);
    Map<String, IDefaultContextToolbarDelegate> delegates =
        new LinkedHashMap<String, IDefaultContextToolbarDelegate>();
    for (IService service : services) {
      if (service instanceof IDelegateService) {
        IDefaultContextToolbarDelegate delegate =
            ((IDelegateService) service)
                .getDelegate(peerNode, IDefaultContextToolbarDelegate.class);
        if (delegate != null) {
          for (String stepGroupId : delegate.getHandledStepGroupIds(peerNode)) {
            if (!delegates.containsKey(stepGroupId)) {
              delegates.put(stepGroupId, delegate);
            }
          }
        }
      }
    }

    List<Entry> actions = new ArrayList<Entry>();
    String[] entries =
        HistoryManager.getInstance()
            .getHistory(
                IStepAttributes.PROP_LAST_RUN_HISTORY_ID
                    + "@"
                    + peerNode.getPeerId()); // $NON-NLS-1$
    if (entries != null && entries.length > 0) {
      int count = 0;
      for (final String entry : entries) {
        if (count >= getMaxEntries()) {
          break;
        }
        IPropertiesContainer decoded = DataHelper.decodePropertiesContainer(entry);
        String stepGroupId = decoded.getStringProperty(IStepAttributes.ATTR_STEP_GROUP_ID);
        if (stepGroupId != null && delegates.containsKey(stepGroupId)) {
          Entry action = new Entry();
          action.peerNode = peerNode;
          action.delegate = delegates.get(stepGroupId);
          action.data = entry;
          actions.add(action);
          count++;
        }
      }
    }

    return actions.toArray();
  }
Пример #2
0
  /** Executes the script launch. */
  protected void executeLaunch() {
    // Get the script properties container
    final IPropertiesContainer properties = getProperties();
    if (properties == null) {
      // This is an illegal argument. Properties must be set
      IStatus status =
          new Status(
              IStatus.ERROR,
              CoreBundleActivator.getUniqueIdentifier(),
              NLS.bind(
                  Messages.ScriptLauncher_error_illegalNullArgument, "properties"), // $NON-NLS-1$
              new IllegalArgumentException());
      invokeCallback(status, null);
      return;
    }

    // Get the script to execute
    String script = properties.getStringProperty(IScriptLauncherProperties.PROP_SCRIPT);
    if (script == null || "".equals(script.trim())) { // $NON-NLS-1$
      IStatus status =
          new Status(
              IStatus.ERROR,
              CoreBundleActivator.getUniqueIdentifier(),
              Messages.ScriptLauncher_error_missingScript,
              new IllegalArgumentException(IScriptLauncherProperties.PROP_SCRIPT));
      invokeCallback(status, null);
      return;
    }

    // Create the script parser instance
    Parser parser = new Parser(script);
    try {
      // Parse the script
      Token[] tokens = parser.parse();

      // And execute the tokens extracted, one by one sequentially
      if (tokens != null && tokens.length > 0) {
        executeToken(tokens, 0);
      } else {
        invokeCallback(Status.OK_STATUS, null);
        return;
      }
    } catch (IOException e) {
      IStatus status =
          new Status(
              IStatus.ERROR,
              CoreBundleActivator.getUniqueIdentifier(),
              NLS.bind(Messages.ScriptLauncher_error_parsingScript, e.getLocalizedMessage()),
              e);
      invokeCallback(status, null);
      return;
    }
  }
  /* (non-Javadoc)
   * @see org.eclipse.tcf.te.ui.views.handler.OpenEditorHandler#execute(org.eclipse.core.commands.ExecutionEvent)
   */
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    final IPeerNode peerNode =
        ServiceManager.getInstance()
            .getService(IDefaultContextService.class)
            .getDefaultContext(null);

    IService[] services =
        ServiceManager.getInstance().getServices(peerNode, IDelegateService.class, false);
    Map<String, IDefaultContextToolbarDelegate> delegates =
        new LinkedHashMap<String, IDefaultContextToolbarDelegate>();
    for (IService service : services) {
      if (service instanceof IDelegateService) {
        IDefaultContextToolbarDelegate delegate =
            ((IDelegateService) service)
                .getDelegate(peerNode, IDefaultContextToolbarDelegate.class);
        if (delegate != null) {
          for (String stepGroupId : delegate.getHandledStepGroupIds(peerNode)) {
            if (!delegates.containsKey(stepGroupId)) {
              delegates.put(stepGroupId, delegate);
            }
          }
        }
      }
    }

    String entry =
        HistoryManager.getInstance()
            .getFirst(
                IStepAttributes.PROP_LAST_RUN_HISTORY_ID
                    + "@"
                    + peerNode.getPeerId()); // $NON-NLS-1$
    if (entry != null) {
      IPropertiesContainer decoded = DataHelper.decodePropertiesContainer(entry);
      String stepGroupId = decoded.getStringProperty(IStepAttributes.ATTR_STEP_GROUP_ID);
      if (stepGroupId != null && delegates.containsKey(stepGroupId)) {
        IDefaultContextToolbarDelegate delegate = delegates.get(stepGroupId);
        delegate.execute(peerNode, entry, false);
      }
    }
    return null;
  }