Reputation: 815
I am using an ContainerSelectionDialog
inside my Eclipse RCP application. I now would like to add tabs to the dialog, with some additional stuff inside.
This is how my ContainerSelectionDialog
looks like:
// ...
ContainerSelectionDialog dialog = new ContainerSelectionDialog(
Display.getDefault().getActiveShell(), c, true,
"Please select target folder");
int open = dialog.open();
if (!(open == org.eclipse.jface.window.Window.OK))
return null;
Object[] result = dialog.getResult();
IPath path = (IPath) result[0];
targetFolder = ResourcesPlugin.getWorkspace().getRoot()
.findMember(path);
containerPath = targetFolder.getLocation().toPortableString();
// ...
How can I add tabs to this dialog?
Upvotes: 0
Views: 169
Reputation: 111142
The best you can do is add controls below the selection tree. Even this is made difficult by a bug in ContainerSelectionDialog
. This code shows how to do this and work around the bug:
public class MyContainerSelectionDialog extends ContainerSelectionDialog
{
public MyContainerSelectionDialog(final Shell parentShell, final IContainer initialRoot, final boolean allowNewContainerName, final String message)
{
super(parentShell, initialRoot, allowNewContainerName, message);
}
@Override
protected Control createDialogArea(final Composite parent)
{
Composite body = (Composite)super.createDialogArea(parent);
// Bug in ContainerSelectionDialog is returning null for the body!
if (body == null)
{
// body is the last control added to the parent
final Control [] children = parent.getChildren();
if (children[children.length - 1] instanceof Composite)
body = (Composite)children[children.length - 1];
}
// TODO add your controls here, this example just adds a Label
final Label label = new Label(body, SWT.NONE);
label.setText("My label");
return body;
}
}
Upvotes: 1