private void setProjectNatures(IProject project, IPluginModelBase model) throws CoreException { IProjectDescription desc = project.getDescription(); if (!desc.hasNature(PDE.PLUGIN_NATURE)) { CoreUtility.addNatureToProject(project, PDE.PLUGIN_NATURE, null); } if (!desc.hasNature(JavaCore.NATURE_ID) && needsJavaNature(project, model)) { CoreUtility.addNatureToProject(project, JavaCore.NATURE_ID, null); } }
@Override public boolean hasNature(String natureID) throws CoreException { checkAccessible(getFlags(getResourceInfo(false, false))); // use #internal method to avoid copy but still throw an // exception if the resource doesn't exist. IProjectDescription desc = internalGetDescription(); if (desc == null) checkAccessible(NULL_FLAG); return desc.hasNature(natureID); }
@Override public boolean hasNature(String natureID) throws CoreException { checkAccessible(getFlags(getResourceInfo(false, false))); // use #internal method to avoid copy but still throw an // exception if the resource doesn't exist. IProjectDescription desc = internalGetDescription(); if (desc == null) checkAccessible(NULL_FLAG); return desc.hasNature(natureID); }
@Override public boolean hasNature(String natureID) throws CoreException { checkAccessible(getFlags(getResourceInfo(false, false))); // use #internal method to avoid copy but still throw an // exception if the resource doesn't exist. IProjectDescription desc = internalGetDescription(); if (desc == null) checkAccessible(NULL_FLAG); return desc.hasNature(natureID); }
/** * Returns the java element associated with the project. * * @param project the project, can be <code>null</code> * @return the associated java element, or <code>null</code> if the project is not a Java * project */ private IJavaProject asJavaProject(final IProject project) { if (project == null) return null; try { if (project.getDescription().hasNature(JavaCore.NATURE_ID)) return JavaCore.create(project); } catch (final CoreException exception) { // Only log the error for projects that are accessible (i.e. exist and are open) if (project.isAccessible()) JavaPlugin.log(exception); } return null; }
/** * Returns the java element associated with the project. * * @param project the project, can be <code>null</code> * @return the associated java element, or <code>null</code> if the project is not a Java * project */ private IJavaProject asJavaProject(final IProject project) { if (project == null) return null; try { if (project.getDescription().hasNature(JavaCore.NATURE_ID)) return JavaCore.create(project); } catch (final CoreException exception) { // Only log the error for projects that are accessible (i.e. exist and are open) if (project.isAccessible()) JavaPlugin.log(exception); } return null; }
/** * Returns the java element associated with the project. * * @param project * the project * @return the associated java element, or <code>null</code> if the * project is not a java project */ private IJavaProject asJavaProject(final IProject project) { try { if (project.getDescription().hasNature(JavaCore.NATURE_ID)) return JavaCore.create(project); } catch (final CoreException exception) { // Only log the error for projects that are accessible (i.e. exist and are open) if (project.isAccessible()) JavaPlugin.log(exception); } return null; }
public static void addProjectNature(IProject project, String natureID, boolean addFirst) { try { IProjectDescription description = project.getDescription(); if (description.hasNature(natureID)) { return; } String[] natures = description.getNatureIds(); String[] newNatures = new String[natures.length + 1]; if (addFirst) { System.arraycopy(natures, 0, newNatures, 1, natures.length); newNatures[0] = natureID; } else { System.arraycopy(natures, 0, newNatures, 0, natures.length); newNatures[natures.length] = natureID; } IStatus status = project.getWorkspace().validateNatureSet(newNatures); if (status.getCode() == IStatus.OK) { description.setNatureIds(newNatures); project.setDescription(description, null); } else { //Error message } } catch (CoreException e) { e.printStackTrace(); } }
descriptor = workspace.loadProjectDescription(dotProjectPath); String name = descriptor.getName(); if (!descriptor.hasNature(JavaCore.NATURE_ID)) { return;