Skip to content

Commit

Permalink
Merge pull request #3254 from bamaer/3240
Browse files Browse the repository at this point in the history
prevent creating unnamed parameters. fixes #3240
  • Loading branch information
hansva committed Oct 13, 2023
2 parents 44fc995 + 6d5acf9 commit a0e5405
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -774,7 +775,19 @@ private void ok() {
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.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,6 +32,7 @@
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;
Expand Down Expand Up @@ -617,6 +619,8 @@ private void cancel() {

private void ok() {

boolean allGood = true;

workflowMeta.setName(wWorkflowName.getText());
workflowMeta.setNameSynchronizedWithFilename(wNameFilenameSync.getSelection());
workflowMeta.setDescription(wDescription.getText());
Expand All @@ -637,7 +641,19 @@ private void ok() {
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.
}
Expand All @@ -649,7 +665,9 @@ private void ok() {

workflowMeta.setChanged(changed || workflowMeta.hasChanged());

dispose();
if(allGood){
dispose();
}
}

public static final Button setShellImage(Shell shell, IAction action) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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
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.

0 comments on commit a0e5405

Please sign in to comment.