Java Code Examples for org.eclipse.core.resources.IProjectDescription#getName()
The following examples show how to use
org.eclipse.core.resources.IProjectDescription#getName() .
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: EclipseProjectImporter.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private void importDir(java.nio.file.Path dir, IProgressMonitor m) { SubMonitor monitor = SubMonitor.convert(m, 4); IWorkspace workspace = ResourcesPlugin.getWorkspace(); IPath dotProjectPath = new Path(dir.resolve(DESCRIPTION_FILE_NAME).toAbsolutePath().toString()); IProjectDescription descriptor; try { descriptor = workspace.loadProjectDescription(dotProjectPath); String name = descriptor.getName(); if (!descriptor.hasNature(JavaCore.NATURE_ID)) { return; } IProject project = workspace.getRoot().getProject(name); if (project.exists()) { IPath existingProjectPath = project.getLocation(); existingProjectPath = fixDevice(existingProjectPath); dotProjectPath = fixDevice(dotProjectPath); if (existingProjectPath.equals(dotProjectPath.removeLastSegments(1))) { project.open(IResource.NONE, monitor.newChild(1)); project.refreshLocal(IResource.DEPTH_INFINITE, monitor.newChild(1)); return; } else { project = findUniqueProject(workspace, name); descriptor.setName(project.getName()); } } project.create(descriptor, monitor.newChild(1)); project.open(IResource.NONE, monitor.newChild(1)); } catch (CoreException e) { JavaLanguageServerPlugin.log(e.getStatus()); throw new RuntimeException(e); } finally { monitor.done(); } }
Example 2
Source File: DotnetNewWizardPage.java From aCute with Eclipse Public License 2.0 | 4 votes |
@Override public boolean isPageComplete() { String locationError = ""; //$NON-NLS-1$ String projectNameError = ""; //$NON-NLS-1$ String templateError = ""; //$NON-NLS-1$ if (directory == null || directory.getPath().isEmpty()) { locationError = Messages.DotnetNewWizardPage_directroyError_empty; } else if (projectName == null || projectName.isEmpty()) { projectNameError = Messages.DotnetNewWizardPage_projectError_empty; } else if (directory.isFile()) { locationError = Messages.DotnetNewWizardPage_locationError_existingFile; } else if (directory.getParentFile() == null || (!directory.exists() && !directory.getParentFile().canWrite())) { locationError = Messages.DotnetNewWizardPage_locationError_unableToCreate; } else if (directory.exists() && !directory.canWrite()) { locationError = Messages.DotnetNewWizardPage_locationError_unableToWrite; } else if (getTemplate() == null) { templateError = Messages.DotnetNewWizardPage_templateError_empty; } else { File dotProject = new File(directory, IProjectDescription.DESCRIPTION_FILE_NAME); if (dotProject.exists()) { IProjectDescription desc = null; try { desc = ResourcesPlugin.getWorkspace() .loadProjectDescription(Path.fromOSString(dotProject.getAbsolutePath())); } catch (CoreException e) { projectNameError = Messages.DotnetNewWizardPage_projectError_invalidDotProjectFile; } if (!desc.getName().equals(projectName)) { projectNameError = Messages.DotnetNewWizardPage_projectError_invalidNameMatch + desc.getName(); } } else { IProject project = null; try { project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); if (project.exists() && (project.getLocation() == null || !directory.getAbsoluteFile().equals(project.getLocation().toFile().getAbsoluteFile()))) { projectNameError = Messages.DotnetNewWizardPage_projectError_existingName; } } catch (IllegalArgumentException ex) { projectNameError = Messages.DotnetNewWizardPage_projectError_invalidName; } } } String error = locationError + projectNameError + templateError; if (error.isEmpty()) { setErrorMessage(null); projectNameControlDecoration.hide(); locationControlDecoration.hide(); templateControlDecoration.hide(); } else { if (!locationError.isEmpty()) { locationControlDecoration.showHoverText(locationError); locationControlDecoration.show(); projectNameControlDecoration.hide(); templateControlDecoration.hide(); } else if(!projectNameError.isEmpty()) { projectNameControlDecoration.showHoverText(projectNameError); projectNameControlDecoration.show(); locationControlDecoration.hide(); templateControlDecoration.hide(); } else { templateControlDecoration.showHoverText(projectNameError); templateControlDecoration.show(); locationControlDecoration.hide(); projectNameControlDecoration.hide(); } setErrorMessage(error); } return error.isEmpty(); }
Example 3
Source File: NewCargoProjectWizardPage.java From corrosion with Eclipse Public License 2.0 | 4 votes |
@Override public boolean isPageComplete() { String locationError = ""; //$NON-NLS-1$ String projectNameError = ""; //$NON-NLS-1$ String cargoError = ""; //$NON-NLS-1$ File cargo = new File(store.getString(CorrosionPreferenceInitializer.CARGO_PATH_PREFERENCE)); if (!(cargo.exists() && cargo.isFile() && cargo.canExecute())) { cargoError = Messages.NewCargoProjectWizardPage_cargoCommandNotFound; } else if (directory == null || directory.getPath().isEmpty()) { locationError = Messages.NewCargoProjectWizardPage_emptyDirectory; } else if (projectName == null || projectName.isEmpty()) { projectNameError = Messages.NewCargoProjectWizardPage_emptyProjectName; } else if (directory.isFile()) { locationError = Messages.NewCargoProjectWizardPage_fileExisting; } else if (directory.getParentFile() == null || (!directory.exists() && !directory.getParentFile().canWrite())) { locationError = Messages.NewCargoProjectWizardPage_cannotCreateDirectory; } else if (directory.exists() && !directory.canWrite()) { locationError = Messages.NewCargoProjectWizardPage_cannotWriteInDirectory; } else { File cargoProject = new File(directory, IProjectDescription.DESCRIPTION_FILE_NAME); if (cargoProject.exists()) { try { IProjectDescription desc = ResourcesPlugin.getWorkspace() .loadProjectDescription(Path.fromOSString(cargoProject.getAbsolutePath())); if (!desc.getName().equals(projectName)) { projectNameError = Messages.NewCargoProjectWizardPage_projectNameDoesntMatchDotProject + desc.getName(); } } catch (CoreException e) { projectNameError = Messages.NewCargoProjectWizardPage_InvalidDotProjectInDirectory; } } else { IProject project = null; try { project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); if (project.exists() && (project.getLocation() == null || !directory.getAbsoluteFile().equals(project.getLocation().toFile().getAbsoluteFile()))) { projectNameError = Messages.NewCargoProjectWizardPage_projectNameAlreadyUsed; } } catch (IllegalArgumentException ex) { projectNameError = Messages.NewCargoProjectWizardPage_invalidProjectName; } } } String error = locationError + projectNameError + cargoError; if (error.isEmpty()) { setErrorMessage(null); projectNameControlDecoration.hide(); locationControlDecoration.hide(); } else { if (!locationError.isEmpty()) { locationControlDecoration.showHoverText(locationError); locationControlDecoration.show(); projectNameControlDecoration.hide(); } else if (!projectNameError.isEmpty()) { projectNameControlDecoration.showHoverText(projectNameError); projectNameControlDecoration.show(); locationControlDecoration.hide(); } setErrorMessage(error); } return error.isEmpty(); }