Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim Jongman2018-04-30 17:15:52 +0000
committerWim Jongman2018-04-30 17:24:51 +0000
commit7571f6fc8d4fd47cf1ed32fa078630ba8e2ed92d (patch)
tree190872129e266d24f7530d7055bf1a1787dd7155 /org.eclipse.tips.core
parent0042755f51c37aa19cf5f0cfea5259ef71437683 (diff)
downloadeclipse.platform.ua-7571f6fc8d4fd47cf1ed32fa078630ba8e2ed92d.tar.gz
eclipse.platform.ua-7571f6fc8d4fd47cf1ed32fa078630ba8e2ed92d.tar.xz
eclipse.platform.ua-7571f6fc8d4fd47cf1ed32fa078630ba8e2ed92d.zip
Bug 532012: [Tips] NLS Support
* Added NLS Change-Id: Idecc14956591869eb17278015ec0b45b893c5882 Signed-off-by: Wim Jongman <wim.jongman@remainsoftware.com>
Diffstat (limited to 'org.eclipse.tips.core')
-rw-r--r--org.eclipse.tips.core/META-INF/MANIFEST.MF4
-rw-r--r--org.eclipse.tips.core/OSGI-INF/l10n/bundle.properties4
-rw-r--r--org.eclipse.tips.core/build.properties3
-rw-r--r--org.eclipse.tips.core/plugin.xml2
-rw-r--r--org.eclipse.tips.core/src/org/eclipse/tips/core/Messages.java16
-rw-r--r--org.eclipse.tips.core/src/org/eclipse/tips/core/TipImage.java26
-rw-r--r--org.eclipse.tips.core/src/org/eclipse/tips/core/TipProvider.java4
-rw-r--r--org.eclipse.tips.core/src/org/eclipse/tips/core/internal/FinalTip.java12
-rw-r--r--org.eclipse.tips.core/src/org/eclipse/tips/core/internal/LogUtil.java10
-rw-r--r--org.eclipse.tips.core/src/org/eclipse/tips/core/internal/Messages.java19
-rw-r--r--org.eclipse.tips.core/src/org/eclipse/tips/core/internal/TipManager.java6
-rw-r--r--org.eclipse.tips.core/src/org/eclipse/tips/core/internal/messages.properties5
-rw-r--r--org.eclipse.tips.core/src/org/eclipse/tips/core/messages.properties2
13 files changed, 82 insertions, 31 deletions
diff --git a/org.eclipse.tips.core/META-INF/MANIFEST.MF b/org.eclipse.tips.core/META-INF/MANIFEST.MF
index 201ad389f..e769edbb4 100644
--- a/org.eclipse.tips.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.tips.core/META-INF/MANIFEST.MF
@@ -1,9 +1,9 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: Tip of the Day core plugin
+Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.tips.core;singleton:=true
Bundle-Version: 0.1.0.qualifier
-Bundle-Vendor: Eclipse Foundation
+Bundle-Vendor: %Bundle-Vendor
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.eclipse.tips.core,
org.eclipse.tips.core.internal;x-internal:=true
diff --git a/org.eclipse.tips.core/OSGI-INF/l10n/bundle.properties b/org.eclipse.tips.core/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 000000000..3648aed3b
--- /dev/null
+++ b/org.eclipse.tips.core/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,4 @@
+#Properties file for org.eclipse.tips.core
+extension-point.name = Tips
+Bundle-Vendor = Eclipse.org
+Bundle-Name = Tip of the Day core plugin \ No newline at end of file
diff --git a/org.eclipse.tips.core/build.properties b/org.eclipse.tips.core/build.properties
index 39b31f3b5..b2c97aefd 100644
--- a/org.eclipse.tips.core/build.properties
+++ b/org.eclipse.tips.core/build.properties
@@ -13,5 +13,6 @@ output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
- images/
+ images/,\
+ OSGI-INF/
src.includes = schema/
diff --git a/org.eclipse.tips.core/plugin.xml b/org.eclipse.tips.core/plugin.xml
index b29e93cdb..26f0fe91d 100644
--- a/org.eclipse.tips.core/plugin.xml
+++ b/org.eclipse.tips.core/plugin.xml
@@ -12,5 +12,5 @@
-->
<plugin>
- <extension-point id="tips" name="Tips" schema="schema/tips.exsd"/>
+ <extension-point id="tips" name="%extension-point.name" schema="schema/tips.exsd"/>
</plugin>
diff --git a/org.eclipse.tips.core/src/org/eclipse/tips/core/Messages.java b/org.eclipse.tips.core/src/org/eclipse/tips/core/Messages.java
new file mode 100644
index 000000000..e42a34b2a
--- /dev/null
+++ b/org.eclipse.tips.core/src/org/eclipse/tips/core/Messages.java
@@ -0,0 +1,16 @@
+package org.eclipse.tips.core;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.tips.core.messages"; //$NON-NLS-1$
+ public static String TipImage_5;
+ public static String TipProvider_0;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/org.eclipse.tips.core/src/org/eclipse/tips/core/TipImage.java b/org.eclipse.tips.core/src/org/eclipse/tips/core/TipImage.java
index 18a12e791..e2d917a88 100644
--- a/org.eclipse.tips.core/src/org/eclipse/tips/core/TipImage.java
+++ b/org.eclipse.tips.core/src/org/eclipse/tips/core/TipImage.java
@@ -64,9 +64,9 @@ public class TipImage {
while ((bytesRead = stream.read(chunk)) > 0) {
outputStream.write(chunk, 0, bytesRead);
}
- fBase64Image = "data:image/" //
+ fBase64Image = "data:image/" // //$NON-NLS-1$
+ getExtension() //
- + ";base64," //
+ + ";base64," // //$NON-NLS-1$
+ Base64.getEncoder().encodeToString(outputStream.toByteArray());
}
@@ -96,15 +96,15 @@ public class TipImage {
public TipImage(String base64Image) {
Assert.isNotNull(base64Image);
fURL = null;
- if (base64Image.matches("^data:image\\/.*?;base64,.*$")) {
+ if (base64Image.matches("^data:image\\/.*?;base64,.*$")) { //$NON-NLS-1$
fBase64Image = base64Image;
- int from = base64Image.indexOf("/") + 1;
- int to = base64Image.indexOf(";");
+ int from = base64Image.indexOf("/") + 1; //$NON-NLS-1$
+ int to = base64Image.indexOf(";"); //$NON-NLS-1$
setExtension(base64Image.substring(from, to).trim());
setExtension(base64Image.substring(from, to).trim());
} else {
int length = base64Image.length();
- throw new RuntimeException("Wrong base64 data " + base64Image.substring(0, length < 50 ? length : 50));
+ throw new RuntimeException(Messages.TipImage_5 + base64Image.substring(0, length < 50 ? length : 50));
}
}
@@ -260,17 +260,17 @@ public class TipImage {
int width = ImageUtil.getWidth(fAspectRatio, myWidthHint, myHeightHint);
int height = ImageUtil.getHeight(fAspectRatio, myWidthHint, myHeightHint);
- String result = "";
+ String result = ""; //$NON-NLS-1$
if (fMaxWidth == UNDEFINED) {
- result += " width=\"" + width + "\"";
+ result += " width=\"" + width + "\""; //$NON-NLS-1$ //$NON-NLS-2$
} else {
- result += " width=\"" + Math.min(fMaxWidth, width) + "\"";
+ result += " width=\"" + Math.min(fMaxWidth, width) + "\""; //$NON-NLS-1$ //$NON-NLS-2$
}
if (fMaxHeight == UNDEFINED) {
- result += " height=\"" + height + "\"";
+ result += " height=\"" + height + "\""; //$NON-NLS-1$ //$NON-NLS-2$
} else {
- result += " height=\"" + Math.min(fMaxHeight, height) + "\"";
+ result += " height=\"" + Math.min(fMaxHeight, height) + "\""; //$NON-NLS-1$ //$NON-NLS-2$
}
return result;
}
@@ -287,11 +287,11 @@ public class TipImage {
if (fExtension != null) {
return fExtension;
}
- String[] split = fURL.getPath().split("\\.");
+ String[] split = fURL.getPath().split("\\."); //$NON-NLS-1$
if (split.length > 1) {
fExtension = split[split.length - 1];
} else {
- fExtension = "png";
+ fExtension = "png"; //$NON-NLS-1$
}
return fExtension;
}
diff --git a/org.eclipse.tips.core/src/org/eclipse/tips/core/TipProvider.java b/org.eclipse.tips.core/src/org/eclipse/tips/core/TipProvider.java
index caa79cbf1..b5d0dff41 100644
--- a/org.eclipse.tips.core/src/org/eclipse/tips/core/TipProvider.java
+++ b/org.eclipse.tips.core/src/org/eclipse/tips/core/TipProvider.java
@@ -53,7 +53,7 @@ public abstract class TipProvider {
/**
* Ready property.
*/
- public static final String PROP_READY = "PR";
+ public static final String PROP_READY = "PR"; //$NON-NLS-1$
private ITipManager fTipManager;
private int fTipIndex;
@@ -272,7 +272,7 @@ public abstract class TipProvider {
// if (!getManager().isOpen()) {
// return this;
// }
- getManager().log(LogUtil.info(String.format("Setting tips")));
+ getManager().log(LogUtil.info(Messages.TipProvider_0));
doSetTips(tips, true);
fReady = true;
fChangeSupport.firePropertyChange(PROP_READY, false, true);
diff --git a/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/FinalTip.java b/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/FinalTip.java
index c752a82f8..581b24b1b 100644
--- a/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/FinalTip.java
+++ b/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/FinalTip.java
@@ -26,6 +26,9 @@ import org.osgi.framework.FrameworkUtil;
*/
public class FinalTip extends Tip implements IHtmlTip {
+ private static final String EH1 = "</h1>"; //$NON-NLS-1$
+ private static final String H1 = "<h1>"; //$NON-NLS-1$
+
/**
* Constructor.
*/
@@ -41,21 +44,20 @@ public class FinalTip extends Tip implements IHtmlTip {
@Override
public String getSubject() {
- return "No more tips";
+ return Messages.FinalTip_2;
}
@Override
public String getHTML() {
- return "<h1>There are no more tips</h1>" //
- + "This provider has no more new tips. You can toggle the " //
- + "<b>Unread</b> checkbox below or select another provider.";
+ return H1 + Messages.FinalTip_3 + EH1 //
+ + Messages.FinalTip_4;
}
@Override
public TipImage getImage() {
Bundle bundle = FrameworkUtil.getBundle(getClass());
try {
- return new TipImage(bundle.getEntry("images/nomoretips.png")).setAspectRatio(417, 640, false);
+ return new TipImage(bundle.getEntry("images/nomoretips.png")).setAspectRatio(417, 640, false); //$NON-NLS-1$
} catch (IOException e) {
// getManager().log(LogUtil.error(getClass(), e));
}
diff --git a/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/LogUtil.java b/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/LogUtil.java
index 976f4e03e..7d76881da 100644
--- a/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/LogUtil.java
+++ b/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/LogUtil.java
@@ -21,15 +21,15 @@ public class LogUtil {
}
public static IStatus error(Throwable throwable) {
- return getStatus(IStatus.ERROR, "org.eclipse.tips.core", throwable.getMessage(), throwable);
+ return getStatus(IStatus.ERROR, "org.eclipse.tips.core", throwable.getMessage(), throwable); //$NON-NLS-1$
}
public static IStatus warn(Throwable throwable) {
- return getStatus(IStatus.WARNING, "org.eclipse.tips.core", throwable.getMessage(), throwable);
+ return getStatus(IStatus.WARNING, "org.eclipse.tips.core", throwable.getMessage(), throwable); //$NON-NLS-1$
}
public static IStatus info(Throwable throwable) {
- return getStatus(IStatus.INFO, "org.eclipse.tips.core", throwable.getMessage(), throwable);
+ return getStatus(IStatus.INFO, "org.eclipse.tips.core", throwable.getMessage(), throwable); //$NON-NLS-1$
}
public static IStatus error(Class<?> clazz, Throwable throwable) {
@@ -60,10 +60,10 @@ public class LogUtil {
if (FrameworkUtil.getBundle(clazz) != null) {
return FrameworkUtil.getBundle(clazz).getSymbolicName();
}
- return "osgi.not.running";
+ return "osgi.not.running"; //$NON-NLS-1$
}
public static IStatus info(String message) {
- return getStatus(IStatus.INFO, "org.eclipse.tips.core", message, null);
+ return getStatus(IStatus.INFO, "org.eclipse.tips.core", message, null); //$NON-NLS-1$
}
} \ No newline at end of file
diff --git a/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/Messages.java b/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/Messages.java
new file mode 100644
index 000000000..2173f3777
--- /dev/null
+++ b/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/Messages.java
@@ -0,0 +1,19 @@
+package org.eclipse.tips.core.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.tips.core.internal.messages"; //$NON-NLS-1$
+ public static String FinalTip_2;
+ public static String FinalTip_3;
+ public static String FinalTip_4;
+ public static String TipManager_0;
+ public static String TipManager_2;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/TipManager.java b/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/TipManager.java
index 2c1be0d8b..564813b1c 100644
--- a/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/TipManager.java
+++ b/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/TipManager.java
@@ -12,6 +12,7 @@ package org.eclipse.tips.core.internal;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeSupport;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -73,7 +74,8 @@ public abstract class TipManager implements ITipManager {
@Override
public ITipManager register(TipProvider provider) {
checkDisposed();
- log(LogUtil.info("Registering provider: " + provider.getID() + " : " + provider.getDescription()));
+ String message = MessageFormat.format(Messages.TipManager_0, provider.getID() ,provider.getDescription());
+ log(LogUtil.info(message));
provider.setManager(this);
addToMaps(provider, Integer.valueOf(getPriority(provider)));
provider.getChangeSupport().addPropertyChangeListener(event -> {
@@ -92,7 +94,7 @@ public abstract class TipManager implements ITipManager {
private void checkDisposed() {
if (isDisposed()) {
- throw new RuntimeException("This TipManager is disposed.");
+ throw new RuntimeException(Messages.TipManager_2);
}
}
diff --git a/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/messages.properties b/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/messages.properties
new file mode 100644
index 000000000..75f6c7491
--- /dev/null
+++ b/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/messages.properties
@@ -0,0 +1,5 @@
+FinalTip_2=No more tips
+FinalTip_3=There are no more tips
+FinalTip_4=This provider has no more new tips. You can toggle the <b>Unread</b> checkbox below or select another provider.
+TipManager_0=Registering provider ID {0} with description {1}.
+TipManager_2=This TipManager is disposed.
diff --git a/org.eclipse.tips.core/src/org/eclipse/tips/core/messages.properties b/org.eclipse.tips.core/src/org/eclipse/tips/core/messages.properties
new file mode 100644
index 000000000..d955a21dc
--- /dev/null
+++ b/org.eclipse.tips.core/src/org/eclipse/tips/core/messages.properties
@@ -0,0 +1,2 @@
+TipImage_5=Wrong base64 data
+TipProvider_0=Setting tips

Back to the top