Author: dmaliarevich
Date: 2008-10-10 09:52:31 -0400 (Fri, 10 Oct 2008)
New Revision: 10774
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/dropDownMenu/dropDownMenu.css
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuGroup/menuGroup.css
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuItem/menuItem.css
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, dropping down was implemented through css and html only, code style was
reviewed.
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/dropDownMenu/dropDownMenu.css
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/dropDownMenu/dropDownMenu.css 2008-10-10
13:52:12 UTC (rev 10773)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/dropDownMenu/dropDownMenu.css 2008-10-10
13:52:31 UTC (rev 10774)
@@ -3,14 +3,12 @@
font-size:11px;
height:auto;
left:0pt;
- padding:2px 5px;
top:0pt;
white-space:nowrap;
width:auto;
}
.rich-ddmenu-label-unselect {
border:0pt solid transparent;
- padding:3px 6px;
}
.rich-ddmenu-label-select {
@@ -28,51 +26,34 @@
}
-.dr-menu-list-border {
- border : 1px solid #bfbfc0;
- background-color : #e7f2fb;
- float : left;
- position : absolute;
+[vpe-ddm-menu-ul] {
+ margin: 0;
+ padding: 0;
+ list-style: none;
+ width: 150px;
+ display: block;
}
-.dr-menu-list-bg {
- border-top : 1px solid #e7f2fb;
- border-left : 1px solid #e7f2fb;
- border-right : 1px solid #e7f2fb;
- background : url(menu_list_bg.gif) repeat-y left;
+[vpe-ddm-menu-li] {
+ position: relative;
+ height: 30px;
}
-.dr-menu-label {
- padding : 2px 5px 2px 5px;
- white-space : nowrap;
- position: relative;
- width : 75px;
- height : 18px;
+[vpe-ddm-menu-li] ul {
+ position: absolute;
+ left: 149px; /* Set 1px less than menu width */
+ top: 0;
+ display: none;
}
-.dr-menu-label-unselect {
- border : 1px solid transparent;
+[vpe-ddm-menu-li] div { /* ddm item/group div */
+
}
-.dr-menu-label-select {
- border : 1px solid #bfbfc0;
- cursor : pointer;
- background : #a9c5e7;
- color : #FFFFFF;
+[vpe-ddm-menu-li] div:hover {
+
}
-.dr-label-text-decor {
- font-weight : bold;
+[vpe-ddm-menu-ul]:hover {
+
}
-.underneath_iframe{
- position: absolute;
- z-index: 90;
- visibility:hidden;
- left:0px;
- top:0px;
- height:1px;
- width:1px;
+/*drop-down mechanism*/
+[vpe-ddm-menu-li]:hover > ul,
+[vpe-ddm-menu-li]:hover > li {
+ display: block;
}
-.dr-menu-list-border{
-border-color:#C4C0B9;background-color:#F1EEE9;}
-.dr-menu-list-bg{
-border-top-color:#F1EEE9;border-left-color:#F1EEE9;border-right-color:#F1EEE9;}
-.dr-menu-label{
-font-family:Arial, Verdana, sans-serif ;font-size:11px;}
-.dr-menu-label-select{
-border-color:#C4C0B9;background-color:#D4CFC7;color:#000000;}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuGroup/menuGroup.css
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuGroup/menuGroup.css 2008-10-10
13:52:12 UTC (rev 10773)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuGroup/menuGroup.css 2008-10-10
13:52:31 UTC (rev 10774)
@@ -4,7 +4,7 @@
font-size:11px;
}
.rich-menu-group-label {
-
+ padding-left: 10px; /*padding for group icon*/
}
.rich-menu-group-folder {
@@ -32,7 +32,7 @@
}
.rich-menu-item-icon-enabled {
border:0pt solid transparent;
- padding:2px 10px 2px 2px;
+ /*padding:2px 10px 2px 2px;*/
}
.rich-menu-item-icon-selected {
@@ -40,13 +40,13 @@
.rich-menu-list-border {
font-family:Arial,Verdana,sans-serif;
background-color:#F1EEE9;
- background-color:#F1EEE9;
border-color:#C4C0B9;
border:1px solid;
}
.rich-menu-list-bg {
background:transparent none repeat-y scroll left center;
background-image:url(list-bg.png);
+ background-color:#F1EEE9;
border-left-color:#C4C0B9;
border-right-color:#C4C0B9;
border-top-color:#C4C0B9;
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuItem/menuItem.css
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuItem/menuItem.css 2008-10-10
13:52:12 UTC (rev 10773)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuItem/menuItem.css 2008-10-10
13:52:31 UTC (rev 10774)
@@ -1,12 +1,14 @@
.rich-menu-item {
-
+ font-family:Arial,Verdana,sans-serif;
+ border-color:#C4C0B9;
+ border:1px solid;
}
.rich-menu-item-label {
-
+ /*padding-left: 10px;*/ /*padding for item icon*/
}
.rich-menu-item-icon {
+ padding:2px 10px 2px 2px;
border:0pt solid transparent;
- padding:2px 10px 2px 2px;
}
.rich-menu-item-disabled {
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-10
13:52:12 UTC (rev 10773)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java 2008-10-10
13:52:31 UTC (rev 10774)
@@ -10,22 +10,18 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.richfaces.template;
-import java.util.ArrayList;
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.VpeVisualDomBuilder;
+import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces;
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.util.HTML;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
-import org.mozilla.interfaces.nsIDOMNode;
-import org.mozilla.interfaces.nsIDOMNodeList;
import org.mozilla.interfaces.nsIDOMText;
-import org.mozilla.xpcom.XPCOMException;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -33,6 +29,12 @@
public class RichFacesDropDownMenuTemplate extends VpeAbstractTemplate {
/*
+ * Public constants for drop down mechanism.
+ */
+ public final static String MENU_PARENT_ID = "vpe-ddm-menu-ul"; //$NON-NLS-1$
+ public final static String MENU_CHILD_ID = "vpe-ddm-menu-li"; //$NON-NLS-1$
+
+ /*
* rich:dropDownMenu constants
*/
private final static String COMPONENT_NAME = "dropDownMenu"; //$NON-NLS-1$
@@ -51,9 +53,9 @@
private static final String CSS_RICH_LABEL_TEXT_DECOR =
"rich-label-text-decor"; //$NON-NLS-1$
private static final String CSS_RICH_MENU_LIST_BORDER =
"rich-menu-list-border"; //$NON-NLS-1$
private static final String CSS_RICH_MENU_LIST_BG = "rich-menu-list-bg";
//$NON-NLS-1$
- private static final String CSS_RICH_DDEMENU_LIST_DIV_STYLE = "position: relative;
z-index: 100; display: table;"; //$NON-NLS-1$
- private static final String CSS_RICH_DDEMENU_BORDER_DIV_STYLE = "position:
relative; z-index: 2; display: table;"; //$NON-NLS-1$
-
+ private static final String CSS_RICH_DDEMENU_LIST_DIV_STYLE = "";
//$NON-NLS-1$
+ private static final String CSS_RICH_DDEMENU_BORDER_DIV_STYLE = "";
//$NON-NLS-1$
+
/*
* rich:dropDownMenu attributes names
*/
@@ -97,27 +99,21 @@
private String ddm_style;
private String ddm_styleClass;
- private nsIDOMElement storedVisualMenu = null;
- private int ddmId = 1;
-
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
VpeCreationData creationData = null;
Element sourceElement = (Element)sourceNode;
- Element srcNode = null;
-
- if ((sourceElement.getUserData(VpeVisualDomBuilder.SRC_NODE) != null)
- && (sourceElement.getUserData(VpeVisualDomBuilder.SRC_NODE)
instanceof Element)) {
- srcNode = (Element) sourceElement.getUserData(VpeVisualDomBuilder.SRC_NODE);
- }
ComponentUtil.setCSSLink(pageContext, STYLE_PATH, COMPONENT_NAME);
readDropDownMenuAttributes(sourceElement);
-
/*
* DropDownMenu component structure.
* In order of nesting.
*/
+ nsIDOMElement ddmMainUL;
+ nsIDOMElement ddmMainLI;
+ nsIDOMElement ddmChildrenUL;
+
nsIDOMElement ddmLabelDiv;
nsIDOMElement ddmTextSpan;
nsIDOMText ddmLabelText;
@@ -128,25 +124,42 @@
/*
* Creating visual elements
*/
- ddmLabelDiv = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV);
- ddmTextSpan = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_SPAN);
- ddmLabelText = visualDocument.createTextNode(""); //$NON-NLS-1$
- ddmListDiv = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV);
- ddmListBorderDiv = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV);
- ddmListBgDiv = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV);
- creationData = new VpeCreationData(ddmLabelDiv);
- storedVisualMenu = ddmLabelDiv;
+
+ ddmMainUL = visualDocument.createElement(HTML.TAG_UL);
+ ddmMainLI = visualDocument.createElement(HTML.TAG_LI);
+ ddmChildrenUL = visualDocument.createElement(HTML.TAG_UL);
+ ddmLabelDiv = visualDocument.createElement(HTML.TAG_DIV);
+ ddmTextSpan = visualDocument.createElement(HTML.TAG_SPAN);
+ ddmLabelText = visualDocument.createTextNode(EMPTY);
+ ddmListDiv = visualDocument.createElement(HTML.TAG_DIV);
+ ddmListBorderDiv = visualDocument.createElement(HTML.TAG_DIV);
+ ddmListBgDiv = visualDocument.createElement(HTML.TAG_DIV);
+ creationData = new VpeCreationData(ddmMainUL);
/*
* Nesting elements
*/
ddmLabelDiv.appendChild(ddmTextSpan);
ddmTextSpan.appendChild(ddmLabelText);
- ddmLabelDiv.appendChild(ddmListDiv);
+// 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.
+ */
+// ddmMainLI.appendChild(ddmChildrenUL);
/*
+ * Setting attributes for the drop-down mechanism
+ */
+ ddmMainUL.setAttribute(MENU_PARENT_ID, EMPTY);
+ ddmMainLI.setAttribute(MENU_CHILD_ID, EMPTY);
+ ddmChildrenUL.setAttribute(MENU_PARENT_ID, EMPTY);
+
+ /*
* Setting css classes
*/
String labelDivClass = EMPTY;
@@ -160,11 +173,12 @@
listBorderDivClass += SPACE + ddm_styleClass;
}
- ddmLabelDiv.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, labelDivClass);
- ddmTextSpan.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
CSS_RICH_LABEL_TEXT_DECOR);
- ddmListBorderDiv.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, listBorderDivClass);
- ddmListBgDiv.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, CSS_RICH_MENU_LIST_BG);
-
+// ddmLabelDiv.setAttribute(HTML.CLASS_ATTR, labelDivClass);
+ ddmMainLI.setAttribute(HTML.ATTR_CLASS, labelDivClass);
+ ddmTextSpan.setAttribute(HTML.ATTR_CLASS, CSS_RICH_LABEL_TEXT_DECOR);
+// ddmListBorderDiv.setAttribute(HTML.ATTR_CLASS, listBorderDivClass);
+// ddmListBgDiv.setAttribute(HTML.ATTR_CLASS, CSS_RICH_MENU_LIST_BG);
+ ddmChildrenUL.setAttribute(HTML.ATTR_CLASS, listBorderDivClass + SPACE +
CSS_RICH_MENU_LIST_BG);
/*
* Setting css styles
*/
@@ -179,107 +193,50 @@
cssLabelDivStyle += SPACE + ddm_style;
}
- ddmListDiv.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, cssListDivStyle);
- ddmListBorderDiv.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
cssListBorderDivStyle);
- ddmLabelDiv.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, cssLabelDivStyle);
-
+// ddmListDiv.setAttribute(HTML.STYLE_ATTR, cssListDivStyle);
+// ddmListBorderDiv.setAttribute(HTML.STYLE_ATTR, cssListBorderDivStyle);
+// ddmLabelDiv.setAttribute(HTML.STYLE_ATTR, cssLabelDivStyle);
+ ddmMainLI.setAttribute(HTML.ATTR_STYLE, cssListDivStyle + SPACE + cssListBorderDivStyle
+ SPACE + cssLabelDivStyle);
+ ddmChildrenUL.setAttribute(HTML.ATTR_STYLE, cssListDivStyle + SPACE +
cssListBorderDivStyle + SPACE + cssLabelDivStyle);
/*
* Encoding label value
*/
- final Element passedElement = (srcNode != null ? srcNode : sourceElement);
- final Element labelFacet = ComponentUtil.getFacet(passedElement, LABEL_FACET_NAME);
+ Element labelFacet = ComponentUtil.getFacet(sourceElement, LABEL_FACET_NAME);
if (null != labelFacet) {
VpeChildrenInfo childrenInfo = new VpeChildrenInfo(ddmTextSpan);
childrenInfo.addSourceChild(labelFacet);
creationData.addChildrenInfo(childrenInfo);
} else {
- Attr valueAttr = sourceElement.getAttributeNode(HtmlComponentUtil.HTML_VALUE_ATTR);
+ Attr valueAttr = sourceElement.getAttributeNode(HTML.ATTR_VALUE);
String labelValue = valueAttr != null && valueAttr.getValue() != null
? valueAttr.getValue()
: EMPTY;
ddmLabelText.setNodeValue(labelValue);
}
-
/*
* Adding child nodes
*/
- List<Node> children = ComponentUtil.getChildren(passedElement);
- int groupCount = 1;
- for (Node child : children) {
- if (child.getNodeType() == Node.ELEMENT_NODE
- && child.getNodeName().endsWith(":menuGroup")) { //$NON-NLS-1$
- child.setUserData(RichFacesMenuGroupTemplate.MENU_GROUP_ID,
- String.valueOf(groupCount), null);
- groupCount++;
+ 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);
+ childDivInfo.addSourceChild(child);
+ creationData.addChildrenInfo(childDivInfo);
}
- nsIDOMElement childDiv = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_DIV);
- ddmListBgDiv.appendChild(childDiv);
- VpeChildrenInfo childDivInfo = new VpeChildrenInfo(childDiv);
- childDivInfo.addSourceChild(child);
- creationData.addChildrenInfo(childDivInfo);
- }
+ }
return creationData;
}
-
- @Override
- public void validate(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument, VpeCreationData data) {
- super.validate(pageContext, sourceNode, visualDocument, data);
- List<nsIDOMElement> children = getChildren(storedVisualMenu);
-// storedVisualMenu.setAttribute(VpeVisualDomBuilder.VPE_USER_MOUSE_OVER_ID,
String.valueOf(ddmId));
-// applyAttributeValueOnChildren(VpeVisualDomBuilder.VPE_USER_MOUSE_OVER_ID,
String.valueOf(ddmId), children);
-// applyAttributeValueOnChildren(
-// VpeVisualDomBuilder.VPE_USER_MOUSE_OVER_LOOKUP_PARENT,
-// "true", children); //$NON-NLS-1$
- }
-
/**
- * Sets the attribute to element children
- * @param attrName attribute name
- * @param attrValue attribute value
- * @param children children
- */
- private void applyAttributeValueOnChildren(String attrName, String attrValue,
List<nsIDOMElement> children) {
- if (children == null || attrName == null || attrValue == null) {
- return;
- }
- for (nsIDOMElement child : children) {
- child.setAttribute(attrName, attrValue);
- applyAttributeValueOnChildren(attrName, attrValue, getChildren(child));
- }
- }
-
- /**
- * Gets element children
- * @param element the element
- * @return children
- */
- private List<nsIDOMElement> getChildren(nsIDOMElement element) {
- List<nsIDOMElement> result = new ArrayList<nsIDOMElement>();
- if (element.hasChildNodes()) {
- nsIDOMNodeList children = element.getChildNodes();
- if (null != children) {
- long len = children.getLength();
- for (int i = 0; i < len; i++) {
- nsIDOMNode item = children.item(i);
- try {
- nsIDOMElement elem = (nsIDOMElement) item
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- result.add(elem);
- } catch (XPCOMException ex) {
- // just ignore this exception
- }
- }
- }
- }
- return result;
- }
-
- /**
* Read attributes from the source element.
*
* @param sourceNode the source node
@@ -290,7 +247,7 @@
}
ddm_direction = sourceElement.getAttribute(DIRECTION);
- ddm_disabled = sourceElement.getAttribute(HtmlComponentUtil.HTML_ATTR_DISABLED);
+ ddm_disabled = sourceElement.getAttribute(HTML.ATTR_DISABLED);
ddm_horizontalOffset = sourceElement.getAttribute(HORIZONTAL_OFFCET);
ddm_jointPoint = sourceElement.getAttribute(JOINT_POINT);
ddm_popupWidth = sourceElement.getAttribute(POPUP_WIDTH);
@@ -303,8 +260,8 @@
ddm_itemStyle = sourceElement.getAttribute(ITEM_STYLE);
ddm_selectedLabelClass = sourceElement.getAttribute(SELECED_LABEL_CLASS);
ddm_selectItemClass = sourceElement.getAttribute(SELECT_ITEM_CLASS);
- ddm_style = sourceElement.getAttribute(HtmlComponentUtil.HTML_STYLE_ATTR);
- ddm_styleClass = sourceElement.getAttribute(HtmlComponentUtil.HTML_STYLECLASS_ATTR);
+ ddm_style = sourceElement.getAttribute(HTML.ATTR_STYLE);
+ ddm_styleClass = sourceElement.getAttribute(RichFaces.ATTR_STYLE_CLASS);
}
/**
@@ -317,16 +274,11 @@
private static boolean attrPresents(String attr) {
return ((null != attr) && (!EMPTY.equalsIgnoreCase(attr)));
}
-
- public void onMouseOver(VpeVisualDomBuilder visualDomBuilder, Node sourceNode, String
mouseOverId) {
- // TODO Auto-generated method stub
-// visualDomBuilder.updateNode(sourceNode);
+
+ @Override
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement visualNode, Object data, String name, String value) {
+ return true;
}
-
- public void stopMouseOver(Node sourceNode) {
- // TODO Auto-generated method stub
-
- }
-
-
}
\ No newline at end of file
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-10
13:52:12 UTC (rev 10773)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuGroupTemplate.java 2008-10-10
13:52:31 UTC (rev 10774)
@@ -13,12 +13,12 @@
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.VpeVisualDomBuilder;
+import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces;
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.util.HTML;
import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
@@ -59,8 +59,8 @@
private static final String CSS_RICH_MENU_ITEM_ICON_SELECTED =
"rich-menu-item-icon-selected"; //$NON-NLS-1$
private static final String CSS_RICH_MENU_LIST_BORDER =
"rich-menu-list-border"; //$NON-NLS-1$
private static final String CSS_RICH_MENU_LIST_BG = "rich-menu-list-bg";
//$NON-NLS-1$
- private static final String CSS_RICH_LIST_FOLDER_DIV_STYLE = "position: relative;
z-index: 100; display: table;"; //$NON-NLS-1$
- private static final String CSS_RICH_LIST_BORDER_DIV_STYLE = "position: relative;
z-index: 2; display: table;"; //$NON-NLS-1$
+ private static final String CSS_RICH_LIST_FOLDER_DIV_STYLE = "";
//$NON-NLS-1$
+ private static final String CSS_RICH_LIST_BORDER_DIV_STYLE = "";
//$NON-NLS-1$
/*
* rich:menuGroup attributes names
@@ -113,6 +113,11 @@
* MenuGroup component structure.
* In order of nesting.
*/
+ nsIDOMElement ddmMainUL;
+ nsIDOMElement grMainLI;
+ nsIDOMElement grChildrenUL;
+ nsIDOMElement ddmChildrenLI;
+
nsIDOMElement grTopDiv;
nsIDOMElement grImgSpan;
nsIDOMElement grImg;
@@ -125,15 +130,17 @@
/*
* Creating visual elements
*/
- grTopDiv = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV);
- grImgSpan = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_SPAN);
- grImg = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_IMG);
- grLabelSpan = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_SPAN);
+ grMainLI = visualDocument.createElement(HTML.TAG_LI);
+ grChildrenUL = visualDocument.createElement(HTML.TAG_UL);
+ grTopDiv = visualDocument.createElement(HTML.TAG_DIV);
+ grImgSpan = visualDocument.createElement(HTML.TAG_SPAN);
+ grImg = visualDocument.createElement(HTML.TAG_IMG);
+ grLabelSpan = visualDocument.createElement(HTML.TAG_SPAN);
grLabelText = visualDocument.createTextNode(EMPTY);
- grFolderDiv = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV);
- grListBorderDiv = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV);
- grListBgDiv = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV);
- creationData = new VpeCreationData(grTopDiv);
+ grFolderDiv = visualDocument.createElement(HTML.TAG_DIV);
+ grListBorderDiv = visualDocument.createElement(HTML.TAG_DIV);
+ grListBgDiv = visualDocument.createElement(HTML.TAG_DIV);
+ creationData = new VpeCreationData(grMainLI);
/*
* Nesting elements
@@ -141,14 +148,24 @@
grTopDiv.appendChild(grImgSpan);
grTopDiv.appendChild(grLabelSpan);
grLabelSpan.appendChild(grLabelText);
- grTopDiv.appendChild(grFolderDiv);
- grFolderDiv.appendChild(grListBorderDiv);
- grListBorderDiv.appendChild(grListBgDiv);
+// grTopDiv.appendChild(grFolderDiv);
+// grFolderDiv.appendChild(grListBorderDiv);
+// grListBorderDiv.appendChild(grListBgDiv);
+ grMainLI.appendChild(grTopDiv);
+ /*
+ * Children <ul> will be added only if there are some of them.
+ */
+// grMainLI.appendChild(grChildrenUL);
/*
+ * Setting attributes for the drop-down mechanism
+ */
+ grMainLI.setAttribute(RichFacesDropDownMenuTemplate.MENU_CHILD_ID, EMPTY);
+ grChildrenUL.setAttribute(RichFacesDropDownMenuTemplate.MENU_PARENT_ID, EMPTY);
+
+ /*
* Setting css classes
*/
-
String topDivClass = EMPTY;
String imgSpanClass = EMPTY;
String labelSpanClass = EMPTY;
@@ -170,13 +187,14 @@
labelSpanClass += SPACE + mg_labelClass;
}
- grTopDiv.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, topDivClass);
- grImgSpan.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, imgSpanClass);
- grLabelSpan.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, labelSpanClass);
- grFolderDiv.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, folderDivClass);
- grListBorderDiv.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
CSS_RICH_MENU_LIST_BORDER);
- grListBgDiv.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, CSS_RICH_MENU_LIST_BG);
-
+// grTopDiv.setAttribute(HTML.CLASS_ATTR, topDivClass);
+ grMainLI.setAttribute(HTML.ATTR_CLASS, topDivClass);
+ grImgSpan.setAttribute(HTML.ATTR_CLASS, imgSpanClass);
+ grLabelSpan.setAttribute(HTML.ATTR_CLASS, labelSpanClass);
+// grFolderDiv.setAttribute(HTML.ATTR_CLASS, folderDivClass);
+// grListBorderDiv.setAttribute(HTML.ATTR_CLASS, CSS_RICH_MENU_LIST_BORDER);
+// grListBgDiv.setAttribute(HTML.ATTR_CLASS, CSS_RICH_MENU_LIST_BG);
+ grChildrenUL.setAttribute(HTML.ATTR_CLASS, folderDivClass + SPACE +
CSS_RICH_MENU_LIST_BORDER + SPACE + CSS_RICH_MENU_LIST_BG);
/*
* Setting css styles
*/
@@ -186,14 +204,16 @@
topDivStyle += SPACE + mg_style;
}
- grTopDiv.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, topDivStyle);
- grFolderDiv.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
CSS_RICH_LIST_FOLDER_DIV_STYLE);
- grListBorderDiv.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
CSS_RICH_LIST_BORDER_DIV_STYLE);
+// grTopDiv.setAttribute(HTML.STYLE_ATTR, topDivStyle);
+ grMainLI.setAttribute(HTML.ATTR_STYLE, topDivStyle);
+// grFolderDiv.setAttribute(HTML.ATTR_STYLE, CSS_RICH_LIST_FOLDER_DIV_STYLE);
+// grListBorderDiv.setAttribute(HTML.ATTR_STYLE, CSS_RICH_LIST_BORDER_DIV_STYLE);
+ grChildrenUL.setAttribute(HTML.ATTR_STYLE, CSS_RICH_LIST_FOLDER_DIV_STYLE + SPACE +
CSS_RICH_LIST_BORDER_DIV_STYLE);
/*
* Encode label value
*/
- Attr valueAttr = sourceElement.getAttributeNode(HtmlComponentUtil.HTML_VALUE_ATTR);
+ Attr valueAttr = sourceElement.getAttributeNode(HTML.ATTR_VALUE);
String labelValue = valueAttr != null
&& valueAttr.getValue() != null ? valueAttr.getValue() : EMPTY;
grLabelText.setNodeValue(labelValue);
@@ -202,7 +222,7 @@
* Encode icon facets
*/
Element iconFacet = ComponentUtil.getFacet(sourceElement, ICON_FACET_NAME);
- Element iconDisabledFacet = ComponentUtil.getFacet(sourceElement,
ICON_DISABLED_FACET_NAME);
+// Element iconDisabledFacet = ComponentUtil.getFacet(sourceElement,
ICON_DISABLED_FACET_NAME);
if (null != iconFacet) {
VpeChildrenInfo childInfo = new VpeChildrenInfo(grImgSpan);
childInfo.addSourceChild(iconFacet);
@@ -214,7 +234,7 @@
* Add path to specified image
*/
String imgFullPath = VpeStyleUtil.addFullPathToImgSrc(iconPath, pageContext, true);
- grImg.setAttribute(HtmlComponentUtil.HTML_ATR_SRC, imgFullPath);
+ grImg.setAttribute(HTML.ATTR_SRC, imgFullPath);
} else {
/*
* Create spacer image
@@ -228,20 +248,27 @@
}
- String menuGroupId = (String) sourceNode.getUserData(MENU_GROUP_ID);
+// String menuGroupId = (String) sourceNode.getUserData(MENU_GROUP_ID);
/*
* Adding child nodes
*/
List<Node> children = ComponentUtil.getChildren(sourceElement);
- for (Node child : children) {
- nsIDOMElement childDiv = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_DIV);
- grListBgDiv.appendChild(childDiv);
- VpeChildrenInfo childDivInfo = new VpeChildrenInfo(childDiv);
- childDivInfo.addSourceChild(child);
- creationData.addChildrenInfo(childDivInfo);
+ 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);
+ VpeChildrenInfo childDivInfo = new VpeChildrenInfo(grChildrenUL);
+ childDivInfo.addSourceChild(child);
+ creationData.addChildrenInfo(childDivInfo);
+ }
}
-
+
return creationData;
}
@@ -255,20 +282,20 @@
return;
}
mg_direction = sourceElement.getAttribute(DIRECTION);
- mg_disabled = sourceElement.getAttribute(HtmlComponentUtil.HTML_ATTR_DISABLED);
+ mg_disabled = sourceElement.getAttribute(HTML.ATTR_DISABLED);
mg_icon = sourceElement.getAttribute(ICON);
mg_iconDisabled = sourceElement.getAttribute(ICON_DISABLED);
mg_iconFolder = sourceElement.getAttribute(ICON_FOLDER);
mg_iconFolderDisabled = sourceElement.getAttribute(ICON_FOLDER_DISABLED);
- mg_value = sourceElement.getAttribute(HtmlComponentUtil.HTML_VALUE_ATTR);
+ mg_value = sourceElement.getAttribute(HTML.ATTR_VALUE);
mg_iconClass = sourceElement.getAttribute(ICON_CLASS);
mg_iconStyle = sourceElement.getAttribute(ICON_STYLE);
mg_labelClass = sourceElement.getAttribute(LABEL_CLASS);
mg_selectClass = sourceElement.getAttribute(SELECT_CLASS);
mg_selectStyle = sourceElement.getAttribute(SELECT_STYLE);
- mg_style = sourceElement.getAttribute(HtmlComponentUtil.HTML_STYLE_ATTR);
- mg_styleClass = sourceElement.getAttribute(HtmlComponentUtil.HTML_STYLECLASS_ATTR);
+ mg_style = sourceElement.getAttribute(HTML.ATTR_STYLE);
+ mg_styleClass = sourceElement.getAttribute(RichFaces.ATTR_STYLE_CLASS);
}
/**
* Checks is attribute have some value.
@@ -287,15 +314,5 @@
nsIDOMElement visualNode, Object data, String name, String value) {
return true;
}
-
- public void onMouseOver(VpeVisualDomBuilder visualDomBuilder, Node sourceNode, String
mouseOverId) {
- // TODO Auto-generated method stub
-// visualDomBuilder.updateNode(sourceNode);
- }
-
- public void stopMouseOver(Node sourceNode) {
- // TODO Auto-generated method stub
-
- }
}
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-10
13:52:12 UTC (rev 10773)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuItemTemplate.java 2008-10-10
13:52:31 UTC (rev 10774)
@@ -13,12 +13,12 @@
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.VpeVisualDomBuilder;
+import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces;
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.util.HTML;
import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
@@ -101,6 +101,8 @@
* MenuItem component structure.
* In order of nesting.
*/
+ nsIDOMElement itemMainLI;
+
nsIDOMElement itemTopDiv;
nsIDOMElement itemIconImgSpan;
nsIDOMElement itemIconImg;
@@ -110,12 +112,13 @@
/*
* Creating visual elements
*/
- itemTopDiv = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV);
- itemIconImgSpan = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_SPAN);
- itemIconImg = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_IMG);
- itemLabelSpan = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_SPAN);
- itemLabelText = visualDocument.createTextNode(""); //$NON-NLS-1$
- creationData = new VpeCreationData(itemTopDiv);
+ itemMainLI = visualDocument.createElement(HTML.TAG_LI);
+ itemTopDiv = visualDocument.createElement(HTML.TAG_DIV);
+ itemIconImgSpan = visualDocument.createElement(HTML.TAG_SPAN);
+ itemIconImg = visualDocument.createElement(HTML.TAG_IMG);
+ itemLabelSpan = visualDocument.createElement(HTML.TAG_SPAN);
+ itemLabelText = visualDocument.createTextNode(EMPTY);
+ creationData = new VpeCreationData(itemMainLI);
/*
* Nesting elements
@@ -123,8 +126,14 @@
itemTopDiv.appendChild(itemIconImgSpan);
itemTopDiv.appendChild(itemLabelSpan);
itemLabelSpan.appendChild(itemLabelText);
+ itemMainLI.appendChild(itemTopDiv);
/*
+ * Setting attributes for the drop-down mechanism
+ */
+ itemMainLI.setAttribute(RichFacesDropDownMenuTemplate.MENU_CHILD_ID, EMPTY);
+
+ /*
* Setting css classes
*/
String topDivClass = EMPTY;
@@ -145,9 +154,11 @@
labelSpanClass += SPACE + mi_labelClass;
}
- itemTopDiv.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, topDivClass);
- itemIconImgSpan.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, iconImgSpanClass);
- itemLabelSpan.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, labelSpanClass);
+// itemTopDiv.setAttribute(HTML.ATTR_CLASS, topDivClass);
+ itemMainLI.setAttribute(HTML.ATTR_CLASS, topDivClass);
+ itemIconImgSpan.setAttribute(HTML.ATTR_CLASS, iconImgSpanClass);
+ itemLabelSpan.setAttribute(HTML.ATTR_CLASS, labelSpanClass);
+
/*
* Setting css styles
@@ -158,21 +169,22 @@
topDivStyle += SPACE + mi_style;
}
- itemTopDiv.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, topDivStyle);
+// itemTopDiv.setAttribute(HTML.ATTR_STYLE, topDivStyle);
+ itemMainLI.setAttribute(HTML.ATTR_STYLE, topDivStyle);
/*
* Encode label and icon value
*/
- Attr valueAttr = sourceElement.getAttributeNode(HtmlComponentUtil.HTML_VALUE_ATTR);
+ Attr valueAttr = sourceElement.getAttributeNode(HTML.ATTR_VALUE);
String labelValue = valueAttr != null
- && valueAttr.getValue() != null ? valueAttr.getValue() : "";
//$NON-NLS-1$
+ && valueAttr.getValue() != null ? valueAttr.getValue() : EMPTY;
itemLabelText.setNodeValue(labelValue);
/*
* Encode icon facets
*/
Element iconFacet = ComponentUtil.getFacet(sourceElement, ICON_FACET_NAME);
- Element iconDisabledFacet = ComponentUtil.getFacet(sourceElement,
ICON_DISABLED_FACET_NAME);
+// Element iconDisabledFacet = ComponentUtil.getFacet(sourceElement,
ICON_DISABLED_FACET_NAME);
if (null != iconFacet) {
VpeChildrenInfo childInfo = new VpeChildrenInfo(itemIconImgSpan);
childInfo.addSourceChild(iconFacet);
@@ -184,7 +196,7 @@
* Add path to specified image
*/
String imgFullPath = VpeStyleUtil.addFullPathToImgSrc(iconPath, pageContext, true);
- itemIconImg.setAttribute(HtmlComponentUtil.HTML_ATR_SRC, imgFullPath);
+ itemIconImg.setAttribute(HTML.ATTR_SRC, imgFullPath);
} else {
/*
* Create spacer image
@@ -221,9 +233,9 @@
if (null == sourceElement) {
return;
}
- mi_disabled = sourceElement.getAttribute(HtmlComponentUtil.HTML_ATTR_DISABLED);
+ mi_disabled = sourceElement.getAttribute(HTML.ATTR_DISABLED);
mi_icon = sourceElement.getAttribute(ICON);
- mi_value = sourceElement.getAttribute(HtmlComponentUtil.HTML_VALUE_ATTR);
+ mi_value = sourceElement.getAttribute(HTML.ATTR_VALUE);
mi_iconClass = sourceElement.getAttribute(ICON_CLASS);
mi_iconDisabled = sourceElement.getAttribute(ICON_DISABLED);
@@ -231,8 +243,8 @@
mi_labelClass = sourceElement.getAttribute(LABEL_CLASS);
mi_selectClass = sourceElement.getAttribute(SELECT_CLASS);
mi_selectStyle = sourceElement.getAttribute(SELECT_STYLE);
- mi_style = sourceElement.getAttribute(HtmlComponentUtil.HTML_STYLE_ATTR);
- mi_styleClass = sourceElement.getAttribute(HtmlComponentUtil.HTML_STYLECLASS_ATTR);
+ mi_style = sourceElement.getAttribute(HTML.ATTR_STYLE);
+ mi_styleClass = sourceElement.getAttribute(RichFaces.ATTR_STYLE_CLASS);
}
/**
@@ -252,14 +264,5 @@
nsIDOMElement visualNode, Object data, String name, String value) {
return true;
}
-
- public void onMouseOver(VpeVisualDomBuilder visualDomBuilder, Node sourceNode, String
mouseOverId) {
- // TODO Auto-generated method stub
-// visualDomBuilder.updateNode(sourceNode);
- }
- public void stopMouseOver(Node sourceNode) {
- // TODO Auto-generated method stub
-
- }
}