@Override
 public void undo() {
   for (int i = 0; i < contextManager.getListContext().size(); i++) {
     IContext context = contextManager.getListContext().get(i);
     List<IContextParameter> listParams = context.getContextParameterList();
     List<IContextParameter> contextParamList = mapParams.get(context.getName());
     if (contextParamList != null) {
       listParams.addAll(contextParamList);
     }
   }
   contextManager.fireContextsChangedEvent();
   helper.refreshContextView();
 }
 /**
  * This method is used to remove the <code>JobContextParameter</code> in <code>JobContext</code>,
  * using the combination of <code>sourceId</code> and <code>name</code> can identify the unique
  * <code>JobContextParameter</code>.
  *
  * @param sourceId
  * @param name
  */
 private void removeParameterFromContext(String sourceId, String name) {
   List<IContext> list = contextManager.getListContext();
   if (list != null && list.size() > 0) {
     for (int i = 0; i < list.size(); i++) {
       IContext context = list.get(i);
       List<IContextParameter> contextParameters = context.getContextParameterList();
       List<IContextParameter> movedList = new ArrayList<IContextParameter>();
       if (contextParameters != null && contextParameters.size() > 0) {
         for (int j = 0; j < contextParameters.size(); j++) {
           IContextParameter contextPara = contextParameters.get(j);
           String tempSourceId = contextPara.getSource();
           String tempParaName = contextPara.getName();
           if (tempSourceId.equals(sourceId) && tempParaName.equals(name)) {
             movedList.add(contextPara);
             contextParameters.remove(j);
             if (mapParams.get(context.getName()) != null) {
               mapParams.get(context.getName()).addAll(movedList);
               mapParams.put(context.getName(), mapParams.get(context.getName()));
             } else {
               mapParams.put(context.getName(), movedList);
             }
             break;
           }
         }
       }
     }
   }
 }
  private void initializeContextCombo() {
    IContextManager contextManager = getContextManager();
    if (contextsCombo.getItems().length > 0) {
      contextsCombo.removeAll();
    }
    if (contextManager != null) {
      List<IContext> contexts = contextManager.getListContext();
      for (IContext context : contexts) {
        if (!Arrays.asList(contextsCombo.getItems()).contains(context.getName())) {
          contextsCombo.add(context.getName());
        }
      }

      for (int i = 0; i < contextsCombo.getItemCount(); i++) {
        IContext defaultContext = contextManager.getDefaultContext();
        if (defaultContext.getName().equals(contextsCombo.getItem(i))) {
          contextsCombo.select(i);
          break;
        }
      }
    }

    int visibleItemCount = contextsCombo.getItemCount();
    if (visibleItemCount > 20) {
      visibleItemCount = 20;
    }
    contextsCombo.setVisibleItemCount(visibleItemCount);
  }
 private void propagateType(IContextManager contextManager, IContextParameter param) {
   for (IContext context : contextManager.getListContext()) {
     IContextParameter paramToModify = context.getContextParameter(param.getName());
     paramToModify.setType(param.getType());
     paramToModify.setComment(param.getComment());
     paramToModify.setSource(param.getSource());
   }
 }
  protected void getInformationsFromContextManager(IContextManager contextManager) {
    List<IContext> internalContextList = new ArrayList<IContext>();
    IContext newSelectedCopiedContext = null;

    // if (!contextComboViewer.getSelection().isEmpty()) {
    // oldSelectedCopiedContext = (IContext) ((StructuredSelection)
    // contextComboViewer.getSelection()).getFirstElement();
    // }

    if (process != null && process.getLastRunContext() != null) {
      for (IContext context : contextManager.getListContext()) {
        IContext copiedContext = context.clone();
        internalContextList.add(copiedContext);
        if (process.getLastRunContext().getName().equals(context.getName())) {
          newSelectedCopiedContext = copiedContext;
        }
      }
    } else {
      for (IContext context : contextManager.getListContext()) {
        IContext copiedContext = context.clone();
        internalContextList.add(copiedContext);
        if (contextManager.getDefaultContext().equals(context)) {
          newSelectedCopiedContext = copiedContext;
        }
      }
    }
    Collections.sort(internalContextList, new ContextCompare());
    contextComboViewer.setInput(internalContextList);

    ProcessManager processManager = ProcessManager.getInstance();

    if (newSelectedCopiedContext != null) {
      setContextComboSelection(new StructuredSelection(newSelectedCopiedContext));
      processManager.setSelectContext(newSelectedCopiedContext);
      contextTableViewer.setInput(newSelectedCopiedContext.getContextParameterList());
    } else {
      IContext element = internalContextList.get(0);
      processManager.setSelectContext(element);
      setContextComboSelection(new StructuredSelection(element));
      contextTableViewer.setInput(element.getContextParameterList());
    }
  }
Exemple #6
0
 @SuppressWarnings("unchecked")
 private void initSets() {
   if (source != null) {
     if (source instanceof ContextItem) {
       ContextItem contextItem = (ContextItem) source;
       defalutContext = contextItem.getDefaultContext();
       for (ContextType type : (List<ContextType>) contextItem.getContext()) {
         String name = type.getName();
         if (name.equals(defalutContext)) {
           name = name + DEFAULT_FLAG;
         }
         contextSetsList.add(name);
       }
     } else if (source instanceof IContextManager) {
       IContextManager contextManager = (IContextManager) (source);
       for (IContext context : contextManager.getListContext()) {
         String name = context.getName();
         if (name.equals(defalutContext)) {
           name = name + DEFAULT_FLAG;
         }
         contextSetsList.add(name);
       }
     } else if (source instanceof List<?>) {
       for (Object obj : (List<?>) source) {
         if (obj instanceof ContextType) {
           ContextType context = (ContextType) obj;
           String name = context.getName();
           if (name.equals(defalutContext)) {
             name = name + DEFAULT_FLAG;
           }
           contextSetsList.add(name);
         }
       }
     }
   }
 }