Author: dmaliarevich
Date: 2008-02-15 11:47:45 -0500 (Fri, 15 Feb 2008)
New Revision: 6350
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/VpeFacetCreator.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1744, COLUMN SELECTION FIXED
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-02-15
16:23:59 UTC (rev 6349)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableColumnCreator.java 2008-02-15
16:47:45 UTC (rev 6350)
@@ -47,10 +47,10 @@
SourceColumnElements columnElements = new SourceColumnElements(sourceNode);
if (visualParent != null &&
HTML.TAG_TABLE.equalsIgnoreCase(visualParent.getNodeName()) && columnElements !=
null) {
VisualDataTableElements visualDataTableElements =
VpeDataTableElements.getVisualDataTableElements(visualParent);
+ VisualColumnElements visualColumnElements = new VisualColumnElements();
nsIDOMElement col = visualDocument.createElement(HTML.TAG_COL);
nsIDOMElement colgroup = VpeDataTableElements.getNamedChild(visualParent,
HTML.TAG_COLGROUP, 0);
creatorInfo = new VpeCreatorInfo(col);
- VisualColumnElements visualColumnElements = new VisualColumnElements();
if (colgroup != null) {
colgroup.appendChild(col);
VpeChildrenInfo info = null;
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-02-15
16:23:59 UTC (rev 6349)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableCreator.java 2008-02-15
16:47:45 UTC (rev 6350)
@@ -27,6 +27,7 @@
import org.mozilla.interfaces.nsIDOMAttr;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNamedNodeMap;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMNodeList;
import org.w3c.dom.Attr;
@@ -112,12 +113,12 @@
SourceDataTableElements sourceElements = new SourceDataTableElements(sourceNode);
VisualDataTableElements visualElements = new VisualDataTableElements();
+ nsIDOMElement outterTable = visualDocument.createElement(HTML.TAG_TABLE);
nsIDOMElement visualTable = visualDocument.createElement(HTML.TAG_TABLE);
- VpeCreatorInfo creatorInfo = new VpeCreatorInfo(visualTable);
-
+ VpeCreatorInfo creatorInfo = new VpeCreatorInfo(outterTable);
nsIDOMElement section = null, row = null, cell = null;
-
nsIDOMElement caption;
+
if (true || sourceElements.hasTableCaption()) {
caption = visualDocument.createElement(HTML.TAG_CAPTION);
visualElements.setTableCaptionTag(caption);
@@ -126,50 +127,54 @@
info.addSourceChild(sourceElements.getTableCaption());
creatorInfo.addChildrenInfo(info);
}
+ outterTable.appendChild(caption);
+ visualElements.setCaption(caption);
}
- visualTable.appendChild(caption);
- visualElements.setCaption(caption);
-
- if (true || sourceElements.hasHeaderSection()) {
+
+ if (true || sourceElements.hasTableHeader()) {
section = visualDocument.createElement(HTML.TAG_THEAD);
- if (true || sourceElements.hasTableHeader()) {
- row = visualDocument.createElement(HTML.TAG_TR);
- section.appendChild(row);
- visualElements.setTableHeaderRow(row);
- if (sourceElements.getTableHeader() != null) {
- VpeChildrenInfo info = new VpeChildrenInfo(row);
- info.addSourceChild(sourceElements.getTableHeader());
- creatorInfo.addChildrenInfo(info);
- }
+ row = visualDocument.createElement(HTML.TAG_TR);
+ section.appendChild(row);
+ visualElements.setTableHeaderRow(row);
+ if (sourceElements.getTableHeader() != null) {
+ VpeChildrenInfo info = new VpeChildrenInfo(row);
+ info.addSourceChild(sourceElements.getTableHeader());
+ creatorInfo.addChildrenInfo(info);
}
- if (true || sourceElements.hasColumnsHeader()) {
- row = visualDocument.createElement("tr");
- section.appendChild(row);
- visualElements.setColumnsHeaderRow(row);
+ outterTable.appendChild(section);
+ visualElements.setTableHeader(section);
+ }
+
+ if (true || sourceElements.hasTableFooter()) {
+ section = visualDocument.createElement(HTML.TAG_TFOOT);
+ row = visualDocument.createElement(HTML.TAG_TR);
+ section.appendChild(row);
+ visualElements.setTableFooterRow(row);
+ if (sourceElements.getTableFooter() != null) {
+ VpeChildrenInfo info = new VpeChildrenInfo(row);
+ info.addSourceChild(sourceElements.getTableFooter());
+ creatorInfo.addChildrenInfo(info);
}
+ outterTable.appendChild(section);
+ visualElements.setTableFooter(section);
+ }
+
+ if (true || sourceElements.hasColumnsHeader()) {
+ section = visualDocument.createElement(HTML.TAG_THEAD);
+ row = visualDocument.createElement(HTML.TAG_TR);
+ section.appendChild(row);
+ visualElements.setColumnsHeaderRow(row);
visualTable.appendChild(section);
- visualElements.setHeader(section);
+ visualElements.setColumnsHeader(section);
}
- if (true || sourceElements.hasFooterSection()) {
- section = visualDocument.createElement("tfoot");
- if (true || sourceElements.hasColumnsFooter()) {
- row = visualDocument.createElement("tr");
- section.appendChild(row);
- visualElements.setColumnsFooterRow(row);
- }
- if (true || sourceElements.hasTableFooter()) {
- row = visualDocument.createElement("tr");
- section.appendChild(row);
- visualElements.setTableFooterRow(row);
- if (sourceElements.getTableFooter() != null) {
- VpeChildrenInfo info = new VpeChildrenInfo(row);
- info.addSourceChild(sourceElements.getTableFooter());
- creatorInfo.addChildrenInfo(info);
- }
- }
+ if (true || sourceElements.hasColumnsFooter()) {
+ section = visualDocument.createElement(HTML.TAG_TFOOT);
+ row = visualDocument.createElement(HTML.TAG_TR);
+ section.appendChild(row);
+ visualElements.setColumnsFooterRow(row);
visualTable.appendChild(section);
- visualElements.setFooter(section);
+ visualElements.setColumnsFooter(section);
}
if (true || sourceElements.hasBodySection()) {
@@ -194,6 +199,15 @@
info.addSourceChild(column.getColumn());
}
+ nsIDOMElement outterTBODY = visualDocument.createElement(HTML.TAG_TBODY);
+ nsIDOMElement outterTR = visualDocument.createElement(HTML.TAG_TR);
+ nsIDOMElement outterTD = visualDocument.createElement(HTML.TAG_TR);
+
+ outterTD.appendChild(visualTable);
+ outterTR.appendChild(outterTD);
+ outterTBODY.appendChild(outterTR);
+ outterTable.appendChild(outterTBODY);
+
Object[] elements = new Object[2];
elements[0] = visualElements;
elements[1] = sourceElements;
@@ -205,6 +219,7 @@
VpeCreatorInfo info1 = creator.create(pageContext, (Element) sourceNode,
visualDocument, visualTable, visualNodeMap);
if (info1 != null && info1.getVisualNode() != null) {
nsIDOMAttr attr = (nsIDOMAttr) info1.getVisualNode();
+ // TODO creates border=1 here
visualTable.setAttributeNode(attr);
}
}
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-02-15
16:23:59 UTC (rev 6349)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableElements.java 2008-02-15
16:47:45 UTC (rev 6350)
@@ -247,24 +247,31 @@
private nsIDOMElement caption;
private nsIDOMElement tableCaptionTag;
- private nsIDOMElement header;
+ private nsIDOMElement tableHeader;
private nsIDOMElement tableHeaderRow;
+
+ private nsIDOMElement columnsHeader;
private nsIDOMElement columnsHeaderRow;
private nsIDOMElement body;
private nsIDOMElement bodyRow;
- private nsIDOMElement footer;
- private nsIDOMElement columnsFooterRow;
+ private nsIDOMElement tableFooter;
private nsIDOMElement tableFooterRow;
+ private nsIDOMElement columnsFooter;
+ private nsIDOMElement columnsFooterRow;
+
public VisualDataTableElements() {
}
- public VisualDataTableElements(nsIDOMElement header, nsIDOMElement body, nsIDOMElement
footer) {
- this.header = header;
+ public VisualDataTableElements(nsIDOMElement caption, nsIDOMElement columnsHeader,
nsIDOMElement columnsFooter, nsIDOMElement header, nsIDOMElement body, nsIDOMElement
footer) {
+ this.caption = caption;
+ this.columnsHeader = columnsHeader;
+ this.columnsFooter = columnsFooter;
+ this.tableHeader = header;
this.body = body;
- this.footer = footer;
+ this.tableFooter = footer;
}
public nsIDOMElement getBody() {
@@ -307,20 +314,36 @@
this.tableCaptionTag = tableCaptionTag;
}
- public nsIDOMElement getFooter() {
- return footer;
+ public nsIDOMElement getTableFooter() {
+ return tableFooter;
}
+
+ public void setTableFooter(nsIDOMElement footer) {
+ this.tableFooter = footer;
+ }
+
+ public nsIDOMElement getTableHeader() {
+ return tableHeader;
+ }
+
+ public void setTableHeader(nsIDOMElement header) {
+ this.tableHeader = header;
+ }
+
+ public nsIDOMElement getColumnsFooter() {
+ return columnsFooter;
+ }
- public void setFooter(nsIDOMElement footer) {
- this.footer = footer;
+ public void setColumnsFooter(nsIDOMElement footer) {
+ this.columnsFooter = footer;
}
- public nsIDOMElement getHeader() {
- return header;
+ public nsIDOMElement getColumnsHeader() {
+ return columnsHeader;
}
- public void setHeader(nsIDOMElement header) {
- this.header = header;
+ public void setColumnsHeader(nsIDOMElement header) {
+ this.columnsHeader = header;
}
public nsIDOMElement getCaption() {
@@ -406,17 +429,20 @@
public static VisualDataTableElements getVisualDataTableElements(nsIDOMNode
visualParent) {
VisualDataTableElements visualDataTableElements = new VisualDataTableElements(
+ VpeDataTableElements.getNamedChild(visualParent, HTML.TAG_CAPTION),
VpeDataTableElements.getNamedChild(visualParent, HTML.TAG_THEAD),
+ VpeDataTableElements.getNamedChild(visualParent, HTML.TAG_TFOOT),
+ VpeDataTableElements.getNamedChild(visualParent, HTML.TAG_THEAD),
VpeDataTableElements.getNamedChild(visualParent, HTML.TAG_TBODY),
VpeDataTableElements.getNamedChild(visualParent, HTML.TAG_TFOOT)
);
visualDataTableElements.setTableCaptionTag(VpeDataTableElements.getNamedChild(visualDataTableElements.getCaption(),
"caption"));
- visualDataTableElements.setTableHeaderRow(VpeDataTableElements.getNamedChild(visualDataTableElements.getHeader(),
"tr"));
- visualDataTableElements.setColumnsHeaderRow(VpeDataTableElements.getNamedChild(visualDataTableElements.getHeader(),
"tr", 1));
+ visualDataTableElements.setTableHeaderRow(VpeDataTableElements.getNamedChild(visualDataTableElements.getTableHeader(),
"tr"));
+ visualDataTableElements.setColumnsHeaderRow(VpeDataTableElements.getNamedChild(visualDataTableElements.getColumnsHeader(),
"tr"));
visualDataTableElements.setBodyRow(VpeDataTableElements.getNamedChild(visualDataTableElements.getBody(),
"tr"));
- visualDataTableElements.setColumnsFooterRow(VpeDataTableElements.getNamedChild(visualDataTableElements.getFooter(),
"tr"));
- visualDataTableElements.setTableFooterRow(VpeDataTableElements.getNamedChild(visualDataTableElements.getFooter(),
"tr", 1));
+ visualDataTableElements.setColumnsFooterRow(VpeDataTableElements.getNamedChild(visualDataTableElements.getColumnsFooter(),
"tr"));
+ visualDataTableElements.setTableFooterRow(VpeDataTableElements.getNamedChild(visualDataTableElements.getTableFooter(),
"tr"));
return visualDataTableElements;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeFacetCreator.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeFacetCreator.java 2008-02-15
16:23:59 UTC (rev 6349)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeFacetCreator.java 2008-02-15
16:47:45 UTC (rev 6350)
@@ -94,7 +94,7 @@
setCellClass(cell, getTableAttrValue(sourceParent, "footerClass"));
} else if (isCaption) {
setCellClass(cell, getTableAttrValue(sourceParent, "captionClass"));
- setCaptionStyle(cell, getTableAttrValue(sourceParent, "captionStyle"));
+ setCaptionStyle(sourceParent, cell, getTableAttrValue(sourceParent,
"captionStyle"));
}
creatorInfo = new VpeCreatorInfo(cell);
}
@@ -119,11 +119,23 @@
}
}
- private void setCaptionStyle(nsIDOMNode cell, String styleName) {
+ /**
+ * Sets the caption style and stretches caption to fit the full table width.
+ *
+ * @param sourceParent the source parent
+ * @param cell the cell
+ * @param captionStyle the caption style
+ */
+ private void setCaptionStyle(Node sourceParent, nsIDOMNode cell, String captionStyle) {
if (cell != null) {
- if (styleName != null && styleName.trim().length() > 0) {
- ((nsIDOMElement)cell).setAttribute("style", styleName);
+ String resultStyle = "";
+ if (captionStyle != null && captionStyle.trim().length() > 0) {
+ resultStyle += captionStyle;
}
+ if (!(captionStyle.lastIndexOf("width") > -1)) {
+ resultStyle += "width: 100%; ";
+ }
+ ((nsIDOMElement)cell).setAttribute(HTML.ATTR_STYLE, resultStyle);
}
}