This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hop.git
The following commit(s) were added to refs/heads/master by this push:
new b8c4e2e HOP-3458 "Widget is disposed" error in table input transform
new 6dfa1fb Merge pull request #1182 from nadment/HOP-3458
b8c4e2e is described below
commit b8c4e2eb1a9ba778db85ccaf7fa9415b0a1b12b8
Author: Nicolas Adment <[email protected]>
AuthorDate: Fri Oct 29 20:50:15 2021 +0200
HOP-3458 "Widget is disposed" error in table input transform
- Make ProgressMonitorDialog modal
- DatabaseMetaInformation use ProgressNullMonitorListener if monitor is
null
- DatabaseMetaInformation open method return null if canceled
- DatabaseMetaInformation check monitor is canceled when loading schema
(cancel fast)
- Pass variables to findDatabase method
- Remove messages that exist in the subfolder
---
.../hop/core/database/DatabaseMetaInformation.java | 135 ++++++++-------------
.../transforms/tableinput/TableInputDialog.java | 2 +-
.../dialog/GetDatabaseInfoProgressDialog.java | 3 +-
.../hop/ui/core/dialog/ProgressMonitorDialog.java | 11 +-
.../core/dialog/messages/messages_en_US.properties | 2 -
.../core/dialog/messages/messages_ja_JP.properties | 2 -
6 files changed, 62 insertions(+), 93 deletions(-)
diff --git
a/core/src/main/java/org/apache/hop/core/database/DatabaseMetaInformation.java
b/core/src/main/java/org/apache/hop/core/database/DatabaseMetaInformation.java
index 079b6b8..3437571 100644
---
a/core/src/main/java/org/apache/hop/core/database/DatabaseMetaInformation.java
+++
b/core/src/main/java/org/apache/hop/core/database/DatabaseMetaInformation.java
@@ -18,6 +18,7 @@
package org.apache.hop.core.database;
import org.apache.hop.core.IProgressMonitor;
+import org.apache.hop.core.ProgressNullMonitorListener;
import org.apache.hop.core.exception.HopDatabaseException;
import org.apache.hop.core.logging.ILoggingObject;
import org.apache.hop.core.util.Utils;
@@ -34,9 +35,6 @@ import java.util.Map;
/**
* Contains the schema's, catalogs, tables, views, synonyms, etc we can find
in the databases...
- *
- * @author Matt
- * @since 7-apr-2005
*/
public class DatabaseMetaInformation {
private static final Class<?> PKG = Database.class; // For Translator
@@ -65,46 +63,32 @@ public class DatabaseMetaInformation {
public void getData(ILoggingObject parentLoggingObject, IProgressMonitor
monitor)
throws HopDatabaseException {
- if (monitor != null) {
- monitor.beginTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.GettingInfoFromDb"), 8);
+ if (monitor == null) {
+ monitor = new ProgressNullMonitorListener();
}
+ monitor.beginTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.GettingInfoFromDb"), 8);
Database db = new Database(parentLoggingObject, variables, databaseMeta);
- /*
- * ResultSet tableResultSet = null;
- *
- * ResultSet schemaTablesResultSet = null; ResultSet schemaResultSet =
null;
- *
- * ResultSet catalogResultSet = null; ResultSet catalogTablesResultSet =
null;
- */
-
try {
- if (monitor != null) {
- monitor.subTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.ConnectingDb"));
- }
+ monitor.subTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.ConnectingDb"));
db.connect();
- if (monitor != null) {
- monitor.worked(1);
- }
+ monitor.worked(1);
- if (monitor != null && monitor.isCanceled()) {
+ if (monitor.isCanceled()) {
return;
}
- if (monitor != null) {
- monitor.subTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.GettingMetaData"));
- }
+
+ monitor.subTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.GettingMetaData"));
DatabaseMetaData dbmd = db.getDatabaseMetaData();
- if (monitor != null) {
- monitor.worked(1);
- }
-
- if (monitor != null && monitor.isCanceled()) {
+ monitor.worked(1);
+ if (monitor.isCanceled()) {
return;
}
- if (monitor != null) {
- monitor.subTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.GettingInfo"));
- }
+
+ // Get catalogs
+ //
+ monitor.subTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.GettingInfo"));
Map<String, String> connectionExtraOptions =
databaseMeta.getExtraOptions();
if (databaseMeta.supportsCatalogs() &&
dbmd.supportsCatalogsInTableDefinitions()) {
ArrayList<Catalog> catalogList = new ArrayList<>();
@@ -169,16 +153,14 @@ public class DatabaseMetaInformation {
// Save for later...
setCatalogs(catalogList.toArray(new Catalog[catalogList.size()]));
}
- if (monitor != null) {
- monitor.worked(1);
- }
-
- if (monitor != null && monitor.isCanceled()) {
+ monitor.worked(1);
+ if (monitor.isCanceled()) {
return;
}
- if (monitor != null) {
- monitor.subTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.GettingSchemaInfo"));
- }
+
+ // Get schemas
+ //
+ monitor.subTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.GettingSchemaInfo"));
if (databaseMeta.supportsSchemas() &&
dbmd.supportsSchemasInTableDefinitions()) {
ArrayList<Schema> schemaList = new ArrayList<>();
try {
@@ -239,6 +221,10 @@ public class DatabaseMetaInformation {
}
schema.setItems(schemaTables.toArray(new
String[schemaTables.size()]));
+
+ if (monitor.isCanceled()) {
+ return;
+ }
}
} catch (Exception e) {
// Typically an unsupported feature, security issue etc.
@@ -248,75 +234,56 @@ public class DatabaseMetaInformation {
// Save for later...
setSchemas(schemaList.toArray(new Schema[schemaList.size()]));
}
- if (monitor != null) {
- monitor.worked(1);
- }
-
- if (monitor != null && monitor.isCanceled()) {
+ monitor.worked(1);
+ if (monitor.isCanceled()) {
return;
}
- if (monitor != null) {
- monitor.subTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.GettingTables"));
- }
+
+ // Get tables
+ //
+ monitor.subTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.GettingTables"));
setTables(db.getTablenames(databaseMeta.supportsSchemas())); // legacy
call
setTableMap(db.getTableMap());
- if (monitor != null) {
- monitor.worked(1);
- }
-
- if (monitor != null && monitor.isCanceled()) {
+ monitor.worked(1);
+ if (monitor.isCanceled()) {
return;
}
- if (monitor != null) {
- monitor.subTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.GettingViews"));
- }
+
+ // Get views
+ //
+ monitor.subTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.GettingViews"));
if (databaseMeta.supportsViews()) {
setViews(db.getViews(databaseMeta.supportsSchemas())); // legacy call
setViewMap(db.getViewMap());
}
- if (monitor != null) {
- monitor.worked(1);
- }
-
- if (monitor != null && monitor.isCanceled()) {
+ monitor.worked(1);
+ if (monitor.isCanceled()) {
return;
}
- if (monitor != null) {
- monitor.subTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.GettingSynonyms"));
- }
+
+ // Get synonyms
+ //
+ monitor.subTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.GettingSynonyms"));
if (databaseMeta.supportsSynonyms()) {
setSynonyms(db.getSynonyms(databaseMeta.supportsSchemas())); // legacy
call
setSynonymMap(db.getSynonymMap());
}
- if (monitor != null) {
- monitor.worked(1);
- }
-
- if (monitor != null && monitor.isCanceled()) {
+ monitor.worked(1);
+ if (monitor.isCanceled()) {
return;
}
- if (monitor != null) {
- monitor.subTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.GettingProcedures"));
- }
- setProcedures(db.getProcedures());
- if (monitor != null) {
- monitor.worked(1);
- }
+ // Get procedures
+ //
+ monitor.subTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.GettingProcedures"));
+ setProcedures(db.getProcedures());
+ monitor.worked(1);
} catch (Exception e) {
throw new HopDatabaseException(
BaseMessages.getString(PKG,
"DatabaseMeta.Error.UnableRetrieveDbInfo"), e);
} finally {
- if (monitor != null) {
- monitor.subTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.ClosingDbConnection"));
- }
-
+ monitor.subTask(BaseMessages.getString(PKG,
"DatabaseMeta.Info.ClosingDbConnection"));
db.disconnect();
- if (monitor != null) {
- monitor.worked(1);
- }
- }
- if (monitor != null) {
monitor.done();
}
}
diff --git
a/plugins/transforms/tableinput/src/main/java/org/apache/hop/pipeline/transforms/tableinput/TableInputDialog.java
b/plugins/transforms/tableinput/src/main/java/org/apache/hop/pipeline/transforms/tableinput/TableInputDialog.java
index 5af4c7b..4d97ef5 100644
---
a/plugins/transforms/tableinput/src/main/java/org/apache/hop/pipeline/transforms/tableinput/TableInputDialog.java
+++
b/plugins/transforms/tableinput/src/main/java/org/apache/hop/pipeline/transforms/tableinput/TableInputDialog.java
@@ -441,7 +441,7 @@ public class TableInputDialog extends BaseTransformDialog
implements ITransformD
}
private void getSql() {
- DatabaseMeta databaseMeta =
pipelineMeta.findDatabase(wConnection.getText());
+ DatabaseMeta databaseMeta =
pipelineMeta.findDatabase(wConnection.getText(), variables);
if (databaseMeta != null) {
DatabaseExplorerDialog std =
new DatabaseExplorerDialog(
diff --git
a/ui/src/main/java/org/apache/hop/ui/core/database/dialog/GetDatabaseInfoProgressDialog.java
b/ui/src/main/java/org/apache/hop/ui/core/database/dialog/GetDatabaseInfoProgressDialog.java
index 6f88f09..0b96cb7 100644
---
a/ui/src/main/java/org/apache/hop/ui/core/database/dialog/GetDatabaseInfoProgressDialog.java
+++
b/ui/src/main/java/org/apache/hop/ui/core/database/dialog/GetDatabaseInfoProgressDialog.java
@@ -72,8 +72,9 @@ public class GetDatabaseInfoProgressDialog {
try {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
-
pmd.run(true, op);
+
+ if ( pmd.getProgressMonitor().isCanceled() ) return null;
} catch (InvocationTargetException e) {
showErrorDialog(e);
return null;
diff --git
a/ui/src/main/java/org/apache/hop/ui/core/dialog/ProgressMonitorDialog.java
b/ui/src/main/java/org/apache/hop/ui/core/dialog/ProgressMonitorDialog.java
index 270d8ff..93baba2 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/dialog/ProgressMonitorDialog.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/dialog/ProgressMonitorDialog.java
@@ -34,6 +34,9 @@ import org.eclipse.swt.widgets.*;
import java.lang.reflect.InvocationTargetException;
+/**
+ * A modal dialog that displays progress during a long running operation.
+ */
public class ProgressMonitorDialog {
private static final Class<?> PKG = ProgressMonitorDialog.class; // For
Translator
@@ -56,9 +59,10 @@ public class ProgressMonitorDialog {
}
/**
- * Gets progressMonitor
+ * Returns the progress monitor to use for operations run in this progress
+ * dialog.
*
- * @return value of progressMonitor
+ * @return the progress monitor
*/
public IProgressMonitor getProgressMonitor() {
return progressMonitor;
@@ -69,8 +73,9 @@ public class ProgressMonitorDialog {
PropsUi props = PropsUi.getInstance();
- shell = new Shell(parent, SWT.RESIZE | (cancelable ? SWT.CLOSE :
SWT.NONE));
+ shell = new Shell(parent, SWT.RESIZE | SWT.APPLICATION_MODAL | (cancelable
? SWT.CLOSE : SWT.NONE));
shell.setText(BaseMessages.getString(PKG,
"ProgressMonitorDialog.Shell.Title"));
+ shell.setImage(GuiResource.getInstance().getImageHopUi());
props.setLook(shell);
display = shell.getDisplay();
diff --git
a/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_en_US.properties
b/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_en_US.properties
index e6a0d37..175f6c8 100644
---
a/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_en_US.properties
+++
b/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_en_US.properties
@@ -106,7 +106,6 @@ TransformFieldsDialog.Fields.Label=Fields\:
EnterSearchDialog.Transform.Tooltip=Search transforms
EnterOptionsDialog.ReplaceDB.Tooltip=Replace existing objects (database
connections, hop servers, cluster schemas, and/or partition schemas) when
opening or importing pipelines.
EnterOptionsDialog.DefaultPreviewSize.Label=Preview data batch size
-GetDatabaseInfoProgressDialog.Error.Message=An error occured getting
information from the database\!
TransformFieldsDialog.Name.Label=Transform name\:
TransformFieldsDialog.TableCol.Decimal=Decimal
EnterPrintDialog.LeftMargin.Label=Left margin (inch)\:
@@ -208,7 +207,6 @@ CheckResultDialog.WarningsErrors.Label=Warnings and errors\:
PreviewRowsDialog.ShowLogging.Message=The logging text
BaseDialog.SaveFile=Save file
TransformFieldsDialog.TableCol.StorageType=Storage
-GetDatabaseInfoProgressDialog.Error.Title=Error getting information
SQLStatementDialog.Log.Transform=-- Transform \: {0}\n
EnterValueDialog.TestResult.Title=Value
EnterOptionsDialog.ConfigFilename.Label=Hop configuration filename
diff --git
a/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_ja_JP.properties
b/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_ja_JP.properties
index 17d8449..70e2754 100644
---
a/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_ja_JP.properties
+++
b/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_ja_JP.properties
@@ -267,8 +267,6 @@ EnterValueDialog.Type.Label=\u30bf\u30a4\u30d7\:
EnterValueDialog.Value.Label=\u5024\:
ErrorDialog.ShowDetails.Message=\u30a8\u30e9\u30fc\u8a73\u7d30\u3068\u4f8b\u5916\u306e\u30b9\u30bf\u30c3\u30af\u30c8\u30ec\u30fc\u30b9
ErrorDialog.ShowDetails.Title=\u30a8\u30e9\u30fc\u8a73\u7d30
-GetDatabaseInfoProgressDialog.Error.Message=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u60c5\u5831\u53d6\u5f97\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002
-GetDatabaseInfoProgressDialog.Error.Title=\u60c5\u5831\u53d6\u5f97\u30a8\u30e9\u30fc
GetPreviewTableProgressDialog.Error.Message=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u60c5\u5831\u53d6\u5f97\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002
GetPreviewTableProgressDialog.Error.Title=\u60c5\u5831\u53d6\u5f97\u30a8\u30e9\u30fc
GetQueryFieldsProgressDialog.Error.Message=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u60c5\u5831\u53d6\u5f97\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002