Eclipse插件:从WorkBench打开一个新窗口 [英] Eclipse Plugin: Opening A New Window From The WorkBench

查看:299
本文介绍了Eclipse插件:从WorkBench打开一个新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里是新的,所以原谅我的任何错误。我只需要你的帮助。我是开发Eclipse插件的新东西,我已经做了很多工作。这是我陷入困境的地方。我有一个按钮的视图。当用户在按钮上弹出时,我想要打开一个新窗口(窗口是一个带有文本区域,按钮和其他SWT窗口小部件的窗体)。
我已经完成了创建窗口。



在我编译应用程序之后,我得到了一个新的eclipse工作台实例(如预期),但是当我打开查看并点击按钮,窗口不显示。这是窗口代码片段:

  public class NewWindow {
private Display display;
私人shell shell;

public NewWindow(){

this.display = new Display();
shell = new Shell(displaySWT.TITLE | SWT.MIN | SWT.CLOSE);
shell.setText(fffffffffffff);

//其他代码
...
...

shell.open();
this.shellSleep(); //这个方法在我的代码中实现
}

这是调用代码片段这个课程:



...
...

  this.btnCreateNewQuery.addSelectionListener(new SelectionListener(){
public void widgetDefaultSelected(SelectionEvent e){

}
public void widgetSelected(SelectionEvent e){NewWindow b = new NewWindow();

}
});

...
...



我不明白为什么窗口不显示。有人可以帮我解决这个问题。我已经花了几天的时间尝试解决它,但还没有找到任何东西。我在这个网站上看了一些,但我不明白他们的意思。这是链接:
如何使工作台窗口在基于Eclipse的项目中打开模态对话框?



我需要帮助请。

解决方案

Eddy,这很容易解决。只需不要创建一个新的显示。重新使用工作台中的一个:

  public NewWindow(){
this.display = PlatformUI.getWorkbench()。 getDisplay();
shell = new Shell(display,SWT.TITLE | SWT.MIN | SWT.CLOSE);
shell.setText(fffffffffffff);

//其他代码
...
...

shell.open();
this.shellSleep(); //这个方法在我的代码中实现
}

替代地,你可以忽略显示变量并且将空值传递给Shell构造函数。


I am new here so forgive me for any mistake. I just need your help urgently. I am new in developing Eclipse plugin and i have manage to do a lot of work. This is where i have got stuck. I have a view with a button. When a user cklicks on the button i want a new window to be opened(The window is a form with Text areas, buttons and other SWT widgets). I have finished creating the window.

After i compile the application, i get a new instance of the eclipse workbench(as expected) but when i open the view and clicks on the button, the window don't show up. This is the window code snippet:

public class NewWindow {
    private Display display;
    private Shell shell;

    public NewWindow(){

        this.display = new Display();
    shell = new Shell(displaySWT.TITLE | SWT.MIN | SWT.CLOSE);
    shell.setText("fffffffffffff");

              // additional code here
               ...
               ...

    shell.open();
    this.shellSleep();  // this methode is implemented in my code
}

This is the code snippet that calls this class:

... ...

this.btnCreateNewQuery.addSelectionListener(new SelectionListener(){
            public void widgetDefaultSelected(SelectionEvent e){

            }
            public void widgetSelected(SelectionEvent e){                                   NewWindow b = new NewWindow();

        }
    });

... ...

I don't understand why the window don't show up. Can someone help me to solve this problem. I have been spendig days and nights trying to fix it but has not find anything yet. I read somethig on this site but i don't understand what they meant. this is the link: How do I get the workbench window to open a modal dialog in an Eclipse based project?

I need help please.

解决方案

Eddy, thats pretty easy to solve. Just do not create a new Display. Reuse the one from the workbench:

public NewWindow() {
        this.display = PlatformUI.getWorkbench().getDisplay();
        shell = new Shell(display, SWT.TITLE | SWT.MIN | SWT.CLOSE);
        shell.setText("fffffffffffff");

              // additional code here
               ...
               ...

        shell.open();
        this.shellSleep();  // this methode is implemented in my code
}

Alternativly you can dismiss the display variable and just pass null to the Shell constructor.

这篇关于Eclipse插件:从WorkBench打开一个新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆