Author: dmaliarevich
Date: 2008-10-13 12:04:38 -0400 (Mon, 13 Oct 2008)
New Revision: 10799
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuGroupTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuItemTemplate.java
Log:
JBIDE-2497, creating nested items in menu and groups was updated.
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java 2008-10-13
15:26:03 UTC (rev 10798)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java 2008-10-13
16:04:38 UTC (rev 10799)
@@ -39,7 +39,10 @@
*/
private final static String COMPONENT_NAME = "dropDownMenu"; //$NON-NLS-1$
private final static String STYLE_PATH = "dropDownMenu/dropDownMenu.css";
//$NON-NLS-1$
+ private final static String CHILD_GROUP_NAME = ":menuGroup"; //$NON-NLS-1$
+ private final static String CHILD_ITEM_NAME = ":menuItem"; //$NON-NLS-1$
private static final String LABEL_FACET_NAME = "label"; //$NON-NLS-1$
+ private static final String DEFAULT_DDM_TITLE = "ddm"; //$NON-NLS-1$
private static final String EMPTY = ""; //$NON-NLS-1$
private static final String SPACE = " "; //$NON-NLS-1$
@@ -140,13 +143,14 @@
* Nesting elements
*/
ddmLabelDiv.appendChild(ddmTextSpan);
- ddmTextSpan.appendChild(ddmLabelText);
+// ddmTextSpan.appendChild(ddmLabelText);
// ddmLabelDiv.appendChild(ddmListDiv);
ddmListDiv.appendChild(ddmListBorderDiv);
ddmListBorderDiv.appendChild(ddmListBgDiv);
ddmMainUL.appendChild(ddmMainLI);
ddmMainLI.appendChild(ddmLabelDiv);
+
/*
* Children <ul> will be added only if there are some of them.
*/
@@ -208,30 +212,36 @@
creationData.addChildrenInfo(childrenInfo);
} else {
Attr valueAttr = sourceElement.getAttributeNode(HTML.ATTR_VALUE);
- String labelValue = valueAttr != null && valueAttr.getValue() != null
+ String labelValue = (valueAttr != null && valueAttr.getValue() != null)
? valueAttr.getValue()
- : EMPTY;
+ : DEFAULT_DDM_TITLE;
ddmLabelText.setNodeValue(labelValue);
+ ddmTextSpan.appendChild(ddmLabelText);
}
/*
- * Adding child nodes
+ * Adding child nodes:
+ * <rich:menuGroup> and <rich:menuItem> only.
*/
List<Node> children = ComponentUtil.getChildren(sourceElement);
- if (children.size() > 0) {
- /*
- * Add children <ul> and children in it.
- */
- ddmMainLI.appendChild(ddmChildrenUL);
- for (Node child : children) {
-// nsIDOMElement childDiv = visualDocument
-// .createElement(HTML.TAG_DIV);
-// ddmListBgDiv.appendChild(childDiv);
- VpeChildrenInfo childDivInfo = new VpeChildrenInfo(ddmChildrenUL);
+ boolean missingChildContainer = true;
+ for (Node child : children) {
+ if (child.getNodeType() == Node.ELEMENT_NODE
+ && (child.getNodeName().endsWith(CHILD_GROUP_NAME) || child
+ .getNodeName().endsWith(CHILD_ITEM_NAME))) {
+ if (missingChildContainer) {
+ /*
+ * Add children <ul> tag.
+ */
+ ddmMainLI.appendChild(ddmChildrenUL);
+ missingChildContainer = false;
+ }
+ VpeChildrenInfo childDivInfo = new VpeChildrenInfo(
+ ddmChildrenUL);
childDivInfo.addSourceChild(child);
creationData.addChildrenInfo(childDivInfo);
}
- }
+ }
return creationData;
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuGroupTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuGroupTemplate.java 2008-10-13
15:26:03 UTC (rev 10798)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuGroupTemplate.java 2008-10-13
16:04:38 UTC (rev 10799)
@@ -37,6 +37,8 @@
private final static String COMPONENT_NAME = "menuGroup"; //$NON-NLS-1$
private final static String STYLE_PATH = "menuGroup/menuGroup.css";
//$NON-NLS-1$
private static final String SPACER_IMG_PATH = "menuGroup/spacer.gif";
//$NON-NLS-1$
+ private final static String CHILD_GROUP_NAME = ":menuGroup"; //$NON-NLS-1$
+ private final static String CHILD_ITEM_NAME = ":menuItem"; //$NON-NLS-1$
private static final String ICON_FACET_NAME = "icon"; //$NON-NLS-1$
private static final String ICON_DISABLED_FACET_NAME = "iconDisabled";
//$NON-NLS-1$
private static final String EMPTY = ""; //$NON-NLS-1$
@@ -152,6 +154,7 @@
// grFolderDiv.appendChild(grListBorderDiv);
// grListBorderDiv.appendChild(grListBgDiv);
grMainLI.appendChild(grTopDiv);
+
/*
* Children <ul> will be added only if there are some of them.
*/
@@ -248,27 +251,29 @@
}
-// String menuGroupId = (String) sourceNode.getUserData(MENU_GROUP_ID);
/*
- * Adding child nodes
+ * Adding child nodes:
+ * <rich:menuGroup> and <rich:menuItem> only.
*/
List<Node> children = ComponentUtil.getChildren(sourceElement);
- if (children.size() > 0) {
- /*
- * Add children <ul> and children in it.
- */
- grMainLI.appendChild(grChildrenUL);
- for (Node child : children) {
-// nsIDOMElement childDiv = visualDocument
-// .createElement(HTML.TAG_DIV);
-// grListBgDiv.appendChild(childDiv);
-// VpeChildrenInfo childDivInfo = new VpeChildrenInfo(childDiv);
+ boolean missingChildContainer = true;
+ for (Node child : children) {
+ if (child.getNodeType() == Node.ELEMENT_NODE
+ && (child.getNodeName().endsWith(CHILD_GROUP_NAME)
+ || child.getNodeName().endsWith(CHILD_ITEM_NAME))) {
+ if (missingChildContainer) {
+ /*
+ * Add children <ul> tag.
+ */
+ grMainLI.appendChild(grChildrenUL);
+ missingChildContainer = false;
+ }
VpeChildrenInfo childDivInfo = new VpeChildrenInfo(grChildrenUL);
childDivInfo.addSourceChild(child);
creationData.addChildrenInfo(childDivInfo);
}
}
-
+
return creationData;
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuItemTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuItemTemplate.java 2008-10-13
15:26:03 UTC (rev 10798)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuItemTemplate.java 2008-10-13
16:04:38 UTC (rev 10799)
@@ -128,6 +128,7 @@
itemLabelSpan.appendChild(itemLabelText);
itemMainLI.appendChild(itemTopDiv);
+
/*
* Setting attributes for the drop-down mechanism
*/
@@ -173,14 +174,6 @@
itemMainLI.setAttribute(HTML.ATTR_STYLE, topDivStyle);
/*
- * Encode label and icon value
- */
- Attr valueAttr = sourceElement.getAttributeNode(HTML.ATTR_VALUE);
- String labelValue = valueAttr != null
- && valueAttr.getValue() != null ? valueAttr.getValue() : EMPTY;
- itemLabelText.setNodeValue(labelValue);
-
- /*
* Encode icon facets
*/
Element iconFacet = ComponentUtil.getFacet(sourceElement, ICON_FACET_NAME);
@@ -209,11 +202,20 @@
itemIconImgSpan.appendChild(itemIconImg);
}
+
+ /*
+ * Encode label and icon value
+ */
+ Attr valueAttr = sourceElement.getAttributeNode(HTML.ATTR_VALUE);
+ String labelValue = (valueAttr != null && valueAttr.getValue() != null)
+ ? valueAttr.getValue()
+ : EMPTY;
+ itemLabelText.setNodeValue(labelValue);
/*
- * Adding child nodes
+ * Adding child nodes, including text nodes.
*/
- List<Node> children = ComponentUtil.getChildren(sourceElement);
+ List<Node> children = ComponentUtil.getChildren(sourceElement, true);
for (Node child : children) {
VpeChildrenInfo childInfo = new VpeChildrenInfo(itemLabelSpan);
childInfo.addSourceChild(child);
Show replies by date