Пример #1
0
 public static boolean validateAndSave(DBRProgressMonitor monitor, ISaveablePart saveable) {
   if (!saveable.isDirty()) {
     return true;
   }
   SaveRunner saveRunner = new SaveRunner(monitor, saveable);
   runInUI(null, saveRunner);
   return saveRunner.getResult();
 }
Пример #2
0
 public static void showMessageBox(
     final Shell shell, final String title, final String info, final int messageType) {
   Runnable runnable =
       new Runnable() {
         @Override
         public void run() {
           MessageBox messageBox = new MessageBox(shell, messageType | SWT.OK);
           messageBox.setMessage(info);
           messageBox.setText(title);
           messageBox.open();
         }
       };
   runInUI(shell, runnable);
 }
Пример #3
0
 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;
 }
Пример #4
0
 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();
 }
Пример #5
0
  private IStatus run(DBRProgressMonitor monitor, boolean lazy) {
    monitor = visualizer.overwriteMonitor(monitor);

    LoadingUIJob<RESULT> updateUIJob = new LoadingUIJob<>(this, monitor);
    updateUIJob.schedule();
    this.loadingService.setProgressMonitor(monitor);
    Throwable error = null;
    RESULT result = null;
    try {
      result = this.loadingService.evaluate();
    } catch (InvocationTargetException e) {
      //            log.error(e.getTargetException());
      error = e.getTargetException();
    } catch (InterruptedException e) {
      return new Status(Status.CANCEL, DBeaverCore.PLUGIN_ID, "Loading interrupted");
    } finally {
      UIUtils.runInUI(null, new LoadFinisher(result, error));
    }
    return Status.OK_STATUS;
  }
Пример #6
0
 @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;
   }
 }
Пример #7
0
 public static void showErrorDialog(
     @Nullable final Shell shell,
     @NotNull final String title,
     @Nullable final String message,
     @NotNull final IStatus status) {
   for (IStatus s = status; s != null; ) {
     if (s.getException() instanceof DBException) {
       if (showDatabaseError(shell, title, message, (DBException) s.getException())) {
         // If this DB error was handled by some DB-specific way then just don't care about it
         return;
       }
       break;
     }
     if (s.getChildren() != null && s.getChildren().length > 0) {
       s = s.getChildren()[0];
     } else {
       break;
     }
   }
   // log.debug(message);
   Runnable runnable =
       new Runnable() {
         @Override
         public void run() {
           // Display the dialog
           StandardErrorDialog dialog =
               new StandardErrorDialog(
                   shell == null ? DBeaverUI.getActiveWorkbenchShell() : shell,
                   title,
                   message,
                   RuntimeUtils.stripStack(status),
                   IStatus.ERROR);
           dialog.open();
         }
       };
   runInUI(shell, runnable);
 }