[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Calling Dialog from Thread
|
Hello,
I have a dialog that I am calling from a thread. The class itself
extends Thread. I am calling the dialog from that class like so:
//dislay the validation dialog
dspDisplay.syncExec(new Runnable() {
public void run() {
if (dspDisplay.isDisposed()){
return;
DlgValidateFile dlgValidateFile = new DlgValidateFile(sShell);
dlgValidateFile.Open(sShell, alBadSessionIDs);
}
});
Unfortunately, the dialog isn't responding to any events once it is
opened. I've successfully invoked a messagebox using similar code just
prior to this call. As far as I can tell there shouldn't be a difference.
The code for the dialog is below. I'd appreciate any help in figuring
out why the dialog isn't responding.
public class DlgValidateFile extends Dialog {
private ArrayList alValidatorWidgets = new ArrayList();
public DlgValidateFile(Shell parent) {
super(parent);
// TODO Auto-generated constructor stub
}
private Shell shDlgValidator = null; //
@jve:decl-index=0:visual-constraint="70,72"
private Button cmdClose = null;
/**
* This method initializes shDlgValidator
*
*/
private void createShDlgValidator(ArrayList alBadSessionIDs) {
GridData gridData = new GridData();
gridData.widthHint = 100;
gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.CENTER;
gridData.grabExcessHorizontalSpace = true;
shDlgValidator = new Shell(SWT.DIALOG_TRIM);
shDlgValidator.setLayout(new GridLayout());
shDlgValidator.setText("Edit Data File");
shDlgValidator.setSize(new Point(375, 200));
//create custom widgets
for(int iCounter=0; iCounter< alBadSessionIDs.size(); iCounter++){
String strWidgetValidator = "widValidator" + String.valueOf(iCounter);
//add widget to list
WidgetValidator widValidator = new WidgetValidator(shDlgValidator,
SWT.NONE);
widValidator.SetLabel((String)alBadSessionIDs.get(iCounter));
alValidatorWidgets.add(widValidator);
}
cmdClose = new Button(shDlgValidator, SWT.NONE);
cmdClose.setText("&Close");
cmdClose.setLayoutData(gridData);
cmdClose.addSelectionListener(new
org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
shDlgValidator.dispose();
}
});
}
/************************************
*
* @param parent
*/public int Open(Shell parent, ArrayList alBadSessionIDs){
createShDlgValidator(alBadSessionIDs);
Display dspDisplay = parent.getDisplay();
Rectangle parentRect = this.getParent().getBounds();
int x = (int)((parentRect.width + parentRect.x)/2);
int y = (int)((parentRect.height + parentRect.y)/2);
shDlgValidator.setBounds(new Rectangle(x, y,
shDlgValidator.getBounds().width, (alBadSessionIDs.size()*40)+100));
shDlgValidator.open();
dspDisplay = parent.getDisplay();
while (!shDlgValidator.isDisposed()) {
if (!dspDisplay.readAndDispatch())
dspDisplay.sleep();
}
return 0;
}
}