Author: dsakovich
Date: 2008-03-27 05:27:47 -0400 (Thu, 27 Mar 2008)
New Revision: 7142
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/HtmlComponentUtil.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-1398
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-26
23:40:06 UTC (rev 7141)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2008-03-27
09:27:47 UTC (rev 7142)
@@ -33,496 +33,548 @@
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) {
- Element element = (Element) node;
- String name = element.getAttribute("name");
- 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;
+ /**
+ * 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;
+ }
+ }
}
- }
- 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())) {
- 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;
- }
+ /**
+ * 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);
+ }
+ }
}
- if (returnTextNode && facets.isEmpty()) {
- facets.add(textNode);
- }
- }
+ return facets;
}
- 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"
- .equalsIgnoreCase(sourceElement.getAttribute("rendered"));
- }
+ /**
+ * 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();
- 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 "
- + 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://"
- + 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"))) {
- children.add(child);
- }
+ /**
+ * 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;
}
- 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"))) {
- children.add(child);
- }
+ /**
+ * 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;
}
- 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;
+ 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
+ }
}
- // 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 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")) {
- String name = ((Element) sourceNode).getAttribute("name");
- if (facetName.equals(name)) {
- return true;
- }
+ /**
+ * Returns Style with default background image for default RichFaces skin.
+ *
+ * @return
+ */
+ public static String getHeaderBackgoundImgStyle() {
+ return getBackgoundImgStyle("common/background.gif"); //$NON-NLS-1$
}
- return false;
- }
- /**
- * Returns Style with default background image for default RichFaces skin.
- *
- * @return
- */
- public static String getHeaderBackgoundImgStyle() {
- return getBackgoundImgStyle("common/background.gif");
- }
+ /**
+ * 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 background image for default RichFaces skin.
- *
- * @return
- */
- public static String getBackgoundImgStyle(String imagePath) {
- String imgPath = ComponentUtil.getAbsoluteResourcePath(imagePath);
- String style = "background-image: url(file:///"
- + imgPath.replace('\\', '/') + ");";
- return style;
- }
+ // public static createStyleClass(String content){
+ //
+ // }
- // 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 = "";
+ /**
+ * 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;
}
- 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 = "";
+ /**
+ * 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;
}
- 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(";");
- for (int i = 0; i < styles.length; i++) {
- String[] pair = styles[i].split(":");
- 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(";");
- for (int i = 0; i < styles.length; i++) {
- String[] pair = styles[i].split(":");
- 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(";") ? "" :
";")
- + 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();
- }
+ /**
+ * 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;
}
- if (inputPath != null && !inputPath.isEmpty()) {
- inputPath = inputPath.removeLastSegments(1);
+
+ /**
+ * 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);
}
- 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;
+ /**
+ * 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;
}
- 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))) {
- return true;
- } else if (("true".equalsIgnoreCase(str))
- || ("false".equalsIgnoreCase(str))) {
- return new Boolean(str).booleanValue();
+ /**
+ * 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);
+ }
+ }
}
- return true;
- }
+ /**
+ * 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;
+ }
+ }
+
}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/HtmlComponentUtil.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/HtmlComponentUtil.java 2008-03-26
23:40:06 UTC (rev 7141)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/HtmlComponentUtil.java 2008-03-27
09:27:47 UTC (rev 7142)
@@ -7,7 +7,7 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.jsf.vpe.richfaces;
/**
@@ -19,158 +19,160 @@
public class HtmlComponentUtil {
/** HTML TAG DL */
- public static final String HTML_TAG_DL = "dl";
-
+ public static final String HTML_TAG_DL = "dl"; //$NON-NLS-1$
+
/** HTML TAG BR */
- public static final String HTML_TAG_BR = "br";
-
+ public static final String HTML_TAG_BR = "br"; //$NON-NLS-1$
+
/** HTML TAG COLGROUP */
- public static final String HTML_TAG_COLGROUP = "colgroup";
-
+ public static final String HTML_TAG_COLGROUP = "colgroup"; //$NON-NLS-1$
+
/** HTML TAG THEAD */
- public static final String HTML_TAG_THEAD = "thead";
-
+ public static final String HTML_TAG_THEAD = "thead"; //$NON-NLS-1$
+
/** HTML TAG TFOOT */
- public static final String HTML_TAG_TFOOT = "tfoot";
-
+ public static final String HTML_TAG_TFOOT = "tfoot"; //$NON-NLS-1$
+
/** HTML TAG CAPTION */
- public static final String HTML_TAG_CAPTION = "caption";
+ public static final String HTML_TAG_CAPTION = "caption"; //$NON-NLS-1$
/** HTML TAG DT */
- public static final String HTML_TAG_DT = "dt";
+ public static final String HTML_TAG_DT = "dt"; //$NON-NLS-1$
/** HTML TAG DD */
- public static final String HTML_TAG_DD = "dd";
+ public static final String HTML_TAG_DD = "dd"; //$NON-NLS-1$
/** HTML_TAG_TABLE * */
- public static final String HTML_TAG_TABLE = "TABLE";
+ public static final String HTML_TAG_TABLE = "TABLE"; //$NON-NLS-1$
/** HTML_TAG_TBODY * */
- public static final String HTML_TAG_TBODY = "TBODY";
-
+ public static final String HTML_TAG_TBODY = "TBODY"; //$NON-NLS-1$
+
/** HTML_TAG_TR * */
- public static final String HTML_TAG_TR = "TR";
+ public static final String HTML_TAG_TR = "TR"; //$NON-NLS-1$
/** HTML_TAG_TD * */
- public static final String HTML_TAG_TD = "TD";
+ public static final String HTML_TAG_TD = "TD"; //$NON-NLS-1$
/** HTML_TAG_TH * */
- public static final String HTML_TAG_TH = "TH";
+ public static final String HTML_TAG_TH = "TH"; //$NON-NLS-1$
/** HTML_TAG_INPUT * */
- public static final String HTML_TAG_INPUT = "INPUT";
+ public static final String HTML_TAG_INPUT = "INPUT"; //$NON-NLS-1$
/** HTML_TAG_IMG * */
- public static final String HTML_TAG_IMG = "IMG";
+ public static final String HTML_TAG_IMG = "IMG"; //$NON-NLS-1$
/** HTML_TAG_DIV */
- public static final String HTML_TAG_DIV = "DIV";
+ public static final String HTML_TAG_DIV = "DIV"; //$NON-NLS-1$
/** HTML_TAG_SPAN */
- public static final String HTML_TAG_SPAN = "SPAN";
+ public static final String HTML_TAG_SPAN = "SPAN"; //$NON-NLS-1$
/** HTML_TAG_A */
- public static final String HTML_TAG_A = "A";
+ public static final String HTML_TAG_A = "A"; //$NON-NLS-1$
/** HTML_TAG_B */
- public static final String HTML_TAG_B = "B";
-
+ public static final String HTML_TAG_B = "B"; //$NON-NLS-1$
+
/** HTML_TAG_LI */
- public static final String HTML_TAG_LI = "LI";
+ public static final String HTML_TAG_LI = "LI"; //$NON-NLS-1$
/** HTML_TABLE_COLSPAN * */
- public static final String HTML_TABLE_COLSPAN = "colspan";
+ public static final String HTML_TABLE_COLSPAN = "colspan"; //$NON-NLS-1$
/** HTML_HEIGHT_ATTR * */
- public static final String HTML_HEIGHT_ATTR = "height";
+ public static final String HTML_HEIGHT_ATTR = "height"; //$NON-NLS-1$
/** HTML_CLASS_ATTR * */
- public static final String HTML_STYLECLASS_ATTR = "styleClass";
+ public static final String HTML_STYLECLASS_ATTR = "styleClass"; //$NON-NLS-1$
/** HTML_CLASS_ATTR * */
- public static final String HTML_CLASS_ATTR = "class";
+ public static final String HTML_CLASS_ATTR = "class"; //$NON-NLS-1$
/** HTML_CELLSPACING_ATTR * */
- public static final String HTML_CELLSPACING_ATTR = "cellspacing";
+ public static final String HTML_CELLSPACING_ATTR = "cellspacing";
//$NON-NLS-1$
/** HTML_CELLPADDING_ATTR * */
- public static final String HTML_CELLPADDING_ATTR = "cellpadding";
+ public static final String HTML_CELLPADDING_ATTR = "cellpadding";
//$NON-NLS-1$
/** HTML_ALIGN_LEFT_VALUE * */
- public static final String HTML_ALIGN_LEFT_VALUE = "left";
-
+ public static final String HTML_ALIGN_LEFT_VALUE = "left"; //$NON-NLS-1$
+
/** HTML_ALIGN_RIGHT_VALUE * */
- public static final String HTML_ALIGN_RIGHT_VALUE = "right";
+ public static final String HTML_ALIGN_RIGHT_VALUE = "right"; //$NON-NLS-1$
/** HTML_ALIGN_CENTER_VALUE * */
- public static final String HTML_ALIGN_CENTER_VALUE = "center";
-
+ public static final String HTML_ALIGN_CENTER_VALUE = "center"; //$NON-NLS-1$
+
/** HTML_ATR_WIDTH */
- public static final String HTML_ATR_WIDTH = "width";
+ public static final String HTML_ATR_WIDTH = "width"; //$NON-NLS-1$
/** HTML_ATR_WIDTH */
- public static final String HTML_ATR_HEIGHT = "height";
+ public static final String HTML_ATR_HEIGHT = "height"; //$NON-NLS-1$
/** HTML_ATR_src */
- public static final String HTML_ATR_SRC = "src";
+ public static final String HTML_ATR_SRC = "src"; //$NON-NLS-1$
/** style */
- public static final String HTML_STYLE_ATTR = "style";
-
+ public static final String HTML_STYLE_ATTR = "style"; //$NON-NLS-1$
+
/** scope */
- public static final String HTML_SCOPE_ATTR = "scope";
+ public static final String HTML_SCOPE_ATTR = "scope"; //$NON-NLS-1$
/** HTML_TABLE_ATR_ */
- public static final String HTML_BORDER_ATTR = "border";
+ public static final String HTML_BORDER_ATTR = "border"; //$NON-NLS-1$
/** HTML_ALIGN_ATR */
- public static final String HTML_ALIGN_ATTR = "align";
+ public static final String HTML_ALIGN_ATTR = "align"; //$NON-NLS-1$
/** HTML_TABLE_ATR_ */
- public static final String FILE_PROTOCOL = "file://";
-
+ public static final String FILE_PROTOCOL = "file://"; //$NON-NLS-1$
+
/** HTML_COLSPAN_ATTR * */
- public static final String HTML_COLSPAN_ATTR = "colspan";
-
+ public static final String HTML_COLSPAN_ATTR = "colspan"; //$NON-NLS-1$
+
/** HTML_ROWSPAN_ATTR * */
- public static final String HTML_ROWSPAN_ATTR = "rowspan";
+ public static final String HTML_ROWSPAN_ATTR = "rowspan"; //$NON-NLS-1$
/** HTML_ROW_ATTR * */
- public static final String HTML_ROW_ATTR = "row";
-
+ public static final String HTML_ROW_ATTR = "row"; //$NON-NLS-1$
+
/** HTML_SIZE_ATTR * */
- public static final String HTML_SIZE_ATTR = "size";
-
+ public static final String HTML_SIZE_ATTR = "size"; //$NON-NLS-1$
+
/** HTML_TYPE_ATTR * */
- public static final String HTML_TYPE_ATTR = "type";
-
+ public static final String HTML_TYPE_ATTR = "type"; //$NON-NLS-1$
+
/** HTML_READONLY_ATTR * */
- public static final String HTML_READONLY_ATTR = "readonly";
-
+ public static final String HTML_READONLY_ATTR = "readonly"; //$NON-NLS-1$
+
/** HTML_TAG_BUTTON * */
- public static final String HTML_TAG_BUTTON = "button";
-
+ public static final String HTML_TAG_BUTTON = "button"; //$NON-NLS-1$
+
/** HTML_VALUE_ATTR * */
- public static final String HTML_VALUE_ATTR = "value";
-
+ public static final String HTML_VALUE_ATTR = "value"; //$NON-NLS-1$
+
/** CSS_BORDER_WIDTH */
- public static final String CSS_BORDER_WIDTH = "border-width";
-
+ public static final String CSS_BORDER_WIDTH = "border-width"; //$NON-NLS-1$
+
/** CSS_BORDER_STYLE */
- public static final String CSS_BORDER_STYLE = "border-style";
-
- /** HTML_WIDTH_ATTR * */
- public static final String HTML_WIDTH_ATTR = "width";
-
- /** HTML_ATTR_VALIGN */
- public static final String HTML_ATTR_VALIGN = "valign";
-
- /** HTML_ATTR_VALIGN_MIDDLE_VALUE */
- public static final String HTML_ATTR_VALIGN_MIDDLE_VALUE = "middle";
+ public static final String CSS_BORDER_STYLE = "border-style"; //$NON-NLS-1$
- /** HTML_ATTR_BACKGROUND */
- public static final String HTML_ATTR_BACKGROUND = "background";
+ public static final String CSS_DISPLAY = "display"; //$NON-NLS-1$
- /** HTML_ATTR_BACKGROUND */
- public static final String HTML_ATTR_DISABLED = "disabled";
+ /** HTML_WIDTH_ATTR * */
+ public static final String HTML_WIDTH_ATTR = "width"; //$NON-NLS-1$
+
+ /** HTML_ATTR_VALIGN */
+ public static final String HTML_ATTR_VALIGN = "valign"; //$NON-NLS-1$
+
+ /** HTML_ATTR_VALIGN_MIDDLE_VALUE */
+ public static final String HTML_ATTR_VALIGN_MIDDLE_VALUE = "middle";
//$NON-NLS-1$
+
+ /** HTML_ATTR_BACKGROUND */
+ public static final String HTML_ATTR_BACKGROUND = "background"; //$NON-NLS-1$
+
+ /** HTML_ATTR_BACKGROUND */
+ public static final String HTML_ATTR_DISABLED = "disabled"; //$NON-NLS-1$
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java 2008-03-26
23:40:06 UTC (rev 7141)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java 2008-03-27
09:27:47 UTC (rev 7142)
@@ -20,6 +20,7 @@
import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
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.template.VpeToggableTemplate;
import org.mozilla.interfaces.nsIDOMDocument;
@@ -44,6 +45,8 @@
private static final String RICH_FACES_TAB_PANEL = "richFacesTabPanel";
//$NON-NLS-1$
private static final String CSS_FILE_PATH = "tabPanel/tabPanel.css";
//$NON-NLS-1$
private static final String SPACER_FILE_PATH = "common/spacer.gif";
//$NON-NLS-1$
+ private static final String INCLUDE_TAG = ":include"; //$NON-NLS-1$
+ private static final String YES = "yes"; //$NON-NLS-1$
private final String HEADER_ALINGMENT = "headerAlignment"; //$NON-NLS-1$
private final String HEADER_SPACING = "headerSpacing"; //$NON-NLS-1$
@@ -123,8 +126,14 @@
int i = 0;
for (Node child : children) {
boolean active = (i == activeId);
+
+ if (child.getNodeName().endsWith(INCLUDE_TAG)) {
+ VpeChildrenInfo vpeChildrenInfo = new VpeChildrenInfo(inerTr);
+ creationData.addChildrenInfo(vpeChildrenInfo);
+ vpeChildrenInfo.addSourceChild(child);
+ }
+
if(child.getNodeName().endsWith(TAB)) {
-
/*
* Adds spacer before first tab
*/
@@ -345,6 +354,22 @@
*/
public void validate(VpePageContext pageContext, Node sourceNode, nsIDOMDocument
visualDocument, VpeCreationData data) {
+ List<nsIDOMNode> elements = new ArrayList<nsIDOMNode>();
+ ComponentUtil.findAllElementsByName(data.getNode(), elements,
HtmlComponentUtil.HTML_TAG_TABLE);
+ for (nsIDOMNode node : elements) {
+ try {
+ nsIDOMElement element = (nsIDOMElement)
node.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ if (ComponentUtil.getAttribute(element,
RichFacesTabTemplate.TAB_HEADER_ATTR).equalsIgnoreCase(YES)) {
+ element.removeAttribute(HtmlComponentUtil.HTML_STYLE_ATTR);
+ }
+ if (ComponentUtil.getAttribute(element,
RichFacesTabTemplate.TAB_BODY_ATTR).equalsIgnoreCase(YES)) {
+ element.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
HtmlComponentUtil.CSS_DISPLAY+" :
"+RichFacesTabTemplate.DISABLED_ELEMENT_STYLE+";");
//$NON-NLS-1$//$NON-NLS-2$
+ }
+ } catch (XPCOMException exeption) {
+ // Ignore
+ }
+ }
+
super.validate(pageContext, sourceNode, visualDocument, data);
if ((storedTabHeaders == null) || (storedTabHeaders.size() < 1)){
return;
@@ -353,7 +378,9 @@
for (nsIDOMElement tab : storedTabHeaders) {
String value = tab.getAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID);
applyAttributeValueOnChildren(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, value,
getChildren(tab));
- applyAttributeValueOnChildren(VpeVisualDomBuilder.VPE_USER_TOGGLE_LOOKUP_PARENT,
"true", getChildren(tab));
+ applyAttributeValueOnChildren(
+ VpeVisualDomBuilder.VPE_USER_TOGGLE_LOOKUP_PARENT,
+ "true", getChildren(tab)); //$NON-NLS-1$
}
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java 2008-03-26
23:40:06 UTC (rev 7141)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java 2008-03-27
09:27:47 UTC (rev 7142)
@@ -25,6 +25,11 @@
public class RichFacesTabTemplate extends VpeAbstractTemplate {
+ public static final String TAB_HEADER_ATTR = "tabheaderattr"; //$NON-NLS-1$
+ public static final String YES = "yes"; //$NON-NLS-1$
+ public static final String DISABLED_ELEMENT_STYLE = "none"; //$NON-NLS-1$
+ public static final String TAB_BODY_ATTR = "tabbodyattr"; //$NON-NLS-1$
+
private final static String SPACER_FILE_PATH = "common/spacer.gif";
//$NON-NLS-1$
private final static String ACTIVE_BKG_FILE_PATH =
"tabPanel/activeBackground.gif"; //$NON-NLS-1$
private final static String INACTIVE_BKG_FILE_PATH =
"tabPanel/inactiveBackground.gif"; //$NON-NLS-1$
@@ -52,6 +57,7 @@
private static final String WIDTH_STYLE_NAME = "width: "; //$NON-NLS-1$
private static final String STYLE_SEMICOLUMN = "; "; //$NON-NLS-1$
+
/**
* Encode body of tab
* @param creationData
@@ -95,11 +101,11 @@
nsIDOMElement table = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TABLE);
td.appendChild(table);
table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
- table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, "10");
+ table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, "10");
//$NON-NLS-1$
table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO);
table.setAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR, HUNDRED_PERCENTS);
- table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-tbpnl-cntnt-pstn" +
SPACE + RichFacesTabPanelTemplate.CSS_CONTENT_POSITION);
- table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "position: relative;
z-index: 1;");
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-tbpnl-cntnt-pstn" +
SPACE + RichFacesTabPanelTemplate.CSS_CONTENT_POSITION); //$NON-NLS-1$
+ table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "position: relative;
z-index: 1;"); //$NON-NLS-1$
nsIDOMElement tr = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR);
table.appendChild(tr);
@@ -107,7 +113,7 @@
tr.appendChild(td);
td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
ComponentUtil.getAttribute(sourceElement, HtmlComponentUtil.HTML_STYLECLASS_ATTR)
- + SPACE + "dr-tbpnl-cntnt"
+ + SPACE + "dr-tbpnl-cntnt" //$NON-NLS-1$
+ SPACE + contentClass);
td.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
ComponentUtil.getAttribute(sourceElement, HtmlComponentUtil.HTML_STYLE_ATTR)
@@ -124,7 +130,29 @@
}
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
- return encodeBody(null, (Element)sourceNode, visualDocument, null, true, EMPTY, EMPTY,
EMPTY, EMPTY, EMPTY, EMPTY);
+ nsIDOMElement table = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ //table.setAttribute("include-tab", "");
+ VpeCreationData creationData = new VpeCreationData(table);
+ nsIDOMElement headerTable =
visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ headerTable.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
+ headerTable.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, ZERO);
+ headerTable.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO);
+ headerTable.setAttribute(TAB_HEADER_ATTR, YES);
+ headerTable.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ HtmlComponentUtil.CSS_DISPLAY
+ + ":" + DISABLED_ELEMENT_STYLE + STYLE_SEMICOLUMN); //$NON-NLS-1$
+ headerTable.appendChild(encodeHeader(creationData, (Element)sourceNode, visualDocument,
table, false, EMPTY, EMPTY, EMPTY, EMPTY,EMPTY));
+ nsIDOMElement bodyTable =
visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ bodyTable.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
+ bodyTable.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, ZERO);
+ bodyTable.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO);
+ bodyTable.setAttribute(TAB_BODY_ATTR, YES);
+ //bodyTable.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
HtmlComponentUtil.CSS_DISPLAY+" : "+DISABLED_ELEMENT_STYLE+";");
//$NON-NLS-1$ //$NON-NLS-2$
+ table.appendChild(headerTable);
+ table.appendChild(bodyTable);
+ encodeBody(creationData, (Element)sourceNode, visualDocument, bodyTable, true, EMPTY,
EMPTY, EMPTY, EMPTY, EMPTY, EMPTY);
+ return creationData;
+
}
/**
@@ -150,14 +178,14 @@
nsIDOMElement headerTd = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
parentTr.appendChild(headerTd);
- headerTd.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "height: 100%;
vertical-align: bottom;");
- String styleClass = "dr-tbpnl-tbcell-dsbl rich-tabhdr-cell-dsbl";
- if(!"true".equalsIgnoreCase(sourceElement.getAttribute(DISABLED))) {
+ headerTd.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "height: 100%;
vertical-align: bottom;"); //$NON-NLS-1$
+ String styleClass = "dr-tbpnl-tbcell-dsbl rich-tabhdr-cell-dsbl";
//$NON-NLS-1$
+ if(!"true".equalsIgnoreCase(sourceElement.getAttribute(DISABLED))) {
//$NON-NLS-1$
if(active) {
- styleClass = "dr-tbpnl-tbcell-act"
+ styleClass = "dr-tbpnl-tbcell-act" //$NON-NLS-1$
+ SPACE + RichFacesTabPanelTemplate.CSS_CELL_ACTIVE;
} else {
- styleClass = "dr-tbpnl-tbcell-inact"
+ styleClass = "dr-tbpnl-tbcell-inact" //$NON-NLS-1$
+ SPACE + RichFacesTabPanelTemplate.CSS_CELL_INACTIVE;
}
}
@@ -170,7 +198,7 @@
table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, ZERO);
table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO);
- table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "height : 100%; position :
relative; z-index : 2;");
+ table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "height : 100%; position :
relative; z-index : 2;"); //$NON-NLS-1$
table.setAttribute(VPE_USER_TOGGLE_ID, toggleId);
nsIDOMElement mainTr = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR);
@@ -196,7 +224,7 @@
*/
}
if (val > 0) {
- labelWidth = val + "px";
+ labelWidth = val + "px"; //$NON-NLS-1$
}
} else {
labelWidth = HUNDRED_PERCENTS;
@@ -213,23 +241,23 @@
mainTd = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
tr.appendChild(mainTd);
- styleClass = "dr-tbpnl-tb dr-tbpnl-tb-dsbl"
+ styleClass = "dr-tbpnl-tb dr-tbpnl-tb-dsbl" //$NON-NLS-1$
+ SPACE + CSS_HEADER
+ SPACE + CSS_LABEL
+ SPACE + CSS_DISABLED
+ SPACE + disabledTabClass;
String bgImgPath = ComponentUtil.getAbsoluteResourcePath(INACTIVE_BKG_FILE_PATH);
- if(!"true".equalsIgnoreCase(sourceElement.getAttribute(DISABLED))) {
+ if(!"true".equalsIgnoreCase(sourceElement.getAttribute(DISABLED))) {
//$NON-NLS-1$
if(active) {
- styleClass = "dr-tbpnl-tb dr-tbpnl-tb-act"
+ styleClass = "dr-tbpnl-tb dr-tbpnl-tb-act" //$NON-NLS-1$
+ SPACE + CSS_HEADER
+ SPACE + CSS_LABEL
+ SPACE + CSS_ACTIVE
+ SPACE + activeTabClass;
bgImgPath = ComponentUtil.getAbsoluteResourcePath(ACTIVE_BKG_FILE_PATH);
} else {
- styleClass = "dr-tbpnl-tb dr-tbpnl-tb-inact"
+ styleClass = "dr-tbpnl-tb dr-tbpnl-tb-inact" //$NON-NLS-1$
+ SPACE + CSS_HEADER
+ SPACE + CSS_LABEL
+ SPACE + CSS_INACTIVE
@@ -237,11 +265,11 @@
}
}
- styleClass += SPACE + "dr-tbpnl-tbtopbrdr" + SPACE
+ styleClass += SPACE + "dr-tbpnl-tbtopbrdr" + SPACE //$NON-NLS-1$
+ RichFacesTabPanelTemplate.CSS_SIDE_CELL;
mainTd.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, styleClass);
- String style = "background-image: url(file:///"
- + bgImgPath.replace('\\', '/') + ");";
+ String style = "background-image: url(file:///" //$NON-NLS-1$
+ + bgImgPath.replace('\\', '/') + ");"; //$NON-NLS-1$
mainTd.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, style);
@@ -269,10 +297,10 @@
private static void encodeSpacer(nsIDOMElement parentTr, nsIDOMDocument visualDocument)
{
nsIDOMElement td = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
parentTr.appendChild(td);
- td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-tbpnl-tbbrdr"
+ td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-tbpnl-tbbrdr"
//$NON-NLS-1$
+ SPACE + RichFacesTabPanelTemplate.CSS_SIDE_BORDER);
String borderImgPath = ComponentUtil.getAbsoluteResourcePath(BORDER_FILE_PATH);
- String style = "background-image: url(file:///" +
borderImgPath.replace('\\', '/') + ");";
+ String style = "background-image: url(file:///" +
borderImgPath.replace('\\', '/') + ");"; //$NON-NLS-1$
//$NON-NLS-2$
td.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, style);
nsIDOMElement img = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_IMG);
td.appendChild(img);