@Override
  public String[] getFrameworkVMArguments() {
    IPath installPath = getServer().getRuntime().getLocation();
    // If installPath is relative, convert to canonical path and hope for
    // the best
    if (!installPath.isAbsolute()) {
      try {
        String installLoc = (new File(installPath.toOSString())).getCanonicalPath();
        installPath = new Path(installLoc);
      } catch (IOException e) {
        // Ignore if there is a problem
      }
    }

    IPath deployPath = getBaseDirectory();
    // If deployPath is relative, convert to canonical path and hope for the
    // best
    if (!deployPath.isAbsolute()) {
      try {
        String deployLoc = (new File(deployPath.toOSString())).getCanonicalPath();
        deployPath = new Path(deployLoc);
      } catch (IOException e) {
        // Ignore if there is a problem
      }
    }

    return getJonasVersionHandler().getFrameworkVMArguments(installPath, null, deployPath, false);
  }
예제 #2
0
  /**
   * Set the boolean symbol on and off image path. If the path is relative, then build absolute
   * path.
   *
   * <p><b>Rules:</b> <br>
   * If the image selected is on, then search off image. <br>
   * If the image selected is off, then search on image. <br>
   * If one or both is not found, the image path selected is the same for both.
   *
   * @param model
   * @param imagePath The path to the selected image (on or off or other)
   */
  public synchronized void setSymbolImagePath(ControlBoolSymbolModel model, IPath imagePath) {
    if (imagePath == null || imagePath.isEmpty()) {
      return;
    }
    if (!imagePath.isAbsolute()) {
      imagePath = org.csstudio.opibuilder.util.ResourceUtil.buildAbsolutePath(model, imagePath);
    }
    // Default
    this.onImagePath = imagePath;
    this.offImagePath = imagePath;

    // Search on or off equivalent
    if (ImageUtils.isOnImage(imagePath)) {
      IPath offImagePath = ImageUtils.searchOffImage(imagePath);
      if (offImagePath != null) {
        this.offImagePath = offImagePath;
      }
    } else if (ImageUtils.isOffImage(imagePath)) {
      IPath onImagePath = ImageUtils.searchOnImage(imagePath);
      if (onImagePath != null) {
        this.onImagePath = onImagePath;
      }
    }
    if (imagePath.getFileExtension() != null
        && "svg".compareToIgnoreCase(imagePath.getFileExtension()) == 0) {
      workingWithSVG = true;
    } else {
      workingWithSVG = false;
    }
    loadOffImage();
    loadOnImage();
  }
  protected IFile findFileInWorkspace(IPath path) {
    IFile file = null;
    if (path.isAbsolute()) {
      IWorkspaceRoot root = getProject().getWorkspace().getRoot();

      // construct a URI, based on the project's locationURI, that points
      // to the given path
      URI projectURI = project.getLocationURI();

      URI newURI =
          EFSExtensionManager.getDefault().createNewURIFromPath(projectURI, path.toString());

      IFile[] files = root.findFilesForLocationURI(newURI);

      for (int i = 0; i < files.length; i++) {
        if (files[i].getProject().equals(getProject())) {
          file = files[i];
          break;
        }
      }

    } else {
      file = getProject().getFile(path);
    }
    return file;
  }
  /**
   * @param filePath
   * @return
   */
  protected IFile findFilePath(String filePath) {
    IPath path = null;
    IPath fp = new Path(filePath);
    if (fp.isAbsolute()) {
      if (getBaseDirectory().isPrefixOf(fp)) {
        int segments = getBaseDirectory().matchingFirstSegments(fp);
        path = fp.removeFirstSegments(segments);
      } else {
        path = fp;
      }
    } else {
      path = getWorkingDirectory().append(filePath);
    }

    IFile file = null;
    // The workspace may throw an IllegalArgumentException
    // Catch it and the parser should fallback to scan the entire project.
    try {
      file = findFileInWorkspace(path);
    } catch (Exception e) {
    }

    // We have to do another try, on Windows for cases like "TEST.C" vs "test.c"
    // We use the java.io.File canonical path.
    if (file == null || !file.exists()) {
      File f = path.toFile();
      try {
        String canon = f.getCanonicalPath();
        path = new Path(canon);
        file = findFileInWorkspace(path);
      } catch (IOException e1) {
      }
    }
    return (file != null && file.exists()) ? file : null;
  }
 /**
  * @param filePath : String
  * @return filePath : IPath - not <code>null</code>
  */
 public IPath getAbsolutePath(String filePath) {
   IPath pFilePath;
   if (filePath.startsWith("/")) { // $NON-NLS-1$
     return convertCygpath(new Path(filePath));
   } else if (filePath.startsWith("\\")
       || //$NON-NLS-1$
       (!filePath.startsWith(".")
           && //$NON-NLS-1$
           filePath.length() > 2
           && filePath.charAt(1) == ':'
           && (filePath.charAt(2) == '\\' || filePath.charAt(2) == '/'))) {
     // absolute path
     pFilePath = new Path(filePath);
   } else {
     // relative path
     IPath cwd = getWorkingDirectory();
     if (!cwd.isAbsolute()) {
       cwd = getBaseDirectory().append(cwd);
     }
     if (filePath.startsWith("`pwd`")) { // $NON-NLS-1$
       if (filePath.length() > 5 && (filePath.charAt(5) == '/' || filePath.charAt(5) == '\\')) {
         filePath = filePath.substring(6);
       } else {
         filePath = filePath.substring(5);
       }
     }
     pFilePath = cwd.append(filePath);
   }
   return pFilePath;
 }
  private File[] parseEndorsedDirs(IProject project, String endorsedDirs) {
    if (endorsedDirs == null) {
      return null;
    }
    // Remove quotes, use system separators
    endorsedDirs = endorsedDirs.replaceAll("\"", "");

    // Quote from http://docs.oracle.com/javase/6/docs/technotes/guides/standards/
    // "If more than one directory path is specified by java.endorsed.dirs,
    // they must be separated by File.pathSeparatorChar."
    String[] paths = endorsedDirs.split("" + File.pathSeparatorChar);

    // Convert dir paths to Files
    List<File> dirs = new ArrayList<File>(paths.length);
    for (String path : paths) {
      IPath p = new Path(useSystemSeparator(path));
      if (!p.isAbsolute()) {
        p = project.getLocation().append(p);
      }
      File lib = new File(p.toOSString());
      dirs.add(lib);
    }

    return dirs.toArray(new File[0]);
  }
예제 #7
0
  /**
   * Return true if the IFile with the given name exists in this project.
   *
   * @param aFileName filename can be relative to one of the input file paths for the
   *     WorkbenchURIConverter.
   * @return <code>true</code> if filename exists in this project
   * @since 1.0.0
   */
  public boolean fileExists(String aFileName) {
    if (aFileName == null) return false;

    IPath path = new Path(aFileName);
    if (path.isAbsolute()) return ResourcesPlugin.getWorkspace().getRoot().getFile(path).exists();
    else return getWorkbenchURIConverter().canGetUnderlyingResource(aFileName);
  }
예제 #8
0
 public Collection<IPath> getIncludeDirs(
     final IProject project, final Collection<IPath> includeDirs) {
   final IErlProject erlProject = ErlModelManager.getErlangModel().getErlangProject(project);
   if (erlProject == null) {
     return includeDirs;
   }
   final Collection<IPath> projectIncludeDirs = erlProject.getIncludeDirs();
   final IPathVariableManager pvm = ResourcesPlugin.getWorkspace().getPathVariableManager();
   for (IPath inc : projectIncludeDirs) {
     inc = PluginUtils.resolvePVMPath(pvm, inc);
     if (inc.isAbsolute()) {
       includeDirs.add(inc);
     } else {
       final IFolder folder = project.getFolder(inc);
       if (folder != null) {
         final IPath location = folder.getLocation();
         if (location != null) {
           includeDirs.add(location);
         } else {
           ErlLogger.warn("No location for %s", folder);
         }
       }
     }
   }
   return includeDirs;
 }
 /**
  * Respects images residing in any plug-in. If path is relative, then this bundle is looked up for
  * the image, otherwise, for absolute path, first segment is taken as id of plug-in with image
  *
  * @generated
  * @param path the path to image, either absolute (with plug-in id as first segment), or relative
  *     for bundled images
  * @return the image descriptor
  */
 public static ImageDescriptor findImageDescriptor(String path) {
   final IPath p = new Path(path);
   if (p.isAbsolute() && p.segmentCount() > 1) {
     return AbstractUIPlugin.imageDescriptorFromPlugin(
         p.segment(0), p.removeFirstSegments(1).makeAbsolute().toString());
   } else {
     return getBundledImageDescriptor(p.makeAbsolute().toString());
   }
 }
예제 #10
0
 /**
  * @deprecated
  * @param folder
  * @param runtime
  * @param ignoreError
  * @return
  */
 public static String getFolder(String folder, IRuntime runtime, boolean ignoreError) {
   String tmp =
       new ConfigNameResolver()
           .performSubstitutions(folder, runtime == null ? null : runtime.getName(), ignoreError);
   IPath p = new Path(tmp);
   if (!p.isAbsolute() && runtime != null) {
     p = runtime.getLocation().append(p);
   }
   return p.toString();
 }
  public static IIncludePathEntry newSourceEntry(IPath path, IResource resource) {

    if (path == null) {
      throw new IllegalArgumentException("Source path cannot be null"); // $NON-NLS-1$
    }
    if (!path.isAbsolute()) {
      throw new IllegalArgumentException(
          "Path for IIncludePathEntry must be absolute"); //$NON-NLS-1$
    }
    return new IncludePathEntry(K_SOURCE, IIncludePathEntry.IPE_SOURCE, path, resource, false);
  }
 public static IIncludePathEntry newProjectEntry(
     IPath path, IResource resource, boolean isExported) {
   if (path == null || resource == null) {
     throw new IllegalArgumentException("Null arguments are not allowed"); // $NON-NLS-1$
   }
   if (!path.isAbsolute()) {
     throw new IllegalArgumentException(
         "Path for IIncludePathEntry must be absolute"); //$NON-NLS-1$
   }
   return new IncludePathEntry(
       K_SOURCE, IIncludePathEntry.IPE_PROJECT, path, resource, isExported);
 }
예제 #13
0
 /**
  * Get list of clones for the given workspace or path. When <code>path</code> is not <code>null
  * </code> the result is narrowed to clones under the <code>path</code>.
  *
  * @param workspaceId the workspace ID. Must be null if path is provided.
  * @param path path under the workspace starting with project ID. Must be null if workspaceId is
  *     provided.
  * @return the request
  */
 private WebRequest listGitClonesRequest(String workspaceId, IPath path) {
   assertTrue(workspaceId == null && path != null || workspaceId != null && path == null);
   String requestURI = SERVER_LOCATION + GIT_SERVLET_LOCATION + Clone.RESOURCE + '/';
   if (workspaceId != null) {
     requestURI += "workspace/" + workspaceId;
   } else {
     requestURI += "path" + (path.isAbsolute() ? path : path.makeAbsolute());
   }
   WebRequest request = new GetMethodWebRequest(requestURI);
   request.setHeaderField(ProtocolConstants.HEADER_ORION_VERSION, "1");
   setAuthentication(request);
   return request;
 }
예제 #14
0
 private static void buildPaths(
     final IWorkspaceRoot root, final IProject project, final Collection<IPath> list)
     throws CoreException {
   final IPath projectPath = project.getFullPath();
   for (final IPath pp : list) {
     // only create in-project paths
     if (!pp.isAbsolute() && !pp.toString().equals(".") && !pp.isEmpty()) {
       final IPath path = projectPath.append(pp);
       final IFolder folder = root.getFolder(path);
       createFolderHelper(folder);
     }
   }
 }
예제 #15
0
 /** @return the folder */
 public String getFolder() {
   String result = new ExpressionResolver(resolver).resolve(folder);
   // This resolved variable still might be relative, so we must
   // resolve it further if possible, by prepending the server home
   IPath p = new Path(result);
   if (!p.isAbsolute()) {
     String s2 =
         ConfigNameResolver.getVariablePattern(ConfigNameResolver.JBOSS_SERVER_HOME)
             + IPath.SEPARATOR
             + result;
     result = new ExpressionResolver(resolver).resolve(s2);
   }
   return result;
 }
예제 #16
0
 private String getBopOpenFileText() {
   // from project relative path to absolute path
   String fileName = bopOpenFileText.getText().trim();
   if (fileName.length() > 0) {
     IPath filePath = new Path(fileName);
     if (!filePath.isAbsolute()) {
       if (getContainer().getProject() != null) {
         IPath projectPath = getContainer().getProject().getLocation();
         filePath = projectPath.append(filePath);
         fileName = filePath.toString();
       }
     }
   }
   return fileName;
 }
예제 #17
0
 @SuppressWarnings("rawtypes")
 public List getFrameworkClasspath(IPath configPath) {
   IPath installPath = getRuntime().getLocation();
   // If installPath is relative, convert to canonical path and hope for
   // the best
   if (!installPath.isAbsolute()) {
     try {
       String installLoc = (new File(installPath.toOSString())).getCanonicalPath();
       installPath = new Path(installLoc);
     } catch (IOException e) {
       // Ignore if there is a problem
     }
   }
   return getVersionHandler().getFrameworkClasspath(installPath, configPath);
 }
예제 #18
0
 private void setBopOpenFileText(String fileName) {
   // from absolute path to project relative path
   if (fileName.length() > 0) {
     IPath filePath = new Path(fileName);
     if (filePath.isAbsolute()) {
       if (getContainer().getProject() != null) {
         IPath projectPath = getContainer().getProject().getLocation();
         if (projectPath.isPrefixOf(filePath)) {
           filePath = filePath.removeFirstSegments(projectPath.segmentCount());
           filePath = filePath.setDevice(null);
           fileName = filePath.toString();
         }
       }
     }
   }
   bopOpenFileText.setText(fileName);
 }
  /**
   * Removes path information from the given string containing one or more comma separated osgi
   * bundles. Replaces escaped '\:' with ':'. Removes, reference, platform and file prefixes.
   * Removes any other path information converting the location or the last segment to a bundle id.
   *
   * @param osgiBundles list of bundles to strip path information from (commma separated)
   * @return list of bundles with path information stripped
   */
  public static String stripPathInformation(String osgiBundles) {
    StringBuffer result = new StringBuffer();
    StringTokenizer tokenizer = new StringTokenizer(osgiBundles, ","); // $NON-NLS-1$
    while (tokenizer.hasMoreElements()) {
      String token = tokenizer.nextToken();
      token = token.replaceAll("\\\\:|/:", ":"); // $NON-NLS-1$ //$NON-NLS-2$

      // read up until the first @, if there
      int atIndex = token.indexOf('@');
      String bundle = atIndex > 0 ? token.substring(0, atIndex) : token;
      bundle = bundle.trim();

      // strip [reference:][platform:][file:] prefixes if any
      if (bundle.startsWith(REFERENCE_PREFIX) && bundle.length() > REFERENCE_PREFIX.length())
        bundle = bundle.substring(REFERENCE_PREFIX.length());
      if (bundle.startsWith(PLATFORM_PREFIX) && bundle.length() > PLATFORM_PREFIX.length())
        bundle = bundle.substring(PLATFORM_PREFIX.length());
      if (bundle.startsWith(FILE_URL_PREFIX) && bundle.length() > FILE_URL_PREFIX.length())
        bundle = bundle.substring(FILE_URL_PREFIX.length());

      // if the path is relative, the last segment is the bundle symbolic name
      // Otherwise, we need to retrieve the bundle symbolic name ourselves
      IPath path = new Path(bundle);
      String id = null;
      if (path.isAbsolute()) {
        id = getSymbolicName(bundle);
      }
      if (id == null) {
        id = path.lastSegment();
      }
      if (id != null) {
        int underscoreIndex = id.indexOf('_');
        if (underscoreIndex >= 0) {
          id = id.substring(0, underscoreIndex);
        }
        if (id.endsWith(JAR_EXTENSION)) {
          id = id.substring(0, id.length() - 4);
        }
      }
      if (result.length() > 0) result.append(","); // $NON-NLS-1$
      result.append(id != null ? id : bundle);
      if (atIndex > -1) result.append(token.substring(atIndex).trim());
    }
    return result.toString();
  }
예제 #20
0
	public IEditorInput getEditorInput(IPath p, IProject project) {
		IFile f = getFileForPath(p, project);
		if (f != null && f.exists()) {
			return new FileEditorInput(f);
		}
		if (p.isAbsolute()) {
			File file = p.toFile();
			if (file.exists()) {
				try {
					IFileStore ifs = EFS.getStore(file.toURI());
					return new FileStoreEditorInput(ifs);
				} catch (CoreException _) {
					Activator.getDefault().getLog().log(_.getStatus());
				}
			}
		}
		return findFileInCommonSourceLookup(p);
	}
예제 #21
0
 /**
  * If the file designated by filename exists, return the IPath representation of the filename If
  * it does not exist, try cygpath translation
  *
  * @param filename - file name
  * @return location (outside of the workspace).
  */
 protected IPath getLocation(String filename) {
   IPath path = new Path(filename);
   File file = path.toFile();
   if (!file.exists() && isCygwin && path.isAbsolute()) {
     try {
       String cygfilename = Cygwin.cygwinToWindowsPath(filename);
       IPath convertedPath = new Path(cygfilename);
       file = convertedPath.toFile();
       if (file.exists()) {
         path = convertedPath;
       }
     } catch (UnsupportedOperationException e) {
       isCygwin = false;
     } catch (IOException e) {
     }
   }
   return path;
 }
예제 #22
0
	private IFile getFileForPathImpl(IPath path, IProject project) {
		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
		if (path.isAbsolute()) {
			IFile c = root.getFileForLocation(path);
			return c;
		}
		if (project != null && project.exists()) {
			ICProject cproject = CoreModel.getDefault().create(project);
			if (cproject != null) {
				try {
					ISourceRoot[] roots = cproject.getAllSourceRoots();
					for (ISourceRoot sourceRoot : roots) {
						IResource r = sourceRoot.getResource();
						if (r instanceof IContainer) {
							IContainer parent = (IContainer) r;
							IResource res = parent.findMember(path);
							if (res != null && res.exists() && res instanceof IFile) {
								IFile file = (IFile) res;
								return file;
							}
						}
					}

					IOutputEntry entries[] = cproject.getOutputEntries();
					for (IOutputEntry pathEntry : entries) {
						IPath p = pathEntry.getPath();
						IResource r = root.findMember(p);
						if (r instanceof IContainer) {
							IContainer parent = (IContainer) r;
							IResource res = parent.findMember(path);
							if (res != null && res.exists() && res instanceof IFile) {
								IFile file = (IFile) res;
								return file;
							}
						}
					}
					
				} catch (CModelException _) {
					Activator.getDefault().getLog().log(_.getStatus());
				}
			}
		}
		return null;
	}
예제 #23
0
  /**
   * Helper method - returns the targeted item (IResource if internal or java.io.File if external),
   * or null if unbound Internal items must be referred to using container relative paths.
   */
  public static Object getTarget(IContainer container, IPath path, boolean checkResourceExistence) {

    if (path == null) return null;

    // lookup - inside the container
    if (path.getDevice() == null) { // container relative paths should not contain a device
      // (see http://dev.eclipse.org/bugs/show_bug.cgi?id=18684)
      // (case of a workspace rooted at d:\ )
      IResource resource = container.findMember(path);
      if (resource != null) {
        if (!checkResourceExistence || resource.exists()) return resource;
        return null;
      }
    }

    // if path is relative, it cannot be an external path
    // (see http://dev.eclipse.org/bugs/show_bug.cgi?id=22517)
    if (!path.isAbsolute()) return null;

    // lookup - outside the container
    File externalFile = new File(path.toOSString());
    if (!checkResourceExistence) {
      return externalFile;
    } else if (existingExternalFiles.contains(externalFile)) {
      return externalFile;
    } else {
      if (ModelWorkspaceManager.ZIP_ACCESS_VERBOSE) {
        System.out.println(
            "("
                + Thread.currentThread()
                + ") [ModelWorkspaceImpl.getTarget(...)] Checking existence of "
                + path.toString()); // $NON-NLS-1$ //$NON-NLS-2$
      }
      if (externalFile.exists()) {
        // cache external file
        existingExternalFiles.add(externalFile);
        return externalFile;
      }
    }
    return null;
  }
  protected void checkIfPatternValid() {
    String pattern = fExclusionPatternDialog.getText().trim();
    if (pattern.length() == 0) {
      fExclusionPatternStatus.setError(NewWizardMessages.ExclusionInclusionEntryDialog_error_empty);
      return;
    }
    IPath path = new Path(pattern);
    if (path.isAbsolute() || path.getDevice() != null) {
      fExclusionPatternStatus.setError(
          NewWizardMessages.ExclusionInclusionEntryDialog_error_notrelative);
      return;
    }
    if (fExistingPatterns.contains(pattern)) {
      fExclusionPatternStatus.setError(
          NewWizardMessages.ExclusionInclusionEntryDialog_error_exists);
      return;
    }

    fExclusionPattern = pattern;
    fExclusionPatternStatus.setOK();
  }
예제 #25
0
  /**
   * Verify that program name of the configuration can be found as a file.
   *
   * @return Absolute path of the program location
   */
  public static IPath verifyProgramPath(ILaunchConfiguration configuration, ICProject cproject)
      throws CoreException {
    String programName =
        configuration.getAttribute(
            ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String) null);
    if (programName == null) {
      abort(
          LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_not_specified"),
          null, //$NON-NLS-1$
          ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
    }

    IPath programPath = new Path(programName);
    if (programPath.isEmpty()) {
      abort(
          LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_does_not_exist"),
          null, //$NON-NLS-1$
          ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
    }

    if (!programPath.isAbsolute() && cproject != null) {
      // Find the specified program within the specified project
      IFile wsProgramPath = cproject.getProject().getFile(programPath);
      programPath = wsProgramPath.getLocation();
    }

    if (!programPath.toFile().exists()) {
      abort(
          LaunchMessages.getString(
              "AbstractCLaunchDelegate.Program_file_does_not_exist"), //$NON-NLS-1$
          new FileNotFoundException(
              LaunchMessages.getFormattedString(
                  "AbstractCLaunchDelegate.PROGRAM_PATH_not_found", //$NON-NLS-1$
                  programPath.toOSString())),
          ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST);
    }

    return programPath;
  }
 private void addBaseString(IPath endPath, CPElement cpentry, StringBuffer str) {
   IPath baseRef = (IPath) cpentry.getAttribute(CPElement.BASE_REF);
   if (!baseRef.isEmpty()) {
     if (baseRef.isAbsolute()) {
       //				str.append("From project ");
       IPath path = baseRef;
       if (endPath != null) {
         path = path.append(endPath);
       }
       str.append(path.makeRelative().toPortableString());
     } else {
       //				str.append("From contribution ");
       IPathEntryContainer container;
       if (endPath != null) {
         str.append(endPath.toPortableString());
       }
       str.append(" - ("); // $NON-NLS-1$
       try {
         container = CoreModel.getPathEntryContainer(baseRef, cpentry.getCProject());
         if (container != null) {
           str.append(container.getDescription());
         }
       } catch (CModelException e1) {
       }
       str.append(')');
     }
   } else {
     IPath path = (IPath) cpentry.getAttribute(CPElement.BASE);
     if (!path.isEmpty()) {
       if (endPath != null) {
         path = path.append(endPath);
       }
       str.insert(0, path.toPortableString());
     } else if (endPath != null) {
       str.insert(0, endPath.toPortableString());
     }
   }
 }
예제 #27
0
  /**
   * @param checked pass true to get the checked elements, false to get the selected elements
   * @return map between project and repository root directory (converted to an absolute path) for
   *     all projects selected by user
   */
  public Map<IProject, File> getProjects(boolean checked) {
    final Object[] elements;
    if (!internalMode)
      if (checked) elements = projectMoveViewer.getCheckedElements();
      else {
        ISelection selection = viewer.getSelection();
        elements = ((IStructuredSelection) selection).toArray();
      }
    else if (checked) elements = viewer.getCheckedElements();
    else {
      ISelection selection = viewer.getSelection();
      if (selection instanceof IStructuredSelection)
        elements = ((IStructuredSelection) selection).toArray();
      else elements = new Object[0];
    }

    Map<IProject, File> ret = new HashMap<IProject, File>(elements.length);
    for (Object ti : elements) {
      if (!internalMode) {
        File workdir = selectedRepository.getWorkTree();
        IProject project = (IProject) ti;
        IPath targetLocation = new Path(relPath.getText()).append(project.getName());
        File targetFile = new File(workdir, targetLocation.toOSString());
        ret.put(project, targetFile);

      } else {
        final IProject project = ((ProjectAndRepo) ti).getProject();
        String path = ((ProjectAndRepo) ti).getRepo();
        final IPath selectedRepo = Path.fromOSString(path);
        IPath localPathToRepo = selectedRepo;
        if (!selectedRepo.isAbsolute()) {
          localPathToRepo = project.getLocation().append(selectedRepo);
        }
        ret.put(project, localPathToRepo.toFile());
      }
    }
    return ret;
  }
  @Override
  public void importRuntimeConfiguration(IRuntime runtime, IProgressMonitor monitor)
      throws CoreException {

    super.importRuntimeConfiguration(runtime, monitor);
    OSGIFrameworkInstanceBehaviorDelegate fsb =
        (OSGIFrameworkInstanceBehaviorDelegate)
            getServer().loadAdapter(EquinoxFrameworkInstanceBehavior.class, null);
    if (fsb != null) {
      IPath tempDir = fsb.getTempDirectory();
      if (!tempDir.isAbsolute()) {
        IPath rootPath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
        tempDir = rootPath.append(tempDir);
      }
      setInstanceDirectory(tempDir.toPortableString());
    }

    try {
      getEquinoxConfiguration();
    } catch (CoreException e) {
      Trace.trace(Trace.SEVERE, "Can't setup for Equinox configuration.", e);
    }
  }
예제 #29
0
  /** Save attributes to an XML file. */
  static void saveAttributes(IPath filenameHint, AttributeValueSets attributes) {
    final IPath pathHint =
        filenameHint.isAbsolute()
            ? filenameHint
            : FileDialogs.recallPath(REMEMBER_DIRECTORY).append(filenameHint);

    final Path saveLocation = FileDialogs.openSaveXML(pathHint);
    if (saveLocation != null) {
      try {
        final Persister persister = new Persister(new Format(2));
        persister.write(attributes, saveLocation.toFile());
      } catch (Exception e) {
        Utils.showError(
            new Status(
                IStatus.ERROR,
                WorkbenchCorePlugin.PLUGIN_ID,
                "An error occurred while saving attributes.",
                e));
      }

      FileDialogs.rememberDirectory(REMEMBER_DIRECTORY, saveLocation);
    }
  }
  /* (non-Javadoc)
   * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
   */
  public String getText(Object element) {
    IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry) element;
    switch (entry.getType()) {
      case IRuntimeClasspathEntry.PROJECT:
        IResource res = entry.getResource();
        IJavaElement proj = JavaCore.create(res);
        if (proj == null) {
          return entry.getPath().lastSegment();
        } else {
          return lp.getText(proj);
        }
      case IRuntimeClasspathEntry.ARCHIVE:
        IPath path = entry.getPath();
        if (path == null) {
          return MessageFormat.format("Invalid path: {0}", new Object[] {"null"}); // $NON-NLS-1$
        }
        if (!path.isAbsolute() || !path.isValidPath(path.toString())) {
          return MessageFormat.format("Invalid path: {0}", new Object[] {path.toOSString()});
        }
        String[] segments = path.segments();
        StringBuffer displayPath = new StringBuffer();
        if (segments.length > 0) {
          String device = path.getDevice();
          if (device != null) {
            displayPath.append(device);
            displayPath.append(File.separator);
          }
          for (int i = 0; i < segments.length - 1; i++) {
            displayPath.append(segments[i]).append(File.separator);
          }
          displayPath.append(segments[segments.length - 1]);

          // getDevice means that's a absolute path.
          if (path.getDevice() != null && !path.toFile().exists()) {
            displayPath.append(" (missing) ");
          }
        } else {
          displayPath.append(path.toOSString());
        }
        return displayPath.toString();
      case IRuntimeClasspathEntry.VARIABLE:
        path = entry.getPath();
        IPath srcPath = entry.getSourceAttachmentPath();
        StringBuffer buf = new StringBuffer(path.toString());
        if (srcPath != null) {
          buf.append(" ["); // $NON-NLS-1$
          buf.append(srcPath.toString());
          IPath rootPath = entry.getSourceAttachmentRootPath();
          if (rootPath != null) {
            buf.append(IPath.SEPARATOR);
            buf.append(rootPath.toString());
          }
          buf.append(']');
        }
        // append JRE name if we can compute it
        if (path.equals(new Path(JavaRuntime.JRELIB_VARIABLE)) && fLaunchConfiguration != null) {
          try {
            IVMInstall vm = JavaRuntime.computeVMInstall(fLaunchConfiguration);
            buf.append(" - "); // $NON-NLS-1$
            buf.append(vm.getName());
          } catch (CoreException e) {
          }
        }
        return buf.toString();
      case IRuntimeClasspathEntry.CONTAINER:
        path = entry.getPath();
        if (fLaunchConfiguration != null) {
          try {
            IJavaProject project = null;
            try {
              project = JavaRuntime.getJavaProject(fLaunchConfiguration);
            } catch (CoreException e) {
            }
            if (project == null) {
            } else {
              IClasspathContainer container =
                  JavaCore.getClasspathContainer(entry.getPath(), project);
              if (container != null) {
                if (container.getDescription().startsWith("Persisted container")) {
                  return container.getPath().toString();
                } else {
                  return container.getDescription();
                }
              }
            }
          } catch (CoreException e) {
          }
        }
        return entry.getPath().toString();
      case IRuntimeClasspathEntry.OTHER:
        IRuntimeClasspathEntry delegate = entry;
        if (entry instanceof ClasspathEntry) {
          delegate = ((ClasspathEntry) entry).getDelegate();
        }
        String name = lp.getText(delegate);
        if (name == null || name.length() == 0) {
          return ((IRuntimeClasspathEntry2) delegate).getName();
        }
        return name;
    }
    return ""; //$NON-NLS-1$
  }