【问题标题】:Custom Eclipse RAP Dialog with JFace from Viewpart来自 Viewpart 的带有 JFace 的自定义 Eclipse RAP 对话框
【发布时间】:2013-09-04 17:25:30
【问题描述】:

我有一个扩展 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 类,我如何才能返回到“视图”以及如何查看我的新对话框?试过了,不行。

【问题讨论】:

    标签: java dialog jface


    【解决方案1】:

    您需要通过扩展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 了解更多详情。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-15
      • 2016-02-07
      相关资源
      最近更新 更多