Author: svasilyev
Date: 2007-09-18 13:18:05 -0400 (Tue, 18 Sep 2007)
New Revision: 3693
Modified:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java
Log:
JBIDE-901 and remove org.jboss.tools.vpe.ui plugin
Modified:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java 2007-09-18
16:58:04 UTC (rev 3692)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java 2007-09-18
17:18:05 UTC (rev 3693)
@@ -37,11 +37,9 @@
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
-
-
VpeCreationData creatorInfo = null;
- try {
- Element sourceElement = (Element)sourceNode;
+
+ Element sourceElement = (Element)sourceNode;
nsIDOMElement visualMenu =
visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV);
ComponentUtil.setCSSLink(pageContext, "dropDownMenu/dropDownMenu.css",
"richFacesDropDownMenu");
@@ -55,8 +53,6 @@
STYLE_ATTR_NAME,
HtmlComponentUtil.HTML_STYLE_ATTR, null, null);
- Attr ddmLabelFromAttribute = sourceElement.getAttributeNode("value");
-
nsIDOMElement visualMenuLabel =
visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV);
visualMenuLabel.setAttribute("class", "dr-label-text-decor
rich-label-text-decor");
correctAttribute(sourceElement, visualMenuLabel,
@@ -71,61 +67,52 @@
visualMenu.appendChild(visualMenuLabel);
- String ddmLabelFromFacet = getLabelFacet(sourceElement);
- Map visualNodeMap = pageContext.getDomMapping().getVisualMap();
creatorInfo = new VpeCreationData(visualMenu);
VpeChildrenInfo childrenInfo = new VpeChildrenInfo(visualMenuLabel);
- nsIDOMNode textLabel = null;
- if (ddmLabelFromFacet != null) {
- textLabel = visualDocument.createTextNode(ddmLabelFromFacet);
+ Element facetElement = getLabelFacet(sourceElement);
+
+ if (facetElement != null) {
+ childrenInfo.addSourceChild(facetElement);
} else {
- String valueForLabel = ddmLabelFromAttribute == null
- ? ""
- : ddmLabelFromAttribute.getValue();
- textLabel = visualDocument.createTextNode(valueForLabel);
- }
- if (textLabel != null) {
+ Attr ddmLabelFromAttribute = sourceElement.getAttributeNode("value");
+ String valueForLabel = ddmLabelFromAttribute != null &&
ddmLabelFromAttribute.getValue() != null
+ ? ddmLabelFromAttribute.getValue()
+ : "";
+ nsIDOMNode textLabel = visualDocument.createTextNode(valueForLabel);
visualMenuLabel.appendChild(textLabel);
- creatorInfo.addChildrenInfo(childrenInfo);
}
+
+ creatorInfo.addChildrenInfo(childrenInfo);
visualMenu.appendChild(visualMenuLabel);
- }catch(Throwable t) {
- t.printStackTrace();
- }
return creatorInfo;
}
- private String getLabelFacet(Element sourceElement) {
- String labelFacet = null;
- NodeList children = sourceElement.getChildNodes();
- int cnt = children != null ? children.getLength() : 0;
- if (cnt > 0) {
- for (int i = 0; i < cnt; i++) {
- Node child = children.item(i);
- if (child.getNodeType() == Node.ELEMENT_NODE &&
- child.getNodeName().endsWith(":facet")) {
- Element facetElement = (Element)child;
- String facetName = facetElement.getAttribute("name");
- if (LABEL_FACET_NAME.equals(facetName)) {
- NodeList facetChildren = facetElement.getChildNodes();
- int facetCnt = facetChildren != null ? facetChildren.getLength() : 0;
- if (facetCnt > 0) {
- for (int j = 0; j < facetCnt; j++) {
- Node facetChild = facetChildren.item(i);
- if (facetChild.getNodeType() == Node.ELEMENT_NODE &&
- facetChild.getNodeName().endsWith(":verbatim")) {
- labelFacet = getElementTextContent((Element)facetChild);
- break;
- }
- }
+
+ private Element getLabelFacet(Element sourceElement) {
+ if (sourceElement == null) {
+ return null;
+ }
+
+ NodeList children = sourceElement.getChildNodes();
+ if (children != null) {
+ int size = children.getLength();
+ if (size > 0) {
+ for (int i=0; i<size; i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE
+ && child.getNodeName().endsWith(":facet")) {
+ Element facetElement = (Element)child;
+ if (LABEL_FACET_NAME.equals(facetElement.getAttribute("name"))) {
+ return facetElement;
}
}
}
}
}
- return labelFacet;
+
+ return null;
}
private String getElementTextContent(Element element) {
Show replies by date