Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Programmatically invoke the import "Existing projects into workspace"(Programmatically invoke the import "Existing projects into workspace")
Programmatically invoke the import "Existing projects into workspace" [message #661540] Fri, 25 March 2011 08:32 Go to next message
Nicolas P is currently offline Nicolas PFriend
Messages: 2
Registered: March 2011
Junior Member
Hi,

I am trying to find a way to programmatically invoke the import "Existing projects into workspace". I can invoke the Import wizard but I can't find a way to programmatically select the list of project i want to be imported in workspace and without invoking the wizard. Is there a way to do this directly? I'm trying to bypass the wizard and only calling the import "Existing projects into workspace" on the project(s) i want to import. I tried this:

 // Get list of model test project and import project into workspace
    ExternalProjectImportWizard wizard = new ExternalProjectImportWizard();
    wizard.init(PlatformUI.getWorkbench(), null);
    wizard.addPages();
    WizardProjectsImportPage page = (WizardProjectsImportPage) wizard.getPage("wizardExternalProjectsPage");
    page.updateProjectsList("D:\\model");
    wizard.performFinish();


But it doesn't work and ends up with a NPE. What am i doing wrong ? Sad

Thanks
--
Nicolas
Re: Programmatically invoke the import "Existing projects into workspace" [message #661826 is a reply to message #661540] Mon, 28 March 2011 07:08 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
On 25/03/11 2:02 PM, Nicolas Phung wrote:

> I'm trying to bypass the wizard and only
> calling the import "Existing projects into workspace" on the project(s)
> i want to import.

There isn't an API to do that. You have to hack around the internal
classes (which might be broken on the future releases)

--
- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Re: Programmatically invoke the import "Existing projects into workspace" [message #662630 is a reply to message #661826] Thu, 31 March 2011 11:03 Go to previous message
Nicolas P is currently offline Nicolas PFriend
Messages: 2
Registered: March 2011
Junior Member
This works for me:

IProjectDescription description = null;
    try {
      description = ResourcesPlugin.getWorkspace().loadProjectDescription(new Path(PROJECT_PATH + "/.project")); //$NON-NLS-1$ 
      IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(description.getName());
      project.create(description, null);
      project.open(null);
    } catch (CoreException exception_p) {
      exception_p.printStackTrace();
    }

Previous Topic:Common Navigator Inline editing
Next Topic:How can I use IProject.getName() in plugin.xml or plugin.properties file
Goto Forum:
  


Current Time: Thu Apr 25 22:11:04 GMT 2024

Powered by FUDForum. Page generated in 0.02873 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top