public IContextParameter getRealParameter(
     IContextManager manager, String property, Object element) {
   IContextParameter para = null;
   IContext context = null;
   if (manager != null) {
     context = manager.getContext(property);
     if (context == null) {
       return null;
     }
     if (element instanceof ContextTableTabParentModel) {
       if (IContextParameter.BUILT_IN.equals(
           ((ContextTableTabParentModel) element).getSourceId())) {
         IContextParameter builtContextParameter =
             ((ContextTableTabParentModel) element).getContextParameter();
         if (builtContextParameter != null) {
           para = context.getContextParameter(builtContextParameter.getName());
         }
       }
     } else if (element instanceof ContextTableTabChildModel) {
       ContextTableTabChildModel child = (ContextTableTabChildModel) element;
       String sourceId = child.getContextParameter().getSource();
       para =
           context.getContextParameter(
               sourceId, ((ContextTableTabChildModel) element).getContextParameter().getName());
     }
   }
   return para;
 }
 private void removeParentModelInGroupBySource(ContextTableTabParentModel parentModel) {
   Set<String> paraNames = new HashSet<String>();
   String sourceId = parentModel.getSourceId();
   if (IContextParameter.BUILT_IN.equals(sourceId)) {
     String paraName = parentModel.getContextParameter().getName();
     paraNames.add(paraName);
   } else {
     List<ContextTabChildModel> children = parentModel.getChildren();
     if (children != null && children.size() > 0) {
       for (ContextTabChildModel child : children) {
         IContextParameter contextPara = child.getContextParameter();
         String paraName = contextPara.getName();
         paraNames.add(paraName);
       }
     }
   }
   modelManager.onContextRemoveParameter(getContextManager(), paraNames, sourceId);
 }
  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;
  }