private void checkContextGroupSource() {
   IContextManager contextManager = getContextManager();
   if (helper == null) {
     return;
   }
   if (contextManager != null) {
     helper.initHelper(contextManager);
     Map<String, Item> items = new HashMap<String, Item>();
     boolean needRefresh = false;
     for (IContextParameter param : contextManager.getDefaultContext().getContextParameterList()) {
       if (!param.isBuiltIn()) {
         String source = param.getSource();
         Item sourceItem = items.get(source);
         if (sourceItem == null) {
           sourceItem = ContextUtils.getRepositoryContextItemById(source);
         }
         if (sourceItem == null) { // source not found
           needRefresh = true;
           param.setSource(IContextParameter.BUILT_IN);
           propagateType(contextManager, param);
         } else {
           items.put(source, sourceItem);
         }
       }
     }
     if (needRefresh) {
       setModifiedFlag(contextManager);
       modelManager.refresh();
     }
   }
 }
  /**
   * DOC ggu Comment method "addContextParameterType".
   *
   * @param defaultContextParameterType
   */
  public void addContextParameterType(ContextParameterType defaultContextParameterType) {
    if (!isValid(defaultContextParameterType) || !isValid(manager)) {
      return;
    }

    ContextItem item = (ContextItem) getParentContextItem(defaultContextParameterType);
    if (item == null) {
      return;
    }
    ContextUtils.addContextParameterType(manager, item, defaultContextParameterType);
  }
 /*
  * check same ContextParameter or not.
  */
 private boolean checkIsSameContextParameter() {
   List<ContextItem> allContextItem = ContextUtils.getAllContextItem();
   for (IContext context : process.getContextManager().getListContext()) {
     for (IContextParameter param : context.getContextParameterList()) {
       if (allContextItem != null) {
         ContextItem contextItem =
             ContextUtils.getContextItemById(allContextItem, param.getSource());
         ContextType contextType =
             ContextUtils.getContextTypeByName(contextItem, context.getName(), true);
         ContextParameterType contextParameterType =
             ContextUtils.getContextParameterTypeByName(contextType, param.getName());
         if (!ContextUtils.samePropertiesForContextParameter(param, contextParameterType)) {
           return false;
         }
         // if don't open the job to run it(not use the "Detect and update all jobs"), will show
         // UpdateDetectionDialog to update the context ,after updated the item, the
         // contextComboViewer still
         // set the old one , so need refresh.
         IContext runJobViewContext = getSelectedContext();
         if (runJobViewContext != null) {
           for (IContextParameter tempContext : runJobViewContext.getContextParameterList()) {
             if (tempContext.getName().equals(contextParameterType.getName())
                 && !ContextUtils.samePropertiesForContextParameter(
                     tempContext, contextParameterType)) {
               return false;
             }
           }
         }
       }
     }
   }
   return true;
 }
  private Object getPropertyValue(IContextModelManager manager, Object element, int columnIndex) {

    if (isEmptyTreeNode(element)) {
      return "";
    }
    String contextParaName = ContextNatTableUtils.getCurrentContextModelName(element);
    String currentColumnName = getColumnProperty(columnIndex);
    if (currentColumnName.equals(ContextTableConstants.COLUMN_NAME_PROPERTY)) {
      if (element instanceof ContextTableTabParentModel) {
        String sourceId = ((ContextTableTabParentModel) element).getSourceId();
        if (!sourceId.equals(IContextParameter.BUILT_IN)) {
          Item item = ContextUtils.getRepositoryContextItemById(sourceId);
          if (item != null) {
            if (item instanceof JobletProcessItem) {
              return contextParaName + JOBLET_CONTEXT;
            } else if (item instanceof ProcessItem) {
              return contextParaName + JOB_CONTEXT;
            } else {
              return contextParaName + REPOSITORYT_CONTEXT;
            }
          }
        } else {
          return contextParaName;
        }
      } else {
        return contextParaName;
      }
    } else {
      IContextParameter currentParam =
          getRealParameter(manager.getContextManager(), currentColumnName, element);
      if (currentParam != null) {
        if (columnIndex == 1) {
          String contextParaType = currentParam.getType();
          JavaType javaType = ContextParameterJavaTypeManager.getJavaTypeFromId(contextParaType);
          if (javaType != null) {
            return javaType.getLabel();
          } else {
            return contextParaType;
          }
        } else if (currentColumnName.equals(ContextTableConstants.COLUMN_COMMENT_PROPERTY)) {
          return currentParam.getComment();
        } else {
          if (this.groupModel.isPartOfAGroup(columnIndex)) {
            String columnGroupName = this.groupModel.getColumnGroupByIndex(columnIndex).getName();
            if (manager.getContextManager() != null) {
              List<IContext> contexts = manager.getContextManager().getListContext();
              IContextParameter currentPara =
                  findContextPara(contexts, columnGroupName, contextParaName);
              if (currentPara == null) {
                return "";
              }
              if (currentColumnName.equals(ContextTableConstants.COLUMN_CHECK_PROPERTY)) {
                return currentPara.isPromptNeeded();
              } else if (currentColumnName.equals(ContextTableConstants.COLUMN_PROMPT_PROPERTY)) {
                return currentPara.getPrompt();
              } else if (currentColumnName.equals(ContextTableConstants.COLUMN_CONTEXT_VALUE)) {
                // because it's raw value, so need display * for password type.
                if (PasswordEncryptUtil.isPasswordType(currentPara.getType())) {
                  return PasswordEncryptUtil.getPasswordDisplay(currentPara.getValue());
                }
                return currentPara.getDisplayValue();
              }
            }
          }
        }
      }
    }
    return "";
  }
  public static List<ContextTableTabParentModel> constructContextDatas(
      List<IContextParameter> contextDatas) {
    List<ContextTableTabParentModel> output = new ArrayList<ContextTableTabParentModel>();
    if (!contextDatas.isEmpty()) {
      int i = 0;
      for (IContextParameter para : contextDatas) {
        String sourceId = para.getSource();
        if (IContextParameter.BUILT_IN.equals(sourceId)) {
          sourceId = para.getSource();
          ContextTableTabParentModel firstLevelNode = new ContextTableTabParentModel();
          String sourceLabel = sourceId;
          ContextItem contextItem = ContextUtils.getContextItemById2(sourceId);
          if (contextItem != null) {
            sourceLabel = contextItem.getProperty().getLabel();
            final ProjectManager pm = ProjectManager.getInstance();
            if (!pm.isInCurrentMainProject(contextItem)) {
              final Project project = pm.getProject(contextItem);
              if (project != null) {
                firstLevelNode.setProjectLabel(project.getLabel());
              }
            }
          }
          firstLevelNode.setOrder(i);
          firstLevelNode.setSourceName(sourceLabel);
          firstLevelNode.setSourceId(sourceId);
          firstLevelNode.setContextParameter(para);
          output.add(firstLevelNode);
        } else {
          ContextTableTabParentModel firstLevelNode = null;
          if (sourceId != null) {
            firstLevelNode = lookupContextParentForNonBuiltinNode(sourceId, output);
            if (firstLevelNode == null) {
              firstLevelNode = new ContextTableTabParentModel();
              output.add(firstLevelNode);
              String sourceLabel = sourceId;
              // the item maybe a joblet item now
              Item contextItem = ContextUtils.getRepositoryContextItemById(sourceId);
              if (contextItem != null) {
                sourceLabel = contextItem.getProperty().getLabel();
                final ProjectManager pm = ProjectManager.getInstance();
                if (!pm.isInCurrentMainProject(contextItem)) {
                  final Project project = pm.getProject(contextItem);
                  if (project != null) {
                    firstLevelNode.setProjectLabel(project.getLabel());
                  }
                }
              }
              firstLevelNode.setSourceName(sourceLabel);
              firstLevelNode.setOrder(i);
              firstLevelNode.setSourceId(sourceId);
            }

            ContextTableTabChildModel child = new ContextTableTabChildModel();
            child.setSourceId(sourceId);
            child.setContextParameter(para);
            child.setParent(firstLevelNode);
            firstLevelNode.addChild(child);
          }
        }
        i++;
      }
    }
    return output;
  }