Search in sources :

Example 71 with IProject

use of org.eclipse.core.resources.IProject in project jop by jop-devel.

the class JOPPropertyPage method performDefaults.

/* (non-Javadoc)
     * @see org.eclipse.jface.preference.FieldEditorPreferencePage#performDefaults()
     */
@Override
public void performDefaults() {
    super.performDefaults();
    IProject project = getProject();
    IPath projectRoot = project.getLocation();
    IScopeContext scopeContext = new ProjectScope(project);
    Preferences projectPrefs = scopeContext.getNode(IJOPUIConstants.PLUGIN_ID);
    jopDirectoryEditor.setStringValue(projectPrefs.get(IJOPLaunchConfigurationConstants.ATTR_JOP_HOME, projectRoot.toOSString()));
    IPath defaultQuartusProjectFile = projectRoot.append("quartus").append("cycmin").append("jop").addFileExtension("qpf");
    quartusProjectFileEditor.setStringValue(projectPrefs.get(IJOPLaunchConfigurationConstants.ATTR_QUARTUS_PROJECT, defaultQuartusProjectFile.toOSString()));
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) IPath(org.eclipse.core.runtime.IPath) Preferences(org.osgi.service.prefs.Preferences) IProject(org.eclipse.core.resources.IProject)

Example 72 with IProject

use of org.eclipse.core.resources.IProject in project jop by jop-devel.

the class ToggleJOPNatureAction method run.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
public void run(IAction action) {
    if (selection instanceof IStructuredSelection) {
        for (Iterator it = ((IStructuredSelection) selection).iterator(); it.hasNext(); ) {
            Object element = it.next();
            IProject project = null;
            if (element instanceof IProject) {
                project = (IProject) element;
            } else if (element instanceof IAdaptable) {
                project = (IProject) ((IAdaptable) element).getAdapter(IProject.class);
            }
            if (project != null) {
                toggleNature(project);
                System.err.println(project + " > Nature");
                PropertyTester jopPropTest = new JOPNaturePropertyTester();
                jopPropTest.test(project, "hasJOPNature", null, null);
            }
        }
    }
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) PropertyTester(org.eclipse.core.expressions.PropertyTester) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IProject(org.eclipse.core.resources.IProject)

Example 73 with IProject

use of org.eclipse.core.resources.IProject in project che by eclipse.

the class Project method getDescription.

@Override
public IProjectDescription getDescription() throws CoreException {
    return new IProjectDescription() {

        @Override
        public IBuildConfiguration[] getBuildConfigReferences(String s) {
            return new IBuildConfiguration[0];
        }

        @Override
        public ICommand[] getBuildSpec() {
            return new ICommand[0];
        }

        @Override
        public String getComment() {
            return null;
        }

        @Override
        public IProject[] getDynamicReferences() {
            return new IProject[0];
        }

        @Override
        public IPath getLocation() {
            return null;
        }

        @Override
        public URI getLocationURI() {
            return null;
        }

        @Override
        public String getName() {
            return null;
        }

        @Override
        public String[] getNatureIds() {
            RegisteredProject project = workspace.getProjectRegistry().getProject(path.toString());
            if (project == null) {
                ResourcesPlugin.log(new Status(IStatus.ERROR, "resource", "Can't find project: " + path.toOSString()));
                return new String[0];
            }
            Map<String, List<String>> attributes = project.getAttributes();
            String language = "";
            if (attributes.containsKey("language")) {
                language = attributes.get("language").get(0);
            }
            return "java".equals(language) ? new String[] { "org.eclipse.jdt.core.javanature" } : new String[] { language };
        }

        @Override
        public IProject[] getReferencedProjects() {
            return new IProject[0];
        }

        @Override
        public boolean hasNature(String s) {
            String[] natureIds = getNatureIds();
            for (String id : natureIds) {
                if (s.equals(id)) {
                    return true;
                }
            }
            return false;
        }

        @Override
        public ICommand newCommand() {
            return null;
        }

        @Override
        public void setActiveBuildConfig(String s) {
        }

        @Override
        public void setBuildConfigs(String[] strings) {
        }

        @Override
        public void setBuildConfigReferences(String s, IBuildConfiguration[] iBuildConfigurations) {
        }

        @Override
        public void setBuildSpec(ICommand[] iCommands) {
        }

        @Override
        public void setComment(String s) {
        }

        @Override
        public void setDynamicReferences(IProject[] iProjects) {
        }

        @Override
        public void setLocation(IPath iPath) {
        }

        @Override
        public void setLocationURI(URI uri) {
        }

        @Override
        public void setName(String s) {
        }

        @Override
        public void setNatureIds(String[] strings) {
        }

        @Override
        public void setReferencedProjects(IProject[] iProjects) {
        }
    };
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IPath(org.eclipse.core.runtime.IPath) ICommand(org.eclipse.core.resources.ICommand) IProjectDescription(org.eclipse.core.resources.IProjectDescription) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) List(java.util.List) URI(java.net.URI) IProject(org.eclipse.core.resources.IProject) IBuildConfiguration(org.eclipse.core.resources.IBuildConfiguration)

Example 74 with IProject

use of org.eclipse.core.resources.IProject in project che by eclipse.

the class WorkspaceRoot method getProjects.

@Override
public IProject[] getProjects() {
    ProjectRegistry projectRegistry = workspace.getProjectRegistry();
    List<IProject> projects = new ArrayList<>();
    List<RegisteredProject> rootProjects = projectRegistry.getProjects();
    for (RegisteredProject rootProject : rootProjects) {
        Project project = new Project(new Path(rootProject.getPath()), workspace);
        projects.add(project);
    }
    return projects.toArray(new IProject[projects.size()]);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IProject(org.eclipse.core.resources.IProject) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) ArrayList(java.util.ArrayList) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) IProject(org.eclipse.core.resources.IProject)

Example 75 with IProject

use of org.eclipse.core.resources.IProject in project che by eclipse.

the class WorkspaceRoot method getProject.

@Override
public IProject getProject(String name) {
    //first check our project cache
    Project result = projectTable.get(name);
    if (result == null) {
        IPath projectPath = new Path(null, name).makeAbsolute();
        //try to get the project using a canonical name
        //.lastSegment();
        String canonicalName = projectPath.toOSString();
        result = projectTable.get(canonicalName);
        if (result != null)
            return result;
        result = new Project(projectPath, workspace);
        projectTable.putIfAbsent(canonicalName, result);
    }
    return result;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IProject(org.eclipse.core.resources.IProject) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) IPath(org.eclipse.core.runtime.IPath)

Aggregations

IProject (org.eclipse.core.resources.IProject)665 CoreException (org.eclipse.core.runtime.CoreException)157 IFile (org.eclipse.core.resources.IFile)142 Test (org.junit.Test)130 IResource (org.eclipse.core.resources.IResource)112 IPath (org.eclipse.core.runtime.IPath)98 IFolder (org.eclipse.core.resources.IFolder)77 File (java.io.File)73 IOException (java.io.IOException)70 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)70 Path (org.eclipse.core.runtime.Path)70 IJavaProject (org.eclipse.jdt.core.IJavaProject)68 ArrayList (java.util.ArrayList)67 IWorkspace (org.eclipse.core.resources.IWorkspace)55 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)48 ByteArrayInputStream (java.io.ByteArrayInputStream)45 ProjectAdapter (org.apache.sling.ide.test.impl.helpers.ProjectAdapter)45 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)41 IProjectDescription (org.eclipse.core.resources.IProjectDescription)38 IStatus (org.eclipse.core.runtime.IStatus)35