Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2009-06-22 20:01:47 +0000
committerChris Goldthorpe2009-06-22 20:01:47 +0000
commit2dabceb1c5a87eaf5c635f3b8bf5b6646fc2fed7 (patch)
treeb17baa8f65fca4af9639a2d714aa0259047616b4 /org.eclipse.ui.cheatsheets/src/org
parentdeadfc30ac4fd0293931618120d082f8b2376b40 (diff)
downloadeclipse.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/src/org')
-rw-r--r--org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java30
-rw-r--r--org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/SubItem.java13
-rw-r--r--org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CoreItem.java21
3 files changed, 50 insertions, 14 deletions
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

Back to the top