use of org.pentaho.di.ui.core.database.dialog.DatabaseExplorerDialog in project pentaho-kettle by pentaho.
the class GPLoadDialog method getTableName.
private void getTableName(TextVar schema, TextVar tableName) {
DatabaseMeta inf = null;
// New class: SelectTableDialog
int connr = wConnection.getSelectionIndex();
if (connr >= 0) {
inf = transMeta.getDatabase(connr);
}
if (inf != null) {
if (log.isDebug()) {
logDebug(BaseMessages.getString(PKG, "GPLoadDialog.Log.LookingAtConnection") + inf.toString());
}
DatabaseExplorerDialog std = new DatabaseExplorerDialog(shell, SWT.NONE, inf, transMeta.getDatabases());
std.setSelectedSchemaAndTable(wSchema.getText(), wTable.getText());
if (std.open()) {
schema.setText(Const.NVL(std.getSchemaName(), ""));
tableName.setText(Const.NVL(std.getTableName(), ""));
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "GPLoadDialog.InvalidConnection.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "GPLoadDialog.InvalidConnection.DialogTitle"));
mb.open();
}
}
use of org.pentaho.di.ui.core.database.dialog.DatabaseExplorerDialog in project pentaho-kettle by pentaho.
the class GPBulkLoaderDialog method getTableName.
private void getTableName() {
DatabaseMeta inf = null;
// New class: SelectTableDialog
int connr = wConnection.getSelectionIndex();
if (connr >= 0) {
inf = transMeta.getDatabase(connr);
}
if (inf != null) {
if (log.isDebug()) {
logDebug(BaseMessages.getString(PKG, "GPBulkLoaderDialog.Log.LookingAtConnection") + inf.toString());
}
DatabaseExplorerDialog std = new DatabaseExplorerDialog(shell, SWT.NONE, inf, transMeta.getDatabases());
std.setSelectedSchemaAndTable(wSchema.getText(), wTable.getText());
if (std.open()) {
wSchema.setText(Const.NVL(std.getSchemaName(), ""));
wTable.setText(Const.NVL(std.getTableName(), ""));
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "GPBulkLoaderDialog.InvalidConnection.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "GPBulkLoaderDialog.InvalidConnection.DialogTitle"));
mb.open();
}
}
use of org.pentaho.di.ui.core.database.dialog.DatabaseExplorerDialog in project pentaho-kettle by pentaho.
the class JobEntryWaitForSQLDialog method getSQL.
private void getSQL() {
DatabaseMeta inf = jobMeta.findDatabase(wConnection.getText());
if (inf != null) {
DatabaseExplorerDialog std = new DatabaseExplorerDialog(shell, SWT.NONE, inf, jobMeta.getDatabases());
if (std.open()) {
String sql = "SELECT *" + Const.CR + "FROM " + inf.getQuotedSchemaTableCombination(std.getSchemaName(), std.getTableName()) + Const.CR;
wSQL.setText(sql);
MessageBox yn = new MessageBox(shell, SWT.YES | SWT.NO | SWT.CANCEL | SWT.ICON_QUESTION);
yn.setMessage(BaseMessages.getString(PKG, "JobEntryWaitForSQL.IncludeFieldNamesInSQL"));
yn.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.DialogCaptionQuestion"));
int id = yn.open();
switch(id) {
case SWT.CANCEL:
break;
case SWT.NO:
wSQL.setText(sql);
break;
case SWT.YES:
Database db = new Database(loggingObject, inf);
try {
db.connect();
RowMetaInterface fields = db.getQueryFields(sql, false);
if (fields != null) {
sql = "SELECT" + Const.CR;
for (int i = 0; i < fields.size(); i++) {
ValueMetaInterface field = fields.getValueMeta(i);
if (i == 0) {
sql += " ";
} else {
sql += ", ";
}
sql += inf.quoteField(field.getName()) + Const.CR;
}
sql += "FROM " + inf.getQuotedSchemaTableCombination(std.getSchemaName(), std.getTableName()) + Const.CR;
wSQL.setText(sql);
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "JobEntryWaitForSQL.ERROR_CouldNotRetrieveFields") + Const.CR + BaseMessages.getString(PKG, "JobEntryWaitForSQL.PerhapsNoPermissions"));
mb.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.DialogCaptionError2"));
mb.open();
}
} catch (KettleException e) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.DialogCaptionError3"));
mb.setMessage(BaseMessages.getString(PKG, "JobEntryWaitForSQL.AnErrorOccurred") + Const.CR + e.getMessage());
mb.open();
} finally {
db.disconnect();
}
break;
default:
break;
}
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "JobEntryWaitForSQL.ConnectionNoLongerAvailable"));
mb.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.DialogCaptionError4"));
mb.open();
}
}
use of org.pentaho.di.ui.core.database.dialog.DatabaseExplorerDialog in project pentaho-kettle by pentaho.
the class OraBulkLoaderDialog method getTableName.
private void getTableName() {
DatabaseMeta inf = null;
// New class: SelectTableDialog
int connr = wConnection.getSelectionIndex();
if (connr >= 0) {
inf = transMeta.getDatabase(connr);
}
if (inf != null) {
if (log.isDebug()) {
logDebug(BaseMessages.getString(PKG, "OraBulkLoaderDialog.Log.LookingAtConnection") + inf.toString());
}
DatabaseExplorerDialog std = new DatabaseExplorerDialog(shell, SWT.NONE, inf, transMeta.getDatabases());
std.setSelectedSchemaAndTable(wSchema.getText(), wTable.getText());
if (std.open()) {
wSchema.setText(Const.NVL(std.getSchemaName(), ""));
wTable.setText(Const.NVL(std.getTableName(), ""));
setTableFieldCombo();
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "OraBulkLoaderDialog.InvalidConnection.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "OraBulkLoaderDialog.InvalidConnection.DialogTitle"));
mb.open();
}
}
use of org.pentaho.di.ui.core.database.dialog.DatabaseExplorerDialog in project pentaho-kettle by pentaho.
the class JobEntryEvalTableContentDialog method getSQL.
private void getSQL() {
DatabaseMeta inf = jobMeta.findDatabase(wConnection.getText());
if (inf != null) {
DatabaseExplorerDialog std = new DatabaseExplorerDialog(shell, SWT.NONE, inf, jobMeta.getDatabases());
if (std.open()) {
String sql = "SELECT *" + Const.CR + "FROM " + inf.getQuotedSchemaTableCombination(std.getSchemaName(), std.getTableName()) + Const.CR;
wSQL.setText(sql);
MessageBox yn = new MessageBox(shell, SWT.YES | SWT.NO | SWT.CANCEL | SWT.ICON_QUESTION);
yn.setMessage(BaseMessages.getString(PKG, "JobEntryEvalTableContent.IncludeFieldNamesInSQL"));
yn.setText(BaseMessages.getString(PKG, "JobEntryEvalTableContent.DialogCaptionQuestion"));
int id = yn.open();
switch(id) {
case SWT.CANCEL:
break;
case SWT.NO:
wSQL.setText(sql);
break;
case SWT.YES:
Database db = new Database(loggingObject, inf);
try {
db.connect();
RowMetaInterface fields = db.getQueryFields(sql, false);
if (fields != null) {
sql = "SELECT" + Const.CR;
for (int i = 0; i < fields.size(); i++) {
ValueMetaInterface field = fields.getValueMeta(i);
if (i == 0) {
sql += " ";
} else {
sql += ", ";
}
sql += inf.quoteField(field.getName()) + Const.CR;
}
sql += "FROM " + inf.getQuotedSchemaTableCombination(std.getSchemaName(), std.getTableName()) + Const.CR;
wSQL.setText(sql);
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "JobEntryEvalTableContent.ERROR_CouldNotRetrieveFields") + Const.CR + BaseMessages.getString(PKG, "JobEntryEvalTableContent.PerhapsNoPermissions"));
mb.setText(BaseMessages.getString(PKG, "JobEntryEvalTableContent.DialogCaptionError2"));
mb.open();
}
} catch (KettleException e) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setText(BaseMessages.getString(PKG, "JobEntryEvalTableContent.DialogCaptionError3"));
mb.setMessage(BaseMessages.getString(PKG, "JobEntryEvalTableContent.AnErrorOccurred") + Const.CR + e.getMessage());
mb.open();
} finally {
db.disconnect();
}
break;
default:
break;
}
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "JobEntryEvalTableContent.ConnectionNoLongerAvailable"));
mb.setText(BaseMessages.getString(PKG, "JobEntryEvalTableContent.DialogCaptionError4"));
mb.open();
}
}
Aggregations