/**
  * ggu Comment method "getContextItemById".
  *
  * <p>bug 13184
  */
 public ContextItem getContextItemById(String id) {
   if (!isValid(id)) {
     return null;
   }
   Set<ContextItem> itemSet = getContextItems();
   for (ContextItem item : itemSet) {
     if (item.getProperty().getId().equals(id)) {
       return item;
     }
   }
   return null;
 }
예제 #2
0
  private void createSourceArea(Composite parent) {
    if (source != null && source instanceof ContextItem) {
      ContextItem contextItem = (ContextItem) source;

      Composite inner = new Composite(parent, SWT.NONE);
      GridLayout gridLayout = new GridLayout(2, false);
      gridLayout.marginHeight = 0;
      inner.setLayout(gridLayout);
      inner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      Label label = new Label(inner, SWT.NONE);
      label.setText(Messages.getString("ContextSetsSelectionDialog.Source")); // $NON-NLS-1$

      Label source = new Label(inner, SWT.NONE);
      source.setText(
          contextItem.getProperty().getLabel()
              + " "
              + contextItem.getProperty().getVersion()); // $NON-NLS-1$
      source.setForeground(new Color(null, 255, 0, 0));
    }
  }
 /**
  * get the ContextItem from the name.
  *
  * @deprecated by 13184
  */
 @Deprecated
 public ContextItem getContextItemByName(String name) {
   if (!isValid(name)) {
     return null;
   }
   Set<ContextItem> itemSet = getContextItems();
   for (ContextItem item : itemSet) {
     if (item.getProperty().getLabel().equals(name)) {
       return item;
     }
   }
   return null;
 }
 /**
  * ggu Comment method "existParameterForJob".
  *
  * <p>check that the obj is existed in job context.
  */
 public boolean existParameterForJob(Object obj, List<ContextItem> allContextItems) {
   if (!isValid(obj)) {
     return false;
   }
   if (allContextItems == null) {
     allContextItems = new ArrayList<ContextItem>(getContextItems());
   }
   if (obj instanceof ContextItem) {
     Set<String> paramSet =
         this.itemNameToParametersMap.get(((ContextItem) obj).getProperty().getId());
     return paramSet != null && !paramSet.isEmpty();
   } else if (obj instanceof ContextParameterType) {
     ContextItem contextItem = (ContextItem) getParentContextItem(obj, allContextItems);
     if (contextItem != null) {
       Set<String> paramSet = this.itemNameToParametersMap.get(contextItem.getProperty().getId());
       return paramSet != null && paramSet.contains(((ContextParameterType) obj).getName());
     }
   }
   return false;
 }
  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;
  }