本文整理匯總了Java中org.eclipse.core.resources.IProject.exists方法的典型用法代碼示例。如果您正苦於以下問題:Java IProject.exists方法的具體用法?Java IProject.exists怎麽用?Java IProject.exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IProject
的用法示例。
在下文中一共展示了IProject.exists方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getProject
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
* Returns with the corresponding {@link IN4JSProject N4JS project} for the given {@link IProject Eclipse project}
* argument. Returns with {@code null} if
* <ul>
* <li>the {@code project} argument is {@code null} or</li>
* <li>no {@link IN4JSProject#exists() existing} {@link IN4JSProject N4JS project} project can be found with the
* desired project ID.</li>
* </ul>
*
* @param project
* the searched project.
* @return the N4JS project or {@code null} if such project does not exist.
*/
public IN4JSProject getProject(IProject project) {
checkArgument(!(project instanceof ExternalProject), "Expected Eclipse workspace project. Got: " + project);
if (null == project || !project.exists() || !project.isOpen()) {
return null;
}
final String projectName = Strings.nullToEmpty(project.getName());
final IN4JSProject n4Project = core.create(createPlatformResourceURI(projectName, true));
if (null == n4Project || !n4Project.exists() || n4Project.isExternal()) {
return null;
}
return n4Project;
}
示例2: createProject
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
protected void createProject ( final IProgressMonitor monitor ) throws CoreException
{
monitor.beginTask ( "Create project", 2 );
final IProject project = this.info.getProject ();
final IProjectDescription desc = project.getWorkspace ().newProjectDescription ( project.getName () );
desc.setLocation ( this.info.getProjectLocation () );
desc.setNatureIds ( new String[] { Constants.PROJECT_NATURE_CONFIGURATION, PROJECT_NATURE_JS } );
final ICommand jsCmd = desc.newCommand ();
jsCmd.setBuilderName ( BUILDER_JS_VALIDATOR );
final ICommand localBuilder = desc.newCommand ();
localBuilder.setBuilderName ( Constants.PROJECT_BUILDER );
desc.setBuildSpec ( new ICommand[] { jsCmd, localBuilder } );
if ( !project.exists () )
{
project.create ( desc, new SubProgressMonitor ( monitor, 1 ) );
project.open ( new SubProgressMonitor ( monitor, 1 ) );
}
monitor.done ();
}
示例3: createProjectPluginResource
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public IProject createProjectPluginResource(String projectName, IProgressMonitor monitor) throws CoreException {
IWorkspace myWorkspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot myWorkspaceRoot = myWorkspace.getRoot();
IProject resourceProject = myWorkspaceRoot.getProject(projectName);
if (!resourceProject.exists()) {
if(myWorkspaceRoot.getLocation().toFile().equals(new Path(Engine.PROJECTS_PATH).toFile())){
logDebug("createProjectPluginResource : project is in the workspace folder");
resourceProject.create(monitor);
}else{
logDebug("createProjectPluginResource: project isn't in the workspace folder");
IPath projectPath = new Path(Engine.PROJECTS_PATH + "/" + projectName).makeAbsolute();
IProjectDescription description = myWorkspace.newProjectDescription(projectName);
description.setLocation(projectPath);
resourceProject.create(description, monitor);
}
}
return resourceProject;
}
示例4: validatePage
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private void validatePage() {
setErrorMessage(null);
setMessage(null);
updateButtons(false);
String projectName= fProjectText.getText().trim();
if (projectName.length() == 0) {
setErrorMessage(MessageUtil.getString("project_not_defined"));
return;
}
IProject project= ResourceManager.getProject(projectName);
if (!project.exists()) {
setErrorMessage(MessageUtil.getString("invalid_project_name"));
return;
}
if (!GW4ENature.hasGW4ENature(project)) {
setErrorMessage(MessageUtil.getString("not_a_gw4e_project"));
return;
}
GW4ELaunchConfigurationTab.this.setDirty(true);
updateLaunchConfigurationDialog();
updateButtons(true);
}
示例5: deleteProjects
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private static void deleteProjects(final IProject[] projects, StringBuilder error) {
for (final IProject project : projects) {
if (project.exists()) {
try {
project.delete(true, true, new NullProgressMonitor());
} catch (CoreException e) {
error.append(e.getMessage());
}
}
}
}
示例6: getJSProject
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private IProject getJSProject() {
IProject javaProject = findJSProject(PROJECT_NAME);
if (javaProject == null || !javaProject.exists()) {
try {
demandCreateProject = ProjectUtils.createJSProject(PROJECT_NAME);
javaProject = findJSProject(PROJECT_NAME);
} catch (CoreException e) {
fail("Cannot create project due to: " + e.getMessage() + " / " + e);
}
}
return javaProject;
}
示例7: validateModuleSpecifier
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
* Module specifier specifier property constraints
*/
@Override
protected void validateModuleSpecifier() throws ValidationException {
String effectiveModuleSpecifier = getModel().getEffectiveModuleSpecifier();
// Invoke super validation procedure on full effective module specifier
doValidateModuleSpecifier(effectiveModuleSpecifier);
/* Check for potential file collisions */
if (isFileSpecifyingModuleSpecifier(effectiveModuleSpecifier)) {
IProject moduleProject = ResourcesPlugin.getWorkspace().getRoot()
.getProject(getModel().getProject().toString());
IPath effectiveModulePath = new Path(getModel().getEffectiveModuleSpecifier());
IPath n4jsdPath = getModel().getSourceFolder()
.append(effectiveModulePath.addFileExtension(N4JSGlobals.N4JSD_FILE_EXTENSION));
IPath n4jsPath = getModel().getSourceFolder()
.append(effectiveModulePath.addFileExtension(N4JSGlobals.N4JS_FILE_EXTENSION));
if (getModel().isDefinitionFile() && moduleProject.exists(n4jsPath)) {
throw new ValidationException(
String.format(ErrorMessages.THE_NEW_DEFINITION_MODULE_COLLIDES_WITH_THE_SOURCE_FILE,
moduleProject.getFullPath().append(n4jsPath)));
} else if (!getModel().isDefinitionFile() && moduleProject.exists(n4jsdPath)) {
throw new ValidationException(String
.format(ErrorMessages.THE_NEW_SOURCE_MODULE_COLLIDES_WITH_THE_DEFINITION_FILE,
moduleProject.getFullPath().append(n4jsdPath)));
}
}
}
示例8: updateProposalContext
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
* This method should be invoked whenever source folder or project value change, to update the proposal contexts for
* the field source folder and module specifier
*/
private void updateProposalContext() {
IPath projectPath = model.getProject();
IPath sourceFolderPath = model.getSourceFolder();
// Early exit for empty project value
if (projectPath.isEmpty()) {
sourceFolderContentProposalAdapter.setContentProposalProvider(null);
moduleSpecifierContentProposalAdapter.setContentProposalProvider(null);
return;
}
IProject project = ResourcesPlugin.getWorkspace().getRoot()
.getProject(projectPath.toString());
if (null == project || !project.exists()) {
// Disable source folder and module specifier proposals
sourceFolderContentProposalAdapter.setContentProposalProvider(null);
moduleSpecifierContentProposalAdapter.setContentProposalProvider(null);
} else {
// Try to retrieve the source folder and if not specified set it to null
IContainer sourceFolder = sourceFolderPath.segmentCount() != 0 ? project.getFolder(sourceFolderPath) : null;
// If the project exists, enable source folder proposals
sourceFolderContentProposalAdapter
.setContentProposalProvider(sourceFolderContentProviderFactory.createProviderForProject(project));
if (null != sourceFolder && sourceFolder.exists()) {
// If source folder exists as well enable module specifier proposal
moduleSpecifierContentProposalAdapter.setContentProposalProvider(
moduleSpecifierContentProviderFactory.createProviderForPath(sourceFolder.getFullPath()));
} else {
// Otherwise disable module specifier proposals
moduleSpecifierContentProposalAdapter.setContentProposalProvider(null);
}
}
}
示例9: getProject
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private IProject getProject(BuildData buildData) {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(buildData.getProjectName());
if (null == project || !project.isAccessible()) {
final IProject externalProject = getExternalLibraryWorkspace().getProject(buildData.getProjectName());
if (null != externalProject && externalProject.exists()) {
project = externalProject;
}
}
return project;
}
示例10: findTarget
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
protected IContainer findTarget ( final Protocol protocol, final IProject modelProject )
{
final IProject project = findProject ( protocol, modelProject );
if ( !project.exists () )
{
throw new RuntimeException ( String.format ( "Project '%s' does not exists", project.getName () ) );
}
return project.getFolder ( "src" );
}
示例11: getProjectPluginResource
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public IProject getProjectPluginResource(String projectName, IProgressMonitor monitor) throws CoreException {
if (cacheIProject.containsKey(projectName)) return (IProject)cacheIProject.get(projectName);
IProject resourceProject = createProjectPluginResource(projectName);
if (resourceProject.exists()) {
resourceProject.refreshLocal(IResource.DEPTH_INFINITE, monitor);
if (!resourceProject.isOpen())
resourceProject.open(monitor);
}
cacheIProject.put(projectName, resourceProject);
return resourceProject;
}
示例12: moveProjectPluginResource
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public void moveProjectPluginResource(String projectName, String newName) throws CoreException {
cacheIProject.remove(projectName);
IWorkspace myWorkspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot myWorkspaceRoot = myWorkspace.getRoot();
IProject resourceProject = myWorkspaceRoot.getProject(projectName);
if (resourceProject.exists()) {
IPath newProjectPath = new Path(Engine.PROJECTS_PATH + "/" + newName).makeAbsolute();
IProjectDescription description = myWorkspace.newProjectDescription(newName);
description.setLocation(newProjectPath);
resourceProject.move(description, false, null);
}
}
示例13: createJavaProject
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private IJavaProject createJavaProject(String name) throws CoreException {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
if (project.exists())
project.delete(true, null);
project.create(null);
project.open(null);
IProjectDescription description = project.getDescription();
description.setNatureIds(new String[] { JavaCore.NATURE_ID });
project.setDescription(description, null);
IJavaProject javaProject = JavaCore.create(project);
javaProject.setRawClasspath(new IClasspathEntry[] { JavaCore.newVariableEntry(new Path("JRE_LIB"), null, null) }, null);
return javaProject;
}
示例14: deleteProjectPluginResource
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public void deleteProjectPluginResource(boolean deleteContent, String projectName) throws CoreException {
cacheIProject.remove(projectName);
IWorkspace myWorkspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot myWorkspaceRoot = myWorkspace.getRoot();
IProject resourceProject = myWorkspaceRoot.getProject(projectName);
if (resourceProject.exists()) {
resourceProject.delete(deleteContent, false, null);
}
}
示例15: createProject
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public static IJavaProject createProject(String name) throws CoreException {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(name);
if (!project.exists()) {
project.create(new NullProgressMonitor());
} else {
project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
}
if (!project.isOpen()) {
project.open(new NullProgressMonitor());
}
IFolder binFolder = project.getFolder("bin");
if (!binFolder.exists()) {
createFolder(binFolder, false, true, new NullProgressMonitor());
}
IPath outputLocation = binFolder.getFullPath();
addNatureToProject(project, JavaCore.NATURE_ID, new NullProgressMonitor());
IJavaProject jproject = JavaCore.create(project);
jproject.setOutputLocation(outputLocation, new NullProgressMonitor());
IClasspathEntry[] entries = PreferenceConstants.getDefaultJRELibrary();
jproject.setRawClasspath(entries, new NullProgressMonitor());
return jproject;
}