Author: sdzmitrovich
Date: 2008-07-08 10:59:36 -0400 (Tue, 08 Jul 2008)
New Revision: 9091
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOptionSelectItemTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/NodeProxyUtil.java
Log:
code adjustment
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java 2008-07-08
14:57:00 UTC (rev 9090)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java 2008-07-08
14:59:36 UTC (rev 9091)
@@ -15,7 +15,6 @@
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.NodesManagingUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
@@ -125,7 +124,7 @@
}
elementData.addNodeData(new AttributeData(outputAttr,
- targetVisualElement, false));
+ targetVisualElement, true));
creationData.addChildrenInfo(targetVisualInfo);
@@ -193,12 +192,10 @@
VpeElementProxyData elementProxyData = (VpeElementProxyData) elementMapping
.getElementData();
- Node sourceNode = NodeProxyUtil.findNodeByPosition(elementProxyData
- .getNodelist(), focusPosition, anchorPosition);
+ VpeNodeMapping nodeMapping = NodeProxyUtil.findNodeByPosition(
+ domMapping, elementProxyData.getNodelist(), focusPosition,
+ anchorPosition);
- VpeNodeMapping nodeMapping = NodesManagingUtil.getNodeMapping(
- domMapping, sourceNode);
-
if (nodeMapping != null) {
if (nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOptionSelectItemTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOptionSelectItemTemplate.java 2008-07-08
14:57:00 UTC (rev 9090)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOptionSelectItemTemplate.java 2008-07-08
14:59:36 UTC (rev 9091)
@@ -11,6 +11,7 @@
package org.jboss.tools.jsf.vpe.jsf.template;
import org.jboss.tools.jsf.vpe.jsf.template.util.ComponentUtil;
+import org.jboss.tools.jsf.vpe.jsf.template.util.JSF;
import org.jboss.tools.jsf.vpe.jsf.template.util.NodeProxyUtil;
import org.jboss.tools.jsf.vpe.jsf.template.util.model.VpeElementProxyData;
import org.jboss.tools.vpe.editor.context.VpePageContext;
@@ -81,51 +82,53 @@
} else if (attrPresents(enabledClass)) {
option.setAttribute(CLASS, enabledClass);
}
-
- Attr attr = null;
- if (element.hasAttribute(ITEM_LABEL)) {
- attr = element.getAttributeNode(ITEM_LABEL);
- }
- VpeElementProxyData elementData = new VpeElementProxyData();
-
- if (null != attr) {
- if (null == escape || "true".equalsIgnoreCase(escape)) {
- // show text as is
- String itemLabel = attr.getNodeValue();
- String bundleValue = ComponentUtil.getBundleValue(pageContext,
- attr);
- nsIDOMText text;
- // if bundleValue differ from value then will be represent
- // bundleValue, but text will be not edit
- if (!itemLabel.equals(bundleValue)) {
- text = visualDocument.createTextNode(bundleValue);
+ processOutputAttribute(pageContext, visualDocument, element, option, creationData);
- } else {
- text = visualDocument.createTextNode(itemLabel);
-
- elementData.addNodeData(new AttributeData(attr,
- option, true));
- creationData.setElementData(elementData);
- }
-
-
- option.appendChild(text);
- } else {
- // show formatted text
- VpeChildrenInfo spanInfo = new VpeChildrenInfo(option);
- // re-parse attribute's value
- NodeList list = NodeProxyUtil.reparseAttributeValue(elementData,attr);
- // add children to info
- for (int i = 0; i < list.getLength(); i++) {
- Node child = list.item(i);
- // add info to creation data
- spanInfo.addSourceChild(child);
- }
- creationData.addChildrenInfo(spanInfo);
- }
- }
-
+// Attr attr = null;
+// if (element.hasAttribute(ITEM_LABEL)) {
+// attr = element.getAttributeNode(ITEM_LABEL);
+// }
+//
+// VpeElementProxyData elementData = new VpeElementProxyData();
+//
+// if (null != attr) {
+// if (null == escape || "true".equalsIgnoreCase(escape)) {
+// // show text as is
+// String itemLabel = attr.getNodeValue();
+// String bundleValue = ComponentUtil.getBundleValue(pageContext,
+// attr);
+// nsIDOMText text;
+// // if bundleValue differ from value then will be represent
+// // bundleValue, but text will be not edit
+// if (!itemLabel.equals(bundleValue)) {
+// text = visualDocument.createTextNode(bundleValue);
+//
+// } else {
+// text = visualDocument.createTextNode(itemLabel);
+//
+// elementData.addNodeData(new AttributeData(attr,
+// option, true));
+// creationData.setElementData(elementData);
+// }
+//
+//
+// option.appendChild(text);
+// } else {
+// // show formatted text
+// VpeChildrenInfo spanInfo = new VpeChildrenInfo(option);
+// // re-parse attribute's value
+// NodeList list = NodeProxyUtil.reparseAttributeValue(elementData,attr);
+// // add children to info
+// for (int i = 0; i < list.getLength(); i++) {
+// Node child = list.item(i);
+// // add info to creation data
+// spanInfo.addSourceChild(child);
+// }
+// creationData.addChildrenInfo(spanInfo);
+// }
+// }
+//
return creationData;
}
@@ -177,5 +180,13 @@
* VpeSourceDomBuilder sourceBuilder = pageContext.getSourceBuilder();
* sourceBuilder.setSelection(sourceElement, 0, 0); }
*/
+
+ @Override
+ protected Attr getOutputAttributeNode(Element element) {
+ if (element.hasAttribute(JSF.ATTR_ITEM_LABEL))
+ return element.getAttributeNode(JSF.ATTR_ITEM_LABEL);
+ return null;
+ }
+
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/NodeProxyUtil.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/NodeProxyUtil.java 2008-07-08
14:57:00 UTC (rev 9090)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/NodeProxyUtil.java 2008-07-08
14:59:36 UTC (rev 9091)
@@ -24,6 +24,8 @@
import org.jboss.tools.jsf.vpe.jsf.template.util.model.NodeProxy;
import org.jboss.tools.jsf.vpe.jsf.template.util.model.TextProxy;
import org.jboss.tools.jsf.vpe.jsf.template.util.model.VpeElementProxyData;
+import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
+import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
import org.w3c.dom.Attr;
import org.w3c.dom.Node;
@@ -101,8 +103,8 @@
* @param anchorPosition
* @return
*/
- static public Node findNodeByPosition(NodeList nodeList, int focusPosition,
- int anchorPosition) {
+ static public VpeNodeMapping findNodeByPosition(VpeDomMapping domMapping,
+ NodeList nodeList, int focusPosition, int anchorPosition) {
if (anchorPosition < focusPosition) {
focusPosition = anchorPosition;
@@ -113,10 +115,10 @@
Node child = nodeList.item(i);
- Node result = null;
+ VpeNodeMapping result = null;
if (child.hasChildNodes()) {
- result = findNodeByPosition(child.getChildNodes(),
+ result = findNodeByPosition(domMapping, child.getChildNodes(),
focusPosition, anchorPosition);
}
@@ -125,9 +127,10 @@
if ((focusPosition >= (NodesManagingUtil.getStartOffsetNode(child)))
&& (anchorPosition <= (NodesManagingUtil
- .getEndOffsetNode(child))))
+ .getEndOffsetNode(child)))) {
- return child;
+ return NodesManagingUtil.getNodeMapping(domMapping, child);
+ }
}
return null;