diff options
author | Dejan Gloszic | 2006-01-30 23:14:39 +0000 |
---|---|---|
committer | Dejan Gloszic | 2006-01-30 23:14:39 +0000 |
commit | 8a8a8fcc9d036d0e69d179cdb1849549ba9d7457 (patch) | |
tree | 9860fe78a5fc2a04aa621365a47997e4cd8b68fc | |
parent | 75567553c1ad70fdb0420cf1bbbae3341d825ccf (diff) | |
download | eclipse.platform.ua-20060130.tar.gz eclipse.platform.ua-20060130.tar.xz eclipse.platform.ua-20060130.zip |
*** empty log message ***v20060130
53 files changed, 2297 insertions, 66 deletions
diff --git a/org.eclipse.help.ui/plugin.properties b/org.eclipse.help.ui/plugin.properties index 305c9950b..9a1b82f20 100644 --- a/org.eclipse.help.ui/plugin.properties +++ b/org.eclipse.help.ui/plugin.properties @@ -49,7 +49,5 @@ dynamicHelpAction.label = Dynamic Help dynamicHelpAction.tooltip = Dynamic Help #Commands -command.category.help.name = Help -command.category.help.description = Commands relating to the Help system command.closeTray.name = Close User Assistance Tray command.closeTray.description = Close the user assistance tray containing context help information and cheat sheets. diff --git a/org.eclipse.help.ui/plugin.xml b/org.eclipse.help.ui/plugin.xml index 49a176719..1b778b797 100644 --- a/org.eclipse.help.ui/plugin.xml +++ b/org.eclipse.help.ui/plugin.xml @@ -126,16 +126,12 @@ <extension point="org.eclipse.ui.commands"> <command - categoryId="org.eclipse.help.ui.category.help" + categoryId="org.eclipse.ui.category.help" defaultHandler="org.eclipse.help.ui.internal.CloseHelpTrayHandler" description="%command.closeTray.description" id="org.eclipse.help.ui.closeTray" name="%command.closeTray.name"> </command> - <category - description="%command.category.help.description" - id="org.eclipse.help.ui.category.help" - name="%command.category.help.name"/> </extension> <extension point="org.eclipse.ui.bindings"> diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/xhtml/UIContentFilterProcessor.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/xhtml/UIContentFilterProcessor.java index 64462d678..e6cd1a9b8 100644 --- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/xhtml/UIContentFilterProcessor.java +++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/xhtml/UIContentFilterProcessor.java @@ -21,7 +21,7 @@ import org.eclipse.ui.activities.WorkbenchActivityHelper; */ public class UIContentFilterProcessor extends UAContentFilterProcessor { - protected boolean isFilteredIn(String filter, String value) { + public boolean isFilteredIn(String filter, String value) { boolean filtered_in = false; if (filter.equals("category")) { //$NON-NLS-1$ filtered_in = filterByCategory(value); diff --git a/org.eclipse.help/META-INF/MANIFEST.MF b/org.eclipse.help/META-INF/MANIFEST.MF index a12eff88f..8a26b7a3c 100644 --- a/org.eclipse.help/META-INF/MANIFEST.MF +++ b/org.eclipse.help/META-INF/MANIFEST.MF @@ -14,6 +14,6 @@ Export-Package: org.eclipse.help, org.eclipse.help.internal.protocols;x-friends:="org.eclipse.help.base,org.eclipse.help.ui,org.eclipse.help.webapp", org.eclipse.help.internal.toc;x-friends:="org.eclipse.help.base,org.eclipse.help.ui,org.eclipse.help.webapp", org.eclipse.help.internal.util;x-friends:="org.eclipse.help.base,org.eclipse.help.ui,org.eclipse.help.webapp", - org.eclipse.help.internal.xhtml;x-friends:="org.eclipse.help.ui" + org.eclipse.help.internal.xhtml;x-friends:="org.eclipse.help.ui,org.eclipse.ui.intro" Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.1.0,4.0.0)" Eclipse-LazyStart: true diff --git a/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentFilterProcessor.java b/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentFilterProcessor.java index 2856b4e2c..a3f647b42 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentFilterProcessor.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentFilterProcessor.java @@ -115,7 +115,7 @@ public class UAContentFilterProcessor { * @param value * @return */ - protected boolean isFilteredIn(String filter, String value) { + public boolean isFilteredIn(String filter, String value) { boolean filtered_in = false; if (filter.equals("ws")) { //$NON-NLS-1$ filtered_in = filterByWS(value); diff --git a/org.eclipse.help/src/org/eclipse/help/internal/xhtml/XHTMLSupport.java b/org.eclipse.help/src/org/eclipse/help/internal/xhtml/XHTMLSupport.java index 9ab50dcf6..46574b999 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/xhtml/XHTMLSupport.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/xhtml/XHTMLSupport.java @@ -53,6 +53,9 @@ public class XHTMLSupport { return document; } + public static UAContentFilterProcessor getFilterProcessor() { + return filterProcessor; + } /** * Used by the UI plugin to override base functionality and add more filtering capabilities. diff --git a/org.eclipse.ua.tests/META-INF/MANIFEST.MF b/org.eclipse.ua.tests/META-INF/MANIFEST.MF index d9f46af17..e5f427745 100644 --- a/org.eclipse.ua.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.ua.tests/META-INF/MANIFEST.MF @@ -11,7 +11,8 @@ Require-Bundle: org.junit, org.eclipse.help.appserver, org.eclipse.ui, org.eclipse.ui.cheatsheets, - org.eclipse.ui.intro + org.eclipse.ui.intro, + org.eclipse.help.ui Eclipse-LazyStart: true Bundle-Vendor: Eclipse.org Bundle-ClassPath: ua-tests.jar diff --git a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java index f0cf48862..1d3867aa4 100644 --- a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java +++ b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java @@ -10,24 +10,46 @@ *******************************************************************************/ package org.eclipse.ua.tests.util; -import java.io.BufferedReader; -import java.io.FileReader; +import java.io.ByteArrayOutputStream; +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; + +import org.osgi.framework.Bundle; /* * Utility methods for working with files. */ public class FileUtil { - public static String getContents(String path) throws IOException { - BufferedReader in = new BufferedReader(new FileReader(path)); - StringBuffer buf = new StringBuffer(); - String line = null; - while ((line = in.readLine()) != null) { - buf.append(line); - buf.append("\n"); + /** + * Gets the contents of the file with the given relative path in the given bundle, + * as a String (file must + * be encoded as UTF-8). + */ + public static String getContents(Bundle bundle, String relativePath) throws IOException { + return readString(bundle.getEntry(relativePath).openStream()); + } + + /** + * Gets the contents of the file with the given absolute path as a String (file must + * be encoded as UTF-8). + */ + public static String getContents(String absolutePath) throws IOException { + return readString(new FileInputStream(absolutePath)); + } + + /** + * Reads the contents of the input stream as UTF-8 and constructs and returns + * as a String. + */ + private static String readString(InputStream in) throws IOException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + byte[] buffer = new byte[4096]; + int num; + while ((num = in.read(buffer)) > 0) { + out.write(buffer, 0, num); } - in.close(); - return buf.toString(); + return new String(out.toByteArray(), "UTF-8"); } } diff --git a/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/composite/AllCompositeTests.java b/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/composite/AllCompositeTests.java index ebc27c60f..0090705f6 100644 --- a/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/composite/AllCompositeTests.java +++ b/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/composite/AllCompositeTests.java @@ -18,7 +18,7 @@ public class AllCompositeTests { public static Test suite() { TestSuite suite = new TestSuite( - "Test for org.eclipse.ua.tests.cheatsheet.AllCompositeTests"); + "org.eclipse.ua.tests.cheatsheet.AllCompositeTests"); //$JUnit-BEGIN$ suite.addTestSuite(TestCompositeParser.class); suite.addTestSuite(TestEventing.class); diff --git a/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/execution/AllExecutionTests.java b/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/execution/AllExecutionTests.java index 58b4e20a9..993a8326b 100644 --- a/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/execution/AllExecutionTests.java +++ b/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/execution/AllExecutionTests.java @@ -12,6 +12,7 @@ public class AllExecutionTests { TestSuite suite = new TestSuite( "org.eclipse.ua.tests.cheatsheet.AllExecutionTests"); //$JUnit-BEGIN$ + suite.addTestSuite(TestVariableSubstitution.class); suite.addTestSuite(TestActionExecution.class); suite.addTestSuite(TestCommandExecution.class); //$JUnit-END$ diff --git a/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/execution/CommandHandler.java b/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/execution/CommandHandler.java index 185bb6489..e64815875 100644 --- a/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/execution/CommandHandler.java +++ b/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/execution/CommandHandler.java @@ -24,6 +24,14 @@ import org.eclipse.core.commands.ExecutionException; */ public class CommandHandler extends AbstractHandler { + public static final String RESULT_TO_STRING = "RESULT_TO_STRING"; + + public class CommandResult { + public String toString() { + return RESULT_TO_STRING; + } + } + private static Map params; private static int timesCompleted; private static boolean throwException; @@ -45,7 +53,7 @@ public class CommandHandler extends AbstractHandler { timesCompleted++; - return null; + return new CommandResult(); } public static Map getParams() { diff --git a/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/execution/MockCheatSheetManager.java b/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/execution/MockCheatSheetManager.java new file mode 100644 index 000000000..6039a5c98 --- /dev/null +++ b/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/execution/MockCheatSheetManager.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2005 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.ua.tests.cheatsheet.execution; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.ui.cheatsheets.ICheatSheetManager; + +/** + * Mock object used in JUnit tests for command execution + */ + +public class MockCheatSheetManager implements ICheatSheetManager { + + private Map dataStore = new HashMap(); + public String getCheatSheetID() { + return "Mock"; + } + + public String getData(String key) { + return (String)dataStore.get(key); + } + + public void setData(String key, String data) { + dataStore.put(key, data); + } + +} diff --git a/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/execution/TestCommandExecution.java b/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/execution/TestCommandExecution.java index 57fc17a34..0359e7e8b 100644 --- a/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/execution/TestCommandExecution.java +++ b/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/execution/TestCommandExecution.java @@ -24,6 +24,7 @@ import org.eclipse.core.commands.common.NotDefinedException; import org.eclipse.core.runtime.IStatus; import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin; import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.cheatsheets.ICheatSheetManager; import org.eclipse.ui.commands.ICommandService; import org.eclipse.ui.internal.cheatsheets.CommandRunner; import org.eclipse.ui.internal.cheatsheets.data.CheatSheetCommand; @@ -44,7 +45,7 @@ public class TestCommandExecution extends TestCase { private static final String SERIALIZED_COMMAND = COMMAND_ID + '(' + PARAM1_ID + '=' + PARAM1_VALUE + ',' + PARAM2_ID + '=' + PARAM2_VALUE + ')'; - // "org.eclipse.ui.views.showView(org.eclipse.ui.views.showView.viewId=org.eclipse.ui.views.TaskList)"; + private static final String RETURN_STORE = "retData"; protected void setUp() throws Exception { CommandHandler.reset(); @@ -95,27 +96,44 @@ public class TestCommandExecution extends TestCase { public void testCommandRunner() { CheatSheetCommand command = new CheatSheetCommand(); + ICheatSheetManager csm = new MockCheatSheetManager(); command.setSerialization(SERIALIZED_COMMAND); - IStatus status = new CommandRunner().executeCommand(command); + IStatus status = new CommandRunner().executeCommand(command, csm); assertTrue(status.isOK()); checkCommandExecution(); } + public void testCommandWithResult() { + CheatSheetCommand command = new CheatSheetCommand(); + ICheatSheetManager csm = new MockCheatSheetManager(); + command.setSerialization(SERIALIZED_COMMAND); + command.setReturns(RETURN_STORE); + + IStatus status = new CommandRunner().executeCommand(command, csm); + assertTrue(status.isOK()); + String result = csm.getData(RETURN_STORE); + assertNotNull(result); + assertEquals(CommandHandler.RESULT_TO_STRING, result); + checkCommandExecution(); + } + public void testInvalidCommandId() { CheatSheetCommand command = new CheatSheetCommand(); + ICheatSheetManager csm = new MockCheatSheetManager(); command.setSerialization(COMMAND_ID + ".invalid"); //$NON-NLS-1$ - IStatus status = new CommandRunner().executeCommand(command); + IStatus status = new CommandRunner().executeCommand(command, csm); assertFalse(status.isOK()); } public void testCommandException() { CheatSheetCommand command = new CheatSheetCommand(); + ICheatSheetManager csm = new MockCheatSheetManager(); command.setSerialization(SERIALIZED_COMMAND); CommandHandler.setThrowException(true); - IStatus status = new CommandRunner().executeCommand(command); + IStatus status = new CommandRunner().executeCommand(command, csm); assertFalse(status.isOK()); } diff --git a/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/execution/TestVariableSubstitution.java b/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/execution/TestVariableSubstitution.java new file mode 100644 index 000000000..3f1f942e2 --- /dev/null +++ b/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/execution/TestVariableSubstitution.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2005 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.ua.tests.cheatsheet.execution; + +/** + * Test variable substitution in cheatsheets. This functionality is used by + * command execution + */ + +import org.eclipse.ui.cheatsheets.ICheatSheetManager; +import org.eclipse.ui.internal.cheatsheets.views.CheatSheetManager; + +import junit.framework.TestCase; + +public class TestVariableSubstitution extends TestCase { + private ICheatSheetManager manager; + + protected void setUp() throws Exception { + manager = new MockCheatSheetManager(); + manager.setData("p1", "one"); + manager.setData("p2", "two"); + } + + private String substitute(String input) { + return CheatSheetManager.performVariableSubstitution(input, manager); + } + + public void testNoSubstitution() { + assertEquals("abcdefg", substitute("abcdefg")); + } + + public void testFullString() { + assertEquals("one", substitute("${p1}")); + } + + public void testEmbeddedString() { + assertEquals("AoneB", substitute("A${p1}B")); + } + + public void testRepeatedSubstitution() { + assertEquals("oneXone", substitute("${p1}X${p1}")); + } + + public void testMultipleSubstitution() { + assertEquals("onetwo", substitute("${p1}${p2}")); + } + + public void testNonexistentParameter() { + assertEquals("one", substitute("${p1}${p3}")); + } + + public void testUnterminatedParameter() { + assertEquals("${p1", "${p1"); + } + + +} diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor.xhtml b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor.xhtml new file mode 100644 index 000000000..a8e3aaf20 --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor.xhtml @@ -0,0 +1,22 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<!-- + The anchor test page. This page contains an anchor, and content is contributed into the anchor + from an intro extension. See ext.xml in the same folder. +--> + +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<title>anchor.xhtml</title> +</head> + +<body> +<h2>anchor.xhtml</h2> +<p> +This page contains an anchor, where other pages can contribute content to it. In this case there should +be one contribution from anchor2.xhtml below: +</p> +<anchor id="my.anchor.id"/> +</body> +</html> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor2.xhtml b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor2.xhtml new file mode 100644 index 000000000..eef8c5e70 --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor2.xhtml @@ -0,0 +1,19 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<!-- + This page contains content that is contributed into an anchor in anchor.xhtml. This file is + referenced by ext.xhtml. When viewed you don't see this page, only the line that is contributed. +--> + +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<title>anchor.xhtml</title> +</head> + +<body> +<ul> +<li>This text comes from anchor2.xhtml and is contributed into an anchor in anchor.xhtml.</li> +</ul> +</body> +</html> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor2_serialized.txt b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor2_serialized.txt new file mode 100644 index 000000000..251808bed --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor2_serialized.txt @@ -0,0 +1,16 @@ +<!-- + This page contains content that is contributed into an anchor in anchor.xhtml. This file is + referenced by ext.xhtml. When viewed you don't see this page, only the line that is contributed. +--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + +<title>anchor.xhtml</title> +</head> + +<body> +<ul> +<li>This text comes from anchor2.xhtml and is contributed into an anchor in anchor.xhtml.</li> +</ul> +</body> +</html> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor_serialized.txt b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor_serialized.txt new file mode 100644 index 000000000..9540a2f68 --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor_serialized.txt @@ -0,0 +1,21 @@ +<!-- + The anchor test page. This page contains an anchor, and content is contributed into the anchor + from an intro extension. See ext.xml in the same folder. +--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + +<title>anchor.xhtml</title> +</head> + +<body> +<h2>anchor.xhtml</h2> +<p> +This page contains an anchor, where other pages can contribute content to it. In this case there should +be one contribution from anchor2.xhtml below: +</p> +<ul> +<li>This text comes from anchor2.xhtml and is contributed into an anchor in anchor.xhtml.</li> +</ul> +</body> +</html> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/filter.xhtml b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/filter.xhtml new file mode 100644 index 000000000..f073924c8 --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/filter.xhtml @@ -0,0 +1,84 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<!-- + The filter examples page. This tests filtering in intro XHTML. When viewed, this page + displays facts about your environment. For example, your os is linux, your ws is gtk, etc. + All the other content should be filtered out. +--> + +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<title>filter.xhtml</title> +</head> + +<body> +<h2>filter.xhtml</h2> +<p> +This page contains filtered content. +</p> +<ul> +<li filter="os=win32">Your OS is <strong>win32</strong>.</li> +<li filter="os=linux">Your OS is <strong>linux</strong>.</li> +<li filter="os=macosx">Your OS is <strong>macosx</strong>.</li> + +<!-- should never appear --> +<li filter="os=invalid">This line should never appear.</li> + +<li filter="ws=win32">Your WS is <strong>win32</strong>.</li> +<li filter="ws=gtk">Your WS is <strong>gtk</strong>.</li> +<li filter="ws=carbon">Your WS is <strong>carbon</strong>.</li> + +<!-- should never appear --> +<li filter="ws=invalid">This line should never appear.</li> + +<li filter="arch=x86">Your ARCH is <strong>x86</strong>.</li> +<li filter="arch=ppc">Your ARCH is <strong>ppc</strong>.</li> + +<!-- should never appear --> +<li filter="arch=invalid">Your ARCH is <strong>invalid</strong>.</li> +<li> +<filter name="os" value="win32"/> +<filter name="ws" value="win32"/> +Your OS is <strong>win32</strong> AND your WS is <strong>win32</strong>. +</li> +<li> +<filter name="os" value="linux"/> +<filter name="ws" value="gtk"/> +Your OS is <strong>linux</strong> AND your WS is <strong>gtk</strong>. +</li> +<li> +<filter name="os" value="macosx"/> +<filter name="ws" value="carbon"/> +Your OS is <strong>macosx</strong> AND your WS is <strong>carbon</strong>. +</li> + +<!-- should never appear --> +<li> +<filter name="os" value="win32"/> +<filter name="ws" value="invalid"/> +Your OS is <strong>win32</strong> AND your WS is <strong>invalid</strong>. +</li> + +<li filter="plugin=org.eclipse.help">The plugin <code>org.eclipse.help</code> is installed.</li> + +<!-- should never appear --> +<li filter="plugin=invalid">The plugin <code>invalid</code> is installed.</li> + +<li filter="product=org.eclipse.sdk.ide">The product <code>org.eclipse.sdk.ide</code> is running.</li> + +<!-- should never appear --> +<li filter="product=invalid">The product <code>invalid</code> is running.</li> + +<li filter="category=org.eclipse.categories.developmentCategory">The category <code>org.eclipse.categories.developmentCategory</code> is enabled.</li> + +<!-- should never appear --> +<li filter="category=invalid">The category <code>invalid</code> is enabled.</li> + +<li filter="activity=org.eclipse.javaDevelopment">The activity <code>org.eclipse.javaDevelopment</code> is enabled.</li> + +<!-- should never appear --> +<li filter="activity=invalid">The activity <code>invalid</code> is enabled.</li> +</ul> +</body> +</html> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/filter_serialized_linux_gtk_x86.txt b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/filter_serialized_linux_gtk_x86.txt new file mode 100644 index 000000000..56c91ec81 --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/filter_serialized_linux_gtk_x86.txt @@ -0,0 +1,69 @@ +<!-- + The filter examples page. This tests filtering in intro XHTML. When viewed, this page + displays facts about your environment. For example, your os is linux, your ws is gtk, etc. + All the other content should be filtered out. +--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + +<title>filter.xhtml</title> +</head> + +<body> +<h2>filter.xhtml</h2> +<p> +This page contains filtered content. +</p> +<ul> +<li filter="os=linux">Your OS is <strong>linux</strong>.</li> + + + +<!-- should never appear --> + + +<li filter="ws=gtk">Your WS is <strong>gtk</strong>.</li> + + + +<!-- should never appear --> + + +<li filter="arch=x86">Your ARCH is <strong>x86</strong>.</li> + + +<!-- should never appear --> + +<li> +<filter name="os" value="linux" /> +<filter name="ws" value="gtk" /> +Your OS is <strong>linux</strong> AND your WS is <strong>gtk</strong>. +</li> + + + +<!-- should never appear --> + + +<li filter="plugin=org.eclipse.help">The plugin <code>org.eclipse.help</code> is installed.</li> + +<!-- should never appear --> + + +<li filter="product=org.eclipse.sdk.ide">The product <code>org.eclipse.sdk.ide</code> is running.</li> + +<!-- should never appear --> + + +<li filter="category=org.eclipse.categories.developmentCategory">The category <code>org.eclipse.categories.developmentCategory</code> is enabled.</li> + +<!-- should never appear --> + + +<li filter="activity=org.eclipse.javaDevelopment">The activity <code>org.eclipse.javaDevelopment</code> is enabled.</li> + +<!-- should never appear --> + +</ul> +</body> +</html> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/filter_serialized_macosx_carbon_ppc.txt b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/filter_serialized_macosx_carbon_ppc.txt new file mode 100644 index 000000000..63685d8e3 --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/filter_serialized_macosx_carbon_ppc.txt @@ -0,0 +1,69 @@ +<!-- + The filter examples page. This tests filtering in intro XHTML. When viewed, this page + displays facts about your environment. For example, your os is linux, your ws is gtk, etc. + All the other content should be filtered out. +--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + +<title>filter.xhtml</title> +</head> + +<body> +<h2>filter.xhtml</h2> +<p> +This page contains filtered content. +</p> +<ul> +<li filter="os=macosx">Your OS is <strong>macosx</strong>.</li> + + + +<!-- should never appear --> + + +<li filter="ws=carbon">Your WS is <strong>carbon</strong>.</li> + + + +<!-- should never appear --> + + +<li filter="arch=ppc">Your ARCH is <strong>ppc</strong>.</li> + + +<!-- should never appear --> + +<li> +<filter name="os" value="macosx" /> +<filter name="ws" value="carbon" /> +Your OS is <strong>macosx</strong> AND your WS is <strong>carbon</strong>. +</li> + + + +<!-- should never appear --> + + +<li filter="plugin=org.eclipse.help">The plugin <code>org.eclipse.help</code> is installed.</li> + +<!-- should never appear --> + + +<li filter="product=org.eclipse.sdk.ide">The product <code>org.eclipse.sdk.ide</code> is running.</li> + +<!-- should never appear --> + + +<li filter="category=org.eclipse.categories.developmentCategory">The category <code>org.eclipse.categories.developmentCategory</code> is enabled.</li> + +<!-- should never appear --> + + +<li filter="activity=org.eclipse.javaDevelopment">The activity <code>org.eclipse.javaDevelopment</code> is enabled.</li> + +<!-- should never appear --> + +</ul> +</body> +</html> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/filter_serialized_win32_win32_x86.txt b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/filter_serialized_win32_win32_x86.txt new file mode 100644 index 000000000..4e00a4367 --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/filter_serialized_win32_win32_x86.txt @@ -0,0 +1,69 @@ +<!-- + The filter examples page. This tests filtering in intro XHTML. When viewed, this page + displays facts about your environment. For example, your os is linux, your ws is gtk, etc. + All the other content should be filtered out. +--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + +<title>filter.xhtml</title> +</head> + +<body> +<h2>filter.xhtml</h2> +<p> +This page contains filtered content. +</p> +<ul> +<li filter="os=win32">Your OS is <strong>win32</strong>.</li> + + + +<!-- should never appear --> + + +<li filter="ws=win32">Your WS is <strong>win32</strong>.</li> + + + +<!-- should never appear --> + + +<li filter="arch=x86">Your ARCH is <strong>x86</strong>.</li> + + +<!-- should never appear --> + +<li> +<filter name="os" value="win32" /> +<filter name="ws" value="win32" /> +Your OS is <strong>win32</strong> AND your WS is <strong>win32</strong>. +</li> + + + +<!-- should never appear --> + + +<li filter="plugin=org.eclipse.help">The plugin <code>org.eclipse.help</code> is installed.</li> + +<!-- should never appear --> + + +<li filter="product=org.eclipse.sdk.ide">The product <code>org.eclipse.sdk.ide</code> is running.</li> + +<!-- should never appear --> + + +<li filter="category=org.eclipse.categories.developmentCategory">The category <code>org.eclipse.categories.developmentCategory</code> is enabled.</li> + +<!-- should never appear --> + + +<li filter="activity=org.eclipse.javaDevelopment">The activity <code>org.eclipse.javaDevelopment</code> is enabled.</li> + +<!-- should never appear --> + +</ul> +</body> +</html> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/include.xhtml b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/include.xhtml new file mode 100644 index 000000000..ce4319fda --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/include.xhtml @@ -0,0 +1,21 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<!-- + The include test page. This page includes a line from include2.xhtml. +--> + +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<title>include.xhtml</title> +</head> + +<body> +<h2>include.xhtml</h2> +<p> +This page contains include examples. Below there should be one line of text that is included from +another file, include2.xhtml: +</p> +<include path="include2/my.include.id"/> +</body> +</html> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/include2.xhtml b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/include2.xhtml new file mode 100644 index 000000000..8570752dc --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/include2.xhtml @@ -0,0 +1,20 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<!-- + This page contains a line with an ID that is included from another page (include.xhtml). + You don't ever see this page when viewed. +--> + +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<title>include2.xhtml</title> +</head> + +<body> +<h2>include2.xhtml</h2> +<ul id="my.include.id"> +<li>This text comes from include2.xhtml and can be included by other documents.</li> +</ul> +</body> +</html> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/include2_serialized.txt b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/include2_serialized.txt new file mode 100644 index 000000000..85c25dc46 --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/include2_serialized.txt @@ -0,0 +1,17 @@ +<!-- + This page contains a line with an ID that is included from another page (include.xhtml). + You don't ever see this page when viewed. +--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + +<title>include2.xhtml</title> +</head> + +<body> +<h2>include2.xhtml</h2> +<ul id="my.include.id"> +<li>This text comes from include2.xhtml and can be included by other documents.</li> +</ul> +</body> +</html> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/include_serialized.txt b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/include_serialized.txt new file mode 100644 index 000000000..9f6dadd97 --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/include_serialized.txt @@ -0,0 +1,20 @@ +<!-- + The include test page. This page includes a line from include2.xhtml. +--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + +<title>include.xhtml</title> +</head> + +<body> +<h2>include.xhtml</h2> +<p> +This page contains include examples. Below there should be one line of text that is included from +another file, include2.xhtml: +</p> +<ul id="my.include.id"> +<li>This text comes from include2.xhtml and can be included by other documents.</li> +</ul> +</body> +</html> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/root.xhtml b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/root.xhtml new file mode 100644 index 000000000..df0a9ebee --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/root.xhtml @@ -0,0 +1,27 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<!-- + This is the main intro page that contains links to the various example test pages. + See the referenced pages for more details. There is no dynamic content on this page. +--> + +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<title>root.xhtml</title> +</head> + +<body> +<h2>root.xhtml</h2> +<div class="page-style"> + +<ul> +<li><a href="http://org.eclipse.ui.intro/showPage?id=static">static.xhtml</a></li> +<li><a href="http://org.eclipse.ui.intro/showPage?id=filter">filter.xhtml</a></li> +<li><a href="http://org.eclipse.ui.intro/showPage?id=include">include.xhtml</a></li> +<li><a href="http://org.eclipse.ui.intro/showPage?id=anchor">anchor.xhtml</a></li> +</ul> + +</div> +</body> +</html> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/root_serialized.txt b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/root_serialized.txt new file mode 100644 index 000000000..2f050e2e5 --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/root_serialized.txt @@ -0,0 +1,24 @@ +<!-- + This is the main intro page that contains links to the various example test pages. + See the referenced pages for more details. There is no dynamic content on this page. +--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + +<title>root.xhtml</title> +</head> + +<body> +<h2>root.xhtml</h2> +<div class="page-style"> + +<ul> +<li><a href="http://org.eclipse.ui.intro/showPage?id=static" shape="rect">static.xhtml</a></li> +<li><a href="http://org.eclipse.ui.intro/showPage?id=filter" shape="rect">filter.xhtml</a></li> +<li><a href="http://org.eclipse.ui.intro/showPage?id=include" shape="rect">include.xhtml</a></li> +<li><a href="http://org.eclipse.ui.intro/showPage?id=anchor" shape="rect">anchor.xhtml</a></li> +</ul> + +</div> +</body> +</html> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/static.xhtml b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/static.xhtml new file mode 100644 index 000000000..722635d9e --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/static.xhtml @@ -0,0 +1,19 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<!-- + A static XHTML page for sanity test. No dynamic content here. +--> + +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<title>static.xhtml</title> +</head> + +<body> +<h2>static.xhtml</h2> +<p> +This page contains static XHTML content only. +</p> +</body> +</html> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/static_serialized.txt b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/static_serialized.txt new file mode 100644 index 000000000..65a3c3779 --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/static_serialized.txt @@ -0,0 +1,16 @@ +<!-- + A static XHTML page for sanity test. No dynamic content here. +--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + +<title>static.xhtml</title> +</head> + +<body> +<h2>static.xhtml</h2> +<p> +This page contains static XHTML content only. +</p> +</body> +</html> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/ext.xml b/org.eclipse.ua.tests/data/intro/dynamicXHTML/ext.xml new file mode 100644 index 000000000..8d6215016 --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/ext.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + An extension to introContent.xml with an additional page and a contribution to an anchor. +--> +<introContent> + <extensionContent content="content/anchor2.xhtml" path="anchor/my.anchor.id" /> + <page id="anchor2" content="content/anchor2.xhtml"/> +</introContent> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/introContent.xml b/org.eclipse.ua.tests/data/intro/dynamicXHTML/introContent.xml new file mode 100644 index 000000000..7f9845dc1 --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/introContent.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!-- + This is an intro used to test dynamic content with XHTML files. This lists all the pages, and + the referenced XHTML files contain the content. See the files for more details. +--> +<introContent> + <page id="root" content="content/root.xhtml"/> + <page id="static" content="content/static.xhtml"/> + <page id="filter" content="content/filter.xhtml"/> + <page id="include" content="content/include.xhtml"/> + <page id="include2" content="content/include2.xhtml"/> + <page id="anchor" content="content/anchor.xhtml"/> +</introContent> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/introContent_serialized.txt b/org.eclipse.ua.tests/data/intro/dynamicXHTML/introContent_serialized.txt new file mode 100644 index 000000000..3d4d8af5b --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/introContent_serialized.txt @@ -0,0 +1,109 @@ + +Intro Model Content: +====================== + +Model has valid config = true +Presentation type = 2 +Home page id = root +Number of pages (not including Root Page) = 6 +Number of shared groups = 0 +Number of unresolved extensions = 0 + +HOME PAGE: +-------------- + is dynamic= true + id = root + title = null + style = null + alt-style = null + url = null + style-id = null + page styles are = + page alt-styles are = + page children = 0 + + +PAGE id = static +---------- + title = null + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 0 + + +PAGE id = filter +---------- + title = null + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 0 + + +PAGE id = include +---------- + title = null + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 0 + + +PAGE id = include2 +---------- + title = null + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 0 + + +PAGE id = anchor +---------- + title = null + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 0 + + +PAGE id = anchor2 +---------- + title = null + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 0 + + +Model Flag Tests: +---------------- + First page children are: + Groups: 0 + Links: 0 + Texts: 0 + HTMLs: 0 + Images: 0 + Includes: 0 + Page Titles: 0 + Page Heads: 0 + Model Elements: 0 + Containers: 0 + All Pages: 0 + Anchors: 0 + Content providers: 0 + Elements with Text child(AbstractTextElemets): 0 + Groups and Links: 0 diff --git a/org.eclipse.ua.tests/data/intro/dynamicXML/ext.xml b/org.eclipse.ua.tests/data/intro/dynamicXML/ext.xml new file mode 100644 index 000000000..d7ff0aa99 --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXML/ext.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + An extension to the dynamicXML test intro that contributes a group into an anchor. + The link should appear in the anchor examples page (see introContent.xml in same folder). +--> +<introContent> + <!-- + The group below will be placed where the anchor is in the anchor page in introContent.xml in + the same folder. + --> + <extensionContent path="anchor/my.id.anchor"> + <group> + <link label="This link is from extension content ext.xml and is to be contributed into a page with an anchor." url="http://org.eclipse.ui.intro/showPage?id=anchor"/> + </group> + </extensionContent> +</introContent> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXML/introContent.xml b/org.eclipse.ua.tests/data/intro/dynamicXML/introContent.xml new file mode 100644 index 000000000..333083765 --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXML/introContent.xml @@ -0,0 +1,147 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!-- + An intro for testing dynamic content in intro XML. This is a very simple intro with no + images or graphics that has filtering, includes and anchor examples. +--> +<introContent> + + <!-- + The main page, containing links to the various examples. + --> + <page id="root"> + <title>Dynamic XML Intro</title> + <group> + <link label="Static Content Example" url="http://org.eclipse.ui.intro/showPage?id=static"/> + </group> + <group> + <link label="Filter Example" url="http://org.eclipse.ui.intro/showPage?id=filter"/> + </group> + <group> + <link label="Include Example" url="http://org.eclipse.ui.intro/showPage?id=include"/> + </group> + <group> + <link label="Anchor Example" url="http://org.eclipse.ui.intro/showPage?id=anchor"/> + </group> + </page> + + <!-- + A simple static page that shows one link, no dynamic content. Used as a sanity test. + --> + <page id="static"> + <title>Static Content Example</title> + <group> + <link label="This page contains static content only." url="http://org.eclipse.ui.intro/showPage?id=static"/> + </group> + </page> + + <!-- + The filter examples page. Has links that are os/ws/arch/etc specific. When viewed, this page + should state facts about your environment. For exmaple, your OS is win32, your WS is win32, etc. + --> + <page id="filter"> + <title>Filter Example</title> + <group> + <link filter="os=win32" label="Your OS is win32." url="http://org.eclipse.ui.intro/showPage?id=filter"/> + <link filter="os=linux" label="Your OS is linux." url="http://org.eclipse.ui.intro/showPage?id=filter"/> + <link filter="os=macosx" label="Your OS is macosx." url="http://org.eclipse.ui.intro/showPage?id=filter"/> + + <!-- should never appear --> + <link filter="os=invalid" label="Your OS is invalid." url="http://org.eclipse.ui.intro/showPage?id=filter"/> + </group> + <group> + <link filter="ws=win32" label="Your WS is win32." url="http://org.eclipse.ui.intro/showPage?id=filter"/> + <link filter="ws=gtk" label="Your WS is gtk." url="http://org.eclipse.ui.intro/showPage?id=filter"/> + <link filter="ws=carbon" label="Your WS is carbon." url="http://org.eclipse.ui.intro/showPage?id=filter"/> + + <!-- should never appear --> + <link filter="ws=invalid" label="Your WS is invalid." url="http://org.eclipse.ui.intro/showPage?id=filter"/> + </group> + <group> + <link filter="arch=x86" label="Your ARCH is x86." url="http://org.eclipse.ui.intro/showPage?id=filter"/> + <link filter="arch=ppc" label="Your ARCH is ppc." url="http://org.eclipse.ui.intro/showPage?id=filter"/> + + <!-- should never appear --> + <link filter="arch=invalid" label="Your ARCH is invalid." url="http://org.eclipse.ui.intro/showPage?id=filter"/> + </group> + <group> + <link label="Your OS is win32 AND your WS is win32." url="http://org.eclipse.ui.intro/showPage?id=filter"> + <filter name="os" value="win32"/> + <filter name="ws" value="win32"/> + </link> + <link label="Your OS is linux AND your WS is gtk." url="http://org.eclipse.ui.intro/showPage?id=filter"> + <filter name="os" value="linux"/> + <filter name="ws" value="gtk"/> + </link> + <link label="Your OS is macosx AND your WS is carbon." url="http://org.eclipse.ui.intro/showPage?id=filter"> + <filter name="os" value="macosx"/> + <filter name="ws" value="carbon"/> + </link> + + <!-- should never appear --> + <link label="Your OS is win32 AND your WS is invalid." url="http://org.eclipse.ui.intro/showPage?id=filter"> + <filter name="os" value="win32"/> + <filter name="ws" value="invalid"/> + </link> + </group> + <group> + <link filter="plugin=org.eclipse.help" label="The plugin org.eclipse.help is installed." url="http://org.eclipse.ui.intro/showPage?id=filter"/> + + <!-- should never appear --> + <link filter="plugin=invalid" label="The plugin invalid is installed." url="http://org.eclipse.ui.intro/showPage?id=filter"/> + </group> + <group> + <link filter="product=org.eclipse.sdk.ide" label="The product org.eclipse.sdk.ide is running." url="http://org.eclipse.ui.intro/showPage?id=filter"/> + + <!-- should never appear --> + <link filter="plugin=invalid" label="The product invalid is running." url="http://org.eclipse.ui.intro/showPage?id=filter"/> + </group> + <group> + <link filter="category=org.eclipse.categories.developmentCategory" label="The category org.eclipse.categories.developmentCategory is enabled." url="http://org.eclipse.ui.intro/showPage?id=filter"/> + + <!-- should never appear --> + <link filter="category=invalid" label="The category invalid is enabled." url="http://org.eclipse.ui.intro/showPage?id=filter"/> + </group> + <group> + <link filter="activity=org.eclipse.javaDevelopment" label="The activity org.eclipse.javaDevelopment is enabled." url="http://org.eclipse.ui.intro/showPage?id=filter"/> + + <!-- should never appear --> + <link filter="activity=invalid" label="The activity invalid is enabled." url="http://org.eclipse.ui.intro/showPage?id=filter"/> + </group> + </page> + + <!-- + The include examples page. The include should bring in the group from the page include2 below. + There should be two links on this page when viewed. + --> + <page id="include"> + <title>Include Example</title> + <group> + <link label="There should be one link below included from another page." url="http://org.eclipse.ui.intro/showPage?id=include"/> + </group> + <include path="include2/my.id.include2"/> + </page> + + <!-- + You never actually see this page, it is only used to define a group that is included in page + "include" above. + --> + <page id="include2"> + <title>Include Example 2</title> + <group id="my.id.include2"> + <link label="This link is from page id=include2 and is to be included into other pages." url="http://org.eclipse.ui.intro/showPage?id=include"/> + </group> + </page> + + <!-- + The anchor examples page. This page contains an anchor. The content is contributed from an intro + extension. See ext.xml in the same folder. + --> + <page id="anchor"> + <title>Anchor Example</title> + <group> + <link label="There is an anchor below this link that should be populated from another page." url="http://org.eclipse.ui.intro/showPage?id=anchor"/> + </group> + <anchor id="my.id.anchor"/> + </page> + +</introContent> diff --git a/org.eclipse.ua.tests/data/intro/dynamicXML/introContent_serialized_linux_gtk_x86.txt b/org.eclipse.ua.tests/data/intro/dynamicXML/introContent_serialized_linux_gtk_x86.txt new file mode 100644 index 000000000..ee4adc03f --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXML/introContent_serialized_linux_gtk_x86.txt @@ -0,0 +1,279 @@ + +Intro Model Content: +====================== + +Model has valid config = true +Presentation type = 2 +Home page id = root +Number of pages (not including Root Page) = 5 +Number of shared groups = 0 +Number of unresolved extensions = 0 + +HOME PAGE: +-------------- + is dynamic= true + id = root + title = Dynamic XML Intro + style = null + alt-style = null + url = null + style-id = null + page styles are = + page alt-styles are = + page children = 5 + + TITLE: id = null + title = Dynamic XML Intro + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Static Content Example + text = null + url = http://org.eclipse.ui.intro/showPage?id=static + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Filter Example + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Include Example + text = null + url = http://org.eclipse.ui.intro/showPage?id=include + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Anchor Example + text = null + url = http://org.eclipse.ui.intro/showPage?id=anchor + style-id = null + +PAGE id = static +---------- + title = Static Content Example + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 2 + + TITLE: id = null + title = Static Content Example + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = This page contains static content only. + text = null + url = http://org.eclipse.ui.intro/showPage?id=static + style-id = null + +PAGE id = filter +---------- + title = Filter Example + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 9 + + TITLE: id = null + title = Filter Example + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Your OS is linux. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Your WS is gtk. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Your ARCH is x86. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Your OS is linux AND your WS is gtk. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = The plugin org.eclipse.help is installed. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = The product org.eclipse.sdk.ide is running. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = The category org.eclipse.categories.developmentCategory is enabled. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = The activity org.eclipse.javaDevelopment is enabled. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + +PAGE id = include +---------- + title = Include Example + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 3 + + TITLE: id = null + title = Include Example + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = There should be one link below included from another page. + text = null + url = http://org.eclipse.ui.intro/showPage?id=include + style-id = null + GROUP: id = my.id.include2 + label = null + children = 1 + style-id = null + LINK: id = null + label = This link is from page id=include2 and is to be included into other pages. + text = null + url = http://org.eclipse.ui.intro/showPage?id=include + style-id = null + +PAGE id = include2 +---------- + title = Include Example 2 + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 2 + + TITLE: id = null + title = Include Example 2 + style-id = null + GROUP: id = my.id.include2 + label = null + children = 1 + style-id = null + LINK: id = null + label = This link is from page id=include2 and is to be included into other pages. + text = null + url = http://org.eclipse.ui.intro/showPage?id=include + style-id = null + +PAGE id = anchor +---------- + title = Anchor Example + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 4 + + TITLE: id = null + title = Anchor Example + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = There is an anchor below this link that should be populated from another page. + text = null + url = http://org.eclipse.ui.intro/showPage?id=anchor + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = This link is from extension content ext.xml and is to be contributed into a page with an anchor. + text = null + url = http://org.eclipse.ui.intro/showPage?id=anchor + style-id = null + ANCHOR: id = my.id.anchor + +Model Flag Tests: +---------------- + First page children are: + Groups: 1 + Links: 0 + Texts: 0 + HTMLs: 0 + Images: 0 + Includes: 0 + Page Titles: 1 + Page Heads: 0 + Model Elements: 2 + Containers: 1 + All Pages: 0 + Anchors: 0 + Content providers: 0 + Elements with Text child(AbstractTextElemets): 0 + Groups and Links: 1 diff --git a/org.eclipse.ua.tests/data/intro/dynamicXML/introContent_serialized_macosx_carbon_ppc.txt b/org.eclipse.ua.tests/data/intro/dynamicXML/introContent_serialized_macosx_carbon_ppc.txt new file mode 100644 index 000000000..c2b422514 --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXML/introContent_serialized_macosx_carbon_ppc.txt @@ -0,0 +1,279 @@ + +Intro Model Content: +====================== + +Model has valid config = true +Presentation type = 2 +Home page id = root +Number of pages (not including Root Page) = 5 +Number of shared groups = 0 +Number of unresolved extensions = 0 + +HOME PAGE: +-------------- + is dynamic= true + id = root + title = Dynamic XML Intro + style = null + alt-style = null + url = null + style-id = null + page styles are = + page alt-styles are = + page children = 5 + + TITLE: id = null + title = Dynamic XML Intro + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Static Content Example + text = null + url = http://org.eclipse.ui.intro/showPage?id=static + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Filter Example + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Include Example + text = null + url = http://org.eclipse.ui.intro/showPage?id=include + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Anchor Example + text = null + url = http://org.eclipse.ui.intro/showPage?id=anchor + style-id = null + +PAGE id = static +---------- + title = Static Content Example + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 2 + + TITLE: id = null + title = Static Content Example + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = This page contains static content only. + text = null + url = http://org.eclipse.ui.intro/showPage?id=static + style-id = null + +PAGE id = filter +---------- + title = Filter Example + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 9 + + TITLE: id = null + title = Filter Example + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Your OS is macosx. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Your WS is carbon. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Your ARCH is ppc. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Your OS is macosx AND your WS is carbon. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = The plugin org.eclipse.help is installed. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = The product org.eclipse.sdk.ide is running. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = The category org.eclipse.categories.developmentCategory is enabled. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = The activity org.eclipse.javaDevelopment is enabled. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + +PAGE id = include +---------- + title = Include Example + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 3 + + TITLE: id = null + title = Include Example + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = There should be one link below included from another page. + text = null + url = http://org.eclipse.ui.intro/showPage?id=include + style-id = null + GROUP: id = my.id.include2 + label = null + children = 1 + style-id = null + LINK: id = null + label = This link is from page id=include2 and is to be included into other pages. + text = null + url = http://org.eclipse.ui.intro/showPage?id=include + style-id = null + +PAGE id = include2 +---------- + title = Include Example 2 + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 2 + + TITLE: id = null + title = Include Example 2 + style-id = null + GROUP: id = my.id.include2 + label = null + children = 1 + style-id = null + LINK: id = null + label = This link is from page id=include2 and is to be included into other pages. + text = null + url = http://org.eclipse.ui.intro/showPage?id=include + style-id = null + +PAGE id = anchor +---------- + title = Anchor Example + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 4 + + TITLE: id = null + title = Anchor Example + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = There is an anchor below this link that should be populated from another page. + text = null + url = http://org.eclipse.ui.intro/showPage?id=anchor + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = This link is from extension content ext.xml and is to be contributed into a page with an anchor. + text = null + url = http://org.eclipse.ui.intro/showPage?id=anchor + style-id = null + ANCHOR: id = my.id.anchor + +Model Flag Tests: +---------------- + First page children are: + Groups: 1 + Links: 0 + Texts: 0 + HTMLs: 0 + Images: 0 + Includes: 0 + Page Titles: 1 + Page Heads: 0 + Model Elements: 2 + Containers: 1 + All Pages: 0 + Anchors: 0 + Content providers: 0 + Elements with Text child(AbstractTextElemets): 0 + Groups and Links: 1 diff --git a/org.eclipse.ua.tests/data/intro/dynamicXML/introContent_serialized_win32_win32_x86.txt b/org.eclipse.ua.tests/data/intro/dynamicXML/introContent_serialized_win32_win32_x86.txt new file mode 100644 index 000000000..8f242151d --- /dev/null +++ b/org.eclipse.ua.tests/data/intro/dynamicXML/introContent_serialized_win32_win32_x86.txt @@ -0,0 +1,279 @@ + +Intro Model Content: +====================== + +Model has valid config = true +Presentation type = 2 +Home page id = root +Number of pages (not including Root Page) = 5 +Number of shared groups = 0 +Number of unresolved extensions = 0 + +HOME PAGE: +-------------- + is dynamic= true + id = root + title = Dynamic XML Intro + style = null + alt-style = null + url = null + style-id = null + page styles are = + page alt-styles are = + page children = 5 + + TITLE: id = null + title = Dynamic XML Intro + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Static Content Example + text = null + url = http://org.eclipse.ui.intro/showPage?id=static + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Filter Example + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Include Example + text = null + url = http://org.eclipse.ui.intro/showPage?id=include + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Anchor Example + text = null + url = http://org.eclipse.ui.intro/showPage?id=anchor + style-id = null + +PAGE id = static +---------- + title = Static Content Example + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 2 + + TITLE: id = null + title = Static Content Example + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = This page contains static content only. + text = null + url = http://org.eclipse.ui.intro/showPage?id=static + style-id = null + +PAGE id = filter +---------- + title = Filter Example + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 9 + + TITLE: id = null + title = Filter Example + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Your OS is win32. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Your WS is win32. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Your ARCH is x86. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = Your OS is win32 AND your WS is win32. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = The plugin org.eclipse.help is installed. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = The product org.eclipse.sdk.ide is running. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = The category org.eclipse.categories.developmentCategory is enabled. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = The activity org.eclipse.javaDevelopment is enabled. + text = null + url = http://org.eclipse.ui.intro/showPage?id=filter + style-id = null + +PAGE id = include +---------- + title = Include Example + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 3 + + TITLE: id = null + title = Include Example + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = There should be one link below included from another page. + text = null + url = http://org.eclipse.ui.intro/showPage?id=include + style-id = null + GROUP: id = my.id.include2 + label = null + children = 1 + style-id = null + LINK: id = null + label = This link is from page id=include2 and is to be included into other pages. + text = null + url = http://org.eclipse.ui.intro/showPage?id=include + style-id = null + +PAGE id = include2 +---------- + title = Include Example 2 + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 2 + + TITLE: id = null + title = Include Example 2 + style-id = null + GROUP: id = my.id.include2 + label = null + children = 1 + style-id = null + LINK: id = null + label = This link is from page id=include2 and is to be included into other pages. + text = null + url = http://org.eclipse.ui.intro/showPage?id=include + style-id = null + +PAGE id = anchor +---------- + title = Anchor Example + style = null + alt-style = null + style-id = null + page styles are = + page alt-styles are = + page children = 4 + + TITLE: id = null + title = Anchor Example + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = There is an anchor below this link that should be populated from another page. + text = null + url = http://org.eclipse.ui.intro/showPage?id=anchor + style-id = null + GROUP: id = null + label = null + children = 1 + style-id = null + LINK: id = null + label = This link is from extension content ext.xml and is to be contributed into a page with an anchor. + text = null + url = http://org.eclipse.ui.intro/showPage?id=anchor + style-id = null + ANCHOR: id = my.id.anchor + +Model Flag Tests: +---------------- + First page children are: + Groups: 1 + Links: 0 + Texts: 0 + HTMLs: 0 + Images: 0 + Includes: 0 + Page Titles: 1 + Page Heads: 0 + Model Elements: 2 + Containers: 1 + All Pages: 0 + Anchors: 0 + Content providers: 0 + Elements with Text child(AbstractTextElemets): 0 + Groups and Links: 1 diff --git a/org.eclipse.ua.tests/data/intro/platform/serialized.txt b/org.eclipse.ua.tests/data/intro/platform/serialized.txt index a12fa8745..ad5e07c6b 100644 --- a/org.eclipse.ua.tests/data/intro/platform/serialized.txt +++ b/org.eclipse.ua.tests/data/intro/platform/serialized.txt @@ -531,4 +531,4 @@ Model Flag Tests: Anchors: 0 Content providers: 0 Elements with Text child(AbstractTextElemets): 0 - Groups and Links: 3
\ No newline at end of file + Groups and Links: 3 diff --git a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/parser/ValidTest.java b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/parser/ValidTest.java index 1c353565d..d13a73bf5 100644 --- a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/parser/ValidTest.java +++ b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/parser/ValidTest.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.ua.tests.intro.parser; +import java.util.Iterator; +import java.util.Map; import java.util.StringTokenizer; import junit.framework.Assert; @@ -19,12 +21,14 @@ import junit.framework.TestSuite; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.Platform; +import org.eclipse.help.ui.internal.HelpUIPlugin; import org.eclipse.ua.tests.intro.util.IntroModelSerializer; import org.eclipse.ua.tests.intro.util.IntroModelSerializerTest; import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin; import org.eclipse.ua.tests.util.FileUtil; import org.eclipse.ui.internal.intro.impl.model.IntroModelRoot; import org.eclipse.ui.internal.intro.impl.model.loader.ExtensionPointManager; +import org.osgi.framework.Bundle; /* * Tests the intro parser on valid intro content. @@ -39,7 +43,17 @@ public class ValidTest extends TestCase { } /* - * Test valid intro content. + * Ensure that org.eclipse.help.ui is started. It contributes extra content + * filtering that is used by this test. See UIContentFilterProcessor. + */ + protected void setUp() throws Exception { + HelpUIPlugin.getDefault(); + } + + /* + * Test valid intro content. This goes through all the test intro content (xml files and + * xhtml files) and serializes them using the IntroModelSerializer, then compares the result + * of the serialization with the expected content (the _serialized.txt files). */ public void testParserValid() { IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.ui.intro.config"); @@ -48,35 +62,81 @@ public class ValidTest extends TestCase { * Only use the ones from this test plugin. */ if (elements[i].getDeclaringExtension().getNamespace().equals(UserAssistanceTestPlugin.getDefault().getBundle().getSymbolicName())) { - String pluginRoot = UserAssistanceTestPlugin.getDefault().getBundle().getLocation().substring("update@".length()); String content = elements[i].getAttribute("content"); String id = elements[i].getAttribute("id"); - String resultFile = IntroModelSerializerTest.getResultFile(pluginRoot + content); - + Bundle bundle = UserAssistanceTestPlugin.getDefault().getBundle(); + IntroModelRoot model = ExtensionPointManager.getInst().getModel(id); IntroModelSerializer serializer = new IntroModelSerializer(model); - + + /* + * Try [filename]_serialized_os_ws_arch.txt. If it's not there, try + * [filename]_serialized.txt. + * + * We use different files for os/ws/arch combinations in order to test dynamic content, + * specifically filtering. Some of the files have filters by os, ws, and arch so the + * result is different on each combination. + */ + String contents = null; try { - String expected = FileUtil.getContents(resultFile); - String actual = serializer.toString(); - - StringTokenizer tok1 = new StringTokenizer(expected, "\n"); - StringTokenizer tok2 = new StringTokenizer(actual, "\n"); + contents = FileUtil.getContents(bundle, IntroModelSerializerTest.getResultFile(content, true)); + } + catch(Exception e) { + // didn't find the _serialized_os_ws_arch.txt file, try just _serialized.txt + } + if (contents == null) { + try { + contents = FileUtil.getContents(bundle, IntroModelSerializerTest.getResultFile(content)); + } + catch(Exception e) { + Assert.fail("An error occured while loading expected result file for intro XML for: " + content); + } + } + /* + * Do a fuzzy match. Ignore all whitespace then compare. This is to avoid platform + * specific newlines, etc. + */ + String expected = contents.replaceAll("[ \t\n\r]", ""); + String actual = serializer.toString().replaceAll("[ \t\n\r]", "");; + Assert.assertEquals("The serialization generated for intro did not match the expected result for: " + id, expected, actual); + + Map map = IntroModelSerializerTest.getXHTMLFiles(model); + Iterator iter = map.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry entry = (Map.Entry)iter.next(); + String relativePath = (String)entry.getKey(); /* - * Report the line number and line text where it didn't match, - * as well as the extension id and expected results file. + * Try [filename]_serialized_os_ws_arch.txt. If it's not there, try + * [filename]_serialized.txt. + * + * We use different files for os/ws/arch combinations in order to test dynamic content, + * specifically filtering. Some of the files have filters by os, ws, and arch so the + * result is different on each combination. */ - int lineNumber = 0; - while (tok1.hasMoreTokens() && tok2.hasMoreTokens()) { - String a = tok1.nextToken(); - String b = tok2.nextToken(); - Assert.assertEquals("Serialized intro content model text for \"" + id + "\" did not match expected result (" + IntroModelSerializerTest.getResultFile(content) + "). First difference occured on line " + lineNumber + ".", a, b); - ++lineNumber; + contents = null; + try { + contents = FileUtil.getContents(bundle, IntroModelSerializerTest.getResultFile(relativePath, true)); } - } - catch(Exception e) { - Assert.fail("An error occured while loading expected result file for intro at: " + resultFile); + catch(Exception e) { + // didn't find the _serialized_os_ws_arch.txt file, try just _serialized.txt + } + if (contents == null) { + try { + contents = FileUtil.getContents(bundle, IntroModelSerializerTest.getResultFile(relativePath)); + } + catch(Exception e) { + Assert.fail("An error occured while loading expected result file for intro XHTML for: " + relativePath); + } + } + + /* + * Do a fuzzy match. Ignore all whitespace then compare.. the XML transformers + * seem to add whitespace to the resulting XML string differently. + */ + expected = contents.replaceAll("[ \t\n\r]", ""); + actual = ((String)entry.getValue()).replaceAll("[ \t\n\r]", "");; + Assert.assertEquals("The XHTML generated for intro did not match the expected result for: " + relativePath, expected, actual); } } } diff --git a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializer.java b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializer.java index 5c7e26a81..00868543e 100644 --- a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializer.java +++ b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializer.java @@ -345,6 +345,7 @@ public class IntroModelSerializer { .getChildrenOfType(AbstractIntroElement.GROUP | AbstractIntroElement.LINK); text.append("\n\t\t\tGroups and Links: " + linksAndGroups.length); //$NON-NLS-1$ + text.append("\n"); //$NON-NLS-1$ } /** diff --git a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializerTest.java b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializerTest.java index bd5e3f771..5ea62e131 100644 --- a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializerTest.java +++ b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializerTest.java @@ -12,7 +12,14 @@ package org.eclipse.ua.tests.intro.util; import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; import junit.framework.Test; import junit.framework.TestCase; @@ -20,10 +27,17 @@ import junit.framework.TestSuite; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.Platform; +import org.eclipse.help.ui.internal.HelpUIPlugin; import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin; import org.eclipse.ua.tests.util.ResourceFinder; +import org.eclipse.ui.internal.intro.impl.model.AbstractIntroPage; +import org.eclipse.ui.internal.intro.impl.model.IntroHomePage; import org.eclipse.ui.internal.intro.impl.model.IntroModelRoot; +import org.eclipse.ui.internal.intro.impl.model.IntroPage; import org.eclipse.ui.internal.intro.impl.model.loader.ExtensionPointManager; +import org.eclipse.ui.internal.intro.impl.presentations.BrowserIntroPartImplementation; +import org.eclipse.ui.intro.config.IIntroContentProvider; +import org.eclipse.ui.intro.config.IIntroContentProviderSite; /* * A utility for regenerating the _serialized.txt files that contain the expected @@ -41,6 +55,13 @@ import org.eclipse.ui.internal.intro.impl.model.loader.ExtensionPointManager; * 2. Right-click in "Package Explorer -> Refresh". * * The new files should appear. + * + * Note: Some of the files have os, ws, and arch appended, for example + * <original_name>_serialized_linux_gtk_x86.txt. These are filtering tests that have + * filters by os/ws/arch so the result is different on each combination. This test will + * only generate the _serialized file and will be the one for the current platform. You + * need to make one copy for each combination and edit the files manually to have the + * correct content (or generate on each platform). */ public class IntroModelSerializerTest extends TestCase { @@ -51,6 +72,14 @@ public class IntroModelSerializerTest extends TestCase { return new TestSuite(IntroModelSerializerTest.class); } + /* + * Ensure that org.eclipse.help.ui is started. It contributes extra content + * filtering that is used by this test. See UIContentFilterProcessor. + */ + protected void setUp() throws Exception { + HelpUIPlugin.getDefault(); + } + public void testRunSerializer() { /* * Serialize the SDK's intro. @@ -77,7 +106,7 @@ public class IntroModelSerializerTest extends TestCase { } /* - * Serialize the test intro. + * Serialize the test intros. */ elements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.ui.intro.config"); for (int i=0;i<elements.length;++i) { @@ -89,17 +118,40 @@ public class IntroModelSerializerTest extends TestCase { String content = elements[i].getAttribute("content"); String id = elements[i].getAttribute("id"); + /* + * First do the intro XML files. + */ IntroModelRoot model = ExtensionPointManager.getInst().getModel(id); IntroModelSerializer serializer = new IntroModelSerializer(model); try { - PrintWriter out = new PrintWriter(new FileOutputStream(getResultFile(pluginRoot + content))); + String file = getResultFile(pluginRoot + content); + PrintWriter out = new PrintWriter(new FileOutputStream(file)); out.print(serializer.toString()); out.close(); } catch(FileNotFoundException e) { e.printStackTrace(); } + + /* + * Now do the intro XHTML files. Find all the XHTML files referenced + * from the model. + */ + Map map = getXHTMLFiles(model); + Iterator iter = map.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry entry = (Map.Entry)iter.next(); + try { + String file = getResultFile(pluginRoot + entry.getKey()); + PrintWriter out = new PrintWriter(new FileOutputStream(file)); + out.print((String)entry.getValue()); + out.close(); + } + catch(IOException e) { + e.printStackTrace(); + } + } } } } @@ -109,6 +161,79 @@ public class IntroModelSerializerTest extends TestCase { * for the intro xml referred to by the string. */ public static String getResultFile(String in) { - return in.substring(0, in.lastIndexOf('.')) + "_serialized.txt"; + return getResultFile(in, false); + } + + /* + * Same as above, but gives the option of appending os, ws, and arch. For example, + * myfile_serialized_macosx_carbon_ppc.txt. + */ + public static String getResultFile(String in, boolean env) { + StringBuffer buf = new StringBuffer(); + buf.append(in.substring(0, in.lastIndexOf('.')) + "_serialized"); + if (env) { + buf.append('_'); + buf.append(Platform.getOS()); + buf.append('_'); + buf.append(Platform.getWS()); + buf.append('_'); + buf.append(Platform.getOSArch()); + } + buf.append(".txt"); + return buf.toString(); + } + + /* + * Search through the given model and find all XHTML files referred to by the model. + * Also loads the contents of the XHTML files. The result is a mapping of filenames relative + * to the test plugin to Strings, the contents of the XHTML files. + */ + public static Map getXHTMLFiles(IntroModelRoot model) { + Map map = new HashMap(); + Collection pages = new ArrayList(); + IntroHomePage home = model.getHomePage(); + if (home.isXHTMLPage()) { + pages.add(home); + } + IntroPage[] otherPages = model.getPages(); + for (int i=0;i<otherPages.length;++i) { + if (otherPages[i].isXHTMLPage()) { + pages.add(otherPages[i]); + } + } + Iterator iter = pages.iterator(); + while (iter.hasNext()) { + AbstractIntroPage page = (AbstractIntroPage)iter.next(); + BrowserIntroPartImplementation impl = new BrowserIntroPartImplementation(); + String xhtml = impl.generateXHTMLPage(page, new IIntroContentProviderSite() { + public void reflow(IIntroContentProvider provider, boolean incremental) { + // dummy site + } + }); + xhtml = removeEnvironmentSpecificContent(xhtml); + map.put(page.getInitialBase() + page.getRawContent(), xhtml); + } + return map; + } + + /* + * Some of the XHTML content is environment-specific. This means it changes depending on + * the test machine, location on filesystem, etc. This content is not important for this + * test so just strip it out before comparing the serializations. + */ + private static String removeEnvironmentSpecificContent(String xhtml) { + /* + * The base tag is added before showing in browser. It contains an absolute path + * in filesystem. + */ + xhtml = xhtml.replaceAll("<base href=\".*\" />", ""); + + /* + * The order of the params for the meta tag comes out differently on different platforms. + * I'm not sure why, and why just this tag. We don't care about this one for our tests anyway, + * so just strip it. + */ + xhtml = xhtml.replaceAll("<meta .*/>", ""); + return xhtml; } } diff --git a/org.eclipse.ua.tests/plugin.xml b/org.eclipse.ua.tests/plugin.xml index 4dddacb7e..44aba2b98 100644 --- a/org.eclipse.ua.tests/plugin.xml +++ b/org.eclipse.ua.tests/plugin.xml @@ -151,4 +151,65 @@ </command> </extension> + <!-- + Intro test content + --> + <extension + point="org.eclipse.ui.intro"> + <intro + class="org.eclipse.ui.intro.config.CustomizableIntroPart" + id="org.eclipse.ua.tests.intro.dynamicXHTML"> + </intro> + <intro + class="org.eclipse.ui.intro.config.CustomizableIntroPart" + id="org.eclipse.ua.tests.intro.dynamicXML"> + </intro> + <introProductBinding + introId="org.eclipse.ua.tests.intro.dynamicXML" + productId="org.eclipse.sdk.ide"> + </introProductBinding> + </extension> + <extension + point="org.eclipse.ui.intro.config"> + <config + introId="org.eclipse.ua.tests.intro.dynamicXHTML" + content="data/intro/dynamicXHTML/introContent.xml" + id="org.eclipse.ua.tests.intro.config.dynamicXHTML"> + <presentation + home-page-id="root"> + <implementation + kind="html" + os="win32,linux,macosx"> + </implementation> + </presentation> + </config> + <config + introId="org.eclipse.ua.tests.intro.dynamicXML" + id="org.eclipse.ua.tests.intro.config.dynamicXML" + content="data/intro/dynamicXML/introContent.xml"> + <presentation + home-page-id="root" standby-page-id="standby"> + <implementation + style="data/intro/dynamicXML/css/shared.css" + kind="html" + os="win32,linux,macosx"> + </implementation> + <implementation + kind="swt"> + </implementation> + </presentation> + </config> + </extension> + <extension + point="org.eclipse.ui.intro.configExtension"> + <configExtension + content="data/intro/dynamicXHTML/ext.xml" + configId="org.eclipse.ua.tests.intro.config.dynamicXHTML"> + </configExtension> + <configExtension + content="data/intro/dynamicXML/ext.xml" + configId="org.eclipse.ua.tests.intro.config.dynamicXML"> + </configExtension> + </extension> + </plugin> diff --git a/org.eclipse.ui.cheatsheets/schema/contentFile.xsd b/org.eclipse.ui.cheatsheets/schema/contentFile.xsd index b7e8bc696..699ac580f 100644 --- a/org.eclipse.ui.cheatsheets/schema/contentFile.xsd +++ b/org.eclipse.ui.cheatsheets/schema/contentFile.xsd @@ -128,6 +128,7 @@ <xsd:attribute name="when" type="xsd:string" use="required"/> <xsd:attribute name="confirm" type="xsd:boolean" use="optional" default="false"/> <xsd:attribute name="serialization" type="xsd:string" use="optional"/> + <xsd:attribute name="returns" type="xsd:string" use="optional"/> </xsd:complexType> </xsd:element> diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CommandRunner.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CommandRunner.java index 397e5c0ab..f2f0eda43 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CommandRunner.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CommandRunner.java @@ -22,8 +22,10 @@ import org.eclipse.core.runtime.Status; import org.eclipse.osgi.util.NLS; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.cheatsheets.ICheatSheetManager; import org.eclipse.ui.commands.ICommandService; import org.eclipse.ui.internal.cheatsheets.data.CheatSheetCommand; +import org.eclipse.ui.internal.cheatsheets.views.CheatSheetManager; /** * Execute a command defined in a cheatsheet @@ -46,10 +48,11 @@ public class CommandRunner { /** * Attempt to execute a command * @param command a CheatSheetCommand created by the parser + * @param csm * @return OK_STATUS if the command completes withour error, otherwise * an error status */ - public IStatus executeCommand(CheatSheetCommand command) { + public IStatus executeCommand(CheatSheetCommand command, ICheatSheetManager csm) { ICommandService service = getCommandService(); if (service == null) { return new Status @@ -59,11 +62,15 @@ public class CommandRunner { } ParameterizedCommand selectedCommand; + Object result; + String rawSerialization = command.getSerialization(); try { - selectedCommand = service.deserialize(command.getSerialization()); - selectedCommand.executeWithChecks(null, null); + String substitutedSerialization = CheatSheetManager.performVariableSubstitution + (rawSerialization, csm); + selectedCommand = service.deserialize(substitutedSerialization); + result = selectedCommand.executeWithChecks(null, null); } catch (NotDefinedException e) { - String message = NLS.bind(Messages.ERROR_COMMAND_ID_NOT_FOUND, (new Object[] {command.getSerialization()})); + String message = NLS.bind(Messages.ERROR_COMMAND_ID_NOT_FOUND, (new Object[] {rawSerialization})); return new Status(IStatus.ERROR, ICheatSheetResource.CHEAT_SHEET_PLUGIN_ID, IStatus.OK, message, e); } catch (SerializationException e) { return commandFailureStatus(e); @@ -77,6 +84,15 @@ public class CommandRunner { return commandFailureStatus(e); } + if (command.getReturns() != null) { + String returnValue; + if (result == null) { + returnValue = ""; //$NON-NLS-1$ + } else { + returnValue = result.toString(); + } + csm.setData(command.getReturns(), returnValue); + } return Status.OK_STATUS; } diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetCommand.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetCommand.java index ee411afae..c187e6e23 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetCommand.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetCommand.java @@ -25,6 +25,7 @@ import org.w3c.dom.Node; public class CheatSheetCommand extends AbstractExecutable { private String serialization; + private String returns; private boolean serializationFound; public void setSerialization(String serialization) { @@ -36,11 +37,11 @@ public class CheatSheetCommand extends AbstractExecutable { } public boolean isCheatSheetManagerUsed() { - return false; + return true; } public IStatus execute(ICheatSheetManager csm) { - return new CommandRunner().executeCommand(this); + return new CommandRunner().executeCommand(this, csm); } public boolean hasParams() { @@ -48,11 +49,13 @@ public class CheatSheetCommand extends AbstractExecutable { } public boolean handleAttribute(Node attribute) { - if (IParserTags.SERIALIZATION.equals(attribute.getNodeName())) { setSerialization(attribute.getNodeValue()); serializationFound = true; return true; + } else if (IParserTags.RETURNS.equals(attribute.getNodeName())) { + setReturns(attribute.getNodeValue()); + return true; } return false; } @@ -64,4 +67,12 @@ public class CheatSheetCommand extends AbstractExecutable { return null; } + public void setReturns(String returns) { + this.returns = returns; + } + + public String getReturns() { + return returns; + } + } diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/IParserTags.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/IParserTags.java index 1da48bf15..a3d12fd16 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/IParserTags.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/IParserTags.java @@ -124,6 +124,7 @@ public interface IParserTags { // Miscellaneous tags public static final String COMMAND = "command"; //$NON-NLS-1$ public static final String SERIALIZATION = "serialization"; //$NON-NLS-1$ + public static final String RETURNS = "returns"; //$NON-NLS-1$ public static final String ON_COMPLETION = "onCompletion"; //$NON-NLS-1$ public static final String CONTENT_URL = "contentURL"; //$NON-NLS-1$ diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetManager.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetManager.java index 0a3df483c..4663b08c4 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetManager.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetManager.java @@ -20,6 +20,8 @@ import org.eclipse.ui.internal.cheatsheets.registry.CheatSheetElement; */ public class CheatSheetManager implements ICheatSheetManager { + private static final String VARIABLE_END = "}"; + private static final String VARIABLE_BEGIN = "${"; private String cheatsheetID; private List listeners; private Hashtable dataTable = null; @@ -65,12 +67,45 @@ public class CheatSheetManager implements ICheatSheetManager { public String getVariableData(String variable) { String result = variable; - if(variable != null && variable.startsWith("${") && variable.endsWith("}")) { //$NON-NLS-1$ //$NON-NLS-2$ + if(variable != null && variable.startsWith(VARIABLE_BEGIN) && variable.endsWith(VARIABLE_END)) { //$NON-NLS-1$ //$NON-NLS-2$ result = variable.substring(2,variable.length()-1); result = getData(result); } return result; } + + /** + * Substitute occurences of ${data} with values from the cheatsheetmanager. + * This function is static to allow for JUnit testing + * @param input The input string + * @param csm The cheatsheet manager + * @return The input string with substitutions made for any cheatsheet + * variables encountered. + */ + public static String performVariableSubstitution(String input, + ICheatSheetManager csm) + { + String remaining = input; + String output = ""; //$NON-NLS-1$ + while (remaining.length() > 0) { + int varIndex = remaining.indexOf(VARIABLE_BEGIN); + int endIndex = remaining.indexOf(VARIABLE_END, varIndex + 1); + if (varIndex < 0 || endIndex < 0) { + output += remaining; + remaining = ""; + } else { + String varName = remaining.substring(varIndex + VARIABLE_BEGIN.length(), + endIndex); + String value = csm.getData(varName); + output += remaining.substring(0, varIndex); + if (value != null) { + output += value; + } + remaining = remaining.substring(endIndex + VARIABLE_END.length()); + } + } + return output; + } /*package*/ void setData(Hashtable data) { dataTable = data; diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CoreItem.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CoreItem.java index 22000a9ea..9a921e914 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CoreItem.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CoreItem.java @@ -540,7 +540,8 @@ public class CoreItem extends ViewItem { * this is the last step. */ void createCompletionComposite(boolean isFinalItem) { - String completionMessage = item.getCompletionMessage(); + String completionMessage = CheatSheetManager.performVariableSubstitution + (item.getCompletionMessage(), viewer.getManager()); if (completionMessage != null) { Color backgroundColor = bodyWrapperComposite.getBackground(); completionComposite = page.getToolkit().createComposite( diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroContainer.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroContainer.java index cb8033ff8..b996ee108 100644 --- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroContainer.java +++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroContainer.java @@ -11,9 +11,12 @@ package org.eclipse.ui.internal.intro.impl.model; +import java.util.Iterator; +import java.util.Map; import java.util.Vector; import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.help.internal.xhtml.XHTMLSupport; import org.eclipse.ui.internal.intro.impl.model.loader.ExtensionPointManager; import org.eclipse.ui.internal.intro.impl.util.Log; import org.osgi.framework.Bundle; @@ -80,8 +83,10 @@ public abstract class AbstractIntroContainer extends AbstractBaseIntroElement { if (!resolved) resolveChildren(); + Vector filtered = filterChildren(children); + AbstractIntroElement[] childrenElements = (AbstractIntroElement[]) convertToModelArray( - children, AbstractIntroElement.ELEMENT); + filtered, AbstractIntroElement.ELEMENT); return childrenElements; } @@ -342,6 +347,49 @@ public abstract class AbstractIntroContainer extends AbstractBaseIntroElement { } /** + * Filters the appropriate elements from the given Vector, according to the current + * environment. For example, if one of the elements has a tag to filter for os=linux and + * the os is win32, the element will not be returned in the resulting Vector. + * + * @param unfiltered the unfiltered elements + * @return a new Vector with elements filtered + */ + private Vector filterChildren(Vector unfiltered) { + Vector filtered = new Vector(); + Iterator iter = unfiltered.iterator(); + while (iter.hasNext()) { + Object element = iter.next(); + if (!filterElement(element)) { + filtered.add(element); + } + } + return filtered; + } + + /** + * Returns whether or not the given element should be filtered in. This is true only if all + * the filters on the element pass. + * + * @param element the element to decide whether to filter + * @return whether or not the given element should be filtered in + */ + private boolean filterElement(Object element) { + if (element instanceof AbstractIntroIdElement) { + Map filters = ((AbstractIntroIdElement)element).getFilters(); + if (filters != null) { + Iterator iter = filters.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry entry = (Map.Entry)iter.next(); + if (!XHTMLSupport.getFilterProcessor().isFilteredIn((String)entry.getKey(), (String)entry.getValue())) { + return true; + } + } + } + } + return false; + } + + /** * Find the target element pointed to by the path in the include. It is * assumed that configId always points to an external config, and not the * same config of the inlcude. diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroIdElement.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroIdElement.java index 2300b4191..fa729b3c2 100644 --- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroIdElement.java +++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroIdElement.java @@ -11,9 +11,14 @@ package org.eclipse.ui.internal.intro.impl.model; +import java.util.HashMap; +import java.util.Map; + import org.eclipse.core.runtime.IConfigurationElement; import org.osgi.framework.Bundle; import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** @@ -25,8 +30,13 @@ import org.w3c.dom.Element; public abstract class AbstractIntroIdElement extends AbstractIntroElement { public static final String ATT_ID = "id"; //$NON-NLS-1$ + public static final String ATT_FILTER = "filter"; //$NON-NLS-1$ + public static final String ATT_NAME = "name"; //$NON-NLS-1$ + public static final String ATT_VALUE = "value"; //$NON-NLS-1$ + public static final String ELEMENT_FILTER = "filter"; //$NON-NLS-1$ protected String id; + private Map filters; AbstractIntroIdElement(IConfigurationElement element) { super(element); @@ -36,13 +46,48 @@ public abstract class AbstractIntroIdElement extends AbstractIntroElement { AbstractIntroIdElement(Element element, Bundle bundle) { super(element, bundle); id = getAttribute(element, ATT_ID); + filters = findFilters(element); } AbstractIntroIdElement(Element element, Bundle bundle, String base) { super(element, bundle, base); id = getAttribute(element, ATT_ID); + filters = findFilters(element); } + /** + * Finds all filters associated with the given element. These can be defined as either + * a filter attribute on the element, or filter elements as children of this element. + * The result is a mapping of all the filter names to values. For example, "os" -> "win32". + * + * @param element the element whose filters to find + * @return a filter name to value mapping for all the filters on this element + */ + private static Map findFilters(Element element) { + Map map = null; + // check for filter attribute + String filterAttribute = element.getAttribute(ATT_FILTER); + if (filterAttribute.length() > 0) { + map = new HashMap(); + int equalsIndex = filterAttribute.indexOf('='); + String name = filterAttribute.substring(0, equalsIndex); + String value = filterAttribute.substring(equalsIndex + 1); + map.put(name, value); + } + // check for child filter elements + NodeList list = element.getChildNodes(); + for (int i=0;i<list.getLength();++i) { + Node node = list.item(i); + if (node.getNodeType() == Node.ELEMENT_NODE && ELEMENT_FILTER.equals(node.getNodeName())) { + Element elementNode = (Element)node; + if (map == null) { + map = new HashMap(); + } + map.put(elementNode.getAttribute(ATT_NAME), elementNode.getAttribute(ATT_VALUE)); + } + } + return map; + } /** * @return Returns the id. @@ -51,5 +96,7 @@ public abstract class AbstractIntroIdElement extends AbstractIntroElement { return id; } - + public Map getFilters() { + return filters; + } } diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroPage.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroPage.java index bcf7f1f57..5a2f43591 100644 --- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroPage.java +++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroPage.java @@ -16,8 +16,8 @@ import java.util.Vector; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; +import org.eclipse.help.internal.xhtml.XHTMLSupport; import org.eclipse.ui.internal.intro.impl.IIntroConstants; -import org.eclipse.ui.internal.intro.impl.IntroPlugin; import org.eclipse.ui.internal.intro.impl.model.loader.ExtensionPointManager; import org.eclipse.ui.internal.intro.impl.model.loader.IntroContentParser; import org.eclipse.ui.internal.intro.impl.model.loader.ModelLoaderUtil; @@ -634,6 +634,9 @@ public abstract class AbstractIntroPage extends AbstractIntroContainer { ModelUtil.insertStyle(dom, style); } + // filter the content + XHTMLSupport.getFilterProcessor().applyFilters(dom); + // and resolve includes. resolveIncludes(); @@ -846,6 +849,13 @@ public abstract class AbstractIntroPage extends AbstractIntroContainer { } /** + * Returns the raw or unprocessed base location. + */ + public String getInitialBase() { + return initialBase; + } + + /** * Return the url of the embedded IFrame, if this page is an IFrame page. * * @param url diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java index 0b0323942..dd174cc50 100644 --- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java +++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java @@ -247,7 +247,7 @@ public class BrowserIntroPartImplementation extends * Note: Resolving dynamic content is done at the UI level, consistant with * SWT presentation. */ - private String generateXHTMLPage(AbstractIntroPage page, + public String generateXHTMLPage(AbstractIntroPage page, IIntroContentProviderSite site) { // get/cache all content provider elements in DOM. Document dom = page.getResolvedDocument(); |