예제 #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();
  }
  /* (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;
  }