Index: jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JSF2CompositeAttributeTemplate.java
===================================================================
--- jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JSF2CompositeAttributeTemplate.java (revision 23081)
+++ jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JSF2CompositeAttributeTemplate.java (working copy)
@@ -30,14 +30,14 @@
nsIDOMDocument visualDocument) {
Element sourceElement = (Element) sourceNode;
String name = sourceElement.getAttribute(JSF.ATTR_NAME);
- String defaultValue = sourceElement.getAttribute(JSF.ATTR_DEFAULT);
//we should register attributes only if we process this as custom component, but not when we open component definition page
if(!pageContext.getVisualBuilder().isCurrentMainDocument()){
String compositionCustomElementAttributeKey = Jsf2CustomComponentTemplate.JSF2_CUSTOM_COMPONENT_PARAMETR_KEY +name;
if(pageContext.getCustomElementsAttributes().containsKey(compositionCustomElementAttributeKey)){
pageContext.addAttributeInCustomElementsMap(JSF.CUSTOM_COMPONENT_ATTR_PREFIX+name,
pageContext.getCustomElementsAttributes().get(compositionCustomElementAttributeKey));
- }else if(defaultValue!=null) {
+ }else if(sourceElement.hasAttribute(JSF.ATTR_DEFAULT)) {
+ String defaultValue = sourceElement.getAttribute(JSF.ATTR_DEFAULT);
pageContext.addAttributeInCustomElementsMap(JSF.CUSTOM_COMPONENT_ATTR_PREFIX+name, defaultValue);
}
}
Index: jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java
===================================================================
--- jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java (revision 23081)
+++ jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java (working copy)
@@ -493,11 +493,7 @@
* @return the attribute
*/
public static String getAttribute(Element sourceElement, String attributeName, String defaultValue) {
- String attribute = sourceElement.getAttribute(attributeName);
- if (attribute == null) {
- attribute = defaultValue;
- }
- return attribute;
+ return sourceElement.hasAttribute(attributeName) ? sourceElement.getAttribute(attributeName) : defaultValue;
}
/**
@@ -651,7 +647,7 @@
public static void correctAttribute(Element sourceNode, nsIDOMElement targetNode,
String sourceAttrName, String targetAttrName,
String prefValue, String defValue) {
- String attrValue = ((Element) sourceNode).getAttribute(sourceAttrName);
+ String attrValue = sourceNode.hasAttribute(sourceAttrName) ? sourceNode.getAttribute(sourceAttrName) : null;
if (prefValue != null && prefValue.trim().length() > 0 && attrValue != null) {
attrValue = prefValue.trim() + Constants.WHITE_SPACE + attrValue;
}
Index: jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java
===================================================================
--- jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java (revision 23081)
+++ jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java (working copy)
@@ -618,9 +618,9 @@
inputStyle = DEFAULT_INPUT_STYLE + Constants.SEMICOLON
+ sourceElement.getAttribute(RichFaces.ATTR_INPUT_STYLE);
+ String inputClassAttrVal = sourceElement.hasAttribute(RichFaces.ATTR_INPUT_CLASS) ? sourceElement.getAttribute(RichFaces.ATTR_INPUT_CLASS) : null;
// inputClass
- inputClass = CSS_R_C_INPUT + Constants.WHITE_SPACE
- + sourceElement.getAttribute(RichFaces.ATTR_INPUT_CLASS);
+ inputClass = CSS_R_C_INPUT + Constants.WHITE_SPACE + inputClassAttrVal;
// inputSize
inputSize = sourceElement.hasAttribute(RichFaces.ATTR_INPUT_SIZE) ? sourceElement
@@ -662,7 +662,7 @@
buttonIcon = buttonIcon.replace('\\', '/');
// buttonClass
- buttonClass = sourceElement.getAttribute(RichFaces.ATTR_BUTTON_CLASS);
+ buttonClass = sourceElement.hasAttribute(RichFaces.ATTR_BUTTON_CLASS) ? sourceElement.getAttribute(RichFaces.ATTR_BUTTON_CLASS) : null;
// showWeekDaysBar
showWeekDaysBar = (!sourceElement
Index: jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesColumnTemplate.java
===================================================================
--- jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesColumnTemplate.java (revision 23081)
+++ jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesColumnTemplate.java (working copy)
@@ -108,9 +108,9 @@
} else {
columnClass = "dr-table-cell rich-table-cell"; //$NON-NLS-1$
}
-
- String styleClass = sourceElement.getAttribute(RichFaces.ATTR_STYLE_CLASS);
- if (styleClass != null) {
+
+ if (sourceElement.hasAttribute(RichFaces.ATTR_STYLE_CLASS)) {
+ String styleClass = sourceElement.getAttribute(RichFaces.ATTR_STYLE_CLASS);
columnClass += " " + styleClass; //$NON-NLS-1$
}
return columnClass;
@@ -172,11 +172,10 @@
* @return IMG
tag if it is necessary, null
otherwise */
public static nsIDOMElement getHeaderIcon(VpePageContext pageContext, Element column, nsIDOMDocument visualDocument) {
String sortable = ComponentUtil.getAttribute(column, RichFaces.ATTR_SORTABLE);
- String sortBy = column.getAttribute(RichFaces.ATTR_SORT_BY);
- if (RichFaces.VALUE_TRUE.equals(sortable) || sortBy != null) {
- nsIDOMElement img = visualDocument.createElement(HTML.TAG_IMG);
- String sortIcon = column.getAttribute(RichFaces.ATTR_SORT_ICON);
- if (sortIcon != null) {
+ if (RichFaces.VALUE_TRUE.equals(sortable) || column.hasAttribute(RichFaces.ATTR_SORT_BY)) {
+ nsIDOMElement img = visualDocument.createElement(HTML.TAG_IMG);
+ if (column.hasAttribute(RichFaces.ATTR_SORT_ICON)) {
+ String sortIcon = column.getAttribute(RichFaces.ATTR_SORT_ICON);
sortIcon = VpeStyleUtil.addFullPathToImgSrc(sortIcon, pageContext, true);
sortIcon = sortIcon.replace('\\', '/');
img.setAttribute(HTML.ATTR_SRC, sortIcon);
Index: jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesListShuttleTemplate.java
===================================================================
--- jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesListShuttleTemplate.java (revision 23081)
+++ jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesListShuttleTemplate.java (working copy)
@@ -361,8 +361,8 @@
// ComponentUtil.copyAttributes(sourceNode, basicTable);
basicTable.setAttribute(HTML.ATTR_CLASS, styleClasses.get("style")); //$NON-NLS-1$
- basicTable.setAttribute(HTML.ATTR_STYLE, sourceElement
- .getAttribute(RichFaces.ATTR_STYLE));
+ String styleAttr = sourceElement.hasAttribute(RichFaces.ATTR_STYLE) ? sourceElement.getAttribute(RichFaces.ATTR_STYLE) : null;
+ basicTable.setAttribute(HTML.ATTR_STYLE, styleAttr);
VpeCreationData creationData = new VpeCreationData(basicTable);
creationData.addChildrenInfo(new VpeChildrenInfo(null));
@@ -699,11 +699,10 @@
.getAttribute(RichFaces.ATTR_SHOW_BUTTON_LABELS));
for (String key : labelsKeys) {
-
- String label = sourceElement.getAttribute(key + "Label"); //$NON-NLS-1$
-
- if (label != null)
+ if (sourceElement.hasAttribute(key + "Label")) {
+ String label = sourceElement.getAttribute(key + "Label"); //$NON-NLS-1$
labels.put(key, label);
+ }
else
labels.put(key, defaultLabels.get(key));
}
@@ -711,11 +710,11 @@
// prepare style classes
Set styleClassesKeys = defaultStyleClasses.keySet();
for (String key : styleClassesKeys) {
-
- String styleClass = sourceElement.getAttribute(key + "Class"); //$NON-NLS-1$
- if (styleClass != null)
+ if (sourceElement.hasAttribute(key + "Class")) {
+ String styleClass = sourceElement.getAttribute(key + "Class"); //$NON-NLS-1$
styleClasses.put(key, defaultStyleClasses.get(key) + " " //$NON-NLS-1$
+ styleClass);
+ }
else
styleClasses.put(key, defaultStyleClasses.get(key));
}
@@ -737,20 +736,18 @@
}
}
-
- // get rowClass
- String rowClasses = sourceElement
- .getAttribute(RichFaces.ATTR_ROW_CLASSES);
-
- // if this attribue exist then
- if (rowClasses != null) {
+
+ // if attribue exist then
+ if (sourceElement.hasAttribute(RichFaces.ATTR_ROW_CLASSES)) {
+ // get rowClass
+ String rowClasses = sourceElement.getAttribute(RichFaces.ATTR_ROW_CLASSES);
rowClass = rowClasses.split("[,;]")[0]; //$NON-NLS-1$
}
-
- String columnClassesAtribute = sourceElement
- .getAttribute(RichFaces.ATTR_COLUMN_CLASSES);
- if (columnClassesAtribute != null)
+
+ if (sourceElement.hasAttribute(RichFaces.ATTR_COLUMN_CLASSES)) {
+ String columnClassesAtribute = sourceElement.getAttribute(RichFaces.ATTR_COLUMN_CLASSES);
columnClasses = Arrays.asList(columnClassesAtribute.split("[,;]")); //$NON-NLS-1$
+ }
else
columnClasses = new ArrayList();
@@ -780,36 +777,36 @@
// prepare buttons attributes
sourceButtonsAlign = sourceElement
- .getAttribute(ATTR_MOVE_CONTROLS_VERTICAL_ALIGN) != null ? sourceElement
+ .hasAttribute(ATTR_MOVE_CONTROLS_VERTICAL_ALIGN) ? sourceElement
.getAttribute(ATTR_MOVE_CONTROLS_VERTICAL_ALIGN)
: DEFAULT_BUTTON_ALIGN;
targetButtonsAlign = sourceElement
- .getAttribute(ATTR_ORDER_CONTROLS_VERTICAL_ALIGN) != null ? sourceElement
+ .hasAttribute(ATTR_ORDER_CONTROLS_VERTICAL_ALIGN) ? sourceElement
.getAttribute(ATTR_ORDER_CONTROLS_VERTICAL_ALIGN)
: DEFAULT_BUTTON_ALIGN;
// prepare lists attributes
- listsHeight = sourceElement.getAttribute(ATTR_LISTS_HEIGHT);
- if (listsHeight == null) {
- listsHeight = DEFAULT_LIST_HEIGHT;
+ if (sourceElement.hasAttribute(ATTR_LISTS_HEIGHT)) {
+ String listsHeightVal = sourceElement.getAttribute(ATTR_LISTS_HEIGHT);
+ listsHeight = VpeStyleUtil.addPxIfNecessary(listsHeightVal);
} else {
- listsHeight = VpeStyleUtil.addPxIfNecessary(listsHeight);
+ listsHeight = DEFAULT_LIST_HEIGHT;
}
- sourceListsWidth = sourceElement.getAttribute(ATTR_SOURCE_LIST_WIDTH);
- if (sourceListsWidth == null) {
- sourceListsWidth = DEFAULT_LIST_WIDTH;
+ if (sourceElement.hasAttribute(ATTR_SOURCE_LIST_WIDTH)) {
+ String listWidthVal = sourceElement.getAttribute(ATTR_SOURCE_LIST_WIDTH);
+ sourceListsWidth = VpeStyleUtil.addPxIfNecessary(listWidthVal);
} else {
- sourceListsWidth = VpeStyleUtil.addPxIfNecessary(sourceListsWidth);
+ sourceListsWidth = DEFAULT_LIST_WIDTH;
}
-
- targetListsWidth = sourceElement.getAttribute(ATTR_TARGET_LIST_WIDTH);
- if (targetListsWidth == null) {
- targetListsWidth = DEFAULT_LIST_WIDTH;
+
+ if (sourceElement.hasAttribute(ATTR_TARGET_LIST_WIDTH)) {
+ String listWidthVal = sourceElement.getAttribute(ATTR_TARGET_LIST_WIDTH);
+ targetListsWidth = VpeStyleUtil.addPxIfNecessary(listWidthVal);
} else {
- targetListsWidth = VpeStyleUtil.addPxIfNecessary(targetListsWidth);
+ targetListsWidth = DEFAULT_LIST_WIDTH;
}
}
@@ -904,7 +901,7 @@
String headerClass = styleClasses.get("headerCell"); //$NON-NLS-1$
if ((child instanceof Element)
- && (((Element) child).getAttribute("headerClass")) != null) { //$NON-NLS-1$
+ && ((Element) child).hasAttribute("headerClass")) { //$NON-NLS-1$
headerClass += " " //$NON-NLS-1$
+ ((Element) child).getAttribute("headerClass"); //$NON-NLS-1$
}
Index: jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPickListTemplate.java
===================================================================
--- jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPickListTemplate.java (revision 23081)
+++ jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPickListTemplate.java (working copy)
@@ -299,7 +299,8 @@
creationData.addChildrenInfo(new VpeChildrenInfo(null));
rootTable.setAttribute(HTML.ATTR_CLASS, styleClasses.get(RichFaces.ATTR_STYLE));
- rootTable.setAttribute(HTML.ATTR_STYLE, sourceElement.getAttribute(RichFaces.ATTR_STYLE));
+ String attrStyleVal = sourceElement.hasAttribute(RichFaces.ATTR_STYLE) ? sourceElement.getAttribute(RichFaces.ATTR_STYLE) : null;
+ rootTable.setAttribute(HTML.ATTR_STYLE, attrStyleVal);
// create source box
final nsIDOMElement sourceBoxTd = visualDocument.createElement(HTML.TAG_TD);
@@ -588,10 +589,8 @@
// prepare labels
for (LabelKey key : LabelKey.values()) {
-
- String label = sourceElement.getAttribute(key.getValue() + LABEL_SUFFIX);
-
- if (label != null) {
+ if (sourceElement.hasAttribute(key.getValue() + LABEL_SUFFIX)) {
+ String label = sourceElement.getAttribute(key.getValue() + LABEL_SUFFIX);
labels.put(key.getValue(), label);
} else {
labels.put(key.getValue(), defaultLabels.get(key));
@@ -609,7 +608,7 @@
isShowButtonLabels = !Boolean.FALSE.toString().equalsIgnoreCase(sourceElement
.getAttribute(ATTR_SHOW_BUTTON_LABELS));
// prepare buttons attributes
- moveControlsAlign = sourceElement.getAttribute(ATTR_MOVE_CONTROLS_VERTICAL_ALIGN) != null ? sourceElement
+ moveControlsAlign = sourceElement.hasAttribute(ATTR_MOVE_CONTROLS_VERTICAL_ALIGN) ? sourceElement
.getAttribute(ATTR_MOVE_CONTROLS_VERTICAL_ALIGN) : DEFAULT_BUTTON_ALIGN;
// prepare lists attributes
@@ -644,10 +643,9 @@
private void prepareStyleClasses(Element sourceElement) {
// prepare style classes
Set styleClassesKeys = defaultStyleClasses.keySet();
- for (String key : styleClassesKeys) {
-
- String styleClass = sourceElement.getAttribute(key + CLASS_SUFFIX);
- if (styleClass != null) {
+ for (String key : styleClassesKeys) {
+ if (sourceElement.hasAttribute(key + CLASS_SUFFIX)) {
+ String styleClass = sourceElement.getAttribute(key + CLASS_SUFFIX);
styleClasses.put(key, defaultStyleClasses.get(key) + " " //$NON-NLS-1$
+ styleClass);
} else {
Index: jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTogglePanelTemplate.java
===================================================================
--- jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTogglePanelTemplate.java (revision 23081)
+++ jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTogglePanelTemplate.java (working copy)
@@ -77,9 +77,9 @@
Node child = children.item(i);
if (child instanceof Element && child.getNodeName().endsWith(":facet")) { //$NON-NLS-1$
- Element facet = (Element)child;
- String name = ((Element)facet).getAttribute("name"); //$NON-NLS-1$
- if (name != null) {
+ Element facet = (Element)child;
+ if (facet.hasAttribute("name")) {
+ String name = facet.getAttribute("name"); //$NON-NLS-1$
states.put(name, facet);
}
}
@@ -88,10 +88,10 @@
}
private String getInitialState(Element sourceElement) {
- String initialState = sourceElement.getAttribute("initialState"); //$NON-NLS-1$
-
- String stateOrder = sourceElement.getAttribute("stateOrder"); //$NON-NLS-1$
- if(stateOrder!=null) {
+ String initialState = sourceElement.hasAttribute("initialState") ? sourceElement.getAttribute("initialState") : null; //$NON-NLS-1$
+
+ if(sourceElement.hasAttribute("stateOrder")) {
+ String stateOrder = sourceElement.getAttribute("stateOrder"); //$NON-NLS-1$
StringTokenizer st = new StringTokenizer(stateOrder.trim(), ",", false); //$NON-NLS-1$
String firstState = null;
while(st.hasMoreElements()) {
@@ -119,8 +119,7 @@
private String getActiveState(Element sourceElement) {
String activeStateStr;
- String stateOrder = sourceElement.getAttribute("stateOrder"); //$NON-NLS-1$
- if(null == stateOrder) return null;
+ if(!sourceElement.hasAttribute("stateOrder")) return null;
activeStateStr = (String)toggleMap.get(sourceElement);
@@ -131,9 +130,9 @@
return activeStateStr;
}
- private String getNextState(Element sourceElement, String toggleId) {
+ private String getNextState(Element sourceElement, String toggleId) {
+ if(!sourceElement.hasAttribute("stateOrder")) return null;
String stateOrder = sourceElement.getAttribute("stateOrder"); //$NON-NLS-1$
- if(null == stateOrder) return null;
String activeState = getActiveState(sourceElement);
StringTokenizer st = new StringTokenizer(stateOrder.trim(), ",", false); //$NON-NLS-1$