package org.argeo.cms.swt.dialogs;
import org.argeo.api.cms.CmsLog;
+import org.argeo.cms.ux.widgets.CmsDialog;
import org.argeo.eclipse.ui.EclipseUiException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusEvent;
public class LightweightDialog {
private final static CmsLog log = CmsLog.getLog(LightweightDialog.class);
- // must be the same value as org.eclipse.jface.window.Window#OK
- public final static int OK = 0;
- // must be the same value as org.eclipse.jface.window.Window#CANCEL
- public final static int CANCEL = 1;
-
private Shell parentShell;
private Shell backgroundShell;
private Shell foregoundShell;
if (hasChildShells())
return;
if (returnCode == null)// not yet closed
- closeShell(CANCEL);
+ closeShell(CmsDialog.CANCEL);
}
@Override
if (hasChildShells())
return;
if (returnCode == null)// not yet closed
- closeShell(CANCEL);
+ closeShell(CmsDialog.CANCEL);
}
});
backgroundShell.addDisposeListener((event) -> onClose());
block();
}
if (returnCode == null)
- returnCode = OK;
+ returnCode = CmsDialog.OK;
return returnCode;
}
try {
runEventLoop(foregoundShell);
} catch (ThreadDeath t) {
- returnCode = CANCEL;
+ returnCode = CmsDialog.CANCEL;
if (log.isTraceEnabled())
log.error("Thread death, canceling dialog", t);
} catch (Throwable t) {
- returnCode = CANCEL;
+ returnCode = CmsDialog.CANCEL;
log.error("Cannot open blocking lightweight dialog", t);
}
}
private synchronized void notifyClose() {
if (returnCode == null)
- returnCode = CANCEL;
+ returnCode = CmsDialog.CANCEL;
notifyAll();
}
protected void closeShell(int returnCode) {
this.returnCode = returnCode;
- if (CANCEL == returnCode)
+ if (CmsDialog.CANCEL == returnCode)
onCancel();
if (foregoundShell != null && !foregoundShell.isDisposed()) {
foregoundShell.close();