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;
 }
  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;
  }
 private void removeChildModelInGroupBySource(ContextTableTabChildModel child) {
   IContextParameter contextPara = child.getContextParameter();
   String sourceId = contextPara.getSource();
   String contextName = contextPara.getName();
   modelManager.onContextRemoveParameter(getContextManager(), contextName, sourceId);
 }