Author: dvinnichek
Date: 2010-07-08 06:01:35 -0400 (Thu, 08 Jul 2010)
New Revision: 23308
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfAbstractTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfCellTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfChapterTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfSectionTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfTableTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/util/SeamUtil.java
Log:
fix templates for seam components according to JBIDE-6542
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfAbstractTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfAbstractTemplate.java 2010-07-08
09:48:23 UTC (rev 23307)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfAbstractTemplate.java 2010-07-08
10:01:35 UTC (rev 23308)
@@ -43,24 +43,24 @@
protected final void copySizeAttrs(nsIDOMElement visualElement,
Element sourceElement) {
- String width = sourceElement.getAttribute(HTML.ATTR_WIDTH);
- String height = sourceElement.getAttribute(HTML.ATTR_HEIGHT);
- if (width != null) {
- String styleAttrValue = visualElement.getAttribute(HTML.ATTR_STYLE);
- if (styleAttrValue == null) {
+ if (sourceElement.hasAttribute(HTML.ATTR_WIDTH)) {
+ String width = sourceElement.getAttribute(HTML.ATTR_WIDTH);
+ if (visualElement.hasAttribute(HTML.ATTR_STYLE)) {
+ String styleAttrValue = visualElement.getAttribute(HTML.ATTR_STYLE);
+ visualElement.setAttribute(HTML.ATTR_STYLE, styleAttrValue
+ + "; width:" + width); //$NON-NLS-1$
+ } else {
visualElement.setAttribute(HTML.ATTR_STYLE, "width:" + width);
//$NON-NLS-1$
- } else {
- visualElement.setAttribute(HTML.ATTR_STYLE, styleAttrValue
- + "; width:" + width); //$NON-NLS-1$
}
}
- if (height != null) {
- String styleAttrValue = visualElement.getAttribute(HTML.ATTR_STYLE);
- if (styleAttrValue == null) {
- visualElement.setAttribute(HTML.ATTR_STYLE, "height:" + height);
//$NON-NLS-1$
- } else {
+ if (sourceElement.hasAttribute(HTML.ATTR_HEIGHT)) {
+ String height = sourceElement.getAttribute(HTML.ATTR_HEIGHT);
+ if (visualElement.hasAttribute(HTML.ATTR_STYLE)) {
+ String styleAttrValue = visualElement.getAttribute(HTML.ATTR_STYLE);
visualElement.setAttribute(HTML.ATTR_STYLE, styleAttrValue
+ "; height:" + height); //$NON-NLS-1$
+ } else {
+ visualElement.setAttribute(HTML.ATTR_STYLE, "height:" + height);
//$NON-NLS-1$
}
}
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfCellTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfCellTemplate.java 2010-07-08
09:48:23 UTC (rev 23307)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfCellTemplate.java 2010-07-08
10:01:35 UTC (rev 23308)
@@ -54,23 +54,25 @@
}
private void copyAttrs(nsIDOMElement visualElement, Element sourceElement) {
- String attr = sourceElement.getAttribute(HTML.ATTR_COLSPAN);
- if (attr != null) {
- visualElement.setAttribute(HTML.ATTR_COLSPAN, attr);
+
+ if (sourceElement.hasAttribute(HTML.ATTR_COLSPAN)) {
+ String colspanAttr = sourceElement.getAttribute(HTML.ATTR_COLSPAN);
+ visualElement.setAttribute(HTML.ATTR_COLSPAN, colspanAttr);
}
- attr = sourceElement
- .getAttribute(SeamUtil.SEAM_ATTR_HORIZONAL_ALIGNMENT);
- if (attr != null) {
- visualElement.setAttribute(HTML.ATTR_ALIGN, attr);
+
+ if (sourceElement.hasAttribute(SeamUtil.SEAM_ATTR_HORIZONAL_ALIGNMENT)) {
+ String horAlAttr =
sourceElement.getAttribute(SeamUtil.SEAM_ATTR_HORIZONAL_ALIGNMENT);
+ visualElement.setAttribute(HTML.ATTR_ALIGN, horAlAttr);
}
- attr = sourceElement
- .getAttribute(SeamUtil.SEAM_ATTR_VERTICAL_ALIGNMENT);
- if (attr != null) {
- visualElement.setAttribute(HTML.ATTR_VALIGN, attr);
+
+ if (sourceElement.hasAttribute(SeamUtil.SEAM_ATTR_VERTICAL_ALIGNMENT)) {
+ String vertAlAttr =
sourceElement.getAttribute(SeamUtil.SEAM_ATTR_VERTICAL_ALIGNMENT);
+ visualElement.setAttribute(HTML.ATTR_VALIGN, vertAlAttr);
}
- attr = sourceElement.getAttribute("noWrap"); //$NON-NLS-1$
- if (attr != null) {
- visualElement.setAttribute("nowrap", attr); //$NON-NLS-1$
+
+ if (sourceElement.hasAttribute("noWrap")) {
+ String noWrapAttr = sourceElement.getAttribute("noWrap"); //$NON-NLS-1$
+ visualElement.setAttribute("nowrap", noWrapAttr); //$NON-NLS-1$
}
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfChapterTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfChapterTemplate.java 2010-07-08
09:48:23 UTC (rev 23307)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfChapterTemplate.java 2010-07-08
10:01:35 UTC (rev 23308)
@@ -40,15 +40,14 @@
sourceElement = (Element) sourceNode;
visualElement = VisualDomUtil.createBorderlessContainer(visualDocument);
nsIDOMNode headNode = visualDocument.createElement(HTML.TAG_H1);
- String chapterNumber = sourceElement.getAttribute(NUMBER);
- if (chapterNumber != null) {
+ String chapterNumber = "1"; //$NON-NLS-1$
+ if (sourceElement.hasAttribute(NUMBER)) {
try {
+ chapterNumber = sourceElement.getAttribute(NUMBER);
Integer.parseInt(chapterNumber);
} catch (NumberFormatException e) {
chapterNumber = "1"; //$NON-NLS-1$
}
- } else {
- chapterNumber = "1"; //$NON-NLS-1$
}
nsIDOMText chapterNumberNode = visualDocument
.createTextNode(chapterNumber + ". "); //$NON-NLS-1$
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfSectionTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfSectionTemplate.java 2010-07-08
09:48:23 UTC (rev 23307)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfSectionTemplate.java 2010-07-08
10:01:35 UTC (rev 23308)
@@ -121,9 +121,10 @@
private int getChapterNumber(Node chapterNode) {
int chapterNumber = 1;
- String chapterNumberString = ((Element) chapterNode)
- .getAttribute("number"); //$NON-NLS-1$
- if (chapterNumberString != null) {
+ Element chapterElement = (Element) chapterNode;
+ String numberAttrName = "number"; //$NON-NLS-1$
+ if (chapterElement.hasAttribute(numberAttrName)) {
+ String chapterNumberString = chapterElement.getAttribute(numberAttrName);
try {
chapterNumber = Integer.parseInt(chapterNumberString);
} catch (NumberFormatException e) {
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfTableTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfTableTemplate.java 2010-07-08
09:48:23 UTC (rev 23307)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamPdfTableTemplate.java 2010-07-08
10:01:35 UTC (rev 23308)
@@ -71,10 +71,11 @@
private int getNumberOfColumns(Node sourceTableNode) {
int columnsNumber = 1;
- String columnsNumberString = ((Element) sourceTableNode)
- .getAttribute("columns"); //$NON-NLS-1$
- if (columnsNumberString != null) {
+ Element sourceTableElement = (Element) sourceTableNode;
+ String columnsAttrName = "columns"; //$NON-NLS-1$
+ if (sourceTableElement.hasAttribute(columnsAttrName)) {
try {
+ String columnsNumberString = sourceTableElement.getAttribute(columnsAttrName);
columnsNumber = Integer.parseInt(columnsNumberString);
if (columnsNumber < 1) {
columnsNumber = 1;
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/util/SeamUtil.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/util/SeamUtil.java 2010-07-08
09:48:23 UTC (rev 23307)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/util/SeamUtil.java 2010-07-08
10:01:35 UTC (rev 23308)
@@ -69,8 +69,9 @@
public static void setAlignment(Element sourceElement,
nsIDOMElement visualElement) {
- String align = sourceElement.getAttribute(SeamUtil.SEAM_ATTR_ALIGNMENT);
- if (align != null) {
+
+ if (sourceElement.hasAttribute(SeamUtil.SEAM_ATTR_ALIGNMENT)) {
+ String align = sourceElement.getAttribute(SeamUtil.SEAM_ATTR_ALIGNMENT);
visualElement.setAttribute(HTML.ATTR_ALIGN, HTML.VALUE_ALIGN_LEFT);
for (int i = 0; i < SeamUtil.POSSIBLE_ALIGNS.length; i++) {
if (SeamUtil.POSSIBLE_ALIGNS[i].equalsIgnoreCase(align)) {
@@ -143,9 +144,9 @@
private static String parseFontStyleValue(Node sourceFontNode) {
StringBuffer styleAttrValue = new StringBuffer(""); //$NON-NLS-1$
- String stringValueToParse = ((Element) sourceFontNode)
- .getAttribute(HTML.ATTR_STYLE);
- if (stringValueToParse != null) {
+ Element sourceFontElement = (Element) sourceFontNode;
+ if (sourceFontElement.hasAttribute(HTML.ATTR_STYLE)) {
+ String stringValueToParse = sourceFontElement.getAttribute(HTML.ATTR_STYLE);
int boldPos = stringValueToParse.indexOf("bold"); //$NON-NLS-1$
if (boldPos != -1) {
styleAttrValue.append(" font-weight : bold;"); //$NON-NLS-1$
@@ -168,30 +169,30 @@
private static String getFontFamily(Node sourceFontNode) {
String fontFamily = "unknown"; //$NON-NLS-1$
- String stringName = ((Element) sourceFontNode)
- .getAttribute(HTML.ATTR_NAME);
- if (stringName != null) {
+ Element sourceFontElement = (Element) sourceFontNode;
+ if (sourceFontElement.hasAttribute(HTML.ATTR_NAME)) {
+ String stringName = sourceFontElement.getAttribute(HTML.ATTR_NAME);
fontFamily = stringName;
}
return " font-family : " + fontFamily + ";"; //$NON-NLS-1$
//$NON-NLS-2$
}
private static String getSize(Node sourceFontNode) {
- String stringSizeAttr = ((Element) sourceFontNode)
- .getAttribute(HTML.ATTR_SIZE);
- if (stringSizeAttr != null) {
+ Element sourceFontElement = (Element) sourceFontNode;
+ if (sourceFontElement.hasAttribute(HTML.ATTR_SIZE)) {
try {
+ String stringSizeAttr = sourceFontElement.getAttribute(HTML.ATTR_SIZE);
int intSize = Integer.parseInt(stringSizeAttr);
if (intSize < 0) {
return ""; //$NON-NLS-1$
}
+ return " font-size : " + stringSizeAttr + "pt;"; //$NON-NLS-1$
//$NON-NLS-2$
} catch (NumberFormatException e) {
return ""; //$NON-NLS-1$
}
} else {
return ""; //$NON-NLS-1$
- }
- return " font-size : " + stringSizeAttr + "pt;"; //$NON-NLS-1$
//$NON-NLS-2$
+ }
}
public static String getAbsoluteResourcePath(String resourcePathInPlugin) {
Show replies by date