[jbosstools-commits] JBoss Tools SVN: r6926 - 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
Fri Mar 14 07:05:41 EDT 2008


Author: dmaliarevich
Date: 2008-03-14 07:05:41 -0400 (Fri, 14 Mar 2008)
New Revision: 6926

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-1744, frame and rules attributes processing updated, setting style classes for the columns was fixed, 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-14 10:48:21 UTC (rev 6925)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableColumnCreator.java	2008-03-14 11:05:41 UTC (rev 6926)
@@ -183,17 +183,19 @@
 			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;
+				int classesCount = classes.length;
+				int columnCount = index + 1;
 				String className = "";
 
-				if (indx <= len) {
-					className = classes[indx - 1];
+				// Finds correct css style class index
+				// for the column
+				if (columnCount <= classesCount) {
+					className = classes[columnCount - 1];
 				} else {
-					int idx = indx % len;
-					className = classes[idx];
+					int remainder = columnCount % classesCount;
+					int classesIndex = ((0 == remainder) ? (classesCount-1) : (remainder-1));
+					className = classes[classesIndex];
 				}
 				if (className.trim().length() > 0) {
 					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-14 10:48:21 UTC (rev 6925)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableCreator.java	2008-03-14 11:05:41 UTC (rev 6926)
@@ -49,7 +49,10 @@
 	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;" ;
+	private static final String ATTR_RULES = "rules";
+	private static final String ATTR_RULES_VALUE_ROWS = "rows";
+    private static final String TD_HIDDEN_BORDER_STYLE = "padding: 0px; border: 0px hidden;";
+    private static final String TD_RULES_ROWS_BORDER_STYLE = "padding: 0px;";
 
 	private List propertyCreators;
 
@@ -121,7 +124,10 @@
 		SourceDataTableElements sourceElements = new SourceDataTableElements(sourceNode);
 		VisualDataTableElements visualElements = new VisualDataTableElements();
 
+		// Table with caption, header, footer, 
+		// that wraps table with content
 		nsIDOMElement outterTable = visualDocument.createElement(HTML.TAG_TABLE);
+		// Table with main content
 		nsIDOMElement visualTable = visualDocument.createElement(HTML.TAG_TABLE);
 		VpeCreatorInfo creatorInfo = new VpeCreatorInfo(outterTable);
 		nsIDOMElement section = null, row = null, cell = null;
@@ -214,9 +220,9 @@
 		// To create appropriate visual appearance
 		// borders of the body cell and content table
 		// were set via styles.
-		outterTD.setAttribute(ATTR_STYLE, HIDDEN_BORDER_STYLE);
+		outterTD.setAttribute(ATTR_STYLE, TD_HIDDEN_BORDER_STYLE);
 		visualTable.setAttribute(ATTR_WIDTH, "100%");
-		visualTable.setAttribute(ATTR_STYLE, HIDDEN_BORDER_STYLE);
+		visualTable.setAttribute(ATTR_BORDER, "0");
 		
 		outterTD.appendChild(visualTable);
 		outterTR.appendChild(outterTD);
@@ -234,7 +240,8 @@
 		for (int i = 0; i < propertyCreators.size(); i++) {
 			VpeCreator creator = (VpeCreator)propertyCreators.get(i);
 			if (creator != null) {
-				VpeCreatorInfo info1 = creator.create(pageContext, (Element) sourceNode, visualDocument, visualTable, visualNodeMap);
+				// Sets attributes for the wrapper table
+				VpeCreatorInfo info1 = creator.create(pageContext, (Element) sourceNode, visualDocument, outterTable, visualNodeMap);
 				if (info1 != null && info1.getVisualNode() != null) {
 					nsIDOMAttr attr = (nsIDOMAttr) info1.getVisualNode();
 					// Fixes creation 'border="1"' 
@@ -243,13 +250,35 @@
 					if (null == attr.getNodeValue() || "".equalsIgnoreCase(attr.getNodeValue())) {
 						continue;
 					}
-					if (ATTR_BORDER.equalsIgnoreCase(attr.getNodeName())) {
-						visualTable.setAttribute(ATTR_BORDER, attr.getNodeValue());
+					outterTable.setAttributeNode(attr);
+				}
+				// Sets attributes for the content table
+				VpeCreatorInfo info2 = creator.create(pageContext, (Element) sourceNode, visualDocument, visualTable, visualNodeMap);
+				if (info2 != null && info2.getVisualNode() != null) {
+					nsIDOMAttr attr = (nsIDOMAttr) info2.getVisualNode();
+					// Fixes creation 'border="1"' 
+					// when setting border attribute to the table.
+					// Also skips empty attributes to fix layout problems.
+					if (null == attr.getNodeValue() || "".equalsIgnoreCase(attr.getNodeValue())) {
+						continue;
 					}
+					// Setting row classes to the table row 
 					if (VpeTemplateManager.ATTR_DATATABLE_ROW_CLASSES.equalsIgnoreCase(attr.getNodeName())) {
 						setRowClass(visualElements.getContentTableBodyRow(), attr.getNodeValue());
+						continue;
 					}
-					outterTable.setAttributeNode(attr);
+					// Skip setting content table border
+					if (ATTR_BORDER.equalsIgnoreCase(attr.getNodeName())) {
+						continue;
+					}
+					// Fixes creation of a border around content table
+					// when attribute rules="rows" is set
+					if (ATTR_RULES.equalsIgnoreCase(attr.getNodeName())) {
+						if (ATTR_RULES_VALUE_ROWS.equalsIgnoreCase(attr.getNodeValue())) {
+							outterTD.setAttribute(ATTR_STYLE, TD_RULES_ROWS_BORDER_STYLE);
+						}
+					}
+					visualTable.setAttributeNode(attr);
 				}
 			}
 		}




More information about the jbosstools-commits mailing list