Java 在eclipse中获取对话框的输入字段
对于我的插件,我尝试使用以下行获取活动的Eclipse对话框:Java 在eclipse中获取对话框的输入字段,java,eclipse,eclipse-plugin,dialog,title,Java,Eclipse,Eclipse Plugin,Dialog,Title,对于我的插件,我尝试使用以下行获取活动的Eclipse对话框: String shellTitle = Display.getCurrent().getActiveShell().getTitle(); System.out.println("Opened dialog: " + shellTitle); 例如,如果我打开“搜索”对话框,这些行将打印我 Opened dialog: Search 在我的控制台里。例如,我还想在搜索字段中打印关键字 Opened dialog: Search
String shellTitle = Display.getCurrent().getActiveShell().getTitle();
System.out.println("Opened dialog: " + shellTitle);
例如,如果我打开“搜索”对话框,这些行将打印我
Opened dialog: Search
在我的控制台里。例如,我还想在搜索字段中打印关键字
Opened dialog: Search (with the search word 'ChatSession')
我已经阅读了API参考,在那里,我可以找到getTitle和其他一些获取边界的方法等等
我的想法可以实现吗?如果不是,这些所谓的扩展点是否可以实现?我从未使用过它们,但听说过。你问题中的错误: 您正在对Shell数组对象调用getTitle方法。这是错误的。 您正在混合对话框和Shell 假设你说的是壳牌。您可以使用以下代码获取活动Shell上的控件 导入org.eclipse.swt.swt; 导入org.eclipse.swt.events.SelectionEvent; 导入org.eclipse.swt.events.SelectionListener; 导入org.eclipse.swt.layout.FillLayout; 导入org.eclipse.swt.widgets.Button; 导入org.eclipse.swt.widgets.Control; 导入org.eclipse.swt.widgets.Display; 导入org.eclipse.swt.widgets.Label; 导入org.eclipse.swt.widgets.Shell; 导入org.eclipse.swt.widgets.Text; 公共类ShellControlsGetting{ 公共静态无效字符串[]args{ 显示=新显示; 最终外壳=新外壳显示; shell.setLayoutnew FillLayout; Button Button=新按钮Shell,SWT.PUSH; button.settext打开3个外壳; 最终外壳[]外壳=新外壳[3]; button.AddSelectionListener新建SelectionListener{ @凌驾 公共无效widgetSelectedSelectionEvent e{ 对于int i=0;i<3;i++{ 壳[i]=新壳; shell[i].setTextShell+i+1; shells[i].setLayoutnew FillLayout; 贝壳类[i].设置尺寸250,50; 外壳[i].设置位置100200+i+1*100; Label Label=新标签盒[i],SWT.左; label.settext搜索框+i+1; 文本搜索=新文本外壳[i],SWT.SINGLE | SWT.BORDER; search.setTextsearch键+i+1; 贝壳[i].开放; } Shell currentActiveShell=Display.getCurrent.getActiveShell; 字符串shellTitle=currentActiveShell.getText; Control[]children=currentActiveShell.getChildren; 对于int i=0;i