Author: dsakovich
Date: 2008-02-21 08:23:32 -0500 (Thu, 21 Feb 2008)
New Revision: 6497
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelBar/background.gif
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelBar/panelBar.css
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
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1713
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelBar/background.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelBar/background.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelBar/panelBar.css
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelBar/panelBar.css 2008-02-21
13:07:03 UTC (rev 6496)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/panelBar/panelBar.css 2008-02-21
13:23:32 UTC (rev 6497)
@@ -16,6 +16,9 @@
vertical-align: middle;
color: #000000;
background-color: #D4CFC7;
+ background-image: url(background.gif);
+ background-position : left top;
+ background-repeat: repeat-x;
font-size: 11px;
font-weight: bold;
font-family: Arial, Verdana, sans-serif;
@@ -25,6 +28,8 @@
border: 0px solid red;
padding: 0px 1px 1px 5px;
cursor: pointer;
+ background-color: #D4CFC7;
+ background-image: url(background.gif);
background-position: top left;
background-repeat: repeat-x;
vertical-align: middle;
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-02-21
13:07:03 UTC (rev 6496)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2008-02-21
13:23:32 UTC (rev 6497)
@@ -12,7 +12,6 @@
import java.io.File;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IFile;
@@ -34,478 +33,496 @@
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;
- }
- }
- 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) {
+ 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;
}
+ }
+ 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;
- }
- }
- 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())) {
+ 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"
- .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"
+ .equalsIgnoreCase(sourceElement.getAttribute("rendered"));
+ }
- /**
- * 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();
+ 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 "
+ + 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://"
+ + 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);
- }
- }
- 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"))) {
+ 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"))) {
- 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"))) {
+ 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")) {
- String name = ((Element) sourceNode).getAttribute("name");
- 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");
+ /**
+ * 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;
+ }
}
+ 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:///"
- + imgPath.replace('\\', '/') + ");";
- return style;
+ /**
+ * 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:///"
+ + imgPath.replace('\\', '/') + ");";
+ return style;
+ }
+
+ // 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 = "";
}
-
-// public static createStyleClass(String content){
-//
-// }
+ return 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 = "";
- }
- 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 = "";
}
+ 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 = "";
+ /**
+ * @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;
}
- return attribute;
+ }
}
+ return false;
+ }
- /**
- * @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 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();
}
- return false;
+ }
}
+ 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(";") ? "" :
";")
+ + 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;
- }
- 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;
}
+ 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();
- }
- 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))) {
+ return true;
+ } else if (("true".equalsIgnoreCase(str))
+ || ("false".equalsIgnoreCase(str))) {
+ return new Boolean(str).booleanValue();
}
+ return true;
+ }
}
\ 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-02-21
13:07:03 UTC (rev 6496)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelBarTemplate.java 2008-02-21
13:23:32 UTC (rev 6497)
@@ -32,19 +32,26 @@
private static Map toggleMap = new HashMap();
+ 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";
+
+
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
-
+
Element sourceElement = (Element) sourceNode;
+ nsIDOMElement table = visualDocument.createElement("table");
- nsIDOMElement div = visualDocument.createElement("table");
+ VpeCreationData creationData = new VpeCreationData(table);
- VpeCreationData creationData = new VpeCreationData(div);
-
ComponentUtil.setCSSLink(pageContext, "panelBar/panelBar.css",
"richFacesPanelBar");
String styleClass = sourceElement.getAttribute("styleClass");
- div.setAttribute("class", "dr-pnlbar rich-panelbar dr-pnlbar-b "
+ table.setAttribute("class", "dr-pnlbar rich-panelbar dr-pnlbar-b "
+ (styleClass == null ? "" : styleClass));
// Set style attribute
@@ -57,30 +64,69 @@
List<Node> children = ComponentUtil.getChildren(sourceElement);
int activeId = getActiveId(sourceElement, children);
int i = 0;
+
+ String style = ComponentUtil.getAttribute(sourceElement,
+ HtmlComponentUtil.HTML_STYLE_ATTR);
+
+ String contentClass = ComponentUtil.getAttribute(sourceElement,
+ CONTENT_CLASS);
+ String contentStyle = ComponentUtil.getAttribute(sourceElement,
+ CONTENT_STYLE);
+ String headerClass = ComponentUtil.getAttribute(sourceElement,
+ HEADER_CLASS);
+ String headerStyle = ComponentUtil.getAttribute(sourceElement,
+ HEADER_STYLE);
+ String headerActiveStyle = ComponentUtil.getAttribute(sourceElement,
+ HEADER_ACTIVE_STYLE);
+ String headerActiveClass = ComponentUtil.getAttribute(sourceElement,
+ HEADER_ACTIVE_CLASS);
+
for (Node child : children) {
boolean active = (i == activeId);
if (child.getNodeName().endsWith(":panelBarItem")) {
- RichFacesPanelItemTemplate.encode(creationData,
- (Element) child, visualDocument, div, active,
- ComponentUtil.getAttribute((Element) child,
- "styleClass"), ComponentUtil.getAttribute(
- (Element) child, "style"), ComponentUtil
- .getAttribute((Element) child, "headerClass"),
- ComponentUtil.getAttribute((Element) child,
- "headerStyle"), ComponentUtil.getAttribute(
- (Element) child, "headerClassActive"),
- ComponentUtil.getAttribute((Element) child,
- "headerStyleActive"), ComponentUtil
- .getAttribute((Element) child, "contentClass"),
- ComponentUtil.getAttribute((Element) child,
- "contentStyle"), String.valueOf(i));
+ 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,
+ (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++;
}
}
- div.setAttribute("style", styleValue.toString());
+ table.setAttribute("style", styleValue.toString());
return creationData;
}
@@ -91,7 +137,8 @@
*/
private String height(Element sourceElement) {
String height = sourceElement.getAttribute("height");
- if (height == null || height.length() == 0 || height.equals("100%")) {
+ if (height == null || height.length() == 0 ) {
+
height = "100%";
}
return "height: " + height + ";";
@@ -175,4 +222,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-02-21
13:07:03 UTC (rev 6496)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelItemTemplate.java 2008-02-21
13:23:32 UTC (rev 6497)
@@ -25,6 +25,8 @@
public class RichFacesPanelItemTemplate extends VpeAbstractTemplate {
+ private static final String DEFAULT_LABEL = "auto generated label";
+
/**
*
* @param creationData
@@ -60,13 +62,13 @@
parentVisualElement.appendChild(div);
}
- div.setAttribute("class", "dr-pnlbar rich-panelbar dr-pnlbar-ext "
- + barStyleClass);
+ div.setAttribute("class", barStyleClass
+ + " dr-pnlbar rich-panelbar dr-pnlbar-ext ");
div.setAttribute("style", barStyle);
div.setAttribute("vpe-user-toggle-id", toggleId);
// Encode Header
- String headerActivetStyleClass = "dr-pnlbar-h-act rich-panelbar-header-act "
+ String headerActivetStyleClass = "dr-pnlbar-h rich-panelbar-header "
+ barHeaderActiveStyleClass
+ " "
+ ComponentUtil
@@ -78,20 +80,18 @@
+ barHeaderActiveStyle
+ " "
+ ComponentUtil
- .getAttribute(sourceElement, "headerStyleActive") + " "
- + ComponentUtil.getHeaderBackgoundImgStyle();
+ .getAttribute(sourceElement, "headerStyleActive");
String headerStyleClass = "dr-pnlbar-h rich-panelbar-header "
- + barHeaderStyleClass + " "
- + ComponentUtil.getAttribute(sourceElement, "headerClass");
+ + ComponentUtil.getAttribute(sourceElement, "headerClass")
+ + barHeaderStyleClass;
String headerStyle = barHeaderStyle + " "
- + ComponentUtil.getAttribute(sourceElement, "headerStyle")
- + " " + ComponentUtil.getHeaderBackgoundImgStyle();
+ + ComponentUtil.getAttribute(sourceElement, "headerStyle");
if (active) {
- encodeHeader(sourceElement, visualDocument, div,
+ encodeHeader(creationData, sourceElement, visualDocument, div,
headerActivetStyleClass, headerActivetStyle, toggleId);
} else {
- encodeHeader(sourceElement, visualDocument, div, headerStyleClass,
- headerStyle, toggleId);
+ encodeHeader(creationData, sourceElement, visualDocument, div,
+ headerStyleClass, headerStyle, toggleId);
}
// Encode Body
@@ -110,16 +110,17 @@
parentVisualElement.appendChild(tr2);
}
- nsIDOMElement table = visualDocument
+ nsIDOMElement contentTable = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_TABLE);
- td2.appendChild(table);
- table.setAttribute("cellpadding", "0");
- table.setAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR, "100%");
- table.setAttribute(HtmlComponentUtil.HTML_HEIGHT_ATTR, "100%");
+ td2.appendChild(contentTable);
+ contentTable.setAttribute("cellpadding", "0");
+ contentTable.setAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR, "100%");
+ contentTable.setAttribute(HtmlComponentUtil.HTML_HEIGHT_ATTR, "100%");
+
nsIDOMElement tbody = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_TBODY);
- table.appendChild(tbody);
+ contentTable.appendChild(tbody);
nsIDOMElement tr = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_TR);
@@ -164,9 +165,10 @@
* @param style
* @param toggleId
*/
- private static void encodeHeader(Element sourceElement,
- nsIDOMDocument visualDocument, nsIDOMElement parentDiv,
- String styleClass, String style, String toggleId) {
+ private static void encodeHeader(VpeCreationData vpeCreationData,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement parentDiv, String styleClass, String style,
+ String toggleId) {
nsIDOMElement div = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_DIV);
@@ -176,9 +178,15 @@
div.setAttribute("vpe-user-toggle-id", toggleId);
String label = sourceElement.getAttribute("label");
- if (label != null) {
- div.appendChild(visualDocument.createTextNode(label));
+ Element facet = ComponentUtil.getFacet(sourceElement, "label");
+ if (facet == null) {
+ div.appendChild(visualDocument
+ .createTextNode((label == null) ? DEFAULT_LABEL : label));
+ } else {
+ VpeChildrenInfo facetInfo = new VpeChildrenInfo(div);
+ facetInfo.addSourceChild(facet);
+ vpeCreationData.addChildrenInfo(facetInfo);
}
+ }
- }
}
\ No newline at end of file
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-02-21
13:07:03 UTC (rev 6496)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-02-21
13:23:32 UTC (rev 6497)
@@ -16,10 +16,10 @@
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Collection;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -34,7 +34,7 @@
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.xml.core.internal.document.ElementImpl;
import org.eclipse.wst.xml.core.internal.document.NodeImpl;
@@ -57,7 +57,7 @@
import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
-import org.jboss.tools.vpe.editor.template.VpeCreatorUtil;
+import org.jboss.tools.vpe.editor.template.VpeCreatorUtil;
import org.jboss.tools.vpe.editor.template.VpeDefaultPseudoContentCreator;
import org.jboss.tools.vpe.editor.template.VpeTagDescription;
import org.jboss.tools.vpe.editor.template.VpeTemplate;
@@ -86,7 +86,8 @@
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocument;
+
public class VpeVisualDomBuilder extends VpeDomBuilder {
/** REGEX_EL */
private static final Pattern REGEX_EL = Pattern.compile(
@@ -113,8 +114,8 @@
private VpeDnD dnd;
private nsIDOMNode headNode;
private List includeStack;
- //TODO Max Areshkau JBIDE-1457
-// boolean rebuildFlag = false;
+ // TODO Max Areshkau JBIDE-1457
+ // boolean rebuildFlag = false;
/** faceletFile */
private boolean faceletFile = false;
@@ -158,9 +159,9 @@
unborderedVisualNodes.add(HTML.TAG_BR);
}
private VpeDnd dropper;
-
- private Map<IFile,Document> includeDocuments = new HashMap<IFile,
Document>();
+ private Map<IFile, Document> includeDocuments = new HashMap<IFile,
Document>();
+
public VpeVisualDomBuilder(VpeDomMapping domMapping,
INodeAdapter sorceAdapter, VpeTemplateManager templateManager,
MozillaEditor visualEditor, VpePageContext pageContext) {
@@ -184,11 +185,11 @@
}
public void buildDom(Document sourceDocument) {
- VpeSourceDomBuilder sourceBuilder = pageContext.getSourceBuilder();
- IDocument document = sourceBuilder.getStructuredTextViewer()
- .getDocument();
- if (document == null)
- return;
+ VpeSourceDomBuilder sourceBuilder = pageContext.getSourceBuilder();
+ IDocument document = sourceBuilder.getStructuredTextViewer()
+ .getDocument();
+ if (document == null)
+ return;
includeStack = new ArrayList();
IEditorInput input = pageContext.getEditPart().getEditorInput();
if (input instanceof IFileEditorInput) {
@@ -205,11 +206,11 @@
}
public void rebuildDom(Document sourceDocument) {
- //clearIncludeDocuments();
+ // clearIncludeDocuments();
cleanHead();
domMapping.clear(visualContentArea);
- super.dispose();
-
+ super.dispose();
+
pageContext.clearAll();
refreshExternalLinks();
pageContext.getBundle().refreshRegisteredBundles();
@@ -372,22 +373,24 @@
boolean registerFlag = isCurrentMainDocument();
switch (sourceNode.getNodeType()) {
case Node.ELEMENT_NODE:
-// Map<?, ?> xmlnsMap = createXmlns((Element) sourceNode);
+ // Map<?, ?> xmlnsMap = createXmlns((Element) sourceNode);
Set<Node> ifDependencySet = new HashSet<Node>();
- pageContext.setCurrentVisualNode(visualOldContainer);
+ pageContext.setCurrentVisualNode(visualOldContainer);
VpeTemplate template = templateManager.getTemplate(pageContext,
(Element) sourceNode, ifDependencySet);
VpeCreationData creationData = null;
- //FIX FOR JBIDE-1568, added by Max Areshkau
- try {
- creationData = template.create(getPageContext(), sourceNode, getVisualDocument());
- }catch (XPCOMException ex) {
- VpePlugin.getPluginLog().logError(ex);
- VpeTemplate defTemplate = templateManager.getDefTemplate();
- creationData = defTemplate.create(getPageContext(), sourceNode,
getVisualDocument());
- }
- pageContext.setCurrentVisualNode(null);
+ // FIX FOR JBIDE-1568, added by Max Areshkau
+ try {
+ creationData = template.create(getPageContext(), sourceNode,
+ getVisualDocument());
+ } catch (XPCOMException ex) {
+ VpePlugin.getPluginLog().logError(ex);
+ VpeTemplate defTemplate = templateManager.getDefTemplate();
+ creationData = defTemplate.create(getPageContext(), sourceNode,
+ getVisualDocument());
+ }
+ pageContext.setCurrentVisualNode(null);
nsIDOMElement visualNewElement = (nsIDOMElement) creationData
.getNode();
@@ -413,7 +416,7 @@
VpeElementMapping elementMapping = new VpeElementMapping(
(Element) sourceNode, visualNewElement, border,
template, ifDependencySet, creationData.getData());
-// elementMapping.setXmlnsMap(xmlnsMap);
+ // elementMapping.setXmlnsMap(xmlnsMap);
registerNodes(elementMapping);
}
if (template.isChildren()) {
@@ -427,10 +430,10 @@
childrenInfoList);
}
}
- pageContext.setCurrentVisualNode(visualOldContainer);
+ pageContext.setCurrentVisualNode(visualOldContainer);
template.validate(pageContext, (Element) sourceNode,
visualDocument, creationData);
- pageContext.setCurrentVisualNode(null);
+ pageContext.setCurrentVisualNode(null);
if (border != null)
return border;
else
@@ -809,10 +812,10 @@
}
}
nsIDOMNode visualOldNode = domMapping.remove(sourceNode);
- getSourceNodes().remove(sourceNode);
- if (sourceNode instanceof INodeNotifier) {
- ((INodeNotifier) sourceNode).removeAdapter(getSorceAdapter());
- }
+ getSourceNodes().remove(sourceNode);
+ if (sourceNode instanceof INodeNotifier) {
+ ((INodeNotifier) sourceNode).removeAdapter(getSorceAdapter());
+ }
if (visualOldNode != null) {
if (elementMapping != null) {
nsIDOMElement border = elementMapping.getBorder();
@@ -827,8 +830,9 @@
addNode(sourceNode, visualNextNode, visualContainer);
}
} else {
- //Max Areshkau Why we need update parent node when we update text node?
- //lookd like we haven't need do it.
+ // Max Areshkau Why we need update parent node when we update text
+ // node?
+ // lookd like we haven't need do it.
if (sourceNode.getNodeType() == Node.TEXT_NODE) {
updateNode(sourceNode.getParentNode());
}
@@ -837,10 +841,10 @@
public void removeNode(Node sourceNode) {
domMapping.remove(sourceNode);
- getSourceNodes().remove(sourceNode);
- if (sourceNode instanceof INodeNotifier) {
- ((INodeNotifier) sourceNode).removeAdapter(getSorceAdapter());
- }
+ getSourceNodes().remove(sourceNode);
+ if (sourceNode instanceof INodeNotifier) {
+ ((INodeNotifier) sourceNode).removeAdapter(getSorceAdapter());
+ }
}
private Node getParentTable(Node sourceNode, int depth) {
@@ -864,46 +868,46 @@
return null;
}
-// public void setText(Node sourceText) {
-// Node sourceParent = sourceText.getParentNode();
-// if (sourceParent != null && sourceParent.getLocalName() != null) {
-// String sourceParentName = sourceParent.getLocalName();
-// if (HTML.TAG_TEXTAREA.equalsIgnoreCase(sourceParentName)
-// || HTML.TAG_OPTION.equalsIgnoreCase(sourceParentName)) {
-// updateNode(sourceText.getParentNode());
-// return;
-// }
-// }
-// nsIDOMNode visualText = domMapping.getVisualNode(sourceText);
-// if (visualText != null) {
-// String visualValue = TextUtil.visualText(sourceText.getNodeValue());
-// visualText.setNodeValue(visualValue);
-// }else {
-// VpeNodeMapping nodeMapping = domMapping
-// .getNodeMapping(sourceParent);
-// if (nodeMapping != null
-// && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
-// VpeTemplate template = ((VpeElementMapping) nodeMapping)
-// .getTemplate();
-// if (template != null) {
-// if (!template.containsText()) {
-// return;
-// }
- public boolean setText(Node sourceText) {
+ // public void setText(Node sourceText) {
+ // Node sourceParent = sourceText.getParentNode();
+ // if (sourceParent != null && sourceParent.getLocalName() != null) {
+ // String sourceParentName = sourceParent.getLocalName();
+ // if (HTML.TAG_TEXTAREA.equalsIgnoreCase(sourceParentName)
+ // || HTML.TAG_OPTION.equalsIgnoreCase(sourceParentName)) {
+ // updateNode(sourceText.getParentNode());
+ // return;
+ // }
+ // }
+ // nsIDOMNode visualText = domMapping.getVisualNode(sourceText);
+ // if (visualText != null) {
+ // String visualValue = TextUtil.visualText(sourceText.getNodeValue());
+ // visualText.setNodeValue(visualValue);
+ // }else {
+ // VpeNodeMapping nodeMapping = domMapping
+ // .getNodeMapping(sourceParent);
+ // if (nodeMapping != null
+ // && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ // VpeTemplate template = ((VpeElementMapping) nodeMapping)
+ // .getTemplate();
+ // if (template != null) {
+ // if (!template.containsText()) {
+ // return;
+ // }
+ public boolean setText(Node sourceText) {
Node sourceParent = sourceText.getParentNode();
if (sourceParent != null && sourceParent.getLocalName() != null) {
String sourceParentName = sourceParent.getLocalName();
if (HTML.TAG_TEXTAREA.equalsIgnoreCase(sourceParentName)
|| HTML.TAG_OPTION.equalsIgnoreCase(sourceParentName)) {
updateNode(sourceText.getParentNode());
- return true;
+ return true;
}
}
nsIDOMNode visualText = domMapping.getVisualNode(sourceText);
if (visualText != null) {
String visualValue = TextUtil.visualText(sourceText.getNodeValue());
visualText.setNodeValue(visualValue);
- }else {
+ } else {
VpeNodeMapping nodeMapping = domMapping
.getNodeMapping(sourceParent);
if (nodeMapping != null
@@ -912,20 +916,21 @@
.getTemplate();
if (template != null) {
if (!template.containsText()) {
- return false;
+ return false;
}
}
}
updateNode(sourceText);
- return true;
+ return true;
}
-
- // }
- // updateNode(sourceText);
- return false;
+
+ // }
+ // updateNode(sourceText);
+ return false;
}
-// }
+ // }
+
public void setAttribute(Element sourceElement, String name, String value) {
VpeElementMapping elementMapping = (VpeElementMapping) domMapping
.getNodeMapping(sourceElement);
@@ -956,17 +961,17 @@
} else if (HTML.TAG_INPUT
.equalsIgnoreCase(visualElementName)) {
updateElement(sourceElement);
- // Fixes JBIDE-1744 author dmaliarevich
- // unified h:dataTable border lookup
- // after attribute change and
- // after visual editor refresh
+ // Fixes JBIDE-1744 author dmaliarevich
+ // unified h:dataTable border lookup
+ // after attribute change and
+ // after visual editor refresh
} else if (HTML.TAG_TABLE
- .equalsIgnoreCase(visualElementName)) {
- updateElement(sourceElement);
+ .equalsIgnoreCase(visualElementName)) {
+ updateElement(sourceElement);
}
// End of fix
}
-// setXmlnsAttribute(elementMapping, name, value);
+ // setXmlnsAttribute(elementMapping, name, value);
template.setAttribute(pageContext, sourceElement,
visualDocument, visualElement, elementMapping
.getData(), name, value);
@@ -1023,10 +1028,20 @@
toggleLookup = "true".equals(toggleLookupAttr.getNodeValue());
}
+ nsIDOMElement selectedElem = getLastSelectedElement();
+
VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(getLastSelectedElement());
- Node sourceNode = (Node) domMapping
- .getSourceNode(getLastSelectedElement());
+ .getNodeMapping(selectedElem);
+ if (elementMapping == null) {
+ // may be toggle with facet
+ while (!selectedElem.getNodeName().equals(HTML.TAG_TABLE)) {
+ selectedElem = (nsIDOMElement) selectedElem.getParentNode()
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ }
+ elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(selectedElem);
+ }
+ Node sourceNode = (Node) domMapping.getSourceNode(selectedElem);
if (sourceNode == null)
return false;
@@ -1071,16 +1086,16 @@
.getVisualNode(), elementMapping.getData(),
name, null)) {
updateElement(sourceElement);
- }
-// else {
-// removeXmlnsAttribute(elementMapping, name);
-// template.removeAttribute(pageContext, sourceElement,
-// visualDocument, (nsIDOMElement) elementMapping
-// .getVisualNode(), elementMapping.getData(),
-// name);
-// resetTooltip(sourceElement, (nsIDOMElement) elementMapping
-// .getVisualNode());
-// }
+ }
+ // else {
+ // removeXmlnsAttribute(elementMapping, name);
+ // template.removeAttribute(pageContext, sourceElement,
+ // visualDocument, (nsIDOMElement) elementMapping
+ // .getVisualNode(), elementMapping.getData(),
+ // name);
+ // resetTooltip(sourceElement, (nsIDOMElement) elementMapping
+ // .getVisualNode());
+ // }
}
}
}
@@ -1116,7 +1131,11 @@
public nsIDOMNode addLinkNodeToHead(String href_val, String ext_val) {
nsIDOMElement newNode = createLinkNode(href_val,
ATTR_REL_STYLESHEET_VALUE, ext_val);
- headNode.appendChild(newNode);
+
+ //TODO Dzmitry Sakovich
+ // Fix priority CSS classes JBIDE-1713
+ nsIDOMNode firstNode = headNode.getFirstChild();
+ headNode.insertBefore(newNode, firstNode);
return newNode;
}
@@ -1936,77 +1955,78 @@
return (VpeIncludeInfo) includeStack.get(1);
}
- public void dispose() {
- clearIncludeDocuments();
- includeDocuments=null;
+ public void dispose() {
+ clearIncludeDocuments();
+ includeDocuments = null;
cleanHead();
domMapping.clear(visualContentArea);
pageContext.dispose();
- super.dispose();
+ super.dispose();
}
-
- private void clearIncludeDocuments() {
- Collection<Document> documents = includeDocuments.values();
- for (Iterator iterator = documents.iterator(); iterator.hasNext();) {
- Document document = (Document) iterator.next();
- VpeCreatorUtil.releaseDocumentFromRead(document);
- }
- includeDocuments.clear();
+
+ private void clearIncludeDocuments() {
+ Collection<Document> documents = includeDocuments.values();
+ for (Iterator iterator = documents.iterator(); iterator.hasNext();) {
+ Document document = (Document) iterator.next();
+ VpeCreatorUtil.releaseDocumentFromRead(document);
}
-// protected Map createXmlns(Element sourceNode) {
-// NamedNodeMap attrs = ((Element) sourceNode).getAttributes();
-// if (attrs != null) {
-// Map xmlnsMap = new HashMap();
-// for (int i = 0; i < attrs.getLength(); i++) {
-// addTaglib(sourceNode, xmlnsMap, attrs.item(i).getNodeName(),
-// true);
-// }
-// if (xmlnsMap.size() > 0) {
-// return xmlnsMap;
-// }
-// }
-// return null;
-// }
+ includeDocuments.clear();
+ }
-// private void setXmlnsAttribute(VpeElementMapping elementMapping,
-// String name, String value) {
-// Element sourceElement = (Element) elementMapping.getSourceNode();
-// if (sourceElement != null) {
-// Map xmlnsMap = elementMapping.getXmlnsMap();
-// if (xmlnsMap == null)
-// xmlnsMap = new HashMap();
-// addTaglib(sourceElement, xmlnsMap, name, true);
-// elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap : null);
-// }
-// }
+ // protected Map createXmlns(Element sourceNode) {
+ // NamedNodeMap attrs = ((Element) sourceNode).getAttributes();
+ // if (attrs != null) {
+ // Map xmlnsMap = new HashMap();
+ // for (int i = 0; i < attrs.getLength(); i++) {
+ // addTaglib(sourceNode, xmlnsMap, attrs.item(i).getNodeName(),
+ // true);
+ // }
+ // if (xmlnsMap.size() > 0) {
+ // return xmlnsMap;
+ // }
+ // }
+ // return null;
+ // }
-// private void removeXmlnsAttribute(VpeElementMapping elementMapping,
-// String name) {
-// Element sourceElement = (Element) elementMapping.getSourceNode();
-// if (sourceElement != null) {
-// Map xmlnsMap = elementMapping.getXmlnsMap();
-// if (xmlnsMap != null) {
-// Object id = xmlnsMap.remove(name);
-// if (id != null) {
-// pageContext.setTaglib(((Integer) id).intValue(), null,
-// null, true);
-// elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap
-// : null);
-// }
-// }
-// }
-// }
-//
-// private void addTaglib(Element sourceElement, Map xmlnsMap,
-// String attrName, boolean ns) {
-// Attr attr = sourceElement.getAttributeNode(attrName);
-// if (ATTR_XMLNS.equals(attr.getPrefix())) {
-// xmlnsMap.put(attr.getNodeName(), Integer.valueOf(attr.hashCode()));
-// pageContext.setTaglib(attr.hashCode(), attr.getNodeValue(), attr
-// .getLocalName(), ns);
-// }
-// }
+ // private void setXmlnsAttribute(VpeElementMapping elementMapping,
+ // String name, String value) {
+ // Element sourceElement = (Element) elementMapping.getSourceNode();
+ // if (sourceElement != null) {
+ // Map xmlnsMap = elementMapping.getXmlnsMap();
+ // if (xmlnsMap == null)
+ // xmlnsMap = new HashMap();
+ // addTaglib(sourceElement, xmlnsMap, name, true);
+ // elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap : null);
+ // }
+ // }
+ // private void removeXmlnsAttribute(VpeElementMapping elementMapping,
+ // String name) {
+ // Element sourceElement = (Element) elementMapping.getSourceNode();
+ // if (sourceElement != null) {
+ // Map xmlnsMap = elementMapping.getXmlnsMap();
+ // if (xmlnsMap != null) {
+ // Object id = xmlnsMap.remove(name);
+ // if (id != null) {
+ // pageContext.setTaglib(((Integer) id).intValue(), null,
+ // null, true);
+ // elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap
+ // : null);
+ // }
+ // }
+ // }
+ // }
+ //
+ // private void addTaglib(Element sourceElement, Map xmlnsMap,
+ // String attrName, boolean ns) {
+ // Attr attr = sourceElement.getAttributeNode(attrName);
+ // if (ATTR_XMLNS.equals(attr.getPrefix())) {
+ // xmlnsMap.put(attr.getNodeName(), Integer.valueOf(attr.hashCode()));
+ // pageContext.setTaglib(attr.hashCode(), attr.getNodeValue(), attr
+ // .getLocalName(), ns);
+ // }
+ // }
+
/**
* @return the dnd
*/
@@ -2098,15 +2118,16 @@
protected nsIDOMNode createTextNode(Node sourceNode, boolean registerFlag) {
String sourceText = sourceNode.getNodeValue();
-
- //Max Areshkau this code causes very slow work of visual editor
- //when we editing in big files txt nodes.For example exmployee.xhtml from JBIDE1105
-// if (sourceText.trim().length() <= 0) {
-// if (registerFlag)
-// registerNodes(new VpeNodeMapping(sourceNode, null));
-// return null;
-// }
+ // Max Areshkau this code causes very slow work of visual editor
+ // when we editing in big files txt nodes.For example exmployee.xhtml
+ // from JBIDE1105
+ // if (sourceText.trim().length() <= 0) {
+ // if (registerFlag)
+ // registerNodes(new VpeNodeMapping(sourceNode, null));
+ // return null;
+ // }
+
if (faceletFile) {
Matcher matcher_EL = REGEX_EL.matcher(sourceText);
if (matcher_EL.find()) {
@@ -2145,9 +2166,9 @@
*/
public void setXulRunnerEditor(XulRunnerEditor xulRunnerEditor) {
this.xulRunnerEditor = xulRunnerEditor;
- }
-
- public Map<IFile, Document> getIncludeDocuments() {
- return includeDocuments;
}
+
+ public Map<IFile, Document> getIncludeDocuments() {
+ return includeDocuments;
+ }
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2008-02-21
13:07:03 UTC (rev 6496)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2008-02-21
13:23:32 UTC (rev 6497)
@@ -23,467 +23,472 @@
public class VpeStyleUtil {
- public static final String ATTRIBUTE_STYLE = "style";
+ public static final String ATTRIBUTE_STYLE = "style";
- public static final String PARAMETER_POSITION = "position";
- public static final String PARAMETER_TOP = "top";
- public static final String PARAMETER_LEFT = "left";
- public static final String PARAMETER_WIDTH = "width";
- public static final String PARAMETER_HEIGHT = "height";
- public static final String PARAMETR_BACKGROND = "background";
+ public static final String PARAMETER_POSITION = "position";
+ public static final String PARAMETER_TOP = "top";
+ public static final String PARAMETER_LEFT = "left";
+ public static final String PARAMETER_WIDTH = "width";
+ public static final String PARAMETER_HEIGHT = "height";
+ public static final String PARAMETR_BACKGROND = "background";
- public static final String VALUE_ABSOLUTE = "absolute";
+ public static final String VALUE_ABSOLUTE = "absolute";
- public static final String DOT_STRING = ".";
- public static final String COLON_STRING = ":";
- public static final String SEMICOLON_STRING = ";";
- public static final String PX_STRING = "px";
- public static final String SPACE_STRING = " ";
- public static final String EMPTY_STRING = "";
+ public static final String DOT_STRING = ".";
+ public static final String COLON_STRING = ":";
+ public static final String SEMICOLON_STRING = ";";
+ public static final String PX_STRING = "px";
+ public static final String SPACE_STRING = " ";
+ public static final String EMPTY_STRING = "";
- public static String ATTR_URL = "url";
- public static String OPEN_BRACKET = "(";
- public static String CLOSE_BRACKET = ")";
- public static String FILE_PRTOCOL = "file://";
- public static String FILE_STR = "file:";
- public static String FILE_SEPARAROT = "/";
+ public static String ATTR_URL = "url";
+ public static String OPEN_BRACKET = "(";
+ public static String CLOSE_BRACKET = ")";
+ public static String FILE_PRTOCOL = "file://";
+ public static String FILE_STR = "file:";
+ public static String FILE_SEPARAROT = "/";
- // sets parameter position in atribute style to absolute value
- public static void setAbsolute(Element sourceElement) {
- String style = sourceElement.getAttribute(ATTRIBUTE_STYLE);
- if (style == null) {
- style = EMPTY_STRING;
- } else { // remove old sizes
- style = deleteFromString(style, PARAMETER_POSITION,
- SEMICOLON_STRING);
- }
- if (style.length() > 0) {
- if (!style.endsWith(SEMICOLON_STRING))
- style += SEMICOLON_STRING;
- }
+ // sets parameter position in atribute style to absolute value
+ public static void setAbsolute(Element sourceElement) {
+ String style = sourceElement.getAttribute(ATTRIBUTE_STYLE);
+ if (style == null) {
+ style = EMPTY_STRING;
+ } else { // remove old sizes
+ style = deleteFromString(style, PARAMETER_POSITION,
+ SEMICOLON_STRING);
+ }
+ if (style.length() > 0) {
+ if (!style.endsWith(SEMICOLON_STRING))
+ style += SEMICOLON_STRING;
+ }
- style += SPACE_STRING + PARAMETER_POSITION + SPACE_STRING
- + COLON_STRING + SPACE_STRING + VALUE_ABSOLUTE
- + SEMICOLON_STRING;
+ style += SPACE_STRING + PARAMETER_POSITION + SPACE_STRING
+ + COLON_STRING + SPACE_STRING + VALUE_ABSOLUTE
+ + SEMICOLON_STRING;
- sourceElement.setAttribute(ATTRIBUTE_STYLE, style);
+ sourceElement.setAttribute(ATTRIBUTE_STYLE, style);
+ }
+
+ // sets parameter position in absolute value
+ public static String setAbsolute(String styleString) {
+ String style = new String(styleString);
+ if (style == null) {
+ style = EMPTY_STRING;
+ } else { // remove old sizes
+ style = deleteFromString(style, PARAMETER_POSITION,
+ SEMICOLON_STRING);
}
+ if (style.length() > 0) {
+ if (!style.endsWith(SEMICOLON_STRING))
+ style += SEMICOLON_STRING;
+ }
- // sets parameter position in absolute value
- public static String setAbsolute(String styleString) {
- String style = new String(styleString);
- if (style == null) {
- style = EMPTY_STRING;
- } else { // remove old sizes
- style = deleteFromString(style, PARAMETER_POSITION,
- SEMICOLON_STRING);
- }
- if (style.length() > 0) {
- if (!style.endsWith(SEMICOLON_STRING))
- style += SEMICOLON_STRING;
- }
+ style += SPACE_STRING + PARAMETER_POSITION + SPACE_STRING
+ + COLON_STRING + SPACE_STRING + VALUE_ABSOLUTE
+ + SEMICOLON_STRING;
- style += SPACE_STRING + PARAMETER_POSITION + SPACE_STRING
- + COLON_STRING + SPACE_STRING + VALUE_ABSOLUTE
- + SEMICOLON_STRING;
+ return style;
+ }
- return style;
+ // return true if parameter position was set to absolute
+ public static boolean getAbsolute(Element sourceElement) {
+ String style = sourceElement.getAttribute(ATTRIBUTE_STYLE);
+ if (style == null) {
+ return false;
+ } else { // remove old sizes
+ if (style.indexOf(VALUE_ABSOLUTE) >= 0)
+ return true;
}
+ return false;
+ }
- // return true if parameter position was set to absolute
- public static boolean getAbsolute(Element sourceElement) {
- String style = sourceElement.getAttribute(ATTRIBUTE_STYLE);
- if (style == null) {
- return false;
- } else { // remove old sizes
- if (style.indexOf(VALUE_ABSOLUTE) >= 0)
- return true;
- }
- return false;
+ // return true if parameter position was set to absolute
+ public static boolean getAbsolute(String style) {
+ if (style == null) {
+ return false;
+ } else { // remove old sizes
+ if (style.indexOf(VALUE_ABSOLUTE) >= 0)
+ return true;
}
+ return false;
+ }
- // return true if parameter position was set to absolute
- public static boolean getAbsolute(String style) {
- if (style == null) {
- return false;
- } else { // remove old sizes
- if (style.indexOf(VALUE_ABSOLUTE) >= 0)
- return true;
- }
- return false;
- }
+ // return value of parameter described in sizeAttribute, for example
+ // "style.width"
+ public static int getSizeFromStyle(Element sourceElement,
+ String sizeAttribute) {
+ int dotPosition = sizeAttribute.indexOf(DOT_STRING);
+ String attribute = sizeAttribute.substring(0, dotPosition);
+ String parameter = sizeAttribute.substring(dotPosition + 1,
+ sizeAttribute.length());
- // return value of parameter described in sizeAttribute, for example
- // "style.width"
- public static int getSizeFromStyle(Element sourceElement,
- String sizeAttribute) {
- int dotPosition = sizeAttribute.indexOf(DOT_STRING);
- String attribute = sizeAttribute.substring(0, dotPosition);
- String parameter = sizeAttribute.substring(dotPosition + 1,
- sizeAttribute.length());
+ String style = sourceElement.getAttribute(attribute);
+ if (style == null || EMPTY_STRING.equals(style))
+ return -1;
- String style = sourceElement.getAttribute(attribute);
- if (style == null || EMPTY_STRING.equals(style))
- return -1;
-
- int parameterPosition = style.indexOf(parameter);
- if (parameterPosition >= 0) {
- int valuePosition = style.indexOf(COLON_STRING, parameterPosition);
- if (valuePosition >= 0) {
- int endPosition = style.indexOf(PX_STRING, valuePosition);
- if (endPosition >= 0) {
- return Integer.parseInt(style.substring(valuePosition + 1,
- endPosition).trim());
- }
- }
+ int parameterPosition = style.indexOf(parameter);
+ if (parameterPosition >= 0) {
+ int valuePosition = style.indexOf(COLON_STRING, parameterPosition);
+ if (valuePosition >= 0) {
+ int endPosition = style.indexOf(PX_STRING, valuePosition);
+ if (endPosition >= 0) {
+ return Integer.parseInt(style.substring(valuePosition + 1,
+ endPosition).trim());
}
- return -1;
+ }
}
+ return -1;
+ }
- // return value of parameter described in sizeAttribute, for example
- // "style.width"
- public static String getParameterFromStyle(Element sourceElement,
- String sizeAttribute) {
- int dotPosition = sizeAttribute.indexOf(DOT_STRING);
- String attribute = sizeAttribute.substring(0, dotPosition);
- String parameter = sizeAttribute.substring(dotPosition + 1,
- sizeAttribute.length());
+ // return value of parameter described in sizeAttribute, for example
+ // "style.width"
+ public static String getParameterFromStyle(Element sourceElement,
+ String sizeAttribute) {
+ int dotPosition = sizeAttribute.indexOf(DOT_STRING);
+ String attribute = sizeAttribute.substring(0, dotPosition);
+ String parameter = sizeAttribute.substring(dotPosition + 1,
+ sizeAttribute.length());
- String style = sourceElement.getAttribute(attribute);
- if (style == null || EMPTY_STRING.equals(style))
- return null;
+ String style = sourceElement.getAttribute(attribute);
+ if (style == null || EMPTY_STRING.equals(style))
+ return null;
- int parameterPosition = style.indexOf(parameter);
- if (parameterPosition >= 0) {
- int valuePosition = style.indexOf(COLON_STRING, parameterPosition);
- if (valuePosition >= 0) {
- int endPosition = style.indexOf(PX_STRING, valuePosition);
- if (endPosition >= 0) {
- return style.substring(valuePosition + 1, endPosition)
- .trim();
- }
- }
+ int parameterPosition = style.indexOf(parameter);
+ if (parameterPosition >= 0) {
+ int valuePosition = style.indexOf(COLON_STRING, parameterPosition);
+ if (valuePosition >= 0) {
+ int endPosition = style.indexOf(PX_STRING, valuePosition);
+ if (endPosition >= 0) {
+ return style.substring(valuePosition + 1, endPosition)
+ .trim();
}
- return null;
+ }
}
+ return null;
+ }
- // sets value of parameter described in sizeAttribute, for example
- // "style.width"
- public static void setSizeInStyle(Element sourceElement,
- String sizeAttribute, int size) {
- int dotPosition = sizeAttribute.indexOf(DOT_STRING);
- String attribute = sizeAttribute.substring(0, dotPosition);
- String parameter = sizeAttribute.substring(dotPosition + 1,
- sizeAttribute.length());
+ // sets value of parameter described in sizeAttribute, for example
+ // "style.width"
+ public static void setSizeInStyle(Element sourceElement,
+ String sizeAttribute, int size) {
+ int dotPosition = sizeAttribute.indexOf(DOT_STRING);
+ String attribute = sizeAttribute.substring(0, dotPosition);
+ String parameter = sizeAttribute.substring(dotPosition + 1,
+ sizeAttribute.length());
- String style = sourceElement.getAttribute(attribute);
- if (style == null) {
- style = EMPTY_STRING;
- } else { // remove old sizes
- style = deleteFromString(style, parameter, SEMICOLON_STRING);
- }
- if (style.length() > 0) {
- if (!style.endsWith(SEMICOLON_STRING))
- style += SEMICOLON_STRING;
- }
-
- style += SPACE_STRING + parameter + SPACE_STRING + COLON_STRING
- + SPACE_STRING + size + PX_STRING + SEMICOLON_STRING;
-
- sourceElement.setAttribute(attribute, style);
+ String style = sourceElement.getAttribute(attribute);
+ if (style == null) {
+ style = EMPTY_STRING;
+ } else { // remove old sizes
+ style = deleteFromString(style, parameter, SEMICOLON_STRING);
}
+ if (style.length() > 0) {
+ if (!style.endsWith(SEMICOLON_STRING))
+ style += SEMICOLON_STRING;
+ }
- // sets value of parameter described in sizeAttribute, for example
- // "style.width"
- public static void setParameterInStyle(Element sourceElement,
- String sizeAttribute, String value) {
- int dotPosition = sizeAttribute.indexOf(DOT_STRING);
- String attribute = sizeAttribute.substring(0, dotPosition);
- String parameter = sizeAttribute.substring(dotPosition + 1,
- sizeAttribute.length());
+ style += SPACE_STRING + parameter + SPACE_STRING + COLON_STRING
+ + SPACE_STRING + size + PX_STRING + SEMICOLON_STRING;
- String style = sourceElement.getAttribute(attribute);
- if (style == null) {
- style = EMPTY_STRING;
- } else { // remove old sizes
- style = deleteFromString(style, parameter, SEMICOLON_STRING);
- }
- if (style.length() > 0) {
- if (!style.endsWith(SEMICOLON_STRING))
- style += SEMICOLON_STRING;
- }
+ sourceElement.setAttribute(attribute, style);
+ }
- style += SPACE_STRING + parameter + SPACE_STRING + COLON_STRING
- + SPACE_STRING + value + SEMICOLON_STRING;
+ // sets value of parameter described in sizeAttribute, for example
+ // "style.width"
+ public static void setParameterInStyle(Element sourceElement,
+ String sizeAttribute, String value) {
+ int dotPosition = sizeAttribute.indexOf(DOT_STRING);
+ String attribute = sizeAttribute.substring(0, dotPosition);
+ String parameter = sizeAttribute.substring(dotPosition + 1,
+ sizeAttribute.length());
- sourceElement.setAttribute(attribute, style);
+ String style = sourceElement.getAttribute(attribute);
+ if (style == null) {
+ style = EMPTY_STRING;
+ } else { // remove old sizes
+ style = deleteFromString(style, parameter, SEMICOLON_STRING);
}
+ if (style.length() > 0) {
+ if (!style.endsWith(SEMICOLON_STRING))
+ style += SEMICOLON_STRING;
+ }
- public static String setSizeInStyle(String style, String parameter, int size) {
- if (style == null) {
- style = EMPTY_STRING;
- } else { // remove old sizes
- style = deleteFromString(style, parameter, SEMICOLON_STRING);
- }
- if (style.length() > 0) {
- if (!style.endsWith(SEMICOLON_STRING))
- style += SEMICOLON_STRING;
- }
+ style += SPACE_STRING + parameter + SPACE_STRING + COLON_STRING
+ + SPACE_STRING + value + SEMICOLON_STRING;
- style += SPACE_STRING + parameter + SPACE_STRING + COLON_STRING
- + SPACE_STRING + size + PX_STRING + SEMICOLON_STRING;
+ sourceElement.setAttribute(attribute, style);
+ }
- return style;
+ public static String setSizeInStyle(String style, String parameter, int size) {
+ if (style == null) {
+ style = EMPTY_STRING;
+ } else { // remove old sizes
+ style = deleteFromString(style, parameter, SEMICOLON_STRING);
}
+ if (style.length() > 0) {
+ if (!style.endsWith(SEMICOLON_STRING))
+ style += SEMICOLON_STRING;
+ }
- public static String setParameterInStyle(String style, String parameter,
- String value) {
- if (style == null) {
- style = EMPTY_STRING;
- } else { // remove old sizes
- style = deleteFromString(style, parameter, SEMICOLON_STRING);
- }
- if (style.length() > 0) {
- if (!style.endsWith(SEMICOLON_STRING))
- style += SEMICOLON_STRING;
- }
+ style += SPACE_STRING + parameter + SPACE_STRING + COLON_STRING
+ + SPACE_STRING + size + PX_STRING + SEMICOLON_STRING;
- style += SPACE_STRING + parameter + SPACE_STRING + COLON_STRING
- + SPACE_STRING + value + SEMICOLON_STRING;
+ return style;
+ }
- return style;
+ public static String setParameterInStyle(String style, String parameter,
+ String value) {
+ if (style == null) {
+ style = EMPTY_STRING;
+ } else { // remove old sizes
+ style = deleteFromString(style, parameter, SEMICOLON_STRING);
}
-
- // selets parameter from atribute style
- public static void deleteFromStyle(Element sourceElement, String begin,
- String end) {
- String style = sourceElement.getAttribute(ATTRIBUTE_STYLE);
- style = deleteFromString(style, begin, end);
- sourceElement.setAttribute(ATTRIBUTE_STYLE, style);
+ if (style.length() > 0) {
+ if (!style.endsWith(SEMICOLON_STRING))
+ style += SEMICOLON_STRING;
}
- // selets parameter from atribute style
- public static String deleteFromString(String data, String begin, String end) {
- int startPosition = data.indexOf(begin);
+ style += SPACE_STRING + parameter + SPACE_STRING + COLON_STRING
+ + SPACE_STRING + value + SEMICOLON_STRING;
- if (startPosition < 0)
- return data;
+ return style;
+ }
- int endPosition = data.indexOf(end, startPosition);
+ // selets parameter from atribute style
+ public static void deleteFromStyle(Element sourceElement, String begin,
+ String end) {
+ String style = sourceElement.getAttribute(ATTRIBUTE_STYLE);
+ style = deleteFromString(style, begin, end);
+ sourceElement.setAttribute(ATTRIBUTE_STYLE, style);
+ }
- String result = data.substring(0, startPosition).trim();
- if (endPosition > 0) {
- result += data.substring(endPosition + 1, data.length()).trim();
- }
+ // selets parameter from atribute style
+ public static String deleteFromString(String data, String begin, String end) {
+ int startPosition = data.indexOf(begin);
- return result;
+ if (startPosition < 0)
+ return data;
+
+ int endPosition = data.indexOf(end, startPosition);
+
+ String result = data.substring(0, startPosition).trim();
+ if (endPosition > 0) {
+ result += data.substring(endPosition + 1, data.length()).trim();
}
- /**
- *
- * @param value
- * Css string
- * @param input
- * The editor input
- * @return format style string
- */
- public static String addFullPathIntoBackgroundValue(String value,
- IEditorInput input) {
+ return result;
+ }
- if (value.indexOf(FILE_STR) != -1)
- return value;
+ /**
+ *
+ * @param value
+ * Css string
+ * @param input
+ * The editor input
+ * @return format style string
+ */
+ public static String addFullPathIntoBackgroundValue(String value,
+ IEditorInput input) {
- if (!new File(value).isAbsolute())
- value = getFilePath(input, value);
+ if (value.indexOf(FILE_STR) != -1)
+ return value;
- value = FILE_PRTOCOL + value;
- URL url = null;
- try {
- url = new URL(value);
- } catch (MalformedURLException e) {
- return value;
- }
+ if (!new File(value).isAbsolute())
+ value = getFilePath(input, value);
- return url.toString();
+ value = FILE_PRTOCOL + value;
+ URL url = null;
+ try {
+ url = new URL(value);
+ } catch (MalformedURLException e) {
+ return value;
}
- /**
- *
- * @param value
- * Css string
- * @param input
- * The editor input
- * @return format style string
- */
- public static String addFullPathIntoURLValue(String value,
- IEditorInput input) {
+ return url.toString();
+ }
- String urls[] = value.split(ATTR_URL);
+ /**
+ *
+ * @param value
+ * Css string
+ * @param input
+ * The editor input
+ * @return format style string
+ */
+ public static String addFullPathIntoURLValue(String value,
+ IEditorInput input) {
- if (urls.length == 1)
- return value;
+ String urls[] = value.split(ATTR_URL);
- String finalStr = EMPTY_STRING;
- for (int i = 1; i < urls.length; i++) {
+ if (urls.length == 1)
+ return value;
- urls[i] = urls[i].replace("\'", EMPTY_STRING);
- urls[i] = ATTR_URL + urls[i];
+ String finalStr = EMPTY_STRING;
+ for (int i = 1; i < urls.length; i++) {
- int startAttr = urls[i].indexOf(ATTR_URL);
+ urls[i] = urls[i].replace("\'", EMPTY_STRING);
+ urls[i] = ATTR_URL + urls[i];
- int startPathIndex = urls[i].indexOf(OPEN_BRACKET, startAttr);
- int endPathIndex = urls[i].indexOf(CLOSE_BRACKET,
- startPathIndex + 1);
+ int startAttr = urls[i].indexOf(ATTR_URL);
- if (startPathIndex == -1 || endPathIndex == -1)
- continue;
+ int startPathIndex = urls[i].indexOf(OPEN_BRACKET, startAttr);
+ int endPathIndex = urls[i].indexOf(CLOSE_BRACKET,
+ startPathIndex + 1);
- String filePath = urls[i].substring(startPathIndex + 1,
- endPathIndex);
- if (filePath.indexOf(FILE_STR) != -1)
- continue;
+ if (startPathIndex == -1 || endPathIndex == -1)
+ continue;
- if (!new File(filePath).isAbsolute())
- filePath = getFilePath(input, filePath);
+ String filePath = urls[i].substring(startPathIndex + 1,
+ endPathIndex);
+ if (filePath.indexOf(FILE_STR) != -1)
+ continue;
- filePath = FILE_PRTOCOL + filePath;
- URL url = null;
- try {
- url = new URL(filePath);
- } catch (MalformedURLException e) {
- continue;
- }
- filePath = url.toString();
+ if (!new File(filePath).isAbsolute())
+ filePath = getFilePath(input, filePath);
- String firstPartValue = urls[i].substring(0, startPathIndex + 1);
- String secondPartValue = urls[i].substring(endPathIndex, urls[i]
- .length());
+ filePath = FILE_PRTOCOL + filePath;
+ URL url = null;
+ try {
+ url = new URL(filePath);
+ } catch (MalformedURLException e) {
+ continue;
+ }
+ filePath = url.toString();
- urls[i] = firstPartValue + filePath + secondPartValue;
- }
- for (int i = 0; i < urls.length; i++)
- finalStr += urls[i];
- return finalStr;
- }
+ String firstPartValue = urls[i].substring(0, startPathIndex + 1);
+ String secondPartValue = urls[i].substring(endPathIndex, urls[i]
+ .length());
- /**
- *
- * @param nput
- * The editor input
- * @param fileName
- * Relative path file
- * @return Absolute path file
- */
- public static String getFilePath(IEditorInput input, String fileName) {
- IPath inputPath = getInputParentPath(input);
- return inputPath.toOSString() + File.separator + fileName;
+ urls[i] = firstPartValue + filePath + secondPartValue;
}
+ for (int i = 0; i < urls.length; i++)
+ finalStr += urls[i];
+ return finalStr;
+ }
- /**
- *
- * @param input
- * The editor input
- * @return Path
- */
- 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;
+ /**
+ *
+ * @param nput
+ * The editor input
+ * @param fileName
+ * Relative path file
+ * @return Absolute path file
+ */
+ public static String getFilePath(IEditorInput input, String fileName) {
+ IPath inputPath = getInputParentPath(input);
+ return inputPath.toOSString() + File.separator + fileName;
+ }
+
+ /**
+ *
+ * @param input
+ * The editor input
+ * @return Path
+ */
+ 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;
+ }
- /**
- *
- * @param value
- * Css string
- * @param href_val
- * Path of css file
- * @return Format style string
- */
- public static String addFullPathIntoURLValue(String value, String href_val) {
+ /**
+ *
+ * @param value
+ * Css string
+ * @param href_val
+ * Path of css file
+ * @return Format style string
+ */
+ public static String addFullPathIntoURLValue(String value, String href_val) {
- String urls[] = value.split(ATTR_URL);
+ String urls[] = value.split(ATTR_URL);
- if (urls.length == 1)
- return value;
+ if (urls.length == 1)
+ return value;
- String finalStr = EMPTY_STRING;
+ String finalStr = EMPTY_STRING;
- for (int i = 1; i < urls.length; i++) {
+ for (int i = 1; i < urls.length; i++) {
- urls[i] = urls[i].replace("\'", EMPTY_STRING);
- urls[i] = ATTR_URL + urls[i];
+ urls[i] = urls[i].replace("\'", EMPTY_STRING);
+ urls[i] = ATTR_URL + urls[i];
- int startAttr = urls[i].indexOf(ATTR_URL);
+ int startAttr = urls[i].indexOf(ATTR_URL);
- int startPathIndex = urls[i].indexOf(OPEN_BRACKET, startAttr);
- int endPathIndex = urls[i].indexOf(CLOSE_BRACKET,
- startPathIndex + 1);
+ int startPathIndex = urls[i].indexOf(OPEN_BRACKET, startAttr);
+ int endPathIndex = urls[i].indexOf(CLOSE_BRACKET,
+ startPathIndex + 1);
- String filePath = urls[i].substring(startPathIndex + 1,
- endPathIndex);
- if (filePath.indexOf(FILE_STR) != -1)
- continue;
+ String filePath = urls[i].substring(startPathIndex + 1,
+ endPathIndex);
+ if (filePath.indexOf(FILE_STR) != -1)
+ continue;
- if (!new File(filePath).isAbsolute())
- filePath = getAbsolutePathImage(filePath, href_val);
- else
- filePath = FILE_PRTOCOL + filePath;
+ if (!new File(filePath).isAbsolute())
+ filePath = getAbsolutePathImage(filePath, href_val);
+ else
+ filePath = FILE_PRTOCOL + filePath;
- URL url = null;
- try {
- url = new URL(filePath);
- } catch (MalformedURLException e) {
- continue;
- }
- filePath = url.toString();
+ try {
+ new URL(filePath);
+ } catch (MalformedURLException e) {
+ continue;
+ }
- String firstPartValue = urls[i].substring(0, startPathIndex + 1);
- String secondPartValue = urls[i].substring(endPathIndex, urls[i]
- .length());
+ // Dzmitry Sakovich
+ // Fix for Linux
+ // filePath = url.toString();
- urls[i] = firstPartValue + filePath + secondPartValue;
- }
- for (int i = 0; i < urls.length; i++)
- finalStr += urls[i];
- return finalStr;
+ String firstPartValue = urls[i].substring(0, startPathIndex + 1);
+ String secondPartValue = urls[i].substring(endPathIndex, urls[i]
+ .length());
+
+ urls[i] = firstPartValue + filePath + secondPartValue;
}
+ for (int i = 0; i < urls.length; i++)
+ finalStr += urls[i];
+ return finalStr;
+ }
- /**
- *
- * @param pathImgRelative
- * Relative path img file
- * @param pathCssAbsolute
- * Absolute path css file
- * @return Absolute path img file
- */
- private static String getAbsolutePathImage(String pathImgRelative,
- String pathCssAbsolute) {
+ /**
+ *
+ * @param pathImgRelative
+ * Relative path img file
+ * @param pathCssAbsolute
+ * Absolute path css file
+ * @return Absolute path img file
+ */
+ private static String getAbsolutePathImage(String pathImgRelative,
+ String pathCssAbsolute) {
- int k = 0;
- int j = 0;
- URL url = null;
- try {
- url = new URL(pathCssAbsolute);
- } catch (MalformedURLException e) {
- return pathImgRelative;
- }
- pathCssAbsolute = url.toString();
- while (j != -1) {
- j = pathCssAbsolute.indexOf(FILE_SEPARAROT, j + 1);
- if (j == -1)
- break;
- k = j;
- }
- return pathCssAbsolute.substring(0, k + 1) + pathImgRelative;
+ int k = 0;
+ int j = 0;
+ try {
+ new URL(pathCssAbsolute);
+ } catch (MalformedURLException e) {
+ return pathImgRelative;
}
+
+ // TODO Dzmitry Sakovich
+ // Fix for Linux
+ // pathCssAbsolute = url.toString();
+
+ while (j != -1) {
+ j = pathCssAbsolute.indexOf(FILE_SEPARAROT, j + 1);
+ if (j == -1)
+ break;
+ k = j;
+ }
+ return pathCssAbsolute.substring(0, k + 1) + pathImgRelative;
+ }
}
\ No newline at end of file