예제 #1
0
  private IToolChain getDefaultToolChain() {
    IResourceInfo rcInfo = getResourceInfo();
    IToolChain defaultTc = null;
    if (rcInfo.getPath().segmentCount() == 0) {
      //			1.Per-project : change to the "default" tool-chain defined in the extension
      //			super-class of the project configuration. NOTE: the makefile project case might
      //			need a special handling in this case.

      IConfiguration cfg = rcInfo.getParent();
      IConfiguration extCfg = cfg.getParent();
      defaultTc = extCfg.getToolChain();
      if (defaultTc == null) {
        if (cfg.getToolChain() != null) {
          defaultTc = cfg.getToolChain().getSuperClass();
        }
      }
    } else {
      //			2.per-folder : change to the same tool-chain as the one used by the parent
      //			folder.
      IFolderInfo parentFo = ((ResourceInfo) rcInfo).getParentFolderInfo();
      IToolChain tc = parentFo.getToolChain();
      defaultTc = ManagedBuildManager.getExtensionToolChain(tc);
    }

    if (defaultTc != null && defaultTc.getId().equals(ConfigurationDataProvider.PREF_TC_ID))
      defaultTc = null;

    return defaultTc;
  }
예제 #2
0
 @Override
 protected Tool[] filterTools(Tool[] tools) {
   IResourceInfo rcInfo = getResourceInfo();
   return (Tool[])
       ((FolderInfo) rcInfo).filterTools(tools, rcInfo.getParent().getManagedProject());
 }
예제 #3
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);
    }
  }