Author: dmaliarevich
Date: 2008-04-01 06:09:26 -0400 (Tue, 01 Apr 2008)
New Revision: 7236
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuTemplate.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1588, styles updated, expandSingle attribute
added, toggling updated.
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java 2008-04-01
09:59:08 UTC (rev 7235)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java 2008-04-01
10:09:26 UTC (rev 7236)
@@ -31,6 +31,8 @@
public class RichFacesPanelMenuGroupTemplate extends VpeAbstractTemplate {
+ public static final String GROUP_COUNT_SEPARATOR = "-"; //$NON-NLS-1$
+
/*
* pich:panelMenuGroup attributes
*/
@@ -184,7 +186,7 @@
RichFacesPanelMenuGroupTemplate.encode(pageContext,
creationData, sourceParentElement,
(Element) child, visualDocument, div, activeIds,
- childId + "-" + childGroupCount); //$NON-NLS-1$
+ childId + GROUP_COUNT_SEPARATOR + childGroupCount);
childGroupCount++;
} else {
RichFacesPanelMenuItemTemplate
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java 2008-04-01
09:59:08 UTC (rev 7235)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java 2008-04-01
10:09:26 UTC (rev 7236)
@@ -33,8 +33,6 @@
private static final String DISABLED = "disabled"; //$NON-NLS-1$
private static final String ICON = "icon"; //$NON-NLS-1$
private static final String ICON_DISABLED = "iconDisabled"; //$NON-NLS-1$
- private static final String ITEM_CLASS = "itemClass"; //$NON-NLS-1$
- private static final String ITEM_STYLE = "itemStyle"; //$NON-NLS-1$
private static final String DISABLED_CLASS = "disabledClass"; //$NON-NLS-1$
private static final String DISABLED_STYLE = "disabledStyle"; //$NON-NLS-1$
private static final String STYLE = "style"; //$NON-NLS-1$
@@ -51,7 +49,11 @@
private static final String IMG_SPACER_SRC = "/panelMenuItem/spacer.gif";
//$NON-NLS-1$
private static final String STYLE_PATH = "/panelMenuItem/style.css";
//$NON-NLS-1$
+ private static final String SPACE = " "; //$NON-NLS-1$
+ private static final String EMPTY = ""; //$NON-NLS-1$
private static final String TRUE = "true"; //$NON-NLS-1$
+ private static final String RIGHT = "right"; //$NON-NLS-1$
+ private static final String LEFT = "left"; //$NON-NLS-1$
private static final String NO_SIZE_VALUE = "0"; //$NON-NLS-1$
private static final String DEFAULT_SIZE_VALUE = "16"; //$NON-NLS-1$
@@ -85,8 +87,6 @@
private static String pmi_disabled;
private static String pmi_icon;
private static String pmi_iconDisabled;
- private static String pmi_itemClass;
- private static String pmi_itemStyle;
private static String pmi_disabledClass;
private static String pmi_disabledStyle;
private static String pmi_style;
@@ -156,7 +156,7 @@
"element.style"); //$NON-NLS-1$
String value = sourceElement.getAttribute("label"); //$NON-NLS-1$
- nsIDOMText text = visualDocument.createTextNode(value == null ? ""
//$NON-NLS-1$
+ nsIDOMText text = visualDocument.createTextNode(value == null ? EMPTY //$NON-NLS-1$
: value);
tdLable.appendChild(text);
@@ -275,12 +275,12 @@
nsIDOMElement right, nsIDOMElement left, nsIDOMElement imgPoints,
nsIDOMElement imgSpacer2) {
if (!(iconPosition == null)) {
- if (iconPosition.equals("right")) { //$NON-NLS-1$
+ if (iconPosition.equals(RIGHT)) {
setItemImage(right, imgPoints);
} else {
setItemImage(right, imgSpacer2);
ComponentUtil.setImg(imgSpacer2, IMG_SPACER_SRC);
- if (iconPosition.equals("left")) { //$NON-NLS-1$
+ if (iconPosition.equals(LEFT)) {
setItemImage(left, imgPoints);
}
}
@@ -294,22 +294,25 @@
private static void setItemClassAndStyle(nsIDOMElement table,
String parentClass, String itemClass, String defaultClass,
String parentStyle, String itemStyle) {
- String resultClass = ""; //$NON-NLS-1$
+
+ String resultClass = EMPTY;
+ if (!(defaultClass == null || defaultClass.length() == 0)) {
+ resultClass += defaultClass;
+ }
if (!(parentClass == null || parentClass.length() == 0)) {
- resultClass += parentClass;
+ resultClass += SPACE + parentClass;
}
if (!(itemClass == null || itemClass.length() == 0)) {
- resultClass += itemClass;
+ resultClass += SPACE + itemClass;
}
- table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, defaultClass
- + " " + resultClass); //$NON-NLS-1$
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, resultClass);
- String resultStyle = ""; //$NON-NLS-1$
+ String resultStyle = EMPTY;
if (!(parentStyle == null || parentStyle.length() == 0)) {
resultStyle += parentStyle;
}
if (!(itemStyle == null || itemStyle.length() == 0)) {
- resultStyle += itemStyle;
+ resultStyle += SPACE + itemStyle;
}
table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, resultStyle);
}
@@ -365,8 +368,6 @@
pmi_disabled = sourceElement.getAttribute(DISABLED);
pmi_icon = sourceElement.getAttribute(ICON);
pmi_iconDisabled = sourceElement.getAttribute(ICON_DISABLED);
- pmi_itemClass = sourceElement.getAttribute(ITEM_CLASS);
- pmi_itemStyle = sourceElement.getAttribute(ITEM_STYLE);
pmi_disabledClass = sourceElement.getAttribute(DISABLED_CLASS);
pmi_disabledStyle = sourceElement.getAttribute(DISABLED_STYLE);
pmi_style = sourceElement.getAttribute(STYLE);
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuTemplate.java 2008-04-01
09:59:08 UTC (rev 7235)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuTemplate.java 2008-04-01
10:09:26 UTC (rev 7236)
@@ -38,8 +38,15 @@
*/
public class RichFacesPanelMenuTemplate extends VpeAbstractTemplate implements
VpeToggableTemplate {
-
+
/*
+ * rich:panelMenu attributes
+ */
+ public static final String DISABLED = "disabled"; //$NON-NLS-1$
+ public static final String EXPAND_SINGLE = "expandSingle"; //$NON-NLS-1$
+ public static final String WIDTH = "width"; //$NON-NLS-1$
+
+ /*
* rich:panelMenu attributes for groups
*/
public static final String ICON_GROUP_POSITION = "iconGroupPosition";
//$NON-NLS-1$
@@ -64,7 +71,6 @@
/*
* rich:panelMenu style classes
*/
- public static final String DISABLED = "disabled"; //$NON-NLS-1$
public static final String STYLE = "style"; //$NON-NLS-1$
public static final String STYLE_CLASS = "styleClass"; //$NON-NLS-1$
@@ -88,13 +94,13 @@
public static final String ITEM_CLASS = "itemClass"; //$NON-NLS-1$
public static final String ITEM_STYLE = "itemStyle"; //$NON-NLS-1$
-
- private static final String WIDTH_ATTR_PANELMENU = "width"; //$NON-NLS-1$
-
private static final String PANEL_MENU_GROUP_END = ":panelMenuGroup";
//$NON-NLS-1$
private static final String PANEL_MENU_ITEM_END = ":panelMenuItem";
//$NON-NLS-1$
+ private static final String TRUE = "true"; //$NON-NLS-1$
private List<String> activeIds = new ArrayList<String>();
+
+ private String expandSingle;
// private static final String DISABLED_STYLE_FOR_TABLE = "color:#B1ADA7";
@@ -103,10 +109,10 @@
Element sourceElement = (Element) sourceNode;
- String width = sourceElement.getAttribute(WIDTH_ATTR_PANELMENU);
+ String width = sourceElement.getAttribute(WIDTH);
String style = sourceElement.getAttribute(STYLE);
- String styleClass = sourceElement
- .getAttribute(STYLE_CLASS);
+ String styleClass = sourceElement.getAttribute(STYLE_CLASS);
+ expandSingle = sourceElement.getAttribute(EXPAND_SINGLE);
if (width != null) {
style += "" + "; width:" + width; //$NON-NLS-1$ //$NON-NLS-2$
@@ -176,19 +182,68 @@
public void toggle(VpeVisualDomBuilder builder, Node sourceNode,
String toggleId) {
- if (activeIds.contains(toggleId)) {
- activeIds.remove(toggleId);
-
- for (Iterator<String> iterator = activeIds.iterator(); iterator.hasNext();) {
- String id = iterator.next();
- if (id.startsWith(toggleId)) {
- iterator.remove();
+ /*
+ * Expand only one group.
+ */
+ if ((null != expandSingle) && (TRUE.equalsIgnoreCase(expandSingle))) {
+ if (activeIds.contains(toggleId)) {
+ /*
+ * Close group and its children
+ */
+ activeIds.remove(toggleId);
+ for (Iterator<String> iterator = activeIds.iterator(); iterator.hasNext();) {
+ String id = iterator.next();
+ if (id.startsWith(toggleId)) {
+ iterator.remove();
+ }
}
+ } else {
+ /*
+ * Expand new group, close others
+ */
+ String[] toggleIds =
toggleId.split(RichFacesPanelMenuGroupTemplate.GROUP_COUNT_SEPARATOR);
+ if ((null != toggleIds) && (toggleIds.length > 0)) {
+ for (Iterator<String> iterator = activeIds.iterator(); iterator.hasNext();) {
+ String id = iterator.next();
+ String[] ids = id.split(RichFacesPanelMenuGroupTemplate.GROUP_COUNT_SEPARATOR);
+ if ((null != ids) && (ids.length > 0)) {
+ if (ids.length >= toggleIds.length) {
+ /*
+ * Remove all ids that are deeper than selected
+ * and that are on the same level.
+ */
+ iterator.remove();
+ } else {
+ /*
+ * Remove all ids that are not in the selected branch.
+ */
+ for (int i = 0; i < ids.length; i++) {
+ if (!ids[i].equalsIgnoreCase(toggleIds[i])) {
+ iterator.remove();
+ }
+ }
+ }
+ }
+ }
+ }
+ activeIds.add(toggleId);
}
- } else{
- activeIds.add(toggleId);
+ } else {
+ /*
+ * Expand any number of groups.
+ */
+ if (activeIds.contains(toggleId)) {
+ activeIds.remove(toggleId);
+ for (Iterator<String> iterator = activeIds.iterator(); iterator.hasNext();) {
+ String id = iterator.next();
+ if (id.startsWith(toggleId)) {
+ iterator.remove();
+ }
+ }
+ } else {
+ activeIds.add(toggleId);
+ }
}
-
}
public void stopToggling(Node sourceNode) {