1
votes

Here is an extract of my Eclipse RCP application I am working on:

UML diagram

Description: In the method createContents(Composite) inside the class ContainerSelectionDialog I am calling createComposite(Composite) in MyComposite, which inherits from the abstract class 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));

Inside createComposite(Composite) I am creating SWT widgets like org.eclipse.swt.widgets.Text, org.eclipse.swt.widgets.Combo and so on. Example:

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);

So inside my Eclipse RCP application, the user can open a dialog with the defined widget elements, where he can input data. In okPressed(), in the class ContainerSelectionDialog I want to read the values, the user put in, by using getSettings() from MyComposite:

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

This is not my design decision. I am just trying to understand the following: How to use the getSettings() method inside okPressed(), to get the values?

Hope this is enough information, otherwise I will give additional info in the comments. I would appriciate any help!

1
What exactly is the problem with invoking a method (getSimulationSettings) on an object (abstractCompositeProxy)? The method signature appears weird, but might be okay for you. I would expect getSimulationSettings returning a List of Setting-instances, which might lead to invoke "addAll" on results, instead of add. - gia

1 Answers

0
votes

Access compositeProxy from okPressed() in the same way you do in createContents().