editSuppButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Set<ToolPlan> allPlans = ToolProjectSupport.getAllPlansForProject(model.getProject());
Set<ToolPlan> supplierPlans = model.getSupplierPlansAsToolPlans();
ListSelectionDialog supplierDialog = new ListSelectionDialog(getShell(),
allPlans,
new IStructuredContentProvider(){
@Override
public void dispose() {
}
@Override
public void inputChanged(Viewer arg0, Object arg1,
Object arg2) {
}
@Override
public Object[] getElements(Object parent) {
if (parent instanceof Set<?>){
return ((Set<?>)parent).toArray();
}
return null;
}
},
new LabelProvider(),
"Select suppier plans from list");
supplierDialog.setInitialSelections(supplierPlans.toArray());
supplierDialog.setTitle("Supplier Plans");
int act = supplierDialog.open();
switch (act){
case Dialog.OK:
/*
* 1. clear the existing suppliers,
* 2. write the selected ones
* 3. rewrite the prx file
*/
Object[] sups = supplierDialog.getResult();
model.clearSuppliers();
for (Object elem : sups){
String name = ((ToolPlan)elem).getToolName();
model.addSupplierPlan(name);
}