diff --git a/plugins/tech/aws/src/main/java/org/apache/hop/pipeline/transforms/redshift/bulkloader/RedshiftBulkLoaderDialog.java b/plugins/tech/aws/src/main/java/org/apache/hop/pipeline/transforms/redshift/bulkloader/RedshiftBulkLoaderDialog.java index 68117a1fd5..1751335d3e 100644 --- a/plugins/tech/aws/src/main/java/org/apache/hop/pipeline/transforms/redshift/bulkloader/RedshiftBulkLoaderDialog.java +++ b/plugins/tech/aws/src/main/java/org/apache/hop/pipeline/transforms/redshift/bulkloader/RedshiftBulkLoaderDialog.java @@ -342,26 +342,26 @@ private void addGeneralTab( fdTruncate.right = new FormAttachment(100, 0); wTruncate.setLayoutData(fdTruncate); SelectionAdapter lsTruncMod = - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent arg0) { - input.setChanged(); - } - }; + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent arg0) { + input.setChanged(); + } + }; wTruncate.addSelectionListener(lsTruncMod); wTruncate.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - toggleSpecifyFieldsFlags(); - } - }); + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + toggleSpecifyFieldsFlags(); + } + }); Control lastControl = wlTruncate; // Truncate only when have rows Label wlOnlyWhenHaveRows = new Label(wGeneralComp, SWT.RIGHT); wlOnlyWhenHaveRows.setText( - BaseMessages.getString(PKG, "RedshiftBulkLoaderDialog.OnlyWhenHaveRows.Label")); + BaseMessages.getString(PKG, "RedshiftBulkLoaderDialog.OnlyWhenHaveRows.Label")); PropsUi.setLook(wlOnlyWhenHaveRows); FormData fdlOnlyWhenHaveRows = new FormData(); fdlOnlyWhenHaveRows.top = new FormAttachment(lastControl, margin); @@ -377,12 +377,12 @@ public void widgetSelected(SelectionEvent e) { wOnlyWhenHaveRows.setLayoutData(fdTruncateWhenHaveRows); SelectionAdapter lsSelMod = - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent arg0) { - input.setChanged(); - } - }; + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent arg0) { + input.setChanged(); + } + }; wOnlyWhenHaveRows.addSelectionListener(lsSelMod); lastControl = wlOnlyWhenHaveRows; @@ -390,7 +390,7 @@ public void widgetSelected(SelectionEvent arg0) { // Specify fields Label wlSpecifyFields = new Label(wGeneralComp, SWT.RIGHT); wlSpecifyFields.setText( - BaseMessages.getString(PKG, "RedshiftBulkLoaderDialog.SpecifyFields.Label")); + BaseMessages.getString(PKG, "RedshiftBulkLoaderDialog.SpecifyFields.Label")); PropsUi.setLook(wlSpecifyFields); FormData fdlSpecifyFields = new FormData(); fdlSpecifyFields.top = new FormAttachment(lastControl, margin); @@ -410,12 +410,12 @@ public void widgetSelected(SelectionEvent arg0) { // If the flag is off, gray out the fields tab e.g. wSpecifyFields.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent arg0) { - toggleSpecifyFieldsFlags(); - } - }); + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent arg0) { + toggleSpecifyFieldsFlags(); + } + }); Label wlStreamToS3Csv = new Label(wGeneralComp, SWT.RIGHT); wlStreamToS3Csv.setText( @@ -522,8 +522,7 @@ private void addAwsAuthenticationTab( CTabItem wAwsAuthTab = new CTabItem(wTabFolder, SWT.NONE); wAwsAuthTab.setText( - BaseMessages.getString( - PKG, "RedshiftBulkLoaderDialog.AwsAuthTab.Label")); // $NON-NLS-1$ + BaseMessages.getString(PKG, "RedshiftBulkLoaderDialog.AwsAuthTab.Label")); // $NON-NLS-1$ Composite wAwsAuthComp = new Composite(wTabFolder, SWT.NONE); PropsUi.setLook(wAwsAuthComp); @@ -535,7 +534,7 @@ private void addAwsAuthenticationTab( wlAwsAuthType = new Label(wAwsAuthComp, SWT.RIGHT); wlAwsAuthType.setText( - BaseMessages.getString(PKG, "RedshiftBulkLoaderDialog.AuthenticationType.Label")); + BaseMessages.getString(PKG, "RedshiftBulkLoaderDialog.AuthenticationType.Label")); PropsUi.setLook(wlAwsAuthType); FormData fdlAwsAuthType = new FormData(); fdlAwsAuthType.top = new FormAttachment(0, margin); @@ -555,9 +554,10 @@ private void addAwsAuthenticationTab( Control lastControl = wlAwsAuthType; wlUseSystemVars = new Label(wAwsAuthComp, SWT.RIGHT); - wlUseSystemVars.setText(BaseMessages.getString(PKG, "RedshiftBulkLoaderDialog.Authenticate.UseSystemVars.Label")); + wlUseSystemVars.setText( + BaseMessages.getString(PKG, "RedshiftBulkLoaderDialog.Authenticate.UseSystemVars.Label")); wlUseSystemVars.setToolTipText( - BaseMessages.getString(PKG, "RedshiftBulkLoaderDialog.Authenticate.UseSystemVars.Tooltip")); + BaseMessages.getString(PKG, "RedshiftBulkLoaderDialog.Authenticate.UseSystemVars.Tooltip")); PropsUi.setLook(wlUseSystemVars); FormData fdlUseSystemVars = new FormData(); fdlUseSystemVars.top = new FormAttachment(lastControl, margin); @@ -575,12 +575,12 @@ private void addAwsAuthenticationTab( lastControl = wlUseSystemVars; wUseSystemVars.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - toggleKeysSelection(); - } - }); + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + toggleKeysSelection(); + } + }); wlAccessKeyId = new Label(wAwsAuthComp, SWT.RIGHT); wlAccessKeyId.setText("AWS_ACCESS_KEY_ID"); @@ -597,6 +597,8 @@ public void widgetSelected(SelectionEvent e) { fdUseAccessKeyId.left = new FormAttachment(middle, 0); fdUseAccessKeyId.right = new FormAttachment(100, 0); wAccessKeyId.setLayoutData(fdUseAccessKeyId); + wAccessKeyId.addModifyListener(lsMod); + lastControl = wAccessKeyId; wlSecretAccessKey = new Label(wAwsAuthComp, SWT.RIGHT); @@ -614,13 +616,10 @@ public void widgetSelected(SelectionEvent e) { fdSecretAccessKey.left = new FormAttachment(middle, 0); fdSecretAccessKey.right = new FormAttachment(100, 0); wSecretAccessKey.setLayoutData(fdSecretAccessKey); - lastControl = wSecretAccessKey; + wSecretAccessKey.addModifyListener(lsMod); - // Start with system variables enabled and AWS keys disabled by default - wlAccessKeyId.setEnabled(false); - wAccessKeyId.setEnabled(false); - wlSecretAccessKey.setEnabled(false); - wSecretAccessKey.setEnabled(false); + lastControl = wSecretAccessKey; + toggleKeysSelection(); wlAwsIamRole = new Label(wAwsAuthComp, SWT.RIGHT); wlAwsIamRole.setText(BaseMessages.getString(PKG, "RedshiftBulkLoaderDialog.IamRole.Label")); @@ -638,20 +637,18 @@ public void widgetSelected(SelectionEvent e) { fdIamRole.left = new FormAttachment(middle, 0); fdIamRole.right = new FormAttachment(100, 0); wAwsIamRole.setLayoutData(fdIamRole); + wAwsIamRole.addModifyListener(lsMod); - lastControl = wlAwsIamRole; - // Credentials are enabled by default. wlAwsIamRole.setEnabled(false); wAwsIamRole.setEnabled(false); wAwsAuthType.addSelectionListener( - new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - toggleAuthSelection(); - } - }); - + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + toggleAuthSelection(); + } + }); FormData fdAwsAuthComp = new FormData(); fdAwsAuthComp.left = new FormAttachment(0, 0); @@ -668,8 +665,7 @@ private void addFieldsTab(CTabFolder wTabFolder, int margin, int middle, ModifyL CTabItem wFieldsTab = new CTabItem(wTabFolder, SWT.NONE); wFieldsTab.setText( - BaseMessages.getString( - PKG, "RedshiftBulkLoaderDialog.FieldsTab.Label")); // $NON-NLS-1$ + BaseMessages.getString(PKG, "RedshiftBulkLoaderDialog.FieldsTab.Label")); // $NON-NLS-1$ Composite wFieldsComp = new Composite(wTabFolder, SWT.NONE); PropsUi.setLook(wFieldsComp); @@ -1154,13 +1150,17 @@ private void getSchemaName() { if (null != schemas && schemas.length > 0) { schemas = Const.sortStrings(schemas); EnterSelectionDialog dialog = - new EnterSelectionDialog( - shell, - schemas, - BaseMessages.getString( - PKG, "RedshiftBulkLoaderDialog.AvailableSchemas.Title", wConnection.getText()), - BaseMessages.getString( - PKG, "RedshiftBulkLoaderDialog.AvailableSchemas.Message", wConnection.getText())); + new EnterSelectionDialog( + shell, + schemas, + BaseMessages.getString( + PKG, + "RedshiftBulkLoaderDialog.AvailableSchemas.Title", + wConnection.getText()), + BaseMessages.getString( + PKG, + "RedshiftBulkLoaderDialog.AvailableSchemas.Message", + wConnection.getText())); String d = dialog.open(); if (d != null) { wSchema.setText(Const.NVL(d, "")); @@ -1168,17 +1168,18 @@ private void getSchemaName() { } } else { - org.apache.hop.ui.core.dialog.MessageBox mb = new org.apache.hop.ui.core.dialog.MessageBox(shell, SWT.OK | SWT.ICON_ERROR); + 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, "RedshiftBulkLoaderDialog.NoSchema.Error")); mb.setText(BaseMessages.getString(PKG, "RedshiftBulkLoaderDialog.GetSchemas.Error")); mb.open(); } } catch (Exception e) { new ErrorDialog( - shell, - BaseMessages.getString(PKG, "System.Dialog.Error.Title"), - BaseMessages.getString(PKG, "RedshiftBulkLoaderDialog.ErrorGettingSchemas"), - e); + shell, + BaseMessages.getString(PKG, "System.Dialog.Error.Title"), + BaseMessages.getString(PKG, "RedshiftBulkLoaderDialog.ErrorGettingSchemas"), + e); } } } @@ -1326,16 +1327,9 @@ public void toggleAuthSelection() { } public void toggleKeysSelection() { - if (wUseSystemVars.getSelection()) { - wlAccessKeyId.setEnabled(false); - wAccessKeyId.setEnabled(false); - wlSecretAccessKey.setEnabled(false); - wSecretAccessKey.setEnabled(false); - } else { - wlAccessKeyId.setEnabled(true); - wAccessKeyId.setEnabled(true); - wlSecretAccessKey.setEnabled(true); - wSecretAccessKey.setEnabled(true); - } + wlAccessKeyId.setEnabled(!wUseSystemVars.getSelection()); + wAccessKeyId.setEnabled(!wUseSystemVars.getSelection()); + wlSecretAccessKey.setEnabled(!wUseSystemVars.getSelection()); + wSecretAccessKey.setEnabled(!wUseSystemVars.getSelection()); } }