Author: dsakovich
Date: 2008-03-31 09:48:23 -0400 (Mon, 31 Mar 2008)
New Revision: 7211
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/META-INF/MANIFEST.MF
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelBarTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelItemTemplate.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-1713
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/META-INF/MANIFEST.MF 2008-03-31
13:28:45 UTC (rev 7210)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/META-INF/MANIFEST.MF 2008-03-31
13:48:23 UTC (rev 7211)
@@ -13,7 +13,8 @@
org.eclipse.wst.sse.ui,
org.eclipse.ui.workbench.texteditor,
org.eclipse.ui.ide,
- org.mozilla.xpcom
+ org.mozilla.xpcom,
+ org.eclipse.wst.sse.core
Eclipse-LazyStart: true
Bundle-Vendor: Red Hat, Inc.
Bundle-ClassPath: lib/jhighlight-1.0.jar,
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2008-03-31
13:28:45 UTC (rev 7210)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2008-03-31
13:48:23 UTC (rev 7211)
@@ -20,11 +20,14 @@
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.editors.text.ILocationProvider;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
+import org.jboss.tools.vpe.editor.bundle.BundleMap;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMNodeList;
import org.mozilla.xpcom.XPCOMException;
+import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
@@ -33,548 +36,574 @@
public class ComponentUtil {
- /**
- * Gets child of Facet element by name. If facet has a few children the
- * method will return first one.
- *
- * @param sourceElement
- * @param facetName
- * @param returnTextNode
- * return child text node if facet doesn't have any child
- * elements;
- * @return
- */
- public static Node getFacet(Element sourceElement, String facetName,
- boolean returnTextNode) {
- NodeList children = sourceElement.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- Node node = children.item(i);
- if (node instanceof Element && node.getNodeName() != null
- && node.getNodeName().indexOf(":facet") > 0) { //$NON-NLS-1$
- Element element = (Element) node;
- String name = element.getAttribute("name"); //$NON-NLS-1$
- if (facetName.equals(name)) {
- NodeList childNodes = element.getChildNodes();
- Text textNode = null;
- for (int j = 0; j < childNodes.getLength(); j++) {
- Node child = childNodes.item(j);
- if (child instanceof Element) {
- return child;
- } else if (child instanceof Text) {
- textNode = (Text) child;
- }
- }
- if (returnTextNode) {
- return textNode;
- }
- }
+ /**
+ * Gets child of Facet element by name. If facet has a few children the
+ * method will return first one.
+ *
+ * @param sourceElement
+ * @param facetName
+ * @param returnTextNode
+ * return child text node if facet doesn't have any child
+ * elements;
+ * @return
+ */
+ public static Node getFacet(Element sourceElement, String facetName,
+ boolean returnTextNode) {
+ NodeList children = sourceElement.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ if (node instanceof Element && node.getNodeName() != null
+ && node.getNodeName().indexOf(":facet") > 0) { //$NON-NLS-1$
+ Element element = (Element) node;
+ String name = element.getAttribute("name"); //$NON-NLS-1$
+ if (facetName.equals(name)) {
+ NodeList childNodes = element.getChildNodes();
+ Text textNode = null;
+ for (int j = 0; j < childNodes.getLength(); j++) {
+ Node child = childNodes.item(j);
+ if (child instanceof Element) {
+ return child;
+ } else if (child instanceof Text) {
+ textNode = (Text) child;
}
+ }
+ if (returnTextNode) {
+ return textNode;
+ }
}
- return null;
+ }
}
+ return null;
+ }
- /**
- * Gets all facets of sourceElement. If facet has a few children the method
- * will return first one.
- *
- * @param sourceElement
- * @param facetName
- * @param returnTextNode
- * return child text node if facet doesn't have any child
- * elements;
- * @return
- */
- public static ArrayList<Node> getFacets(Element sourceElement,
- boolean returnTextNode) {
- ArrayList<Node> facets = new ArrayList<Node>();
- NodeList children = sourceElement.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- Node node = children.item(i);
- if (node instanceof Element && "f:facet".equals(node.getNodeName()))
{ //$NON-NLS-1$
- Element element = (Element) node;
- NodeList childNodes = element.getChildNodes();
- Text textNode = null;
- for (int j = 0; j < childNodes.getLength(); j++) {
- Node child = childNodes.item(j);
- if (child instanceof Element) {
- facets.add(child);
- break;
- } else if (child instanceof Text) {
- textNode = (Text) child;
- }
- }
- if (returnTextNode && facets.isEmpty()) {
- facets.add(textNode);
- }
- }
+ /**
+ * Gets all facets of sourceElement. If facet has a few children the method
+ * will return first one.
+ *
+ * @param sourceElement
+ * @param facetName
+ * @param returnTextNode
+ * return child text node if facet doesn't have any child
+ * elements;
+ * @return
+ */
+ public static ArrayList<Node> getFacets(Element sourceElement,
+ boolean returnTextNode) {
+ ArrayList<Node> facets = new ArrayList<Node>();
+ NodeList children = sourceElement.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ if (node instanceof Element &&
"f:facet".equals(node.getNodeName())) { //$NON-NLS-1$
+ Element element = (Element) node;
+ NodeList childNodes = element.getChildNodes();
+ Text textNode = null;
+ for (int j = 0; j < childNodes.getLength(); j++) {
+ Node child = childNodes.item(j);
+ if (child instanceof Element) {
+ facets.add(child);
+ break;
+ } else if (child instanceof Text) {
+ textNode = (Text) child;
+ }
}
- return facets;
+ if (returnTextNode && facets.isEmpty()) {
+ facets.add(textNode);
+ }
+ }
}
+ return facets;
+ }
- /**
- * Gets child of Facet element by name. If facet has a few children the
- * method will return first one.
- *
- * @param sourceElement
- * @param facetName
- * @return
- */
- public static Element getFacet(Element sourceElement, String facetName) {
- return (Element) getFacet(sourceElement, facetName, false);
- }
+ /**
+ * Gets child of Facet element by name. If facet has a few children the
+ * method will return first one.
+ *
+ * @param sourceElement
+ * @param facetName
+ * @return
+ */
+ public static Element getFacet(Element sourceElement, String facetName) {
+ return (Element) getFacet(sourceElement, facetName, false);
+ }
- /**
- * Returns true if "rendered" attribute of source element does not contain
- * "false" value.
- *
- * @param sourceElement
- * @return
- */
- public static boolean isRendered(Element sourceElement) {
- return !"false" //$NON-NLS-1$
- .equalsIgnoreCase(sourceElement.getAttribute("rendered")); //$NON-NLS-1$
- }
+ /**
+ * Returns true if "rendered" attribute of source element does not contain
+ * "false" value.
+ *
+ * @param sourceElement
+ * @return
+ */
+ public static boolean isRendered(Element sourceElement) {
+ return !"false" //$NON-NLS-1$
+ .equalsIgnoreCase(sourceElement.getAttribute("rendered")); //$NON-NLS-1$
+ }
- /**
- * Sets CSS link in visual html document.
- *
- * @param pageContext
- * @param cssHref
- */
- public static void setCSSLink(VpePageContext pageContext, String cssHref,
- String ext) {
- String pluginPath = RichFacesTemplatesActivator.getPluginResourcePath();
- IPath pluginFile = new Path(pluginPath);
- File cssFile = pluginFile.append(cssHref).toFile();
- if (cssFile.exists()) {
- String cssPath = "file:///" + cssFile.getPath(); //$NON-NLS-1$
- pageContext.getVisualBuilder().replaceLinkNodeToHead(cssPath, ext);
- }
+ /**
+ * Sets CSS link in visual html document.
+ *
+ * @param pageContext
+ * @param cssHref
+ */
+ public static void setCSSLink(VpePageContext pageContext, String cssHref,
+ String ext) {
+ String pluginPath = RichFacesTemplatesActivator.getPluginResourcePath();
+ IPath pluginFile = new Path(pluginPath);
+ File cssFile = pluginFile.append(cssHref).toFile();
+ if (cssFile.exists()) {
+ String cssPath = "file:///" + cssFile.getPath(); //$NON-NLS-1$
+ pageContext.getVisualBuilder().replaceLinkNodeToHead(cssPath, ext);
}
+ }
- public static String getAbsoluteResourcePath(String resourcePathInPlugin) {
- String pluginPath = RichFacesTemplatesActivator.getPluginResourcePath();
- IPath pluginFile = new Path(pluginPath);
- File file = pluginFile.append(resourcePathInPlugin).toFile();
- if (file.exists()) {
- return file.getAbsolutePath();
- } else {
- throw new RuntimeException("Can't get path for " //$NON-NLS-1$
- + resourcePathInPlugin);
- }
+ public static String getAbsoluteResourcePath(String resourcePathInPlugin) {
+ String pluginPath = RichFacesTemplatesActivator.getPluginResourcePath();
+ IPath pluginFile = new Path(pluginPath);
+ File file = pluginFile.append(resourcePathInPlugin).toFile();
+ if (file.exists()) {
+ return file.getAbsolutePath();
+ } else {
+ throw new RuntimeException("Can't get path for " //$NON-NLS-1$
+ + resourcePathInPlugin);
}
+ }
- /**
- * Adds image as attribute to IMG tag
- *
- * @param img
- * @param fileImageName
- */
- public static void setImg(nsIDOMElement img, String fileImageName) {
- img.setAttribute("src", "file://" //$NON-NLS-1$//$NON-NLS-2$
- + getAbsoluteResourcePath(fileImageName));
- }
+ /**
+ * Adds image as attribute to IMG tag
+ *
+ * @param img
+ * @param fileImageName
+ */
+ public static void setImg(nsIDOMElement img, String fileImageName) {
+ img.setAttribute("src", "file://" //$NON-NLS-1$//$NON-NLS-2$
+ + getAbsoluteResourcePath(fileImageName));
+ }
- /**
- * Returns all child source elements of component but facets.
- *
- * @param sourceElement
- * @param returnTextNodes
- * return child text nodes and elements or elements only;
- * @return
- */
- public static List<Node> getChildren(Element sourceElement,
- boolean returnTextNodes) {
- ArrayList<Node> children = new ArrayList<Node>();
- NodeList nodeList = sourceElement.getChildNodes();
- for (int i = 0; i < nodeList.getLength(); i++) {
- Node child = nodeList.item(i);
- if ((child instanceof Element || returnTextNodes)
- && (!child.getNodeName().equals("f:facet"))) { //$NON-NLS-1$
- children.add(child);
- }
- }
- return children;
+ /**
+ * Returns all child source elements of component but facets.
+ *
+ * @param sourceElement
+ * @param returnTextNodes
+ * return child text nodes and elements or elements only;
+ * @return
+ */
+ public static List<Node> getChildren(Element sourceElement,
+ boolean returnTextNodes) {
+ ArrayList<Node> children = new ArrayList<Node>();
+ NodeList nodeList = sourceElement.getChildNodes();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node child = nodeList.item(i);
+ if ((child instanceof Element || returnTextNodes)
+ && (!child.getNodeName().equals("f:facet"))) { //$NON-NLS-1$
+ children.add(child);
+ }
}
+ return children;
+ }
- /**
- * Returns all child source elements of component but facets.
- *
- * @param sourceElement
- * @return
- */
- public static List<Node> getChildren(Element sourceElement) {
- return getChildren(sourceElement, false);
- }
+ /**
+ * Returns all child source elements of component but facets.
+ *
+ * @param sourceElement
+ * @return
+ */
+ public static List<Node> getChildren(Element sourceElement) {
+ return getChildren(sourceElement, false);
+ }
- /**
- * Returns all child visual elements of component but facets.
- *
- * @param visualElement
- * @param
- * @return returnTextNodes return child text nodes and elements or elements
- * only;
- */
- public static List<nsIDOMNode> getChildren(nsIDOMElement visualElement,
- boolean returnTextNodes) {
- ArrayList<nsIDOMNode> children = new ArrayList<nsIDOMNode>();
- nsIDOMNodeList nodeList = visualElement.getChildNodes();
- for (int i = 0; i < nodeList.getLength(); i++) {
- nsIDOMNode child = nodeList.item(i);
- if ((child instanceof nsIDOMElement || returnTextNodes)
- && (!child.getNodeName().equals("f:facet"))) { //$NON-NLS-1$
- children.add(child);
- }
- }
- return children;
+ /**
+ * Returns all child visual elements of component but facets.
+ *
+ * @param visualElement
+ * @param
+ * @return returnTextNodes return child text nodes and elements or elements
+ * only;
+ */
+ public static List<nsIDOMNode> getChildren(nsIDOMElement visualElement,
+ boolean returnTextNodes) {
+ ArrayList<nsIDOMNode> children = new ArrayList<nsIDOMNode>();
+ nsIDOMNodeList nodeList = visualElement.getChildNodes();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ nsIDOMNode child = nodeList.item(i);
+ if ((child instanceof nsIDOMElement || returnTextNodes)
+ && (!child.getNodeName().equals("f:facet"))) { //$NON-NLS-1$
+ children.add(child);
+ }
}
+ return children;
+ }
- /**
- * Returns all child visual elements of component but facets.
- *
- * @param visualElement
- * @return
- */
- public static List<nsIDOMNode> getChildren(nsIDOMElement visualElement) {
- return getChildren(visualElement, false);
- }
+ /**
+ * Returns all child visual elements of component but facets.
+ *
+ * @param visualElement
+ * @return
+ */
+ public static List<nsIDOMNode> getChildren(nsIDOMElement visualElement) {
+ return getChildren(visualElement, false);
+ }
- /**
- * Copies all attributes from source node to visual node.
- *
- * @param sourceNode
- * @param visualNode
- */
- public static void copyAttributes(Node sourceNode,
- nsIDOMElement visualElement) {
- NamedNodeMap namedNodeMap = sourceNode.getAttributes();
- for (int i = 0; i < namedNodeMap.getLength(); i++) {
- Node attribute = namedNodeMap.item(i);
- // added by Max Areshkau fix for JBIDE-1568
- try {
+ /**
+ * Copies all attributes from source node to visual node.
+ *
+ * @param sourceNode
+ * @param visualNode
+ */
+ public static void copyAttributes(Node sourceNode,
+ nsIDOMElement visualElement) {
+ NamedNodeMap namedNodeMap = sourceNode.getAttributes();
+ for (int i = 0; i < namedNodeMap.getLength(); i++) {
+ Node attribute = namedNodeMap.item(i);
+ // added by Max Areshkau fix for JBIDE-1568
+ try {
- visualElement.setAttribute(attribute.getNodeName(), attribute
- .getNodeValue());
- } catch (XPCOMException ex) {
- // if error-code not equals error for incorrect name throws
- // exception
- // error code is NS_ERROR_DOM_INVALID_CHARACTER_ERR=0x80530005
- if (ex.errorcode != 2152923141L) {
- throw ex;
- }
- // else we ignore this exception
- }
+ visualElement.setAttribute(attribute.getNodeName(), attribute
+ .getNodeValue());
+ } catch (XPCOMException ex) {
+ // if error-code not equals error for incorrect name throws
+ // exception
+ // error code is NS_ERROR_DOM_INVALID_CHARACTER_ERR=0x80530005
+ if (ex.errorcode != 2152923141L) {
+ throw ex;
}
+ // else we ignore this exception
+ }
}
+ }
- /**
- * Copies attributes from source node to visual node.
- *
- * @param attributes -
- * list names of attributes which will copy
- * @param sourceNode
- * @param visualNode
- */
- public static void copyAttributes(Element sourceElement,
- List<String> attributes, nsIDOMElement visualElement) {
+ /**
+ * Copies attributes from source node to visual node.
+ *
+ * @param attributes -
+ * list names of attributes which will copy
+ * @param sourceNode
+ * @param visualNode
+ */
+ public static void copyAttributes(Element sourceElement,
+ List<String> attributes, nsIDOMElement visualElement) {
- if (attributes == null)
- return;
+ if (attributes == null)
+ return;
- for (String attributeName : attributes) {
+ for (String attributeName : attributes) {
- String attributeValue = sourceElement.getAttribute(attributeName);
- if (attributeValue != null)
- visualElement.setAttribute(attributeName, attributeValue);
- }
-
+ String attributeValue = sourceElement.getAttribute(attributeName);
+ if (attributeValue != null)
+ visualElement.setAttribute(attributeName, attributeValue);
}
- /**
- * Returns true if sourceNode is Facet
- *
- * @param sourceNode
- * @param facetName
- * @return
- */
- public static boolean isFacet(Node sourceNode, String facetName) {
- if (sourceNode != null && sourceNode instanceof Element
- && sourceNode.getNodeName().equals("f:facet")) { //$NON-NLS-1$
- String name = ((Element) sourceNode).getAttribute("name"); //$NON-NLS-1$
- if (facetName.equals(name)) {
- return true;
- }
- }
- return false;
- }
+ }
- /**
- * Returns Style with default background image for default RichFaces skin.
- *
- * @return
- */
- public static String getHeaderBackgoundImgStyle() {
- return getBackgoundImgStyle("common/background.gif"); //$NON-NLS-1$
+ /**
+ * Returns true if sourceNode is Facet
+ *
+ * @param sourceNode
+ * @param facetName
+ * @return
+ */
+ public static boolean isFacet(Node sourceNode, String facetName) {
+ if (sourceNode != null && sourceNode instanceof Element
+ && sourceNode.getNodeName().equals("f:facet")) { //$NON-NLS-1$
+ String name = ((Element) sourceNode).getAttribute("name"); //$NON-NLS-1$
+ if (facetName.equals(name)) {
+ return true;
+ }
}
+ return false;
+ }
- /**
- * Returns Style with background image for default RichFaces skin.
- *
- * @return
- */
- public static String getBackgoundImgStyle(String imagePath) {
- String imgPath = ComponentUtil.getAbsoluteResourcePath(imagePath);
- String style = "background-image: url(file:///" //$NON-NLS-1$
- + imgPath.replace('\\', '/') + ");"; //$NON-NLS-1$
- return style;
- }
+ /**
+ * Returns Style with default background image for default RichFaces skin.
+ *
+ * @return
+ */
+ public static String getHeaderBackgoundImgStyle() {
+ return getBackgoundImgStyle("common/background.gif"); //$NON-NLS-1$
+ }
- // public static createStyleClass(String content){
- //
- // }
+ /**
+ * Returns Style with background image for default RichFaces skin.
+ *
+ * @return
+ */
+ public static String getBackgoundImgStyle(String imagePath) {
+ String imgPath = ComponentUtil.getAbsoluteResourcePath(imagePath);
+ String style = "background-image: url(file:///" //$NON-NLS-1$
+ + imgPath.replace('\\', '/') + ");"; //$NON-NLS-1$
+ return style;
+ }
- /**
- * Returns value of attribute.
- *
- * @param sourceElement
- * @param attributeName
- * @return
- */
- public static String getAttribute(Element sourceElement,
- String attributeName) {
- String attribute = sourceElement.getAttribute(attributeName);
- if (attribute == null) {
- attribute = ""; //$NON-NLS-1$
- }
- return attribute;
+ // public static createStyleClass(String content){
+ //
+ // }
+
+ /**
+ * Returns value of attribute.
+ *
+ * @param sourceElement
+ * @param attributeName
+ * @return
+ */
+ public static String getAttribute(Element sourceElement,
+ String attributeName) {
+ String attribute = sourceElement.getAttribute(attributeName);
+ if (attribute == null) {
+ attribute = ""; //$NON-NLS-1$
}
+ return attribute;
+ }
- /**
- * Returns value of attribute.
- *
- * @param sourceElement
- * @param attributeName
- * @return
- */
- public static String getAttribute(nsIDOMElement sourceElement,
- String attributeName) {
- String attribute = sourceElement.getAttribute(attributeName);
- if (attribute == null) {
- attribute = ""; //$NON-NLS-1$
- }
- return attribute;
+ /**
+ * Returns value of attribute.
+ *
+ * @param sourceElement
+ * @param attributeName
+ * @return
+ */
+ public static String getAttribute(nsIDOMElement sourceElement,
+ String attributeName) {
+ String attribute = sourceElement.getAttribute(attributeName);
+ if (attribute == null) {
+ attribute = ""; //$NON-NLS-1$
}
+ return attribute;
+ }
- /**
- * @param style
- * @param name
- * @return
- */
- public static boolean parameterPresent(String style, String name) {
- if (style != null && style.length() > 0) {
- String[] styles = style.split(";"); //$NON-NLS-1$
- for (int i = 0; i < styles.length; i++) {
- String[] pair = styles[i].split(":"); //$NON-NLS-1$
- if (pair[0].trim().equals(name)) {
- return true;
- }
- }
+ /**
+ * @param style
+ * @param name
+ * @return
+ */
+ public static boolean parameterPresent(String style, String name) {
+ if (style != null && style.length() > 0) {
+ String[] styles = style.split(";"); //$NON-NLS-1$
+ for (int i = 0; i < styles.length; i++) {
+ String[] pair = styles[i].split(":"); //$NON-NLS-1$
+ if (pair[0].trim().equals(name)) {
+ return true;
}
- return false;
+ }
}
+ return false;
+ }
- /**
- * @param style
- * @param name
- * @return
- */
- public static String getStyleParametr(String style, String name) {
- if (style != null && style.length() > 0) {
- String[] styles = style.split(";"); //$NON-NLS-1$
- for (int i = 0; i < styles.length; i++) {
- String[] pair = styles[i].split(":"); //$NON-NLS-1$
- if (pair[0].trim().equals(name)) {
- return pair[1].trim();
- }
- }
+ /**
+ * @param style
+ * @param name
+ * @return
+ */
+ public static String getStyleParametr(String style, String name) {
+ if (style != null && style.length() > 0) {
+ String[] styles = style.split(";"); //$NON-NLS-1$
+ for (int i = 0; i < styles.length; i++) {
+ String[] pair = styles[i].split(":"); //$NON-NLS-1$
+ if (pair[0].trim().equals(name)) {
+ return pair[1].trim();
}
- return null;
+ }
}
+ return null;
+ }
- /**
- *
- * @param style
- * @param element
- * @return
- */
- public static String addParameter(String style, String element) {
- String s = style.trim();
- return style + (s.length() == 0 || s.endsWith(";") ? "" :
";") //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- + element;
- }
+ /**
+ *
+ * @param style
+ * @param element
+ * @return
+ */
+ public static String addParameter(String style, String element) {
+ String s = style.trim();
+ return style + (s.length() == 0 || s.endsWith(";") ? "" :
";") //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ + element;
+ }
- /**
- * Adds image as attribute to IMG tag from users worcpace
- *
- * @param pageContext
- * Page Context
- * @param img
- * img element to which set picture
- * @param fileImageName
- * image name
- * @param undefinedImgName
- * default image when image is undefined
- */
- public static void setImgFromResources(VpePageContext pageContext,
- nsIDOMElement img, String fileImageName, String undefinedImgName) {
- IEditorInput input = pageContext.getEditPart().getEditorInput();
- IPath inputPath = getInputParentPath(input);
- File file = new File(inputPath.toOSString() + File.separator
- + fileImageName);
- if (file.exists()) {
- img.setAttribute(HtmlComponentUtil.HTML_ATR_SRC,
- HtmlComponentUtil.FILE_PROTOCOL + inputPath.toOSString()
- + File.separator + fileImageName);
- } else {
- img.setAttribute(HtmlComponentUtil.HTML_ATR_SRC, undefinedImgName);
- }
+ /**
+ * Adds image as attribute to IMG tag from users worcpace
+ *
+ * @param pageContext
+ * Page Context
+ * @param img
+ * img element to which set picture
+ * @param fileImageName
+ * image name
+ * @param undefinedImgName
+ * default image when image is undefined
+ */
+ public static void setImgFromResources(VpePageContext pageContext,
+ nsIDOMElement img, String fileImageName, String undefinedImgName) {
+ IEditorInput input = pageContext.getEditPart().getEditorInput();
+ IPath inputPath = getInputParentPath(input);
+ File file = new File(inputPath.toOSString() + File.separator
+ + fileImageName);
+ if (file.exists()) {
+ img.setAttribute(HtmlComponentUtil.HTML_ATR_SRC,
+ HtmlComponentUtil.FILE_PROTOCOL + inputPath.toOSString()
+ + File.separator + fileImageName);
+ } else {
+ img.setAttribute(HtmlComponentUtil.HTML_ATR_SRC, undefinedImgName);
}
+ }
- /**
- * Open file
- *
- * @param pageContext
- * Page Context
- * @param fileName
- * file name
- * @return file
- */
- public static File openFile(VpePageContext pageContext, String fileName) {
- IEditorInput input = pageContext.getEditPart().getEditorInput();
- IPath inputPath = getInputParentPath(input);
- File file = new File(inputPath.toOSString() + File.separator + fileName);
- return file;
- }
+ /**
+ * Open file
+ *
+ * @param pageContext
+ * Page Context
+ * @param fileName
+ * file name
+ * @return file
+ */
+ public static File openFile(VpePageContext pageContext, String fileName) {
+ IEditorInput input = pageContext.getEditPart().getEditorInput();
+ IPath inputPath = getInputParentPath(input);
+ File file = new File(inputPath.toOSString() + File.separator + fileName);
+ return file;
+ }
- /**
- * Returns locale of user input
- *
- * @param input
- * @return
- */
- public static IPath getInputParentPath(IEditorInput input) {
- IPath inputPath = null;
- if (input instanceof ILocationProvider) {
- inputPath = ((ILocationProvider) input).getPath(input);
- } else if (input instanceof IFileEditorInput) {
- IFile inputFile = ((IFileEditorInput) input).getFile();
- if (inputFile != null) {
- inputPath = inputFile.getLocation();
- }
- }
- if (inputPath != null && !inputPath.isEmpty()) {
- inputPath = inputPath.removeLastSegments(1);
- }
- return inputPath;
+ /**
+ * Returns locale of user input
+ *
+ * @param input
+ * @return
+ */
+ public static IPath getInputParentPath(IEditorInput input) {
+ IPath inputPath = null;
+ if (input instanceof ILocationProvider) {
+ inputPath = ((ILocationProvider) input).getPath(input);
+ } else if (input instanceof IFileEditorInput) {
+ IFile inputFile = ((IFileEditorInput) input).getFile();
+ if (inputFile != null) {
+ inputPath = inputFile.getLocation();
+ }
}
+ if (inputPath != null && !inputPath.isEmpty()) {
+ inputPath = inputPath.removeLastSegments(1);
+ }
+ return inputPath;
+ }
- /**
- * Move attributes from sourceNode to html
- *
- * @param sourceNode
- * @param visualNode
- * @param attrName
- * @param htmlAttrName
- * @param prefValue
- * @param defValue
- */
- public static void correctAttribute(Element sourceNode,
- nsIDOMElement visualNode, String attrName, String htmlAttrName,
- String prefValue, String defValue) {
- String attrValue = ((Element) sourceNode).getAttribute(attrName);
- if (prefValue != null && prefValue.trim().length() > 0
- && attrValue != null) {
- attrValue = prefValue.trim() + " " + attrValue; //$NON-NLS-1$
- }
- if (attrValue != null) {
- visualNode.setAttribute(htmlAttrName, attrValue);
- } else if (defValue != null) {
- visualNode.setAttribute(htmlAttrName, defValue);
- } else
- visualNode.removeAttribute(attrName);
+ /**
+ * Move attributes from sourceNode to html
+ *
+ * @param sourceNode
+ * @param visualNode
+ * @param attrName
+ * @param htmlAttrName
+ * @param prefValue
+ * @param defValue
+ */
+ public static void correctAttribute(Element sourceNode,
+ nsIDOMElement visualNode, String attrName, String htmlAttrName,
+ String prefValue, String defValue) {
+ String attrValue = ((Element) sourceNode).getAttribute(attrName);
+ if (prefValue != null && prefValue.trim().length() > 0
+ && attrValue != null) {
+ attrValue = prefValue.trim() + " " + attrValue; //$NON-NLS-1$
}
+ if (attrValue != null) {
+ visualNode.setAttribute(htmlAttrName, attrValue);
+ } else if (defValue != null) {
+ visualNode.setAttribute(htmlAttrName, defValue);
+ } else
+ visualNode.removeAttribute(attrName);
+ }
- /**
- * Parses string value retrieved from sourceElement.getAttribure(..) method
- * to its boolean value.
- * <p>
- * <code>false</code> is returned only if it specified explicitly,
- * otherwise <code>true</code> is returned.
- *
- * @param str
- * the string to parse
- * @return boolean value from string
- */
- public static boolean string2boolean(String str) {
- if ((str == null) || ("".equals(str))) { //$NON-NLS-1$
- return true;
- } else if (("true".equalsIgnoreCase(str)) //$NON-NLS-1$
- || ("false".equalsIgnoreCase(str))) { //$NON-NLS-1$
- return new Boolean(str).booleanValue();
- }
- return true;
+ /**
+ * Parses string value retrieved from sourceElement.getAttribure(..) method
+ * to its boolean value.
+ * <p>
+ * <code>false</code> is returned only if it specified explicitly,
+ * otherwise <code>true</code> is returned.
+ *
+ * @param str
+ * the string to parse
+ * @return boolean value from string
+ */
+ public static boolean string2boolean(String str) {
+ if ((str == null) || ("".equals(str))) { //$NON-NLS-1$
+ return true;
+ } else if (("true".equalsIgnoreCase(str)) //$NON-NLS-1$
+ || ("false".equalsIgnoreCase(str))) { //$NON-NLS-1$
+ return new Boolean(str).booleanValue();
}
+ return true;
+ }
- /**
- * find elements by name
- *
- * @param node -
- * current node
- * @param elements -
- * list of found elements
- * @param name -
- * name element
- */
- static public void findElementsByName(Node node, List<Node> elements,
- String name) {
- // get children
- NodeList children = node.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- // if current child is required then add his to list
- if (name.equalsIgnoreCase((child.getNodeName()))) {
- elements.add(child);
- } else {
- findElementsByName(child, elements, name);
- }
- }
+ /**
+ * find elements by name
+ *
+ * @param node -
+ * current node
+ * @param elements -
+ * list of found elements
+ * @param name -
+ * name element
+ */
+ static public void findElementsByName(Node node, List<Node> elements,
+ String name) {
+ // get children
+ NodeList children = node.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ // if current child is required then add his to list
+ if (name.equalsIgnoreCase((child.getNodeName()))) {
+ elements.add(child);
+ } else {
+ findElementsByName(child, elements, name);
+ }
}
+ }
- /**
- * find all elements by name
- *
- * @param node -
- * current node
- * @param elements -
- * list of found elements
- * @param name -
- * name element
- */
- static public void findAllElementsByName(nsIDOMNode node,
- List<nsIDOMNode> elements, String name) {
+ /**
+ * find all elements by name
+ *
+ * @param node -
+ * current node
+ * @param elements -
+ * list of found elements
+ * @param name -
+ * name element
+ */
+ static public void findAllElementsByName(nsIDOMNode node,
+ List<nsIDOMNode> elements, String name) {
- try {
- nsIDOMNodeList list = node.getChildNodes();
- if (node.getNodeName().equalsIgnoreCase(name)) {
- elements.add(node);
- }
- for (int i = 0; i < list.getLength(); i++) {
- findAllElementsByName(list.item(i), elements, name);
- }
- } catch (XPCOMException e) {
- // Ignore
- return;
- }
+ try {
+ nsIDOMNodeList list = node.getChildNodes();
+ if (node.getNodeName().equalsIgnoreCase(name)) {
+ elements.add(node);
+ }
+ for (int i = 0; i < list.getLength(); i++) {
+ findAllElementsByName(list.item(i), elements, name);
+ }
+ } catch (XPCOMException e) {
+ // Ignore
+ return;
}
+ }
+ /**
+ *
+ * @param pageContext
+ * @param value
+ * @param offfset
+ * @return
+ */
+ public static String getBundleValue(VpePageContext pageContext,
+ String value, int offset) {
+ BundleMap bundle = pageContext.getBundle();
+ return bundle.getBundleValue(value, offset);
+
+ }
+
+ /**
+ * get bundle
+ *
+ * @param pageContext
+ * @param attr
+ * @return
+ */
+ public static String getBundleValue(VpePageContext pageContext, Attr attr) {
+ return getBundleValue(pageContext, attr.getNodeValue(),
+ ((IDOMAttr) attr).getValueRegionStartOffset());
+ }
+
}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelBarTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelBarTemplate.java 2008-03-31
13:28:45 UTC (rev 7210)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelBarTemplate.java 2008-03-31
13:48:23 UTC (rev 7211)
@@ -30,35 +30,39 @@
public class RichFacesPanelBarTemplate extends VpeAbstractTemplate implements
VpeToggableTemplate, VpeTemplate {
- private static Map toggleMap = new HashMap();
+ private static final String SEMI_COLON = ";"; //$NON-NLS-1$
+ private static final String PERCENT_100 = "100%"; //$NON-NLS-1$
+ private static final String PANEL_BAR_ITEM = ":panelBarItem";
//$NON-NLS-1$
+ private static final String SPACE = " "; //$NON-NLS-1$
+ private static final String EMPTY = ""; //$NON-NLS-1$
+ private static final String DR_PNLBAR_RICH_PANELBAR_DR_PNLBAR_B = "dr-pnlbar
rich-panelbar dr-pnlbar-b "; //$NON-NLS-1$
+ private static final String PANEL_BAR_PANEL_BAR_CSS =
"panelBar/panelBar.css"; //$NON-NLS-1$
- private final static String CONTENT_CLASS = "contentClass";
- private final static String CONTENT_STYLE = "contentStyle";
- private final static String HEADER_CLASS = "headerClass";
- private final static String HEADER_STYLE = "headerStyle";
- private final static String HEADER_ACTIVE_CLASS = "headerClassActive";
- private final static String HEADER_ACTIVE_STYLE = "headerStyleActive";
-
-
+ private static Map<Node, String> toggleMap = new HashMap<Node,
String>();
+
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
-
+
Element sourceElement = (Element) sourceNode;
- nsIDOMElement table = visualDocument.createElement("table");
+ nsIDOMElement table = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
VpeCreationData creationData = new VpeCreationData(table);
- ComponentUtil.setCSSLink(pageContext, "panelBar/panelBar.css",
- "richFacesPanelBar");
- String styleClass = sourceElement.getAttribute("styleClass");
- table.setAttribute("class", "dr-pnlbar rich-panelbar dr-pnlbar-b "
- + (styleClass == null ? "" : styleClass));
+ ComponentUtil.setCSSLink(pageContext, PANEL_BAR_PANEL_BAR_CSS,
+ "richFacesPanelBar"); //$NON-NLS-1$
+ String styleClass = sourceElement
+ .getAttribute(HtmlComponentUtil.HTML_STYLECLASS_ATTR);
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ DR_PNLBAR_RICH_PANELBAR_DR_PNLBAR_B
+ + (styleClass == null ? EMPTY : styleClass));
// Set style attribute
- StringBuffer styleValue = new StringBuffer("padding: 0px; ");
- styleValue.append(height(sourceElement)).append(" ").append(
- width(sourceElement)).append(" ").append(
- ComponentUtil.getAttribute(sourceElement, "style"));
+ StringBuffer styleValue = new StringBuffer("padding: 0px; "); //$NON-NLS-1$
+ styleValue.append(height(sourceElement)).append(SPACE).append(
+ width(sourceElement)).append(SPACE).append(
+ ComponentUtil.getAttribute(sourceElement,
+ HtmlComponentUtil.HTML_STYLE_ATTR));
// Encode Body
List<Node> children = ComponentUtil.getChildren(sourceElement);
@@ -69,64 +73,37 @@
HtmlComponentUtil.HTML_STYLE_ATTR);
String contentClass = ComponentUtil.getAttribute(sourceElement,
- CONTENT_CLASS);
+ RichFacesPanelItemTemplate.CONTENT_CLASS);
String contentStyle = ComponentUtil.getAttribute(sourceElement,
- CONTENT_STYLE);
+ RichFacesPanelItemTemplate.CONTENT_STYLE);
String headerClass = ComponentUtil.getAttribute(sourceElement,
- HEADER_CLASS);
+ RichFacesPanelItemTemplate.HEADER_CLASS);
String headerStyle = ComponentUtil.getAttribute(sourceElement,
- HEADER_STYLE);
+ RichFacesPanelItemTemplate.HEADER_STYLE);
String headerActiveStyle = ComponentUtil.getAttribute(sourceElement,
- HEADER_ACTIVE_STYLE);
+ RichFacesPanelItemTemplate.HEADER_ACTIVE_STYLE);
String headerActiveClass = ComponentUtil.getAttribute(sourceElement,
- HEADER_ACTIVE_CLASS);
+ RichFacesPanelItemTemplate.HEADER_ACTIVE_CLASS);
for (Node child : children) {
boolean active = (i == activeId);
- if (child.getNodeName().endsWith(":panelBarItem")) {
+ if (child.getNodeName().endsWith(PANEL_BAR_ITEM)) {
- String internContentClass = ComponentUtil.getAttribute(
- (Element) child, CONTENT_CLASS);
- String internContentStyle = ComponentUtil.getAttribute(
- (Element) child, CONTENT_STYLE);
- String internHeaderClass = ComponentUtil.getAttribute(
- (Element) child, HEADER_CLASS);
- String internHeaderStyle = ComponentUtil.getAttribute(
- (Element) child, HEADER_STYLE);
- String internHeaderActiveStyle = ComponentUtil.getAttribute(
- (Element) child, HEADER_ACTIVE_STYLE);
- String internHeaderActiveClass = ComponentUtil.getAttribute(
- (Element) child, HEADER_ACTIVE_CLASS);
+ RichFacesPanelItemTemplate.encode(creationData, pageContext,
+ (Element) child, visualDocument, table, active,
+ ComponentUtil.getAttribute(sourceElement,
+ HtmlComponentUtil.HTML_STYLECLASS_ATTR), style,
+ headerClass, headerStyle, headerActiveClass,
+ headerActiveStyle, contentClass, contentStyle, String
+ .valueOf(i));
- RichFacesPanelItemTemplate
- .encode(
- creationData,
- (Element) child,
- visualDocument,
- table,
- active,
- ComponentUtil.getAttribute(sourceElement,
- HtmlComponentUtil.HTML_STYLECLASS_ATTR),
- style,
- (internHeaderClass.length() == 0) ? headerClass
- : internHeaderClass,
- (internHeaderStyle.length() == 0) ? headerStyle
- : internHeaderStyle,
- (internHeaderActiveClass.length() == 0) ? headerActiveClass
- : internHeaderActiveClass,
- (internHeaderActiveStyle.length() == 0) ? headerActiveStyle
- : internHeaderActiveStyle,
- (internContentClass.length() == 0) ? contentClass
- : internContentClass,
- (internContentStyle.length() == 0) ? contentStyle
- : internContentStyle, String.valueOf(i));
-
i++;
}
}
- table.setAttribute("style", styleValue.toString());
+ table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, styleValue
+ .toString());
return creationData;
}
@@ -136,12 +113,13 @@
* @return
*/
private String height(Element sourceElement) {
- String height = sourceElement.getAttribute("height");
- if (height == null || height.length() == 0 ) {
-
- height = "100%";
+ String height = sourceElement
+ .getAttribute(HtmlComponentUtil.HTML_HEIGHT_ATTR);
+ if (height == null || height.length() == 0) {
+
+ height = PERCENT_100;
}
- return "height: " + height + ";";
+ return "height: " + height + SEMI_COLON; //$NON-NLS-1$
}
/**
@@ -150,11 +128,12 @@
* @return
*/
public String width(Element sourceElement) {
- String width = sourceElement.getAttribute("width");
+ String width = sourceElement
+ .getAttribute(HtmlComponentUtil.HTML_ATR_WIDTH);
if (width == null || width.length() == 0) {
- width = "100%";
+ width = PERCENT_100;
}
- return "width: " + width + ";";
+ return "width: " + width + SEMI_COLON; //$NON-NLS-1$
}
/**
@@ -205,7 +184,7 @@
private int getChildrenCount(List<Node> children) {
int count = 0;
for (Node child : children) {
- if (child.getNodeName().endsWith(":panelBarItem")) {
+ if (child.getNodeName().endsWith(PANEL_BAR_ITEM)) {
count++;
}
}
@@ -222,5 +201,5 @@
return true;
return false;
}
-
+
}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelItemTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelItemTemplate.java 2008-03-31
13:28:45 UTC (rev 7210)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelItemTemplate.java 2008-03-31
13:48:23 UTC (rev 7211)
@@ -20,13 +20,31 @@
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMText;
+import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class RichFacesPanelItemTemplate extends VpeAbstractTemplate {
- private static final String DEFAULT_LABEL = "auto generated label";
+ public final static String CONTENT_CLASS = "contentClass"; //$NON-NLS-1$
+ public final static String CONTENT_STYLE = "contentStyle"; //$NON-NLS-1$
+ public final static String HEADER_CLASS = "headerClass"; //$NON-NLS-1$
+ public final static String HEADER_STYLE = "headerStyle"; //$NON-NLS-1$
+ public final static String HEADER_ACTIVE_CLASS = "headerClassActive";
//$NON-NLS-1$
+ public final static String HEADER_ACTIVE_STYLE = "headerStyleActive";
//$NON-NLS-1$
+ private static final String PERCENT_100 = "100%"; //$NON-NLS-1$
+ private static final String DR_PNLBAR_H_RICH_PANELBAR_HEADER = "dr-pnlbar-h
rich-panelbar-header "; //$NON-NLS-1$
+ private static final String DR_PNLBAR_RICH_PANELBAR_DR_PNLBAR_EXT = " dr-pnlbar
rich-panelbar dr-pnlbar-ext "; //$NON-NLS-1$
+ private static final String DR_PNLBAR_C_RICH_PANELBAR_CONTENT = "dr-pnlbar-c
rich-panelbar-content "; //$NON-NLS-1$
+ private static final String ZERO = "0"; //$NON-NLS-1$
+ private static final String EMPTY = ""; //$NON-NLS-1$
+ private static final String VPE_USER_TOGGLE_ID = "vpe-user-toggle-id";
//$NON-NLS-1$
+ private static final String LABEL = "label"; //$NON-NLS-1$
+ private static final String DEFAULT_LABEL = "auto generated label";
//$NON-NLS-1$
+ private static final String SPACE = " "; //$NON-NLS-1$
+
/**
*
* @param creationData
@@ -46,12 +64,12 @@
* @return
*/
public static VpeCreationData encode(VpeCreationData creationData,
- Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMElement parentVisualElement, boolean active,
- String barStyleClass, String barStyle, String barHeaderStyleClass,
- String barHeaderStyle, String barHeaderActiveStyleClass,
- String barHeaderActiveStyle, String barContentStyleClass,
- String barContentStyle, String toggleId) {
+ VpePageContext pageContext, Element sourceElement,
+ nsIDOMDocument visualDocument, nsIDOMElement parentVisualElement,
+ boolean active, String barStyleClass, String barStyle,
+ String barHeaderStyleClass, String barHeaderStyle,
+ String barHeaderActiveStyleClass, String barHeaderActiveStyle,
+ String barContentStyleClass, String barContentStyle, String toggleId) {
nsIDOMElement div = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_DIV);
@@ -62,36 +80,45 @@
parentVisualElement.appendChild(div);
}
- div.setAttribute("class", barStyleClass
- + " dr-pnlbar rich-panelbar dr-pnlbar-ext ");
- div.setAttribute("style", barStyle);
- div.setAttribute("vpe-user-toggle-id", toggleId);
+ div.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, barStyleClass
+ + DR_PNLBAR_RICH_PANELBAR_DR_PNLBAR_EXT);
+ div.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, barStyle);
+ div.setAttribute(VPE_USER_TOGGLE_ID, toggleId);
// Encode Header
- String headerActivetStyleClass = "dr-pnlbar-h rich-panelbar-header "
- + barHeaderActiveStyleClass
- + " "
- + ComponentUtil
- .getAttribute(sourceElement, "headerClassActive");
- String headerActivetStyle = barHeaderStyle
- + " "
- + ComponentUtil.getAttribute(sourceElement, "headerStyle")
- + " "
+ String headerActiveStyle = barHeaderStyle
+ + SPACE
+ + ComponentUtil.getAttribute(sourceElement, HEADER_STYLE)
+ + SPACE
+ barHeaderActiveStyle
- + " "
+ + SPACE
+ ComponentUtil
- .getAttribute(sourceElement, "headerStyleActive");
- String headerStyleClass = "dr-pnlbar-h rich-panelbar-header "
- + ComponentUtil.getAttribute(sourceElement, "headerClass")
- + barHeaderStyleClass;
- String headerStyle = barHeaderStyle + " "
- + ComponentUtil.getAttribute(sourceElement, "headerStyle");
+ .getAttribute(sourceElement, HEADER_ACTIVE_STYLE);
+ String headerStyle = barHeaderStyle + SPACE
+ + ComponentUtil.getAttribute(sourceElement, HEADER_STYLE);
+
+ String internContentClass = ComponentUtil.getAttribute(sourceElement,
+ CONTENT_CLASS);
+ String internContentStyle = ComponentUtil.getAttribute(sourceElement,
+ CONTENT_STYLE);
+ String internHeaderClass = ComponentUtil.getAttribute(sourceElement,
+ HEADER_CLASS);
+ String internHeaderActiveClass = ComponentUtil.getAttribute(
+ sourceElement, HEADER_ACTIVE_CLASS);
+
if (active) {
- encodeHeader(creationData, sourceElement, visualDocument, div,
- headerActivetStyleClass, headerActivetStyle, toggleId);
+ String headerClass = DR_PNLBAR_H_RICH_PANELBAR_HEADER + SPACE
+ + barHeaderStyleClass + SPACE + internHeaderClass + SPACE
+ + barHeaderActiveStyleClass + SPACE
+ + internHeaderActiveClass;
+ encodeHeader(creationData, pageContext, sourceElement,
+ visualDocument, div, headerClass, headerActiveStyle,
+ toggleId);
} else {
- encodeHeader(creationData, sourceElement, visualDocument, div,
- headerStyleClass, headerStyle, toggleId);
+ String headerClass = DR_PNLBAR_H_RICH_PANELBAR_HEADER + SPACE
+ + barHeaderStyleClass + SPACE + internHeaderClass;
+ encodeHeader(creationData, pageContext, sourceElement,
+ visualDocument, div, headerClass, headerStyle, toggleId);
}
// Encode Body
@@ -102,8 +129,8 @@
nsIDOMElement td2 = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_TD);
tr2.appendChild(td2);
- tr2.setAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR, "100%");
- tr2.setAttribute(HtmlComponentUtil.HTML_HEIGHT_ATTR, "100%");
+ tr2.setAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR, PERCENT_100);
+ tr2.setAttribute(HtmlComponentUtil.HTML_HEIGHT_ATTR, PERCENT_100);
if (creationData == null) {
creationData = new VpeCreationData(tr2);
} else {
@@ -114,9 +141,12 @@
.createElement(HtmlComponentUtil.HTML_TAG_TABLE);
td2.appendChild(contentTable);
- contentTable.setAttribute("cellpadding", "0");
- contentTable.setAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR, "100%");
- contentTable.setAttribute(HtmlComponentUtil.HTML_HEIGHT_ATTR, "100%");
+ contentTable.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR,
+ ZERO);
+ contentTable.setAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR,
+ PERCENT_100);
+ contentTable.setAttribute(HtmlComponentUtil.HTML_HEIGHT_ATTR,
+ PERCENT_100);
nsIDOMElement tbody = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_TBODY);
@@ -130,14 +160,12 @@
.createElement(HtmlComponentUtil.HTML_TAG_TD);
tr.appendChild(td);
- String tdClass = "dr-pnlbar-c rich-panelbar-content "
- + barContentStyleClass + " "
- + ComponentUtil.getAttribute(sourceElement, "contentClass");
- String tdStyle = barContentStyle + " "
- + ComponentUtil.getAttribute(sourceElement, "contentStyle");
+ String tdClass = DR_PNLBAR_C_RICH_PANELBAR_CONTENT
+ + barContentStyleClass + SPACE + internContentClass;
+ String tdStyle = barContentStyle + SPACE + internContentStyle;
- td.setAttribute("class", tdClass);
- td.setAttribute("style", tdStyle);
+ td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, tdClass);
+ td.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, tdStyle);
List<Node> children = ComponentUtil
.getChildren(sourceElement, true);
@@ -152,8 +180,9 @@
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
- return encode(null, (Element) sourceNode, visualDocument, null, false,
- "", "", "", "", "", "",
"", "", "0");
+ return encode(null, pageContext, (Element) sourceNode, visualDocument,
+ null, false, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
+ EMPTY, ZERO);
}
/**
@@ -166,27 +195,48 @@
* @param toggleId
*/
private static void encodeHeader(VpeCreationData vpeCreationData,
- Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMElement parentDiv, String styleClass, String style,
- String toggleId) {
+ VpePageContext pageContext, Element sourceElement,
+ nsIDOMDocument visualDocument, nsIDOMElement parentDiv,
+ String styleClass, String style, String toggleId) {
nsIDOMElement div = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_DIV);
parentDiv.appendChild(div);
- div.setAttribute("class", styleClass);
- div.setAttribute("style", style);
- div.setAttribute("vpe-user-toggle-id", toggleId);
+ div.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, styleClass);
+ div.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, style);
+ div.setAttribute(VPE_USER_TOGGLE_ID, toggleId);
- String label = sourceElement.getAttribute("label");
- Element facet = ComponentUtil.getFacet(sourceElement, "label");
+ Element facet = ComponentUtil.getFacet(sourceElement, LABEL);
+
if (facet == null) {
- div.appendChild(visualDocument
- .createTextNode((label == null) ? DEFAULT_LABEL : label));
+ Attr attr = null;
+ if (sourceElement.hasAttribute(LABEL)) {
+ attr = sourceElement.getAttributeNode(LABEL);
+ }
+ if (attr != null) {
+ String itemLabel = attr.getNodeValue();
+ String bundleValue = ComponentUtil.getBundleValue(pageContext,
+ attr);
+ nsIDOMText text;
+ // if bundleValue differ from value then will be represent
+ // bundleValue, but text will be not edit
+ if (!itemLabel.equals(bundleValue)) {
+ text = visualDocument.createTextNode(bundleValue);
+
+ } else {
+ text = visualDocument.createTextNode(itemLabel);
+ }
+ div.appendChild(text);
+ } else {
+ div.appendChild(visualDocument.createTextNode(DEFAULT_LABEL));
+ }
+
} else {
VpeChildrenInfo facetInfo = new VpeChildrenInfo(div);
facetInfo.addSourceChild(facet);
vpeCreationData.addChildrenInfo(facetInfo);
}
+
}
}
\ No newline at end of file