Witam,
Czy jest możliwość zwracania danych z child shella do parent shella?
Już tłumaczę problem..
Otóż, mam klasę:
public class CreateOffer {
ArrayList<ProductsList> items=new ArrayList<ProductsList>();
ExpandBar bar;
Text place;
public CreateOffer(final Display display)
{
final Shell shell = new Shell(display,SWT.SHELL_TRIM &(~SWT.RESIZE)&(~SWT.MAX));
shell.setText("Tworzenie nowej oferty");
shell.setSize(600,400);
FillLayout lay = new FillLayout();
shell.setLayout(lay);
bar=new ExpandBar(shell, SWT.V_SCROLL);
Button addNewPlace = new Button(shell, SWT.PUSH);
addNewPlace.setText("Dodaj pomieszczenie");
addNewPlace.addSelectionListener(new SelectionAdapter(){
@Override
public void widgetSelected(SelectionEvent e)
{
ProductsList prod= new ProductsList(bar, SWT.NONE, place.getText(),shell, display);
items.add(prod);
shell.layout(true);
}
});
place = new Text(shell, SWT.SINGLE);
shell.open();
}
}
Przy wciśnieciu przycisku tworzony jest nowy composite jako ExpandBarItem.
public class ProductsList extends Composite{
TableItem[] selectionP;
public ProductsList(Composite comp, int arg, String name,final Shell shell, final Display display)
{
super(comp, arg);
GridLayout layout = new GridLayout();
layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10;
layout.verticalSpacing = 10;
this.setLayout(layout);
ExpandItem item0=new ExpandItem((ExpandBar)comp, SWT.NONE,0);
item0.setText(name);
item0.setExpanded(true);
this.addListener(SWT.MenuDetect, new Listener() {
public void handleEvent(Event event) {
Menu menu = new Menu((Shell)shell, SWT.POP_UP);
MenuItem item = new MenuItem(menu, SWT.PUSH);
item.setText("Dodaj produkt");
item.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
addProductToPlace aPTP =new addProductToPlace(shell);
System.out.println(aPTP.open());
}
});
menu.setLocation(event.x, event.y);
menu.setVisible(true);
while (!menu.isDisposed() && menu.isVisible()) {
if (!display.readAndDispatch())
display.sleep();
}
menu.dispose();
}
});
Table table= new Table(this, SWT.BORDER | SWT.MULTI);
table.setHeaderVisible(true);
TableColumn col1=new TableColumn(table, SWT.NONE);
col1.setText("id");
TableColumn col2=new TableColumn(table, SWT.NONE);
col2.setText("ilosc");
item0.setHeight(this.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
item0.setControl(this);
this.layout(true);
}
}
Klikając na niego możemy wywołać menu kontekstowe do dodawania produktów, które wybieramy z tabeli zawierającej dane z bazy danych.
I teraz pytanie, jak przekazać dane w postaci choćby TableItem[] selection; do klasy ProductsList?