diff --git a/src/main/java/com/salesforce/dataloader/dyna/FileByteArrayConverter.java b/src/main/java/com/salesforce/dataloader/dyna/FileByteArrayConverter.java index d3c60c3a..61536c8b 100644 --- a/src/main/java/com/salesforce/dataloader/dyna/FileByteArrayConverter.java +++ b/src/main/java/com/salesforce/dataloader/dyna/FileByteArrayConverter.java @@ -111,7 +111,7 @@ public Object convert(Class type, Object value) { if (mimeType.equalsIgnoreCase("text/plain") && config != null && config.getBoolean(Config.LOAD_PRESERVE_WHITESPACE_IN_RICH_TEXT) - && "ContentNote".equalsIgnoreCase(config.getString(Config.ENTITY))) { + && AppUtil.isContentSObject(config.getString(Config.ENTITY))) { // Preserve the formatting only if the content is of type plain text // AND the flag to preserve whitespace characters in RichText fields is enabled // AND the content is for ContentNote sobject. diff --git a/src/main/java/com/salesforce/dataloader/ui/ContentLimitLink.java b/src/main/java/com/salesforce/dataloader/ui/ContentLimitLink.java new file mode 100644 index 00000000..e2872886 --- /dev/null +++ b/src/main/java/com/salesforce/dataloader/ui/ContentLimitLink.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2015, salesforce.com, inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or + * promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.salesforce.dataloader.ui; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Link; +import org.eclipse.swt.widgets.Listener; + +import com.salesforce.dataloader.config.Config; +import com.salesforce.dataloader.controller.Controller; +import com.salesforce.dataloader.util.AppUtil; + +/** + * + */ +public class ContentLimitLink extends Link { + + /** + * @param parent + * @param style + */ + private Controller controller; + + public ContentLimitLink(Composite parent, int style, Controller controller) { + super(parent, style); + this.controller = controller; + this.setText(Labels.getString("UI.contentUploadLimit")); + this.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + UIUtils.openURL(e.text); + } + }); + + // based on https://www.informit.com/articles/article.aspx?p=354574&seqNum=3 + this.addListener(SWT.Paint, new Listener() { + public void handleEvent(Event e) { + setVisible(); + } + }); + } + + public void setVisible() { + Config config = controller.getConfig(); + String operation = config.getString(Config.OPERATION); + boolean isVisible = AppUtil.isContentSObject( + config.getString(Config.ENTITY)) + && operation != null + && ("insert".equalsIgnoreCase(operation) + || "update".equalsIgnoreCase(operation) + || "upsert".equalsIgnoreCase(operation)); + setVisible(isVisible); + } + + // Based on answer at https://stackoverflow.com/questions/4264983/why-is-subclassing-not-allowed-for-many-of-the-swt-controls + @Override + protected void checkSubclass() { + // allow subclass + } + +} diff --git a/src/main/java/com/salesforce/dataloader/ui/DataSelectionDialog.java b/src/main/java/com/salesforce/dataloader/ui/DataSelectionDialog.java index 2df27cd1..b352e331 100644 --- a/src/main/java/com/salesforce/dataloader/ui/DataSelectionDialog.java +++ b/src/main/java/com/salesforce/dataloader/ui/DataSelectionDialog.java @@ -34,14 +34,11 @@ import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.Shell; import com.salesforce.dataloader.config.Config; @@ -55,7 +52,7 @@ public class DataSelectionDialog extends BaseDialog { private boolean success; private Button ok; private Label label; - private Link contentNoteLimitLink; + private ContentLimitLink contentNoteLimitLink; /** * InputDialog constructor @@ -140,10 +137,7 @@ public void run() { success = true; ok.setEnabled(true); String apiInfoStr = getController().getAPIInfo(); - String contentNoteLimitsStr = ""; - if ("ContentNote".equalsIgnoreCase(sObjectName)) { - contentNoteLimitsStr = "\n\nContentNote limits"; - } + // Set the description label.setText(Labels.getFormattedString( "DataSelectionDialog.initSuccess", String.valueOf(totalRows)) @@ -159,8 +153,7 @@ public void run() { + apiInfoStr ); //$NON-NLS-1$ - contentNoteLimitLink.setText(contentNoteLimitsStr); - label.getParent().pack(); + label.getParent().pack(); } }); @@ -193,18 +186,11 @@ protected void createContents(final Shell shell) { labelData.widthHint = 400; label.setLayoutData(labelData); - contentNoteLimitLink = new Link(shell, SWT.WRAP); - contentNoteLimitLink.setText(""); + contentNoteLimitLink = new ContentLimitLink(shell, SWT.WRAP, getController()); GridData linkData = new GridData(); linkData.horizontalSpan = 2; linkData.widthHint = 400; contentNoteLimitLink.setLayoutData(linkData); - contentNoteLimitLink.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - UIUtils.openURL(e.text); - } - }); //the bottom separator Label labelSeparatorBottom = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); diff --git a/src/main/java/com/salesforce/dataloader/ui/FinishPage.java b/src/main/java/com/salesforce/dataloader/ui/FinishPage.java index 7b2c39d7..03f05c7e 100644 --- a/src/main/java/com/salesforce/dataloader/ui/FinishPage.java +++ b/src/main/java/com/salesforce/dataloader/ui/FinishPage.java @@ -50,6 +50,7 @@ public class FinishPage extends LoadPage { private DirectoryFieldEditor dirFE; + private ContentLimitLink contentNoteLimitLink; public FinishPage(Controller controller) { this("FinishPage", controller); //$NON-NLS-1$ //$NON-NLS-2$ @@ -88,6 +89,9 @@ public void modifyText(ModifyEvent arg0) { } }); + + contentNoteLimitLink = new ContentLimitLink(comp, SWT.WRAP, getController()); + hook_createControl(comp); setControl(comp); setupPage(); @@ -122,11 +126,13 @@ public void run() { }); return false; } + setPageComplete(); IWizardContainer wizardContainer = this.getContainer(); if (wizardContainer != null) { wizardContainer.updateButtons(); } + contentNoteLimitLink.setVisible(); if (!controller.saveConfig()) return false; return true; } diff --git a/src/main/java/com/salesforce/dataloader/util/AppUtil.java b/src/main/java/com/salesforce/dataloader/util/AppUtil.java index d0052e1c..8c5a9321 100644 --- a/src/main/java/com/salesforce/dataloader/util/AppUtil.java +++ b/src/main/java/com/salesforce/dataloader/util/AppUtil.java @@ -107,6 +107,7 @@ public enum APP_RUN_MODE { private static APP_RUN_MODE appRunMode = APP_RUN_MODE.UI; private static Logger logger = null; private static String latestDownloadableDataLoaderVersion; + private static final ArrayList CONTENT_SOBJECT_LIST = new ArrayList(); static { Properties versionProps = new Properties(); @@ -121,7 +122,7 @@ public enum APP_RUN_MODE { String[] versionParts = DATALOADER_VERSION.split("\\."); DATALOADER_SHORT_VERSION=versionParts[0]; MIN_JAVA_VERSION=versionProps.getProperty("java.min.version"); - + CONTENT_SOBJECT_LIST.add("ContentNote".toLowerCase()); } public static String[] initializeAppConfig(String[] args) throws FactoryConfigurationError, IOException, ConfigInitializationException { @@ -261,10 +262,14 @@ public static void setUseGMTForDateFieldValue(boolean val) { useGMTForDateFieldValue = val; } + public static boolean isContentSObject(String sObjectName) { + return CONTENT_SOBJECT_LIST.contains(sObjectName.toLowerCase()); + } private static boolean useGMTForDateFieldValue; public static boolean isUseGMTForDateFieldValue() { return useGMTForDateFieldValue; } + private static String configurationsDir = null; public static synchronized String getConfigurationsDir() { if (configurationsDir == null) { diff --git a/src/main/resources/labels.properties b/src/main/resources/labels.properties index d8f4a735..bda18845 100644 --- a/src/main/resources/labels.properties +++ b/src/main/resources/labels.properties @@ -25,6 +25,7 @@ UI.warning=Warning UI.error=Error UI.message=Info UI.fileAlreadyExists=The file you have selected already exists. Would you like to replace the existing file? +UI.contentUploadLimit=Make sure that the Content files to be uploaded are within specified limits DataSelectionDialog.title=Data Selection DataSelectionDialog.titleError=Data Selection Error