diff options
author | Chris Goldthorpe | 2009-06-22 20:01:47 +0000 |
---|---|---|
committer | Chris Goldthorpe | 2009-06-22 20:01:47 +0000 |
commit | 2dabceb1c5a87eaf5c635f3b8bf5b6646fc2fed7 (patch) | |
tree | b17baa8f65fca4af9639a2d714aa0259047616b4 /org.eclipse.ui.cheatsheets | |
parent | deadfc30ac4fd0293931618120d082f8b2376b40 (diff) | |
download | eclipse.platform.ua-2dabceb1c5a87eaf5c635f3b8bf5b6646fc2fed7.tar.gz eclipse.platform.ua-2dabceb1c5a87eaf5c635f3b8bf5b6646fc2fed7.tar.xz eclipse.platform.ua-2dabceb1c5a87eaf5c635f3b8bf5b6646fc2fed7.zip |
Bug 191580 [CheatSheet] no bolding in cheatsheet subitems
Diffstat (limited to 'org.eclipse.ui.cheatsheets')
6 files changed, 78 insertions, 49 deletions
diff --git a/org.eclipse.ui.cheatsheets/META-INF/MANIFEST.MF b/org.eclipse.ui.cheatsheets/META-INF/MANIFEST.MF index ba0c8269c..8e8d45292 100644 --- a/org.eclipse.ui.cheatsheets/META-INF/MANIFEST.MF +++ b/org.eclipse.ui.cheatsheets/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %PLUGIN_NAME Bundle-SymbolicName: org.eclipse.ui.cheatsheets; singleton:=true -Bundle-Version: 3.3.200.qualifier +Bundle-Version: 3.4.0.qualifier Bundle-Activator: org.eclipse.ui.internal.cheatsheets.CheatSheetPlugin Bundle-Vendor: %PROVIDER_NAME Bundle-Localization: plugin diff --git a/org.eclipse.ui.cheatsheets/schema/cheatSheetContentFileSpec.exsd b/org.eclipse.ui.cheatsheets/schema/cheatSheetContentFileSpec.exsd index 3e7a3f65d..9c095011d 100644 --- a/org.eclipse.ui.cheatsheets/schema/cheatSheetContentFileSpec.exsd +++ b/org.eclipse.ui.cheatsheets/schema/cheatSheetContentFileSpec.exsd @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='UTF-8'?> <!-- Schema file written by PDE --> -<schema targetNamespace="org.eclipse.ui.cheatsheets"> +<schema targetNamespace="org.eclipse.ui.cheatsheets" xmlns="http://www.w3.org/2001/XMLSchema"> <annotation> <appInfo> <meta.schema plugin="org.eclipse.ui.cheatsheets" id="cheat_sheet_schema" name="Cheat Sheet Content File XML Format"/> @@ -189,14 +189,18 @@ given item can be performed in any order. All sub-items within an item have to be completed or skipped before progressing to the next item. (Which means actions that must be performed in a required sequence should not be represented as sub-items.)</p> +<p>Since version 3.4 a description has been allowed in a subitem in place of the label attribute, which allows for formatting tags to be used.</p> </documentation> </annotation> <complexType> - <choice minOccurs="0" maxOccurs="1"> - <element ref="action"/> - <element ref="command"/> - <element ref="perform-when"/> - </choice> + <sequence> + <element ref="description" minOccurs="0" maxOccurs="1"/> + <choice minOccurs="0" maxOccurs="1"> + <element ref="action"/> + <element ref="command"/> + <element ref="perform-when"/> + </choice> + </sequence> <attribute name="label" type="string" use="required"> <annotation> <documentation> @@ -208,6 +212,8 @@ as sub-items.)</p> variables that are unbound. The values of the variables are as of the beginning of the execution of the main step (when the &lt;item&gt; element is elaborated), rather than when the individual sub-step are run. + + A subitem may have either a label or a description element but not both. A description element may contain the formating tags such as &lt;b&gt;, &lt;/b&gt; or &lt;br/&gt;. </documentation> <appInfo> <meta.attribute translatable="true"/> @@ -641,23 +647,7 @@ demonstrates the use of commands, perform-when and conditional subitems.</p&g </documentation> </annotation> - <annotation> - <appInfo> - <meta.section type="apiInfo"/> - </appInfo> - <documentation> - - </documentation> - </annotation> - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - - </documentation> - </annotation> <annotation> <appInfo> diff --git a/org.eclipse.ui.cheatsheets/schema/cheatSheetContentFileSpec.html b/org.eclipse.ui.cheatsheets/schema/cheatSheetContentFileSpec.html index 607627524..4a19bb069 100644 --- a/org.eclipse.ui.cheatsheets/schema/cheatSheetContentFileSpec.html +++ b/org.eclipse.ui.cheatsheets/schema/cheatSheetContentFileSpec.html @@ -20,7 +20,7 @@ DTD fragments (<a href="cheatSheetContentFileSpec.exsd">machine readable XML sch <p></p> <p class="code SchemaDtd"><!ELEMENT <a name="e.cheatsheet">cheatsheet</a> (<a href="#e.intro">intro</a> , <a href="#e.item">item</a>+)></p> <p class="code SchemaDtd"><!ATTLIST cheatsheet</p> -<p class="code SchemaDtdAttlist">title CDATA #REQUIRED></p> +<p class="code SchemaDtdAttlist">title CDATA #REQUIRED</p>></p> <p></p> <p class="ConfigMarkupElementDesc"> The root element of a cheatsheet.</p> @@ -30,7 +30,7 @@ The root element of a cheatsheet.</p> </ul> <br><p class="code SchemaDtd"><!ELEMENT <a name="e.intro">intro</a> (<a href="#e.description">description</a>)></p> <p class="code SchemaDtd"><!ATTLIST intro</p> -<p class="code SchemaDtdAttlist">contextId CDATA #IMPLIED<p class="code SchemaDtdAttlist">href CDATA #IMPLIED></p> +<p class="code SchemaDtdAttlist">contextId CDATA #IMPLIED</p><p class="code SchemaDtdAttlist">href CDATA #IMPLIED</p>></p> <p></p> <p class="ConfigMarkupElementDesc"> The <intro> element is used to define the introductory text to be displayed when the cheat sheet is opened.</p> @@ -60,7 +60,7 @@ whitespace immediately before the <<b>/description</b>> tag.</p> <br><br> <p class="code SchemaDtd"><!ELEMENT <a name="e.item">item</a> (<a href="#e.description">description</a> , (<a href="#e.action">action</a> | <a href="#e.command">command</a> | <a href="#e.perform-when">perform-when</a> | (<a href="#e.subitem">subitem</a> | <a href="#e.conditional-subitem">conditional-subitem</a> | <a href="#e.repeated-subitem">repeated-subitem</a>)*) , <a href="#e.onCompletion">onCompletion</a>?)></p> <p class="code SchemaDtd"><!ATTLIST item</p> -<p class="code SchemaDtdAttlist">title CDATA #REQUIRED<p class="code SchemaDtdAttlist">dialog (true | false) "false"<p class="code SchemaDtdAttlist">skip (true | false) "false"<p class="code SchemaDtdAttlist">contextId CDATA #IMPLIED<p class="code SchemaDtdAttlist">href CDATA #IMPLIED></p> +<p class="code SchemaDtdAttlist">title CDATA #REQUIRED</p><p class="code SchemaDtdAttlist">dialog (true | false) "false"</p><p class="code SchemaDtdAttlist">skip (true | false) "false"</p><p class="code SchemaDtdAttlist">contextId CDATA #IMPLIED</p><p class="code SchemaDtdAttlist">href CDATA #IMPLIED</p>></p> <p></p> <div class="ConfigMarkupElementDesc"> <p>Each <item> element describes one top-level step in a cheat sheet. An @@ -95,9 +95,9 @@ based on cheat sheet variables whose value are acquired in earlier steps.</p></d <li><b>contextId</b> - The optional help context id of the documentation for this cheat sheet step. If supplied, context help for the given fully-qualified context id is shown to the user (typically in a small pop-up window) when they clicks the step's help link. If this attribute is supplied, the <b>href</b> attribute should not be supplied (<b>href</b> will be ignored if both are present).</li> <li><b>href</b> - The optional help document describing this cheat sheet step. If supplied, this help document is shown to the user (typically in a help browser shown in a separate window) when they clicks the step's help link. If this attribute is supplied, the <b>contextId</b> attribute should not be supplied (<b>href</b> will be ignored if both are present).</li> </ul> -<br><p class="code SchemaDtd"><!ELEMENT <a name="e.subitem">subitem</a> (<a href="#e.action">action</a> | <a href="#e.command">command</a> | <a href="#e.perform-when">perform-when</a>)?></p> +<br><p class="code SchemaDtd"><!ELEMENT <a name="e.subitem">subitem</a> (<a href="#e.description">description</a>? , (<a href="#e.action">action</a> | <a href="#e.command">command</a> | <a href="#e.perform-when">perform-when</a>)?)></p> <p class="code SchemaDtd"><!ATTLIST subitem</p> -<p class="code SchemaDtdAttlist">label CDATA #REQUIRED<p class="code SchemaDtdAttlist">skip (true | false) "false"<p class="code SchemaDtdAttlist">when CDATA #IMPLIED></p> +<p class="code SchemaDtdAttlist">label CDATA #REQUIRED</p><p class="code SchemaDtdAttlist">skip (true | false) "false"</p><p class="code SchemaDtdAttlist">when CDATA #IMPLIED</p>></p> <p></p> <div class="ConfigMarkupElementDesc"> <p>Each <subitem> element describes a sub-step in a cheat sheet. A <subitem> @@ -114,7 +114,8 @@ that they have successfully completed the step.</p> given item can be performed in any order. All sub-items within an item have to be completed or skipped before progressing to the next item. (Which means actions that must be performed in a required sequence should not be represented -as sub-items.)</p></div> +as sub-items.)</p> +<p>Since version 3.4 a description has been allowed in a subitem in place of the label attribute, which allows for formatting tags to be used.</p></div> <br> <ul class="ConfigMarkupAttlistDesc"> <li><b>label</b> - The title of the cheat sheet sub-item. If the string @@ -124,7 +125,9 @@ as sub-items.)</p></div> in the context of the execution of the cheat sheet, or the empty string for variables that are unbound. The values of the variables are as of the beginning of the execution of the main step (when the <item> element - is elaborated), rather than when the individual sub-step are run.</li> + is elaborated), rather than when the individual sub-step are run. + + A subitem may have either a label or a description element but not both. A description element may contain the formating tags such as <b>, </b> or <br/>.</li> <li><b>skip</b> - if "true" this sub-step can be skipped. The UI generally shows a button that the user can press to indicate that they are skipping this sub-step.</li> @@ -135,7 +138,7 @@ as sub-items.)</p></div> </ul> <br><p class="code SchemaDtd"><!ELEMENT <a name="e.conditional-subitem">conditional-subitem</a> (<a href="#e.subitem">subitem</a>+)></p> <p class="code SchemaDtd"><!ATTLIST conditional-subitem</p> -<p class="code SchemaDtdAttlist">condition CDATA #REQUIRED></p> +<p class="code SchemaDtdAttlist">condition CDATA #REQUIRED</p>></p> <p></p> <div class="ConfigMarkupElementDesc"> <p>Each <conditional-subitem> element describes a single sub-step whose @@ -171,7 +174,7 @@ equivalent to </ul> <br><p class="code SchemaDtd"><!ELEMENT <a name="e.repeated-subitem">repeated-subitem</a> (<a href="#e.subitem">subitem</a>)></p> <p class="code SchemaDtd"><!ATTLIST repeated-subitem</p> -<p class="code SchemaDtdAttlist">values CDATA #REQUIRED></p> +<p class="code SchemaDtdAttlist">values CDATA #REQUIRED</p>></p> <p></p> <div class="ConfigMarkupElementDesc"> <p>Each <repeated-subitem> element describes a sub-item that expands into @@ -214,7 +217,7 @@ then the item expands to something equivalent to: </ul> <br><p class="code SchemaDtd"><!ELEMENT <a name="e.action">action</a> EMPTY></p> <p class="code SchemaDtd"><!ATTLIST action</p> -<p class="code SchemaDtdAttlist">class CDATA #REQUIRED<p class="code SchemaDtdAttlist">pluginId CDATA #REQUIRED<p class="code SchemaDtdAttlist">paramN CDATA #IMPLIED<p class="code SchemaDtdAttlist">confirm (true | false) "false"<p class="code SchemaDtdAttlist">when CDATA #IMPLIED<p class="code SchemaDtdAttlist">required (true | false) "true"<p class="code SchemaDtdAttlist">translate CDATA #IMPLIED></p> +<p class="code SchemaDtdAttlist">class CDATA #REQUIRED</p><p class="code SchemaDtdAttlist">pluginId CDATA #REQUIRED</p><p class="code SchemaDtdAttlist">paramN CDATA #IMPLIED</p><p class="code SchemaDtdAttlist">confirm (true | false) "false"</p><p class="code SchemaDtdAttlist">when CDATA #IMPLIED</p><p class="code SchemaDtdAttlist">required (true | false) "true"</p><p class="code SchemaDtdAttlist">translate CDATA #IMPLIED</p>></p> <p></p> <p class="ConfigMarkupElementDesc"> Each <action> element describes an action in a cheat sheet.</p> @@ -258,7 +261,7 @@ Examples: </ul> <br><p class="code SchemaDtd"><!ELEMENT <a name="e.command">command</a> EMPTY></p> <p class="code SchemaDtd"><!ATTLIST command</p> -<p class="code SchemaDtdAttlist">serialization CDATA #REQUIRED<p class="code SchemaDtdAttlist">returns CDATA #IMPLIED<p class="code SchemaDtdAttlist">confirm (true | false) "false"<p class="code SchemaDtdAttlist">when CDATA #IMPLIED<p class="code SchemaDtdAttlist">required (true | false) "true"<p class="code SchemaDtdAttlist">translate CDATA #IMPLIED></p> +<p class="code SchemaDtdAttlist">serialization CDATA #REQUIRED</p><p class="code SchemaDtdAttlist">returns CDATA #IMPLIED</p><p class="code SchemaDtdAttlist">confirm (true | false) "false"</p><p class="code SchemaDtdAttlist">when CDATA #IMPLIED</p><p class="code SchemaDtdAttlist">required (true | false) "true"</p><p class="code SchemaDtdAttlist">translate CDATA #IMPLIED</p>></p> <p></p> <div class="ConfigMarkupElementDesc"> <p>Each <command> element describes an command in a cheat sheet. @@ -309,7 +312,7 @@ the cheat sheet variable <i>var</i> at the time this step was completed.</p> <br><br> <p class="code SchemaDtd"><!ELEMENT <a name="e.perform-when">perform-when</a> (<a href="#e.action">action</a> | <a href="#e.command">command</a>)+></p> <p class="code SchemaDtd"><!ATTLIST perform-when</p> -<p class="code SchemaDtdAttlist">condition CDATA #REQUIRED></p> +<p class="code SchemaDtdAttlist">condition CDATA #REQUIRED</p>></p> <p></p> <div class="ConfigMarkupElementDesc"> <p>Each <perform-when> element describes an action in a cheat sheet. diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java index e504a4f01..35b0c2dec 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java @@ -394,6 +394,19 @@ public class CheatSheetParser implements IStatusContainer { throw new CheatSheetParserException(message); } } + + private void handleSubItemDescription(SubItem subItem, Node startNode) throws CheatSheetParserException { + Assert.isNotNull(subItem); + Assert.isNotNull(startNode); + + Node descriptionNode = findNode(startNode, IParserTags.DESCRIPTION); + + if(descriptionNode != null) { + String text = handleMarkedUpText(descriptionNode, startNode, IParserTags.DESCRIPTION); + subItem.setLabel(text); + subItem.setFormatted(true); + } + } private String handleMarkedUpText(Node nodeContainingText, Node startNode, String nodeName ) { NodeList nodes = nodeContainingText.getChildNodes(); @@ -781,8 +794,6 @@ public class CheatSheetParser implements IStatusContainer { Assert.isTrue(subItemNode.getNodeName().equals(IParserTags.SUBITEM)); SubItem subItem = new SubItem(); - - handleSubItemAttributes(subItem, subItemNode); IncompatibleSiblingChecker checker = new IncompatibleSiblingChecker(this, subItemNode); @@ -797,6 +808,15 @@ public class CheatSheetParser implements IStatusContainer { handleExecutable(subItem, node, new CheatSheetCommand()); } else if(node.getNodeName().equals(IParserTags.PERFORMWHEN)) { handlePerformWhen(subItem, node); + } else if (node.getNodeName().equals(IParserTags.DESCRIPTION)) { + if (subItem.isFormatted()) { + String message = NLS.bind( + Messages.ERROR_PARSING_MULTIPLE_DESCRIPTION, + (new Object[] { node.getNodeName() })); + addStatus(IStatus.ERROR, message, null); + } else { + handleSubItemDescription(subItem, node); + } } else { if(node.getNodeType() != Node.TEXT_NODE && node.getNodeType() != Node.COMMENT_NODE ) { String message = NLS.bind(Messages.WARNING_PARSING_UNKNOWN_ELEMENT, (new Object[] {node.getNodeName(), subItemNode.getNodeName()})); @@ -804,6 +824,7 @@ public class CheatSheetParser implements IStatusContainer { } } } + handleSubItemAttributes(subItem, subItemNode); item.addSubItem(subItem); } @@ -811,8 +832,6 @@ public class CheatSheetParser implements IStatusContainer { Assert.isNotNull(subItem); Assert.isNotNull(subItemNode); - boolean label = false; - NamedNodeMap attributes = subItemNode.getAttributes(); if (attributes != null) { for (int x = 0; x < attributes.getLength(); x++) { @@ -822,7 +841,6 @@ public class CheatSheetParser implements IStatusContainer { continue; if (attributeName.equals(IParserTags.LABEL)) { - label = true; subItem.setLabel(attribute.getNodeValue()); } else if (attributeName.equals(IParserTags.SKIP)) { subItem.setSkip(attribute.getNodeValue().equals(TRUE_STRING)); @@ -835,7 +853,7 @@ public class CheatSheetParser implements IStatusContainer { } } - if(!label) { + if(subItem.getLabel() == null) { String message = NLS.bind(Messages.ERROR_PARSING_NO_LABEL, (new Object[] {subItemNode.getNodeName()})); throw new CheatSheetParserException(message); } diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/SubItem.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/SubItem.java index f51303910..ab4fcaade 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/SubItem.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/SubItem.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2006 IBM Corporation and others. + * Copyright (c) 2002, 2009 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 @@ -13,8 +13,9 @@ package org.eclipse.ui.internal.cheatsheets.data; public class SubItem extends AbstractSubItem implements IExecutableItem, IPerformWhenItem { private String label; - private boolean skip; + private boolean skip = false; private String when; + private boolean formatted = false; private AbstractExecutable executable; private PerformWhen performWhen; @@ -98,4 +99,12 @@ public class SubItem extends AbstractSubItem implements IExecutableItem, IPerfor public void setPerformWhen(PerformWhen performWhen) { this.performWhen = performWhen; } + + public void setFormatted(boolean formatted) { + this.formatted = formatted; + } + + public boolean isFormatted() { + return formatted; + } } 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 880663462..40b56a3ad 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2007 IBM Corporation and others. + * Copyright (c) 2002, 2009 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 @@ -147,13 +147,22 @@ public class CoreItem extends ViewItem { } else { labelText = sub.getLabel(); } - Text subitemLabel = new Text(buttonComposite, SWT.READ_ONLY + SWT.WRAP); - subitemLabel.setText(labelText); + Control subItemLabel; + if (sub.isFormatted()) { + FormText formText = page.getToolkit().createFormText(buttonComposite, false); + formText.setText(labelText, labelText.startsWith(IParserTags.FORM_START_TAG), false); + formText.setBackground(itemColor); + subItemLabel = formText; + } else { + Text text = new Text(buttonComposite, SWT.READ_ONLY + SWT.WRAP); + text.setText(labelText); + text.setBackground(itemColor); + subItemLabel = text; + } TableWrapData labelData = new TableWrapData(); labelData.indent = LABEL_MARGIN; - subitemLabel.setLayoutData(labelData); - subitemLabel.setBackground(itemColor); - holder.setSubitemLabel(subitemLabel); + subItemLabel.setLayoutData(labelData); + holder.setSubitemLabel(subItemLabel); added++; // Add some space to the right of the label |