コード例 #1
0
  /**
   * Returns the link target location entered by the user.
   *
   * @return the link target location entered by the user. null if the user chose not to create a
   *     link.
   */
  public URI getLinkTargetURI() {
    if (!createLink) {
      return null;
    }
    // resolve path variable if we have a relative path
    if (!linkTarget.startsWith("/")) { // $NON-NLS-1$
      IPathVariableManager pathVariableManager =
          RemoteResourcesPlugin.getWorkspace().getPathVariableManager();
      try {

        URI path = new URI(linkTarget.replace(java.io.File.separatorChar, '/'));
        URI resolved = pathVariableManager.resolveURI(path);
        if (path != resolved) {
          // we know this is a path variable, but return unresolved
          // path so resource will be created with variable intact
          return path;
        }
      } catch (URISyntaxException e) {
        // link target is not a valid URI. Fall through to handle this
        // below
      }
    }

    FileSystemConfiguration configuration = getSelectedConfiguration();
    if (configuration == null) {
      return URIUtil.toURI(linkTarget);
    }
    // validate non-local file system location
    return configuration.getContributor().getURI(linkTarget);
  }
コード例 #2
0
  /**
   * Tries to resolve the value entered in the link target field as a variable, if the value is a
   * relative path. Displays the resolved value if the entered value is a variable.
   */
  private void resolveVariable() {
    IPathVariableManager pathVariableManager =
        RemoteResourcesPlugin.getWorkspace().getPathVariableManager();
    IPath path = new Path(linkTarget);
    IPath resolvedPath = pathVariableManager.resolvePath(path);

    if (path.equals(resolvedPath)) {
      resolvedPathLabelText.setVisible(false);
      resolvedPathLabelData.setVisible(false);
    } else {
      resolvedPathLabelText.setVisible(true);
      resolvedPathLabelData.setVisible(true);
    }
    resolvedPathLabelData.setText(resolvedPath.toOSString());
  }