Ejemplo n.º 1
0
  public IToolChain getBaseToolChain() {
    ITool tools[] = getToolsToInvoke();
    ITool baseTool = null;
    for (int i = 0; i < tools.length; i++) {
      ITool tool = tools[i];
      ITool superTool = tool.getSuperClass();
      if (superTool != null) {
        baseTool = superTool;
        if (!superTool.isExtensionElement()) {
          break;
        }
      }
    }

    IToolChain baseTc = null;
    if (baseTool != null) {
      IBuildObject parent = baseTool.getParent();
      if (parent instanceof IToolChain) {
        baseTc = (IToolChain) parent;
      } else if (parent instanceof ResourceConfiguration) {
        baseTc = ((ResourceConfiguration) parent).getBaseToolChain();
      }
    }

    return baseTc;
  }
Ejemplo n.º 2
0
  /**
   * Create a new resource configuration based on one already defined.
   *
   * @param cfg The <code>IConfiguration</code> the resource configuration will be added to.
   * @param cloneConfig The <code>ResourceConfiguration</code> to copy the settings from.
   * @param id A unique ID for the new resource configuration.
   */
  public ResourceConfiguration(
      IConfiguration cfg,
      ResourceConfiguration cloneConfig,
      String id,
      Map<IPath, Map<String, String>> superClassIdMap,
      boolean cloneChildren) {
    super(cfg, cloneConfig, id);

    isExtensionResourceConfig = cfg.isExtensionElement();
    if (!cloneConfig.isExtensionResourceConfig) cloneChildren = true;

    if (!isExtensionResourceConfig) setResourceData(new BuildFileData(this));

    setManagedBuildRevision(cloneConfig.getManagedBuildRevision());

    //  Copy the remaining attributes
    if (cloneConfig.toolsToInvoke != null) {
      toolsToInvoke = new String(cloneConfig.toolsToInvoke);
    }
    if (cloneConfig.rcbsApplicability != null) {
      rcbsApplicability = new Integer(cloneConfig.rcbsApplicability.intValue());
    }

    boolean copyIds = cloneChildren && id.equals(cloneConfig.id);
    // Clone the resource configuration's tool children
    if (cloneConfig.toolList != null) {
      for (ITool toolChild : cloneConfig.getToolList()) {
        String subId = null;
        String subName;

        Map<String, String> curIdMap = superClassIdMap.get(cloneConfig.getPath());
        ITool extTool = ManagedBuildManager.getExtensionTool(toolChild);
        if (curIdMap != null) {
          if (extTool != null) {
            subId = curIdMap.get(extTool.getId());
          }
        }

        subName = toolChild.getName();

        if (subId == null) {
          if (extTool != null) {
            subId =
                copyIds
                    ? toolChild.getId()
                    : ManagedBuildManager.calculateChildId(extTool.getId(), null);
            //					subName = toolChild.getSuperClass().getName();
          } else {
            subId =
                copyIds
                    ? toolChild.getId()
                    : ManagedBuildManager.calculateChildId(toolChild.getId(), null);
            //					subName = toolChild.getName();
          }
        }

        //  The superclass for the cloned tool is not the same as the one from the tool being
        // cloned.
        //  The superclasses reside in different configurations.
        ITool toolSuperClass = null;
        String superId = null;
        //  Search for the tool in this configuration that has the same grand-superClass as the
        //  tool being cloned
        ITool otherSuperTool = toolChild.getSuperClass();
        if (otherSuperTool != null) {
          if (otherSuperTool.isExtensionElement()) {
            toolSuperClass = otherSuperTool;
          } else {
            IResourceInfo otherRcInfo = otherSuperTool.getParentResourceInfo();
            IResourceInfo thisRcInfo = cfg.getResourceInfo(otherRcInfo.getPath(), true);
            ITool otherExtTool = ManagedBuildManager.getExtensionTool(otherSuperTool);
            if (otherExtTool != null) {
              if (thisRcInfo != null) {
                ITool tools[] = thisRcInfo.getTools();
                for (int i = 0; i < tools.length; i++) {
                  ITool thisExtTool = ManagedBuildManager.getExtensionTool(tools[i]);
                  if (otherExtTool.equals(thisExtTool)) {
                    toolSuperClass = tools[i];
                    superId = toolSuperClass.getId();
                    break;
                  }
                }
              } else {
                superId =
                    copyIds
                        ? otherSuperTool.getId()
                        : ManagedBuildManager.calculateChildId(otherExtTool.getId(), null);
                Map<String, String> idMap = superClassIdMap.get(otherRcInfo.getPath());
                if (idMap == null) {
                  idMap = new HashMap<String, String>();
                  superClassIdMap.put(otherRcInfo.getPath(), idMap);
                }
                idMap.put(otherExtTool.getId(), superId);
              }
            }
          }
        }
        //				IToolChain tCh = cloneConfig.getBaseToolChain();
        //				if(tCh != null){
        //					if(!tCh.isExtensionElement()){
        //						IFolderInfo fo = tCh.getParentFolderInfo();
        //						IPath path = fo.getPath();
        //						IResourceInfo baseFo = cfg.getResourceInfo(path, false);
        //						if(baseFo instanceof IFileInfo)
        //							baseFo = cfg.getResourceInfo(path.removeLastSegments(1), false);
        //						tCh = ((IFolderInfo)baseFo).getToolChain();
        //
        //					}
        //					ITool[] tools = tCh.getTools();
        //					for (int i=0; i<tools.length; i++) {
        //					    ITool configTool = tools[i];
        //					    if (toolChild.getSuperClass() != null
        //					    		&& configTool.getSuperClass() == toolChild.getSuperClass().getSuperClass())
        //					    {
        //					        toolSuperClass = configTool;
        //					        break;
        //					    }
        //					}
        //				} else {
        //					//TODO:
        //				}

        Tool newTool = null;
        if (toolSuperClass != null)
          newTool = new Tool(this, toolSuperClass, subId, subName, (Tool) toolChild);
        else newTool = new Tool(this, superId, subId, subName, (Tool) toolChild);

        addTool(newTool);
      }
    }

    if (copyIds) {
      isDirty = cloneConfig.isDirty;
      needsRebuild = cloneConfig.needsRebuild;
    } else {
      setDirty(true);
      setRebuildState(true);
    }
  }