Shell 对用户隐藏对话框而不关闭它
我的应用程序是在OOTB应用程序中运行的。用户可以从OOTB应用程序中选择数据,并将其存储在我的应用程序中的可写列表中。然后,用户可以单击OOTB工具栏中的按钮,打开我的应用程序的基本对话框。此对话框向用户显示他们已选择的数据表。从基本对话框中,他们可以对表中的数据执行不同的任务。这包括删除数据以及从OOTB应用程序中选择更多数据。我的应用程序将保存数据,直到用户关闭OOTB应用程序。但是我必须在基本对话框上给用户一个按钮,以便从他们的视图中删除该对话框。因此,当他们使用OOTB应用程序时,对话框并不会妨碍他们。我的基本对话框是建立在标题的基础上的。我的第一次尝试是在createButtonForButtonBar方法中关闭dailogShell 对用户隐藏对话框而不关闭它,shell,button,swt,Shell,Button,Swt,我的应用程序是在OOTB应用程序中运行的。用户可以从OOTB应用程序中选择数据,并将其存储在我的应用程序中的可写列表中。然后,用户可以单击OOTB工具栏中的按钮,打开我的应用程序的基本对话框。此对话框向用户显示他们已选择的数据表。从基本对话框中,他们可以对表中的数据执行不同的任务。这包括删除数据以及从OOTB应用程序中选择更多数据。我的应用程序将保存数据,直到用户关闭OOTB应用程序。但是我必须在基本对话框上给用户一个按钮,以便从他们的视图中删除该对话框。因此,当他们使用OOTB应用程序时,对话
protected void createButtonsForButtonBar(Composite parent) {
Button okButton = createButton(parent, OK, "Close Aplot", true);
okButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
viewer = null;
close();
}
});
}
但是最后的结果是();正在处理所有SWT小部件并导致运行时错误。尝试打开备份对话框时,SWT_小部件已被释放。因此,我提出了一些建议,试图隐藏外壳。因此,我删除了close()并将其放入getShell()
}
现在我在第行得到一个运行时空指针异常:getShell().setVisible(false)
如果我移除“OK”并替换为SWT_PUSH。它似乎工作正常
protected void createButtonsForButtonBar(Composite parent) {
Button okButton = createButton(parent, SWT.PUSH, "Close Aplot", true);
okButton.setEnabled(true);
okButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
viewer = null;
getShell().setVisible(false);
}
});
}
在前面的一个问题中,我意识到这不是一个好的做法
那么,我应该如何在不关闭日志的情况下隐藏日志呢?我假设我必须保留createButtonsForButtonBar方法。那么,我如何才能改变我必须妥善处理的贝壳皮呢
谢谢
编辑
这看起来对吗
@Override
protected void createButtonsForButtonBar(final Composite parent) {
createButton(parent, IDialogConstants.OK_ID, "Close Aplot",
true);
}
@Override
protected void okPressed() {
viewer = null;
getShell().setVisible(false);
}
您可以尝试
org.eclipse.swt.widgets.Decorations.setMinimized(boolean)
在用户单击按钮时最小化对话框?这是更好的解决方案吗?您只需要隐藏对话框的外壳。我知道你就是这么做的。
@Override
protected void createButtonsForButtonBar(final Composite parent) {
createButton(parent, IDialogConstants.OK_ID, "Close Aplot",
true);
}
@Override
protected void okPressed() {
viewer = null;
getShell().setVisible(false);
}