Beispiel #1
0
  public ResourceConfiguration(ResourceConfiguration baseInfo, IPath path, String id, String name) {
    super(baseInfo, path, id, name);

    isExtensionResourceConfig = false;
    setResourceData(new BuildFileData(this));

    setManagedBuildRevision(baseInfo.getManagedBuildRevision());

    //  Copy the remaining attributes
    toolsToInvoke = baseInfo.toolsToInvoke;

    rcbsApplicability = new Integer(KIND_DISABLE_RCBS_TOOL);

    // Clone the resource configuration's tool children
    if (baseInfo.toolList != null) {
      for (ITool toolChild : baseInfo.getToolList()) {
        ITool superTool = toolChild.getSuperClass();
        String baseId = superTool != null ? superTool.getId() : toolChild.getId();
        String subId = ManagedBuildManager.calculateChildId(baseId, null);
        String subName = toolChild.getName();

        Tool newTool = new Tool(this, superTool, subId, subName, (Tool) toolChild);
        addTool(newTool);
      }
    }

    setDirty(true);
    setRebuildState(true);
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
   */
  @Override
  protected void createFieldEditors() {

    // Load up the preference store
    super.createFieldEditors();
    // Add a string editor to edit the tool command
    Composite parent = getFieldEditorParent();
    FontMetrics fm = AbstractCPropertyTab.getFontMetrics(parent);
    commandStringField =
        new StringFieldEditor(fTool.getId(), Messages.BuildToolSettingsPage_tool_command, parent);
    commandStringField.setEmptyStringAllowed(false);
    GridData gd = ((GridData) commandStringField.getTextControl(parent).getLayoutData());
    gd.grabExcessHorizontalSpace = true;
    gd.minimumWidth = Dialog.convertWidthInCharsToPixels(fm, 3);
    addField(commandStringField);
    // Add a field editor that displays overall build options
    Composite par = getFieldEditorParent();
    allOptionFieldEditor =
        new MultiLineTextFieldEditor(ToolSettingsPrefStore.ALL_OPTIONS_ID, ALL_OPTIONS, par);
    allOptionFieldEditor.getTextControl(par).setEditable(false);
    //		gd = ((GridData)allOptionFieldEditor.getTextControl().getLayoutData());
    gd.grabExcessHorizontalSpace = true;
    gd.minimumWidth = Dialog.convertWidthInCharsToPixels(fm, 20);
    addField(allOptionFieldEditor);

    addField(createLabelEditor(getFieldEditorParent(), WHITESPACE));
    addField(
        createLabelEditor(
            getFieldEditorParent(), Messages.BuildToolSettingsPage_tool_advancedSettings));

    // Add a string editor to edit the tool command line pattern
    parent = getFieldEditorParent();
    commandLinePatternField =
        new StringFieldEditor(
            fTool.getId() + ToolSettingsPrefStore.COMMAND_LINE_SUFFIX,
            Messages.BuildToolSettingsPage_tool_commandLinePattern,
            parent);
    gd = ((GridData) commandLinePatternField.getTextControl(parent).getLayoutData());
    gd.grabExcessHorizontalSpace = true;
    gd.widthHint = Dialog.convertWidthInCharsToPixels(fm, 30);
    gd.minimumWidth = Dialog.convertWidthInCharsToPixels(fm, 20);
    addField(commandLinePatternField);
  }
Beispiel #3
0
  @Override
  void applyToolsInternal(ITool[] resultingTools, ToolListModificationInfo info) {
    List<ITool> list = getToolList();
    Map<String, ITool> map = getToolMap();

    list.clear();
    map.clear();

    list.addAll(Arrays.asList(resultingTools));
    for (int i = 0; i < resultingTools.length; i++) {
      ITool tool = resultingTools[i];
      map.put(tool.getId(), tool);
    }

    setRebuildState(true);
  }
 private ITool getTool(IBuildObject cfgBo, String id) {
   IResourceConfiguration rcCfg = null;
   IConfiguration cfg = null;
   ITool tool = null;
   if (cfgBo instanceof IResourceConfiguration) {
     rcCfg = (IResourceConfiguration) cfgBo;
     cfg = rcCfg.getParent();
     ITool tools[] = rcCfg.getTools();
     for (int i = 0; i < tools.length; i++) {
       for (ITool tmp = tools[i]; tmp != null; tmp = tmp.getSuperClass()) {
         if (tmp.getId().equals(id)) {
           tool = tools[i];
           break;
         }
       }
     }
   } else if (cfgBo instanceof IConfiguration) {
     cfg = (IConfiguration) cfgBo;
     tool = cfg.getToolsBySuperClassId(id)[0];
   } else fail("wrong argument");
   return tool;
 }
Beispiel #5
0
  public ResourceConfiguration(
      FolderInfo folderInfo, ITool baseTool, String id, String resourceName, IPath path) {
    super(folderInfo, path, id, resourceName);
    //		setParentFolder(folderInfo);
    //		setParentFolderId(folderInfo.getId());

    isExtensionResourceConfig = folderInfo.isExtensionElement();
    if (!isExtensionResourceConfig) setResourceData(new BuildFileData(this));

    if (folderInfo.getParent() != null)
      setManagedBuildRevision(folderInfo.getParent().getManagedBuildRevision());

    setDirty(false);
    toolsToInvoke = EMPTY_STRING;
    rcbsApplicability = new Integer(KIND_DISABLE_RCBS_TOOL);

    //	Get file extension.
    String extString = path.getFileExtension();
    if (baseTool != null) {
      if (baseTool.getParentResourceInfo() != folderInfo) baseTool = null;
    }
    // Add the resource specific tools to this resource.
    ITool tools[] = folderInfo.getFilteredTools();
    String subId = new String();
    for (int i = 0; i < tools.length; i++) {
      if (tools[i].buildsFileType(extString)) {
        baseTool = tools[i];
        break;
      }
    }

    if (baseTool != null) {
      subId = ManagedBuildManager.calculateChildId(baseTool.getId(), null);
      createTool(baseTool, subId, baseTool.getName(), false);
      setRebuildState(true);
    }
  }
Beispiel #6
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);
    }
  }
 private String getCompilerFlags(String compiler) throws BuildException {
   for (ITool tool : config.getToolChain().getTools()) {
     if (tool.getId().startsWith(compiler)) return tool.getToolCommandFlagsString(null, null);
   }
   return EMPTY_STRING;
 }