Author: dmaliarevich
Date: 2008-03-28 10:33:33 -0400 (Fri, 28 Mar 2008)
New Revision: 7183
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, drop-down functionality added
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-03-28
14:08:41 UTC (rev 7182)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java 2008-03-28
14:33:33 UTC (rev 7183)
@@ -128,23 +128,23 @@
public static VpeCreationData encode(VpePageContext pageContext,
VpeCreationData creationData, Element sourceParentElement,
Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMElement parentVisualElement, boolean expanded,
- int activeChildId) {
+ nsIDOMElement parentVisualElement, List<String> activeIds,
+ String childId) {
+
+ /*
+ * Counts child groups in a parent group
+ */
+ int childGroupCount = 1;
boolean disabled = false;
Element parent = getRichPanelParent(sourceElement);
ComponentUtil.setCSSLink(pageContext, STYLE_PATH, NAME_COMPONENT);
-
- if (expanded == true) {
- activeChildId = -1;
- }
-
+ boolean expanded = activeIds.contains(childId);
nsIDOMElement div = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_DIV);
parentVisualElement.appendChild(div);
div.setAttribute(COMPONENT_ATTR_VPE_SUPPORT, NAME_COMPONENT);
- div.setAttribute(COMPONENT_ATTR_VPE_USER_TOGGLE_ID, String
- .valueOf(activeChildId));
+ div.setAttribute(COMPONENT_ATTR_VPE_USER_TOGGLE_ID, childId);
if ("true".equalsIgnoreCase(sourceParentElement
.getAttribute(PANEL_MENU_GROUP_ATTR_DISABLED))) {
@@ -158,7 +158,7 @@
}
buildTable(pageContext, sourceParentElement, parent, sourceElement,
- visualDocument, div, expanded, disabled, activeChildId);
+ visualDocument, div, expanded, disabled, childId);
List<Node> children = ComponentUtil.getChildren(sourceElement);
@@ -181,14 +181,15 @@
PANEL_MENU_GROUP_END_TAG)) {
RichFacesPanelMenuGroupTemplate.encode(pageContext,
creationData, sourceParentElement,
- (Element) child, visualDocument, div, true,
- -1);
+ (Element) child, visualDocument, div, activeIds,
+ childId + "-" + childGroupCount);
+ childGroupCount++;
} else {
RichFacesPanelMenuItemTemplate
.encode(pageContext, creationData,
sourceParentElement,
(Element) child, visualDocument,
- div, false);
+ div);
}
}
@@ -207,14 +208,13 @@
creationData.addChildrenInfo(childrenInfo);
}
}
-
return creationData;
}
private static final void buildTable(VpePageContext pageContext,
Element sourceParentElement, Element parent, Element sourceElement,
nsIDOMDocument visualDocument, nsIDOMElement div, boolean expanded,
- boolean disabled, int activeChildId) {
+ boolean disabled, String activeChildId) {
String disabledStyle = sourceElement
.getAttribute(PANEL_MENU_GROUP_ATTR_DISABLED_STYLE);
String disableClass = null;
@@ -290,7 +290,9 @@
setIcon(pageContext, parent, sourceParentElement, sourceElement, img1,
img2, expanded, disabled);
- if (parent.getNodeName().endsWith(PANEL_MENU_END_TAG)) {
+ if (parent.getNodeName().endsWith(PANEL_MENU_END_TAG)
+ || ((parent.getNodeName().endsWith(PANEL_MENU_GROUP_END_TAG))
+ && (sourceElement.getNodeName().endsWith(PANEL_MENU_GROUP_END_TAG)))) {
if (styleClass != null
&& sourceParentElement
.getAttribute(PANEL_MENU_ATTR_TOP_GROUP_CLASS) != null) {
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-03-28
14:08:41 UTC (rev 7182)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java 2008-03-28
14:33:33 UTC (rev 7183)
@@ -99,7 +99,7 @@
public static VpeCreationData encode(VpePageContext pageContext,
VpeCreationData creationData, Element sourceParentElement,
Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMElement parentVisualElement, boolean active) {
+ nsIDOMElement parentVisualElement) {
ComponentUtil.setCSSLink(pageContext, STYLE_PATH, PANEL_MENU_ITEM);
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-03-28
14:08:41 UTC (rev 7182)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuTemplate.java 2008-03-28
14:33:33 UTC (rev 7183)
@@ -10,7 +10,9 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.richfaces.template;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -44,7 +46,7 @@
private static final String PANEL_MENU_GROUP_END = ":panelMenuGroup";
private static final String PANEL_MENU_ITEM_END = ":panelMenuItem";
- private static Map toggleMap = new HashMap();
+ private List<String> activeIds = new ArrayList<String>();
// private static final String DISABLED_STYLE_FOR_TABLE = "color:#B1ADA7";
@@ -74,22 +76,18 @@
}
List<Node> children = ComponentUtil.getChildren(sourceElement);
- int activeId = getActiveId(sourceElement, children);
- int i = 0;
+ int i = 1;
for (Node child : children) {
-
- boolean expanded = (i == activeId);
-
if (child.getNodeName().endsWith(PANEL_MENU_GROUP_END)) {
RichFacesPanelMenuGroupTemplate.encode(pageContext,
vpeCreationData, sourceElement, (Element) child,
- visualDocument, div, expanded, i);
+ visualDocument, div, getActiveIds(), String.valueOf(i));
i++;
} else if (child.getNodeName().endsWith(PANEL_MENU_ITEM_END)) {
RichFacesPanelMenuItemTemplate.encode(pageContext,
vpeCreationData, sourceElement, (Element) child,
- visualDocument, div, expanded);
+ visualDocument, div);
} else {
nsIDOMElement childDiv = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_DIV);
@@ -104,25 +102,12 @@
}
/**
+ * Gets the active ids.
*
- * @param sourceElement
- * @param children
- * @return
+ * @return the active ids
*/
- private int getActiveId(Element sourceElement, List<Node> children) {
- int activeId = -1;
- try {
- activeId = Integer.valueOf((String) toggleMap.get(sourceElement));
- } catch (NumberFormatException nfe) {
- activeId = -1;
- }
-
- int count = getChildrenCount(children);
- if (count - 1 < activeId) {
- activeId = count - 1;
- }
-
- return activeId;
+ private List<String> getActiveIds() {
+ return activeIds;
}
/**
@@ -142,11 +127,24 @@
public void toggle(VpeVisualDomBuilder builder, Node sourceNode,
String toggleId) {
- toggleMap.put(sourceNode, 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();
+ }
+ }
+ } else{
+ activeIds.add(toggleId);
+ }
+
}
public void stopToggling(Node sourceNode) {
- toggleMap.remove(sourceNode);
+ activeIds.clear();
}
public boolean isRecreateAtAttrChange(VpePageContext pageContext,