Author: sdzmitrovich
Date: 2008-04-17 05:11:37 -0400 (Thu, 17 Apr 2008)
New Revision: 7566
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfFacet.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/EditableTemplateAdapter.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/VpePanelGridCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TemplateManagingUtil.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2001
http://jira.jboss.com/jira/browse/JBIDE-2002
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfFacet.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfFacet.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfFacet.java 2008-04-17
09:11:37 UTC (rev 7566)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.jsf.template;
+
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+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.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author sdzmitrovich
+ *
+ */
+public class JsfFacet extends VpeAbstractTemplate {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.jboss.tools.vpe.editor.template.VpeTemplate#create(org.jboss.tools.vpe.editor.context.VpePageContext,
+ * org.w3c.dom.Node, org.mozilla.interfaces.nsIDOMDocument)
+ */
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+
+ nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
+
+ VpeCreationData creationData = new VpeCreationData(div);
+
+ NodeList children = sourceNode.getChildNodes();
+
+ /*
+ * <f:facet .../> can contain only one element. so we find first visible
+ * node and add to "div"
+ */
+
+ for (int i = 0; i < children.getLength(); i++) {
+
+ Node child = children.item(i);
+
+ // we add to "div" non-empty text node or tag
+ if (((child.getNodeType() == Node.TEXT_NODE) && !(child
+ .getNodeValue().trim().length() == 0))
+ || child.getNodeType() == (Node.ELEMENT_NODE)) {
+
+ VpeChildrenInfo childrenInfo = new VpeChildrenInfo(div);
+
+ childrenInfo.addSourceChild(children.item(i));
+
+ creationData.addChildrenInfo(childrenInfo);
+
+ break;
+ }
+ }
+
+ return creationData;
+ }
+}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml 2008-04-17
06:23:01 UTC (rev 7565)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml 2008-04-17
09:11:37 UTC (rev 7566)
@@ -546,6 +546,7 @@
title="{tagstring()}" table-size="{@columns}" />
<vpe:resize>
<vpe:width width-attr="width" />
+ <vpe:height height-attr="style.height" />
</vpe:resize>
<vpe:dnd>
<vpe:drag start-enable="yes" />
@@ -568,7 +569,7 @@
class="{@styleClass}" style="{@style}"
title="{tagstring()}" dir="{@dir}"/>
<vpe:resize>
<vpe:width width-attr="width" />
- <vpe:height height-attr="height" />
+ <vpe:height height-attr="style.height" />
</vpe:resize>
<vpe:dnd>
<vpe:drag start-enable="yes" />
@@ -604,14 +605,8 @@
<vpe:if test="@name='popup'">
<vpe:template children="yes"
modify="yes"></vpe:template>
</vpe:if>
- <vpe:if
- test="parentname()='h:dataTable'|parentname()='t:tree'">
- <vpe:template children="yes" modify="yes">
- <vpe:facet />
- </vpe:template>
- </vpe:if>
- <vpe:template children="yes" modify="yes">
- <div />
+
+ <vpe:template children="yes" modify="yes"
class="org.jboss.tools.jsf.vpe.jsf.template.JsfFacet" >
<vpe:dnd>
<vpe:drag start-enable="yes" />
<vpe:drop container="yes" />
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/EditableTemplateAdapter.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/EditableTemplateAdapter.java 2008-04-17
06:23:01 UTC (rev 7565)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/EditableTemplateAdapter.java 2008-04-17
09:11:37 UTC (rev 7566)
@@ -759,6 +759,9 @@
nsIDOMNode visualNode = getTargetVisualNodeBySourceNode(focusNode,
elementMapping);
+ if (visualNode == null)
+ return;
+
setSelectionRange(selectionController
.getSelection(nsISelectionController.SELECTION_NORMAL),
visualNode, new Point(visualFocus, visualAnchor - visualFocus));
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-04-17
06:23:01 UTC (rev 7565)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableCreator.java 2008-04-17
09:11:37 UTC (rev 7566)
@@ -7,7 +7,7 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.vpe.editor.template;
import java.util.ArrayList;
@@ -50,67 +50,82 @@
private final String ZERO = "0"; //$NON-NLS-1$
private final String ONE = "1"; //$NON-NLS-1$
private final String HUNDRED_PERCENTS = "100%"; //$NON-NLS-1$
-
+
private final String ATTR_CAPTION_STYLE = "captionStyle"; //$NON-NLS-1$
private final String ATTR_CAPTION_CLASS = "captionClass"; //$NON-NLS-1$
+ private final String ATTR_HEADER_CLASS = "headerClass"; //$NON-NLS-1$
+ private final String ATTR_FOOTER_CLASS = "footerClass"; //$NON-NLS-1$
private final String ATTR_STYLE = "style"; //$NON-NLS-1$
private final String ATTR_CLASS = "class"; //$NON-NLS-1$
private final String ATTR_WIDTH = "width"; //$NON-NLS-1$
private final String ATTR_BORDER = "border"; //$NON-NLS-1$
private final String ATTR_RULES = "rules"; //$NON-NLS-1$
private final String ATTR_RULES_VALUE_ROWS = "rows"; //$NON-NLS-1$
- private final String TD_HIDDEN_BORDER_STYLE = "padding: 0px; border: 0px
hidden;"; //$NON-NLS-1$
- private final String TD_RULES_ROWS_BORDER_STYLE = "padding: 0px;";
//$NON-NLS-1$
- private final String RULES_HIDDEN_BORDER_STYLE = "border: 0px hidden;";
//$NON-NLS-1$
+ private final String TD_HIDDEN_BORDER_STYLE = "padding: 0px; border: 0px
hidden;"; //$NON-NLS-1$
+ private final String TD_RULES_ROWS_BORDER_STYLE = "padding: 0px;";
//$NON-NLS-1$
+ private final String RULES_HIDDEN_BORDER_STYLE = "border: 0px hidden;";
//$NON-NLS-1$
private List propertyCreators;
- VpeDataTableCreator(Element gridElement, VpeDependencyMap dependencyMap, boolean
caseSensitive) {
+ VpeDataTableCreator(Element gridElement, VpeDependencyMap dependencyMap,
+ boolean caseSensitive) {
this.caseSensitive = caseSensitive;
build(gridElement, dependencyMap);
}
private void build(Element element, VpeDependencyMap dependencyMap) {
- Attr headerClassAttr =
element.getAttributeNode(VpeTemplateManager.ATTR_DATATABLE_HEADER_CLASS);
+ Attr headerClassAttr = element
+ .getAttributeNode(VpeTemplateManager.ATTR_DATATABLE_HEADER_CLASS);
if (headerClassAttr != null) {
try {
- VpeExpressionInfo info =
VpeExpressionBuilder.buildCompletedExpression(headerClassAttr.getValue(), caseSensitive);
+ VpeExpressionInfo info = VpeExpressionBuilder
+ .buildCompletedExpression(headerClassAttr.getValue(),
+ caseSensitive);
headerClassExpr = info.getExpression();
dependencyMap.setCreator(this, info.getDependencySet());
- } catch(VpeExpressionBuilderException e) {
+ } catch (VpeExpressionBuilderException e) {
VpePlugin.reportProblem(e);
}
}
- Attr footerClassAttr =
element.getAttributeNode(VpeTemplateManager.ATTR_DATATABLE_FOOTER_CLASS);
+ Attr footerClassAttr = element
+ .getAttributeNode(VpeTemplateManager.ATTR_DATATABLE_FOOTER_CLASS);
if (footerClassAttr != null) {
try {
- VpeExpressionInfo info =
VpeExpressionBuilder.buildCompletedExpression(footerClassAttr.getValue(), caseSensitive);
+ VpeExpressionInfo info = VpeExpressionBuilder
+ .buildCompletedExpression(footerClassAttr.getValue(),
+ caseSensitive);
footerClassExpr = info.getExpression();
dependencyMap.setCreator(this, info.getDependencySet());
- } catch(VpeExpressionBuilderException e) {
+ } catch (VpeExpressionBuilderException e) {
VpePlugin.reportProblem(e);
}
}
- Attr rowClassesAttr =
element.getAttributeNode(VpeTemplateManager.ATTR_DATATABLE_ROW_CLASSES);
+ Attr rowClassesAttr = element
+ .getAttributeNode(VpeTemplateManager.ATTR_DATATABLE_ROW_CLASSES);
if (rowClassesAttr != null) {
try {
- VpeExpressionInfo info =
VpeExpressionBuilder.buildCompletedExpression(rowClassesAttr.getValue(), caseSensitive);
+ VpeExpressionInfo info = VpeExpressionBuilder
+ .buildCompletedExpression(rowClassesAttr.getValue(),
+ caseSensitive);
rowClassesExpr = info.getExpression();
dependencyMap.setCreator(this, info.getDependencySet());
- } catch(VpeExpressionBuilderException e) {
+ } catch (VpeExpressionBuilderException e) {
VpePlugin.reportProblem(e);
}
}
- Attr columnClassesAttr =
element.getAttributeNode(VpeTemplateManager.ATTR_DATATABLE_COLUMN_CLASSES);
+ Attr columnClassesAttr = element
+ .getAttributeNode(VpeTemplateManager.ATTR_DATATABLE_COLUMN_CLASSES);
if (columnClassesAttr != null) {
try {
- VpeExpressionInfo info =
VpeExpressionBuilder.buildCompletedExpression(columnClassesAttr.getValue(),
caseSensitive);
+ VpeExpressionInfo info = VpeExpressionBuilder
+ .buildCompletedExpression(columnClassesAttr.getValue(),
+ caseSensitive);
columnClassesExpr = info.getExpression();
dependencyMap.setCreator(this, info.getDependencySet());
- } catch(VpeExpressionBuilderException e) {
+ } catch (VpeExpressionBuilderException e) {
VpePlugin.reportProblem(e);
}
}
@@ -120,53 +135,61 @@
String attrName = VpeTemplateManager.ATTR_DATATABLE_PROPERTIES[i];
Attr attr = element.getAttributeNode(attrName);
if (attr != null) {
- if (propertyCreators == null) propertyCreators = new ArrayList();
- propertyCreators.add(new VpeAttributeCreator(attrName, attr.getValue(),
dependencyMap, caseSensitive));
+ if (propertyCreators == null)
+ propertyCreators = new ArrayList();
+ propertyCreators.add(new VpeAttributeCreator(attrName, attr
+ .getValue(), dependencyMap, caseSensitive));
}
}
}
-
+
}
- public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument
visualDocument, nsIDOMElement visualElement, Map visualNodeMap) {
+ public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument, nsIDOMElement visualElement,
+ Map visualNodeMap) {
- SourceDataTableElements sourceElements = new SourceDataTableElements(sourceNode);
+ SourceDataTableElements sourceElements = new SourceDataTableElements(
+ sourceNode);
VisualDataTableElements visualElements = new VisualDataTableElements();
+
+ Element element = (Element) sourceNode;
/*
- * Fixes
http://jira.jboss.com/jira/browse/JBIDE-2001
- * Selection borders are fixed.
+ * Fixes
http://jira.jboss.com/jira/browse/JBIDE-2001 Selection borders
+ * are fixed.
*/
nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
- nsIDOMElement selectionTable = visualDocument.createElement(HTML.TAG_TABLE);
+ nsIDOMElement selectionTable = visualDocument
+ .createElement(HTML.TAG_TABLE);
nsIDOMElement tr = visualDocument.createElement(HTML.TAG_TR);
nsIDOMElement td = visualDocument.createElement(HTML.TAG_TD);
-
+
td.appendChild(div);
tr.appendChild(td);
selectionTable.appendChild(tr);
-
+
VpeCreatorInfo creatorInfo = new VpeCreatorInfo(selectionTable);
/*
- * Table with caption, header, footer,
- * that wraps table with content
+ * Table with caption, header, footer, that wraps table with content
*/
- nsIDOMElement outterTable = visualDocument.createElement(HTML.TAG_TABLE);
-
+ nsIDOMElement outterTable = visualDocument
+ .createElement(HTML.TAG_TABLE);
+
/*
* Table with main content
*/
- nsIDOMElement visualTable = visualDocument.createElement(HTML.TAG_TABLE);
- nsIDOMElement section = null;
+ nsIDOMElement visualTable = visualDocument
+ .createElement(HTML.TAG_TABLE);
+ nsIDOMElement section = null;
nsIDOMElement row = null;
nsIDOMElement caption = null;
-
+
/*
- * Fixes
http://jira.jboss.com/jira/browse/JBIDE-1944
- * author: Denis Maliarevich
- * Any text which is placed outside of the tags
- * will be displayed above the table.
+ * Fixes
http://jira.jboss.com/jira/browse/JBIDE-1944 author: Denis
+ * Maliarevich Any text which is placed outside of the tags will be
+ * displayed above the table.
*/
String redundantText = REDUNDANT_TEXT_SEPARATOR;
for (int i = 0; i < sourceElements.getRedundantTextNodesCount(); i++) {
@@ -184,12 +207,13 @@
info.addSourceChild(sourceElements.getTableCaption());
creatorInfo.addChildrenInfo(info);
}
-
+
/*
- * Everything concerning table caption
- * lies here (was removed from VpeFacetCreator)
+ * Everything concerning table caption lies here (was removed from
+ * VpeFacetCreator)
*/
- Node attr = sourceNode.getAttributes().getNamedItem(ATTR_CAPTION_STYLE);
+ Node attr = sourceNode.getAttributes().getNamedItem(
+ ATTR_CAPTION_STYLE);
if (attr != null) {
caption.setAttribute(ATTR_STYLE, attr.getNodeValue());
}
@@ -206,8 +230,14 @@
row = visualDocument.createElement(HTML.TAG_TR);
section.appendChild(row);
visualElements.setTableHeaderRow(row);
+
+ nsIDOMElement thHeader = visualDocument.createElement(HTML.TAG_TH);
+ thHeader.setAttribute(HTML.ATTR_CLASS, element
+ .getAttribute(ATTR_HEADER_CLASS));
+ row.appendChild(thHeader);
if (sourceElements.getTableHeader() != null) {
- VpeChildrenInfo info = new VpeChildrenInfo(row);
+
+ VpeChildrenInfo info = new VpeChildrenInfo(thHeader);
info.addSourceChild(sourceElements.getTableHeader());
creatorInfo.addChildrenInfo(info);
}
@@ -219,9 +249,13 @@
section = visualDocument.createElement(HTML.TAG_TFOOT);
row = visualDocument.createElement(HTML.TAG_TR);
section.appendChild(row);
+ nsIDOMElement tdFooter = visualDocument.createElement(HTML.TAG_TD);
+ tdFooter.setAttribute(HTML.ATTR_CLASS, element
+ .getAttribute(ATTR_FOOTER_CLASS));
+ row.appendChild(tdFooter);
visualElements.setTableFooterRow(row);
if (sourceElements.getTableFooter() != null) {
- VpeChildrenInfo info = new VpeChildrenInfo(row);
+ VpeChildrenInfo info = new VpeChildrenInfo(tdFooter);
info.addSourceChild(sourceElements.getTableFooter());
creatorInfo.addChildrenInfo(info);
}
@@ -253,40 +287,41 @@
section.appendChild(row);
visualTable.appendChild(section);
visualElements.setContentTableBodyRow(row);
- //visualElements.setBody(section);
+ // visualElements.setBody(section);
}
VpeChildrenInfo info = null;
if (sourceElements.getColumnCount() > 0) {
- nsIDOMElement group = visualDocument.createElement(HTML.TAG_COLGROUP);
+ nsIDOMElement group = visualDocument
+ .createElement(HTML.TAG_COLGROUP);
visualTable.appendChild(group);
info = new VpeChildrenInfo(group);
creatorInfo.addChildrenInfo(info);
}
-
+
for (int i = 0; i < sourceElements.getColumnCount(); i++) {
SourceColumnElements column = sourceElements.getColumn(i);
info.addSourceChild(column.getColumn());
}
- nsIDOMElement outterTBODY = visualDocument.createElement(HTML.TAG_TBODY);
+ nsIDOMElement outterTBODY = visualDocument
+ .createElement(HTML.TAG_TBODY);
nsIDOMElement outterTR = visualDocument.createElement(HTML.TAG_TR);
nsIDOMElement outterTD = visualDocument.createElement(HTML.TAG_TD);
/*
- * To create appropriate visual appearance
- * borders of the body cell and content table
- * were set via styles.
+ * To create appropriate visual appearance borders of the body cell and
+ * content table were set via styles.
*/
outterTD.setAttribute(ATTR_STYLE, TD_HIDDEN_BORDER_STYLE);
visualTable.setAttribute(ATTR_WIDTH, HUNDRED_PERCENTS);
visualTable.setAttribute(ATTR_BORDER, ZERO);
-
+
outterTD.appendChild(visualTable);
outterTR.appendChild(outterTD);
outterTBODY.appendChild(outterTR);
outterTable.appendChild(outterTBODY);
-
+
visualElements.setBodyRow(outterTR);
visualElements.setBody(outterTBODY);
@@ -296,61 +331,69 @@
visualNodeMap.put(this, elements);
for (int i = 0; i < propertyCreators.size(); i++) {
- VpeCreator creator = (VpeCreator)propertyCreators.get(i);
+ VpeCreator creator = (VpeCreator) propertyCreators.get(i);
if (creator != null) {
-
+
/*
- * Sets attributes for the wrapper table
+ * Sets attributes for the wrapper table
*/
- VpeCreatorInfo info1 = creator.create(pageContext, (Element) sourceNode,
visualDocument, outterTable, visualNodeMap);
+ 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"'
- * when setting border attribute to the table.
- * Also skips empty attributes to fix layout problems.
+ * Fixes creation 'border="1"' when setting border attribute
+ * to the table. Also skips empty attributes to fix layout
+ * problems.
*/
- if (null == attr.getNodeValue() || EMPTY.equalsIgnoreCase(attr.getNodeValue())) {
+ if (null == attr.getNodeValue()
+ || EMPTY.equalsIgnoreCase(attr.getNodeValue())) {
continue;
}
outterTable.setAttributeNode(attr);
}
-
+
/*
- * Sets attributes for the content table
+ * Sets attributes for the content table
*/
- VpeCreatorInfo info2 = creator.create(pageContext, (Element) sourceNode,
visualDocument, visualTable, visualNodeMap);
+ 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.
+ * Fixes creation 'border="1"' when setting border attribute
+ * to the table. Also skips empty attributes to fix layout
+ * problems.
*/
- if (null == attr.getNodeValue() || EMPTY.equalsIgnoreCase(attr.getNodeValue())) {
+ if (null == attr.getNodeValue()
+ || EMPTY.equalsIgnoreCase(attr.getNodeValue())) {
continue;
}
/*
- * Sets attributes for the content table
- */
- if
(VpeTemplateManager.ATTR_DATATABLE_ROW_CLASSES.equalsIgnoreCase(attr.getNodeName())) {
- setRowClass(visualElements.getContentTableBodyRow(), attr.getNodeValue());
+ * Sets attributes for the content table
+ */
+ if (VpeTemplateManager.ATTR_DATATABLE_ROW_CLASSES
+ .equalsIgnoreCase(attr.getNodeName())) {
+ setRowClass(visualElements.getContentTableBodyRow(),
+ attr.getNodeValue());
continue;
}
-
+
/*
- * Skip setting content table border
+ * Skip setting content table border
*/
if (ATTR_BORDER.equalsIgnoreCase(attr.getNodeName())) {
-
+
/*
- * If attribute border is set then table cells have borders.
- * Because two table are used border should appear
- * around content table cells but not the table itself.
- * By default content table has no border.
+ * If attribute border is set then table cells have
+ * borders. Because two table are used border should
+ * appear around content table cells but not the table
+ * itself. By default content table has no border.
*/
String value = attr.getNodeValue();
int val = -1;
@@ -363,19 +406,22 @@
}
if (val > 0) {
visualTable.setAttribute(ATTR_BORDER, ONE);
- visualTable.setAttribute(ATTR_STYLE, RULES_HIDDEN_BORDER_STYLE);
+ visualTable.setAttribute(ATTR_STYLE,
+ RULES_HIDDEN_BORDER_STYLE);
}
-
+
continue;
}
-
+
/*
- * Fixes creation of a border around content table
- * when attribute rules="rows" is set
+ * 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);
+ if (ATTR_RULES_VALUE_ROWS.equalsIgnoreCase(attr
+ .getNodeValue())) {
+ outterTD.setAttribute(ATTR_STYLE,
+ TD_RULES_ROWS_BORDER_STYLE);
}
}
visualTable.setAttributeNode(attr);
@@ -384,25 +430,40 @@
}
return creatorInfo;
}
-
- public void setAttribute(VpePageContext pageContext, Element sourceElement, Map
visualNodeMap, String name, String value) {
+
+ public void setAttribute(VpePageContext pageContext, Element sourceElement,
+ Map visualNodeMap, String name, String value) {
VisualDataTableElements visualElements = getVisualDataTableElements(visualNodeMap);
if (visualElements != null) {
- if (caseSensitive ? VpeTemplateManager.ATTR_DATATABLE_HEADER_CLASS.equals(name) :
VpeTemplateManager.ATTR_DATATABLE_HEADER_CLASS.equalsIgnoreCase(name)) {
+ if (caseSensitive ? VpeTemplateManager.ATTR_DATATABLE_HEADER_CLASS
+ .equals(name)
+ : VpeTemplateManager.ATTR_DATATABLE_HEADER_CLASS
+ .equalsIgnoreCase(name)) {
setCellsClass(visualElements.getTableHeaderRow(), value);
setCellsClass(visualElements.getColumnsHeaderRow(), value);
- } else if (caseSensitive ? VpeTemplateManager.ATTR_DATATABLE_FOOTER_CLASS.equals(name)
: VpeTemplateManager.ATTR_DATATABLE_FOOTER_CLASS.equalsIgnoreCase(name)) {
+ } else if (caseSensitive ? VpeTemplateManager.ATTR_DATATABLE_FOOTER_CLASS
+ .equals(name)
+ : VpeTemplateManager.ATTR_DATATABLE_FOOTER_CLASS
+ .equalsIgnoreCase(name)) {
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)) {
+ } else if (caseSensitive ? VpeTemplateManager.ATTR_DATATABLE_ROW_CLASSES
+ .equals(name)
+ : VpeTemplateManager.ATTR_DATATABLE_ROW_CLASSES
+ .equalsIgnoreCase(name)) {
setRowClass(visualElements.getContentTableBodyRow(), value);
- } else if (caseSensitive ?
VpeTemplateManager.ATTR_DATATABLE_COLUMN_CLASSES.equals(name) :
VpeTemplateManager.ATTR_DATATABLE_COLUMN_CLASSES.equalsIgnoreCase(name)) {
+ } else if (caseSensitive ? VpeTemplateManager.ATTR_DATATABLE_COLUMN_CLASSES
+ .equals(name)
+ : VpeTemplateManager.ATTR_DATATABLE_COLUMN_CLASSES
+ .equalsIgnoreCase(name)) {
setCellsClass(visualElements.getContentTableBodyRow(), value);
}
}
}
- public void validate(VpePageContext pageContext, Element sourceElement, Document
visualDocument, Element visualParent, Element visualElement, Map visualNodeMap) {
+ public void validate(VpePageContext pageContext, Element sourceElement,
+ Document visualDocument, Element visualParent,
+ Element visualElement, Map visualNodeMap) {
VisualDataTableElements visualElements = null;
SourceDataTableElements sourceElements = null;
if (visualNodeMap != null) {
@@ -412,39 +473,76 @@
sourceElements = new SourceDataTableElements(sourceElement);
nsIDOMNode visualNode = pageContext.getCurrentVisualNode();
if (visualNode != null) {
- visualElements = VpeDataTableElements.getVisualDataTableElements(visualNode);
+ visualElements = VpeDataTableElements
+ .getVisualDataTableElements(visualNode);
}
}
if (visualElements != null) {
- setCellsClass(visualElements.getTableHeaderRow(),
sourceElement.getAttribute(VpeTemplateManager.ATTR_DATATABLE_HEADER_CLASS));
- setCellsClass(visualElements.getColumnsHeaderRow(),
sourceElement.getAttribute(VpeTemplateManager.ATTR_DATATABLE_HEADER_CLASS));
- setCellsClass(visualElements.getColumnsFooterRow(),
sourceElement.getAttribute(VpeTemplateManager.ATTR_DATATABLE_FOOTER_CLASS));
- setCellsClass(visualElements.getTableFooterRow(),
sourceElement.getAttribute(VpeTemplateManager.ATTR_DATATABLE_FOOTER_CLASS));
+ setCellsClass(
+ visualElements.getTableHeaderRow(),
+ sourceElement
+ .getAttribute(VpeTemplateManager.ATTR_DATATABLE_HEADER_CLASS));
+ setCellsClass(
+ visualElements.getColumnsHeaderRow(),
+ sourceElement
+ .getAttribute(VpeTemplateManager.ATTR_DATATABLE_HEADER_CLASS));
+ setCellsClass(
+ visualElements.getColumnsFooterRow(),
+ sourceElement
+ .getAttribute(VpeTemplateManager.ATTR_DATATABLE_FOOTER_CLASS));
+ setCellsClass(
+ visualElements.getTableFooterRow(),
+ sourceElement
+ .getAttribute(VpeTemplateManager.ATTR_DATATABLE_FOOTER_CLASS));
- setRowClass(visualElements.getBodyRow(),
sourceElement.getAttribute(VpeTemplateManager.ATTR_DATATABLE_ROW_CLASSES));
- setCellsClass(visualElements.getBodyRow(),
sourceElement.getAttribute(VpeTemplateManager.ATTR_DATATABLE_COLUMN_CLASSES));
+ setRowClass(
+ visualElements.getBodyRow(),
+ sourceElement
+ .getAttribute(VpeTemplateManager.ATTR_DATATABLE_ROW_CLASSES));
+ setCellsClass(
+ visualElements.getBodyRow(),
+ sourceElement
+ .getAttribute(VpeTemplateManager.ATTR_DATATABLE_COLUMN_CLASSES));
}
if (sourceElements != null && visualElements != null) {
- setRowDisplayStyle(visualElements.getTableHeaderRow(),
sourceElements.hasTableHeader());
- setRowDisplayStyle(visualElements.getColumnsHeaderRow(),
sourceElements.hasColumnsHeader());
- setRowDisplayStyle(visualElements.getBodyRow(), sourceElements.hasBodySection());
- setRowDisplayStyle(visualElements.getColumnsFooterRow(),
sourceElements.hasColumnsFooter());
- setRowDisplayStyle(visualElements.getTableFooterRow(),
sourceElements.hasTableFooter());
+ setRowDisplayStyle(visualElements.getTableHeaderRow(),
+ sourceElements.hasTableHeader());
+ setRowDisplayStyle(visualElements.getColumnsHeaderRow(),
+ sourceElements.hasColumnsHeader());
+ setRowDisplayStyle(visualElements.getBodyRow(), sourceElements
+ .hasBodySection());
+ setRowDisplayStyle(visualElements.getColumnsFooterRow(),
+ sourceElements.hasColumnsFooter());
+ setRowDisplayStyle(visualElements.getTableFooterRow(),
+ sourceElements.hasTableFooter());
}
}
- public void removeAttribute(VpePageContext pageContext, Element sourceElement, Map
visualNodeMap, String name) {
+ public void removeAttribute(VpePageContext pageContext,
+ Element sourceElement, Map visualNodeMap, String name) {
VisualDataTableElements visualElements = getVisualDataTableElements(visualNodeMap);
if (visualElements != null) {
- if (caseSensitive ? VpeTemplateManager.ATTR_DATATABLE_HEADER_CLASS.equals(name) :
VpeTemplateManager.ATTR_DATATABLE_HEADER_CLASS.equalsIgnoreCase(name)) {
+ if (caseSensitive ? VpeTemplateManager.ATTR_DATATABLE_HEADER_CLASS
+ .equals(name)
+ : VpeTemplateManager.ATTR_DATATABLE_HEADER_CLASS
+ .equalsIgnoreCase(name)) {
removeCellsClass(visualElements.getTableHeaderRow());
removeCellsClass(visualElements.getColumnsHeaderRow());
- } else if (caseSensitive ? VpeTemplateManager.ATTR_DATATABLE_FOOTER_CLASS.equals(name)
: VpeTemplateManager.ATTR_DATATABLE_FOOTER_CLASS.equalsIgnoreCase(name)) {
+ } else if (caseSensitive ? VpeTemplateManager.ATTR_DATATABLE_FOOTER_CLASS
+ .equals(name)
+ : VpeTemplateManager.ATTR_DATATABLE_FOOTER_CLASS
+ .equalsIgnoreCase(name)) {
removeCellsClass(visualElements.getColumnsFooterRow());
removeCellsClass(visualElements.getTableFooterRow());
- } else if (caseSensitive ? VpeTemplateManager.ATTR_DATATABLE_ROW_CLASSES.equals(name)
: VpeTemplateManager.ATTR_DATATABLE_ROW_CLASSES.equalsIgnoreCase(name)) {
+ } else if (caseSensitive ? VpeTemplateManager.ATTR_DATATABLE_ROW_CLASSES
+ .equals(name)
+ : VpeTemplateManager.ATTR_DATATABLE_ROW_CLASSES
+ .equalsIgnoreCase(name)) {
removeRowClass(visualElements.getBodyRow());
- } else if (caseSensitive ?
VpeTemplateManager.ATTR_DATATABLE_COLUMN_CLASSES.equals(name) :
VpeTemplateManager.ATTR_DATATABLE_COLUMN_CLASSES.equalsIgnoreCase(name)) {
+ } else if (caseSensitive ? VpeTemplateManager.ATTR_DATATABLE_COLUMN_CLASSES
+ .equals(name)
+ : VpeTemplateManager.ATTR_DATATABLE_COLUMN_CLASSES
+ .equalsIgnoreCase(name)) {
removeCellsClass(visualElements.getBodyRow());
}
}
@@ -466,14 +564,15 @@
long count = children != null ? children.getLength() : 0;
for (long i = 0; i < count; i++) {
nsIDOMNode child = children.item(i);
- if (child != null && child.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ 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) {
- // just ignore this exception
+ // just ignore this exception
}
}
}
@@ -486,13 +585,14 @@
long count = children != null ? children.getLength() : 0;
for (long i = 0; i < count; i++) {
nsIDOMNode child = children.item(i);
- if (child != null && child.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ if (child != null
+ && child.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
try {
nsIDOMHTMLTableCellElement cell = (nsIDOMHTMLTableCellElement) child
- .queryInterface(nsIDOMHTMLTableCellElement.NS_IDOMHTMLTABLECELLELEMENT_IID);
+ .queryInterface(nsIDOMHTMLTableCellElement.NS_IDOMHTMLTABLECELLELEMENT_IID);
cell.removeAttribute(ATTR_CLASS);
} catch (XPCOMException ex) {
- // just ignore this exception
+ // just ignore this exception
}
}
}
@@ -502,7 +602,8 @@
private void setRowClass(nsIDOMElement row, String value) {
if (row != null && value != null) {
String[] rowClasses = getClasses(value);
- String rowClass = (rowClasses != null && rowClasses.length > 0) ?
rowClasses[0] : null;
+ String rowClass = (rowClasses != null && rowClasses.length > 0) ?
rowClasses[0]
+ : null;
if (rowClass.trim().length() > 0) {
row.setAttribute(ATTR_CLASS, rowClass);
} else {
@@ -513,7 +614,8 @@
private void setRowDisplayStyle(nsIDOMElement row, boolean visible) {
if (row != null) {
- row.setAttribute(ATTR_STYLE, DISPLAY_STYLE_NAME + (visible ? EMPTY : NONE));
+ row.setAttribute(ATTR_STYLE, DISPLAY_STYLE_NAME
+ + (visible ? EMPTY : NONE));
}
}
@@ -527,8 +629,9 @@
if (visualNodeMap != null) {
Object o = visualNodeMap.get(this);
try {
- if (o != null && o instanceof Object[] && ((Object[])o)[0] instanceof
VisualDataTableElements) {
- return (VisualDataTableElements)((Object[])o)[0];
+ if (o != null && o instanceof Object[]
+ && ((Object[]) o)[0] instanceof VisualDataTableElements) {
+ return (VisualDataTableElements) ((Object[]) o)[0];
}
} catch (Exception e) {
}
@@ -540,8 +643,9 @@
if (visualNodeMap != null) {
Object o = visualNodeMap.get(this);
try {
- if (o != null && o instanceof Object[] && ((Object[])o)[1] instanceof
SourceDataTableElements) {
- return (SourceDataTableElements)((Object[])o)[1];
+ if (o != null && o instanceof Object[]
+ && ((Object[]) o)[1] instanceof SourceDataTableElements) {
+ return (SourceDataTableElements) ((Object[]) o)[1];
}
} catch (Exception e) {
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpePanelGridCreator.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpePanelGridCreator.java 2008-04-17
06:23:01 UTC (rev 7565)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpePanelGridCreator.java 2008-04-17
09:11:37 UTC (rev 7566)
@@ -34,7 +34,7 @@
public class VpePanelGridCreator extends VpeAbstractCreator {
- private final String REDUNDANT_TEXT_SEPARATOR = "\n\n";
+ private final String REDUNDANT_TEXT_SEPARATOR = "\n\n"; //$NON-NLS-1$
private boolean caseSensitive;
private VpeExpression tableSizeExpr;
@@ -301,9 +301,7 @@
nsIDOMElement visualHead = null;
nsIDOMElement visualFoot = null;
nsIDOMElement visualCaption = null;
- nsIDOMElement visualBody = visualDocument
- .createElement(HTML.TAG_TBODY);
- visualTable.appendChild(visualBody);
+
if (caption != null) {
visualCaption = visualDocument
.createElement(HTML.TAG_CAPTION);
@@ -317,7 +315,7 @@
String captionClass = captionClassExpr.exec(
pageContext, caption.getParentNode())
.stringValue();
- visualCaption.setAttribute("class", captionClass);
+ visualCaption.setAttribute(HTML.ATTR_CLASS, captionClass);
}
if (captionStyleExpr != null
@@ -325,7 +323,7 @@
String captionStyle = captionStyleExpr.exec(
pageContext, caption.getParentNode())
.stringValue();
- visualCaption.setAttribute("style", captionStyle);
+ visualCaption.setAttribute(HTML.ATTR_STYLE, captionStyle);
}
}
if (header != null) {
@@ -337,6 +335,10 @@
visualTable.appendChild(visualFoot);
}
+ nsIDOMElement visualBody = visualDocument
+ .createElement(HTML.TAG_TBODY);
+ visualTable.appendChild(visualBody);
+
List rowClasses = getClasses(rowClassesExpr, sourceNode,
pageContext);
List columnClasses = getClasses(columnClassesExpr, sourceNode,
@@ -346,7 +348,7 @@
nsIDOMElement visualRow = visualDocument
.createElement(HTML.TAG_TR);
if (rowClasses.size() > 0) {
- visualRow.setAttribute("class", rowClasses.get(rci)
+ visualRow.setAttribute(HTML.ATTR_CLASS, rowClasses.get(rci)
.toString());
rci++;
if (rci >= rowClasses.size())
@@ -356,7 +358,7 @@
nsIDOMElement visualCell = visualDocument
.createElement(HTML.TAG_TD);
if (columnClasses.size() > 0) {
- visualCell.setAttribute("class", columnClasses.get(
+ visualCell.setAttribute(HTML.ATTR_CLASS, columnClasses.get(
cci).toString());
cci++;
if (cci >= columnClasses.size())
@@ -381,9 +383,9 @@
}
}
makeSpecial(header, visualHead, visualDocument, tableSize,
- creatorInfo, "th", headerClassExpr, pageContext);
+ creatorInfo, HTML.TAG_TH, headerClassExpr, pageContext);
makeSpecial(footer, visualFoot, visualDocument, tableSize,
- creatorInfo, "td", footerClassExpr, pageContext);
+ creatorInfo, HTML.TAG_TD, footerClassExpr, pageContext);
for (int i = 0; i < propertyCreators.size(); i++) {
VpeCreator creator = (VpeCreator) propertyCreators.get(i);
@@ -429,11 +431,11 @@
nsIDOMElement visualRow = visualDocument.createElement(HTML.TAG_TR);
visualHead.appendChild(visualRow);
nsIDOMElement visualCell = visualDocument.createElement(cellTag);
- visualCell.setAttribute("colspan", "" + tableSize);
+ visualCell.setAttribute(HTML.ATTR_COLSPAN, "" + tableSize);
if (headerClassExpr != null && header.getParentNode() != null) {
String headerClass = headerClassExpr.exec(pageContext,
header.getParentNode()).stringValue();
- visualCell.setAttribute("class", headerClass);
+ visualCell.setAttribute(HTML.ATTR_CLASS, headerClass);
}
visualRow.appendChild(visualCell);
VpeChildrenInfo childrenInfo = new VpeChildrenInfo(visualCell);
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TemplateManagingUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TemplateManagingUtil.java 2008-04-17
06:23:01 UTC (rev 7565)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TemplateManagingUtil.java 2008-04-17
09:11:37 UTC (rev 7566)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.util;
+import java.util.List;
+
import org.eclipse.swt.graphics.Point;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
@@ -23,6 +25,7 @@
import org.mozilla.interfaces.nsIDOMNSHTMLInputElement;
import org.mozilla.interfaces.nsIDOMNSHTMLTextAreaElement;
import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMRange;
import org.mozilla.interfaces.nsISelection;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -269,15 +272,21 @@
*/
public static nsIDOMNode getSelectedNode(nsISelection selection) {
- if (selection.getFocusNode() != null) {
- if ((selection.getFocusNode().getNodeType() != nsIDOMNode.TEXT_NODE)
- && (selection.getFocusOffset() != 0)) {
+ if (selection.getIsCollapsed()) {
+ if (selection.getFocusNode() != null) {
+ if ((selection.getFocusNode().getNodeType() != nsIDOMNode.TEXT_NODE)
+ && (selection.getFocusOffset() != 0)) {
- return selection.getFocusNode().getChildNodes().item(
- selection.getFocusOffset() - 1);
- } else
- return selection.getFocusNode();
+ return selection.getFocusNode().getChildNodes().item(
+ selection.getFocusOffset() - 1);
+ } else
+ return selection.getFocusNode();
+ }
+ } else {
+ nsIDOMRange range = selection.getRangeAt(0);
+ nsIDOMNode visualAncestor = range.getCommonAncestorContainer();
+ return visualAncestor;
}
return null;
}