Bug 535789 - [Tips] Provide tip provider for Help
* Changed icon
* Added fixed date which us used to calculate hash
* Did some renames
Change-Id: Id019d2aae2587670a6902b57beddc17625798c73
Signed-off-by: Wim Jongman <wim.jongman@remainsoftware.com>
diff --git a/bundles/org.eclipse.platform.doc.tips/icons/48/tips.png b/bundles/org.eclipse.platform.doc.tips/icons/48/tips.png
index cd19de2..276f40b 100644
--- a/bundles/org.eclipse.platform.doc.tips/icons/48/tips.png
+++ b/bundles/org.eclipse.platform.doc.tips/icons/48/tips.png
Binary files differ
diff --git a/bundles/org.eclipse.platform.doc.tips/plugin.xml b/bundles/org.eclipse.platform.doc.tips/plugin.xml
index fc92a01..55d3b83 100644
--- a/bundles/org.eclipse.platform.doc.tips/plugin.xml
+++ b/bundles/org.eclipse.platform.doc.tips/plugin.xml
@@ -4,9 +4,17 @@
<extension
point="org.eclipse.tips.core.tips">
<provider
- class="org.eclipse.platform.doc.tips.HtmlTableProvider"
+ class="org.eclipse.platform.doc.tips.HtmlTableTipProvider"
description="Platform Tips Provider"
id="org.eclipse.platform.doc.tips">
+ <enablement>
+ <with
+ variable="activeWorkbenchWindow.activePerspective">
+ <equals
+ value="org.eclipse.ui.resourcePerspective">
+ </equals>
+ </with>
+ </enablement>
</provider>
</extension>
diff --git a/bundles/org.eclipse.platform.doc.tips/src/org/eclipse/platform/doc/tips/HtmlExtractor.java b/bundles/org.eclipse.platform.doc.tips/src/org/eclipse/platform/doc/tips/HtmlExtractor.java
index 3545b3a..7d58608 100644
--- a/bundles/org.eclipse.platform.doc.tips/src/org/eclipse/platform/doc/tips/HtmlExtractor.java
+++ b/bundles/org.eclipse.platform.doc.tips/src/org/eclipse/platform/doc/tips/HtmlExtractor.java
@@ -14,6 +14,8 @@
import java.io.IOException;
import java.net.URL;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -42,23 +44,22 @@
* in the left column and content in the right column. New and noteworthy or
* help contents from Eclipse is usually structured like that.
*
- * @param html String containing HTML
- * @param lastModifiedValue last modified date of the tip
- * @param monitor {@link IProgressMonitor}
+ * @param html String containing HTML
+ * @param monitor {@link IProgressMonitor}
* @return a list of {@link Tip} objects
* @throws OperationCanceledException
* @throws IOException
*/
- public static List<Tip> getTipsFromEclipseHtmlTable(String providerId, String html, Date lastModifiedValue,
- IProgressMonitor monitor) throws OperationCanceledException, IOException {
+ public static List<Tip> getTips(String providerId, String html, IProgressMonitor monitor)
+ throws OperationCanceledException, IOException {
Document doc = Jsoup.parse(html);
+ Date date = getDate();
Elements trElements = doc.select("tr"); //$NON-NLS-1$
if (!trElements.isEmpty()) {
List<Tip> subjectAndHtmlList = new ArrayList<>();
SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.HtmlExtractor_0, trElements.size());
for (Element element : trElements) {
- DefaultHtmlTip browserTip = createBrowserTip(providerId, lastModifiedValue, element,
- subMonitor.split(1));
+ DefaultHtmlTip browserTip = createBrowserTip(providerId, date, element, subMonitor.split(1));
subjectAndHtmlList.add(browserTip);
}
return subjectAndHtmlList;
@@ -67,6 +68,20 @@
return Collections.emptyList();
}
+ /**
+ * Date is important because it is part of the hashcode for tip used to maintain
+ * the read state.
+ *
+ * @return the photon release date date
+ */
+ private static Date getDate() {
+ try {
+ return new SimpleDateFormat("dd/MM/yyyy").parse("27/06/2018"); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (ParseException e) {
+ return null;
+ }
+ }
+
private static DefaultHtmlTip createBrowserTip(String providerId, Date lastModifiedValue, Element element,
SubMonitor subMonitor) throws IOException {
Elements tdElements = element.select("td"); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.platform.doc.tips/src/org/eclipse/platform/doc/tips/HtmlTableProvider.java b/bundles/org.eclipse.platform.doc.tips/src/org/eclipse/platform/doc/tips/HtmlTableTipProvider.java
similarity index 91%
rename from bundles/org.eclipse.platform.doc.tips/src/org/eclipse/platform/doc/tips/HtmlTableProvider.java
rename to bundles/org.eclipse.platform.doc.tips/src/org/eclipse/platform/doc/tips/HtmlTableTipProvider.java
index d5d9f76..3cd729b 100644
--- a/bundles/org.eclipse.platform.doc.tips/src/org/eclipse/platform/doc/tips/HtmlTableProvider.java
+++ b/bundles/org.eclipse.platform.doc.tips/src/org/eclipse/platform/doc/tips/HtmlTableTipProvider.java
@@ -15,7 +15,6 @@
import java.io.IOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
-import java.util.Date;
import java.util.List;
import org.apache.commons.io.IOUtils;
@@ -30,7 +29,7 @@
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
-public class HtmlTableProvider extends TipProvider {
+public class HtmlTableTipProvider extends TipProvider {
private TipImage tipImage;
@@ -61,20 +60,16 @@
@Override
public IStatus loadNewTips(IProgressMonitor monitor) {
SubMonitor subMonitor = SubMonitor.convert(monitor);
-
Bundle bundle = Platform.getBundle("org.eclipse.platform.doc.user"); //$NON-NLS-1$
URL platformTipsURL = bundle.getEntry("tips/platform_tips.html"); //$NON-NLS-1$
-
try {
String platformTipsHtmlContents = IOUtils.toString(platformTipsURL.openStream(),
StandardCharsets.UTF_8.name());
- List<Tip> browserTips = HtmlExtractor.getTipsFromEclipseHtmlTable(getID(), platformTipsHtmlContents,
- new Date(), subMonitor);
+ List<Tip> browserTips = HtmlExtractor.getTips(getID(), platformTipsHtmlContents, subMonitor);
setTips(browserTips);
} catch (IOException ex) {
return new Status(IStatus.ERROR, bundle.getSymbolicName(), ex.getMessage(), ex);
}
-
return Status.OK_STATUS;
}