This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new 49cc28601d Add a Browse button to select a schema #5438 (#8179)
49cc28601d is described below
commit 49cc28601d66ad4311a9e4cea39b71850276ce23
Author: Nicolas Adment <[email protected]>
AuthorDate: Mon Aug 31 10:14:56 2026 +0200
Add a Browse button to select a schema #5438 (#8179)
Use try with resource in Database
---
.../org/apache/hop/core/database/Database.java | 104 ++++----------
.../tableexists/ActionTableExistsDialog.java | 9 +-
.../actions/waitforsql/ActionWaitForSqlDialog.java | 149 ++++++++++++++-------
.../mysqlbulkloader/MySqlBulkLoaderDialog.java | 47 ++++++-
.../pgbulkloader/PGBulkLoaderDialog.java | 47 ++++++-
.../bulkloader/VerticaBulkLoaderDialog.java | 48 ++++++-
.../databaselookup/DatabaseLookupDialog.java | 12 +-
.../pipeline/transforms/delete/DeleteDialog.java | 1 -
.../dimensionlookup/DimensionLookupDialog.java | 2 +-
.../gettablenames/GetTableNamesDialog.java | 56 +++++++-
.../insertupdate/InsertUpdateDialog.java | 1 -
.../sqlfileoutput/SQLFileOutputDialog.java | 47 ++++++-
12 files changed, 373 insertions(+), 150 deletions(-)
diff --git a/core/src/main/java/org/apache/hop/core/database/Database.java
b/core/src/main/java/org/apache/hop/core/database/Database.java
index 60fb44b3a6..8777edbd1d 100644
--- a/core/src/main/java/org/apache/hop/core/database/Database.java
+++ b/core/src/main/java/org/apache/hop/core/database/Database.java
@@ -3783,16 +3783,15 @@ public class Database implements IVariables,
ILoggingObject, AutoCloseable {
}
public String[] getTableTypes() throws HopDatabaseException {
- try {
+ try (ResultSet resultSet = getDatabaseMetaData().getTableTypes()) {
ArrayList<String> types = new ArrayList<>();
-
- ResultSet rstt = getDatabaseMetaData().getTableTypes();
- while (rstt.next()) {
- String ttype = rstt.getString("TABLE_TYPE");
+ while (resultSet.next()) {
+ String ttype = resultSet.getString("TABLE_TYPE");
types.add(ttype);
}
- return types.toArray(new String[types.size()]);
+ types.sort(String.CASE_INSENSITIVE_ORDER);
+ return types.toArray(new String[0]);
} catch (SQLException e) {
throw new HopDatabaseException("Unable to get table types from
database!", e);
}
@@ -3827,7 +3826,7 @@ public class Database implements IVariables,
ILoggingObject, AutoCloseable {
}
}
res.sort(String.CASE_INSENSITIVE_ORDER);
- return res.toArray(new String[res.size()]);
+ return res.toArray(new String[0]);
}
public Map<String, Collection<String>> getTableMap() throws
HopDatabaseException {
@@ -3847,10 +3846,8 @@ public class Database implements IVariables,
ILoggingObject, AutoCloseable {
schemaname = resolve(databaseMeta.getUsername()).toUpperCase();
}
Map<String, Collection<String>> tableMap = new HashMap<>();
- ResultSet alltables = null;
- try {
- alltables =
- getDatabaseMetaData().getTables(null, schemaname, null,
databaseMeta.getTableTypes());
+ try (ResultSet alltables =
+ getDatabaseMetaData().getTables(null, schemaname, null,
databaseMeta.getTableTypes())) {
while (alltables.next()) {
String cat = "";
try {
@@ -3905,15 +3902,6 @@ public class Database implements IVariables,
ILoggingObject, AutoCloseable {
}
} catch (SQLException e) {
log.logError("Error getting tablenames from schema [" + schemaname +
"]");
- } finally {
- try {
- if (alltables != null) {
- alltables.close();
- }
- } catch (SQLException e) {
- throw new HopDatabaseException(
- "Error closing resultset after getting views from schema [" +
schemaname + "]", e);
- }
}
if (log.isDetailed()) {
@@ -3945,7 +3933,7 @@ public class Database implements IVariables,
ILoggingObject, AutoCloseable {
}
}
res.sort(String.CASE_INSENSITIVE_ORDER);
- return res.toArray(new String[res.size()]);
+ return res.toArray(new String[0]);
}
public Map<String, Collection<String>> getViewMap() throws
HopDatabaseException {
@@ -3964,10 +3952,8 @@ public class Database implements IVariables,
ILoggingObject, AutoCloseable {
}
Map<String, Collection<String>> viewMap = new HashMap<>();
- ResultSet allviews = null;
- try {
- allviews =
- getDatabaseMetaData().getTables(null, schemaname, null,
databaseMeta.getViewTypes());
+ try (ResultSet allviews =
+ getDatabaseMetaData().getTables(null, schemaname, null,
databaseMeta.getViewTypes())) {
while (allviews.next()) {
String cat = "";
try {
@@ -4005,15 +3991,6 @@ public class Database implements IVariables,
ILoggingObject, AutoCloseable {
}
} catch (SQLException e) {
throw new HopDatabaseException("Error getting views from schema [" +
schemaname + "]", e);
- } finally {
- try {
- if (allviews != null) {
- allviews.close();
- }
- } catch (SQLException e) {
- throw new HopDatabaseException(
- "Error closing resultset after getting views from schema [" +
schemaname + "]", e);
- }
}
if (log.isDetailed()) {
@@ -4046,7 +4023,7 @@ public class Database implements IVariables,
ILoggingObject, AutoCloseable {
}
}
res.sort(String.CASE_INSENSITIVE_ORDER);
- return res.toArray(new String[res.size()]);
+ return res.toArray(new String[0]);
}
public Map<String, Collection<String>> getSynonymMap() throws
HopDatabaseException {
@@ -4064,10 +4041,8 @@ public class Database implements IVariables,
ILoggingObject, AutoCloseable {
schemaname = resolve(databaseMeta.getUsername()).toUpperCase();
}
Map<String, Collection<String>> synonymMap = new HashMap<>();
- ResultSet alltables = null;
- try {
- alltables =
- getDatabaseMetaData().getTables(null, schemaname, null,
databaseMeta.getSynonymTypes());
+ try (ResultSet alltables =
+ getDatabaseMetaData().getTables(null, schemaname, null,
databaseMeta.getSynonymTypes())) {
while (alltables.next()) {
String cat = "";
try {
@@ -4105,15 +4080,6 @@ public class Database implements IVariables,
ILoggingObject, AutoCloseable {
}
} catch (SQLException e) {
throw new HopDatabaseException("Error getting synonyms from schema [" +
schemaname + "]", e);
- } finally {
- try {
- if (alltables != null) {
- alltables.close();
- }
- } catch (SQLException e) {
- throw new HopDatabaseException(
- "Error closing resultset after getting synonyms from schema [" +
schemaname + "]", e);
- }
}
if (log.isDetailed()) {
@@ -4141,59 +4107,41 @@ public class Database implements IVariables,
ILoggingObject, AutoCloseable {
}
public String[] getSchemas() throws HopDatabaseException {
- ArrayList<String> catalogList = new ArrayList<>();
- ResultSet catalogResultSet = null;
- try {
- catalogResultSet = getDatabaseMetaData().getSchemas();
+ ArrayList<String> schemaList = new ArrayList<>();
+ try (ResultSet resultSet = getDatabaseMetaData().getSchemas()) {
// Grab all the catalog names and put them in an array list
- while (catalogResultSet != null && catalogResultSet.next()) {
- catalogList.add(catalogResultSet.getString(1));
+ while (resultSet != null && resultSet.next()) {
+ schemaList.add(resultSet.getString(1));
}
} catch (SQLException e) {
throw new HopDatabaseException("Error getting schemas!", e);
- } finally {
- try {
- if (catalogResultSet != null) {
- catalogResultSet.close();
- }
- } catch (SQLException e) {
- throw new HopDatabaseException("Error closing resultset after getting
schemas!", e);
- }
}
if (log.isDetailed()) {
- log.logDetailed(CONST_READ + catalogList.size() + " schemas from db
meta-data.");
+ log.logDetailed(CONST_READ + schemaList.size() + " schemas from db
meta-data.");
}
- return catalogList.toArray(new String[catalogList.size()]);
+ schemaList.sort(String.CASE_INSENSITIVE_ORDER);
+ return schemaList.toArray(new String[0]);
}
public String[] getCatalogs() throws HopDatabaseException {
ArrayList<String> catalogList = new ArrayList<>();
- ResultSet catalogResultSet = null;
- try {
- catalogResultSet = getDatabaseMetaData().getCatalogs();
+ try (ResultSet resultSet = getDatabaseMetaData().getCatalogs()) {
// Grab all the catalog names and put them in an array list
- while (catalogResultSet != null && catalogResultSet.next()) {
- catalogList.add(catalogResultSet.getString(1));
+ while (resultSet != null && resultSet.next()) {
+ catalogList.add(resultSet.getString(1));
}
} catch (SQLException e) {
throw new HopDatabaseException("Error getting catalogs!", e);
- } finally {
- try {
- if (catalogResultSet != null) {
- catalogResultSet.close();
- }
- } catch (SQLException e) {
- throw new HopDatabaseException("Error closing resultset after getting
catalogs!", e);
- }
}
if (log.isDetailed()) {
log.logDetailed(CONST_READ + catalogList.size() + " catalogs from db
meta-data.");
}
- return catalogList.toArray(new String[catalogList.size()]);
+ catalogList.sort(String.CASE_INSENSITIVE_ORDER);
+ return catalogList.toArray(new String[0]);
}
public String[] getProcedures() throws HopDatabaseException {
diff --git
a/plugins/actions/tableexists/src/main/java/org/apache/hop/workflow/actions/tableexists/ActionTableExistsDialog.java
b/plugins/actions/tableexists/src/main/java/org/apache/hop/workflow/actions/tableexists/ActionTableExistsDialog.java
index 5708f87172..f84f70064d 100644
---
a/plugins/actions/tableexists/src/main/java/org/apache/hop/workflow/actions/tableexists/ActionTableExistsDialog.java
+++
b/plugins/actions/tableexists/src/main/java/org/apache/hop/workflow/actions/tableexists/ActionTableExistsDialog.java
@@ -191,9 +191,7 @@ public class ActionTableExistsDialog extends ActionDialog {
try (Database database = new Database(loggingObject, variables,
databaseMeta)) {
database.connect();
String[] schemas = database.getSchemas();
-
if (null != schemas && schemas.length > 0) {
- schemas = Const.sortStrings(schemas);
EnterSelectionDialog dialog =
new EnterSelectionDialog(
shell,
@@ -201,11 +199,10 @@ public class ActionTableExistsDialog extends ActionDialog
{
BaseMessages.getString(
PKG, "System.Dialog.AvailableSchemas.Title",
wConnection.getText()),
BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Message"));
- String d = dialog.open();
- if (d != null) {
- wSchemaname.setText(Const.NVL(d.toString(), ""));
+ String name = dialog.open();
+ if (name != null) {
+ wSchemaname.setText(name);
}
-
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(
diff --git
a/plugins/actions/waitforsql/src/main/java/org/apache/hop/workflow/actions/waitforsql/ActionWaitForSqlDialog.java
b/plugins/actions/waitforsql/src/main/java/org/apache/hop/workflow/actions/waitforsql/ActionWaitForSqlDialog.java
index 2f5562492c..df06338c5d 100644
---
a/plugins/actions/waitforsql/src/main/java/org/apache/hop/workflow/actions/waitforsql/ActionWaitForSqlDialog.java
+++
b/plugins/actions/waitforsql/src/main/java/org/apache/hop/workflow/actions/waitforsql/ActionWaitForSqlDialog.java
@@ -32,6 +32,8 @@ import org.apache.hop.i18n.BaseMessages;
import org.apache.hop.ui.core.PropsUi;
import org.apache.hop.ui.core.database.dialog.DatabaseExplorerDialog;
import org.apache.hop.ui.core.dialog.BaseDialog;
+import org.apache.hop.ui.core.dialog.EnterSelectionDialog;
+import org.apache.hop.ui.core.dialog.ErrorDialog;
import org.apache.hop.ui.core.dialog.MessageBox;
import org.apache.hop.ui.core.widget.MetaSelectionLine;
import org.apache.hop.ui.core.widget.SQLStyledTextComp;
@@ -92,11 +94,11 @@ public class ActionWaitForSqlDialog extends ActionDialog {
private Label wlPosition;
// Schema name
- private Label wlSchemaname;
- private TextVar wSchemaname;
+ private Label wlSchemaName;
+ private TextVar wSchemaName;
- private Label wlTablename;
- private TextVar wTablename;
+ private Label wlTableName;
+ private TextVar wTableName;
private CCombo wSuccessCondition;
@@ -134,41 +136,50 @@ public class ActionWaitForSqlDialog extends ActionDialog {
wConnection.addListener(SWT.Selection, e -> getSqlReservedWords());
// Schema name line
- wlSchemaname = new Label(shell, SWT.RIGHT);
- wlSchemaname.setText(BaseMessages.getString(PKG,
"ActionWaitForSQL.Schemaname.Label"));
- PropsUi.setLook(wlSchemaname);
- FormData fdlSchemaname = new FormData();
- fdlSchemaname.left = new FormAttachment(0, 0);
- fdlSchemaname.right = new FormAttachment(middle, -margin);
- fdlSchemaname.top = new FormAttachment(wConnection, margin);
- wlSchemaname.setLayoutData(fdlSchemaname);
-
- wSchemaname = new TextVar(variables, shell, SWT.SINGLE | SWT.LEFT |
SWT.BORDER);
- PropsUi.setLook(wSchemaname);
- wSchemaname.setToolTipText(BaseMessages.getString(PKG,
"ActionWaitForSQL.Schemaname.Tooltip"));
- wSchemaname.addModifyListener(lsMod);
+ wlSchemaName = new Label(shell, SWT.RIGHT);
+ wlSchemaName.setText(BaseMessages.getString(PKG,
"ActionWaitForSQL.Schemaname.Label"));
+ PropsUi.setLook(wlSchemaName);
+ FormData fdlSchemaName = new FormData();
+ fdlSchemaName.left = new FormAttachment(0, 0);
+ fdlSchemaName.right = new FormAttachment(middle, -margin);
+ fdlSchemaName.top = new FormAttachment(wConnection, margin);
+ wlSchemaName.setLayoutData(fdlSchemaName);
+
+ Button wbSchema = new Button(shell, SWT.PUSH | SWT.CENTER);
+ PropsUi.setLook(wbSchema);
+ wbSchema.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
+ FormData fdbSchema = new FormData();
+ fdbSchema.top = new FormAttachment(wConnection, margin);
+ fdbSchema.right = new FormAttachment(100, 0);
+ wbSchema.setLayoutData(fdbSchema);
+ wbSchema.addListener(SWT.Selection, e -> getSchemaName());
+
+ wSchemaName = new TextVar(variables, shell, SWT.SINGLE | SWT.LEFT |
SWT.BORDER);
+ PropsUi.setLook(wSchemaName);
+ wSchemaName.setToolTipText(BaseMessages.getString(PKG,
"ActionWaitForSQL.Schemaname.Tooltip"));
+ wSchemaName.addModifyListener(lsMod);
FormData fdSchemaname = new FormData();
fdSchemaname.left = new FormAttachment(middle, 0);
fdSchemaname.top = new FormAttachment(wConnection, margin);
- fdSchemaname.right = new FormAttachment(100, 0);
- wSchemaname.setLayoutData(fdSchemaname);
+ fdSchemaname.right = new FormAttachment(wbSchema, -margin);
+ wSchemaName.setLayoutData(fdSchemaname);
// Table name line
- wlTablename = new Label(shell, SWT.RIGHT);
- wlTablename.setText(BaseMessages.getString(PKG,
"ActionWaitForSQL.Tablename.Label"));
- PropsUi.setLook(wlTablename);
+ wlTableName = new Label(shell, SWT.RIGHT);
+ wlTableName.setText(BaseMessages.getString(PKG,
"ActionWaitForSQL.Tablename.Label"));
+ PropsUi.setLook(wlTableName);
FormData fdlTablename = new FormData();
fdlTablename.left = new FormAttachment(0, 0);
fdlTablename.right = new FormAttachment(middle, -margin);
- fdlTablename.top = new FormAttachment(wSchemaname, margin);
- wlTablename.setLayoutData(fdlTablename);
+ fdlTablename.top = new FormAttachment(wSchemaName, margin);
+ wlTableName.setLayoutData(fdlTablename);
wbTable = new Button(shell, SWT.PUSH | SWT.CENTER);
PropsUi.setLook(wbTable);
wbTable.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
FormData fdbTable = new FormData();
fdbTable.right = new FormAttachment(100, 0);
- fdbTable.top = new FormAttachment(wSchemaname, margin / 2);
+ fdbTable.top = new FormAttachment(wSchemaName, margin);
wbTable.setLayoutData(fdbTable);
wbTable.addSelectionListener(
new SelectionAdapter() {
@@ -178,15 +189,15 @@ public class ActionWaitForSqlDialog extends ActionDialog {
}
});
- wTablename = new TextVar(variables, shell, SWT.SINGLE | SWT.LEFT |
SWT.BORDER);
- PropsUi.setLook(wTablename);
- wTablename.setToolTipText(BaseMessages.getString(PKG,
"ActionWaitForSQL.Tablename.Tooltip"));
- wTablename.addModifyListener(lsMod);
+ wTableName = new TextVar(variables, shell, SWT.SINGLE | SWT.LEFT |
SWT.BORDER);
+ PropsUi.setLook(wTableName);
+ wTableName.setToolTipText(BaseMessages.getString(PKG,
"ActionWaitForSQL.Tablename.Tooltip"));
+ wTableName.addModifyListener(lsMod);
FormData fdTablename = new FormData();
fdTablename.left = new FormAttachment(middle, 0);
- fdTablename.top = new FormAttachment(wSchemaname, margin);
+ fdTablename.top = new FormAttachment(wSchemaName, margin);
fdTablename.right = new FormAttachment(wbTable, -margin);
- wTablename.setLayoutData(fdTablename);
+ wTableName.setLayoutData(fdTablename);
// ////////////////////////
// START OF Success GROUP///
@@ -216,7 +227,7 @@ public class ActionWaitForSqlDialog extends ActionDialog {
PropsUi.setLook(wSuccessCondition);
FormData fdSuccessCondition = new FormData();
- fdSuccessCondition.left = new FormAttachment(middle, -margin);
+ fdSuccessCondition.left = new FormAttachment(middle, 0);
fdSuccessCondition.top = new FormAttachment(0, margin);
fdSuccessCondition.right = new FormAttachment(100, 0);
wSuccessCondition.setLayoutData(fdSuccessCondition);
@@ -247,7 +258,7 @@ public class ActionWaitForSqlDialog extends ActionDialog {
PropsUi.setLook(wRowsCountValue);
wRowsCountValue.addModifyListener(lsMod);
FormData fdRowsCountValue = new FormData();
- fdRowsCountValue.left = new FormAttachment(middle, -margin);
+ fdRowsCountValue.left = new FormAttachment(middle, 0);
fdRowsCountValue.top = new FormAttachment(wSuccessCondition, margin);
fdRowsCountValue.right = new FormAttachment(100, 0);
wRowsCountValue.setLayoutData(fdRowsCountValue);
@@ -267,7 +278,7 @@ public class ActionWaitForSqlDialog extends ActionDialog {
BaseMessages.getString(PKG,
"ActionWaitForSQL.MaximumTimeout.Tooltip"));
wMaximumTimeout.addModifyListener(lsMod);
FormData fdMaximumTimeout = new FormData();
- fdMaximumTimeout.left = new FormAttachment(middle, -margin);
+ fdMaximumTimeout.left = new FormAttachment(middle, 0);
fdMaximumTimeout.top = new FormAttachment(wRowsCountValue, margin);
fdMaximumTimeout.right = new FormAttachment(100, 0);
wMaximumTimeout.setLayoutData(fdMaximumTimeout);
@@ -287,7 +298,7 @@ public class ActionWaitForSqlDialog extends ActionDialog {
BaseMessages.getString(PKG,
"ActionWaitForSQL.CheckCycleTime.Tooltip"));
wCheckCycleTime.addModifyListener(lsMod);
FormData fdCheckCycleTime = new FormData();
- fdCheckCycleTime.left = new FormAttachment(middle, -margin);
+ fdCheckCycleTime.left = new FormAttachment(middle, 0);
fdCheckCycleTime.top = new FormAttachment(wMaximumTimeout, margin);
fdCheckCycleTime.right = new FormAttachment(100, 0);
wCheckCycleTime.setLayoutData(fdCheckCycleTime);
@@ -307,7 +318,7 @@ public class ActionWaitForSqlDialog extends ActionDialog {
wSuccessOnTimeout.setToolTipText(
BaseMessages.getString(PKG,
"ActionWaitForSQL.SuccessOnTimeout.Tooltip"));
FormData fdSuccessOnTimeout = new FormData();
- fdSuccessOnTimeout.left = new FormAttachment(middle, -margin);
+ fdSuccessOnTimeout.left = new FormAttachment(middle, 0);
fdSuccessOnTimeout.top = new FormAttachment(wlSuccessOnTimeout, 0,
SWT.CENTER);
fdSuccessOnTimeout.right = new FormAttachment(100, -margin);
wSuccessOnTimeout.setLayoutData(fdSuccessOnTimeout);
@@ -353,7 +364,7 @@ public class ActionWaitForSqlDialog extends ActionDialog {
PropsUi.setLook(wCustomSql);
wCustomSql.setToolTipText(BaseMessages.getString(PKG,
"ActionWaitForSQL.customSQL.Tooltip"));
FormData fdCustomSql = new FormData();
- fdCustomSql.left = new FormAttachment(middle, -margin);
+ fdCustomSql.left = new FormAttachment(middle, 0);
fdCustomSql.top = new FormAttachment(wlCustomSql, 0, SWT.CENTER);
fdCustomSql.right = new FormAttachment(100, 0);
wCustomSql.setLayoutData(fdCustomSql);
@@ -380,7 +391,7 @@ public class ActionWaitForSqlDialog extends ActionDialog {
wUseSubs.setToolTipText(
BaseMessages.getString(PKG,
"ActionWaitForSQL.UseVariableSubst.Tooltip"));
FormData fdUseSubs = new FormData();
- fdUseSubs.left = new FormAttachment(middle, -margin);
+ fdUseSubs.left = new FormAttachment(middle, 0);
fdUseSubs.top = new FormAttachment(wlUseSubs, 0, SWT.CENTER);
fdUseSubs.right = new FormAttachment(100, 0);
wUseSubs.setLayoutData(fdUseSubs);
@@ -407,7 +418,7 @@ public class ActionWaitForSqlDialog extends ActionDialog {
wClearResultList.setToolTipText(
BaseMessages.getString(PKG,
"ActionWaitForSQL.ClearResultList.Tooltip"));
FormData fdClearResultList = new FormData();
- fdClearResultList.left = new FormAttachment(middle, -margin);
+ fdClearResultList.left = new FormAttachment(middle, 0);
fdClearResultList.top = new FormAttachment(wlClearResultList, 0,
SWT.CENTER);
fdClearResultList.right = new FormAttachment(100, 0);
wClearResultList.setLayoutData(fdClearResultList);
@@ -434,7 +445,7 @@ public class ActionWaitForSqlDialog extends ActionDialog {
wAddRowsToResult.setToolTipText(
BaseMessages.getString(PKG,
"ActionWaitForSQL.AddRowsToResult.Tooltip"));
FormData fdAddRowsToResult = new FormData();
- fdAddRowsToResult.left = new FormAttachment(middle, -margin);
+ fdAddRowsToResult.left = new FormAttachment(middle, 0);
fdAddRowsToResult.top = new FormAttachment(wlAddRowsToResult, 0,
SWT.CENTER);
fdAddRowsToResult.right = new FormAttachment(100, 0);
wAddRowsToResult.setLayoutData(fdAddRowsToResult);
@@ -673,18 +684,18 @@ public class ActionWaitForSqlDialog extends ActionDialog {
wbSqlTable.setEnabled(wCustomSql.getSelection());
wUseSubs.setEnabled(wCustomSql.getSelection());
wbTable.setEnabled(!wCustomSql.getSelection());
- wTablename.setEnabled(!wCustomSql.getSelection());
- wlTablename.setEnabled(!wCustomSql.getSelection());
- wlSchemaname.setEnabled(!wCustomSql.getSelection());
- wSchemaname.setEnabled(!wCustomSql.getSelection());
+ wTableName.setEnabled(!wCustomSql.getSelection());
+ wlTableName.setEnabled(!wCustomSql.getSelection());
+ wlSchemaName.setEnabled(!wCustomSql.getSelection());
+ wSchemaName.setEnabled(!wCustomSql.getSelection());
}
/** Copy information from the meta-data input to the dialog fields. */
public void getData() {
wName.setText(Const.nullToEmpty(action.getName()));
wConnection.setText(Const.nullToEmpty(action.getConnection()));
- wSchemaname.setText(Const.nullToEmpty(action.getSchemaName()));
- wTablename.setText(Const.nullToEmpty(action.getTableName()));
+ wSchemaName.setText(Const.nullToEmpty(action.getSchemaName()));
+ wTableName.setText(Const.nullToEmpty(action.getTableName()));
wSuccessCondition.setText(action.getSuccessCondition().getDescription());
wRowsCountValue.setText(Const.NVL(action.getRowsCountValue(), "0"));
wCustomSql.setSelection(action.isCustomSqlEnabled());
@@ -718,8 +729,8 @@ public class ActionWaitForSqlDialog extends ActionDialog {
}
action.setName(wName.getText());
action.setConnection(wConnection.getText());
- action.setSchemaName(wSchemaname.getText());
- action.setTableName(wTablename.getText());
+ action.setSchemaName(wSchemaName.getText());
+ action.setTableName(wTableName.getText());
action.setSuccessCondition(SuccessCondition.lookupDescription(wSuccessCondition.getText()));
action.setRowsCountValue(wRowsCountValue.getText());
action.setCustomSqlEnabled(wCustomSql.getSelection());
@@ -734,15 +745,53 @@ public class ActionWaitForSqlDialog extends ActionDialog {
dispose();
}
+ private void getSchemaName() {
+ if (wSchemaName.isDisposed()) {
+ return;
+ }
+ DatabaseMeta databaseMeta =
getWorkflowMeta().findDatabase(wConnection.getText(), variables);
+ if (databaseMeta != null) {
+ try (Database database = new Database(loggingObject, variables,
databaseMeta)) {
+ database.connect();
+ String[] schemas = database.getSchemas();
+ if (null != schemas && schemas.length > 0) {
+ EnterSelectionDialog dialog =
+ new EnterSelectionDialog(
+ shell,
+ schemas,
+ BaseMessages.getString(
+ PKG, "System.Dialog.AvailableSchemas.Title",
wConnection.getText()),
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Message"));
+ String name = dialog.open();
+ if (name != null) {
+ wSchemaName.setText(name);
+ }
+ } else {
+ MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
+ mb.setMessage(
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Empty.Message"));
+ mb.setText(BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Empty.Title"));
+ mb.open();
+ }
+ } catch (Exception e) {
+ new ErrorDialog(
+ shell,
+ BaseMessages.getString(PKG, "System.Dialog.Error.Title"),
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.ConnectionError"),
+ e);
+ }
+ }
+ }
+
private void getTableName() {
DatabaseMeta databaseMeta =
workflowMeta.findDatabase(wConnection.getText(), variables);
if (databaseMeta != null) {
DatabaseExplorerDialog std =
new DatabaseExplorerDialog(
shell, SWT.NONE, variables, databaseMeta,
getWorkflowMeta().getDatabases());
- std.setSelectedSchemaAndTable(wSchemaname.getText(),
wTablename.getText());
+ std.setSelectedSchemaAndTable(wSchemaName.getText(),
wTableName.getText());
if (std.open()) {
- wTablename.setText(Const.NVL(std.getTableName(), ""));
+ wTableName.setText(Const.NVL(std.getTableName(), ""));
}
}
}
diff --git
a/plugins/databases/mysql/src/main/java/org/apache/hop/pipeline/transforms/mysqlbulkloader/MySqlBulkLoaderDialog.java
b/plugins/databases/mysql/src/main/java/org/apache/hop/pipeline/transforms/mysqlbulkloader/MySqlBulkLoaderDialog.java
index f289e639a7..b72ce82224 100644
---
a/plugins/databases/mysql/src/main/java/org/apache/hop/pipeline/transforms/mysqlbulkloader/MySqlBulkLoaderDialog.java
+++
b/plugins/databases/mysql/src/main/java/org/apache/hop/pipeline/transforms/mysqlbulkloader/MySqlBulkLoaderDialog.java
@@ -43,6 +43,7 @@ import
org.apache.hop.ui.core.database.dialog.DatabaseExplorerDialog;
import org.apache.hop.ui.core.database.dialog.SqlEditor;
import org.apache.hop.ui.core.dialog.BaseDialog;
import org.apache.hop.ui.core.dialog.EnterMappingDialog;
+import org.apache.hop.ui.core.dialog.EnterSelectionDialog;
import org.apache.hop.ui.core.dialog.ErrorDialog;
import org.apache.hop.ui.core.dialog.MessageBox;
import org.apache.hop.ui.core.dialog.ShowMessageDialog;
@@ -176,6 +177,15 @@ public class MySqlBulkLoaderDialog extends
BaseTransformDialog {
fdlSchema.top = new FormAttachment(0, margin);
wlSchema.setLayoutData(fdlSchema);
+ Button wbSchema = new Button(wGeneralComp, SWT.PUSH | SWT.CENTER);
+ PropsUi.setLook(wbSchema);
+ wbSchema.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
+ FormData fdbSchema = new FormData();
+ fdbSchema.top = new FormAttachment(wlSchema, 0, SWT.CENTER);
+ fdbSchema.right = new FormAttachment(100, 0);
+ wbSchema.setLayoutData(fdbSchema);
+ wbSchema.addListener(SWT.Selection, e -> getSchemaName());
+
wSchema = new TextVar(variables, wGeneralComp, SWT.SINGLE | SWT.LEFT |
SWT.BORDER);
PropsUi.setLook(wSchema);
wSchema.addModifyListener(lsMod);
@@ -183,7 +193,7 @@ public class MySqlBulkLoaderDialog extends
BaseTransformDialog {
FormData fdSchema = new FormData();
fdSchema.left = new FormAttachment(middle, 0);
fdSchema.top = new FormAttachment(wlSchema, 0, SWT.CENTER);
- fdSchema.right = new FormAttachment(100, 0);
+ fdSchema.right = new FormAttachment(wbSchema, -margin);
wSchema.setLayoutData(fdSchema);
// Table line...
@@ -848,6 +858,41 @@ public class MySqlBulkLoaderDialog extends
BaseTransformDialog {
dispose();
}
+ private void getSchemaName() {
+ DatabaseMeta databaseMeta =
pipelineMeta.findDatabase(wConnection.getText(), variables);
+ if (databaseMeta != null) {
+ try (Database database = new Database(loggingObject, variables,
databaseMeta)) {
+ database.connect();
+ String[] schemas = database.getSchemas();
+ if (null != schemas && schemas.length > 0) {
+ EnterSelectionDialog dialog =
+ new EnterSelectionDialog(
+ shell,
+ schemas,
+ BaseMessages.getString(
+ PKG, "System.Dialog.AvailableSchemas.Title",
wConnection.getText()),
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Message"));
+ String name = dialog.open();
+ if (name != null) {
+ wSchema.setText(name);
+ }
+ } else {
+ MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
+ mb.setMessage(
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Empty.Message"));
+ mb.setText(BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Empty.Title"));
+ mb.open();
+ }
+ } catch (Exception e) {
+ new ErrorDialog(
+ shell,
+ BaseMessages.getString(PKG, "System.Dialog.Error.Title"),
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.ConnectionError"),
+ e);
+ }
+ }
+ }
+
private void getTableName() {
DatabaseMeta databaseMeta = null;
diff --git
a/plugins/databases/postgresql/src/main/java/org/apache/hop/pipeline/transforms/pgbulkloader/PGBulkLoaderDialog.java
b/plugins/databases/postgresql/src/main/java/org/apache/hop/pipeline/transforms/pgbulkloader/PGBulkLoaderDialog.java
index 6c30e4f471..561deae916 100644
---
a/plugins/databases/postgresql/src/main/java/org/apache/hop/pipeline/transforms/pgbulkloader/PGBulkLoaderDialog.java
+++
b/plugins/databases/postgresql/src/main/java/org/apache/hop/pipeline/transforms/pgbulkloader/PGBulkLoaderDialog.java
@@ -41,6 +41,7 @@ import
org.apache.hop.ui.core.database.dialog.DatabaseExplorerDialog;
import org.apache.hop.ui.core.database.dialog.SqlEditor;
import org.apache.hop.ui.core.dialog.BaseDialog;
import org.apache.hop.ui.core.dialog.EnterMappingDialog;
+import org.apache.hop.ui.core.dialog.EnterSelectionDialog;
import org.apache.hop.ui.core.dialog.ErrorDialog;
import org.apache.hop.ui.core.dialog.MessageBox;
import org.apache.hop.ui.core.widget.ColumnInfo;
@@ -149,6 +150,15 @@ public class PGBulkLoaderDialog extends
BaseTransformDialog {
fdlSchema.top = new FormAttachment(wConnection, margin);
wlSchema.setLayoutData(fdlSchema);
+ Button wbSchema = new Button(shell, SWT.PUSH | SWT.CENTER);
+ PropsUi.setLook(wbSchema);
+ wbSchema.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
+ FormData fdbSchema = new FormData();
+ fdbSchema.top = new FormAttachment(wConnection, margin);
+ fdbSchema.right = new FormAttachment(100, 0);
+ wbSchema.setLayoutData(fdbSchema);
+ wbSchema.addListener(SWT.Selection, e -> getSchemaName());
+
wSchema = new TextVar(variables, shell, SWT.SINGLE | SWT.LEFT |
SWT.BORDER);
PropsUi.setLook(wSchema);
wSchema.addModifyListener(lsMod);
@@ -156,7 +166,7 @@ public class PGBulkLoaderDialog extends BaseTransformDialog
{
FormData fdSchema = new FormData();
fdSchema.left = new FormAttachment(middle, 0);
fdSchema.top = new FormAttachment(wConnection, margin);
- fdSchema.right = new FormAttachment(100, 0);
+ fdSchema.right = new FormAttachment(wbSchema, -margin);
wSchema.setLayoutData(fdSchema);
// Table line...
@@ -706,6 +716,41 @@ public class PGBulkLoaderDialog extends
BaseTransformDialog {
dispose();
}
+ private void getSchemaName() {
+ DatabaseMeta databaseMeta =
pipelineMeta.findDatabase(wConnection.getText(), variables);
+ if (databaseMeta != null) {
+ try (Database database = new Database(loggingObject, variables,
databaseMeta)) {
+ database.connect();
+ String[] schemas = database.getSchemas();
+ if (null != schemas && schemas.length > 0) {
+ EnterSelectionDialog dialog =
+ new EnterSelectionDialog(
+ shell,
+ schemas,
+ BaseMessages.getString(
+ PKG, "System.Dialog.AvailableSchemas.Title",
wConnection.getText()),
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Message"));
+ String name = dialog.open();
+ if (name != null) {
+ wSchema.setText(name);
+ }
+ } else {
+ MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
+ mb.setMessage(
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Empty.Message"));
+ mb.setText(BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Empty.Title"));
+ mb.open();
+ }
+ } catch (Exception e) {
+ new ErrorDialog(
+ shell,
+ BaseMessages.getString(PKG, "System.Dialog.Error.Title"),
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.ConnectionError"),
+ e);
+ }
+ }
+ }
+
private void getTableName() {
String connectionName = wConnection.getText();
if (StringUtils.isEmpty(connectionName)) {
diff --git
a/plugins/databases/vertica/src/main/java/org/apache/hop/pipeline/transforms/vertica/bulkloader/VerticaBulkLoaderDialog.java
b/plugins/databases/vertica/src/main/java/org/apache/hop/pipeline/transforms/vertica/bulkloader/VerticaBulkLoaderDialog.java
index a5394af1f4..887fe6e7a0 100644
---
a/plugins/databases/vertica/src/main/java/org/apache/hop/pipeline/transforms/vertica/bulkloader/VerticaBulkLoaderDialog.java
+++
b/plugins/databases/vertica/src/main/java/org/apache/hop/pipeline/transforms/vertica/bulkloader/VerticaBulkLoaderDialog.java
@@ -47,6 +47,7 @@ import
org.apache.hop.ui.core.database.dialog.DatabaseExplorerDialog;
import org.apache.hop.ui.core.database.dialog.SqlEditor;
import org.apache.hop.ui.core.dialog.BaseDialog;
import org.apache.hop.ui.core.dialog.EnterMappingDialog;
+import org.apache.hop.ui.core.dialog.EnterSelectionDialog;
import org.apache.hop.ui.core.dialog.ErrorDialog;
import org.apache.hop.ui.core.widget.ColumnInfo;
import org.apache.hop.ui.core.widget.MetaSelectionLine;
@@ -191,6 +192,15 @@ public class VerticaBulkLoaderDialog extends
BaseTransformDialog {
fdlSchema.top = new FormAttachment(wConnection, margin);
wlSchema.setLayoutData(fdlSchema);
+ Button wbSchema = new Button(shell, SWT.PUSH | SWT.CENTER);
+ PropsUi.setLook(wbSchema);
+ wbSchema.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
+ FormData fdbSchema = new FormData();
+ fdbSchema.top = new FormAttachment(wConnection, margin);
+ fdbSchema.right = new FormAttachment(100, 0);
+ wbSchema.setLayoutData(fdbSchema);
+ wbSchema.addListener(SWT.Selection, e -> getSchemaName());
+
wSchema = new TextVar(variables, shell, SWT.SINGLE | SWT.LEFT |
SWT.BORDER);
PropsUi.setLook(wSchema);
wSchema.addModifyListener(lsMod);
@@ -198,7 +208,7 @@ public class VerticaBulkLoaderDialog extends
BaseTransformDialog {
fdSchema = new FormData();
fdSchema.left = new FormAttachment(middle, 0);
fdSchema.top = new FormAttachment(wConnection, margin);
- fdSchema.right = new FormAttachment(100, 0);
+ fdSchema.right = new FormAttachment(wbSchema, -margin);
wSchema.setLayoutData(fdSchema);
// Table line...
@@ -920,6 +930,42 @@ public class VerticaBulkLoaderDialog extends
BaseTransformDialog {
dispose();
}
+ private void getSchemaName() {
+ DatabaseMeta databaseMeta =
pipelineMeta.findDatabase(wConnection.getText(), variables);
+ if (databaseMeta != null) {
+ try (Database database = new Database(loggingObject, variables,
databaseMeta)) {
+ database.connect();
+ String[] schemas = database.getSchemas();
+ if (null != schemas && schemas.length > 0) {
+ EnterSelectionDialog dialog =
+ new EnterSelectionDialog(
+ shell,
+ schemas,
+ BaseMessages.getString(
+ PKG, "System.Dialog.AvailableSchemas.Title",
wConnection.getText()),
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Message"));
+ String name = dialog.open();
+ if (name != null) {
+ wSchema.setText(name);
+ }
+ } else {
+ org.apache.hop.ui.core.dialog.MessageBox mb =
+ new org.apache.hop.ui.core.dialog.MessageBox(shell, SWT.OK |
SWT.ICON_ERROR);
+ mb.setMessage(
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Empty.Message"));
+ mb.setText(BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Empty.Title"));
+ mb.open();
+ }
+ } catch (Exception e) {
+ new ErrorDialog(
+ shell,
+ BaseMessages.getString(PKG, "System.Dialog.Error.Title"),
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.ConnectionError"),
+ e);
+ }
+ }
+ }
+
private void getTableName() {
String connectionName = wConnection.getText();
diff --git
a/plugins/transforms/databaselookup/src/main/java/org/apache/hop/pipeline/transforms/databaselookup/DatabaseLookupDialog.java
b/plugins/transforms/databaselookup/src/main/java/org/apache/hop/pipeline/transforms/databaselookup/DatabaseLookupDialog.java
index 430c9e47f9..bfe89319d5 100644
---
a/plugins/transforms/databaselookup/src/main/java/org/apache/hop/pipeline/transforms/databaselookup/DatabaseLookupDialog.java
+++
b/plugins/transforms/databaselookup/src/main/java/org/apache/hop/pipeline/transforms/databaselookup/DatabaseLookupDialog.java
@@ -867,15 +867,14 @@ public class DatabaseLookupDialog extends
BaseTransformDialog {
String[] schemas = database.getSchemas();
if (null != schemas && schemas.length > 0) {
- schemas = Const.sortStrings(schemas);
EnterSelectionDialog dialog =
new EnterSelectionDialog(
shell,
schemas,
BaseMessages.getString(
- PKG, "DatabaseLookupDialog.AvailableSchemas.Title",
wConnection.getText()),
+ PKG, "System.Dialog.AvailableSchemas.Title",
wConnection.getText()),
BaseMessages.getString(
- PKG, "DatabaseLookupDialog.AvailableSchemas.Message",
wConnection.getText()));
+ PKG, "System.Dialog.AvailableSchemas.Message",
wConnection.getText()));
String d = dialog.open();
if (d != null) {
wSchema.setText(Const.NVL(d, ""));
@@ -884,15 +883,16 @@ public class DatabaseLookupDialog extends
BaseTransformDialog {
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
- mb.setMessage(BaseMessages.getString(PKG,
"DatabaseLookupDialog.NoSchema.Error"));
- mb.setText(BaseMessages.getString(PKG,
"DatabaseLookupDialog.GetSchemas.Error"));
+ mb.setMessage(
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Empty.Message"));
+ mb.setText(BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Empty.Title"));
mb.open();
}
} catch (Exception e) {
new ErrorDialog(
shell,
BaseMessages.getString(PKG, "System.Dialog.Error.Title"),
- BaseMessages.getString(PKG,
"DatabaseLookupDialog.ErrorGettingSchemas"),
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.ConnectionError"),
e);
}
}
diff --git
a/plugins/transforms/delete/src/main/java/org/apache/hop/pipeline/transforms/delete/DeleteDialog.java
b/plugins/transforms/delete/src/main/java/org/apache/hop/pipeline/transforms/delete/DeleteDialog.java
index 694487cae0..a0567ec056 100644
---
a/plugins/transforms/delete/src/main/java/org/apache/hop/pipeline/transforms/delete/DeleteDialog.java
+++
b/plugins/transforms/delete/src/main/java/org/apache/hop/pipeline/transforms/delete/DeleteDialog.java
@@ -540,7 +540,6 @@ public class DeleteDialog extends BaseTransformDialog {
String[] schemas = database.getSchemas();
if (null != schemas && schemas.length > 0) {
- schemas = Const.sortStrings(schemas);
EnterSelectionDialog dialog =
new EnterSelectionDialog(
shell,
diff --git
a/plugins/transforms/dimensionlookup/src/main/java/org/apache/hop/pipeline/transforms/dimensionlookup/DimensionLookupDialog.java
b/plugins/transforms/dimensionlookup/src/main/java/org/apache/hop/pipeline/transforms/dimensionlookup/DimensionLookupDialog.java
index 8292e6cfd3..851484774e 100644
---
a/plugins/transforms/dimensionlookup/src/main/java/org/apache/hop/pipeline/transforms/dimensionlookup/DimensionLookupDialog.java
+++
b/plugins/transforms/dimensionlookup/src/main/java/org/apache/hop/pipeline/transforms/dimensionlookup/DimensionLookupDialog.java
@@ -1802,7 +1802,7 @@ public class DimensionLookupDialog extends
BaseTransformDialog {
if (databaseMeta != null) {
try (Database database = new Database(loggingObject, variables,
databaseMeta)) {
database.connect();
- String[] schemas = Const.sortStrings(database.getSchemas());
+ String[] schemas = database.getSchemas();
if (schemas != null && schemas.length > 0) {
EnterSelectionDialog dialog =
diff --git
a/plugins/transforms/gettablenames/src/main/java/org/apache/hop/pipeline/transforms/gettablenames/GetTableNamesDialog.java
b/plugins/transforms/gettablenames/src/main/java/org/apache/hop/pipeline/transforms/gettablenames/GetTableNamesDialog.java
index e0905b7aad..2a192b5d23 100644
---
a/plugins/transforms/gettablenames/src/main/java/org/apache/hop/pipeline/transforms/gettablenames/GetTableNamesDialog.java
+++
b/plugins/transforms/gettablenames/src/main/java/org/apache/hop/pipeline/transforms/gettablenames/GetTableNamesDialog.java
@@ -17,6 +17,7 @@
package org.apache.hop.pipeline.transforms.gettablenames;
+import org.apache.hop.core.database.Database;
import org.apache.hop.core.database.DatabaseMeta;
import org.apache.hop.core.exception.HopException;
import org.apache.hop.core.row.IRowMeta;
@@ -29,6 +30,7 @@ import org.apache.hop.pipeline.PipelinePreviewFactory;
import org.apache.hop.ui.core.PropsUi;
import org.apache.hop.ui.core.database.dialog.PreviewTableSettingsDialog;
import org.apache.hop.ui.core.dialog.BaseDialog;
+import org.apache.hop.ui.core.dialog.EnterSelectionDialog;
import org.apache.hop.ui.core.dialog.EnterTextDialog;
import org.apache.hop.ui.core.dialog.ErrorDialog;
import org.apache.hop.ui.core.dialog.MessageBox;
@@ -60,9 +62,7 @@ public class GetTableNamesDialog extends BaseTransformDialog {
private Text wTableNameField;
private Text wSqlCreationField;
private Button wIncludeTable;
-
private Button wIncludeSchema;
-
private Button wIncludeCatalog;
private Label wlIncludeCatalog;
@@ -79,6 +79,7 @@ public class GetTableNamesDialog extends BaseTransformDialog {
private Text wIsSystemObjectField;
private Label wlSchemaName;
+ private Button wbSchemaName;
private TextVar wSchemaName;
private Button wDynamicSchema;
@@ -120,6 +121,16 @@ public class GetTableNamesDialog extends
BaseTransformDialog {
fdlschemaname.right = new FormAttachment(middle, -margin);
fdlschemaname.top = new FormAttachment(wConnection, margin);
wlSchemaName.setLayoutData(fdlschemaname);
+
+ wbSchemaName = new Button(shell, SWT.PUSH | SWT.CENTER);
+ PropsUi.setLook(wbSchemaName);
+ wbSchemaName.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
+ FormData fdbSchemaName = new FormData();
+ fdbSchemaName.top = new FormAttachment(wConnection, margin);
+ fdbSchemaName.right = new FormAttachment(100, 0);
+ wbSchemaName.setLayoutData(fdbSchemaName);
+ wbSchemaName.addListener(SWT.Selection, e -> getSchemaNames());
+
wSchemaName = new TextVar(variables, shell, SWT.SINGLE | SWT.LEFT |
SWT.BORDER);
wSchemaName.setToolTipText(
BaseMessages.getString(PKG,
"GetTableNamesDialog.SchemaNameName.Tooltip"));
@@ -127,7 +138,7 @@ public class GetTableNamesDialog extends
BaseTransformDialog {
FormData fdschemaname = new FormData();
fdschemaname.left = new FormAttachment(middle, 0);
fdschemaname.top = new FormAttachment(wConnection, margin);
- fdschemaname.right = new FormAttachment(100, 0);
+ fdschemaname.right = new FormAttachment(wbSchemaName, -margin);
wSchemaName.setLayoutData(fdschemaname);
ModifyListener lsModSchema = e -> refreshIncludeCatalog();
wSchemaName.addModifyListener(lsModSchema);
@@ -507,6 +518,7 @@ public class GetTableNamesDialog extends
BaseTransformDialog {
wSchemaField.setEnabled(wDynamicSchema.getSelection());
wPreview.setEnabled(!wDynamicSchema.getSelection());
wlSchemaName.setEnabled(!wDynamicSchema.getSelection());
+ wbSchemaName.setEnabled(!wDynamicSchema.getSelection());
wSchemaName.setEnabled(!wDynamicSchema.getSelection());
if (wDynamicSchema.getSelection()) {
wIncludeCatalog.setSelection(false);
@@ -621,6 +633,44 @@ public class GetTableNamesDialog extends
BaseTransformDialog {
info.setSchemaNameField(wSchemaField.getText());
}
+ private void getSchemaNames() {
+ if (wSchemaName.isDisposed()) {
+ return;
+ }
+ DatabaseMeta databaseMeta =
pipelineMeta.findDatabase(wConnection.getText(), variables);
+ if (databaseMeta != null) {
+ try (Database database = new Database(loggingObject, variables,
databaseMeta)) {
+ database.connect();
+ String[] schemas = database.getSchemas();
+ if (null != schemas && schemas.length > 0) {
+ EnterSelectionDialog dialog =
+ new EnterSelectionDialog(
+ shell,
+ schemas,
+ BaseMessages.getString(
+ PKG, "System.Dialog.AvailableSchemas.Title",
wConnection.getText()),
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Message"));
+ String name = dialog.open();
+ if (name != null) {
+ wSchemaName.setText(name);
+ }
+ } else {
+ MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
+ mb.setMessage(
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Empty.Message"));
+ mb.setText(BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Empty.Title"));
+ mb.open();
+ }
+ } catch (Exception e) {
+ new ErrorDialog(
+ shell,
+ BaseMessages.getString(PKG, "System.Dialog.Error.Title"),
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.ConnectionError"),
+ e);
+ }
+ }
+ }
+
private boolean checkUserInput(GetTableNamesMeta meta) {
if (Utils.isEmpty(meta.getConnection())) {
diff --git
a/plugins/transforms/insertupdate/src/main/java/org/apache/hop/pipeline/transforms/insertupdate/InsertUpdateDialog.java
b/plugins/transforms/insertupdate/src/main/java/org/apache/hop/pipeline/transforms/insertupdate/InsertUpdateDialog.java
index 321a75df95..99d54e82f7 100644
---
a/plugins/transforms/insertupdate/src/main/java/org/apache/hop/pipeline/transforms/insertupdate/InsertUpdateDialog.java
+++
b/plugins/transforms/insertupdate/src/main/java/org/apache/hop/pipeline/transforms/insertupdate/InsertUpdateDialog.java
@@ -763,7 +763,6 @@ public class InsertUpdateDialog extends BaseTransformDialog
{
String[] schemas = database.getSchemas();
if (null != schemas && schemas.length > 0) {
- schemas = Const.sortStrings(schemas);
EnterSelectionDialog dialog =
new EnterSelectionDialog(
shell,
diff --git
a/plugins/transforms/sqlfileoutput/src/main/java/org/apache/hop/pipeline/transforms/sqlfileoutput/SQLFileOutputDialog.java
b/plugins/transforms/sqlfileoutput/src/main/java/org/apache/hop/pipeline/transforms/sqlfileoutput/SQLFileOutputDialog.java
index e608ebb519..4cdd62b867 100644
---
a/plugins/transforms/sqlfileoutput/src/main/java/org/apache/hop/pipeline/transforms/sqlfileoutput/SQLFileOutputDialog.java
+++
b/plugins/transforms/sqlfileoutput/src/main/java/org/apache/hop/pipeline/transforms/sqlfileoutput/SQLFileOutputDialog.java
@@ -22,6 +22,7 @@ import org.apache.hop.core.Const;
import org.apache.hop.core.DbCache;
import org.apache.hop.core.Props;
import org.apache.hop.core.SqlStatement;
+import org.apache.hop.core.database.Database;
import org.apache.hop.core.database.DatabaseMeta;
import org.apache.hop.core.exception.HopException;
import org.apache.hop.core.row.IRowMeta;
@@ -170,6 +171,15 @@ public class SQLFileOutputDialog extends
BaseTransformDialog {
fdlSchema.top = new FormAttachment(wConnection, margin);
wlSchema.setLayoutData(fdlSchema);
+ Button wbSchema = new Button(wGConnection, SWT.PUSH | SWT.CENTER);
+ PropsUi.setLook(wbSchema);
+ wbSchema.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
+ FormData fdbSchema = new FormData();
+ fdbSchema.top = new FormAttachment(wConnection, margin);
+ fdbSchema.right = new FormAttachment(100, 0);
+ wbSchema.setLayoutData(fdbSchema);
+ wbSchema.addListener(SWT.Selection, e -> getSchemaName());
+
wSchema = new TextVar(variables, wGConnection, SWT.SINGLE | SWT.LEFT |
SWT.BORDER);
PropsUi.setLook(wSchema);
wSchema.addModifyListener(lsMod);
@@ -177,7 +187,7 @@ public class SQLFileOutputDialog extends
BaseTransformDialog {
FormData fdSchema = new FormData();
fdSchema.left = new FormAttachment(middle, 0);
fdSchema.top = new FormAttachment(wConnection, margin);
- fdSchema.right = new FormAttachment(100, 0);
+ fdSchema.right = new FormAttachment(wbSchema, -margin);
wSchema.setLayoutData(fdSchema);
// Table line...
@@ -846,6 +856,41 @@ public class SQLFileOutputDialog extends
BaseTransformDialog {
dispose();
}
+ private void getSchemaName() {
+ DatabaseMeta databaseMeta =
pipelineMeta.findDatabase(wConnection.getText(), variables);
+ if (databaseMeta != null) {
+ try (Database database = new Database(loggingObject, variables,
databaseMeta)) {
+ database.connect();
+ String[] schemas = database.getSchemas();
+ if (null != schemas && schemas.length > 0) {
+ EnterSelectionDialog dialog =
+ new EnterSelectionDialog(
+ shell,
+ schemas,
+ BaseMessages.getString(
+ PKG, "System.Dialog.AvailableSchemas.Title",
wConnection.getText()),
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Message"));
+ String name = dialog.open();
+ if (name != null) {
+ wSchema.setText(name);
+ }
+ } else {
+ MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
+ mb.setMessage(
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Empty.Message"));
+ mb.setText(BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.Empty.Title"));
+ mb.open();
+ }
+ } catch (Exception e) {
+ new ErrorDialog(
+ shell,
+ BaseMessages.getString(PKG, "System.Dialog.Error.Title"),
+ BaseMessages.getString(PKG,
"System.Dialog.AvailableSchemas.ConnectionError"),
+ e);
+ }
+ }
+ }
+
private void getTableName() {
String connectionName = wConnection.getText();
if (StringUtils.isEmpty(connectionName)) {