solotim
solotim

Reputation: 1866

How to inherit class WizardResourceImportPage?

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;
    }

  };
}

Upvotes: 1

Views: 612

Answers (1)

Andreas Dolk
Andreas Dolk

Reputation: 114777

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.

Upvotes: 1

Related Questions