1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| ...
MyComboViewer comboViewer = new MyComboViewer(shell, SWT.NONE),
comboViewerII = new MyComboViewer(shell, SWT.NONE);
comboViewer.setContentProvider(new StructuredContentProviderExample());
comboViewer.setLabelProvider(new LabelProviderExample(false));
comboViewerII.setContentProvider(new StructuredContentProviderExample());
comboViewerII.setLabelProvider(new LabelProviderExample(true));
personList.add(new Person("", ""));
personList.add(new Person("David", "Jean"));
...
personList.add(new Person("Alfred", "Sawyer"));
List input = (List)((ArrayList<Person>)personList).clone();
comboViewer.setInput(input);
comboViewerII.setInput(input);
Combo myCombo = comboViewer.getCombo();
GridData gridData = new GridData(GridData.FILL_BOTH);
myCombo.setLayoutData(gridData);
Combo myComboII = comboViewerII.getCombo();
GridData gridDataII = new GridData(GridData.FILL_BOTH);
myComboII.setLayoutData(gridDataII);
Person albert = new Person("Albert", "Muda");
ISelection select = new StructuredSelection(albert);
input.add(albert);
comboViewer.refresh();
comboViewerII.refresh(); // <- :-/
comboViewerII.setSelection(select);
... |
Partager