Eclipse插件:从WorkBench打开一个新窗口 [英] Eclipse Plugin: Opening A New Window From The WorkBench
问题描述
我已经完成了创建窗口。
在我编译应用程序之后,我得到了一个新的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屋!