如何在 Eclipse 插件中为文本字段添加自动完成功能?
How to add an autocomplete feature for text filed in eclipse plugin?
我正在开发一个eclipse 插件。其中,第一页将是身份验证页面。
为此编写的代码是
this.urlLabel = new Label(loginPanel, SWT.NONE);
this.urlLabel.setText("Server URL");
this.server = new Text(loginPanel, SWT.BORDER);
this.usernameLabel = new Label(loginPanel, SWT.NONE);
this.usernameLabel.setText("Username");
this.username = new Text(loginPanel, SWT.BORDER);
this.passwordLabel = new Label(loginPanel, SWT.NONE);
this.passwordLabel.setText("Password");
this.password = new Text(loginPanel, 4196352);
所以我想做的是,对于 URL,当我开始输入用户名时,它应该会建议我使用之前输入的值。
怎么做。
帮我解决这个问题。
您可以为此使用 org.eclipse.jface.fieldassist.AutoCompleteField
。
对于文本控件使用:
new AutoCompleteField(control, new TextContentAdapter(), proposals);
其中 control
是一个 Text
控件(例如您的 username
)。
proposals
是一个字符串数组,其中包含您希望自动完成使用的先前值。
您可以调用AutoCompleteField
的setProposals
方法来更新提案数组。
我正在开发一个eclipse 插件。其中,第一页将是身份验证页面。
为此编写的代码是
this.urlLabel = new Label(loginPanel, SWT.NONE);
this.urlLabel.setText("Server URL");
this.server = new Text(loginPanel, SWT.BORDER);
this.usernameLabel = new Label(loginPanel, SWT.NONE);
this.usernameLabel.setText("Username");
this.username = new Text(loginPanel, SWT.BORDER);
this.passwordLabel = new Label(loginPanel, SWT.NONE);
this.passwordLabel.setText("Password");
this.password = new Text(loginPanel, 4196352);
所以我想做的是,对于 URL,当我开始输入用户名时,它应该会建议我使用之前输入的值。 怎么做。 帮我解决这个问题。
您可以为此使用 org.eclipse.jface.fieldassist.AutoCompleteField
。
对于文本控件使用:
new AutoCompleteField(control, new TextContentAdapter(), proposals);
其中 control
是一个 Text
控件(例如您的 username
)。
proposals
是一个字符串数组,其中包含您希望自动完成使用的先前值。
您可以调用AutoCompleteField
的setProposals
方法来更新提案数组。