I am making a login dialog for a eclipse plugin and I was wondering what would be the best way to check if certain condition are met before you can submit the dialog. Currently I am overriding the okPressed() function and then not running the super function until the conditions are met.
我正在为一个eclipse插件制作一个登录对话框,我想知道在你提交对话框之前,最好的检查方法是什么。目前我正在重写okPressed()函数,然后在满足条件之前不运行super函数。
This is unfortunately not ideal because the user has no indication of what is wrong.
不幸的是,这并不理想,因为用户没有任何错误的指示。
Any ideas?
什么好主意吗?
2 个解决方案
#1
5
You can disable the OK button using something like:
你可以使用以下方法禁用OK按钮:
Button ok = getButton(IDialogConstants.OK_ID);
if (ok != null)
ok.setEnabled(false);
You can set a message at the top of the dialog using
您可以在对话框顶部设置一个消息。
setMessage("message", type);
type
can be IMessageProvider.ERROR
, IMessageProvider.WARNING
, IMessageProvider.INFORMATION
or IMessageProvider.NONE
.
可以IMessageProvider类型。错误,IMessageProvider。警告,IMessageProvider。信息或IMessageProvider.NONE。
So you can add listeners to your input fields and each time a field changes update the message and OK button enable state as required.
因此,您可以将侦听器添加到输入字段中,并且每次字段更改都会更新消息,并根据需要启用状态。
#2
0
To show the error/warning to your user, you can use the TitleAreaDialog.setMessage()
with the message and type of message.
为了向您的用户显示错误/警告,您可以使用TitleAreaDialog.setMessage()来使用消息和消息类型。
#1
5
You can disable the OK button using something like:
你可以使用以下方法禁用OK按钮:
Button ok = getButton(IDialogConstants.OK_ID);
if (ok != null)
ok.setEnabled(false);
You can set a message at the top of the dialog using
您可以在对话框顶部设置一个消息。
setMessage("message", type);
type
can be IMessageProvider.ERROR
, IMessageProvider.WARNING
, IMessageProvider.INFORMATION
or IMessageProvider.NONE
.
可以IMessageProvider类型。错误,IMessageProvider。警告,IMessageProvider。信息或IMessageProvider.NONE。
So you can add listeners to your input fields and each time a field changes update the message and OK button enable state as required.
因此,您可以将侦听器添加到输入字段中,并且每次字段更改都会更新消息,并根据需要启用状态。
#2
0
To show the error/warning to your user, you can use the TitleAreaDialog.setMessage()
with the message and type of message.
为了向您的用户显示错误/警告,您可以使用TitleAreaDialog.setMessage()来使用消息和消息类型。