[英]JFace Tabs inside ContainerSelectionDialog in Eclipse RCP
I am using an ContainerSelectionDialog
inside my Eclipse RCP application. 我在Eclipse RCP应用程序中使用了ContainerSelectionDialog
。 I now would like to add tabs to the dialog, with some additional stuff inside. 我现在想在对话框中添加标签,并在其中添加一些其他内容。
This is how my ContainerSelectionDialog
looks like: 这是我的ContainerSelectionDialog
样子:
// ...
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? 如何在此对话框中添加标签?
The best you can do is add controls below the selection tree. 最好的办法是在选择树下添加控件。 Even this is made difficult by a bug in ContainerSelectionDialog
. 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;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.