Search in sources :

Example 1 with IProjectDescription

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

the class JavaProjectHelper method addNatureToProject.

private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
    IProjectDescription description = proj.getDescription();
    String[] prevNatures = description.getNatureIds();
    String[] newNatures = new String[prevNatures.length + 1];
    System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
    newNatures[prevNatures.length] = natureId;
    description.setNatureIds(newNatures);
    proj.setDescription(description, monitor);
}
Also used : IProjectDescription(org.eclipse.core.resources.IProjectDescription)

Example 2 with IProjectDescription

use of org.eclipse.core.resources.IProjectDescription 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 3 with IProjectDescription

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

the class RenameJavaProjectChange method doRename.

@Override
protected void doRename(IProgressMonitor pm) throws CoreException {
    try {
        pm.beginTask(getName(), 2);
        if (fUpdateReferences)
            modifyClassPaths(new SubProgressMonitor(pm, 1));
        IProject project = getProject();
        if (project != null) {
            IProjectDescription description = project.getDescription();
            description.setName(getNewName());
            project.move(description, IResource.FORCE | IResource.SHALLOW, new SubProgressMonitor(pm, 1));
        }
    } finally {
        pm.done();
    }
}
Also used : IProjectDescription(org.eclipse.core.resources.IProjectDescription) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) IProject(org.eclipse.core.resources.IProject)

Example 4 with IProjectDescription

use of org.eclipse.core.resources.IProjectDescription in project generator by mybatis.

the class WorkspaceUtilities method addJavaNature.

private static void addJavaNature(String projectName) throws CoreException {
    IProject project = getWorkspaceRoot().getProject(projectName);
    IProjectDescription description = project.getDescription();
    description.setNatureIds(new String[] { JavaCore.NATURE_ID });
    project.setDescription(description, null);
}
Also used : IProjectDescription(org.eclipse.core.resources.IProjectDescription) IProject(org.eclipse.core.resources.IProject)

Example 5 with IProjectDescription

use of org.eclipse.core.resources.IProjectDescription in project dbeaver by serge-rider.

the class ProjectCreateWizard method createProject.

private void createProject(DBRProgressMonitor monitor) throws DBException, CoreException {
    final IProgressMonitor nestedMonitor = RuntimeUtils.getNestedMonitor(monitor);
    final IProject project = getNewProject();
    final IProjectDescription description = project.getDescription();
    if (!CommonUtils.isEmpty(data.getDescription())) {
        description.setComment(data.getDescription());
    }
    description.setNatureIds(new String[] { DBeaverNature.NATURE_ID });
    project.setDescription(description, nestedMonitor);
    if (!project.isOpen()) {
        project.open(nestedMonitor);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IProjectDescription(org.eclipse.core.resources.IProjectDescription) IProject(org.eclipse.core.resources.IProject)

Aggregations

IProjectDescription (org.eclipse.core.resources.IProjectDescription)36 IProject (org.eclipse.core.resources.IProject)17 CoreException (org.eclipse.core.runtime.CoreException)10 IWorkspace (org.eclipse.core.resources.IWorkspace)8 ICommand (org.eclipse.core.resources.ICommand)7 IPath (org.eclipse.core.runtime.IPath)6 IStatus (org.eclipse.core.runtime.IStatus)6 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)5 HashSet (java.util.HashSet)4 IResource (org.eclipse.core.resources.IResource)4 Status (org.eclipse.core.runtime.Status)4 File (java.io.File)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 URI (java.net.URI)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 Resource (org.eclipse.emf.ecore.resource.Resource)3 PersistenceException (org.talend.commons.exception.PersistenceException)3 Project (org.talend.core.model.general.Project)3 User (org.talend.core.model.properties.User)3 XmiResourceManager (org.talend.core.repository.utils.XmiResourceManager)3