views:

23

answers:

1

I want to create a 'new project' wizard for my application. The first page of this wizard is simply the instance of org.eclipse.ui.dialogs.WizardNewProjectCreationPage. I want to import some system files to current project in the second wizard page. I found that org.eclipse.ui.dialogs.WizardResourceImportPage is quite close to my thougts, but I can't figour out how to inherit this class and produce a simple file import page.

Can anyone offer an example of doing this? Thanks!

I also tried to test it like below (overrided getFileProvider too), but the file tree shows only the checkbox but no filename.

protected ITreeContentProvider getFolderProvider()
{
    // TODO Auto-generated method stub
    return new WorkbenchContentProvider()
  {
    public Object[] getChildren( Object o )
    {
      if ( o instanceof java.io.File )
        return FileSystemStructureProvider.INSTANCE.getChildren( o ).toArray();
      else
        return new Object[]{new java.io.File("C:\\temp")};
    }

    public boolean hasChildren( Object o )
    {
      if ( o instanceof java.io.File )
        return FileSystemStructureProvider.INSTANCE.isFolder( o );
      else
        return false;
    }

  };
}
+1  A: 

WizardResourceImportPage is abstract, you can extend it and implement the three abstract methods. I'd have a look at WizardFileSystemResourceImportPage1 which is working implementation of WizardResourceImportPage and either study that code or copy and paste source from that class to my own.


Edit

You're example from above only shows blank labels because WizardResourceImportPage uses a WorkbenchLabelProvider and this label provider will return "" if the 'content' object (File in your case) is not adaptable.

Look at the createFileSelectionGroup method. Maybe it's enough to implement your own LabelProvider for File objects and call selectionGroup.setTreeProviders(ITreeContentProvider, ILabelProvider) to make it work with File items in the tree. The standard implementions seems to work with (eclipse) file resources only.

Andreas_D
Thank you, but I think WizardFileSystemResourceImportPage1 is a little bit too complex and uses some internal classes which I can't use directly. I prefer a simple one.
solotim
@Andreas: Whenever I invoke selectionGroup's method, eclipse says this: Discouraged access: The method setRoot(Object) from the type ResourceTreeAndListGroup is not accessible due to restriction on required library C:\Programs\eclipse\plugins\org.eclipse.ui.ide_3.6.0.I20100601-0800.jar
solotim
Yes, that's the general problem with those internal classes. That's why I usually copy code from internal classes into my own project...
Andreas_D