本文整理匯總了Java中org.eclipse.core.resources.IProjectDescription.setLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java IProjectDescription.setLocation方法的具體用法?Java IProjectDescription.setLocation怎麽用?Java IProjectDescription.setLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IProjectDescription
的用法示例。
在下文中一共展示了IProjectDescription.setLocation方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createProject
import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的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 ();
}
示例2: createProjectPluginResource
import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的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;
}
示例3: createLinkedProject
import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
public IProject createLinkedProject(String projectName, Plugin plugin, IPath linkPath) throws CoreException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject project = workspace.getRoot().getProject(projectName);
IProjectDescription desc = workspace.newProjectDescription(projectName);
File file = getFileInPlugin(plugin, linkPath);
IPath projectLocation = new Path(file.getAbsolutePath());
if (Platform.getLocation().equals(projectLocation))
projectLocation = null;
desc.setLocation(projectLocation);
project.create(desc, NULL_MONITOR);
if (!project.isOpen())
project.open(NULL_MONITOR);
return project;
}
示例4: createProject
import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
/**
* Create the project directory.
* If the user has specified an external project location,
* the project is created with a custom description for the location.
*
* @param project project
* @param monitor progress monitor
* @throws CoreException
*/
private void createProject(IProject project, IProgressMonitor monitor)
throws CoreException {
monitor.subTask(TexlipsePlugin.getResourceString("projectWizardProgressDirectory"));
if (!project.exists()) {
if (attributes.getProjectLocation() != null) {
IProjectDescription desc = project.getWorkspace().newProjectDescription(project.getName());
IPath projectPath = new Path(attributes.getProjectLocation());
IStatus stat = ResourcesPlugin.getWorkspace().validateProjectLocation(project, projectPath);
if (stat.getSeverity() != IStatus.OK) {
// should not happen. the location should have been checked in the wizard page
throw new CoreException(stat);
}
desc.setLocation(projectPath);
project.create(desc, monitor);
} else {
project.create(monitor);
}
}
if (!project.isOpen()) {
project.open(monitor);
}
}
示例5: projectRename
import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
/**
* Renames and moves the project, but does not delete the old project. It's
* the callee's reponsibility.
*
* @param project
* @param aNewName
*/
public static IProject projectRename(final IProject project, final String aNewName, final IProgressMonitor aMonitor)
{
try
{
// move the project location to the new location and name
final IProjectDescription description = project.getDescription();
final IPath basePath = description.getLocation().removeLastSegments(1).removeTrailingSeparator();
final IPath newPath = basePath.append(aNewName.concat(TOOLBOX_DIRECTORY_SUFFIX)).addTrailingSeparator();
description.setLocation(newPath);
description.setName(aNewName);
// refresh the project prior to moving to make sure the fs and resource fw are in sync
project.refreshLocal(IResource.DEPTH_INFINITE, aMonitor);
project.copy(description, IResource.NONE | IResource.SHALLOW, aMonitor);
return ResourcesPlugin.getWorkspace().getRoot().getProject(aNewName);
} catch (CoreException e)
{
Activator.getDefault().logError("Error renaming a specification", e);
}
return null;
}
示例6: performFinish
import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
@Override
public boolean performFinish() {
try {
createdProject = _askProjectNamePage.getProjectHandle();
final String languageName = _askLanguageNamePage.getLanguageName();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IProjectDescription description = workspace.newProjectDescription(createdProject.getName());
if (!_askProjectNamePage.getLocationPath().equals(workspace.getRoot().getLocation()))
description.setLocation(_askProjectNamePage.getLocationPath());
//description.setLocationURI(_askProjectNamePage.getLocationURI());
IWorkspaceRunnable operation = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
createdProject.create(description, monitor);
createdProject.open(monitor);
initializeProject(createdProject, languageName);
createdProject.refreshLocal(IResource.DEPTH_INFINITE, monitor);
createdProject.touch(new NullProgressMonitor()); // [FT] One touch to force eclipse to serialize the project properties that will update accordingly the gemoc actions in the menu.
//createdProject.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
}
};
ResourcesPlugin.getWorkspace().run(operation, null);
} catch (CoreException exception) {
Activator.error(exception.getMessage(), exception);
return false;
}
return true;
}
開發者ID:eclipse,項目名稱:gemoc-studio-modeldebugging,代碼行數:31,代碼來源:AbstractCreateNewGemocLanguageProject.java
示例7: moveProjectPluginResource
import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的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);
}
}
示例8: createProject
import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
@Override
protected IProject createProject(final String localPath, final ImportOptions importOptions)
throws CoreException {
final IPath projectRootPath = new Path(localPath);
final String projectName = new File(localPath).getName();
final IProject eclipseProject = importOptions.getEclipseWorkspace().getRoot().getProject(projectName);
final IProjectDescription description =
importOptions.getEclipseWorkspace().newProjectDescription(projectName);
description.setLocation(projectRootPath);
/*
* If this project is NOT to be beneath the workspace root, then we
* need to specify the project description specifically.
*/
final IPath workspaceRootLocation = importOptions.getEclipseWorkspace().getRoot().getLocation();
if (LocalPath.isChild(workspaceRootLocation.toOSString(), projectRootPath.toOSString())) {
/* Inside workspace root */
eclipseProject.create(null, null);
} else {
/* Outside workspace root */
eclipseProject.create(description, null);
}
return eclipseProject;
}
示例9: createOrImportProject
import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
private IProject createOrImportProject(File directory, IWorkspaceRoot workspaceRoot,
IProgressMonitor progressMonitor) throws Exception {
IProjectDescription desc = null;
File expectedProjectDescriptionFile = new File(directory, IProjectDescription.DESCRIPTION_FILE_NAME);
if (expectedProjectDescriptionFile.exists()) {
desc = ResourcesPlugin.getWorkspace()
.loadProjectDescription(new Path(expectedProjectDescriptionFile.getAbsolutePath()));
String expectedName = desc.getName();
IProject projectWithSameName = workspaceRoot.getProject(expectedName);
if (projectWithSameName.exists()) {
if (projectWithSameName.getLocation().toFile().equals(directory)) {
// project seems already there
return projectWithSameName;
}
throw new Exception(NLS.bind(
AngularCLIMessages.AbstractProjectCommandInterpreter_anotherProjectWithSameNameExists_description,
expectedName));
}
} else {
String projectName = directory.getName();
if (workspaceRoot.getProject(directory.getName()).exists()) {
int i = 1;
do {
projectName = directory.getName() + '(' + i + ')';
i++;
} while (workspaceRoot.getProject(projectName).exists());
}
desc = ResourcesPlugin.getWorkspace().newProjectDescription(projectName);
}
desc.setLocation(new Path(directory.getAbsolutePath()));
IProject res = workspaceRoot.getProject(desc.getName());
res.create(desc, progressMonitor);
return res;
}
示例10: createBaseProject
import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
private static IProject createBaseProject(String projectName, IPath location) {
IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
if (!newProject.exists()) {
IPath projectLocation = location;
IProjectDescription desc = newProject.getWorkspace().newProjectDescription(newProject.getName());
if (location != null &&
ResourcesPlugin.getWorkspace().getRoot().getLocation().equals(location)) {
projectLocation = null;
}
desc.setLocation(projectLocation);
try {
newProject.create(desc, null);
if (!newProject.isOpen()) {
newProject.open(null);
}
} catch (CoreException e) {
WPILibCore.logError("Can't create new project.", e);
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", "Error creating project! This may occur if a project of the same name with different case exists in the Workspace");
}
});
}
}else {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", "Error! A project of the same name already exists in the Workspace");
}
});
}
return newProject;
}
示例11: moveProject
import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
@Override
public boolean moveProject(
final IResourceTree tree,
final IProject source,
final IProjectDescription target,
final int updateFlags,
final IProgressMonitor progressMonitor) {
log.trace(MessageFormat.format("moveProject: {0}", source.getFullPath())); //$NON-NLS-1$
progressMonitor.beginTask(
MessageFormat.format(Messages.getString("TFSMoveDeleteHook.MovingProjectFormat"), source.getFullPath()), //$NON-NLS-1$
10);
log.info(MessageFormat.format("Rename detected from project {0} to {1}", source, target)); //$NON-NLS-1$
try {
/*
* Renaming the project only. Does not move folders, only sets the
* new name in the .project file.
*/
if (target.getName() != source.getName()) {
target.setLocation(source.getLocation());
tree.standardMoveProject(source, target, updateFlags, new SubProgressMonitor(progressMonitor, 10));
return true;
} else {
/*
* User is attempting to relocate the project. This gets hairy
* and would involve changing WF mappings in order to pend a
* rename.
*/
tree.failed(
new Status(
IStatus.ERROR,
TFSEclipseClientPlugin.PLUGIN_ID,
0,
MessageFormat.format(
Messages.getString("TFSMoveDeleteHook.MovingProjectNotSupportedInProductFormat"), //$NON-NLS-1$
ProductInformation.getCurrent().toString()),
null));
return true;
}
} finally {
progressMonitor.done();
}
}
示例12: setProjectToRoot
import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
private void setProjectToRoot(final IProject project, File destPath) throws CoreException {
IProjectDescription description = project.getDescription();
description.setLocation(new Path(destPath.getAbsolutePath()));
project.move(description, true, null);
}