Java Code Examples for org.eclipse.core.resources.IProject#getLocationURI()

The following examples show how to use org.eclipse.core.resources.IProject#getLocationURI() . 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: ProjectTestsUtils.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Copies projects from the given location to the node_modules folder of the given project
 */
public static void importDependencies(N4JSProjectName projectName, java.net.URI externalRootLocation,
		LibraryManager libraryManager) throws IOException, CoreException {

	IProject clientProject = getProjectByName(projectName.toEclipseProjectName());
	java.net.URI clientLocation = clientProject.getLocationURI();
	File nodeModulesDir = new File(clientLocation.getPath(), N4JSGlobals.NODE_MODULES);
	if (!nodeModulesDir.isDirectory()) {
		Files.createDirectory(nodeModulesDir.toPath());
	}

	java.nio.file.Path probandsSource = Paths.get(externalRootLocation.getPath());
	FileCopier.copy(probandsSource, nodeModulesDir.toPath());

	libraryManager.synchronizeNpms(new NullProgressMonitor());

	IResourcesSetupUtil.fullBuild();
	waitForAllJobs();
}
 
Example 2
Source File: IndexBuildParticipant.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
protected URI getURI(IProject project)
{
	if (project == null)
	{
		return null;
	}
	URI uri = project.getLocationURI();
	if (uri != null)
	{
		return uri;
	}
	IdeLog.logError(BuildPathCorePlugin.getDefault(),
			MessageFormat.format("Project's location URI is null. raw location: {0}, path: {1}", //$NON-NLS-1$
					project.getRawLocationURI(), project.getFullPath()));
	return project.getRawLocationURI();
}
 
Example 3
Source File: UnifiedBuilder.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * For a full build, we grab all files inside the project and then call build on each file.
 * 
 * @param monitor
 * @throws CoreException
 */
private void fullBuild(List<IBuildParticipant> participants, IProgressMonitor monitor) throws CoreException
{
	SubMonitor sub = SubMonitor.convert(monitor, 100);

	indexProjectBuildPaths(sub.newChild(50));

	// Index files contributed...
	// TODO Remove these special "contributed" files?
	IProject project = getProjectHandle();
	URI uri = project.getLocationURI();
	Set<IFileStore> contributedFiles = getContributedFiles(uri);
	sub.worked(2);
	buildContributedFiles(participants, contributedFiles, sub.newChild(6));

	// Now index the actual files in the project
	CollectingResourceVisitor visitor = new CollectingResourceVisitor();
	project.accept(visitor);
	visitor.files.trimToSize(); // shrink it down to size when we're done
	sub.worked(2);
	buildFiles(participants, visitor.files, sub.newChild(40));

	sub.done();
}
 
Example 4
Source File: VerySimpleBuilder.java    From textuml with Eclipse Public License 1.0 6 votes vote down vote up
protected void createMarkers(IProject project, IProblem[] problems) throws CoreException {
    URI projectURI = project.getLocationURI();
    for (int i = 0; i < problems.length; i++) {
        IFileStore source = (IFileStore) problems[i].getAttribute(IProblem.FILE_NAME);
        IResource target = project;
        if (source != null) {
            final URI sourceURI = source.toURI();
            if (sourceURI != null) {
                URI relativeURI = projectURI.relativize(sourceURI);
                if (!relativeURI.isAbsolute())
                    target = project.getFile(new Path(relativeURI.getPath()));
            }
        }
        IMarker marker = target.createMarker(UIConstants.MARKER_TYPE);
        marker.setAttribute(IMarker.SEVERITY, getMarkerSeverity(problems[i].getSeverity()));
        marker.setAttribute(IMarker.MESSAGE, problems[i].getMessage());
        marker.setAttribute(IMarker.LINE_NUMBER, getLineNumber(problems[i]));
    }
}
 
Example 5
Source File: SVNMoveDeleteHook.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public boolean deleteProject(IResourceTree tree, IProject project, int updateFlags, IProgressMonitor monitor) {
      ISVNLocalFolder resource = new LocalFolder(project);
      try {
      	// If contents are not being deleted, let Eclipse handle.
      	if ((updateFlags & IResource.NEVER_DELETE_PROJECT_CONTENT) == IResource.NEVER_DELETE_PROJECT_CONTENT) {
      		return false;
      	}
      	
      	// If not managed, let Eclipse handle.
	if (!resource.isManaged())
	    return false;
	
	File projectDirectory = new File(project.getLocationURI());
	
	// If meta directory does not exist, let Eclipse handle.
	File metaFolder = new File(projectDirectory, ".svn"); //$NON-NLS-1$
	if (!metaFolder.exists()) {
		return false;
	}
	
	// If database file does not exist, let Eclipse handle.
	File databaseFile = new File(metaFolder, "wc.db"); //$NON-NLS-1$
	if (!databaseFile.exists()) {
		return false;
	}
	
	// If we can delete database file, let Eclipse handle project deletion.
	if (databaseFile.delete()) {
		return false;
	}
	
	// Show message dialog in UI thread and cancel deletion.
	SVNProviderPlugin.handleMessage(Policy.bind("SVNMoveDeleteHook.4"), Policy.bind("SVNMoveDeleteHook.5") + project.getName() + Policy.bind("SVNMoveDeleteHook.6"), IMessageHandler.ERROR); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	return true;
	
} catch (Exception e) {
	// Let Eclipse try to handle it.
	return false;
}
  }
 
Example 6
Source File: RemoveIndexOfFilesOfProjectJob.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public RemoveIndexOfFilesOfProjectJob(IProject project, Set<IFile> files)
{
	super(MessageFormat.format(Messages.RemoveIndexOfFilesOfProjectJob_Name, project.getName()), project
			.getLocationURI());
	this.project = project;
	this.files = files;
}
 
Example 7
Source File: IndexFilesOfProjectJob.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public IndexFilesOfProjectJob(IProject project, Set<IFile> files)
{
	super(MessageFormat.format(Messages.IndexFilesOfProjectJob_Name, project.getName()), project.getLocationURI());
	this.project = project;
	this.files = files;
}
 
Example 8
Source File: EditorUtil.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Gets the project URI associated with the editor.
 * 
 * @return the project URI
 */
public static URI getProjectURI(AbstractThemeableEditor editor)
{
	IProject project = getProject(editor);
	return (project == null) ? null : project.getLocationURI();
}
 
Example 9
Source File: VerySimpleBuilder.java    From textuml with Eclipse Public License 1.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
    IProject toBuild = getProject();

    // mark all referencing as needing rebuild
    for (IProject referencing : toBuild.getReferencingProjects())
        referencing.touch(monitor);

    // build location context
    IFileStore storeToBuild = EFS.getStore(toBuild.getLocationURI());
    LocationContext context = new LocationContext(storeToBuild);
    context.addSourcePath(storeToBuild, null);
    for (IProject referenced : toBuild.getReferencedProjects()) {
        URI referencedLocation = referenced.getLocationURI();
        if (referencedLocation != null) {
            IFileStore modelPathEntry = EFS.getStore(referencedLocation);
            context.addRelatedPath(modelPathEntry);
        }
    }

    removeMarkers(toBuild);
    IProblem[] problems = FrontEnd.getCompilationDirector().compile(null, null, context,
            ICompilationDirector.FULL_BUILD, monitor);
    toBuild.refreshLocal(IResource.DEPTH_INFINITE, null);
    Arrays.sort(problems, new Comparator<IProblem>() {
        public int compare(IProblem o1, IProblem o2) {
            if ((o1 instanceof InternalProblem) || (o2 instanceof InternalProblem)) {
                if (!(o1 instanceof InternalProblem))
                    return 1;
                if (!(o2 instanceof InternalProblem))
                    return -1;
                return 0;
            }
            int fileNameDelta = ((IFileStore) o1.getAttribute(IProblem.FILE_NAME)).toURI().compareTo(
                    ((IFileStore) o2.getAttribute(IProblem.FILE_NAME)).toURI());
            if (fileNameDelta != 0)
                return fileNameDelta;
            int lineNo1 = getLineNumber(o1);
            int lineNo2 = getLineNumber(o2);
            return lineNo1 - lineNo2;
        }

    });
    createMarkers(toBuild, problems);
    return null;
}