Search in sources :

Example 31 with IWorkspaceRoot

use of org.eclipse.core.resources.IWorkspaceRoot in project ow by vtst.

the class ResourceListField method get.

@Override
public List<T> get(IReadOnlyStore store) throws CoreException {
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    List<String> list = store.get(name, Collections.<String>emptyList());
    ArrayList<T> result = new ArrayList<T>(list.size());
    for (String s : list) {
        T resource = castResource(root.findMember(new Path(s)));
        if (resource != null)
            result.add(resource);
    }
    return result;
}
Also used : Path(org.eclipse.core.runtime.Path) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) SWT(org.eclipse.swt.SWT) ArrayList(java.util.ArrayList)

Example 32 with IWorkspaceRoot

use of org.eclipse.core.resources.IWorkspaceRoot in project sling by apache.

the class ImportWizardPage method queryForLocation.

protected IPath queryForLocation(IProject initialSelection, String msg, String title) {
    ContainerSelectionDialog dialog = new ContainerSelectionDialog(getControl().getShell(), initialSelection, allowNewContainerName(), msg);
    if (title != null) {
        dialog.setTitle(title);
    }
    dialog.showClosedProjects(false);
    dialog.setValidator(new ISelectionValidator() {

        @Override
        public String isValid(Object selection) {
            if (!(selection instanceof IPath)) {
                return "Please select a valid import location";
            }
            IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
            IContainer container = (IContainer) root.findMember((IPath) selection);
            if (container instanceof IProject) {
                return "Please select a folder inside the project";
            }
            if (!ProjectHelper.isContentProject(container.getProject())) {
                return "Project " + container.getProject().getName() + " is not a content project";
            }
            if (!ProjectUtil.isInsideContentSyncRoot(container)) {
                return "Please select a folder inside the content sync root folder " + ProjectUtil.getSyncDirectory(container.getProject()).getProjectRelativePath();
            }
            return null;
        }
    });
    dialog.open();
    Object[] result = dialog.getResult();
    if (result != null && result.length == 1) {
        return (IPath) result[0];
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) ContainerSelectionDialog(org.eclipse.ui.dialogs.ContainerSelectionDialog) ISelectionValidator(org.eclipse.ui.dialogs.ISelectionValidator) IContainer(org.eclipse.core.resources.IContainer) IProject(org.eclipse.core.resources.IProject)

Example 33 with IWorkspaceRoot

use of org.eclipse.core.resources.IWorkspaceRoot in project sling by apache.

the class ImportWizardPage method handleContainerBrowseButtonPressed.

private void handleContainerBrowseButtonPressed() {
    IPath result = queryForLocation(project, "Select a location to import data to", "Select location");
    if (result != null) {
        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
        importRoot = (IFolder) root.findMember(result);
        project = importRoot.getProject();
        containerNameField.setText(importRoot.getFullPath().toPortableString());
        repositoryCombo.setProject(project);
        repositoryCombo.refreshRepositoryList(new NullProgressMonitor());
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IPath(org.eclipse.core.runtime.IPath) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot)

Example 34 with IWorkspaceRoot

use of org.eclipse.core.resources.IWorkspaceRoot in project sling by apache.

the class TemporaryProject method before.

@Override
protected void before() throws Throwable {
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    project = root.getProject("test-project-" + COUNTER.incrementAndGet());
    project.create(new NullProgressMonitor());
    project.open(new NullProgressMonitor());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot)

Example 35 with IWorkspaceRoot

use of org.eclipse.core.resources.IWorkspaceRoot in project bndtools by bndtools.

the class AdjustClasspathsForNewProjectJob method runInWorkspace.

@Override
public IStatus runInWorkspace(IProgressMonitor monitor) {
    List<Project> projects;
    SubMonitor progress;
    try {
        projects = new ArrayList<Project>(Central.getWorkspace().getAllProjects());
        progress = SubMonitor.convert(monitor, projects.size());
    } catch (Exception e) {
        return Status.CANCEL_STATUS;
    }
    IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot();
    while (!projects.isEmpty()) {
        Project project = projects.remove(0);
        IProject eclipseProject = WorkspaceUtils.findOpenProject(wsroot, project);
        if (eclipseProject != null && !eclipseProject.equals(addedProject)) {
            try {
                project.propertiesChanged();
                IJavaProject javaProject = JavaCore.create(eclipseProject);
                if (javaProject != null) {
                    BndContainerInitializer.requestClasspathContainerUpdate(javaProject);
                }
            } catch (CoreException e) {
                logger.logStatus(e.getStatus());
                return Status.CANCEL_STATUS;
            }
            progress.worked(1);
        }
        if (progress.isCanceled())
            return Status.CANCEL_STATUS;
    }
    return Status.OK_STATUS;
}
Also used : Project(aQute.bnd.build.Project) IJavaProject(org.eclipse.jdt.core.IJavaProject) IProject(org.eclipse.core.resources.IProject) IJavaProject(org.eclipse.jdt.core.IJavaProject) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) SubMonitor(org.eclipse.core.runtime.SubMonitor) CoreException(org.eclipse.core.runtime.CoreException) IProject(org.eclipse.core.resources.IProject)

Aggregations

IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)172 IProject (org.eclipse.core.resources.IProject)69 IPath (org.eclipse.core.runtime.IPath)60 IResource (org.eclipse.core.resources.IResource)57 IFile (org.eclipse.core.resources.IFile)53 CoreException (org.eclipse.core.runtime.CoreException)50 IWorkspace (org.eclipse.core.resources.IWorkspace)34 File (java.io.File)30 Path (org.eclipse.core.runtime.Path)29 IContainer (org.eclipse.core.resources.IContainer)26 URI (java.net.URI)18 IFolder (org.eclipse.core.resources.IFolder)17 IOException (java.io.IOException)15 IProjectDescription (org.eclipse.core.resources.IProjectDescription)13 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)13 ArrayList (java.util.ArrayList)12 Test (org.junit.Test)12 IStatus (org.eclipse.core.runtime.IStatus)11 IJavaProject (org.eclipse.jdt.core.IJavaProject)11 Location (ch.acanda.eclipse.pmd.domain.Location)10