Ejemplo n.º 1
0
  @Override
  public ICResourceDescription getResDesc(ICConfigurationDescription cf) {
    IAdaptable ad = getElement();

    if (isForProject()) return cf.getRootFolderDescription();
    ICResourceDescription out = null;
    IResource res = (IResource) ad;
    IPath p = res.getProjectRelativePath();
    if (isForFolder() || isForFile()) {
      if (cf instanceof ICMultiItemsHolder) {
        out = cf.getResourceDescription(p, isForFolder()); // sic !
      } else {
        out = cf.getResourceDescription(p, false);
        if (!p.equals(out.getPath())) {
          try {
            if (isForFolder()) out = cf.createFolderDescription(p, (ICFolderDescription) out);
            else out = cf.createFileDescription(p, out);
          } catch (CoreException e) {
            System.out.println(
                Messages.AbstractPage_10
                    + p.toOSString()
                    + "\n"
                    + e.getLocalizedMessage()); // $NON-NLS-1$
          }
        }
      }
    }
    return out;
  }
  private void initLanguageSettings(IProject project) throws CoreException {
    ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(project);

    if (prjDesc == null) throw new IllegalArgumentException("No valid CDT project given!");

    ICConfigurationDescription activeConfig = prjDesc.getActiveConfiguration();

    if (activeConfig == null)
      throw new IllegalArgumentException("No valid active configuration found!");

    String[] extensionsToInclude = getExtensionsToInclude(project);
    ICFolderDescription folderDesc = activeConfig.getRootFolderDescription();

    for (ICLanguageSetting ls : folderDesc.getLanguageSettings()) {
      String[] extensions = ls.getSourceExtensions();
      Arrays.sort(extensions);

      if (Arrays.equals(extensionsToInclude, extensions)) {
        languageSettings.add(ls);
      }
    }
  }