eclipse插件开发Properties视图实现ComboBoxCellEditor

忘了隐藏 2009-11-05 04:58:17
现在在eclipse 插件的Properties视图中使用ComboBoxCellEditor,如何实现下面的功能
1.当有键盘输入时实现下拉框即时弹出;
2.并且下拉框中的内容会和输入的内容相匹配,类似一些网站实现的功能。
...全文
238 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
霜之哀伤 2009-11-06
  • 打赏
  • 举报
回复
可以研究下这个:Content proposals,就是类似Java编辑器里的自动提示。

在Eclipse自带的帮助里:
Platform Plug-in Developer Guide > Programmer's Guide > JFace UI framework > Field Assist > Content proposals

swandragon 2009-11-06
  • 打赏
  • 举报
回复
没做过插件开发

监听键盘事件,有输入时就弹出一个下拉框
输入的内容与文本内容比较,把相似的取出来显示在下拉框中

用js做过类似的功能
忘了隐藏 2009-11-06
  • 打赏
  • 举报
回复
以下方法直接copy到eclipse在导入相应包就可运行,当按CTRL+/或者输入new char[] { '#', '(' }中的'#'和'('顺利呼出弹出框
import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.jface.bindings.keys.ParseException;
import org.eclipse.jface.fieldassist.ContentProposalAdapter;
import org.eclipse.jface.fieldassist.IContentProposalProvider;
import org.eclipse.jface.fieldassist.SimpleContentProposalProvider;
public static void main(String[] args){
Display display = new Display();
Shell sShell = new Shell(display);
sShell.setText("Shell");
GridLayout gridLayout = new GridLayout(1, false);
sShell.setLayout(gridLayout);
sShell.setSize(new Point(300, 200));
KeyStroke keyStroke;
final Text t = new Text(sShell, SWT.BORDER | SWT.MULTI);
t.setLayoutData(new GridData(GridData.FILL_BOTH));
// final Combo t = new Combo(sShell,0);
// t.setItems(new String[]{"abc","bcd","cde"});
char[] autoActivationCharacters = new char[] { '#', '(' };
try {
keyStroke = KeyStroke.getInstance("Alt+/");
ContentProposalAdapter adapter = new ContentProposalAdapter(t,
new TextContentAdapter(), new SimpleContentProposalProvider(
new String[] { "建议1", "建议2", "建议3" }),keyStroke,
autoActivationCharacters);

} catch (ParseException e1) {
e1.printStackTrace();
}

sShell.open();

while (!sShell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();


}


但是在eclipse插件中利用这个类ContentAssistFieldCellEditor google搜一下第一个就是,它基于ContentProposalAdapter,new ContentAssistFieldCellEditor(
parent,
new char[] { '#', '(', 'a' },
new SimpleContentProposalProvider(new String[]{"a","b","c"})
在Properties视图中怎么也呼不出弹出框,弄了两天没进展 郁闷
GreenVesture 2009-11-05
  • 打赏
  • 举报
回复
这个直接用Combo很难实现,其实你看下Combo的代码,它是由一个Text,一个List和一个Button组合而成的,只不过它已经把功能封装好了...那么我觉得你可以自己用一个Text和一个List来实现你需要的功能,Text用来供用户输入(在Text上监听键盘输入),而List用于显示匹配内容,就像eclipse里面的content assist一样.....呵呵,仅仅提供个思路

58,452

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧