Skip to content

Commit

Permalink
fix #3852 - Other minor improvemets to transform's GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
sramazzina committed Apr 24, 2024
1 parent 758cf0e commit b02cb9d
Showing 1 changed file with 71 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -377,20 +377,20 @@ 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;

// 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);
Expand All @@ -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(
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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");
Expand All @@ -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);
Expand All @@ -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"));
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -1154,31 +1150,36 @@ 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, ""));
setTableFieldCombo();
}

} 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);
}
}
}
Expand Down Expand Up @@ -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());
}
}

0 comments on commit b02cb9d

Please sign in to comment.