org.eclipse.jst.common.project.facet.core_1.4.200.v201103170302

16:45:41.024 INFO  jd.cli.Main - Decompiling org.eclipse.jst.common.project.facet.core_1.4.200.v201103170302.jar
package org.eclipse.jst.common.project.facet.core;

import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jst.common.project.facet.core.internal.ClasspathUtil;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.common.project.facet.core.runtime.IRuntime;

public final class ClasspathHelper
{
  public static final String LEGACY_METADATA_FILE_NAME = ".settings/org.eclipse.jst.common.project.facet.core.prefs";
  
  public static boolean addClasspathEntries(IProject project, IProjectFacetVersion fv)
    throws CoreException
  {
    IFacetedProject fproj = ProjectFacetsManager.create(project);
    IRuntime runtime = fproj.getPrimaryRuntime();
    if (runtime != null)
    {
      IClasspathProvider cpprov = 
        (IClasspathProvider)runtime.getAdapter(IClasspathProvider.class);
      
      List<IClasspathEntry> cpentries = cpprov.getClasspathEntries(fv);
      if (cpentries != null)
      {
        addClasspathEntries(project, fv, cpentries);
        return true;
      }
    }
    return false;
  }
  
  public static void addClasspathEntries(IProject project, IProjectFacetVersion fv, List<IClasspathEntry> cpentries)
    throws CoreException
  {
    ClasspathUtil.addClasspathEntries(project, fv.getProjectFacet(), cpentries);
  }
  
  public static void removeClasspathEntries(IProject project, IProjectFacetVersion fv)
    throws CoreException
  {
    ClasspathUtil.removeClasspathEntries(project, fv.getProjectFacet());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.project.facet.core.ClasspathHelper
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.project.facet.core;

import java.util.List;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;

public abstract interface IClasspathProvider
{
  public abstract List<IClasspathEntry> getClasspathEntries(IProjectFacetVersion paramIProjectFacetVersion);
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.project.facet.core.IClasspathProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.project.facet.core;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jst.common.project.facet.core.internal.FacetedProjectFrameworkJavaPlugin;
import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework;
import org.eclipse.wst.common.project.facet.core.IProjectFacet;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;

public final class JavaFacet
{
  public static final String ID = "java";
  public static final IProjectFacet FACET = ProjectFacetsManager.getProjectFacet("java");
  public static final IProjectFacetVersion VERSION_1_3 = FACET.getVersion("1.3");
  public static final IProjectFacetVersion VERSION_1_4 = FACET.getVersion("1.4");
  public static final IProjectFacetVersion VERSION_1_5 = FACET.getVersion("1.5");
  public static final IProjectFacetVersion VERSION_1_6 = FACET.getVersion("1.6");
  public static final IProjectFacetVersion VERSION_1_7 = FACET.getVersion("1.7");
  @Deprecated
  public static final IProjectFacetVersion JAVA_13 = VERSION_1_3;
  @Deprecated
  public static final IProjectFacetVersion JAVA_14 = VERSION_1_4;
  @Deprecated
  public static final IProjectFacetVersion JAVA_50 = VERSION_1_5;
  @Deprecated
  public static final IProjectFacetVersion JAVA_60 = VERSION_1_6;
  
  public static boolean isInstalled(IProject project)
  {
    try
    {
      return FacetedProjectFramework.hasProjectFacet(project, "java");
    }
    catch (CoreException e)
    {
      FacetedProjectFrameworkJavaPlugin.log(e);
    }
    return false;
  }
  
  public static boolean isJavaProject(IProject project)
  {
    try
    {
      return project.getNature("org.eclipse.jdt.core.javanature") != null;
    }
    catch (CoreException localCoreException) {}
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.project.facet.core.JavaFacet
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.project.facet.core;

public enum JavaFacetInstallConfig$ChangeEvent$Type
{
  SOURCE_FOLDERS_CHANGED,  DEFAULT_OUTPUT_FOLDER_CHANGED;
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig.ChangeEvent.Type
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.project.facet.core;

public class JavaFacetInstallConfig$ChangeEvent
{
  private final Type type;
  private final JavaFacetInstallConfig installConfig;
  
  public static enum Type
  {
    SOURCE_FOLDERS_CHANGED,  DEFAULT_OUTPUT_FOLDER_CHANGED;
  }
  
  JavaFacetInstallConfig$ChangeEvent(Type type, JavaFacetInstallConfig installConfig)
  {
    this.type = type;
    this.installConfig = installConfig;
  }
  
  public final Type getType()
  {
    return type;
  }
  
  public final JavaFacetInstallConfig getJavaFacetInstallConfig()
  {
    return installConfig;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig.ChangeEvent
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.project.facet.core;

import org.eclipse.core.runtime.IPath;

abstract class JavaFacetInstallConfig$Folder
{
  public final IPath path;
  
  public JavaFacetInstallConfig$Folder(IPath path)
  {
    this.path = path;
  }
  
  public abstract String getTypeLabel();
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig.Folder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.project.facet.core;

import org.eclipse.core.runtime.IPath;

final class JavaFacetInstallConfig$OutputFolder
  extends JavaFacetInstallConfig.Folder
{
  public JavaFacetInstallConfig$OutputFolder(IPath path)
  {
    super(path);
  }
  
  public String getTypeLabel()
  {
    return JavaFacetInstallConfig.Resources.outputFolderType;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig.OutputFolder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.project.facet.core;

import org.eclipse.osgi.util.NLS;

final class JavaFacetInstallConfig$Resources
  extends NLS
{
  public static String mustSpecifySourceFolderMessage;
  public static String mustSpecifyDefaultOutputFolderMessage;
  public static String nonUniqueSourceFolderMessage;
  public static String cannotNestFoldersMessage;
  public static String sourceFolderType;
  public static String outputFolderType;
  
  static
  {
    initializeMessages(JavaFacetInstallConfig.class.getName(), Resources.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig.Resources
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.project.facet.core;

import org.eclipse.core.runtime.IPath;

final class JavaFacetInstallConfig$SourceFolder
  extends JavaFacetInstallConfig.Folder
{
  public JavaFacetInstallConfig$SourceFolder(IPath path)
  {
    super(path);
  }
  
  public String getTypeLabel()
  {
    return JavaFacetInstallConfig.Resources.sourceFolderType;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig.SourceFolder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.project.facet.core;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileSystem;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProduct;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jst.common.project.facet.core.internal.FacetCorePlugin;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.project.facet.core.ActionConfig;
import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;
import org.eclipse.wst.common.project.facet.core.util.EventListenerRegistry;
import org.eclipse.wst.common.project.facet.core.util.IEventListener;

public class JavaFacetInstallConfig
  extends ActionConfig
{
  private static final String PROD_PROP_OUTPUT_FOLDER = "defaultJavaOutputFolder";
  private static final String PROD_PROP_OUTPUT_FOLDER_LEGACY = "outputFolder";
  private static final String DEFAULT_OUTPUT_FOLDER = "build/classes";
  
  public static class ChangeEvent
  {
    private final Type type;
    private final JavaFacetInstallConfig installConfig;
    
    public static enum Type
    {
      SOURCE_FOLDERS_CHANGED,  DEFAULT_OUTPUT_FOLDER_CHANGED;
    }
    
    ChangeEvent(Type type, JavaFacetInstallConfig installConfig)
    {
      this.type = type;
      this.installConfig = installConfig;
    }
    
    public final Type getType()
    {
      return type;
    }
    
    public final JavaFacetInstallConfig getJavaFacetInstallConfig()
    {
      return installConfig;
    }
  }
  
  private boolean caseSensitiveFs = EFS.getLocalFileSystem().isCaseSensitive();
  private EventListenerRegistry<JavaFacetInstallConfig.ChangeEvent.Type, ChangeEvent> listeners;
  private List<IPath> sourceFolders;
  private List<IPath> sourceFoldersReadOnly;
  private IPath defaultOutputFolder;
  
  public JavaFacetInstallConfig()
  {
    listeners = new EventListenerRegistry(JavaFacetInstallConfig.ChangeEvent.Type.class);
    
    sourceFolders = new CopyOnWriteArrayList();
    sourceFoldersReadOnly = Collections.unmodifiableList(sourceFolders);
    defaultOutputFolder = null;
    
    String sourceFolder = FacetCorePlugin.getJavaSrcFolder();
    
    sourceFolders.add(new Path(sourceFolder));
    
    String outputFolder = getProductProperty("defaultJavaOutputFolder");
    if (outputFolder == null) {
      outputFolder = getProductProperty("outputFolder");
    }
    if (outputFolder == null) {
      outputFolder = "build/classes";
    }
    defaultOutputFolder = new Path(outputFolder);
  }
  
  public Set<IFile> getValidateEditFiles()
  {
    Set<IFile> files = super.getValidateEditFiles();
    IProject project = getFacetedProjectWorkingCopy().getProject();
    if (project != null)
    {
      files.add(project.getFile(".project"));
      files.add(project.getFile(".classpath"));
      files.add(project.getFile(".settings/org.eclipse.jdt.core.prefs"));
      files.add(project.getFile(".settings/org.eclipse.jst.common.project.facet.core.prefs"));
    }
    return files;
  }
  
  public IStatus validate()
  {
    IStatus status = Status.OK_STATUS;
    
    List<Folder> folders = new ArrayList();
    for (IPath sourceFolder : sourceFolders) {
      folders.add(new SourceFolder(sourceFolder));
    }
    folders.add(new OutputFolder(defaultOutputFolder));
    while (!folders.isEmpty())
    {
      Folder folder = (Folder)folders.remove(0);
      status = validateFolder(folders, folder);
      if (!status.isOK()) {
        break;
      }
    }
    return status;
  }
  
  public IStatus validateSourceFolder(String candidateSourceFolder)
  {
    if (candidateSourceFolder == null) {
      throw new IllegalArgumentException();
    }
    List<Folder> folders = new ArrayList();
    for (IPath sourceFolder : sourceFolders) {
      folders.add(new SourceFolder(sourceFolder));
    }
    folders.add(new OutputFolder(defaultOutputFolder));
    
    return validateFolder(folders, new SourceFolder(new Path(candidateSourceFolder.trim())));
  }
  
  private IStatus validateFolder(List<Folder> existingFolders, Folder folder)
  {
    IStatus status = Status.OK_STATUS;
    if (path.segmentCount() == 0)
    {
      if ((folder instanceof SourceFolder)) {
        status = new Status(4, "org.eclipse.jst.common.project.facet.core", Resources.mustSpecifySourceFolderMessage);
      } else {
        status = new Status(4, "org.eclipse.jst.common.project.facet.core", Resources.mustSpecifyDefaultOutputFolderMessage);
      }
    }
    else
    {
      String pjname = getFacetedProjectWorkingCopy().getProjectName();
      String fullPath = "/" + pjname + "/" + path;
      
      status = ResourcesPlugin.getWorkspace().validatePath(fullPath, 2);
      if (status.isOK()) {
        for (Folder existingFolder : existingFolders)
        {
          status = validateFolder(existingFolder, folder);
          if (!status.isOK()) {
            break;
          }
        }
      }
    }
    return status;
  }
  
  private IStatus validateFolder(Folder existingPath, Folder newPath)
  {
    int existingPathLen = path.segmentCount();
    int newPathLen = path.segmentCount();
    int minPathLen = Math.min(existingPathLen, newPathLen);
    if (minPathLen == 0) {
      return Status.OK_STATUS;
    }
    for (int i = 0; i < minPathLen; i++) {
      if (!comparePathSegments(path.segment(i), path.segment(i))) {
        return Status.OK_STATUS;
      }
    }
    String message = null;
    if (existingPathLen == newPathLen)
    {
      if (((existingPath instanceof SourceFolder)) && ((newPath instanceof SourceFolder))) {
        message = NLS.bind(Resources.nonUniqueSourceFolderMessage, path);
      }
    }
    else
    {
      Folder y;
      Folder x;
      Folder y;
      if (existingPathLen > newPathLen)
      {
        Folder x = newPath;
        y = existingPath;
      }
      else
      {
        x = existingPath;
        y = newPath;
      }
      message = NLS.bind(Resources.cannotNestFoldersMessage, new Object[] { path, x.getTypeLabel(), path, y.getTypeLabel() });
    }
    if (message == null) {
      return Status.OK_STATUS;
    }
    return new Status(4, "org.eclipse.jst.common.project.facet.core", message);
  }
  
  private boolean comparePathSegments(String a, String b)
  {
    return ((caseSensitiveFs) && (a.equals(b))) || ((!caseSensitiveFs) && (a.equalsIgnoreCase(b)));
  }
  
  public List<IPath> getSourceFolders()
  {
    return sourceFoldersReadOnly;
  }
  
  public void setSourceFolders(List<IPath> paths)
  {
    if (!sourceFolders.equals(paths))
    {
      sourceFolders.clear();
      sourceFolders.addAll(paths);
      
      ChangeEvent event = new ChangeEvent(JavaFacetInstallConfig.ChangeEvent.Type.SOURCE_FOLDERS_CHANGED, this);
      listeners.notifyListeners(JavaFacetInstallConfig.ChangeEvent.Type.SOURCE_FOLDERS_CHANGED, event);
    }
  }
  
  public void setSourceFolder(IPath path)
  {
    List<IPath> newSourceFolders;
    List<IPath> newSourceFolders;
    if (path == null) {
      newSourceFolders = Collections.emptyList();
    } else {
      newSourceFolders = Collections.singletonList(path);
    }
    setSourceFolders(newSourceFolders);
  }
  
  public void addSourceFolder(IPath path)
  {
    if (path == null) {
      throw new IllegalArgumentException();
    }
    List<IPath> newSourceFolders = new ArrayList(getSourceFolders());
    newSourceFolders.add(path);
    setSourceFolders(newSourceFolders);
  }
  
  public void removeSourceFolder(IPath path)
  {
    List<IPath> newSourceFolders = new ArrayList(getSourceFolders());
    newSourceFolders.remove(path);
    setSourceFolders(newSourceFolders);
  }
  
  public IPath getDefaultOutputFolder()
  {
    return defaultOutputFolder;
  }
  
  public void setDefaultOutputFolder(IPath defaultOutputFolder)
  {
    if (!equal(this.defaultOutputFolder, defaultOutputFolder))
    {
      this.defaultOutputFolder = defaultOutputFolder;
      
      ChangeEvent event = new ChangeEvent(JavaFacetInstallConfig.ChangeEvent.Type.DEFAULT_OUTPUT_FOLDER_CHANGED, this);
      listeners.notifyListeners(JavaFacetInstallConfig.ChangeEvent.Type.DEFAULT_OUTPUT_FOLDER_CHANGED, event);
    }
  }
  
  public void addListener(IEventListener<ChangeEvent> listener, JavaFacetInstallConfig.ChangeEvent.Type... types)
  {
    listeners.addListener(listener, types);
  }
  
  public void removeListener(IEventListener<ChangeEvent> listener)
  {
    listeners.removeListener(listener);
  }
  
  private static boolean equal(Object obj1, Object obj2)
  {
    if ((obj1 == null) || (obj2 == null)) {
      return false;
    }
    return obj1.equals(obj2);
  }
  
  private static String getProductProperty(String propName)
  {
    String value = null;
    if (Platform.getProduct() != null) {
      value = Platform.getProduct().getProperty(propName);
    }
    return value;
  }
  
  private static abstract class Folder
  {
    public final IPath path;
    
    public Folder(IPath path)
    {
      this.path = path;
    }
    
    public abstract String getTypeLabel();
  }
  
  private static final class SourceFolder
    extends JavaFacetInstallConfig.Folder
  {
    public SourceFolder(IPath path)
    {
      super();
    }
    
    public String getTypeLabel()
    {
      return JavaFacetInstallConfig.Resources.sourceFolderType;
    }
  }
  
  private static final class OutputFolder
    extends JavaFacetInstallConfig.Folder
  {
    public OutputFolder(IPath path)
    {
      super();
    }
    
    public String getTypeLabel()
    {
      return JavaFacetInstallConfig.Resources.outputFolderType;
    }
  }
  
  private static final class Resources
    extends NLS
  {
    public static String mustSpecifySourceFolderMessage;
    public static String mustSpecifyDefaultOutputFolderMessage;
    public static String nonUniqueSourceFolderMessage;
    public static String cannotNestFoldersMessage;
    public static String sourceFolderType;
    public static String outputFolderType;
    
    static
    {
      initializeMessages(JavaFacetInstallConfig.class.getName(), Resources.class);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.project.facet.core;

import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.wst.common.project.facet.core.ActionConfig;
import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;

public class JavaFacetUninstallConfig
  extends ActionConfig
{
  public Set<IFile> getValidateEditFiles()
  {
    Set<IFile> files = super.getValidateEditFiles();
    IProject project = getFacetedProjectWorkingCopy().getProject();
    
    files.add(project.getFile(".project"));
    files.add(project.getFile(".classpath"));
    files.add(project.getFile(".settings/org.eclipse.jdt.core.prefs"));
    files.add(project.getFile(".settings/org.eclipse.jst.common.project.facet.core.prefs"));
    
    return files;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.project.facet.core.JavaFacetUninstallConfig
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.project.facet.core;

import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.wst.common.project.facet.core.ActionConfig;
import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;

public class JavaFacetVersionChangeConfig
  extends ActionConfig
{
  public Set<IFile> getValidateEditFiles()
  {
    Set<IFile> files = super.getValidateEditFiles();
    IProject project = getFacetedProjectWorkingCopy().getProject();
    
    files.add(project.getFile(".classpath"));
    files.add(project.getFile(".settings/org.eclipse.jdt.core.prefs"));
    files.add(project.getFile(".settings/org.eclipse.jst.common.project.facet.core.prefs"));
    
    return files;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.project.facet.core.JavaFacetVersionChangeConfig
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.project.facet.core;

import java.util.HashMap;
import java.util.Map;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.IVMInstall2;
import org.eclipse.jdt.launching.IVMInstallType;
import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponent;
import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponentType;
import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponentVersion;
import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;

public final class StandardJreRuntimeComponent
{
  public static final String TYPE_ID = "standard.jre";
  public static final IRuntimeComponentType TYPE = RuntimeManager.getRuntimeComponentType("standard.jre");
  public static final IRuntimeComponentVersion VERSION_1_3 = TYPE.getVersion("1.3");
  public static final IRuntimeComponentVersion VERSION_1_4 = TYPE.getVersion("1.4");
  public static final IRuntimeComponentVersion VERSION_1_5 = TYPE.getVersion("1.5");
  public static final IRuntimeComponentVersion VERSION_1_6 = TYPE.getVersion("1.6");
  public static final IRuntimeComponentVersion VERSION_1_7 = TYPE.getVersion("1.7");
  @Deprecated
  public static final IRuntimeComponentVersion VERSION_5_0 = VERSION_1_5;
  @Deprecated
  public static final IRuntimeComponentVersion VERSION_6_0 = VERSION_1_6;
  public static final String PROP_VM_INSTALL_TYPE = "vm-install-type";
  public static final String PROP_VM_INSTALL_ID = "vm-install-id";
  
  public static IRuntimeComponent create(IVMInstall vmInstall)
  {
    String jvmver = null;
    if ((vmInstall instanceof IVMInstall2))
    {
      IVMInstall2 vmInstall2 = (IVMInstall2)vmInstall;
      jvmver = vmInstall2.getJavaVersion();
    }
    IRuntimeComponentVersion rcv;
    IRuntimeComponentVersion rcv;
    if (jvmver == null)
    {
      rcv = VERSION_1_7;
    }
    else
    {
      IRuntimeComponentVersion rcv;
      if (jvmver.startsWith("1.3"))
      {
        rcv = VERSION_1_3;
      }
      else
      {
        IRuntimeComponentVersion rcv;
        if (jvmver.startsWith("1.4"))
        {
          rcv = VERSION_1_4;
        }
        else
        {
          IRuntimeComponentVersion rcv;
          if (jvmver.startsWith("1.5"))
          {
            rcv = VERSION_1_5;
          }
          else
          {
            IRuntimeComponentVersion rcv;
            if (jvmver.startsWith("1.6"))
            {
              rcv = VERSION_1_6;
            }
            else
            {
              IRuntimeComponentVersion rcv;
              if (jvmver.startsWith("1.7")) {
                rcv = VERSION_1_7;
              } else {
                rcv = VERSION_1_7;
              }
            }
          }
        }
      }
    }
    Map<String, String> properties = new HashMap();
    if (vmInstall != null)
    {
      properties.put("vm-install-type", 
        vmInstall.getVMInstallType().getId());
      
      properties.put("vm-install-id", 
        vmInstall.getId());
    }
    return RuntimeManager.createRuntimeComponent(rcv, properties);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.project.facet.core.StandardJreRuntimeComponent
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.project.facet.core.internal;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jdt.core.IClasspathAttribute;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.core.ClasspathEntry;
import org.eclipse.wst.common.project.facet.core.IProjectFacet;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;

public final class ClasspathUtil
{
  public static final String LEGACY_METADATA_FILE_NAME = ".settings/org.eclipse.jst.common.project.facet.core.prefs";
  public static final Object SYSTEM_OWNER = new Object();
  private static final String OWNER_PROJECT_FACETS_ATTR = "owner.project.facets";
  
  public static List<IClasspathEntry> getProjectClasspath(IJavaProject project)
    throws CoreException
  {
    List<IClasspathEntry> result = new ArrayList();
    IClasspathEntry[] arrayOfIClasspathEntry;
    int j = (arrayOfIClasspathEntry = project.getRawClasspath()).length;
    for (int i = 0; i < j; i++)
    {
      IClasspathEntry cpe = arrayOfIClasspathEntry[i];
      
      result.add(cpe);
    }
    return result;
  }
  
  public static void setProjectClasspath(IJavaProject project, List<IClasspathEntry> cp)
    throws CoreException
  {
    validateClasspathEdit(project);
    project.setRawClasspath((IClasspathEntry[])cp.toArray(new IClasspathEntry[cp.size()]), null);
  }
  
  public static void addClasspathEntry(IProject project, IClasspathEntry cpe)
    throws CoreException
  {
    addClasspathEntry(JavaCore.create(project), cpe);
  }
  
  public static void addClasspathEntry(IJavaProject project, IClasspathEntry cpe)
    throws CoreException
  {
    validateClasspathEdit(project);
    
    IClasspathEntry[] cpOld = project.getRawClasspath();
    IClasspathEntry[] cpNew = new IClasspathEntry[cpOld.length + 1];
    System.arraycopy(cpOld, 0, cpNew, 0, cpOld.length);
    cpNew[cpOld.length] = cpe;
    project.setRawClasspath(cpNew, null);
  }
  
  public static List<IClasspathEntry> getClasspathEntries(IProject project, IProjectFacet facet)
    throws CoreException
  {
    IJavaProject jproj = JavaCore.create(project);
    return getClasspathEntries(jproj, facet);
  }
  
  public static List<IClasspathEntry> getClasspathEntries(IJavaProject project, IProjectFacet facet)
    throws CoreException
  {
    List<IClasspathEntry> result = new ArrayList();
    IClasspathEntry[] arrayOfIClasspathEntry;
    int j = (arrayOfIClasspathEntry = project.getRawClasspath()).length;
    for (int i = 0; i < j; i++)
    {
      IClasspathEntry cpe = arrayOfIClasspathEntry[i];
      
      Set<Object> owners = getOwners(project, cpe);
      if (owners.contains(facet)) {
        result.add(cpe);
      }
    }
    return result;
  }
  
  public static void addClasspathEntries(IProject project, IProjectFacet facet, List<IClasspathEntry> cpentries)
    throws CoreException
  {
    IJavaProject jproj = JavaCore.create(project);
    addClasspathEntries(jproj, facet, cpentries);
  }
  
  public static void addClasspathEntries(IJavaProject project, IProjectFacet facet, List<IClasspathEntry> cpentries)
    throws CoreException
  {
    validateClasspathEdit(project);
    convertLegacyMetadata(project);
    
    List<IClasspathEntry> cp = getProjectClasspath(project);
    for (IClasspathEntry cpe : cpentries)
    {
      IClasspathEntry existingClasspathEntry = null;
      for (IClasspathEntry x : cp) {
        if (x.getPath().equals(cpe.getPath()))
        {
          existingClasspathEntry = x;
          break;
        }
      }
      Set<Object> owners = getOwners(project, existingClasspathEntry);
      
      owners.add(facet);
      if (existingClasspathEntry != null)
      {
        IClasspathEntry annotatedEntry = setOwners(existingClasspathEntry, owners);
        int existingIndex = cp.indexOf(existingClasspathEntry);
        cp.set(existingIndex, annotatedEntry);
      }
      else
      {
        IClasspathEntry annotatedEntry = setOwners(cpe, owners);
        cp.add(annotatedEntry);
      }
    }
    setProjectClasspath(project, cp);
  }
  
  public static void removeClasspathEntries(IProject project, IProjectFacet facet)
    throws CoreException
  {
    IJavaProject jproj = JavaCore.create(project);
    removeClasspathEntries(jproj, facet);
  }
  
  public static void removeClasspathEntries(IJavaProject project, IProjectFacet facet)
    throws CoreException
  {
    validateClasspathEdit(project);
    convertLegacyMetadata(project);
    
    List<IClasspathEntry> cp = getProjectClasspath(project);
    boolean cpchanged = false;
    for (ListIterator<IClasspathEntry> itr = cp.listIterator(); itr.hasNext();)
    {
      IClasspathEntry cpe = (IClasspathEntry)itr.next();
      Set<Object> owners = getOwners(project, cpe);
      if (owners.remove(facet))
      {
        if (owners.size() == 0) {
          itr.remove();
        } else {
          itr.set(setOwners(cpe, owners));
        }
        cpchanged = true;
      }
    }
    if (cpchanged) {
      setProjectClasspath(project, cp);
    }
  }
  
  public static void removeClasspathEntries(IProject project, IProjectFacet facet, List<IClasspathEntry> cpentries)
    throws CoreException
  {
    IJavaProject jproj = JavaCore.create(project);
    removeClasspathEntries(jproj, facet, cpentries);
  }
  
  public static void removeClasspathEntries(IJavaProject project, IProjectFacet facet, List<IClasspathEntry> cpentries)
    throws CoreException
  {
    validateClasspathEdit(project);
    convertLegacyMetadata(project);
    
    List<IClasspathEntry> cp = getProjectClasspath(project);
    boolean cpchanged = false;
    for (ListIterator<IClasspathEntry> itr = cp.listIterator(); itr.hasNext();)
    {
      IClasspathEntry cpe = (IClasspathEntry)itr.next();
      if (cpentries.contains(cpe))
      {
        Set<Object> owners = getOwners(project, cpe);
        if (owners.remove(facet))
        {
          if (owners.size() == 0) {
            itr.remove();
          } else {
            itr.set(setOwners(cpe, owners));
          }
          cpchanged = true;
        }
      }
    }
    if (cpchanged) {
      setProjectClasspath(project, cp);
    }
  }
  
  private static Set<Object> getOwners(IJavaProject project, IClasspathEntry cpe)
    throws CoreException
  {
    Set<Object> owners = new HashSet();
    if (cpe != null)
    {
      IClasspathAttribute[] arrayOfIClasspathAttribute;
      int j = (arrayOfIClasspathAttribute = cpe.getExtraAttributes()).length;
      for (int i = 0; i < j; i++)
      {
        IClasspathAttribute attr = arrayOfIClasspathAttribute[i];
        if (attr.getName().equals("owner.project.facets"))
        {
          owners.addAll(decodeOwnersString(attr.getValue()));
          break;
        }
      }
      owners.addAll(getOwnersFromLegacyMetadata(project, cpe));
      if (owners.isEmpty()) {
        owners.add(SYSTEM_OWNER);
      }
    }
    return owners;
  }
  
  private static Set<Object> getOwnersFromLegacyMetadata(IJavaProject project, IClasspathEntry cpe)
    throws CoreException
  {
    IProject pj = project.getProject();
    IFile legacyMetadataFile = pj.getFile(".settings/org.eclipse.jst.common.project.facet.core.prefs");
    if (legacyMetadataFile.exists())
    {
      ProjectScope scope = new ProjectScope(pj);
      IEclipsePreferences pluginRoot = scope.getNode("org.eclipse.jst.common.project.facet.core");
      Preferences root = pluginRoot.node("classpath.helper");
      try
      {
        keys = root.childrenNames();
      }
      catch (BackingStoreException e)
      {
        String[] keys;
        throw new CoreException(FacetCorePlugin.createErrorStatus(e.getMessage(), e));
      }
      String[] keys;
      String[] arrayOfString1;
      int j = (arrayOfString1 = keys).length;
      for (int i = 0; i < j; i++)
      {
        String key = arrayOfString1[i];
        
        Preferences node = root.node(key);
        String owners = node.get("owners", null);
        if (owners != null)
        {
          IPath path = new Path(key.replaceAll("::", "/"));
          if (cpe.getPath().equals(path)) {
            return decodeOwnersString(owners);
          }
        }
      }
    }
    return Collections.emptySet();
  }
  
  private static IClasspathEntry setOwners(IClasspathEntry cpe, Set<Object> owners)
  {
    if ((owners.size() == 1) && (owners.iterator().next() == SYSTEM_OWNER)) {
      owners.clear();
    }
    String ownersString = owners.size() == 0 ? null : encodeOwnersString(owners);
    return setOwners(cpe, ownersString);
  }
  
  private static IClasspathEntry setOwners(IClasspathEntry cpe, String owners)
  {
    List<IClasspathAttribute> attrs = new ArrayList();
    IClasspathAttribute[] arrayOfIClasspathAttribute;
    int j = (arrayOfIClasspathAttribute = cpe.getExtraAttributes()).length;
    for (int i = 0; i < j; i++)
    {
      IClasspathAttribute attr = arrayOfIClasspathAttribute[i];
      if (!attr.getName().equals("owner.project.facets")) {
        attrs.add(attr);
      }
    }
    if (owners != null) {
      attrs.add(JavaCore.newClasspathAttribute("owner.project.facets", owners));
    }
    return new ClasspathEntry(cpe.getContentKind(), cpe.getEntryKind(), cpe.getPath(), 
      cpe.getInclusionPatterns(), cpe.getExclusionPatterns(), 
      cpe.getSourceAttachmentPath(), cpe.getSourceAttachmentRootPath(), 
      cpe.getOutputLocation(), cpe.isExported(), cpe.getAccessRules(), 
      cpe.combineAccessRules(), 
      (IClasspathAttribute[])attrs.toArray(new IClasspathAttribute[attrs.size()]));
  }
  
  private static String encodeOwnersString(Set<Object> owners)
  {
    StringBuilder buf = new StringBuilder();
    for (Object owner : owners)
    {
      if (buf.length() > 0) {
        buf.append(';');
      }
      if (owner == SYSTEM_OWNER)
      {
        buf.append("#system#");
      }
      else
      {
        IProjectFacet facet = (IProjectFacet)owner;
        buf.append(facet.getId());
      }
    }
    return buf.toString();
  }
  
  private static Set<Object> decodeOwnersString(String str)
  {
    Set<Object> owners = new HashSet();
    String[] split = str.split(";");
    for (int j = 0; j < split.length; j++)
    {
      String segment = split[j];
      if (segment.equals("#system#"))
      {
        owners.add(SYSTEM_OWNER);
      }
      else
      {
        String facetId = segment;
        int colon = facetId.indexOf(':');
        if (colon != -1) {
          facetId = facetId.substring(0, colon);
        }
        owners.add(ProjectFacetsManager.getProjectFacet(facetId));
      }
    }
    return owners;
  }
  
  private static void convertLegacyMetadata(IJavaProject project)
    throws CoreException
  {
    IProject pj = project.getProject();
    IFile legacyMetadataFile = pj.getFile(".settings/org.eclipse.jst.common.project.facet.core.prefs");
    if (legacyMetadataFile.exists())
    {
      ProjectScope scope = new ProjectScope(pj);
      IEclipsePreferences pluginRoot = scope.getNode("org.eclipse.jst.common.project.facet.core");
      Preferences root = pluginRoot.node("classpath.helper");
      Map<IPath, String> metadata = new HashMap();
      try
      {
        keys = root.childrenNames();
      }
      catch (BackingStoreException e)
      {
        String[] keys;
        throw new CoreException(FacetCorePlugin.createErrorStatus(e.getMessage(), e));
      }
      String[] keys;
      String[] arrayOfString1;
      int j = (arrayOfString1 = keys).length;
      for (int i = 0; i < j; i++)
      {
        String key = arrayOfString1[i];
        
        Preferences node = root.node(key);
        String owners = node.get("owners", null);
        if (owners != null) {
          metadata.put(new Path(key.replaceAll("::", "/")), owners);
        }
      }
      if (!metadata.isEmpty())
      {
        List<IClasspathEntry> cp = getProjectClasspath(project);
        boolean cpchanged = false;
        for (Object itr = cp.listIterator(); ((ListIterator)itr).hasNext();)
        {
          IClasspathEntry cpe = (IClasspathEntry)((ListIterator)itr).next();
          String ownersString = (String)metadata.get(cpe.getPath());
          if (ownersString != null)
          {
            Set<Object> owners = decodeOwnersString(ownersString);
            ((ListIterator)itr).set(setOwners(cpe, encodeOwnersString(owners)));
            cpchanged = true;
          }
        }
        if (cpchanged) {
          setProjectClasspath(project, cp);
        }
      }
      legacyMetadataFile.delete(true, null);
    }
  }
  
  private static void validateClasspathEdit(IJavaProject jproject)
    throws CoreException
  {
    IWorkspace ws = ResourcesPlugin.getWorkspace();
    IProject project = jproject.getProject();
    IStatus st = ws.validateEdit(new IFile[] { project.getFile(".classpath") }, IWorkspace.VALIDATE_PROMPT);
    if (st.getSeverity() == 4) {
      throw new CoreException(st);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.project.facet.core.internal.ClasspathUtil
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.project.facet.core.internal;

import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IProduct;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.Status;

public final class FacetCorePlugin
  extends Plugin
{
  public static final String PLUGIN_ID = "org.eclipse.jst.common.project.facet.core";
  public static final String OUTPUT_FOLDER = "outputFolder";
  public static final String PROD_PROP_SOURCE_FOLDER_LEGACY = "defaultSource";
  private static final String PROD_PROP_SOURCE_FOLDER = "defaultJavaSourceFolder";
  public static final String DEFAULT_SOURCE_FOLDER = "src";
  public static final String DEFUALT_OUTPUT_FOLDER = "build/classes";
  private static FacetCorePlugin inst;
  
  public static FacetCorePlugin getDefault()
  {
    return inst;
  }
  
  public FacetCorePlugin()
  {
    if (inst == null) {
      inst = this;
    }
  }
  
  public String getPluginID()
  {
    return "org.eclipse.jst.common.project.facet.core";
  }
  
  public static void log(Exception e)
  {
    ILog log = getDefault().getLog();
    
    log.log(new Status(4, "org.eclipse.jst.common.project.facet.core", 0, "Encountered an unexpected exception.", e));
  }
  
  public static IStatus createErrorStatus(String msg)
  {
    return createErrorStatus(msg, null);
  }
  
  public static IStatus createErrorStatus(String msg, Exception e)
  {
    return new Status(4, "org.eclipse.jst.common.project.facet.core", 0, msg, e);
  }
  
  public static String getJavaSrcFolder()
  {
    String srcFolder = getDefault().getPluginPreferences().getString("defaultSource");
    if ((srcFolder == null) || (srcFolder.equals("")))
    {
      if (Platform.getProduct() != null)
      {
        srcFolder = Platform.getProduct().getProperty("defaultJavaSourceFolder");
        if ((srcFolder == null) || (srcFolder.equals(""))) {
          srcFolder = Platform.getProduct().getProperty("defaultSource");
        }
      }
      if ((srcFolder == null) || (srcFolder.equals(""))) {
        srcFolde
1 2 3 4 5 6 7 8

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd