[jbosstools-commits] JBoss Tools SVN: r23316 - 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
Thu Jul 8 09:56:45 EDT 2010
Author: dvinnichek
Date: 2010-07-08 09:56:44 -0400 (Thu, 08 Jul 2010)
New Revision: 23316
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreatorUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTextPseudoContentCreator.java
Log:
fix templates for vpe editor according to JBIDE-6542
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2010-07-08 13:53:03 UTC (rev 23315)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2010-07-08 13:56:44 UTC (rev 23316)
@@ -343,9 +343,9 @@
* @param templateSection the template section
*/
private void initBreakHandler(Element templateSection) {
- if (breakerType == BREAKER_TYPE_NONE) {
- String typeValue = templateSection.getAttribute(ATTR_BREAKER_TYPE);
- if (typeValue != null) {
+ if (breakerType == BREAKER_TYPE_NONE) {
+ if (templateSection.hasAttribute(ATTR_BREAKER_TYPE)) {
+ String typeValue = templateSection.getAttribute(ATTR_BREAKER_TYPE);
if (ATTR_BREAKER_TYPE_IGNORE.equalsIgnoreCase(typeValue)) {
breakerType = BREAKER_TYPE_IGNORE;
} else if (ATTR_BREAKER_TYPE_SELECTITEM
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreatorUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreatorUtil.java 2010-07-08 13:53:03 UTC (rev 23315)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreatorUtil.java 2010-07-08 13:56:44 UTC (rev 23316)
@@ -49,8 +49,11 @@
}
public static String getFacetName(Node node) {
- if (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
- return ((Element)node).getAttribute("name"); //$NON-NLS-1$
+ Element nodeElement = (Element)node;
+ String nameAttrName = "name"; //$NON-NLS-1$
+ if (node != null && node.getNodeType() == Node.ELEMENT_NODE &&
+ nodeElement.hasAttribute(nameAttrName)) {
+ return nodeElement.getAttribute(nameAttrName);
}
return null;
}
@@ -97,9 +100,14 @@
public static Document getIncludeDocument(Node includeNode, VpePageContext pageContext) {
if (isInclude(includeNode)) {
- String pageName = ((Element)includeNode).getAttribute("page"); //$NON-NLS-1$
- if (pageName == null) {
- pageName = ((Element)includeNode).getAttribute("file"); //$NON-NLS-1$
+ Element includeElement = (Element)includeNode;
+ String pageAttrName = "page"; //$NON-NLS-1$
+ String fileAttrName = "file"; //$NON-NLS-1$
+ String pageName = null;
+ if (includeElement.hasAttribute(pageAttrName)) {
+ pageName = includeElement.getAttribute(pageAttrName);
+ } else if (includeElement.hasAttribute(fileAttrName)) {
+ pageName = includeElement.getAttribute(fileAttrName);
}
if (pageName != null) {
IDOMModel wtpModel = getWtpModelForRead(pageName, pageContext);
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTextPseudoContentCreator.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTextPseudoContentCreator.java 2010-07-08 13:53:03 UTC (rev 23315)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTextPseudoContentCreator.java 2010-07-08 13:56:44 UTC (rev 23316)
@@ -42,15 +42,15 @@
String text = this.text;
if (text == null) {
if (sourceContainer.getNodeType() == Node.ELEMENT_NODE) {
+ Element sourceElement = (Element)sourceContainer;
String name = null;
- if (attrName != null) {
- name = ((Element)sourceContainer).getAttribute(attrName);
- if (name != null) {
- name = name.trim();
+ if (attrName != null) {
+ if (sourceElement.hasAttribute(attrName)) {
+ name = sourceElement.getAttribute(attrName).trim();
}
}
if (name == null || attrName.length() <= 0) {
- name = ((Element)sourceContainer).getNodeName();
+ name = sourceElement.getNodeName();
}
text = MessageFormat.format(VpeUIMessages.VpeTextPseudoContentCreator_InsertContentFor, name);
} else {
More information about the jbosstools-commits
mailing list