コード例 #1
0
 /*
  * get default ContextType from ContextItem
  */
 public static ContextType getDefaultContextType(ContextItem item) {
   if (!isValid(item)) {
     return null;
   }
   for (Object obj : item.getContext()) {
     ContextType type = (ContextType) obj;
     if (type.getName().equals(item.getDefaultContext())) {
       return type;
     }
   }
   return null;
 }
コード例 #2
0
 /*
  * get sibling objecte of the object(include self).
  */
 public Set getSiblingContextObject(Object obj, List<ContextItem> allContextItems) {
   if (!isValid(obj)) {
     return null;
   }
   if (allContextItems == null) {
     allContextItems = new ArrayList<ContextItem>(getContextItems());
   }
   if (allContextItems != null) {
     if (obj instanceof ContextItem) {
       return new HashSet(allContextItems);
     }
     // for SelectRepositoryContextDialog
     if (obj instanceof ContextParameterType) {
       for (ContextItem contextItem : allContextItems) {
         for (Object objType : contextItem.getContext()) {
           ContextType type = (ContextType) objType;
           if (type.getName().equals(contextItem.getDefaultContext())) {
             List paramList = type.getContextParameter();
             if (paramList != null && paramList.contains(obj)) {
               return new HashSet(paramList);
             }
           }
         }
       }
     }
     // for SelectRepositoryContextGroupDialog
     if (obj instanceof ContextType) {
       for (ContextItem contextItem : allContextItems) {
         if (contextItem.getContext().contains(obj)) {
           return new HashSet(contextItem.getContext());
         }
       }
     }
   }
   return null;
 }
コード例 #3
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);
         }
       }
     }
   }
 }