org.eclipse.core.runtime.Path Java Examples

The following examples show how to use org.eclipse.core.runtime.Path. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Commit.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
protected URI createDiffLocation(String toRefId, String fromRefId, String path) throws URISyntaxException {
	IPath diffPath = new Path(GitServlet.GIT_URI).append(Diff.RESOURCE);

	// diff range format is [fromRef..]toRef
	String diffRange = ""; //$NON-NLS-1$
	if (fromRefId != null)
		diffRange = fromRefId + ".."; //$NON-NLS-1$
	diffRange += toRefId;
	diffPath = diffPath.append(diffRange);

	// clone location is of the form /gitapi/clone/file/{workspaceId}/{projectName}[/{path}]
	IPath clonePath = new Path(cloneLocation.getPath()).removeFirstSegments(2);
	if (path == null) {
		diffPath = diffPath.append(clonePath);
	} else if (isRoot) {
		diffPath = diffPath.append(clonePath).append(path);
	} else {
		// need to start from the project root
		// project path is of the form /file/{workspaceId}/{projectName}
		IPath projectRoot = clonePath.uptoSegment(3);
		diffPath = diffPath.append(projectRoot).append(path);
	}

	return new URI(cloneLocation.getScheme(), cloneLocation.getAuthority(), diffPath.toString(), null, null);
}
 
Example #2
Source File: RecipeModelWizard.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * The framework calls this to see if the file is correct.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated
 */
@Override
protected boolean validatePage ()
{
    if ( super.validatePage () )
    {
        final String extension = new Path ( getFileName () ).getFileExtension ();
        if ( extension == null || !FILE_EXTENSIONS.contains ( extension ) )
        {
            final String key = FILE_EXTENSIONS.size () > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; //$NON-NLS-1$ //$NON-NLS-2$
            setErrorMessage ( RecipeEditorPlugin.INSTANCE.getString ( key, new Object[] { FORMATTED_FILE_EXTENSIONS } ) );
            return false;
        }
        return true;
    }
    return false;
}
 
Example #3
Source File: GitTest.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
protected IPath createTempDir() throws CoreException {
	// get a temporary folder location, do not use /tmp
	File workspaceRoot = OrionConfiguration.getRootLocation().toLocalFile(EFS.NONE, null);
	File tmpDir = new File(workspaceRoot, SimpleMetaStoreUtil.ARCHIVE);
	if (!tmpDir.exists()) {
		tmpDir.mkdirs();
	}
	if (!tmpDir.exists() || !tmpDir.isDirectory()) {
		fail("Cannot find the default temporary-file directory: " + tmpDir.toString());
	}

	// get a temporary folder name
	SecureRandom random = new SecureRandom();
	long n = random.nextLong();
	n = (n == Long.MIN_VALUE) ? 0 : Math.abs(n);
	String tmpDirStr = Long.toString(n);
	File tempDir = new File(tmpDir, tmpDirStr);
	if (!tempDir.mkdir()) {
		fail("Cannot create a temporary directory at " + tempDir.toString());
	}
	return Path.fromOSString(tempDir.toString());
}
 
Example #4
Source File: NodeJSService.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Downloads a file from url, return the {@link File} on disk where it was saved.
 * 
 * @param url
 * @param monitor
 * @return
 * @throws CoreException
 */
private File download(URL url, String extension, IProgressMonitor monitor) throws CoreException
{
	DownloadManager manager = new DownloadManager();
	IPath path = Path.fromPortableString(url.getPath());
	String name = path.lastSegment();
	File f = new File(FileUtil.getTempDirectory().toFile(), name + extension);
	f.deleteOnExit();
	manager.addURL(url, f);
	IStatus status = manager.start(monitor);
	if (!status.isOK())
	{
		throw new CoreException(status);
	}
	List<IPath> locations = manager.getContentsLocations();
	return locations.get(0).toFile();
}
 
Example #5
Source File: TraceValidateAndImportOperation.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private IPath computeDestinationContainerPath(Path resourcePath) {
    IPath destinationContainerPath = fDestinationContainerPath;

    // We need to figure out the new destination path relative to the
    // selected "base" source directory.
    // Here for example, the selected source directory is /home/user
    if ((fImportOptionFlags & ImportTraceWizardPage.OPTION_PRESERVE_FOLDER_STRUCTURE) != 0) {
        // /home/user/bar/foo/trace -> /home/user/bar/foo
        IPath sourceContainerPath = resourcePath.removeLastSegments(1);
        if (fBaseSourceContainerPath.equals(resourcePath)) {
            // Use resourcePath directory if fBaseSourceContainerPath
            // points to a directory trace
            sourceContainerPath = resourcePath;
        }
        // /home/user/bar/foo, /home/user -> bar/foo
        IPath relativeContainerPath = sourceContainerPath.makeRelativeTo(fBaseSourceContainerPath);
        // project/Traces + bar/foo -> project/Traces/bar/foo
        destinationContainerPath = fDestinationContainerPath.append(relativeContainerPath);
    }
    return destinationContainerPath;
}
 
Example #6
Source File: WorkspaceFileGenerator.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
	SubMonitor subMonitor = SubMonitor.convert(monitor, files.size());
	try {
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
		for (Map.Entry<String, CharSequence> fileEntry : files.entrySet()) {
			IFile file = workspace.getRoot().getFile(new Path(fileEntry.getKey()));
			file.create(new StringInputStream(fileEntry.getValue().toString()), true, subMonitor);
			if (firstFile == null) {
				firstFile = file;
			}
			subMonitor.worked(1);
		}
	} finally {
		subMonitor.done();
	}
}
 
Example #7
Source File: CoreModelWizard.java    From ifml-editor with MIT License 6 votes vote down vote up
/**
 * The framework calls this to see if the file is correct. <!--
 * begin-user-doc --> <!-- end-user-doc -->
 * 
 * @generated
 */
@Override
protected boolean validatePage() {
	if (super.validatePage()) {
		String extension = new Path(getFileName()).getFileExtension();
		if (extension == null || !FILE_EXTENSIONS.contains(extension)) {
			String key = FILE_EXTENSIONS.size() > 1 ? "_WARN_FilenameExtensions"
					: "_WARN_FilenameExtension";
			setErrorMessage(IFMLMetamodelEditorPlugin.INSTANCE
					.getString(key,
							new Object[] { FORMATTED_FILE_EXTENSIONS }));
			return false;
		}
		return true;
	}
	return false;
}
 
Example #8
Source File: LegacyGWTHostPageSelectionDialog.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Builds the tree nodes for a set of modules and host pages.
 * 
 * @param modulesHostPages the set of modules along with their respective
 *          host pages
 * @return tree root nodes
 */
static LegacyGWTHostPageSelectionTreeItem[] buildTree(
    Map<String, Set<String>> modulesHostPages) {
  List<LegacyGWTHostPageSelectionTreeItem> treeItems = new ArrayList<LegacyGWTHostPageSelectionTreeItem>();
  for (String moduleName : modulesHostPages.keySet()) {
    LegacyGWTHostPageSelectionTreeItem moduleItem = new LegacyGWTHostPageSelectionTreeItem(
        Path.fromPortableString(moduleName.replace('.', '/')));
    treeItems.add(moduleItem);
    for (String hostPage : modulesHostPages.get(moduleName)) {
      new LegacyGWTHostPageSelectionTreeItem(
          Path.fromPortableString(hostPage), moduleItem);
    }
  }

  return treeItems.toArray(new LegacyGWTHostPageSelectionTreeItem[0]);
}
 
Example #9
Source File: BazelProjectSupport.java    From eclipse with Apache License 2.0 6 votes vote down vote up
private static void createClasspath(IPath root, List<String> paths, IJavaProject javaProject,
    int javaLanguageLevel) throws CoreException {
  String name = root.lastSegment();
  IFolder base = javaProject.getProject().getFolder(name);
  if (!base.isLinked()) {
    base.createLink(root, IResource.NONE, null);
  }
  List<IClasspathEntry> list = new LinkedList<>();
  for (String path : paths) {
    IPath workspacePath = base.getFullPath().append(path);
    list.add(JavaCore.newSourceEntry(workspacePath));
  }
  list.add(JavaCore.newContainerEntry(new Path(BazelClasspathContainer.CONTAINER_NAME)));

  list.add(
      JavaCore.newContainerEntry(new Path(STANDARD_VM_CONTAINER_PREFIX + javaLanguageLevel)));
  IClasspathEntry[] newClasspath = list.toArray(new IClasspathEntry[0]);
  javaProject.setRawClasspath(newClasspath, null);
}
 
Example #10
Source File: XpectCompareCommandHandler.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Display comparison view of test file with expected and actual xpect expectation
 */
private void displayComparisonView(ComparisonFailure cf, Description desc) {
	IXpectURIProvider uriProfider = XpectRunner.INSTANCE.getUriProvider();
	IFile fileTest = null;
	if (uriProfider instanceof N4IDEXpectTestURIProvider) {
		N4IDEXpectTestURIProvider fileCollector = (N4IDEXpectTestURIProvider) uriProfider;
		fileTest = ResourcesPlugin.getWorkspace().getRoot()
				.getFileForLocation(new Path(fileCollector.findRawLocation(desc)));
	}

	if (fileTest != null && fileTest.isAccessible()) {
		N4IDEXpectCompareEditorInput inp = new N4IDEXpectCompareEditorInput(fileTest, cf);
		CompareUI.openCompareEditor(inp);
	} else {
		throw new RuntimeException("paths in descriptions changed!");
	}
}
 
Example #11
Source File: IndexManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void readParticipantsIndexNamesFile() {
	SimpleLookupTable containers = new SimpleLookupTable(3);
	try {
		char[] participantIndexNames = org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(this.participantIndexNamesFile, null);
		if (participantIndexNames.length > 0) {
			char[][] names = CharOperation.splitOn('\n', participantIndexNames);
			if (names.length >= 3) {
				// First line is DiskIndex signature  (see writeParticipantsIndexNamesFile())
				if (DiskIndex.SIGNATURE.equals(new String(names[0]))) {					
					for (int i = 1, l = names.length-1 ; i < l ; i+=2) {
						IndexLocation indexLocation = new FileIndexLocation(new File(new String(names[i])), true);
						containers.put(indexLocation, new Path(new String(names[i+1])));
					}
				}				
			}
		}	
	} catch (IOException ignored) {
		if (VERBOSE)
			Util.verbose("Failed to read participant index file names"); //$NON-NLS-1$
	}
	this.participantsContainers = containers;
	return;
}
 
Example #12
Source File: XtextProjectCreator.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private void configurePlainProject(ProjectDescriptor descriptor, ProjectFactory factory) {
	factory.setProjectName(descriptor.getName());
	factory.setLocation(new Path(descriptor.getLocation()));
	factory.setProjectDefaultCharset(projectInfo.getEncoding().toString());
	factory.addWorkingSets(Lists.newArrayList(projectInfo.getWorkingSets()));
	factory.addContributor(new DescriptorBasedContributor(descriptor));
	if (needsM2eIntegration(descriptor)) {
		factory.addProjectNatures("org.eclipse.m2e.core.maven2Nature");
		factory.addBuilderIds("org.eclipse.m2e.core.maven2Builder");
	}
	if (needsBuildshipIntegration(descriptor)) {
		factory.addProjectNatures("org.eclipse.buildship.core.gradleprojectnature");
		factory.addBuilderIds("org.eclipse.buildship.core.gradleprojectbuilder");
		factory.addEarlyContributor(new GradleContributor(descriptor));
	}
}
 
Example #13
Source File: RadlNewWizardPage.java    From RADL with Apache License 2.0 6 votes vote down vote up
private void validateInput() {
  if (getFolderName().length() == 0) {
    updateStatus("Folder must be specified");
    return;
  }
  IResource resource = root.findMember(new Path(getFolderName()));
  if (resource != null && resource.exists() && !(resource instanceof IFolder)) {
    updateStatus("Invalid folder");
    return;
  }
  String serviceName = getServiceName();
  if (serviceName.isEmpty()) {
    updateStatus("Service name must be specified");
    return;
  }
  updateStatus(null);
}
 
Example #14
Source File: RefactoringRenameTestBase.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
public void setUpConfigWorkspaceFiles() throws Exception {
    projectStub = new org.python.pydev.shared_core.resource_stubs.ProjectStub(
            new File(TestDependent.TEST_COM_REFACTORING_PYSRC_LOC),
            natureRefactoring);
    TextEditCreation.createWorkspaceFile = new ICallback<IFile, File>() {

        @Override
        public IFile call(File file) {
            return new FileStub(projectStub, file) {
                @Override
                public IPath getFullPath() {
                    return Path.fromOSString(this.file.getAbsolutePath());
                }

            };
        }
    };
}
 
Example #15
Source File: RouteResourcesHelper.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
private static String getFileName(Item item) {
	String label = item.getProperty().getLabel();
	String selectedVersion = item.getProperty().getVersion();

	if ("Latest".equals(selectedVersion)) {
		return label;
	}

	IPath path = new Path(label);
	String fileExtension = path.getFileExtension();
	String fileName = path.removeFileExtension().toPortableString();
	fileName = fileName + "_" + selectedVersion;
	if (fileExtension != null && !fileExtension.isEmpty()) {
		fileName = fileName + "." + fileExtension;
	}
	return fileName;
}
 
Example #16
Source File: NativeLibrariesConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public NativeLibrariesConfigurationBlock(IStatusChangeListener listener, Shell parent, String nativeLibPath, IClasspathEntry parentEntry) {
	fListener= listener;
	fEntry= parentEntry;

	NativeLibrariesAdapter adapter= new NativeLibrariesAdapter();

	fPathField= new StringDialogField();
	fPathField.setLabelText(NewWizardMessages.NativeLibrariesDialog_location_label);
	fPathField.setDialogFieldListener(adapter);

	fBrowseWorkspace= new SelectionButtonDialogField(SWT.PUSH);
	fBrowseWorkspace.setLabelText(NewWizardMessages.NativeLibrariesDialog_workspace_browse);
	fBrowseWorkspace.setDialogFieldListener(adapter);

	fBrowseExternal= new SelectionButtonDialogField(SWT.PUSH);
	fBrowseExternal.setLabelText(NewWizardMessages.NativeLibrariesDialog_external_browse);
	fBrowseExternal.setDialogFieldListener(adapter);

	if (nativeLibPath != null) {
		fPathField.setText(Path.fromPortableString(nativeLibPath).toString());
		fOrginalValue= nativeLibPath;
	} else {
		fOrginalValue= ""; //$NON-NLS-1$
	}
}
 
Example #17
Source File: DotnetRunTab.java    From aCute with Eclipse Public License 2.0 6 votes vote down vote up
private void updateProjectPath() {
	frameworkViewer.getList().removeAll();
	IPath projectFilePath = ProjectFileAccessor.getProjectFile(projectContainer);
	if (projectFilePath == null) {
		frameworkViewer.add(Messages.DotnetRunTab_noFrameworks);
		frameworkViewer.getList().setEnabled(false);
		return;
	}

	frameworkViewer.getList().deselectAll();
	frameworkViewer.add(Messages.DotnetRunTab_loadingFrameworks);
	frameworkViewer.getList().setEnabled(false);
	targetFrameworks = ProjectFileAccessor.getTargetFrameworks(
			new Path(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getAbsolutePath().toString()
					+ projectFilePath.toString()));
	frameworkViewer.getList().removeAll();
	if (targetFrameworks.length > 0) {
		frameworkViewer.add(targetFrameworks);
		frameworkViewer.getList().select(0);
		frameworkViewer.getList().setEnabled(true);
	} else {
		frameworkViewer.add(Messages.DotnetRunTab_noFrameworks);
		frameworkViewer.getList().setEnabled(false);
	}
}
 
Example #18
Source File: WorkspaceServlet.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	traceRequest(req);
	String pathString = req.getPathInfo();
	IPath path = new Path(pathString == null ? "" : pathString); //$NON-NLS-1$
	if (path.segmentCount() > 0) {
		try {
			WorkspaceInfo workspace = OrionConfiguration.getMetaStore().readWorkspace(path.segment(0));
			if (workspaceResourceHandler.handleRequest(req, resp, workspace))
				return;
		} catch (CoreException e) {
			handleException(resp, "Error reading workspace metadata", e);
			return;
		}
	}
	super.doDelete(req, resp);
}
 
Example #19
Source File: PreviousAction.java    From ice with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * <p>
 * The constructor
 * </p>
 * 
 * @param parent
 *            <p>
 *            The ViewPart to whom the object of this class belongs.
 *            </p>
 */
public PreviousAction(PlayableViewPart parent) {

	// Set the calling class to the local ViewPart field
	viewer = parent;

	// Set the "hover" text
	this.setText("Previous");

	// Set the button image
	Bundle bundle = FrameworkUtil.getBundle(getClass());
	Path imagePath = new Path("icons" + System.getProperty("file.separator")
			+ "previous.gif");
	URL imageURL = FileLocator.find(bundle, imagePath, null);
	ImageDescriptor imageDescriptor = ImageDescriptor
			.createFromURL(imageURL);
	this.setImageDescriptor(imageDescriptor);

	return;
}
 
Example #20
Source File: MultiModuleMoveRefactoringRequest.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
public MultiModuleMoveRefactoringRequest(List<ModuleRenameRefactoringRequest> requests, IContainer target)
        throws MisconfigurationException, TargetNotInPythonpathException {
    super(requests.toArray(new RefactoringRequest[requests.size()]));
    PythonNature nature = PythonNature.getPythonNature(target);
    File file = target.getLocation().toFile();
    this.target = target;
    this.initialName = nature.resolveModule(file);
    IPath fullPath = target.getFullPath();
    if (this.initialName == null) {
        //Check if it's a source folder...
        try {
            Set<String> projectSourcePathSet = nature.getPythonPathNature().getProjectSourcePathSet(true);
            for (String string : projectSourcePathSet) {
                if (new Path(string).equals(fullPath)) {
                    this.initialName = "";
                    break;
                }
            }
        } catch (CoreException e) {
            Log.log(e);
        }
    }
    if (this.initialName == null) {
        throw new TargetNotInPythonpathException("Unable to resolve file as a python module: " + fullPath);
    }
}
 
Example #21
Source File: DetailViewModelWizard.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * The framework calls this to see if the file is correct.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
protected boolean validatePage ()
{
    if ( super.validatePage () )
    {
        String extension = new Path ( getFileName () ).getFileExtension ();
        if ( extension == null || !FILE_EXTENSIONS.contains ( extension ) )
        {
            String key = FILE_EXTENSIONS.size () > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; //$NON-NLS-1$ //$NON-NLS-2$
            setErrorMessage ( DetailViewEditorPlugin.INSTANCE.getString ( key, new Object[] { FORMATTED_FILE_EXTENSIONS } ) );
            return false;
        }
        return true;
    }
    return false;
}
 
Example #22
Source File: AnalysisEngineMainTab.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
private IContainer getContainer(String path) {
Path containerPath = new Path(path);
IResource resource =  getWorkspaceRoot().findMember(containerPath);
if (resource instanceof IContainer)
  return (IContainer) resource;
   
   return null;
 }
 
Example #23
Source File: WebAppLaunchShortcut.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Calculate launch configuration name.
 *
 * @return a launch configuration name.
 */
private static String calculateLaunchConfigName(String startupUrl, boolean isExternal, IResource resource) {
  String launchConfigName = "";
  if ("".equals(startupUrl)) {
    launchConfigName = resource.getProject().getName();
  } else {
    try {
      URL url = new URL(startupUrl);
      String path = url.getPath();
      String hostPageName = new Path(path).lastSegment();
      if (hostPageName != null) {
        launchConfigName = hostPageName;
      } else {
        // No path was specified, use the host name
        launchConfigName = url.getHost();
      }

    } catch (MalformedURLException e) {
      // If the startup URL is not a true URL, just a path plus a file name,
      // then use the file name which is the last segment of the path.
      // Eclipse doesn't correctly handle slashes in launch config names,
      // which occur in legacy GWT cases.
      launchConfigName = new Path(startupUrl).lastSegment();
    }
  }

  if (isExternal) {
    return launchConfigName + "-external";
  }

  return launchConfigName;
}
 
Example #24
Source File: CreateAppEngineWtpProjectTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoTestClassesInDeploymentAssembly() throws InvocationTargetException,
    CoreException, OperationCanceledException, InterruptedException {
  CreateAppEngineWtpProject creator = newCreateAppEngineWtpProject();
  creator.execute(monitor);
  creator.deployAssemblyEntryRemoveJob.join(180000 /* 3 minutes */, monitor);

  assertFalse(DeployAssemblyEntryRemoveJobTest.hasSourcePathInDeployAssembly(project,
      new Path("src/test/java")));
  assertTrue(DeployAssemblyEntryRemoveJobTest.hasSourcePathInDeployAssembly(project,
      new Path("src/main/java")));
}
 
Example #25
Source File: ReconcileContext.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
public String getName()
{
	String name = super.getName();
	if (name != null)
	{
		return name;
	}
	return Path.fromPortableString(getURI().getPath()).lastSegment();
}
 
Example #26
Source File: InvisibleProjectImporterTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void getPackageNameInSrcEmptyFile() throws Exception {
	File projectFolder = copyFiles("singlefile", true);
	IProject invisibleProject = importRootFolder(projectFolder, "lesson1/src/main/java/demosamples/Empty1.java");
	assertTrue(invisibleProject.exists());

	IPath workspaceRoot = Path.fromOSString(projectFolder.getAbsolutePath());
	IPath javaFile = workspaceRoot.append("lesson1/src/main/java/demosamples/Empty1.java");
	String packageName = InvisibleProjectImporter.getPackageName(javaFile, workspaceRoot, JavaCore.create(invisibleProject));
	assertEquals("main.java.demosamples", packageName);
}
 
Example #27
Source File: PathsProvider.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void addSelectedPaths(FileDialog dialog) {
    String[] names = getFileNames(dialog);
    String filterPath = getFilePath(dialog);
    Path baseDir = new Path(filterPath);
    setLastUsedPath(baseDir);
    for (String fileName : names) {
        IPath path = baseDir.append(fileName);
        PathElement pathElt = new PathElement(path, Status.OK_STATUS);
        if (!paths.contains(pathElt)) {
            paths.add(pathElt);
        }
    }
}
 
Example #28
Source File: LibraryClasspathContainerInitializerTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testInitialize_ifSourcePathIsNullContainerIsNotResolvedAgain()
    throws CoreException, IOException {
  File artifactFile = temporaryFolder.newFile();

  IPath sourceAttachmentPath = null;
  IPath sourceAttachmentRootPath = null;
  IClasspathEntry entry = JavaCore.newLibraryEntry(new Path(artifactFile.getAbsolutePath()),
      sourceAttachmentPath, sourceAttachmentRootPath);

  IClasspathEntry[] entries = new IClasspathEntry[]{ entry };
  LibraryClasspathContainer container = mock(LibraryClasspathContainer.class);
  when(container.getClasspathEntries()).thenReturn(entries);
  when(serializer.loadContainer(any(IJavaProject.class), any(IPath.class))).thenReturn(container);

  LibraryClasspathContainerInitializer containerInitializer =
      new LibraryClasspathContainerInitializer(TEST_CONTAINER_PATH, serializer, resolverService);
  containerInitializer.initialize(new Path(TEST_LIBRARY_PATH), testProject.getJavaProject());
  testProject.getJavaProject().getRawClasspath();
  IClasspathEntry[] resolvedClasspath = testProject.getJavaProject().getResolvedClasspath(false);
  
  for (IClasspathEntry resolvedEntry : resolvedClasspath) {
    if (resolvedEntry.getPath().toOSString().equals(artifactFile.getAbsolutePath())) {
      verifyResolveServiceResolveContainerNotCalled();
      return;
    }
  }
  fail("classpath entry not found");
}
 
Example #29
Source File: CheckTocExtensionTest.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
@Before
@Override
public void setUp() throws Exception {
  catalog = parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE);
  IFile pluginxml = workspace.getRoot().getFile(new Path("/test/plugin.xml"));
  pluginModel = new WorkspacePluginModel(pluginxml, false);

}
 
Example #30
Source File: ClassPathBlock.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public static IPath[] chooseExternalJAREntries( Shell shell )
{
	if ( lastUsedPath == null )
	{
		lastUsedPath = ""; //$NON-NLS-1$
	}
	FileDialog dialog = new FileDialog( shell, SWT.MULTI );
	dialog.setText( Messages.getString( "ClassPathBlock_FileDialog.jar.text" ) ); //$NON-NLS-1$
	dialog.setFilterExtensions( ALL_ARCHIVES_FILTER_EXTENSIONS );
	dialog.setFilterPath( lastUsedPath );

	String res = dialog.open( );
	if ( res == null )
	{
		return null;
	}
	String[] fileNames = dialog.getFileNames( );
	int nChosen = fileNames.length;

	IPath filterPath = Path.fromOSString( dialog.getFilterPath( ) );
	IPath[] elems = new IPath[nChosen];
	for ( int i = 0; i < nChosen; i++ )
	{
		elems[i] = filterPath.append( fileNames[i] ).makeAbsolute( );
	}
	lastUsedPath = dialog.getFilterPath( );

	return elems;
}