Skip to content

Commit

Permalink
minor UI tweaks for referencing relationships thru idlookup
Browse files Browse the repository at this point in the history
Better wording to prompt user to specify the idlookup field of related object used in CSV file.
  • Loading branch information
ashitsalesforce committed Feb 8, 2024
1 parent 452c6dc commit 8ad0fba
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public class RelationshipField {
// new format to support polymorphic lookup relationship -
// <parent object name>:<relationship name attribute of relationship field>.<idLookup field of parent sObject>
// Example - "Account:Owner.username"
private static final String NEW_FORMAT_PARENT_IDLOOKUP_FIELD_SEPARATOR_CHAR = "-";
private static final String NEW_FORMAT_RELATIONSHIP_NAME_SEPARATOR_CHAR = ":";
public static final String NEW_FORMAT_PARENT_IDLOOKUP_FIELD_SEPARATOR_CHAR = "-";
public static final String NEW_FORMAT_RELATIONSHIP_NAME_SEPARATOR_CHAR = ":";

public RelationshipField(String parentObjectName, String relationshipName) {
this.parentObjectName = parentObjectName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

Expand All @@ -51,7 +53,7 @@
* @author Alex Warshavsky
* @since 8.0
*/
public class ForeignKeyExternalIdPage extends LoadPage {
public class ChooseLookupFieldForRelationshipPage extends LoadPage {

private final Map<String,Combo> extIdSelections = new HashMap<String,Combo>();
private final Map<String,Combo> parentSelections = new HashMap<String,Combo>();
Expand All @@ -61,8 +63,8 @@ public class ForeignKeyExternalIdPage extends LoadPage {
private boolean hasParentEntitiesWithIdLookupField = false;


public ForeignKeyExternalIdPage(Controller controller) {
super("ForeignKeyExternalIdPage", controller); //$NON-NLS-1$
public ChooseLookupFieldForRelationshipPage(Controller controller) {
super("ChooseLookupFieldForRelationshipPage", controller); //$NON-NLS-1$
// Mark this page as completed as the selected sObject may not have any foreign key
setPageComplete();
}
Expand All @@ -88,7 +90,7 @@ private void createFkExtIdUi() {
Composite comp = new Composite(scrollComp, SWT.NONE);
scrollComp.setContent(comp);

GridLayout gridLayout = new GridLayout(3, false);
GridLayout gridLayout = new GridLayout(5, false);
gridLayout.horizontalSpacing = 10;
gridLayout.marginHeight = 20;
gridLayout.verticalSpacing = 7;
Expand All @@ -105,6 +107,35 @@ private void createFkExtIdUi() {
parentSelections.clear();
this.hasParentEntitiesWithIdLookupField = false;
if(referenceObjects != null) {
Label relNameHeader = new Label(comp, SWT.RIGHT);
relNameHeader.setText(Labels.getString(getClass().getSimpleName() + ".relationshipHeader"));
relNameHeader.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
Font f = relNameHeader.getFont();
FontData[] farr = f.getFontData();
FontData fd = farr[0];
fd.setStyle(SWT.BOLD);
relNameHeader.setFont(new Font(Display.getCurrent(), fd));

Label parentObjectSeparator = new Label(comp, SWT.CENTER);
parentObjectSeparator.setText(RelationshipField.NEW_FORMAT_RELATIONSHIP_NAME_SEPARATOR_CHAR);
parentObjectSeparator.setFont(new Font(Display.getCurrent(), fd));

Label parentObjectNameHeader = new Label(comp, SWT.RIGHT);
parentObjectNameHeader.setText(Labels.getString(
getClass().getSimpleName() + ".parentObjectHeader"));
parentObjectNameHeader.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
parentObjectNameHeader.setFont(new Font(Display.getCurrent(), fd));

Label parentLookupFieldSeparator = new Label(comp, SWT.CENTER);
parentLookupFieldSeparator.setText(RelationshipField.NEW_FORMAT_PARENT_IDLOOKUP_FIELD_SEPARATOR_CHAR);
parentLookupFieldSeparator.setFont(new Font(Display.getCurrent(), fd));

Label idLookupFieldNameHeader = new Label(comp, SWT.RIGHT);
idLookupFieldNameHeader.setText(Labels.getString(
getClass().getSimpleName() + ".parentLookupFieldHeader"));
idLookupFieldNameHeader.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
idLookupFieldNameHeader.setFont(new Font(Display.getCurrent(), fd));

List<String> sortedRelationshipList = new ArrayList<>(referenceObjects.keySet());
Collections.sort(sortedRelationshipList);
for(String relationshipName : sortedRelationshipList) {
Expand Down Expand Up @@ -150,12 +181,16 @@ private void createObjectExtIdUi(Composite comp, String relationshipName) {
// shouldn't happen
return;
}

Combo parentCombo = this.parentSelections.get(relField.getRelationshipName());
if (parentCombo == null) {
// first parent object
Label labelExtId = new Label(comp, SWT.RIGHT);
labelExtId.setText(relField.getRelationshipName() + ":");
labelExtId.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
Label relName = new Label(comp, SWT.RIGHT);
relName.setText(relField.getRelationshipName());
relName.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

Label parentObjectSeparator = new Label(comp, SWT.CENTER);
parentObjectSeparator.setText(RelationshipField.NEW_FORMAT_RELATIONSHIP_NAME_SEPARATOR_CHAR);

parentCombo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
GridData parentData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
Expand All @@ -174,6 +209,8 @@ public void widgetSelected(SelectionEvent event) {
}
});
parentSelections.put(relField.getRelationshipName(), parentCombo);
Label parentLookupFieldSeparator = new Label(comp, SWT.CENTER);
parentLookupFieldSeparator.setText(RelationshipField.NEW_FORMAT_PARENT_IDLOOKUP_FIELD_SEPARATOR_CHAR);
// Add the ext id dropdown
Combo extIdCombo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);

Expand All @@ -195,7 +232,8 @@ private void populateParentLookupFieldCombo(Combo extIdCombo, RelationshipField
// set the objects reference information
List<String> fieldList = new ArrayList<String>(extIdInfo.getParentObjectFieldMap().keySet());
// add default selection "not selected" to the list to allow users to go back to it
fieldList.add(Labels.getString("ForeignKeyExternalIdPage.defaultComboText"));
fieldList.add(Labels.getString(
Labels.getString(getClass().getSimpleName() + ".defaultComboText")));
UIUtils.setComboItems(extIdCombo, fieldList, Labels.getString("ForeignKeyExternalIdPage.defaultComboText"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public LoadPage getNextPage() {

// prepare next page
LoadPage nextPage = null;
ForeignKeyExternalIdPage fkExtIdPage = (ForeignKeyExternalIdPage) getWizard().getPage(ForeignKeyExternalIdPage.class.getSimpleName()); //$NON-NLS-1$
ChooseLookupFieldForRelationshipPage fkExtIdPage = (ChooseLookupFieldForRelationshipPage) getWizard().getPage(ChooseLookupFieldForRelationshipPage.class.getSimpleName()); //$NON-NLS-1$
if(controller.getReferenceDescribes().size() > 0) {
nextPage = fkExtIdPage;
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/salesforce/dataloader/ui/LoadWizard.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public UpdateWizard(Controller controller) {
@Override
protected void hook_additionalLoadWizardPages() {
super.hook_additionalLoadWizardPages();
addPage(new ForeignKeyExternalIdPage(getController()));
addPage(new ChooseLookupFieldForRelationshipPage(getController()));
}
}

Expand All @@ -199,7 +199,7 @@ public UpsertWizard(Controller controller) {
protected void hook_additionalLoadWizardPages() {
super.hook_additionalLoadWizardPages();
addPage(new ExternalIdPage(getController()));
addPage(new ForeignKeyExternalIdPage(getController()));
addPage(new ChooseLookupFieldForRelationshipPage(getController()));
}
}

Expand All @@ -211,7 +211,7 @@ public InsertWizard(Controller controller) {
@Override
protected void hook_additionalLoadWizardPages() {
super.hook_additionalLoadWizardPages();
addPage(new ForeignKeyExternalIdPage(getController()));
addPage(new ChooseLookupFieldForRelationshipPage(getController()));
}
}

Expand Down
15 changes: 9 additions & 6 deletions src/main/resources/labels.properties
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ ExtractAllWizard.confFirstLine=You have chosen to perform an export of all recor
DataSelectionPage.csv=CSV
DataSelectionPage.hard_delete=You need the Bulk API Hard Delete user permission to permanently delete data.
DataSelectionPage.title=Step 2: Select data objects
DataSelectionPage.title=Step 2: Select Salesforce object
DataSelectionPage.description=Select your Salesforce object and your CSV file.
DataSelectionPage.selectObject=Select Salesforce object:
DataSelectionPage.showAll=&Show all Salesforce objects
Expand All @@ -227,7 +227,7 @@ ExternalIdPage.externalIdInfoExtIdExists=To match on {0}, use either the 'Id' fi
ExternalIdPage.title=Step 2a: Choose your field to use for matching
ExtractionDataSelectionPage.showAll=&Show all Salesforce objects
ExtractionDataSelectionPage.title=Step 2: Select Data Objects
ExtractionDataSelectionPage.title=Step 2: Select Salesforce object
ExtractionDataSelectionPage.description=Select your Salesforce object and your target file
ExtractionDataSelectionPage.selectSforce=Select Salesforce Object:
ExtractionDataSelectionPage.chooseTarget=Choose a target for extraction:
Expand Down Expand Up @@ -259,10 +259,13 @@ FinishPage.overwritten=
FinishPage.output=Output
FinishPage.chooseDir=Folder:
ForeignKeyExternalIdPage.title=Step 2b: (Optional) Choose lookup fields on related objects
ForeignKeyExternalIdPage.description=For each related object, select lookup fields of related objects for relationship fields. Otherwise, leave the selection blank.
ForeignKeyExternalIdPage.defaultComboText=<Not selected>
ForeignKeyExternalIdPage.pageMessage=Relationship fields of {0} are listed below, suffixed by related object name. Choose a lookup field of the related object from the dropdown if the CSV file contains values for that lookup field to reference the related object.
ChooseLookupFieldForRelationshipPage.title=Step 2b: (Optional) Map relationships to a lookup field of related objects
ChooseLookupFieldForRelationshipPage.description=For each related object, select a lookup fields of related objects for relationship fields. Otherwise, leave the selection blank.
ChooseLookupFieldForRelationshipPage.defaultComboText=<Not selected>
ChooseLookupFieldForRelationshipPage.pageMessage=Relationships of {0} are listed below.\nSelect a related object and its lookup field if the CSV refers to the related object using the selected lookup field.
ChooseLookupFieldForRelationshipPage.relationshipHeader=Relationship
ChooseLookupFieldForRelationshipPage.parentObjectHeader=Related Object
ChooseLookupFieldForRelationshipPage.parentLookupFieldHeader=Lookup Field
HardDeleteFinishPage.title=Step 4: Finish
HardDeleteFinishPage.description=Select the folder where your success and error files will be saved.
Expand Down

0 comments on commit 8ad0fba

Please sign in to comment.