Skip to content

Commit

Permalink
fix for issue forcedotcom#1017
Browse files Browse the repository at this point in the history
Give user ability to specify and enforce wizard width and height in Settings dialog.
  • Loading branch information
ashitsalesforce committed Mar 20, 2024
1 parent fea7ed9 commit 1e2e29a
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 22 deletions.
6 changes: 4 additions & 2 deletions src/main/java/com/salesforce/dataloader/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,11 @@ public class Config {
public static final String READ_ONLY_CONFIG_PROPERTIES = "config.properties.readonly";
public static final String WIZARD_WIDTH = "sfdc.ui.wizard.width";
public static final String WIZARD_HEIGHT = "sfdc.ui.wizard.height";
public static final String ENFORCE_WIZARD_WIDTH_HEIGHT_CONFIG = "sfdc.ui.wizard.enforceWidthHeight";
public static final String WIZARD_CLOSE_ON_FINISH = "sfdc.ui.wizard.closeOnFinish";
public static final String WIZARD_POPULATE_RESULTS_FOLDER_WITH_PREVIOUS_OP_RESULTS_FOLDER = "sfdc.ui.wizard.finishStep.prepopulateWithPreviousOpResultsFolder";
public static final int DEFAULT_WIZARD_WIDTH = 600;
public static final int DEFAULT_WIZARD_HEIGHT = 700;
public static final int DEFAULT_WIZARD_WIDTH = 400;
public static final int DEFAULT_WIZARD_HEIGHT = 600;

private static final String LAST_RUN_FILE_SUFFIX = "_lastRun.properties"; //$NON-NLS-1$
// Following properties are read-only, i.e. they are not overridden during save() to config.properties
Expand Down Expand Up @@ -615,6 +616,7 @@ private void setDefaults() {
setDefaultValue(PROCESS_KEEP_ACCOUNT_TEAM, false);
setDefaultValue(WIZARD_WIDTH, DEFAULT_WIZARD_WIDTH);
setDefaultValue(WIZARD_HEIGHT, DEFAULT_WIZARD_HEIGHT);
setDefaultValue(ENFORCE_WIZARD_WIDTH_HEIGHT_CONFIG, false);
setDefaultValue(DAO_READ_PREPROCESSOR_SCRIPT, "");
setDefaultValue(DAO_WRITE_POSTPROCESSOR_SCRIPT, "");
setDefaultValue(LIMIT_OUTPUT_TO_QUERY_FIELDS, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ public class AdvancedSettingsDialog extends BaseDialog {
private Text textSandboxPartnerClientID;
private Text textProductionBulkClientID;
private Text textSandboxBulkClientID;
private Text textWizardWidth;
private Text textWizardHeight;
private final String defaultServer;

private Button buttonHideWelcomeScreen;
Expand All @@ -113,7 +115,8 @@ public class AdvancedSettingsDialog extends BaseDialog {
private Button buttonCsvTab;
private Button buttonLoginFromBrowser;
private Button buttonCloseWizardOnFinish;
private Button buttonPopulateResultsFolderOnFinishStep;
private Button buttonEnforceSpecifiedWizardWidthAndHeight;
private Button buttonPopulateResultsFolderOnWizardFinishStep;
private static final String[] LOGGING_LEVEL = { "ALL", "DEBUG", "INFO", "WARN", "ERROR", "FATAL" };
private Combo comboLoggingLevelDropdown;

Expand Down Expand Up @@ -812,12 +815,55 @@ public void verifyText(VerifyEvent event) {
buttonCloseWizardOnFinish = new Button(restComp, SWT.CHECK);
buttonCloseWizardOnFinish.setSelection(closeWizardOnFinish);

Label populateResultsFolderOnFinishStepText = new Label(restComp, SWT.RIGHT | SWT.WRAP);
populateResultsFolderOnFinishStepText.setText(Labels.getString("AdvancedSettingsDialog.populateResultsFolderOnFinishStep"));
populateResultsFolderOnFinishStepText.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
Label labelWizardWidthAndHeight = new Label(restComp, SWT.RIGHT | SWT.WRAP);
labelWizardWidthAndHeight.setText(Labels.getString("AdvancedSettingsDialog.wizardWidthAndHeight"));
labelWizardWidthAndHeight.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
Composite widthAndHeightComp = new Composite(restComp, SWT.NONE);
data = new GridData(GridData.FILL_BOTH);
widthAndHeightComp.setLayoutData(data);
layout = new GridLayout(3, false);
widthAndHeightComp.setLayout(layout);
textWizardWidth = new Text(widthAndHeightComp, SWT.BORDER);
textWizardWidth.setText(config.getString(Config.WIZARD_WIDTH));
data = new GridData();
textWizardWidth.setTextLimit(4);
data.widthHint = 4 * textSize.x;
textWizardWidth.setLayoutData(data);
textWizardWidth.addVerifyListener(new VerifyListener() {
@Override
public void verifyText(VerifyEvent event) {
event.doit = Character.isISOControl(event.character) || Character.isDigit(event.character);
}
});

Label labelMultiplySymbol = new Label(widthAndHeightComp, SWT.CENTER);
labelMultiplySymbol.setText("x");
labelMultiplySymbol.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));

textWizardHeight = new Text(widthAndHeightComp, SWT.BORDER);
textWizardHeight.setText(config.getString(Config.WIZARD_HEIGHT));
textWizardHeight.setTextLimit(4);
data.widthHint = 4 * textSize.x;
textWizardHeight.setLayoutData(data);
textWizardHeight.addVerifyListener(new VerifyListener() {
@Override
public void verifyText(VerifyEvent event) {
event.doit = Character.isISOControl(event.character) || Character.isDigit(event.character);
}
});

Label labelEnforceSpecifiedWizardWidthAndHeight = new Label(restComp, SWT.RIGHT | SWT.WRAP);
labelEnforceSpecifiedWizardWidthAndHeight.setText(Labels.getString("AdvancedSettingsDialog.enforceSpecifiedWizardWidthAndHeight"));
labelEnforceSpecifiedWizardWidthAndHeight.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
buttonEnforceSpecifiedWizardWidthAndHeight = new Button(restComp, SWT.CHECK);
buttonEnforceSpecifiedWizardWidthAndHeight.setSelection(config.getBoolean(Config.ENFORCE_WIZARD_WIDTH_HEIGHT_CONFIG));

Label populateResultsFolderOnWizardFinishStepText = new Label(restComp, SWT.RIGHT | SWT.WRAP);
populateResultsFolderOnWizardFinishStepText.setText(Labels.getString("AdvancedSettingsDialog.populateResultsFolderOnFinishStepOfWizard"));
populateResultsFolderOnWizardFinishStepText.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
boolean populateResultsFolderOnFinishStep = config.getBoolean(Config.WIZARD_POPULATE_RESULTS_FOLDER_WITH_PREVIOUS_OP_RESULTS_FOLDER);
buttonPopulateResultsFolderOnFinishStep = new Button(restComp, SWT.CHECK);
buttonPopulateResultsFolderOnFinishStep.setSelection(populateResultsFolderOnFinishStep);
buttonPopulateResultsFolderOnWizardFinishStep = new Button(restComp, SWT.CHECK);
buttonPopulateResultsFolderOnWizardFinishStep.setSelection(populateResultsFolderOnFinishStep);

blankAgain = new Label(restComp, SWT.NONE);
data = new GridData();
Expand Down Expand Up @@ -969,7 +1015,11 @@ public void widgetSelected(SelectionEvent event) {
config.setValue(Config.BULKV2_API_ENABLED, buttonUseBulkV2Api.getSelection());
config.setValue(Config.OAUTH_LOGIN_FROM_BROWSER, buttonLoginFromBrowser.getSelection());
config.setValue(Config.WIZARD_CLOSE_ON_FINISH, buttonCloseWizardOnFinish.getSelection());
config.setValue(Config.WIZARD_POPULATE_RESULTS_FOLDER_WITH_PREVIOUS_OP_RESULTS_FOLDER, buttonPopulateResultsFolderOnFinishStep.getSelection());
config.setValue(Config.WIZARD_WIDTH, textWizardWidth.getText());
config.setValue(Config.WIZARD_HEIGHT, textWizardHeight.getText());
config.setValue(Config.ENFORCE_WIZARD_WIDTH_HEIGHT_CONFIG, buttonEnforceSpecifiedWizardWidthAndHeight.getSelection());

config.setValue(Config.WIZARD_POPULATE_RESULTS_FOLDER_WITH_PREVIOUS_OP_RESULTS_FOLDER, buttonPopulateResultsFolderOnWizardFinishStep.getSelection());
LoggingUtil.setLoggingLevel(LOGGING_LEVEL[comboLoggingLevelDropdown.getSelectionIndex()]);
String clientIdVal = textProductionPartnerClientID.getText();
if (clientIdVal != null && !clientIdVal.strip().isEmpty()) {
Expand Down
46 changes: 37 additions & 9 deletions src/main/java/com/salesforce/dataloader/ui/LoaderWizardDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.eclipse.swt.widgets.*;

import com.salesforce.dataloader.config.Config;
import com.salesforce.dataloader.exception.ParameterLoadException;

/**
* A dialog to show a wizard to the end user.
Expand Down Expand Up @@ -94,9 +95,9 @@ public class LoaderWizardDialog extends LoaderTitleAreaDialog implements IWizard
private SelectionAdapter cancelListener;
private boolean isMovingToPreviousPage = false;
private Composite pageContainer;
private PageContainerFillLayout pageContainerLayout = new PageContainerFillLayout(5, 5, 600, 800);
private int pageWidth = SWT.DEFAULT;
private int pageHeight = SWT.DEFAULT;
private PageContainerFillLayout pageContainerLayout = null;
private int computedPageWidth = SWT.DEFAULT;
private int computedPageHeight = SWT.DEFAULT;
private static final String FOCUS_CONTROL = "focusControl"; //$NON-NLS-1$
private boolean lockedUI = false;
private HashMap<Integer, Button> buttons;
Expand Down Expand Up @@ -144,6 +145,7 @@ public PageContainerFillLayout(int mw, int mh, int minW, int minH) {
}

private Point computedSizePoint = null;

/*
* (non-Javadoc) Method declared on Layout.
*/
Expand Down Expand Up @@ -174,6 +176,8 @@ public Point computeSize(Composite composite, int wHint, int hHint, boolean forc
computedSizePoint.y = Math.max(computedSizePoint.y, minimumHeight);
if (wHint != SWT.DEFAULT) computedSizePoint.x = wHint;
if (hHint != SWT.DEFAULT) computedSizePoint.y = hHint;
computedPageWidth = computedSizePoint.x;
computedPageHeight = computedSizePoint.y;
return computedSizePoint;
}

Expand Down Expand Up @@ -237,6 +241,15 @@ public void setPageLocation(Control w) {
public LoaderWizardDialog(Shell parentShell, IWizard newWizard, Config config) {
super(parentShell);
this.config = config;
try {
this.pageContainerLayout = new PageContainerFillLayout(5, 5,
config.getInt(Config.WIZARD_WIDTH),
config.getInt(Config.WIZARD_HEIGHT));
} catch (ParameterLoadException e) {
this.pageContainerLayout = new PageContainerFillLayout(5, 5,
Config.DEFAULT_WIZARD_WIDTH,
Config.DEFAULT_WIZARD_HEIGHT);
}
buttons = new HashMap<>();
setShellStyle(SWT.CLOSE | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL | SWT.RESIZE);
setWizard(newWizard);
Expand Down Expand Up @@ -471,8 +484,8 @@ protected Control createDialogArea(Composite parent) {
// Build the Page container
pageContainer = createPageContainer(composite);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = pageWidth;
gd.heightHint = pageHeight;
gd.widthHint = computedPageWidth;
gd.heightHint = computedPageHeight;
pageContainer.setLayoutData(gd);
pageContainer.setFont(parent.getFont());
// Insert a progress monitor
Expand Down Expand Up @@ -896,8 +909,8 @@ public void setMinimumPageSize(Point size) {
* @see #setPageSize(Point)
*/
public void setPageSize(int width, int height) {
pageWidth = width;
pageHeight = height;
computedPageWidth = width;
computedPageHeight = height;
}

/**
Expand Down Expand Up @@ -1139,8 +1152,23 @@ public void updateMessage() {
protected void updateSize(IWizardPage page) {
if (page == null || page.getControl() == null) return;
Shell shell = this.getShell();
shell.pack();
shell.setBounds(getConstrainedShellBounds(shell.getBounds()));
int width = computedPageWidth - 4 * this.pageContainerLayout.marginWidth;
int height = computedPageHeight - 4 * this.pageContainerLayout.marginHeight;
if (config.getBoolean(Config.ENFORCE_WIZARD_WIDTH_HEIGHT_CONFIG)) {
try {
width = config.getInt(Config.WIZARD_WIDTH);
height = config.getInt(Config.WIZARD_HEIGHT);
} catch (ParameterLoadException e) {
width = Config.DEFAULT_WIZARD_WIDTH;
height = Config.DEFAULT_WIZARD_HEIGHT;
}
}
Rectangle bounds = new Rectangle(
OperationPage.SHELL_X_OFFSET,
OperationPage.SHELL_Y_OFFSET,
width,
height);
shell.setBounds(getConstrainedShellBounds(bounds));
pageContainerLayout.layoutPage(page.getControl());
}

Expand Down
10 changes: 6 additions & 4 deletions src/main/resources/labels.properties
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ AdvancedSettingsDialog.loggingLevel=Current logging level:
AdvancedSettingsDialog.configDir=Folder containing configuration files:\n(config.properties, log4j2.properties, ...)
AdvancedSettingsDialog.latestLoggingFile=Logging output file:
AdvancedSettingsDialog.loggingConfigFile=Logging configuration file:
AdvancedSettingsDialog.checkUploadDelimiterCheckbox=Specify delimiter(s) for upload operations.
AdvancedSettingsDialog.closeWizardOnFinish=Close UI Wizard dialog when an operation is completed.
AdvancedSettingsDialog.cacheDescribeGlobalResults=Cache Salesforce object and field information across operations
AdvancedSettingsDialog.populateResultsFolderOnFinishStep=Pre-populate Results Folder input field in Finish step\n (use the folder chosen in the previous operation):
AdvancedSettingsDialog.checkUploadDelimiterCheckbox=Specify delimiter(s) for upload operations:
AdvancedSettingsDialog.cacheDescribeGlobalResults=Cache Salesforce object and field information across operations:
AdvancedSettingsDialog.closeWizardOnFinish=Close UI Wizard when an operation is completed:
AdvancedSettingsDialog.wizardWidthAndHeight=UI Wizard width and height (width x height):
AdvancedSettingsDialog.enforceSpecifiedWizardWidthAndHeight=Enforce specified width and height for UI Wizard:
AdvancedSettingsDialog.populateResultsFolderOnFinishStepOfWizard=Pre-populate Results Folder input field in Finish step of UI Wizard:\n (use the folder chosen in the previous operation)
InsertWizard.windowTitle=Load Inserts
InsertWizard.confFirstLine=You have chosen to insert new records. Click Yes to begin.
Expand Down

0 comments on commit 1e2e29a

Please sign in to comment.