problem with opening multiple modal windows
hi
I have a problem with opening multiple modal windows. I create the main shell window and then a second (modal) window that does some processing. at a certain point the second window launches a third window that I need for some additional user input (which I don't what in the second window). the third window is also modal but the processing in window number 2 is not stopped for the time window number 3 is running - how can I do this?
(in other words - how can i stop B from running while C is open?)
below is the code to show my problem
class A:
=======
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
publicclass A{
privatestatic Display display =null;
private Shell shell =null;
publicstaticvoid main(String[] args){
display = Display.getDefault();
A thisClass =new A();
thisClass.createWindow();
thisClass.shell.open();
while (!thisClass.shell.isDisposed()){
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
privatevoid createWindow()
{
shell =new Shell();
shell.setText("First Window");
shell.setSize(640, 430);
openSecondWindow();
}
privatevoid openSecondWindow()
{
new B(shell);
}
}
class B:
=======
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
publicclass B{
private Shell parent =null;
public B(Shell parent)
{
this.parent = parent;
createWindow();
}
privatevoid createWindow()
{
Shell dialog =new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
dialog.setText("Second Window");
dialog.setSize(330, 200);
Text t =new Text(dialog, SWT.MULTI);
t.setBounds(0,0, 330, 200);
dialog.open();
t.append("dialog opened\n");
t.append("opening third window\n");
C c =new C(dialog);
//I want this window to wait for C !!!
t.append("third window is open\n");
t.append("this windows doesn't wait for the third one to finish\n");
t.append("the value of c.shouldClose() is " + c.shouldClose() +"\n");
}
}
class C:
=======
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
publicclass C{
private Shell parent =null;
privateboolean shouldClose =false;
public C(Shell parent)
{
this.parent = parent;
createWindow();
}
privatevoid createWindow()
{
final Shell dialog =new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
dialog.setText("Third Window");
dialog.setSize(200, 100);
dialog.open();
Button ok =new Button(dialog, SWT.NORMAL);
ok.setText("OK");
ok.setBounds(10, 10, 75, 23);
ok.addListener(SWT.Selection,new Listener(){
publicvoid handleEvent(Event e){
shouldClose =false;
dialog.close();
}
});
Button cancel =new Button(dialog, SWT.NORMAL);
cancel.setText("Anuluj");
cancel.setBounds(100, 10, 75, 23);
cancel.addListener(SWT.Selection,new Listener(){
publicvoid handleEvent(Event e){
shouldClose =true;
dialog.close();
}
});
}
publicboolean shouldClose()
{
return shouldClose;
}
}
thank you very much in advance

