diff --git a/src/main/java/com/salesforce/dataloader/ui/Hyperlink.java b/src/main/java/com/salesforce/dataloader/ui/Hyperlink.java deleted file mode 100644 index 6b094b3e..00000000 --- a/src/main/java/com/salesforce/dataloader/ui/Hyperlink.java +++ /dev/null @@ -1,614 +0,0 @@ -/* - * 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.*; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.widgets.*; - - -/** - * A hyperlink text label. - *

- * This control displays a line of text (with an optional underline) which can - * be clicked to send a Selection event. Colors for the text and underline in - * their normal, mouse hover and active state can be set independently. The text - * can contain a mnemonic character for triggering the link via keyboard. Unless - * the control is created with the NO_FOCUS style, it accepts keyboard focus and - * can be triggered with RETURN and SPACE while focused. - *

- * Note: This control should not be resized beyond its minimum / preferred size. - *

- *

- *
Styles: - *
NO_FOCUS
- *
Events: - *
Selection
- *
- *

- * - * @author Stefan Zeiger (szeiger@novocode.com) - * @since Mar 2, 2004 - * @version $Id: Hyperlink.java,v 1.5 2004/03/10 20:39:19 szeiger Exp $ - */ - -public final class Hyperlink extends Canvas -{ - private String text = ""; - private Cursor handCursor, arrowCursor; - private Color normalForeground, activeForeground, hoverForeground; - private Color normalUnderline, activeUndeline, hoverUnderline; - private boolean isActive; - private boolean cursorInControl; - private Rectangle cachedClientArea; - private Listener shellListener; - private Shell shell; - private int mnemonic = -1; - - - /** - * Constructs a new instance of this class given its parent - * and a style value describing its behavior and appearance. - *

- * The style value is either one of the style constants defined in - * class SWT which is applicable to instances of this - * class, or must be built by bitwise OR'ing together - * (that is, using the int "|" operator) two or more - * of those SWT style constants. The class description - * lists the style constants that are applicable to the class. - * Style bits are also inherited from superclasses. - *

- * - * @param parent a widget which will be the parent of the new instance (cannot be null) - * @param style the style of widget to construct - * - * @exception IllegalArgumentException - * @exception SWTException - */ - - public Hyperlink(Composite parent, int style) - { - super(parent, checkStyle(style)); - - handCursor = new Cursor(getDisplay(), SWT.CURSOR_HAND); - arrowCursor = new Cursor(getDisplay(), SWT.CURSOR_ARROW); - setCursor(handCursor); - - normalForeground = getDisplay().getSystemColor(SWT.COLOR_BLUE); - hoverForeground = normalForeground; - activeForeground = getDisplay().getSystemColor(SWT.COLOR_RED); - - normalUnderline = null; - hoverUnderline = normalForeground; - activeUndeline = activeForeground; - - super.setForeground(normalForeground); - - addPaintListener(new PaintListener() - { - @Override - public void paintControl(PaintEvent event) - { - onPaint(event); - } - }); - - addDisposeListener(new DisposeListener() - { - @Override - public void widgetDisposed(DisposeEvent e) - { - if(handCursor != null) - { - handCursor.dispose(); - handCursor = null; - } - if(arrowCursor != null) - { - arrowCursor.dispose(); - arrowCursor = null; - } - if(shellListener != null) - { - shell.removeListener(SWT.Activate, shellListener); - shell.removeListener(SWT.Deactivate, shellListener); - shellListener = null; - } - text = null; - } - }); - - addListener(SWT.MouseDown, new Listener() - { - @Override - public void handleEvent(Event event) - { - isActive = true; - cursorInControl = true; - redraw(); - } - }); - - addListener(SWT.MouseUp, new Listener() - { - @Override - public void handleEvent(Event event) - { - isActive = false; - redraw(); - if(cursorInControl) linkActivated(); - } - }); - - addListener(SWT.Resize, new Listener() - { - @Override - public void handleEvent(Event event) - { - cachedClientArea = getClientArea(); - } - }); - - Listener mouseListener = new Listener() - { - @Override - public void handleEvent(Event event) - { - boolean newCursorInControl = isInClientArea(event); - if(cursorInControl != newCursorInControl) - { - cursorInControl = newCursorInControl; - if(cursorInControl) setCursor(handCursor); - else if(isActive) setCursor(arrowCursor); - if(isActive || (normalForeground != hoverForeground) || (normalUnderline != hoverUnderline)) redraw(); - } - } - }; - addListener(SWT.MouseMove, mouseListener); - addListener(SWT.MouseEnter, mouseListener); - addListener(SWT.MouseExit, mouseListener); - - cachedClientArea = getClientArea(); - - if((style & SWT.NO_FOCUS) == 0) // Take focus - { - addListener(SWT.KeyDown, new Listener() - { - @Override - public void handleEvent(Event event) - { - if(event.character == ' ') linkActivated(); - } - }); - - addListener(SWT.Traverse, new Listener() - { - @Override - public void handleEvent(Event event) - { - if(event.detail == SWT.TRAVERSE_RETURN) - { - linkActivated(); - event.doit = false; - } - else if(event.detail == SWT.TRAVERSE_MNEMONIC) - { - if(mnemonic != -1 && Character.toLowerCase(event.character) == mnemonic) - { - setFocus(); - linkActivated(); - event.doit = false; - } - else event.doit = true; - } - else event.doit = true; // Accept all other traversal keys - } - }); - - addListener(SWT.FocusIn, new Listener() - { - @Override - public void handleEvent(Event event) - { - //System.out.println("FocusIn"); - redraw(); - } - }); - - addListener(SWT.FocusOut, new Listener() - { - @Override - public void handleEvent(Event event) - { - //System.out.println("FocusOut"); - redraw(); - } - }); - } - else // Don't take focus but still support mnemonics - { - addListener(SWT.Traverse, new Listener() - { - @Override - public void handleEvent(Event event) - { - if(event.detail == SWT.TRAVERSE_MNEMONIC && mnemonic != -1 && Character.toLowerCase(event.character) == mnemonic) - { - linkActivated(); - event.doit = false; - } - } - }); - } - - Composite shellComp = getParent(); - while(shellComp != null && (!(shellComp instanceof Shell))) shellComp = shellComp.getParent(); - shell = (Shell)shellComp; - - if(shell != null) - { - shellListener = new Listener() // Remove stale mouse hover on shell activation / deactivation - { - @Override - public void handleEvent(Event event) - { - boolean newCursorInControl = getDisplay().getCursorControl() == Hyperlink.this; - //System.out.println("Shell (de)activated. Cursor over control: "+newCursorInControl); - if(cursorInControl != newCursorInControl) - { - cursorInControl = newCursorInControl; - if(cursorInControl) setCursor(handCursor); - else if(isActive) setCursor(arrowCursor); - if(isActive || (normalForeground != hoverForeground) || (normalUnderline != hoverUnderline)) redraw(); - } - } - }; - - shell.addListener(SWT.Activate, shellListener); - shell.addListener(SWT.Deactivate, shellListener); - } - } - - - private void linkActivated() - { - //System.out.println("Link clicked!"); - Event e = new Event(); - e.widget = this; - e.type = SWT.Selection; - notifyListeners(SWT.Selection, e); - } - - - private boolean isInClientArea(Event event) - { - return event.x >= cachedClientArea.x && event.x < cachedClientArea.x+cachedClientArea.width && - event.y >= cachedClientArea.y && event.y < cachedClientArea.y+cachedClientArea.height; - } - - - @Override - public boolean isReparentable () - { - checkWidget (); - return false; - } - - - /** - * Check the style bits to ensure that no invalid styles are applied. - */ - - private static int checkStyle(int style) - { - style = style & SWT.NO_FOCUS; - - // [NOTE] The following transparency workaround was taken from CLabel - //TEMPORARY CODE - /* - * The default background on carbon and some GTK themes is not a solid color - * but a texture. To show the correct default background, we must allow - * the operating system to draw it and therefore, we can not use the - * NO_BACKGROUND style. The NO_BACKGROUND style is not required on platforms - * that use double buffering which is true in both of these cases. - */ - String platform = SWT.getPlatform(); - if ("carbon".equals(platform) || "gtk".equals(platform)) return style; - return style | SWT.NO_BACKGROUND; - } - - - @Override - public Point computeSize(int wHint, int hHint, boolean changed) - { - checkWidget(); - Point e = getTotalSize(text); - if (wHint != SWT.DEFAULT) e.x = wHint; - if (hHint != SWT.DEFAULT) e.y = hHint; - return e; - } - - - /** - * Compute the minimum size. - */ - - private Point getTotalSize(String text) - { - Point size = new Point(0, 0); - GC gc = new GC(this); - - if (text != null && text.length() > 0) - { - Point e = gc.textExtent(text, SWT.DRAW_MNEMONIC); - size.x += e.x; - size.y = Math.max(size.y, e.y); - } - else size.y = Math.max(size.y, gc.getFontMetrics().getHeight()); - - gc.dispose(); - return size; - } - - - /** - * Return the Hyperlink's displayed text. - * - * @return the text of the hyperlink or null - */ - - public String getText() - { - return text; - } - - - private void onPaint(PaintEvent event) - { - Rectangle rect = cachedClientArea; // getClientArea(); - if (rect.width == 0 || rect.height == 0) return; - - Point extent = getTotalSize(text); - - GC gc = event.gc; - - if ((getStyle() & SWT.NO_BACKGROUND) != 0) - { - gc.setBackground(getBackground()); - gc.fillRectangle(rect); - } - - if(isFocusControl()) gc.drawFocus(rect.x, rect.y, rect.width, rect.height); - - Color textFG, lineFG; - - if(cursorInControl) - { - textFG = isActive ? activeForeground : hoverForeground; - lineFG = isActive ? activeUndeline : hoverUnderline; - } - else - { - textFG = /* isActive ? mouseOverForeground : */ normalForeground; - lineFG = /* isActive ? mouseOverUnderline : */ normalUnderline; - } - - if(textFG == null) textFG = normalForeground; - if(textFG == null) textFG = getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND); - - int textHeight = gc.getFontMetrics().getHeight(); - - gc.setForeground(textFG); - gc.drawText(text, rect.x, rect.y + (rect.height - textHeight) / 2, SWT.DRAW_TRANSPARENT | SWT.DRAW_MNEMONIC); - - int uy = (rect.y + (rect.height - textHeight) / 2) + gc.getFontMetrics().getAscent() + gc.getFontMetrics().getLeading() + 1; - int lineWidth = extent.x > rect.width ? rect.width : extent.x; - - if(lineFG != null) - { - if(lineFG != textFG) gc.setForeground(lineFG); - gc.drawLine(rect.x, uy, rect.x + lineWidth, uy); - } - } - - - @Override - public void setForeground(Color color) - { - super.setForeground(color); - this.normalForeground = color; - redraw(); - } - - - public void setHoverForeground(Color color) - { - this.hoverForeground = color; - redraw(); - } - - - public void setActiveForeground(Color color) - { - this.activeForeground = color; - redraw(); - } - - - public void setUnderline(Color color) - { - this.normalUnderline = color; - redraw(); - } - - - public void setHoverUnderline(Color color) - { - this.hoverUnderline = color; - redraw(); - } - - - public void setActiveUnderline(Color color) - { - this.activeUndeline = color; - redraw(); - } - - - public Color getHoverForeground() - { - return this.hoverForeground; - } - - - public Color getActiveForeground() - { - return this.activeForeground; - } - - - public Color getUnderline() - { - return this.normalUnderline; - } - - - public Color getHoverUnderline() - { - return this.hoverUnderline; - } - - - public Color getActiveUnderline() - { - return this.activeUndeline; - } - - - @Override - public void setBackground(Color color) - { - super.setBackground(color); - redraw(); - } - - - @Override - public void setFont(Font font) - { - super.setFont(font); - redraw(); - } - - - /** - * Set the Hyperlink's displayed text. - * The value null clears it. - *

- * Mnemonics are indicated by an '&' that causes the next - * character to be the mnemonic. When the user presses a - * key sequence that matches the mnemonic, a selection - * event occurs. On most platforms, the mnemonic appears - * underlined but may be emphasised in a platform specific - * manner. The mnemonic indicator character '&' can be - * escaped by doubling it in the string, causing a single - * '&' to be displayed. - *

- * - * @param text the text to be displayed in the hyperlink or null - * - * @exception SWTException - */ - - public void setText(String text) - { - checkWidget(); - if (text == null) text = ""; - if (!text.equals(this.text)) - { - this.text = text; - int i = text.indexOf('&'); - if(i == -1 || i == text.length()-1) mnemonic = -1; - else mnemonic = Character.toLowerCase(text.charAt(i+1)); - redraw(); - } - } - - - /** - * Adds the listener to receive events. - * - * @param listener the listener - * - * @exception SWTError(ERROR_THREAD_INVALID_ACCESS) - * when called from the wrong thread - * @exception SWTError(ERROR_WIDGET_DISPOSED) - * when the widget has been disposed - * @exception SWTError(ERROR_NULL_ARGUMENT) - * when listener is null - */ - - public void addSelectionListener(SelectionListener listener) - { - checkWidget(); - if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - TypedListener typedListener = new TypedListener(listener); - addListener(SWT.Selection, typedListener); - addListener(SWT.DefaultSelection, typedListener); - } - - - /** - * Removes the listener. - * - * @param listener the listener - * - * @exception SWTError(ERROR_THREAD_INVALID_ACCESS) - * when called from the wrong thread - * @exception SWTError(ERROR_WIDGET_DISPOSED) - * when the widget has been disposed - * @exception SWTError(ERROR_NULL_ARGUMENT) - * when listener is null - */ - - public void removeSelectionListener(SelectionListener listener) - { - checkWidget(); - if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - removeListener(SWT.Selection, listener); - removeListener(SWT.DefaultSelection, listener); - } -} diff --git a/src/main/java/com/salesforce/dataloader/ui/HyperlinkDialog.java b/src/main/java/com/salesforce/dataloader/ui/HyperlinkDialog.java index 0d5b981f..50bb3813 100644 --- a/src/main/java/com/salesforce/dataloader/ui/HyperlinkDialog.java +++ b/src/main/java/com/salesforce/dataloader/ui/HyperlinkDialog.java @@ -26,12 +26,6 @@ package com.salesforce.dataloader.ui; -import java.awt.Desktop; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; - import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.resource.JFaceColors; import org.eclipse.jface.resource.JFaceResources; @@ -42,26 +36,13 @@ import org.eclipse.swt.widgets.*; import com.salesforce.dataloader.controller.Controller; -import com.salesforce.dataloader.util.AppUtil; public class HyperlinkDialog extends BaseDialog { private String boldMessage; - private String linkText; - private String linkURL; - - public String getLinkURL() { - return linkURL; - } - - public void setLinkURL(String linkURL) { - this.linkURL = linkURL; - } - - private Text messageLabel; private Label titleLabel; private Label titleImage; private Label titleBanner; - private Hyperlink link; + private Link link; /** * InputDialog constructor @@ -139,68 +120,24 @@ protected void createContents(final Shell shell) { titleData.left = new FormAttachment(0, 10); titleLabel.setLayoutData(titleData); - messageLabel = new Text(shell, SWT.WRAP | SWT.READ_ONLY); - messageLabel.setForeground(foreground); - messageLabel.setBackground(background); - messageLabel.setText(this.getMessage()); // two lines - messageLabel.setFont(JFaceResources.getDialogFont()); + link = new Link(shell, SWT.WRAP | SWT.READ_ONLY); + link.setForeground(foreground); + link.setBackground(background); + link.setText(this.getMessage()); // two lines + link.setFont(JFaceResources.getDialogFont()); FormData messageLabelData = new FormData(); messageLabelData.top = new FormAttachment(titleLabel, 10); messageLabelData.right = new FormAttachment(titleImage); messageLabelData.left = new FormAttachment(0, 10); // messageLabelData.bottom = new FormAttachment(titleImage, 0, SWT.BOTTOM); - messageLabel.setLayoutData(messageLabelData); - - link = new Hyperlink(shell, SWT.NONE); - link.setText(getLinkText()); - link.setBackground(background); - link.addSelectionListener(new SelectionListener() { + link.setLayoutData(messageLabelData); + link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - Thread runner = new Thread() { - @Override - public void run() { - int exitVal = 0; - if (System.getProperty("os.name").toLowerCase().indexOf("windows") >= 0) { - ArrayList cmd = new ArrayList(); - cmd.add("rundll32"); - cmd.add("url.dll,"); - cmd.add("FileProtocolHandler"); - cmd.add(getLinkURL()); - AppUtil.exec(cmd, "Browser Error"); - } else if (System.getProperty("os.name").toLowerCase().indexOf("mac") >= 0){ - Desktop desktop = Desktop.getDesktop(); - try { - desktop.browse(new URI(getLinkURL())); - } catch (URISyntaxException | IOException e) { - // TODO Auto-generated catch block - logger.error("Browser Error"); - } - } - else { - logger.error("OS is not supported."); - return; - } - - if (exitVal != 0) { - logger.error("Process exited with error" + exitVal); - } - } - }; - - runner.setPriority(Thread.MAX_PRIORITY); - runner.start(); + UIUtils.openURL(e.text); } - - @Override - public void widgetDefaultSelected(SelectionEvent e) {} }); - FormData linkData = new FormData(); - linkData.top = new FormAttachment(messageLabel); - linkData.right = new FormAttachment(titleImage); - linkData.left = new FormAttachment(0, 10); - link.setLayoutData(linkData); - + Composite greyArea = new Composite(shell, SWT.NULL); GridLayout childLayout = new GridLayout(1, false); childLayout.marginHeight = 0; @@ -251,12 +188,4 @@ public String getBoldMessage() { public void setBoldMessage(String message) { boldMessage = message; } - - public String getLinkText() { - return linkText; - } - - public void setLinkText(String linkText) { - this.linkText = linkText; - } } \ No newline at end of file diff --git a/src/main/java/com/salesforce/dataloader/ui/LoaderTitleAreaDialog.java b/src/main/java/com/salesforce/dataloader/ui/LoaderTitleAreaDialog.java index 47606963..ba874438 100644 --- a/src/main/java/com/salesforce/dataloader/ui/LoaderTitleAreaDialog.java +++ b/src/main/java/com/salesforce/dataloader/ui/LoaderTitleAreaDialog.java @@ -85,7 +85,7 @@ public static Image getImageFromRegistry(String imgKey) { Color titleAreaColor; private String message = ""; //$NON-NLS-1$ private String errorMessage; - private Link messageLabel; + private Link messageLink; private Composite workArea; private Label messageImageLabel; private Image messageImage; @@ -235,10 +235,10 @@ public void widgetDisposed(DisposeEvent e) { messageImageLabel.setBackground(background); // Message label @ bottom, center - messageLabel = new Link(parent, SWT.WRAP | SWT.READ_ONLY); - JFaceColors.setColors(messageLabel, foreground, background); - messageLabel.setText(" \n "); // two lines//$NON-NLS-1$ - messageLabel.setFont(JFaceResources.getDialogFont()); + messageLink = new Link(parent, SWT.WRAP | SWT.READ_ONLY); + JFaceColors.setColors(messageLink, foreground, background); + messageLink.setText(" \n "); // two lines//$NON-NLS-1$ + messageLink.setFont(JFaceResources.getDialogFont()); // Filler labels leftFillerLabel = new Label(parent, SWT.CENTER); leftFillerLabel.setBackground(background); @@ -248,7 +248,7 @@ public void widgetDisposed(DisposeEvent e) { determineTitleImageLargest(); if (titleImageLargest) return titleImage; - return messageLabel; + return messageLink; } /** * Determine if the title image is larger than the title message and message @@ -257,13 +257,13 @@ public void widgetDisposed(DisposeEvent e) { private void determineTitleImageLargest() { int titleY = titleImage.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; int labelY = titleLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; - labelY += messageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; - FontData[] data = messageLabel.getFont().getFontData(); + labelY += messageLink.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; + FontData[] data = messageLink.getFont().getFontData(); labelY += data[0].getHeight(); titleImageLargest = titleY > labelY; } /** - * Set the layout values for the messageLabel, messageImageLabel and + * Set the layout values for the messageLink, messageImageLabel and * fillerLabel for the case where there is a normal message. * * @param verticalSpacing @@ -277,19 +277,19 @@ private void setLayoutsForNormalMessage(int verticalSpacing, messageImageData.top = new FormAttachment(titleLabel, verticalSpacing); messageImageData.left = new FormAttachment(0, H_GAP_IMAGE); messageImageLabel.setLayoutData(messageImageData); - FormData messageLabelData = new FormData(); - messageLabelData.top = new FormAttachment(titleLabel, verticalSpacing); - messageLabelData.right = new FormAttachment(titleImage); - messageLabelData.left = new FormAttachment(messageImageLabel, + FormData messageLinkData = new FormData(); + messageLinkData.top = new FormAttachment(titleLabel, verticalSpacing); + messageLinkData.right = new FormAttachment(titleImage); + messageLinkData.left = new FormAttachment(messageImageLabel, horizontalSpacing); if (titleImageLargest) - messageLabelData.bottom = new FormAttachment(titleImage, 0, + messageLinkData.bottom = new FormAttachment(titleImage, 0, SWT.BOTTOM); - messageLabel.setLayoutData(messageLabelData); + messageLink.setLayoutData(messageLinkData); FormData fillerData = new FormData(); fillerData.left = new FormAttachment(0, horizontalSpacing); fillerData.top = new FormAttachment(messageImageLabel, 0); - fillerData.bottom = new FormAttachment(messageLabel, 0, SWT.BOTTOM); + fillerData.bottom = new FormAttachment(messageLink, 0, SWT.BOTTOM); bottomFillerLabel.setLayoutData(fillerData); FormData data = new FormData(); data.top = new FormAttachment(messageImageLabel, 0, SWT.TOP); @@ -350,24 +350,24 @@ public void setErrorMessage(String newErrorMessage) { updateMessage(message); messageImageLabel.setImage(messageImage); setImageLabelVisible(messageImage != null); - messageLabel.setToolTipText(message); + messageLink.setToolTipText(message); } else { //Add in a space for layout purposes but do not //change the instance variable String displayedErrorMessage = " " + errorMessage; //$NON-NLS-1$ updateMessage(displayedErrorMessage); - messageLabel.setToolTipText(errorMessage); + messageLink.setToolTipText(errorMessage); if (!showingError) { // we were not previously showing an error showingError = true; // lazy initialize the error background color and image if (errorMsgAreaBackground == null) { errorMsgAreaBackground = JFaceColors - .getErrorBackground(messageLabel.getDisplay()); + .getErrorBackground(messageLink.getDisplay()); errorMsgImage = getImageFromRegistry(DLG_IMG_TITLE_ERROR); } // show the error - normalMsgAreaBackground = messageLabel.getBackground(); + normalMsgAreaBackground = messageLink.getBackground(); setMessageBackgrounds(true); messageImageLabel.setImage(errorMsgImage); setImageLabelVisible(true); @@ -402,7 +402,7 @@ private void layoutForNewMessage() { data = new FormData(); data.top = new FormAttachment(messageImageLabel, 0); data.left = new FormAttachment(0, 0); - data.bottom = new FormAttachment(messageLabel, 0, SWT.BOTTOM); + data.bottom = new FormAttachment(messageLink, 0, SWT.BOTTOM); data.right = new FormAttachment(messageImageLabel, 0, SWT.RIGHT); bottomFillerLabel.setLayoutData(data); data = new FormData(); @@ -411,15 +411,15 @@ private void layoutForNewMessage() { data.bottom = new FormAttachment(messageImageLabel, 0, SWT.BOTTOM); data.right = new FormAttachment(messageImageLabel, 0); leftFillerLabel.setLayoutData(data); - FormData messageLabelData = new FormData(); - messageLabelData.top = new FormAttachment(titleLabel, + FormData messageLinkData = new FormData(); + messageLinkData.top = new FormAttachment(titleLabel, verticalSpacing); - messageLabelData.right = new FormAttachment(titleImage); - messageLabelData.left = new FormAttachment(messageImageLabel, 0); + messageLinkData.right = new FormAttachment(titleImage); + messageLinkData.left = new FormAttachment(messageImageLabel, 0); if (titleImageLargest) - messageLabelData.bottom = new FormAttachment(titleImage, 0, + messageLinkData.bottom = new FormAttachment(titleImage, 0, SWT.BOTTOM); - messageLabel.setLayoutData(messageLabelData); + messageLink.setLayoutData(messageLinkData); } //Do not layout before the dialog area has been created //to avoid incomplete calculations. @@ -504,12 +504,12 @@ private void showMessage(String newMessage, Image newImage) { updateMessage(shownMessage); messageImageLabel.setImage(messageImage); setImageLabelVisible(messageImage != null); - messageLabel.setToolTipText(message); + messageLink.setToolTipText(message); layoutForNewMessage(); } } /** - * Update the contents of the messageLabel. + * Update the contents of the messageLink. * * @param newMessage * the message to use @@ -518,8 +518,8 @@ private void updateMessage(String newMessage) { //Be sure there are always 2 lines for layout purposes if (newMessage != null && newMessage.indexOf('\n') == -1) newMessage = newMessage + "\n "; //$NON-NLS-1$ - messageLabel.setText(newMessage); - messageLabel.addSelectionListener(new SelectionAdapter() { + messageLink.setText(newMessage); + messageLink.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { UIUtils.openURL(e.text); @@ -564,7 +564,7 @@ public void setTitleImage(Image newTitleImage) { if (titleImageLargest) top = titleImage; else - top = messageLabel; + top = messageLink; resetWorkAreaAttachments(top); } } @@ -584,7 +584,7 @@ public void setBannerImage(Image newBannerImage) { if (titleImageLargest) top = titleImage; else - top = messageLabel; + top = messageLink; resetWorkAreaAttachments(top); } } @@ -613,7 +613,7 @@ private void setMessageBackgrounds(boolean showingError) { color = errorMsgAreaBackground; else color = normalMsgAreaBackground; - messageLabel.setBackground(color); + messageLink.setBackground(color); messageImageLabel.setBackground(color); bottomFillerLabel.setBackground(color); leftFillerLabel.setBackground(color); diff --git a/src/main/java/com/salesforce/dataloader/ui/uiActions/HelpUIAction.java b/src/main/java/com/salesforce/dataloader/ui/uiActions/HelpUIAction.java index 01614773..bdffdcb4 100644 --- a/src/main/java/com/salesforce/dataloader/ui/uiActions/HelpUIAction.java +++ b/src/main/java/com/salesforce/dataloader/ui/uiActions/HelpUIAction.java @@ -30,6 +30,7 @@ import com.salesforce.dataloader.controller.Controller; import com.salesforce.dataloader.ui.*; +import com.salesforce.dataloader.util.AppUtil; /** * @author Lexi Viripaeff @@ -50,11 +51,28 @@ public HelpUIAction(Controller controller) { public void run() { HyperlinkDialog dlg = new HyperlinkDialog(LoaderWindow.getApp().getShell(), controller); dlg.setText(Labels.getString("HelpUIAction.dlgTitle")); //$NON-NLS-1$ - dlg.setMessage(Labels.getString("HelpUIAction.dlgMsg")); //$NON-NLS-1$ - dlg.setLinkText(Labels.getString("HelpUIAction.dlgLinkText")); //$NON-NLS-1$ - dlg.setLinkURL(Labels.getString("HelpUIAction.dlgURL")); //$NON-NLS-1$ + dlg.setMessage( + getLoaderUpgradeMessage() + + System.getProperty("line.separator") + + Labels.getString("HelpUIAction.dlgMsg") + + System.getProperty("line.separator") + + Labels.getString("HelpUIAction.dlgLinkText") + ); //$NON-NLS-1$ dlg.setBoldMessage(Labels.getString("HelpUIAction.msgHeader")); //$NON-NLS-1$ dlg.open(); } + + private String getLoaderUpgradeMessage() { + String upgradeMsg = ""; + if (!AppUtil.DATALOADER_VERSION.equals(AppUtil.getLatestDownloadableDataLoaderVersion())) { + upgradeMsg = + Labels.getFormattedString("LoaderDownloadDialog.messageLineOne", + new String[] {AppUtil.getLatestDownloadableDataLoaderVersion(), + AppUtil.DATALOADER_DOWNLOAD_URL}) + + System.getProperty("line.separator") + + System.getProperty("line.separator"); + } + return upgradeMsg; + } } \ No newline at end of file diff --git a/src/main/resources/labels.properties b/src/main/resources/labels.properties index 1b677eac..641c378d 100644 --- a/src/main/resources/labels.properties +++ b/src/main/resources/labels.properties @@ -321,11 +321,11 @@ CSVViewerDialog.errorProcessExit=Process exiting with value: LoadFinishDialog.viewSuccess=View Successes HelpUIAction.menuText=&About -HelpUIAction.dlgTitle=Help +HelpUIAction.dlgTitle=About ${project.name} v${project.version} HelpUIAction.dlgMsg=${project.name} is an application for the bulk import or export of data. Use it\nto insert, update, delete, or extract Salesforce records. ${project.name} \ncan move data into or out of any Salesforce object.\n\nCopyright (c) 2015, salesforce.com, inc.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted\nprovided that the following conditions are met:\n\nRedistributions of source code must retain the above copyright notice, this list of conditions\nand the following disclaimer.\n\nRedistributions in binary form must reproduce the above copyright notice, this list of conditions\nand the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nNeither the name of salesforce.com, inc. nor the names of its contributors may be used to\nendorse or promote products derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS\nIS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\nEXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\nPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n -HelpUIAction.dlgLinkText=${project.name} Documentation -HelpUIAction.dlgURL=http://www.salesforce.com/us/developer/docs/dataLoader/ -HelpUIAction.msgHeader=${project.name} Help +HelpUIAction.dlgLinkText=${project.name} Documentation +HelpUIAction.dlgURL= +HelpUIAction.msgHeader=${project.name} v${project.version} HelpUIAction.tooltip=About ${project.name} LogoutUIAction.text=Logout