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/hop.git
The following commit(s) were added to refs/heads/master by this push:
new 6d5acf93c3 prevent creating unnamed parameters. fixes #3240
new a0e5405d45 Merge pull request #3254 from bamaer/3240
6d5acf93c3 is described below
commit 6d5acf93c36990f069917281ba9f852edc8c7d9f
Author: Bart Maertens <[email protected]>
AuthorDate: Sun Sep 24 11:35:11 2023 +0200
prevent creating unnamed parameters. fixes #3240
---
.../hop/ui/pipeline/dialog/PipelineDialog.java | 15 ++++++++++++++-
.../hop/ui/workflow/dialog/WorkflowDialog.java | 22 ++++++++++++++++++++--
.../dialog/messages/messages_en_US.properties | 2 ++
.../dialog/messages/messages_en_US.properties | 4 +++-
4 files changed, 39 insertions(+), 4 deletions(-)
diff --git
a/ui/src/main/java/org/apache/hop/ui/pipeline/dialog/PipelineDialog.java
b/ui/src/main/java/org/apache/hop/ui/pipeline/dialog/PipelineDialog.java
index 210e5daa06..9d6921b836 100644
--- a/ui/src/main/java/org/apache/hop/ui/pipeline/dialog/PipelineDialog.java
+++ b/ui/src/main/java/org/apache/hop/ui/pipeline/dialog/PipelineDialog.java
@@ -18,6 +18,7 @@
// CHECKSTYLE:FileLength:OFF
package org.apache.hop.ui.pipeline.dialog;
+import org.apache.commons.lang.StringUtils;
import org.apache.hop.core.Const;
import org.apache.hop.core.Props;
import org.apache.hop.core.exception.HopException;
@@ -774,7 +775,19 @@ public class PipelineDialog extends Dialog {
TableItem item = wParamFields.getNonEmpty(i);
try {
- pipelineMeta.addParameterDefinition(item.getText(1), item.getText(2),
item.getText(3));
+ if(StringUtils.isEmpty(item.getText(1)) &&
(!StringUtils.isEmpty(item.getText(2)) ||
!StringUtils.isEmpty(item.getText(3)))){
+ ok = false;
+ MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
+ mb.setText(
+ BaseMessages.getString(
+ PKG,
"PipelineDialog.NoUnnamedParameters.DialogTitle"));
+ mb.setMessage(
+ BaseMessages.getString(
+ PKG,
"PipelineDialog.NoUnnamedParameters.DialogMessage"));
+ mb.open();
+ }else{
+ pipelineMeta.addParameterDefinition(item.getText(1),
item.getText(2), item.getText(3));
+ }
} catch (DuplicateParamException e) {
// Ignore the duplicate parameter.
}
diff --git
a/ui/src/main/java/org/apache/hop/ui/workflow/dialog/WorkflowDialog.java
b/ui/src/main/java/org/apache/hop/ui/workflow/dialog/WorkflowDialog.java
index 89a882bf0a..6a950c1018 100644
--- a/ui/src/main/java/org/apache/hop/ui/workflow/dialog/WorkflowDialog.java
+++ b/ui/src/main/java/org/apache/hop/ui/workflow/dialog/WorkflowDialog.java
@@ -17,6 +17,7 @@
package org.apache.hop.ui.workflow.dialog;
+import org.apache.commons.lang.StringUtils;
import org.apache.hop.core.Const;
import org.apache.hop.core.Props;
import org.apache.hop.core.parameters.DuplicateParamException;
@@ -31,6 +32,7 @@ import org.apache.hop.ui.core.ConstUi;
import org.apache.hop.ui.core.PropsUi;
import org.apache.hop.ui.core.dialog.BaseDialog;
import org.apache.hop.ui.core.dialog.ErrorDialog;
+import org.apache.hop.ui.core.dialog.MessageBox;
import org.apache.hop.ui.core.gui.GuiResource;
import org.apache.hop.ui.core.gui.WindowProperty;
import org.apache.hop.ui.core.widget.ColumnInfo;
@@ -617,6 +619,8 @@ public class WorkflowDialog extends Dialog {
private void ok() {
+ boolean allGood = true;
+
workflowMeta.setName(wWorkflowName.getText());
workflowMeta.setNameSynchronizedWithFilename(wNameFilenameSync.getSelection());
workflowMeta.setDescription(wDescription.getText());
@@ -637,7 +641,19 @@ public class WorkflowDialog extends Dialog {
TableItem item = wParamFields.getNonEmpty(i);
try {
- workflowMeta.addParameterDefinition(item.getText(1), item.getText(2),
item.getText(3));
+ if(StringUtils.isEmpty(item.getText(1)) &&
(!StringUtils.isEmpty(item.getText(2)) ||
!StringUtils.isEmpty(item.getText(3)))){
+ allGood = false;
+ MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
+ mb.setText(
+ BaseMessages.getString(
+ PKG,
"WorkflowDialog.NoUnnamedParameters.DialogTitle"));
+ mb.setMessage(
+ BaseMessages.getString(
+ PKG,
"WorkflowDialog.NoUnnamedParameters.DialogMessage"));
+ mb.open();
+ }else{
+ workflowMeta.addParameterDefinition(item.getText(1),
item.getText(2), item.getText(3));
+ }
} catch (DuplicateParamException e) {
// Ignore the duplicate parameter.
}
@@ -649,7 +665,9 @@ public class WorkflowDialog extends Dialog {
workflowMeta.setChanged(changed || workflowMeta.hasChanged());
- dispose();
+ if(allGood){
+ dispose();
+ }
}
public static final Button setShellImage(Shell shell, IAction action) {
diff --git
a/ui/src/main/resources/org/apache/hop/ui/pipeline/dialog/messages/messages_en_US.properties
b/ui/src/main/resources/org/apache/hop/ui/pipeline/dialog/messages/messages_en_US.properties
index a22553f760..d678a416f1 100644
---
a/ui/src/main/resources/org/apache/hop/ui/pipeline/dialog/messages/messages_en_US.properties
+++
b/ui/src/main/resources/org/apache/hop/ui/pipeline/dialog/messages/messages_en_US.properties
@@ -95,3 +95,5 @@
PipelinePreviewProgressDialog.ErrorLoadingPipeline.DialogTitle=Error loading pip
PipelinePreviewProgressDialog.Exception.ErrorPreparingPipeline=There was an
error preparing (initializing) the pipeline\!
PipelinePreviewProgressDialog.Monitor.BeginTask.Title=Starting pipeline in
preview...
PipelinePreviewProgressDialog.SubTask.TransformPreviewFinished=Transform
preview has finished.
+PipelineDialog.NoUnnamedParameters.DialogTitle=No unnamed parameters
+PipelineDialog.NoUnnamedParameters.DialogMessage=Parameters can''t have a
default value or description without a name.
\ No newline at end of file
diff --git
a/ui/src/main/resources/org/apache/hop/ui/workflow/dialog/messages/messages_en_US.properties
b/ui/src/main/resources/org/apache/hop/ui/workflow/dialog/messages/messages_en_US.properties
index 9088a03b9b..5fa2a9e27b 100644
---
a/ui/src/main/resources/org/apache/hop/ui/workflow/dialog/messages/messages_en_US.properties
+++
b/ui/src/main/resources/org/apache/hop/ui/workflow/dialog/messages/messages_en_US.properties
@@ -68,4 +68,6 @@
WorkflowExecutionConfigurationDialog.VariablesColumn.Value=Value
WorkflowExecutionConfigurationDialog.VerifyRunConfigurationName.Warning=Warning\!
The proposed run configuration name is different from what was used last in
another workflow. Make sure you''re using the right run configuration before
executing\!
WorkflowExecutionConfigurationDialog.alwaysShowOption=Uncheck this option if
you don''t want to see this dialog when running your workflow
WorkflowExecutionConfigurationDialog.docHeader=Run a workflow
-WorkflowExecutionConfigurationDialog.docTitle=Help for Execute a workflow
\ No newline at end of file
+WorkflowExecutionConfigurationDialog.docTitle=Help for Execute a workflow
+WorkflowDialog.NoUnnamedParameters.DialogTitle=No unnamed parameters
+WorkflowDialog.NoUnnamedParameters.DialogMessage=Parameters can''t have a
default value or description without a name.
\ No newline at end of file