Author: dmaliarevich
Date: 2008-03-13 09:30:58 -0400 (Thu, 13 Mar 2008)
New Revision: 6906
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
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableElements.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1744, row and column classes added, 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-13
12:35:18 UTC (rev 6905)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableColumnCreator.java 2008-03-13
13:30:58 UTC (rev 6906)
@@ -66,9 +66,9 @@
String styleClass = "";
String tableHeaderClass = getNodeAttrValue(sourceNode.getParentNode(),
VpeTemplateManager.ATTR_DATATABLE_HEADER_CLASS);
String columnHeaderClass = getNodeAttrValue(sourceNode,
VpeTemplateManager.ATTR_DATATABLE_HEADER_CLASS);
- if (null != columnHeaderClass &&
!"".equalsIgnoreCase(columnHeaderClass)) {
+ if (null != columnHeaderClass) {
styleClass = columnHeaderClass;
- } else if (null != tableHeaderClass &&
!"".equalsIgnoreCase(tableHeaderClass)) {
+ } else if (null != tableHeaderClass) {
styleClass = tableHeaderClass;
}
setCellClass(cell, styleClass);
@@ -84,14 +84,14 @@
styleClass = "";
String tableFooterClass = getNodeAttrValue(sourceNode.getParentNode(),
VpeTemplateManager.ATTR_DATATABLE_FOOTER_CLASS);
String columnFooterClass = getNodeAttrValue(sourceNode,
VpeTemplateManager.ATTR_DATATABLE_FOOTER_CLASS);
- if (null != columnFooterClass &&
!"".equalsIgnoreCase(columnFooterClass)) {
+ if (null != columnFooterClass) {
styleClass = columnFooterClass;
- } else if (null != tableFooterClass &&
!"".equalsIgnoreCase(tableFooterClass)) {
+ } else if (null != tableFooterClass) {
styleClass = tableFooterClass;
}
setCellClass(cell, styleClass);
visualColumnElements.setFooterCell(cell);
-
+
cell = VpeDataTableElements.makeCell(visualDataTableElements.getBodyRow(), index,
HTML.TAG_TD, visualDocument);
NodeList list = sourceNode.getChildNodes();
int cnt = list != null ? list.getLength() : 0;
@@ -116,6 +116,11 @@
}
}
creatorInfo.addChildrenInfo(info);
+
+ String columnClasses = getNodeAttrValue(sourceNode.getParentNode(),
VpeTemplateManager.ATTR_DATATABLE_COLUMN_CLASSES);
+ if (null != columnClasses) {
+ setColumnClassesToCell(cell, columnClasses, index);
+ }
visualColumnElements.setBodyCell(cell);
}
visualNodeMap.put(this, visualColumnElements);
@@ -167,10 +172,61 @@
return ind < name2.length() && name1.equals(name2.substring(ind >= 0 ?
ind + 1 : 0));
}
- private void setCellClass(nsIDOMNode cell, String className) {
+ /**
+ * Sets the column classes to cell.
+ *
+ * @param cell the cell
+ * @param columnClasses the column classes
+ * @param index the index of the column in the table
+ */
+ private void setColumnClassesToCell(nsIDOMElement cell,
+ String columnClasses, int index) {
if (cell != null) {
+ String[] classes = splitClasses(columnClasses);
+
+ if ((null != classes) && (classes.length > 0)) {
+ int len = classes.length;
+ int indx = index + 1;
+ String className = "";
+
+ if (indx <= len) {
+ className = classes[indx - 1];
+ } else {
+ int idx = indx % len;
+ className = classes[idx];
+ }
+ if (className.trim().length() > 0) {
+ cell.setAttribute("class", className);
+ }
+ }
+
+ }
+ }
+
+ /**
+ * Splits a sequence of classes to an array of separate classes.
+ *
+ * @param value the sequence of classes
+ *
+ * @return the array of separate classes
+ */
+ private String[] splitClasses(String value) {
+ if (value != null) {
+ return value.split(",");
+ }
+ return null;
+ }
+
+ /**
+ * Sets the css class to the cell.
+ *
+ * @param cell the cell
+ * @param className the class name
+ */
+ private void setCellClass(nsIDOMElement cell, String className) {
+ if (cell != null) {
if (className != null && className.trim().length() > 0) {
- ((nsIDOMElement)cell).setAttribute("class", className);
+ cell.setAttribute("class", className);
}
}
}
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-13
12:35:18 UTC (rev 6905)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableCreator.java 2008-03-13
13:30:58 UTC (rev 6906)
@@ -190,7 +190,7 @@
row = visualDocument.createElement(HTML.TAG_TR);
section.appendChild(row);
visualTable.appendChild(section);
- //visualElements.setBodyRow(row);
+ visualElements.setContentTableBodyRow(row);
//visualElements.setBody(section);
}
@@ -246,6 +246,9 @@
if (ATTR_BORDER.equalsIgnoreCase(attr.getNodeName())) {
visualTable.setAttribute(ATTR_BORDER, attr.getNodeValue());
}
+ if
(VpeTemplateManager.ATTR_DATATABLE_ROW_CLASSES.equalsIgnoreCase(attr.getNodeName())) {
+ setRowClass(visualElements.getContentTableBodyRow(), attr.getNodeValue());
+ }
outterTable.setAttributeNode(attr);
}
}
@@ -263,9 +266,9 @@
setCellsClass(visualElements.getColumnsFooterRow(), value);
setCellsClass(visualElements.getTableFooterRow(), value);
} else if (caseSensitive ? VpeTemplateManager.ATTR_DATATABLE_ROW_CLASSES.equals(name)
: VpeTemplateManager.ATTR_DATATABLE_ROW_CLASSES.equalsIgnoreCase(name)) {
- setRowClass(visualElements.getBodyRow(), value);
+ setRowClass(visualElements.getContentTableBodyRow(), value);
} else if (caseSensitive ?
VpeTemplateManager.ATTR_DATATABLE_COLUMN_CLASSES.equals(name) :
VpeTemplateManager.ATTR_DATATABLE_COLUMN_CLASSES.equalsIgnoreCase(name)) {
- setCellsClass(visualElements.getBodyRow(), value);
+ setCellsClass(visualElements.getContentTableBodyRow(), value);
}
}
}
@@ -337,7 +340,7 @@
if (child != null && child.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
try {
nsIDOMHTMLTableCellElement cell = (nsIDOMHTMLTableCellElement) child
- .queryInterface(nsIDOMHTMLTableCellElement.NS_IDOMHTMLTABLECELLELEMENT_IID);
+ .queryInterface(nsIDOMHTMLTableCellElement.NS_IDOMHTMLTABLECELLELEMENT_IID);
cell.setAttribute(ATTR_CLASS, classes[ind]);
ind = ind < (classes.length - 1) ? ind + 1 : 0;
} catch (XPCOMException ex) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableElements.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableElements.java 2008-03-13
12:35:18 UTC (rev 6905)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableElements.java 2008-03-13
13:30:58 UTC (rev 6906)
@@ -255,6 +255,8 @@
private nsIDOMElement body;
private nsIDOMElement bodyRow;
+
+ private nsIDOMElement contentTableBodyRow;
private nsIDOMElement tableFooter;
private nsIDOMElement tableFooterRow;
@@ -289,6 +291,14 @@
public void setBodyRow(nsIDOMElement bodyRow) {
this.bodyRow = bodyRow;
}
+
+ public nsIDOMElement getContentTableBodyRow() {
+ return contentTableBodyRow;
+ }
+
+ public void setContentTableBodyRow(nsIDOMElement contentTableBodyRow) {
+ this.contentTableBodyRow = contentTableBodyRow;
+ }
public nsIDOMElement getColumnsFooterRow() {
return columnsFooterRow;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2008-03-13
12:35:18 UTC (rev 6905)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2008-03-13
13:30:58 UTC (rev 6906)
@@ -149,7 +149,7 @@
static final String ATTR_DATATABLE_FOOTER_CLASS = "footerClass";
static final String ATTR_DATATABLE_ROW_CLASSES = "rowClasses";
static final String ATTR_DATATABLE_COLUMN_CLASSES = "columnClasses";
- static final String[] ATTR_DATATABLE_PROPERTIES = {"width",
"bgcolor","border","cellpadding","cellspacing","frame","rules","class","style","title",
"dir"};
+ static final String[] ATTR_DATATABLE_PROPERTIES = {"width",
"bgcolor","border","cellpadding","cellspacing","frame","rules","class","style","title",
"dir", "rowClasses"};
public static final String ATTR_LINK_HREF = "href";
public static final String ATTR_LINK_REL = "rel";