private boolean fillStatementParameters(final List<SQLQueryParameter> parameters) { final RunnableWithResult<Boolean> binder = new RunnableWithResult<Boolean>() { @Override public void run() { SQLQueryParameterBindDialog dialog = new SQLQueryParameterBindDialog(partSite, getExecutionContext(), parameters); result = (dialog.open() == IDialogConstants.OK_ID); } }; UIUtils.runInUI(partSite.getShell(), binder); Boolean result = binder.getResult(); return result != null && result; }
public static boolean confirmAction( final Shell shell, final String title, final String question) { RunnableWithResult<Boolean> confirmer = new RunnableWithResult<Boolean>() { @Override public void run() { MessageBox messageBox = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO); messageBox.setMessage(question); messageBox.setText(title); int response = messageBox.open(); result = (response == SWT.YES); } }; runInUI(shell, confirmer); return confirmer.getResult(); }
@Override public DBAAuthInfo promptUserCredentials(String prompt, String userName, String userPassword) { // Ask user final Shell shell = DBeaverUI.getActiveWorkbenchShell(); final BaseAuthDialog authDialog = new BaseAuthDialog(shell, prompt); authDialog.setUserName(userName); authDialog.setUserPassword(userPassword); final RunnableWithResult<Boolean> binder = new RunnableWithResult<Boolean>() { @Override public void run() { result = (authDialog.open() == IDialogConstants.OK_ID); } }; UIUtils.runInUI(shell, binder); if (binder.getResult() != null && binder.getResult()) { return authDialog.getAuthInfo(); } else { return null; } }