0

我有一个扩展 ViewPart 的类“视图”。在我的课之后,我想显示一个包含两个标签的对话框。

首先,我像这样使用“InputDialog”:

        Composite composite = new Composite(top, SWT.NONE);
    Label label= new Label(tmpComposite, SWT.NONE);
    label.setText("");

    InputDialog dlg;
        dlg = new InputDialog(Display.getCurrent().getActiveShell(),
                "Title", "Some Text", label.getText(), insertValidator());
    if (dlg.open() == Window.OK) {
        //Do sth.                   
    }

这行得通。但现在我有两个标签。我怎样才能意识到它?我找到了一些解决方案,但没有一个在 ViewPart 或 Eclipse RCP 中工作。

谢谢你的帮助!

顺便说一句,如果您的解决方案是从我的“视图”调用一个 java 类,我怎样才能回到“视图”以及如何查看我的新对话框?试过了,不行。

4

1 回答 1

0

您需要通过扩展来创建自定义对话框org.eclipse.jface.dialogs.Dialog

public class MyDialog extends Dialog 
{
  public MyDialog(Shell parentShell)
  {
    super(parentShell);
  }

  @Override
  protected Control createDialogArea(Composite parent) 
  {
    Composite container = (Composite)super.createDialogArea(parent);

    // Add your controls here

    return container;
  }
}

您以类似的方式使用它InputDialog

MyDialog dialog = new MyDialog(shell);
dialog.open();

查看http://www.vogella.com/articles/EclipseDialogs/article.html了解更多详细信息。

于 2013-09-04T18:13:39.923 回答