[jbosstools-commits] JBoss Tools SVN: r6882 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Mar 12 03:36:36 EDT 2008


Author: dmaliarevich
Date: 2008-03-12 03:36:35 -0400 (Wed, 12 Mar 2008)
New Revision: 6882

Modified:
   trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableColumnCreator.java
   trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableCreator.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1873, fixes, code adjustment

Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableColumnCreator.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableColumnCreator.java	2008-03-12 00:26:47 UTC (rev 6881)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableColumnCreator.java	2008-03-12 07:36:35 UTC (rev 6882)
@@ -64,8 +64,8 @@
 				creatorInfo.addChildrenInfo(info);
 				
 				String styleClass = "";
-				String tableHeaderClass = getNodeAttrValue(sourceNode.getParentNode(), "headerClass");
-				String columnHeaderClass = getNodeAttrValue(sourceNode, "headerClass");
+				String tableHeaderClass = getNodeAttrValue(sourceNode.getParentNode(), VpeTemplateManager.ATTR_DATATABLE_HEADER_CLASS);
+				String columnHeaderClass = getNodeAttrValue(sourceNode, VpeTemplateManager.ATTR_DATATABLE_HEADER_CLASS);
 				if (null != columnHeaderClass && !"".equalsIgnoreCase(columnHeaderClass)) {
 					styleClass = columnHeaderClass;
 				} else if (null != tableHeaderClass && !"".equalsIgnoreCase(tableHeaderClass)) {
@@ -82,8 +82,8 @@
 				creatorInfo.addChildrenInfo(info);
 				
 				styleClass = "";
-				String tableFooterClass = getNodeAttrValue(sourceNode.getParentNode(), "footerClass");
-				String columnFooterClass = getNodeAttrValue(sourceNode, "footerClass");
+				String tableFooterClass = getNodeAttrValue(sourceNode.getParentNode(), VpeTemplateManager.ATTR_DATATABLE_FOOTER_CLASS);
+				String columnFooterClass = getNodeAttrValue(sourceNode, VpeTemplateManager.ATTR_DATATABLE_FOOTER_CLASS);
 				if (null != columnFooterClass && !"".equalsIgnoreCase(columnFooterClass)) {
 					styleClass = columnFooterClass;
 				} else if (null != tableFooterClass && !"".equalsIgnoreCase(tableFooterClass)) {

Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableCreator.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableCreator.java	2008-03-12 00:26:47 UTC (rev 6881)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableCreator.java	2008-03-12 07:36:35 UTC (rev 6882)
@@ -27,9 +27,11 @@
 import org.mozilla.interfaces.nsIDOMAttr;
 import org.mozilla.interfaces.nsIDOMDocument;
 import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMHTMLTableCellElement;
 import org.mozilla.interfaces.nsIDOMNamedNodeMap;
 import org.mozilla.interfaces.nsIDOMNode;
 import org.mozilla.interfaces.nsIDOMNodeList;
+import org.mozilla.xpcom.XPCOMException;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -44,6 +46,7 @@
 	private VpeExpression columnClassesExpr;
 	
 	private static final String ATTR_STYLE = "style";
+	private static final String ATTR_CLASS = "class";
 	private static final String ATTR_WIDTH = "width";
 	private static final String ATTR_BORDER = "border";
 	private static final String HIDDEN_BORDER_STYLE = "border: 0px hidden;" ;
@@ -332,8 +335,14 @@
 			for (long i = 0; i < count; i++) {
 				nsIDOMNode child = children.item(i);
 				if (child != null && child.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
-					((Element)child).setAttribute("class", classes[ind]);
-					ind = ind < (classes.length - 1) ? ind + 1 : 0;
+					try {
+						nsIDOMHTMLTableCellElement cell = (nsIDOMHTMLTableCellElement) child
+							.queryInterface(nsIDOMHTMLTableCellElement.NS_IDOMHTMLTABLECELLELEMENT_IID);
+						cell.setAttribute(ATTR_CLASS, classes[ind]);
+						ind = ind < (classes.length - 1) ? ind + 1 : 0;
+					} catch (XPCOMException ex) {
+					    // just ignore this exception
+					}
 				}
 			}
 		}
@@ -346,7 +355,13 @@
 			for (long i = 0; i < count; i++) {
 				nsIDOMNode child = children.item(i);
 				if (child != null && child.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
-					((nsIDOMElement)child).removeAttribute("class");
+					try {
+						nsIDOMHTMLTableCellElement cell = (nsIDOMHTMLTableCellElement) child
+							.queryInterface(nsIDOMHTMLTableCellElement.NS_IDOMHTMLTABLECELLELEMENT_IID);
+						cell.removeAttribute(ATTR_CLASS);
+					} catch (XPCOMException ex) {
+					    // just ignore this exception
+					}
 				}
 			}
 		}
@@ -357,22 +372,22 @@
 			String[] rowClasses = getClasses(value);
 			String rowClass = (rowClasses != null && rowClasses.length > 0) ? rowClasses[0] : null;
 			if (rowClass.trim().length() > 0) {
-				row.setAttribute("class", rowClass);
+				row.setAttribute(ATTR_CLASS, rowClass);
 			} else {
-				row.removeAttribute("class");
+				row.removeAttribute(ATTR_CLASS);
 			}
 		}
 	}
 
 	private void setRowDisplayStyle(nsIDOMElement row, boolean visible) {
 		if (row != null) {
-			row.setAttribute("style", "display:" + (visible ? "" : "none"));
+			row.setAttribute(ATTR_STYLE, "display:" + (visible ? "" : "none"));
 		}
 	}
 
 	private void removeRowClass(nsIDOMElement row) {
 		if (row != null) {
-			row.removeAttribute("class");
+			row.removeAttribute(ATTR_CLASS);
 		}
 	}
 




More information about the jbosstools-commits mailing list