Java 类org.eclipse.core.resources.IPathVariableManager 实例源码

项目:PDFReporter-Studio    文件:JavaProjectClassLoader.java   
private static void covertPathToUrl(IProject project, Set<URL> paths, IPath path) {
    if (path != null && project != null && path.removeFirstSegments(1) != null && project.findMember(path.removeFirstSegments(1)) != null) {

        URI uri = project.findMember(path.removeFirstSegments(1)).getRawLocationURI();

        if (uri != null) {
            String scheme = uri.getScheme();
            if (FILE_SCHEME.equalsIgnoreCase(scheme))
                addUri(paths, uri);
            else if ("sourcecontrol".equals(scheme)) {
                // special case of Rational Team Concert
                IPath sourceControlPath = project.findMember(path.removeFirstSegments(1)).getLocation();
                File sourceControlFile = sourceControlPath.toFile();
                if (sourceControlFile.exists())
                    addUri(paths, sourceControlFile.toURI());
            } else {
                IPathVariableManager variableManager = ResourcesPlugin.getWorkspace().getPathVariableManager();
                addUri(paths, variableManager.resolveURI(uri));
            }
        }
    }
}
项目:dsl-devkit    文件:UndeployJob.java   
/**
 * Undeploys the check configuration.
 *
 * @throws CoreException
 *           core exception.
 */
public static void undeployCheckConfiguration() throws CoreException {
  IWorkspace workspace = ResourcesPlugin.getWorkspace();
  IPathVariableManager pathMan = workspace.getPathVariableManager();
  if (pathMan.getURIValue(CheckCfgConstants.CHECK_CFG_VAR_NAME) == null) {
    return;
  }
  pathMan.setURIValue(CheckCfgConstants.CHECK_CFG_VAR_NAME, null);
}
项目:che    文件:ImportOperation.java   
/**
 * Transform an absolute path URI to a relative path one (i.e. from "C:\foo\bar\file.txt" to
 * "VAR\file.txt" granted that the relativeVariable is "VAR" and points to "C:\foo\bar\").
 *
 * @param location
 * @param resource
 * @return an URI that was made relative to a variable
 */
private IPath createRelativePath(IPath location, IResource resource) {
  if (relativeVariable == null) return location;
  if (relativeVariable.equals(ABSOLUTE_PATH)) return location;
  IPathVariableManager pathVariableManager = resource.getPathVariableManager();
  try {
    return URIUtil.toPath(
        pathVariableManager.convertToRelative(URIUtil.toURI(location), true, relativeVariable));
  } catch (CoreException e) {
    return location;
  }
}
项目:gwt-eclipse-plugin    文件:GwtTestUtilities.java   
/**
 * Sets up workspace variables to point at the the {@code GWT_ROOT} and {@code GWT_TOOLS}
 * environment variables, which point at a local clone of the GWT git repository. If those
 * environment variables are not set, extracts a snapshot of the GWT source tree that
 * is bundled with this plug-in and sets the environment variables to point at it.
 */
private static void setupWorkspaceVariables() throws CoreException {
  IPathVariableManager variableManager = ResourcesPlugin.getWorkspace().getPathVariableManager();

  String gwtRoot = System.getenv("GWT_ROOT");
  if (gwtRoot == null) {
    System.out.println("The GWT_ROOT environment variable is not set, using test bundle version");
    gwtRoot = TestEnvironmentUtil.installTestSdk(
        GwtTestingPlugin.getDefault().getBundle(),
        Path.fromPortableString("/resources/gwt-root.zip")).append("trunk").toOSString();
    TestEnvironmentUtil.updateEnvironmentVariable("GWT_ROOT", gwtRoot);
    System.out.println("The GWT_ROOT environment variable is now set");
  }
  IPath gwtRootPath = Path.fromOSString(gwtRoot);
  if (variableManager.getURIValue("GWT_ROOT") == null) {
    CorePluginLog.logInfo("Setting GWT_ROOT = " + gwtRootPath.toOSString());
    variableManager.setURIValue("GWT_ROOT", gwtRootPath.toFile().toURI());
  }

  String gwtTools = System.getenv("GWT_TOOLS");
  if (gwtTools == null) {
    System.out.println("The GWT_TOOLS environment variable is not set, using GWT_ROOT as a base");
    gwtTools = gwtRoot + "/tools";
    TestEnvironmentUtil.updateEnvironmentVariable("GWT_TOOLS", gwtTools);
  }
  IPath gwtToolsPath = Path.fromOSString(gwtTools);
  if (JavaCore.getClasspathVariable("GWT_TOOLS") == null) {
    CorePluginLog.logInfo("Setting GWT_TOOLS = " + gwtToolsPath.toOSString());
    JavaCore.setClasspathVariable("GWT_TOOLS", gwtToolsPath, null);
  }
}
项目:gwt-eclipse-plugin    文件:GWTProjectsRuntime.java   
@Override
public IStatus validate() {
  IWorkspace workspace = ResourcesPlugin.getWorkspace();
  IPathVariableManager pathVariableManager = workspace.getPathVariableManager();
  URI gwtUri = pathVariableManager.getURIValue("GWT_ROOT");
  if (gwtUri == null) {
    return new Status(IStatus.ERROR, GWTPlugin.PLUGIN_ID,
        "Path variable 'GWT_ROOT' is not defined");
  }

  IPath gwtRoot = URIUtil.toPath(gwtUri);
  if (gwtRoot == null) {
    return new Status(IStatus.ERROR, GWTPlugin.PLUGIN_ID,
        "Path variable 'GWT_ROOT' is not defined");
  }

  if (!gwtRoot.toFile().exists()) {
    return new Status(IStatus.ERROR, GWTPlugin.PLUGIN_ID,
        "Path variable 'GWT_ROOT' points to an invalid location");
  }

  if (findDevProject() == null) {
    return new Status(IStatus.ERROR, GWTPlugin.PLUGIN_ID, "Could not find and gwt-dev-* project");
  }

  if (findUserProject() == null) {
    return new Status(IStatus.ERROR, GWTPlugin.PLUGIN_ID, "Could not find the gwt-user project");
  }

  return getGwtDevJarStatus(this);
}
项目:filesync4eclipse    文件:SyncWizard.java   
/**
 * @param source
 * @return File object, corresponding to given resource. This file could be
 * deleted or not yet created.
 */
protected File getSourceFile(IResource source) {
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    // linked resources will be resolved here!
    IPath rawPath = source.getRawLocation();

    // here we should resolve path variables,
    // probably existing at first place of path
    IPathVariableManager pathManager = workspace.getPathVariableManager();
    rawPath = pathManager.resolvePath(rawPath);
    return rawPath.toFile();
}
项目:Eclipse-Postfix-Code-Completion    文件:AddSourceFolderWizardPage.java   
/**
 * Validates this page's controls.
    * @param folderName the folder name
 *
 * @return IStatus indicating the validation result. IStatus.OK if the
 *  specified link target is valid given the linkHandle.
 */
private IStatus validateLinkLocation(String folderName) {
    IWorkspace workspace= JavaPlugin.getWorkspace();
    IPath path= Path.fromOSString(fLinkFields.fLinkLocation.getText());

    Path folderLocation= new Path(folderName);
    if (folderLocation.isAbsolute())
        return new StatusInfo(IStatus.ERROR, NewWizardMessages.AddSourceFolderWizardPage_error_NotARelativePathName);

    IProject project= fNewElement.getJavaProject().getProject();
    IFolder folder= project.getFolder(folderLocation);
    IStatus locationStatus= workspace.validateLinkLocation(folder, path);
    if (locationStatus.matches(IStatus.ERROR))
        return locationStatus;

    IPathVariableManager pathVariableManager= project.getPathVariableManager();
    IPath path1= Path.fromOSString(fLinkFields.fLinkLocation.getText());
    IPath resolvedPath= pathVariableManager.resolvePath(path1);
    // use the resolved link target name
    String resolvedLinkTarget= resolvedPath.toOSString();

    path= new Path(resolvedLinkTarget);
    File linkTargetFile= new Path(resolvedLinkTarget).toFile();
    if (linkTargetFile.exists()) {
        if (!linkTargetFile.isDirectory())
            return new StatusInfo(IStatus.ERROR, NewWizardMessages.NewFolderDialog_linkTargetNotFolder);
    } else {
        return new StatusInfo(IStatus.ERROR, NewWizardMessages.NewFolderDialog_linkTargetNonExistent);
    }
    if (locationStatus.isOK()) {
        return new StatusInfo();
    }
    return new StatusInfo(locationStatus.getSeverity(), locationStatus.getMessage());
}
项目:sadlos2    文件:OwlImportOperation.java   
/**
     * Transform an absolute path URI to a relative path one (i.e. from
     * "C:\foo\bar\file.txt" to "VAR\file.txt" granted that the relativeVariable
     * is "VAR" and points to "C:\foo\bar\").
     * 
     * @param location
     * @param resource 
     * @return an URI that was made relative to a variable
     */
    private IPath createRelativePath(IPath location, IResource resource) {
        if (relativeVariable == null)
            return location;
        if (relativeVariable.equals(ABSOLUTE_PATH))
            return location;
        IPathVariableManager pathVariableManager = resource.getPathVariableManager();
//      try {
//          return URIUtil.toPath(pathVariableManager.convertToRelative(URIUtil.toURI(location), true, relativeVariable));
//      } catch (CoreException e) {
//          return location;
//      }
        return null;  // temporary
    }
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:AddSourceFolderWizardPage.java   
/**
 * Validates this page's controls.
    * @param folderName the folder name
 *
 * @return IStatus indicating the validation result. IStatus.OK if the
 *  specified link target is valid given the linkHandle.
 */
private IStatus validateLinkLocation(String folderName) {
    IWorkspace workspace= JavaPlugin.getWorkspace();
    IPath path= Path.fromOSString(fLinkFields.fLinkLocation.getText());

    Path folderLocation= new Path(folderName);
    if (folderLocation.isAbsolute())
        return new StatusInfo(IStatus.ERROR, NewWizardMessages.AddSourceFolderWizardPage_error_NotARelativePathName);

    IProject project= fNewElement.getJavaProject().getProject();
    IFolder folder= project.getFolder(folderLocation);
    IStatus locationStatus= workspace.validateLinkLocation(folder, path);
    if (locationStatus.matches(IStatus.ERROR))
        return locationStatus;

    IPathVariableManager pathVariableManager= project.getPathVariableManager();
    IPath path1= Path.fromOSString(fLinkFields.fLinkLocation.getText());
    IPath resolvedPath= pathVariableManager.resolvePath(path1);
    // use the resolved link target name
    String resolvedLinkTarget= resolvedPath.toOSString();

    path= new Path(resolvedLinkTarget);
    File linkTargetFile= new Path(resolvedLinkTarget).toFile();
    if (linkTargetFile.exists()) {
        if (!linkTargetFile.isDirectory())
            return new StatusInfo(IStatus.ERROR, NewWizardMessages.NewFolderDialog_linkTargetNotFolder);
    } else {
        return new StatusInfo(IStatus.ERROR, NewWizardMessages.NewFolderDialog_linkTargetNonExistent);
    }
    if (locationStatus.isOK()) {
        return new StatusInfo();
    }
    return new StatusInfo(locationStatus.getSeverity(), locationStatus.getMessage());
}
项目:VariantSync    文件:ProjectRoot.java   
@Override
public IPathVariableManager getPathVariableManager() {
    // not required
    return null;
}
项目:che    文件:Workspace.java   
@Override
public IPathVariableManager getPathVariableManager() {
  throw new UnsupportedOperationException();
}
项目:che    文件:Resource.java   
public IPathVariableManager getPathVariableManager() {
  //        if (getProject() == null)
  //            return workspace.getPathVariableManager();
  //        return new ProjectPathVariableManager(this);
  throw new UnsupportedOperationException();
}
项目:PerformanceHat    文件:AbstractBaseResourceDecorator.java   
/**
 * {@inheritDoc}
 */
@Override
public IPathVariableManager getPathVariableManager() {
  return resource().getPathVariableManager();
}
项目:Pydev    文件:AbstractIResourceStub.java   
@Override
public IPathVariableManager getPathVariableManager() {
    return null;
}