Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim Jongman2018-05-11 17:55:08 +0000
committerWim Jongman2018-05-11 17:57:39 +0000
commit17355c81a7dc85dd97206a735c95180fe94b38f0 (patch)
tree2bbc9d6e5853d0d6e14cd85efabd5e999bba79df
parentb6400463660b9910904b064bd27d72bbe0c100ec (diff)
downloadeclipse.platform.ua-17355c81a7dc85dd97206a735c95180fe94b38f0.tar.gz
eclipse.platform.ua-17355c81a7dc85dd97206a735c95180fe94b38f0.tar.xz
eclipse.platform.ua-17355c81a7dc85dd97206a735c95180fe94b38f0.zip
Bug 534178: [Tips] Tip deploy job
* Abandoned internet download due to wontfix * Fixed warnings Change-Id: I93487e25b6cc179f20fb0cf7a1f3975bd16eeaf9 Signed-off-by: Wim Jongman <wim.jongman@remainsoftware.com>
-rw-r--r--org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/Startup.java44
-rw-r--r--org.eclipse.tips.json/src/org/eclipse/tips/json/JsonTipProvider.java38
-rw-r--r--org.eclipse.tips.json/src/org/eclipse/tips/json/internal/ProviderLoader.java177
-rw-r--r--org.eclipse.tips.json/src/org/eclipse/tips/json/internal/Util.java57
-rw-r--r--org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipComposite.java12
-rw-r--r--org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/ResourceManager.java9
-rw-r--r--org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/SWTResourceManager.java15
7 files changed, 81 insertions, 271 deletions
diff --git a/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/Startup.java b/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/Startup.java
index 36bfbd96c..698c0a9a0 100644
--- a/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/Startup.java
+++ b/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/Startup.java
@@ -19,7 +19,6 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.tips.core.TipProvider;
-import org.eclipse.tips.json.internal.ProviderLoader;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.UIJob;
@@ -30,10 +29,9 @@ import org.osgi.framework.FrameworkUtil;
* Early startup to run the TipManager in the IDE.
*
*/
-@SuppressWarnings("restriction")
public class Startup implements IStartup {
- private static final String BCKSLASH = "\""; //$NON-NLS-1$
+ private static final String DBLQUOTE = "\""; //$NON-NLS-1$
private static final String EQ = "="; //$NON-NLS-1$
private static final String SLASH = "/"; //$NON-NLS-1$
private static final String LT = "<"; //$NON-NLS-1$
@@ -47,43 +45,7 @@ public class Startup implements IStartup {
openManager();
}
- /**
- * Reloads the tip providers.
- */
public static void loadProviders() {
- loadInternalProviders();
- loadExternalProviders();
- }
-
- private static void loadInternalProviders() {
- getInternalProvidersJob().schedule();
- }
-
- private static Job getInternalProvidersJob() {
- Job job = new Job(Messages.Startup_0) {
-
- @Override
- protected IStatus run(IProgressMonitor pArg0) {
- String baseURL = System.getProperty("org.eclipse.tips.ide.provider.url"); //$NON-NLS-1$
- if (baseURL == null) {
- baseURL = "http://www.eclipse.org/downloads/download.php?r=1&file=/e4/tips/"; //$NON-NLS-1$
- }
- try {
- ProviderLoader.loadProviderData(IDETipManager.getInstance(), baseURL,
- IDETipManager.getStateLocation());
- } catch (Exception e) {
- Status status = new Status(IStatus.ERROR, FrameworkUtil.getBundle(Startup.class).getSymbolicName(),
- Messages.Startup_3, e);
- IDETipManager.getInstance().log(status);
- return status;
- }
- return Status.OK_STATUS;
- };
- };
- return job;
- }
-
- private static void loadExternalProviders() {
IConfigurationElement[] elements = Platform.getExtensionRegistry()
.getConfigurationElementsFor("org.eclipse.tips.core.tips"); //$NON-NLS-1$
for (IConfigurationElement element : elements) {
@@ -132,9 +94,9 @@ public class Startup implements IStartup {
String result = EMPTY;
for (String name : element.getAttributeNames()) {
result += name;
- result += EQ + BCKSLASH;
+ result += EQ + DBLQUOTE;
result += element.getAttribute(name);
- result += BCKSLASH + SPACE;
+ result += DBLQUOTE + SPACE;
}
return result;
}
diff --git a/org.eclipse.tips.json/src/org/eclipse/tips/json/JsonTipProvider.java b/org.eclipse.tips.json/src/org/eclipse/tips/json/JsonTipProvider.java
index 3a1a8dd78..566821da7 100644
--- a/org.eclipse.tips.json/src/org/eclipse/tips/json/JsonTipProvider.java
+++ b/org.eclipse.tips.json/src/org/eclipse/tips/json/JsonTipProvider.java
@@ -62,37 +62,14 @@ public abstract class JsonTipProvider extends TipProvider {
}
/**
- * Returns a specific portion of the underlying json file as a json object, if
- * the json object was not yet fetched it will be done here, making it a
- * potential costly operation. The passed part can be an array to indicate a
- * structure e.g. {"provider","variables"}.
- *
- * @param part one or more keys of the underlying json file, may not be null.
- * @return the JSon Object as a string
- * @throws IOException
- * @see {@link #loadNewTips(IProgressMonitor)}
- */
- public synchronized String getJsonObject(String... part) throws IOException {
- if (fJsonObject == null) {
- fJsonObject = loadJsonObject();
- }
- JsonObject temp = fJsonObject.getAsJsonObject(part[0]);
- for (int i = 1; i < part.length; i++) {
- temp = temp.getAsJsonObject(part[0]);
-
- }
- return temp.getAsString();
- }
-
- /**
*
* {@inheritDoc}
- *
+ *
* <p>
* <b>Implementation Details</b><br>
* The implementation of this method in this provider will fetch the json file
* and store it locally.
- *
+ *
*/
@Override
public synchronized IStatus loadNewTips(IProgressMonitor monitor) {
@@ -101,6 +78,10 @@ public abstract class JsonTipProvider extends TipProvider {
try {
subMonitor.beginTask(getDescription() + SPACE + Messages.JsonTipProvider_1, -1);
fJsonObject = loadJsonObject();
+ if (fJsonObject == null) {
+ return new Status(IStatus.INFO, "org.eclipse.tips.json",
+ MessageFormat.format("Could not parse json for {0}. Cache invalidated.", getID()), null);
+ }
JsonObject provider = fJsonObject.getAsJsonObject(JsonConstants.P_PROVIDER);
fDescription = Util.getValueOrDefault(provider, JsonConstants.P_DESCRIPTION, "not set"); //$NON-NLS-1$
fImage = Util.getValueOrDefault(provider, JsonConstants.P_IMAGE, null);
@@ -121,7 +102,12 @@ public abstract class JsonTipProvider extends TipProvider {
private JsonObject loadJsonObject() throws IOException {
try (InputStream stream = fJsonUrl.openStream(); InputStreamReader reader = new InputStreamReader(stream)) {
- return (JsonObject) new JsonParser().parse(reader);
+ Object result = new JsonParser().parse(reader);
+ if (result instanceof JsonObject) {
+ return (JsonObject) result;
+ } else {
+ return null;
+ }
}
}
diff --git a/org.eclipse.tips.json/src/org/eclipse/tips/json/internal/ProviderLoader.java b/org.eclipse.tips.json/src/org/eclipse/tips/json/internal/ProviderLoader.java
deleted file mode 100644
index 3874ad03d..000000000
--- a/org.eclipse.tips.json/src/org/eclipse/tips/json/internal/ProviderLoader.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2018 Remain Software
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * wim.jongman@remainsoftware.com - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tips.json.internal;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.StandardCopyOption;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tips.core.ITipManager;
-import org.eclipse.tips.core.internal.LogUtil;
-import org.eclipse.tips.json.JsonTipProvider;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.FrameworkUtil;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-
-/**
- * A helper class to load providers from an internet location.
- *
- */
-@SuppressWarnings("restriction")
-public class ProviderLoader {
-
- /**
- * This method loads provider information from the internet and stores it
- * locally. This method should not be called in the user interface thread.
- *
- * @param pManager the tip manager
- * @param baseURL the location of the providers.json file
- * @param stateLocation the place to store state
- */
- public static void loadProviderData(ITipManager pManager, String baseURL, File stateLocation) {
- loadProviders(pManager, baseURL, stateLocation);
- }
-
- private static void loadProviders(ITipManager pManager, String pBaseURL, File stateLocation) {
- try {
- URL webFile = new URL(pBaseURL + "index.json"); //$NON-NLS-1$
- File target = new File(stateLocation, "index.json"); //$NON-NLS-1$
- try (InputStream in = webFile.openStream()) {
- Files.copy(in, target.toPath(), StandardCopyOption.REPLACE_EXISTING);
- }
- pManager.log(LogUtil.info(String.format(Messages.ProviderLoader_1, target.toPath())));
- createProviders(pManager, target, pBaseURL, stateLocation);
- } catch (Exception e) {
- String symbolicName = FrameworkUtil.getBundle(ProviderLoader.class).getSymbolicName();
- pManager.log(new Status(IStatus.ERROR, symbolicName, Messages.ProviderLoader_3, e));
- }
- }
-
- private static void createProviders(ITipManager pManager, File pTarget, String pBaseURL, File stateLocation)
- throws Exception {
- try (FileReader reader = new FileReader(pTarget)) {
- JsonObject value = (JsonObject) new JsonParser().parse(reader);
- JsonArray providers = value.getAsJsonArray(JsonConstants.P_PROVIDER);
- providers.forEach(provider -> loadProvider(pManager, provider, pBaseURL, stateLocation));
- }
- }
-
- private static void loadProvider(ITipManager pManager, JsonElement pProvider, String pBaseURL, File userLocation) {
- JsonObject provider = pProvider.getAsJsonObject();
- String version = Util.getValueOrDefault(provider, "version", null); //$NON-NLS-1$
- String location = Util.getValueOrDefault(provider, "location", null); //$NON-NLS-1$
- String bundleName = Util.getValueOrDefault(provider, "require-bundle", null); //$NON-NLS-1$
- if (version == null || bundleName == null) {
- logInvalidProvider(pManager, provider);
- return;
- }
- pManager.log(LogUtil
- .info(String.format(Messages.ProviderLoader_0,
- location, version, bundleName)));
- Bundle bundle = Platform.getBundle(bundleName);
- if (bundle == null) {
- logInvalidProvider(pManager, provider);
- return;
- }
-
- try {
- File fileLocation = new File(userLocation, bundleName);
- if (!fileLocation.exists()) {
- fileLocation.mkdirs();
- }
-
- File versionFile = new File(fileLocation, "version.txt"); //$NON-NLS-1$
- if (!versionFile.exists()) {
- versionFile.createNewFile();
- try (FileOutputStream fos = new FileOutputStream(versionFile)) {
- fos.write(version.getBytes());
- }
- }
-
- String existingVersion = getFileContent(versionFile);
- File providerFile = new File(fileLocation, "provider.json"); //$NON-NLS-1$
- if (!version.equals(existingVersion) || !providerFile.exists()) {
- pManager.log(LogUtil.info(String.format(Messages.ProviderLoader_10, existingVersion, version)));
- URL webFile = new URL(pBaseURL + "/" + location); //$NON-NLS-1$
- try (InputStream in = webFile.openStream()) {
- Files.copy(in, providerFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
- }
- try (FileOutputStream fos = new FileOutputStream(versionFile)) {
- fos.write(version.getBytes());
- }
- }
- registerProvider(pManager, bundleName, fileLocation);
-
- } catch (IOException e) {
- String symbolicName = FrameworkUtil.getBundle(ProviderLoader.class).getSymbolicName();
- pManager.log(
- new Status(IStatus.ERROR, symbolicName,
- String.format(Messages.ProviderLoader_2, pProvider.toString()), e));
- }
- }
-
- private static void registerProvider(ITipManager pManager, String bundleName, File pFileLocation)
- throws IOException, MalformedURLException {
- JsonTipProvider tipProvider = new JsonTipProvider() {
-
- @Override
- public String getID() {
- return bundleName + ".json.provider"; //$NON-NLS-1$
- }
-
- @Override
- public synchronized IStatus loadNewTips(IProgressMonitor pMonitor) {
- getManager().log(LogUtil.info(String.format(Messages.ProviderLoader_14, getID())));
- IStatus status = super.loadNewTips(pMonitor);
- getManager().log(status);
- getManager().log(LogUtil.info(String.format(Messages.ProviderLoader_15, getID())));
- return status;
- }
- };
-
- File providerFile = new File(pFileLocation, "provider.json"); //$NON-NLS-1$
- String fileLocation = providerFile.toURI().toURL().toString();
- tipProvider.setJsonUrl(fileLocation);
- pManager.log(LogUtil.info(String.format(Messages.ProviderLoader_17, fileLocation)));
- pManager.register(tipProvider);
- }
-
- public static String getFileContent(File pVersionFile) throws IOException {
- try (FileInputStream fis = new FileInputStream(pVersionFile)) {
- try (BufferedReader br = new BufferedReader(new InputStreamReader(fis))) {
- return br.readLine();
- }
- }
- }
-
- private static void logInvalidProvider(ITipManager pManager, JsonObject pProvider) {
- String symbolicName = FrameworkUtil.getBundle(ProviderLoader.class).getSymbolicName();
- pManager.log(new Status(IStatus.ERROR, symbolicName,
- String.format(Messages.ProviderLoader_4, pProvider.toString())));
- }
-} \ No newline at end of file
diff --git a/org.eclipse.tips.json/src/org/eclipse/tips/json/internal/Util.java b/org.eclipse.tips.json/src/org/eclipse/tips/json/internal/Util.java
index af7ae80ee..04bee890e 100644
--- a/org.eclipse.tips.json/src/org/eclipse/tips/json/internal/Util.java
+++ b/org.eclipse.tips.json/src/org/eclipse/tips/json/internal/Util.java
@@ -4,8 +4,15 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.text.MessageFormat;
import java.util.Map.Entry;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.osgi.framework.FrameworkUtil;
+
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
@@ -14,7 +21,7 @@ public class Util {
/**
* Parses the passed json or returns a default value.
- *
+ *
* @param jsonObject
* @param element the value to return in case the jsonObject does not
* contain the specified value.
@@ -31,7 +38,7 @@ public class Util {
/**
* Parses the passed json or returns a default value.
- *
+ *
* @param jsonObject
* @param element the value to return in case the jsonObject does not
* contain the specified value.
@@ -48,7 +55,7 @@ public class Util {
/**
* Parses the passed json or returns a default value.
- *
+ *
* @param jsonObject
* @param element the value to return in case the jsonObject does not
* contain the specified value.
@@ -69,13 +76,13 @@ public class Util {
* {@link JsonConstants#T_VARIABLES} object then this is parsed as well.
* <p>
* Example:
- *
+ *
* <pre>
- * json object: {"first": "Wim", "last": "Jongman", "variables": {"title": "Mr.", "age": 53}}
+ * json object: {"first": "Wim", "last": "Jongman", "variables": {"title": "Mr.", "age": 53}}
* input: "${title} ${first} ${last} is ${age} years old."
* output: "Mr. Wim Jongman is 53 years old"
* </pre>
- *
+ *
* @param object the input json object
* @param input the string to scan
* @return the replaced string
@@ -108,13 +115,47 @@ public class Util {
/**
* @param input the json string representation
- * @return the parsed json object
+ * @return the parsed json object or null if a json object could not be found in
+ * the string
* @throws IOException
*/
public static JsonObject getJson(String input) throws IOException {
try (InputStream stream = new ByteArrayInputStream(input.getBytes());
InputStreamReader reader = new InputStreamReader(stream)) {
- return (JsonObject) new JsonParser().parse(reader);
+ JsonElement element = new JsonParser().parse(reader);
+ if (element instanceof JsonObject) {
+ return (JsonObject) element;
+ } else {
+ return null;
+ }
+ }
+ }
+
+ /**
+ * Checks if the URL is valid.
+ *
+ * @param pUrl
+ * @return A status indicating the result.
+ * @throws IOException
+ */
+ public static IStatus isValidUrl(String pUrl) {
+ String symbolicName = FrameworkUtil.getBundle(Util.class).getSymbolicName();
+ try {
+ URL url = new URL(pUrl);
+ HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
+ int responseCode = httpCon.getResponseCode();
+ if (responseCode != 200) {
+ return new Status(IStatus.ERROR, symbolicName, MessageFormat
+ .format("Received response code {0} from {1}.", new Object[] { responseCode + "", pUrl }));
+ }
+ if (httpCon.getContentLength() <= 0) {
+ return new Status(IStatus.ERROR, symbolicName,
+ MessageFormat.format("Received empty file from {0}.", pUrl));
+ }
+ } catch (Exception e) {
+ return new Status(IStatus.ERROR, symbolicName, MessageFormat.format("Received empty file from {0}.", pUrl),
+ e);
}
+ return Status.OK_STATUS;
}
}
diff --git a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipComposite.java b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipComposite.java
index 087683f0e..a2edd3894 100644
--- a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipComposite.java
+++ b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipComposite.java
@@ -351,11 +351,7 @@ public class TipComposite extends Composite implements ProviderSelectionListener
}
private void loadContentHtml(IHtmlTip tip) {
- try {
- fBrowser.setText(getScaling() + getHTML(tip).trim());
- } catch (IOException e) {
- fTipManager.log(LogUtil.error(getClass(), e));
- }
+ fBrowser.setText(getScaling() + getHTML(tip).trim());
}
private void loadContentUrl(IUrlTip tip) {
@@ -487,7 +483,7 @@ public class TipComposite extends Composite implements ProviderSelectionListener
+ ");</script>"; //$NON-NLS-1$
}
- private String getHTML(IHtmlTip tip) throws IOException {
+ private String getHTML(IHtmlTip tip) {
String encodedImage = encodeImage(tip);
return tip.getHTML() + encodedImage;
}
@@ -500,7 +496,7 @@ public class TipComposite extends Composite implements ProviderSelectionListener
return EMPTY;
}
- private String encodeImage(IHtmlTip tip) throws IOException {
+ private String encodeImage(IHtmlTip tip) {
TipImage image = tip.getImage();
if (image == null) {
return EMPTY;
@@ -508,7 +504,7 @@ public class TipComposite extends Composite implements ProviderSelectionListener
return encodeImageFromBase64(image);
}
- private String encodeImageFromBase64(TipImage image) throws IOException {
+ private String encodeImageFromBase64(TipImage image) {
int width = fBrowser.getClientArea().width;
int height = Math.min(fBrowser.getClientArea().height / 2, (2 * (width / 3)));
String attributes = gtkHack(image.getIMGAttributes(width, height).trim());
diff --git a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/ResourceManager.java b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/ResourceManager.java
index c5e6a3317..605fa4561 100644
--- a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/ResourceManager.java
+++ b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/ResourceManager.java
@@ -48,7 +48,7 @@ public class ResourceManager extends SWTResourceManager {
// Image
//
////////////////////////////////////////////////////////////////////////////
- private static Map<ImageDescriptor, Image> m_descriptorImageMap = new HashMap<ImageDescriptor, Image>();
+ private static Map<ImageDescriptor, Image> m_descriptorImageMap = new HashMap<>();
/**
* Returns an {@link ImageDescriptor} stored in the file at the specified path
@@ -128,18 +128,19 @@ public class ResourceManager extends SWTResourceManager {
* the corner to place decorator image.
* @return the resulting decorated {@link Image}.
*/
+ @SuppressWarnings("unused")
public static Image decorateImage(final Image baseImage, final Image decorator, final int corner) {
if (corner <= 0 || corner >= LAST_CORNER_KEY) {
throw new IllegalArgumentException(Messages.ResourceManager_0);
}
Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[corner];
if (cornerDecoratedImageMap == null) {
- cornerDecoratedImageMap = new HashMap<Image, Map<Image, Image>>();
+ cornerDecoratedImageMap = new HashMap<>();
m_decoratedImageMap[corner] = cornerDecoratedImageMap;
}
Map<Image, Image> decoratedMap = cornerDecoratedImageMap.get(baseImage);
if (decoratedMap == null) {
- decoratedMap = new HashMap<Image, Image>();
+ decoratedMap = new HashMap<>();
cornerDecoratedImageMap.put(baseImage, decoratedMap);
}
//
@@ -217,7 +218,7 @@ public class ResourceManager extends SWTResourceManager {
/**
* Maps URL to images.
*/
- private static Map<String, Image> m_URLImageMap = new HashMap<String, Image>();
+ private static Map<String, Image> m_URLImageMap = new HashMap<>();
/**
* Provider for plugin resources, used by WindowBuilder at design time.
diff --git a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/SWTResourceManager.java b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/SWTResourceManager.java
index 290ac822c..cc612e009 100644
--- a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/SWTResourceManager.java
+++ b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/SWTResourceManager.java
@@ -43,13 +43,14 @@ import org.eclipse.swt.widgets.Display;
* @author scheglov_ke
* @author Dan Rubel
*/
+@SuppressWarnings("unused")
public class SWTResourceManager {
////////////////////////////////////////////////////////////////////////////
//
// Color
//
////////////////////////////////////////////////////////////////////////////
- private static Map<RGB, Color> m_colorMap = new HashMap<RGB, Color>();
+ private static Map<RGB, Color> m_colorMap = new HashMap<>();
/**
* Returns the system {@link Color} matching the specific ID.
@@ -114,7 +115,7 @@ public class SWTResourceManager {
/**
* Maps image paths to images.
*/
- private static Map<String, Image> m_imageMap = new HashMap<String, Image>();
+ private static Map<String, Image> m_imageMap = new HashMap<>();
/**
* Returns an {@link Image} encoded by the specified {@link InputStream}.
@@ -257,12 +258,12 @@ public class SWTResourceManager {
}
Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[corner];
if (cornerDecoratedImageMap == null) {
- cornerDecoratedImageMap = new HashMap<Image, Map<Image, Image>>();
+ cornerDecoratedImageMap = new HashMap<>();
m_decoratedImageMap[corner] = cornerDecoratedImageMap;
}
Map<Image, Image> decoratedMap = cornerDecoratedImageMap.get(baseImage);
if (decoratedMap == null) {
- decoratedMap = new HashMap<Image, Image>();
+ decoratedMap = new HashMap<>();
cornerDecoratedImageMap.put(baseImage, decoratedMap);
}
//
@@ -324,11 +325,11 @@ public class SWTResourceManager {
/**
* Maps font names to fonts.
*/
- private static Map<String, Font> m_fontMap = new HashMap<String, Font>();
+ private static Map<String, Font> m_fontMap = new HashMap<>();
/**
* Maps fonts to their bold versions.
*/
- private static Map<Font, Font> m_fontToBoldFontMap = new HashMap<Font, Font>();
+ private static Map<Font, Font> m_fontToBoldFontMap = new HashMap<>();
/**
* Returns a {@link Font} based on its name, height and style.
@@ -432,7 +433,7 @@ public class SWTResourceManager {
/**
* Maps IDs to cursors.
*/
- private static Map<Integer, Cursor> m_idToCursorMap = new HashMap<Integer, Cursor>();
+ private static Map<Integer, Cursor> m_idToCursorMap = new HashMap<>();
/**
* Returns the system cursor matching the specific ID.

Back to the top