【问题标题】:How to use user input in Eclipse RCP application?如何在 Eclipse RCP 应用程序中使用用户输入?
【发布时间】:2015-09-08 09:32:37
【问题描述】:

这是我正在开发的 Eclipse RCP 应用程序的摘录:

说明:在类ContainerSelectionDialog内的方法createContents(Composite)中,我在MyComposite中调用createComposite(Composite),它继承自抽象类AbstractCompositeProxy

TabFolder folder = new TabFolder((Composite) dialogArea, SWT.TOP);
Composite comp = (Composite) super.createDialogArea(folder);
TabItem tab = new TabItem(folder, SWT.NONE);
tab.setText("Header");
tab.setControl(compositeProxy
        .createComposite(comp));

createComposite(Composite) 内部,我正在创建org.eclipse.swt.widgets.Textorg.eclipse.swt.widgets.Combo 等SWT 小部件。示例:

Label label = new Label(parentComposite, SWT.NONE);
label.setText("Something");

Text text = new Text(parentComposite, SWT.BORDER);
GridData gridData = new GridData();
gridData.horizontalAlignment = SWT.FILL;
gridData.grabExcessHorizontalSpace = true;
text.setLayoutData(gridData);

所以在我的 Eclipse RCP 应用程序中,用户可以打开一个包含已定义小部件元素的对话框,他可以在其中输入数据。在okPressed() 中,在ContainerSelectionDialog 类中,我想读取用户输入的值,方法是使用MyComposite 中的getSettings()

@Override
protected void okPressed() {
    List<Object> results = new ArrayList<>();
    results.add(abstractCompositeProxy.getSimulationSettings());
    setResult(results);
    super.okPressed();
}

这不是我的设计决定。我只是想了解以下内容:如何使用okPressed() 中的getSettings() 方法来获取值?

希望这是足够的信息,否则我将在 cmets 中提供更多信息。我会给予任何帮助!

【问题讨论】:

  • 在对象 (abstractCompositeProxy) 上调用方法 (getSimulationSettings) 到底有什么问题?方法签名看起来很奇怪,但对你来说可能没问题。我希望 getSimulationSettings 返回一个设置实例列表,这可能会导致在结果上调用“addAll”,而不是 add。

标签: java eclipse-plugin swt eclipse-rcp jface


【解决方案1】:

okPressed() 访问compositeProxy,方式与在createContents() 中的相同。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-01
    • 2014-08-13
    • 1970-01-01
    相关资源
    最近更新 更多