Author: ezheleznyakov
Date: 2007-10-16 09:14:30 -0400 (Tue, 16 Oct 2007)
New Revision: 4225
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/chevron.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/chevronDown.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/chevronUp.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/disc.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/grid.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/spacer.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/style.css
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/triangle.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/triangleDown.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/triangleUp.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuItem/
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuItem/points.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuItem/spacer.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuItem/style.css
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuTemplate.java
Modified:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
Log:
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/chevron.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/chevron.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/chevronDown.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/chevronDown.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/chevronUp.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/chevronUp.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/disc.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/disc.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/grid.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/grid.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/spacer.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/spacer.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/style.css
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/style.css
(rev 0)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/style.css 2007-10-16
13:14:30 UTC (rev 4225)
@@ -0,0 +1,57 @@
+.rich-pmenu-group-icon {
+ width: 16;
+ height: 16;
+ vspace: 0;
+ hspace: 0;
+ vertical-align: middle;
+}
+
+.rich-pmenu-group-disabled {
+ color: #B1ADA7;
+}
+
+.dr-pmenu-top-group-div {
+ border-color: #C4C0B9;
+}
+
+.dr-pmenu-top-group-div {
+ border: 1px solid;
+ margin-bottom: 3px;
+ padding: 1px;
+ border-color: #C4C0B9;
+}
+
+.dr-pmenu-top-self-div {
+ border-top: 1px solid;
+ margin-bottom: 3px;
+ padding: 1px;
+ border-color: #C4C0B9;
+}
+
+.dr-pmenu-top-group {
+ background-color: #D4CFC7;
+ font-family: Arial, Verdana, sans-serif;
+ font-size: 11px;
+ font-weight: bold;
+ background-position: left top;
+ background-repeat: repeat-x;
+ cursor: pointer;
+ height: 20px;
+ padding: 2px 1px 2px 2px;
+ width: 100%;
+}
+
+.dr-pmenu-selected-item {
+ font-style: italic;
+}
+
+.dr-pmenu-group-self-label {
+ padding-left: 5px;
+ width: 100%;
+}
+
+.rich-pmenu-group-self-label {
+ font-family: Arial, Verdana, sans-serif;
+ font-size: 11px;
+ font-weight: bold;
+}
\ No newline at end of file
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/style.css
___________________________________________________________________
Name: svn:mime-type
+ text/css
Name: svn:eol-style
+ native
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/triangle.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/triangle.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/triangleDown.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/triangleDown.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/triangleUp.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuGroup/triangleUp.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuItem/points.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuItem/points.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuItem/spacer.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuItem/spacer.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuItem/style.css
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuItem/style.css
(rev 0)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuItem/style.css 2007-10-16
13:14:30 UTC (rev 4225)
@@ -0,0 +1,71 @@
+
+.dr-pmenu-top-group-div {
+ border-color:#C4C0B9;
+}
+
+.dr-pmenu-top-group-div {
+ border:1px solid;
+ margin-bottom:3px;
+ padding:1px;
+ border-color:#C4C0B9;
+
+}
+
+.dr-pmenu-top-group {
+ background-color:#D4CFC7;
+ color:#000000;
+ font-family:Arial,Verdana,sans-serif;
+ font-size:11px;
+ font-weight:bold;
+}
+
+.dr-pmenu-top-group {
+ background-position:left top;
+ background-repeat:repeat-x;
+ cursor:pointer;
+ height:20px;
+ padding:2px 1px 2px 2px;
+ width:100%;
+}
+
+.dr-pmenu-nowrap {
+ white-space:nowrap;
+}
+
+element.style {
+ width:100%;
+}
+
+
+.dr-pmenu-group-self-label {
+ padding-left:5px;
+}
+
+.dr-pmenu-item-disabled {
+ color:#B1ADA7;
+ font-family:Arial,Verdana,sans-serif;
+ font-size:11px;
+ margin-top:1px;
+ padding:2px 1px 1px;
+}
+
+.dr-pmenu-item {
+ cursor:pointer;
+ margin-top:1px;
+ padding:2px 1px 1px;
+}
+
+.dr-pmenu-item {
+ color:#000000;
+ font-family:Arial,Verdana,sans-serif;
+ font-size:11px;
+}
+
+.dr-pmenu-nowrap {
+ white-space:nowrap;
+}
+
+.dr-pmenu-top-self-div {
+ border-top: 1px solid;
+ border-color: #C4C0B9;
+}
\ No newline at end of file
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelMenuItem/style.css
___________________________________________________________________
Name: svn:mime-type
+ text/css
Name: svn:eol-style
+ native
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java
(rev 0)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java 2007-10-16
13:14:30 UTC (rev 4225)
@@ -0,0 +1,456 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jsf.vpe.richfaces.template;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
+import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMText;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+
+public class RichFacesPanelMenuGroupTemplate extends VpeAbstractTemplate {
+
+ private static final String NAME_COMPONENT = "panelMenuGroup";
+
+ private static final String PANEL_MENU_END_TAG = ":panelMenu";
+
+ private static final String PANEL_MENU_GROUP_END_TAG = ":panelMenuGroup";
+
+ private static final String PANEL_MENU_ITEM_END_TAG = ":panelMenuItem";
+
+ // *******************************************************************************
+ // * Panel menu attribytes.
+ // ******************************************************************************/
+ private static final String PANEL_MENU_ATTR_ICON_GROUP_POSITION =
"iconGroupPosition";
+
+ private static final String PANEL_MENU_ATTR_ICON_TOP_GROUP_POSITION =
"iconGroupTopPosition";
+
+ private static final String PANEL_MENU_ATTR_ICON_COLLAPSED_GROUP =
"iconCollapsedGroup";
+
+ private static final String PANEL_MENU_ATTR_ICON_COLLAPSED_TOP_GROUP =
"iconCollapsedTopGroup";
+
+ private static final String PANEL_MENU_ATTR_ICON_EXPANDED_GROUP =
"iconExpandedGroup";
+
+ private static final String PANEL_MENU_ATTR_ICON_EXPANDED_TOP_GROUP =
"iconExpandedTopGroup";
+
+ private static final String PANEL_MENU_ATTR_ICON_DISABLE_GROUP =
"iconDisableGroup";
+
+ private static final String PANEL_MENU_ATTR_ICON_TOP_DISABLE_GROUP =
"iconTopDisableGroup";
+
+ private static final String PANEL_MENU_ATTR_DISABLED_GROUP_CLASS =
"disabledGroupClass";
+
+ private static final String PANEL_MENU_ATTR_DISABLED_GROUP_STYLE =
"disabledGroupStyle";
+
+ private static final String PANEL_MENU_ATTR_TOP_GROUP_CLASS =
"topGroupClass";
+
+ private static final String PANEL_MENU_ATTR_GROUP_CLASS = "groupClass";
+
+ private static final String PANEL_MENU_ATTR_TOP_GROUP_STYLE =
"topGroupStyle";
+
+ private static final String PANEL_MENU_ATTR_GROUP_STYLE = "groupStyle";
+
+ // *******************************************************************************
+ // * Panel menu group attribytes.
+ // ******************************************************************************/
+ private static final String PANEL_MENU_GROUP_ATTR_DISABLED_STYLE =
"disabledStyle";
+
+ private static final String PANEL_MENU_GROUP_ATTR_DISABLED_CLASS =
"disabledClass";
+
+ private static final String PANEL_MENU_GROUP_ATTR_DISABLED = "disabled";
+
+ private static final String PANEL_MENU_GROUP_ATTR_ICON_EXPANDED =
"iconExpanded";
+
+ private static final String PANEL_MENU_GROUP_ATTR_ICON_COLLAPSED =
"iconCollapsed";
+
+ private static final String PANEL_MENU_GROUP_ATTR_ICON_DISABLED =
"iconDisabled";
+
+ private static final String PANEL_MENU_GROUP_ATTR_ICON_LABEL = "label";
+
+ private static final String COMPONENT_ATTR_VPE_SUPPORT = "vpeSupport";
+
+ private static final String COMPONENT_ATTR_VPE_USER_TOGGLE_ID =
"vpe-user-toggle-id";
+
+ private static final String PANEL_MENU_GROUP_ICON_SPACER_PATH =
"/panelMenuGroup/spacer.gif";
+
+ private static final String STYLE_PATH = "/panelMenuGroup/style.css";
+
+ private static final String EMPTY_DIV_STYLE = "display: none;";
+
+ private static final Map<String, String> DEFAULT_ICON_MAP = new HashMap<String,
String>();
+
+ static {
+ DEFAULT_ICON_MAP.put("chevron", "/panelMenuGroup/chevron.gif");
+ DEFAULT_ICON_MAP.put("chevronUp",
"/panelMenuGroup/chevronUp.gif");
+ DEFAULT_ICON_MAP.put("chevronDown",
"/panelMenuGroup/chevronDown.gif");
+ DEFAULT_ICON_MAP.put("triangle", "/panelMenuGroup/triangle.gif");
+ DEFAULT_ICON_MAP.put("triangleUp",
"/panelMenuGroup/triangleUp.gif");
+ DEFAULT_ICON_MAP
+ .put("triangleDown", "/panelMenuGroup/triangleDown.gif");
+ DEFAULT_ICON_MAP.put("disc", "/panelMenuGroup/disc.gif");
+ DEFAULT_ICON_MAP.put("grid", "/panelMenuGroup/grid.gif");
+ }
+
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ nsIDOMElement div = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ div.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, EMPTY_DIV_STYLE);
+ return new VpeCreationData(div);
+ }
+
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement visualNode, Object data, String name, String value) {
+ return true;
+ }
+
+ public static VpeCreationData encode(VpePageContext pageContext,
+ VpeCreationData creationData, Element sourceParentElement,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement parentVisualElement, boolean expanded,
+ int activeChildId) {
+ boolean disabled = false;
+ Element parent = getRichPanelParent(sourceElement);
+
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH, NAME_COMPONENT);
+
+ if (expanded == true) {
+ activeChildId = -1;
+ }
+
+ 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));
+
+ if ("true".equalsIgnoreCase(sourceParentElement
+ .getAttribute(PANEL_MENU_GROUP_ATTR_DISABLED))) {
+ disabled = true;
+ } else if ("true".equalsIgnoreCase(parent
+ .getAttribute(PANEL_MENU_GROUP_ATTR_DISABLED))) {
+ disabled = true;
+ } else if ("true".equalsIgnoreCase(sourceElement
+ .getAttribute(PANEL_MENU_GROUP_ATTR_DISABLED))) {
+ disabled = true;
+ }
+
+ buildTable(pageContext, sourceParentElement, parent, sourceElement,
+ visualDocument, div, expanded, disabled, activeChildId);
+
+ List<Node> children = ComponentUtil.getChildren(sourceElement);
+
+ if (!children.isEmpty()) {
+ nsIDOMElement childSpan = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_SPAN);
+ VpeChildrenInfo childrenInfo = new VpeChildrenInfo(childSpan);
+ for (Node child : children) {
+ if (!child.getNodeName().endsWith(PANEL_MENU_GROUP_END_TAG)
+ && !child.getNodeName().endsWith(
+ PANEL_MENU_ITEM_END_TAG)) {
+ if (childrenInfo.getSourceChildren() == null
+ || childrenInfo.getSourceChildren().size() == 0) {
+ div.appendChild(childSpan);
+ }
+ childrenInfo.addSourceChild(child);
+ } else {
+ if (expanded && !disabled) {
+ if (child.getNodeName().endsWith(
+ PANEL_MENU_GROUP_END_TAG)) {
+ RichFacesPanelMenuGroupTemplate.encode(pageContext,
+ creationData, sourceParentElement,
+ (Element) child, visualDocument, div, true,
+ -1);
+ } else {
+ RichFacesPanelMenuItemTemplate
+ .encode(pageContext, creationData,
+ sourceParentElement,
+ (Element) child, visualDocument,
+ div, false);
+ }
+ }
+
+ if (childrenInfo.getSourceChildren() != null
+ && childrenInfo.getSourceChildren().size() > 0) {
+ creationData.addChildrenInfo(childrenInfo);
+ childSpan = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_SPAN);
+ childrenInfo = new VpeChildrenInfo(childSpan);
+ }
+ }
+ }
+
+ if (childrenInfo.getSourceChildren() != null
+ && childrenInfo.getSourceChildren().size() > 0) {
+ 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) {
+ String disabledStyle = sourceElement
+ .getAttribute(PANEL_MENU_GROUP_ATTR_DISABLED_STYLE);
+ String disableClass = null;
+ String style = sourceElement
+ .getAttribute(HtmlComponentUtil.HTML_STYLE_ATTR);
+ String styleClass = sourceElement
+ .getAttribute(HtmlComponentUtil.HTML_STYLECLASS_ATTR);
+
+ if (disabledStyle == null) {
+ disabledStyle = sourceParentElement
+ .getAttribute(PANEL_MENU_ATTR_DISABLED_GROUP_STYLE);
+ }
+
+ if (sourceElement.getAttribute(PANEL_MENU_GROUP_ATTR_DISABLED_CLASS) != null) {
+ disableClass = sourceElement
+ .getAttribute(PANEL_MENU_GROUP_ATTR_DISABLED_CLASS);
+ } else if (sourceParentElement
+ .getAttribute(PANEL_MENU_ATTR_DISABLED_GROUP_CLASS) != null) {
+ disableClass = sourceParentElement
+ .getAttribute(PANEL_MENU_ATTR_DISABLED_GROUP_CLASS);
+ } else {
+ disableClass = "rich-pmenu-group-disabled";
+ }
+
+ nsIDOMElement table = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ div.appendChild(table);
+ table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, "0");
+ table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, "0");
+
+ nsIDOMElement tableBody = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ table.appendChild(tableBody);
+
+ nsIDOMElement column1 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ column1.setAttribute(COMPONENT_ATTR_VPE_USER_TOGGLE_ID, String
+ .valueOf(activeChildId));
+ tableBody.appendChild(column1);
+
+ nsIDOMElement img1 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_IMG);
+ column1.appendChild(img1);
+ ComponentUtil.setImg(img1, PANEL_MENU_GROUP_ICON_SPACER_PATH);
+ img1.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "rich-pmenu-group-icon");
+
+ nsIDOMElement column2 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ tableBody.appendChild(column2);
+ column2.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "width: 100%;");
+
+ nsIDOMText name = visualDocument.createTextNode(sourceElement
+ .getAttribute(PANEL_MENU_GROUP_ATTR_ICON_LABEL));
+ column2.appendChild(name);
+ column2.setAttribute(COMPONENT_ATTR_VPE_USER_TOGGLE_ID, String
+ .valueOf(activeChildId));
+
+ nsIDOMElement column3 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ column3.setAttribute(COMPONENT_ATTR_VPE_USER_TOGGLE_ID, String
+ .valueOf(activeChildId));
+ tableBody.appendChild(column3);
+
+ nsIDOMElement img2 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_IMG);
+ column3.appendChild(img2);
+ img2.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "rich-pmenu-group-icon");
+ ComponentUtil.setImg(img2, PANEL_MENU_GROUP_ICON_SPACER_PATH);
+
+ setIcon(pageContext, parent, sourceParentElement, sourceElement, img1,
+ img2, expanded, disabled);
+
+ if (parent.getNodeName().endsWith(PANEL_MENU_END_TAG)) {
+ if (styleClass != null
+ && sourceParentElement
+ .getAttribute(PANEL_MENU_ATTR_TOP_GROUP_CLASS) != null) {
+ styleClass = "dr-pmenu-group-self-label dr-pmenu-top-group"
+ + " "
+ + sourceParentElement
+ .getAttribute(PANEL_MENU_ATTR_TOP_GROUP_CLASS);
+ } else {
+ styleClass = "dr-pmenu-group-self-label dr-pmenu-top-group";
+ }
+ if (style != null
+ && sourceParentElement
+ .getAttribute(PANEL_MENU_ATTR_TOP_GROUP_STYLE) != null) {
+ style = sourceParentElement
+ .getAttribute(PANEL_MENU_ATTR_TOP_GROUP_STYLE);
+ } else {
+ style = "";
+ }
+ div.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "dr-pmenu-top-group-div");
+ } else {
+ if (styleClass != null
+ && sourceParentElement
+ .getAttribute(PANEL_MENU_ATTR_GROUP_CLASS) != null) {
+ styleClass = "dr-pmenu-group-self-label rich-pmenu-group-self-label"
+ + " "
+ + sourceParentElement
+ .getAttribute(PANEL_MENU_ATTR_GROUP_CLASS);
+ } else {
+ styleClass = "dr-pmenu-group-self-label rich-pmenu-group-self-label";
+ }
+ if (style != null
+ && sourceParentElement
+ .getAttribute(PANEL_MENU_ATTR_GROUP_STYLE) != null) {
+ style = sourceParentElement
+ .getAttribute(PANEL_MENU_ATTR_GROUP_STYLE);
+ } else {
+ style = "";
+ }
+ div.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "dr-pmenu-top-self-div");
+ }
+
+ if (disabled) {
+ styleClass = styleClass + " " + disableClass;
+
+ if (disabledStyle != null) {
+ style = style + " " + disabledStyle;
+ }
+ }
+
+ if (!"".equals(style.trim())) {
+ table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, style);
+ }
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, styleClass);
+ }
+
+ private static final Element getRichPanelParent(Element sourceElement) {
+ Element parent = (Element) sourceElement.getParentNode();
+
+ while (true) {
+ if (parent.getNodeName().endsWith(PANEL_MENU_END_TAG)
+ || parent.getNodeName().endsWith(PANEL_MENU_GROUP_END_TAG)) {
+ break;
+ } else {
+ parent = (Element) parent.getParentNode();
+ }
+ }
+
+ return parent;
+ }
+
+ private static final void setIcon(VpePageContext pageContext, Node parent,
+ Element sourceParentElement, Element sourceElement,
+ nsIDOMElement img1, nsIDOMElement img2, boolean expanded,
+ boolean disabled) {
+ boolean needChangePosition = false;
+ String pathIconExpanded = sourceElement
+ .getAttribute(PANEL_MENU_GROUP_ATTR_ICON_EXPANDED);
+ String pathIconCollapsed = sourceElement
+ .getAttribute(PANEL_MENU_GROUP_ATTR_ICON_COLLAPSED);
+ String pathIconDisabled = sourceElement
+ .getAttribute(PANEL_MENU_GROUP_ATTR_ICON_DISABLED);
+
+ if (parent.getNodeName().endsWith(PANEL_MENU_END_TAG)) {
+ if (pathIconExpanded == null) {
+ pathIconExpanded = sourceParentElement
+ .getAttribute(PANEL_MENU_ATTR_ICON_EXPANDED_TOP_GROUP);
+ }
+ if (pathIconCollapsed == null) {
+ pathIconCollapsed = sourceParentElement
+ .getAttribute(PANEL_MENU_ATTR_ICON_COLLAPSED_TOP_GROUP);
+ }
+ if (pathIconDisabled == null) {
+ pathIconDisabled = sourceParentElement
+ .getAttribute(PANEL_MENU_ATTR_ICON_TOP_DISABLE_GROUP);
+ }
+
+ if ("right".equals(sourceParentElement
+ .getAttribute(PANEL_MENU_ATTR_ICON_TOP_GROUP_POSITION))) {
+ needChangePosition = true;
+ }
+ } else {
+ if (pathIconExpanded == null) {
+ pathIconExpanded = sourceParentElement
+ .getAttribute(PANEL_MENU_ATTR_ICON_EXPANDED_GROUP);
+ }
+ if (pathIconCollapsed == null) {
+ pathIconCollapsed = sourceParentElement
+ .getAttribute(PANEL_MENU_ATTR_ICON_COLLAPSED_GROUP);
+ }
+ if (pathIconDisabled == null) {
+ pathIconDisabled = sourceParentElement
+ .getAttribute(PANEL_MENU_ATTR_ICON_DISABLE_GROUP);
+ }
+
+ if ("right".equals(sourceParentElement
+ .getAttribute(PANEL_MENU_ATTR_ICON_GROUP_POSITION))) {
+ needChangePosition = true;
+ }
+ }
+
+ if (needChangePosition) {
+ nsIDOMElement temp = img2;
+ img2 = img1;
+ img1 = temp;
+ }
+
+ if (disabled) {
+ if (pathIconDisabled != null
+ && DEFAULT_ICON_MAP.containsKey(pathIconDisabled)) {
+ pathIconDisabled = DEFAULT_ICON_MAP.get(pathIconDisabled);
+ ComponentUtil.setImg(img1, pathIconDisabled);
+ } else {
+ ComponentUtil.setImgFromResources(pageContext, img1,
+ pathIconDisabled, PANEL_MENU_GROUP_ICON_SPACER_PATH);
+ }
+ } else {
+ if (expanded) {
+ if (pathIconExpanded != null
+ && DEFAULT_ICON_MAP.containsKey(pathIconExpanded)) {
+ pathIconExpanded = DEFAULT_ICON_MAP.get(pathIconExpanded);
+ ComponentUtil.setImg(img1, pathIconExpanded);
+ } else {
+ ComponentUtil
+ .setImgFromResources(pageContext, img1,
+ pathIconExpanded,
+ PANEL_MENU_GROUP_ICON_SPACER_PATH);
+ }
+ } else {
+ if (pathIconCollapsed != null
+ && DEFAULT_ICON_MAP.containsKey(pathIconCollapsed)) {
+ pathIconCollapsed = DEFAULT_ICON_MAP.get(pathIconCollapsed);
+ ComponentUtil.setImg(img1, pathIconCollapsed);
+ } else {
+ ComponentUtil.setImgFromResources(pageContext, img1,
+ pathIconCollapsed,
+ PANEL_MENU_GROUP_ICON_SPACER_PATH);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java
(rev 0)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java 2007-10-16
13:14:30 UTC (rev 4225)
@@ -0,0 +1,348 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jsf.vpe.richfaces.template;
+
+import java.util.List;
+
+import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
+import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMText;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class RichFacesPanelMenuItemTemplate extends VpeAbstractTemplate {
+
+ private static final String STYLE_PATH = "/panelMenuItem/style.css";
+
+ private static final String PANEL_MENU_ITEM_CLASS = "dr-pmenu-item";
+
+ private static final String NO_SIZE_VALUE = "0";
+
+ private static final String DEFAULT_SIZE_VALUE = "16";
+
+ private static final String PANEL_MENU_NOWARP_CLASS = "dr-pmenu-nowrap";
+
+ private static final String PANEL_MENU_LABLE_CLASS =
"dr-pmenu-group-self-label";
+
+ private static final String PANEL_MENU_DIV = "dr-pmenu-top-self-div";
+
+ private static final String PANEL_MENU_ITEM = "panelMenuItem";
+
+ private static final String IMG_POINTS_SRC = "/panelMenuItem/points.gif";
+
+ private static final String IMG_SPACER_SRC = "/panelMenuItem/spacer.gif";
+
+ private static final String EMPTY_DIV_STYLE = "display: none;";
+
+ private static final String DISABLED_CLASS = "dr-pmenu-item-disabled";
+
+ private static final String DISABLED_ITEM_STYLE = "disabledItemStyle";
+
+ private static final String ITEM_CLASS = "itemClass";
+
+ private static final String ICON_ITEM_TOP_POSITION = "iconItemTopPosition";
+
+ private static final String TOP_ITEM_STYLE = "topItemStyle";
+
+ private static final String ICON_TOP_DISABLED_ITEM = "iconTopDisabledItem";
+
+ private static final String DISABLE_ITEM_CLASS = "disableItemClass";
+
+ private static final String ICON_DISABLED_ITEM = "iconDisabledItem";
+
+ private static final String ICON_ITEM_POSITION = "iconItemPosition";
+
+ private static final String ICON_ITEM = "iconItem";
+
+ private static final String ICON_TOP_ITEM = "iconTopItem";
+
+ private static final String TOP_ITEM_CLASS = "topItemClass";
+
+ private static final String ITEM_STYLE = "itemStyle";
+
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ nsIDOMElement div = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ div.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, EMPTY_DIV_STYLE);
+
+ return new VpeCreationData(div);
+ }
+
+ public static VpeCreationData encode(VpePageContext pageContext,
+ VpeCreationData creationData, Element sourceParentElement,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement parentVisualElement, boolean active) {
+
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH, PANEL_MENU_ITEM);
+
+ nsIDOMElement parentDiv = visualDocument.createElement("div");
+ parentDiv.setAttribute("CLASS", PANEL_MENU_DIV);
+ parentVisualElement.appendChild(parentDiv);
+ nsIDOMElement div = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+
+ parentDiv.appendChild(div);
+
+ if (sourceElement.getParentNode().getNodeName().endsWith(
+ ":panelMenuGroup")
+ || (sourceElement.getParentNode().getNodeName()
+ .endsWith(":panelMenu"))) {
+ div.setAttribute("vpeSupport", PANEL_MENU_ITEM);
+ nsIDOMElement table = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ div.appendChild(table);
+
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ PANEL_MENU_ITEM_CLASS);
+ table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR,
+ NO_SIZE_VALUE);
+ table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR,
+ NO_SIZE_VALUE);
+ table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR,
+ NO_SIZE_VALUE);
+
+ nsIDOMElement tr = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ table.appendChild(tr);
+
+ nsIDOMElement tdNowrap = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ tr.appendChild(tdNowrap);
+ tdNowrap.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ PANEL_MENU_NOWARP_CLASS);
+
+ nsIDOMElement tdLable = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ tr.appendChild(tdLable);
+ tdLable.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ PANEL_MENU_LABLE_CLASS);
+ tdLable.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ "element.style");
+ String value = sourceElement.getAttribute("label");
+ nsIDOMText text = visualDocument.createTextNode(value == null ? ""
+ : value);
+
+ tdLable.appendChild(text);
+
+ nsIDOMElement td = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ tr.appendChild(td);
+
+ nsIDOMElement imgPoints = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_IMG);
+
+ nsIDOMElement imgSpacer1 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_IMG);
+
+ tdNowrap.appendChild(imgSpacer1);
+ setDefaultImgAttributes(imgSpacer1);
+ ComponentUtil.setImg(imgSpacer1, IMG_SPACER_SRC);
+
+ nsIDOMElement imgSpacer2 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_IMG);
+
+ if (sourceElement.getParentNode().getNodeName().endsWith(
+ ":panelMenu")) {
+ String icon = sourceElement.getAttribute("icon");
+ if (icon == null || icon.length() == 0) {
+ setItemImage(sourceElement, sourceParentElement, td,
+ tdNowrap, ICON_ITEM_TOP_POSITION, pageContext,
+ visualDocument, sourceParentElement
+ .getAttribute(ICON_TOP_ITEM), imgPoints,
+ imgSpacer2);
+ } else {
+ setItemImage(sourceElement, sourceParentElement, td,
+ tdNowrap, ICON_ITEM_TOP_POSITION, pageContext,
+ visualDocument, icon, imgPoints, imgSpacer2);
+ }
+
+ setItemClassAndStyle(sourceElement, sourceParentElement,
+ imgPoints, pageContext, table, sourceParentElement
+ .getAttribute(TOP_ITEM_CLASS),
+ sourceParentElement.getAttribute(TOP_ITEM_STYLE),
+ sourceParentElement
+ .getAttribute(ICON_TOP_DISABLED_ITEM));
+
+ } else {
+ if (sourceElement.getParentNode().getNodeName().endsWith(
+ ":panelMenuGroup")) {
+ String icon = sourceElement.getAttribute("icon");
+ if (icon == null || icon.length() == 0) {
+ setItemImage(sourceElement, sourceParentElement, td,
+ tdNowrap, ICON_ITEM_POSITION, pageContext,
+ visualDocument, sourceParentElement
+ .getAttribute(ICON_ITEM), imgPoints,
+ imgSpacer2);
+ } else {
+ setItemImage(sourceElement, sourceParentElement, td,
+ tdNowrap, ICON_ITEM_POSITION, pageContext,
+ visualDocument, icon, imgPoints, imgSpacer2);
+ }
+ }
+
+ setItemClassAndStyle(sourceElement, sourceParentElement,
+ imgPoints, pageContext, table, sourceParentElement
+ .getAttribute(ITEM_CLASS), sourceParentElement
+ .getAttribute(ITEM_STYLE), sourceParentElement
+ .getAttribute(ICON_DISABLED_ITEM));
+ }
+
+ List<Node> children = ComponentUtil.getChildren(sourceElement);
+
+ if (!children.isEmpty()) {
+ VpeChildrenInfo childInfo = new VpeChildrenInfo(tdLable);
+ creationData.addChildrenInfo(childInfo);
+ for (Node child : children) {
+ if (!(child.getNodeName().endsWith(":panelMenuGroup") || child
+ .getNodeName().endsWith(":panelMenu"))) {
+ childInfo.addSourceChild(child);
+ }
+ }
+ }
+ }
+ return creationData;
+ }
+
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, Document visualDocument, Node visualNode,
+ Object data, String name, String value) {
+ return true;
+ }
+
+ private static void setDefaultImgAttributes(nsIDOMElement element) {
+ element.setAttribute(HtmlComponentUtil.HTML_ATR_WIDTH,
+ DEFAULT_SIZE_VALUE);
+ element.setAttribute("vspace", NO_SIZE_VALUE);
+ element.setAttribute("hspace", NO_SIZE_VALUE);
+ element.setAttribute(HtmlComponentUtil.HTML_ATR_HEIGHT,
+ DEFAULT_SIZE_VALUE);
+ }
+
+ private static void setImagePosition(nsIDOMElement place,
+ nsIDOMElement image, VpePageContext pageContext, String icon) {
+ place.appendChild(image);
+ setDefaultImgAttributes(image);
+ if (icon == null || icon.length() == 0) {
+ ComponentUtil.setImg(image, IMG_POINTS_SRC);
+ } else {
+ ComponentUtil.setImgFromResources(pageContext, image, icon,
+ IMG_SPACER_SRC);
+ }
+ }
+
+ private static void setItemImage(Element sourceElement,
+ Element sourceParentElement, nsIDOMElement td,
+ nsIDOMElement tdNowrap, String attribute,
+ VpePageContext pageContext, nsIDOMDocument visualDocument,
+ String image, nsIDOMElement imgPoints, nsIDOMElement imgSpacer2) {
+ String iconPosition = sourceParentElement.getAttribute(attribute);
+ if (!(iconPosition == null)) {
+ if (iconPosition.equals("right")) {
+
+ setImagePosition(td, imgPoints, pageContext, image);
+
+ } else {
+ td.appendChild(imgSpacer2);
+ setDefaultImgAttributes(imgSpacer2);
+ ComponentUtil.setImg(imgSpacer2, IMG_SPACER_SRC);
+ if (iconPosition.equals("left")) {
+ setImagePosition(tdNowrap, imgPoints, pageContext, image);
+ }
+ }
+ } else {
+ setImagePosition(tdNowrap, imgPoints, pageContext, image);
+ td.appendChild(imgSpacer2);
+ setDefaultImgAttributes(imgSpacer2);
+ ComponentUtil.setImg(imgSpacer2, IMG_SPACER_SRC);
+ }
+ }
+
+ private static void setItemClassAndStyle(Element sourceElement,
+ Element sourceParentElement, nsIDOMElement imgPoints,
+ VpePageContext pageContext, nsIDOMElement table,
+ String parentClass, String parentStyle, String icon) {
+
+ if ("true".equals(sourceElement.getAttribute("disabled"))) {
+
+ String iconDisabled = sourceElement.getAttribute("iconDisabled");
+ if (iconDisabled == null || iconDisabled.length() == 0) {
+ if (!(icon == null || icon.length() == 0)) {
+ ComponentUtil.setImgFromResources(pageContext, imgPoints,
+ icon, IMG_POINTS_SRC);
+ } else {
+ ComponentUtil.setImg(imgPoints, IMG_POINTS_SRC);
+ }
+ } else {
+ ComponentUtil.setImgFromResources(pageContext, imgPoints,
+ iconDisabled, IMG_SPACER_SRC);
+ }
+
+ String resultDisabledClass = "";
+ String disabledItemClass = sourceParentElement
+ .getAttribute(DISABLE_ITEM_CLASS);
+ if (!(disabledItemClass == null || disabledItemClass.length() == 0)) {
+ resultDisabledClass += disabledItemClass;
+ }
+ String disabledClass = sourceElement.getAttribute("disabledClass");
+ if (!(disabledClass == null || disabledClass.length() == 0)) {
+ resultDisabledClass += disabledClass;
+ }
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ DISABLED_CLASS + " " + resultDisabledClass);
+
+ String resultDisabledStyle = "";
+ String disabledItemStyle = sourceParentElement
+ .getAttribute(DISABLED_ITEM_STYLE);
+ if (!(disabledItemStyle == null || disabledItemStyle.length() == 0)) {
+ resultDisabledStyle += disabledItemStyle;
+ }
+ String disabledStyle = sourceElement.getAttribute("disabledStyle");
+ if (!(disabledStyle == null || disabledStyle.length() == 0)) {
+ resultDisabledStyle += disabledStyle;
+ }
+ table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ resultDisabledStyle);
+
+ } else {
+ String resultClass = "";
+ String itemClass = parentClass;
+ if (!(itemClass == null || itemClass.length() == 0)) {
+ resultClass += itemClass;
+ }
+ String styleClass = sourceElement.getAttribute("styleClass");
+ if (!(styleClass == null || styleClass.length() == 0)) {
+ resultClass += styleClass;
+ }
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ PANEL_MENU_ITEM_CLASS + " " + resultClass);
+
+ String resultStyle = "";
+ String itemStyle = parentStyle;
+ if (!(itemStyle == null || itemStyle.length() == 0)) {
+ resultStyle += itemStyle;
+ }
+ String style = sourceElement.getAttribute("style");
+ if (!(style == null || style.length() == 0)) {
+ resultStyle += style;
+ }
+ table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, resultStyle);
+ }
+ }
+}
\ No newline at end of file
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuTemplate.java
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuTemplate.java
(rev 0)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuTemplate.java 2007-10-16
13:14:30 UTC (rev 4225)
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.richfaces.template;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
+import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
+import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.template.VpeToggableTemplate;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ *
+ * @author ezheleznyakov(a)exadel.com
+ *
+ */
+public class RichFacesPanelMenuTemplate extends VpeAbstractTemplate implements
+ VpeToggableTemplate {
+
+ private static final String WIDTH_ATTR_PANELMENU = "width";
+ private static final String STYLE_ATTR_PANELMENU = "style";
+ private static final String STYLECLASS_ATTR_PANELMENU = "styleClass";
+
+ 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 static final String DISABLED_STYLE_FOR_TABLE = "color:#B1ADA7";
+
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+
+ Element sourceElement = (Element) sourceNode;
+
+ String width = sourceElement.getAttribute(WIDTH_ATTR_PANELMENU);
+ String style = sourceElement.getAttribute(STYLE_ATTR_PANELMENU);
+ String styleClass = sourceElement.getAttribute(STYLECLASS_ATTR_PANELMENU);
+
+ if(width != null) {
+ style += "" + "; width:" + width;
+ }
+
+ nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
+ VpeCreationData vpeCreationData = new VpeCreationData(div);
+
+ if (style != null) {
+ div.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, style);
+ }
+
+ if (styleClass != null) {
+ div.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, styleClass);
+ }
+
+ List<Node> children = ComponentUtil.getChildren(sourceElement);
+ int activeId = getActiveId(sourceElement, children);
+ int i = 0;
+
+ 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);
+ i++;
+ } else if (child.getNodeName().endsWith(PANEL_MENU_ITEM_END)) {
+ RichFacesPanelMenuItemTemplate.encode(pageContext,
+ vpeCreationData, sourceElement, (Element) child,
+ visualDocument, div, expanded);
+ } else {
+ nsIDOMElement childDiv = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ VpeChildrenInfo childrenInfo = new VpeChildrenInfo(childDiv);
+ div.appendChild(childDiv);
+ childrenInfo.addSourceChild(child);
+ vpeCreationData.addChildrenInfo(childrenInfo);
+ }
+ }
+
+ return vpeCreationData;
+ }
+
+ /**
+ *
+ * @param sourceElement
+ * @param children
+ * @return
+ */
+ 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;
+ }
+
+ /**
+ *
+ * @param children
+ * @return
+ */
+ private int getChildrenCount(List<Node> children) {
+ int count = 0;
+ for (Node child : children) {
+ if (child.getNodeName().endsWith(PANEL_MENU_GROUP_END)) {
+ count++;
+ }
+ }
+ return count;
+ }
+
+ public void toggle(VpeVisualDomBuilder builder, Node sourceNode,
+ String toggleId) {
+ toggleMap.put(sourceNode, toggleId);
+ }
+
+ public void stopToggling(Node sourceNode) {
+ toggleMap.remove(sourceNode);
+ }
+
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, Document visualDocument, Node visualNode,
+ Object data, String name, String value) {
+ return true;
+ }
+}
\ No newline at end of file
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2007-10-16
13:12:38 UTC (rev 4224)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2007-10-16
13:14:30 UTC (rev 4225)
@@ -652,5 +652,29 @@
</span>
</vpe:template>
</vpe:tag>
+
+ <vpe:tag name="rich:panelMenuItem" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes"
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesPanelMenuItemTemplate">
+ <vpe:drag start-enable="yes"/>
+ <vpe:drop container="yes"/>
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="rich:panelMenuGroup" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes"
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesPanelMenuGroupTemplate">
+ <vpe:drag start-enable="yes"/>
+ <vpe:drop container="yes"/>
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="rich:panelMenu" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes"
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesPanelMenuTemplate">
+ <vpe:resize>
+ <vpe:width width-attr="width" />
+ </vpe:resize>
+ <vpe:drag start-enable="yes"/>
+ <vpe:drop container="yes"/>
+ </vpe:template>
+ </vpe:tag>
</vpe:templates>
\ No newline at end of file