Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2008-08-13 20:09:30 +0000
committerChris Goldthorpe2008-08-13 20:09:30 +0000
commit73f8b7a6d019e1742f59e77a0ce6d3bd2a74e374 (patch)
tree6d0bf0990c34c97dddc5b3d3cd93952f778023dd /org.eclipse.help
parent58f6a9da2987bc57773889d5f55b40a7fd6cfca4 (diff)
downloadeclipse.platform.ua-73f8b7a6d019e1742f59e77a0ce6d3bd2a74e374.tar.gz
eclipse.platform.ua-73f8b7a6d019e1742f59e77a0ce6d3bd2a74e374.tar.xz
eclipse.platform.ua-73f8b7a6d019e1742f59e77a0ce6d3bd2a74e374.zip
Bug 241869 – [Help] Customizable options for nav tree ordering
Diffstat (limited to 'org.eclipse.help')
-rw-r--r--org.eclipse.help/schema/helpData.exsd44
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/HelpData.java35
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java33
3 files changed, 80 insertions, 32 deletions
diff --git a/org.eclipse.help/schema/helpData.exsd b/org.eclipse.help/schema/helpData.exsd
index c3a3f44c5..d731057e9 100644
--- a/org.eclipse.help/schema/helpData.exsd
+++ b/org.eclipse.help/schema/helpData.exsd
@@ -1,10 +1,10 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
-<schema targetNamespace="Help data XML format">
+<schema targetNamespace="Help data XML format" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
- <appInfo>
- <meta.schema plugin="Help data XML format" id="" name="Help data XML format"/>
- </appInfo>
+ <appinfo>
+ <meta.schema plugin="Help data XML format" id="null" name="Help data XML format"/>
+ </appinfo>
<documentation>
The help data XML file is used by products to control the order of books in the help table of contents, as well whether or not books or keyword index sets should be displayed at all. The file must be referenced in the product&apos;s &lt;code&gt;plugin_customization.ini&lt;/code&gt; file using the &lt;code&gt;org.eclipse.help/HELP_DATA&lt;/code&gt; property.
</documentation>
@@ -104,19 +104,31 @@
</complexType>
</element>
+ <element name="otherTocs">
+ <complexType>
+ <attribute name="sort" type="boolean" use="default" value="true">
+ <annotation>
+ <documentation>
+ Defines whether the tocs not specified in tocOrder will be sorted alphabetically by title. Not sorting gives a similar order to that in Eclipse 3.3 before sorting was introduced.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
<annotation>
- <appInfo>
+ <appinfo>
<meta.section type="since"/>
- </appInfo>
+ </appinfo>
<documentation>
3.3
</documentation>
</annotation>
<annotation>
- <appInfo>
+ <appinfo>
<meta.section type="examples"/>
- </appInfo>
+ </appinfo>
<documentation>
&lt;p&gt;
The following example shows how to arrange the following books in the order shown:
@@ -162,28 +174,20 @@ The markup would be the following:
</documentation>
</annotation>
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
<annotation>
- <appInfo>
+ <appinfo>
<meta.section type="implementation"/>
- </appInfo>
+ </appinfo>
<documentation>
This API is supported by any help implementation that is based on &lt;code&gt;org.eclipse.help&lt;/code&gt;, including the default help implementation provided by Eclipse.
</documentation>
</annotation>
<annotation>
- <appInfo>
+ <appinfo>
<meta.section type="copyright"/>
- </appInfo>
+ </appinfo>
<documentation>
Copyright (c) 2006 IBM Corporation and others.&lt;br&gt;
All rights reserved. This program and the accompanying materials are made
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/HelpData.java b/org.eclipse.help/src/org/eclipse/help/internal/HelpData.java
index bb0817d2a..957c1e29c 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/HelpData.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/HelpData.java
@@ -18,12 +18,13 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.eclipse.core.runtime.IProduct;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.help.internal.util.ProductPreferences;
import org.osgi.framework.Bundle;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
@@ -42,6 +43,8 @@ public class HelpData {
private static final String ELEMENT_CATEGORY = "category"; //$NON-NLS-1$
private static final String ELEMENT_INDEX = "index"; //$NON-NLS-1$
private static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
+ private static final String ELEMENT_OTHER_TOCS = "otherTocs"; //$NON-NLS-1$
+ private static final String ATTRIBUTE_SORT = "sort"; //$NON-NLS-1$
private static final String PLUGINS_ROOT_SLASH = "PLUGINS_ROOT/"; //$NON-NLS-1$
private static HelpData productHelpData;
@@ -50,6 +53,7 @@ public class HelpData {
private List tocOrder;
private Set hiddenTocs;
private Set hiddenIndexes;
+ private String sortMode;
/*
* Get the active product's help data, or null if the product doesn't have
@@ -79,6 +83,9 @@ public class HelpData {
productHelpData = new HelpData(helpDataUrl);
}
}
+ if (productHelpData == null) {
+ productHelpData = new HelpData(null);
+ }
}
return productHelpData;
}
@@ -129,6 +136,16 @@ public class HelpData {
}
return hiddenIndexes;
}
+
+ /*
+ * Returns true if tocs not specified in the toc order are sorted
+ */
+ public synchronized boolean isSortOthers() {
+ if (sortMode == null) {
+ loadHelpData();
+ }
+ return "true".equals(sortMode); //$NON-NLS-1$
+ }
/*
* Allow unit tests to override for providing test data.
@@ -144,6 +161,7 @@ public class HelpData {
tocOrder = new ArrayList();
hiddenTocs = new HashSet();
hiddenIndexes = new HashSet();
+ sortMode = "true"; //$NON-NLS-1$
if (url != null) {
try {
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
@@ -154,6 +172,15 @@ public class HelpData {
String msg = "Error loading help data file \"" + url + "\""; //$NON-NLS-1$ //$NON-NLS-2$
HelpPlugin.logError(msg, t);
}
+ } else {
+ // Derive information from preferences
+ Preferences prefs = HelpPlugin.getDefault().getPluginPreferences();
+ String baseTocs = prefs.getString(HelpPlugin.BASE_TOCS_KEY);
+ String ignoredTocs = prefs.getString(HelpPlugin.IGNORED_TOCS_KEY);
+ String ignoredIndexes = prefs.getString(HelpPlugin.IGNORED_INDEXES_KEY);
+ tocOrder = ProductPreferences.tokenize(baseTocs);
+ hiddenTocs.addAll(ProductPreferences.tokenize(ignoredTocs));
+ hiddenIndexes.addAll(ProductPreferences.tokenize(ignoredIndexes));
}
}
@@ -192,6 +219,12 @@ public class HelpData {
hiddenIndexes.add(id);
}
}
+ else if (ELEMENT_OTHER_TOCS.equals(name)) {
+ String sortAttribute = attributes.getValue(ATTRIBUTE_SORT);
+ if (sortAttribute != null) {
+ sortMode = sortAttribute.toLowerCase();
+ }
+ }
}
/* (non-Javadoc)
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java b/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java
index 5d472bacf..de6cf3905 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java
@@ -20,6 +20,7 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -76,13 +77,14 @@ public class ProductPreferences {
public static List getPrimaryTocOrdering() {
if (primaryTocOrdering == null) {
IProduct product = Platform.getProduct();
+ String pluginId = null;
if (product != null) {
- String pluginId = product.getDefiningBundle().getSymbolicName();
- Preferences prefs = HelpPlugin.getDefault().getPluginPreferences();
- String helpDataFile = prefs.getString(HelpPlugin.HELP_DATA_KEY);
- String baseTOCS = prefs.getString(HelpPlugin.BASE_TOCS_KEY);
- primaryTocOrdering = getTocOrdering(pluginId, helpDataFile, baseTOCS);
+ pluginId = product.getDefiningBundle().getSymbolicName();
}
+ Preferences prefs = HelpPlugin.getDefault().getPluginPreferences();
+ String helpDataFile = prefs.getString(HelpPlugin.HELP_DATA_KEY);
+ String baseTOCS = prefs.getString(HelpPlugin.BASE_TOCS_KEY);
+ primaryTocOrdering = getTocOrdering(pluginId, helpDataFile, baseTOCS);
// active product has no preference for toc order
if (primaryTocOrdering == null) {
primaryTocOrdering = new ArrayList();
@@ -129,7 +131,10 @@ public class ProductPreferences {
helpDataPath = helpDataFile.substring(nextSlash + 1);
}
}
- Bundle bundle = Platform.getBundle(helpDataPluginId);
+ Bundle bundle = null;
+ if (helpDataPluginId != null) {
+ bundle = Platform.getBundle(helpDataPluginId);
+ }
if (bundle != null) {
URL helpDataUrl = bundle.getEntry(helpDataPath);
HelpData helpData = new HelpData(helpDataUrl);
@@ -186,7 +191,7 @@ public class ProductPreferences {
*/
public static List getOrderedList(List items, List primary, List[] secondary, Map nameIdMap) {
List result = new ArrayList();
- Set set = new HashSet(items);
+ Set set = new LinkedHashSet(items);
if (orderResolver == null) {
orderResolver = new SequenceResolver();
}
@@ -199,12 +204,14 @@ public class ProductPreferences {
set.remove(obj);
}
}
- List remaining = new ArrayList();
- remaining.addAll(set);
- if (nameIdMap != null) {
+ if (HelpData.getProductHelpData().isSortOthers() && nameIdMap != null) {
+ List remaining = new ArrayList();
+ remaining.addAll(set);
sortByName(remaining, nameIdMap);
+ result.addAll(remaining);
+ } else {
+ result.addAll(set);
}
- result.addAll(remaining);
return result;
}
@@ -388,4 +395,8 @@ public class ProductPreferences {
// TODO Auto-generated method stub
return 0;
}
+
+ public static void resetPrimaryTocOrdering() {
+ primaryTocOrdering = null;
+ }
}

Back to the top