Search in sources :

Example 11 with DatabaseDialog

use of org.pentaho.di.ui.core.database.dialog.DatabaseDialog in project pentaho-kettle by pentaho.

the class JobEntryDialog method showDbDialogUnlessCancelledOrValid.

@VisibleForTesting
String showDbDialogUnlessCancelledOrValid(DatabaseMeta changing, DatabaseMeta origin) {
    changing.shareVariablesWith(jobMeta);
    DatabaseDialog cid = getDatabaseDialog();
    cid.setDatabaseMeta(changing);
    cid.setModalDialog(true);
    String name = null;
    boolean repeat = true;
    while (repeat) {
        name = cid.open();
        if (name == null) {
            // Cancel was pressed
            repeat = false;
        } else {
            name = name.trim();
            DatabaseMeta same = jobMeta.findDatabase(name);
            if (same == null || same == origin) {
                // OK was pressed and input is valid
                repeat = false;
            } else {
                showDbExistsDialog(changing);
            }
        }
    }
    return name;
}
Also used : DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) DatabaseDialog(org.pentaho.di.ui.core.database.dialog.DatabaseDialog) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)11 DatabaseDialog (org.pentaho.di.ui.core.database.dialog.DatabaseDialog)11 Shell (org.eclipse.swt.widgets.Shell)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 ExecutionException (java.util.concurrent.ExecutionException)2 JSONObject (org.json.simple.JSONObject)2 Test (org.junit.Test)2 KettleException (org.pentaho.di.core.exception.KettleException)2 JobMeta (org.pentaho.di.job.JobMeta)2 TransMeta (org.pentaho.di.trans.TransMeta)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 Button (org.eclipse.swt.widgets.Button)1 Label (org.eclipse.swt.widgets.Label)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1 ComboVar (org.pentaho.di.ui.core.widget.ComboVar)1 LocalizedString (org.pentaho.metadata.model.concept.types.LocalizedString)1