Author: ezheleznyakov
Date: 2007-09-20 07:41:40 -0400 (Thu, 20 Sep 2007)
New Revision: 3730
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/lib/
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/lib/jhighlight-1.0.jar
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessageTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessagesTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesVirtualEarthTemplate.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/.classpath
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/META-INF/MANIFEST.MF
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/build.properties
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/templates/vpe-templates-richfaces.xml
Log:
http://jira.jboss.com/jira/browse/JBIDE-847
Create template for <rich:insert>, <rich:message>, <rich:messages>,
<rich:toolTip>, <rich:effect>, <rich:virtualEarth>,
<rich:changeExpandListener>
<rich:nodeSelectListener> components.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/.classpath
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/.classpath 2007-09-20 09:03:53 UTC
(rev 3729)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/.classpath 2007-09-20 11:41:40 UTC
(rev 3730)
@@ -3,5 +3,6 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="lib" path="lib/jhighlight-1.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/META-INF/MANIFEST.MF 2007-09-20
09:03:53 UTC (rev 3729)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/META-INF/MANIFEST.MF 2007-09-20
11:41:40 UTC (rev 3730)
@@ -15,3 +15,5 @@
org.eclipse.ui.ide
Eclipse-LazyStart: true
Bundle-Vendor: Red Hat, Inc.
+Bundle-ClassPath: lib/jhighlight-1.0.jar,
+ .
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/build.properties
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/build.properties 2007-09-20
09:03:53 UTC (rev 3729)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/build.properties 2007-09-20
11:41:40 UTC (rev 3730)
@@ -4,7 +4,8 @@
.,\
resources/,\
templates/,\
- plugin.xml
+ plugin.xml,\
+ lib/jhighlight-1.0.jar
src.includes = src/,\
resources/,\
templates/
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/lib/jhighlight-1.0.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/lib/jhighlight-1.0.jar
___________________________________________________________________
Name: svn:mime-type
+ application/x-jar
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2007-09-20
09:03:53 UTC (rev 3729)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2007-09-20
11:41:40 UTC (rev 3730)
@@ -281,6 +281,22 @@
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;
+ }
/**
* Returns locale of user input
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 2007-09-20
09:03:53 UTC (rev 3729)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/HtmlComponentUtil.java 2007-09-20
11:41:40 UTC (rev 3730)
@@ -62,6 +62,9 @@
/** HTML_HEIGHT_ATTR * */
public static final String HTML_HEIGHT_ATTR = "height";
+
+ /** HTML_CLASS_ATTR * */
+ public static final String HTML_STYLECLASS_ATTR = "styleClass";
/** HTML_CLASS_ATTR * */
public static final String HTML_CLASS_ATTR = "class";
@@ -74,6 +77,9 @@
/** HTML_ALIGN_LEFT_VALUE * */
public static final String HTML_ALIGN_LEFT_VALUE = "left";
+
+ /** HTML_ALIGN_RIGHT_VALUE * */
+ public static final String HTML_ALIGN_RIGHT_VALUE = "right";
/** HTML_ALIGN_CENTER_VALUE * */
public static final String HTML_ALIGN_CENTER_VALUE = "center";
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java 2007-09-20
11:41:40 UTC (rev 3730)
@@ -0,0 +1,279 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.richfaces.template;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.StringBufferInputStream;
+import java.util.HashMap;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
+import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+
+import com.uwyn.jhighlight.renderer.Renderer;
+import com.uwyn.jhighlight.renderer.XhtmlRendererFactory;
+
+/**
+ *
+ * @author ezheleznyakov(a)exadel.com
+ *
+ */
+public class RichFacesInsertTemplate extends VpeAbstractTemplate {
+
+ private static String SRC_ATTR_NAME = "src";
+ private static String HIGHTLIGHT_ATTR_NAME = "highlight";
+
+ private static String CODE_TAG = "code>";
+
+ private static String CLASS = "class=";
+
+ private static String STYLE = "style=";
+
+ private static String OPEN_BRACKET = "{";
+ private static String CLOSE_BRACKET = "}";
+
+ private static String SPACE = " ";
+
+ private static String SPAN_TAG = "<span style=\"color:
rgb(255,255,255)\">_</span>";
+
+ private static String EMPTY_STRING = "";
+
+ private static String HTML = "html";
+ private static String XHTML = "xhtml";
+ private static String XML = "xml";
+ private static String JAVA = "java";
+ private static String CPP = "cpp";
+ private static String GROOVY = "groovy";
+ private static String LZX = "lzx";
+
+ private Document visualDocument;
+
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ Document visualDocument) {
+
+ this.visualDocument = visualDocument;
+
+ Element div = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+
+ String srcValue = ((Element) sourceNode).getAttribute(SRC_ATTR_NAME);
+ String highlightValue = ((Element) sourceNode)
+ .getAttribute(HIGHTLIGHT_ATTR_NAME);
+
+ VpeCreationData vpeCreationData = new VpeCreationData(div);
+
+ File file = ComponentUtil.openFile(pageContext, srcValue);
+ String finalStr = "";
+ String buf = "";
+
+ if (srcValue == null)
+ return vpeCreationData;
+
+ try {
+ BufferedReader br = new BufferedReader(new InputStreamReader(
+ new FileInputStream(file)));
+
+ while ((buf = br.readLine()) != null)
+ finalStr += buf + "\n";
+
+ } catch (Exception e) {
+ finalStr = "Resources " + srcValue + " not found.";
+ div.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "color: red; "
+ + "font-weight: bold;");
+ Text text = visualDocument.createTextNode(finalStr);
+ div.appendChild(text);
+ return vpeCreationData;
+ }
+
+ if (!serchInSupportedTypes(highlightValue))
+ return vpeCreationData;
+
+ if (highlightValue == null) {
+ finalStr = finalStr.replace('\n', ' ');
+ Text text = visualDocument.createTextNode(finalStr);
+ div.appendChild(text);
+ return vpeCreationData;
+ }
+
+ Renderer renderer = XhtmlRendererFactory.getRenderer(highlightValue);
+ String transformStr = null;
+ try {
+ transformStr = renderer.highlight("", finalStr, "utf-8", false);
+ transformStr = convertString(transformStr, highlightValue);
+ Node node = parseTransformString(transformStr);
+ buildVisualNode(node, div);
+ } catch (IOException e1) {
+ return vpeCreationData;
+ }
+ return vpeCreationData;
+ }
+
+ /**
+ *
+ * @param str
+ * @param highlightValue
+ * highlight attribute value
+ */
+ private String convertString(String str, String highlightValue) {
+
+ HashMap<String, String> map = new HashMap<String, String>();
+
+ if (highlightValue.equalsIgnoreCase(HTML)
+ || highlightValue.equalsIgnoreCase(XHTML)
+ || highlightValue.equalsIgnoreCase(LZX))
+ highlightValue = XML;
+ if (highlightValue.equalsIgnoreCase(GROOVY))
+ highlightValue = JAVA;
+ if (highlightValue.equalsIgnoreCase("c++"))
+ highlightValue = CPP;
+
+ String sym = "." + highlightValue + "_";
+
+ for (int i = 0; i < str.length();) {
+ int start = str.indexOf(sym, i);
+ if (start == -1)
+ break;
+ int startBracket = str.indexOf(OPEN_BRACKET, start);
+ String key = str.substring(start + 1, startBracket - 1);
+ int endBracket = str.indexOf(CLOSE_BRACKET, startBracket);
+ String value = str.substring(startBracket + 2, endBracket - 2);
+ i = endBracket;
+ map.put(key, value);
+ }
+
+ int start = str.indexOf(CODE_TAG);
+ int end = str.indexOf(CODE_TAG, start + 1);
+ str = str.substring(start - 1, end + 5);
+
+ str = str.replaceAll(CLASS, STYLE);
+
+ Set<String> set = map.keySet();
+
+ for (String key : set) {
+ String value = map.get(key);
+ str = str.replaceAll(key, value);
+ }
+ str = str.replace(SPACE, SPAN_TAG);
+ return str;
+ }
+
+ /**
+ *
+ * @param fileTransform
+ */
+ @SuppressWarnings("deprecation")
+ public Node parseTransformString(String transformString) {
+
+ DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
+
+ DocumentBuilder builder = null;
+ Document doc = null;
+ Node node = null;
+ try {
+ builder = fact.newDocumentBuilder();
+ doc = builder.parse(new StringBufferInputStream(transformString));
+ node = doc.getElementsByTagName("code").item(0);
+ } catch (Exception e) {
+ return node;
+ }
+ return node;
+ }
+
+ /**
+ *
+ * @param highlightValue
+ * value of highlight attribute
+ * @return true of highlight value correct
+ */
+
+ private boolean serchInSupportedTypes(String highlightValue) {
+
+ if (highlightValue == null)
+ return true;
+
+ if (highlightValue.trim().equals(EMPTY_STRING))
+ return false;
+
+ Set<?> set = XhtmlRendererFactory.getSupportedTypes();
+
+ for (Object object : set)
+ if (highlightValue.equalsIgnoreCase((String) object))
+ return true;
+
+ return false;
+ }
+
+ /**
+ *
+ * @param node
+ * @param el
+ * @return
+ */
+ private void buildVisualNode(Node node, Element el) {
+
+ if (node instanceof Text) {
+ Text text = visualDocument.createTextNode(node.getTextContent());
+ el.appendChild(text);
+
+ } else {
+ Element elem = visualDocument.createElement(node.getNodeName());
+ el.appendChild(elem);
+
+ for (int i = 0; i < node.getAttributes().getLength(); i++)
+ elem.setAttribute(node.getAttributes().item(i).getNodeName(),
+ node.getAttributes().item(i).getNodeValue());
+
+ for (int i = 0; i < node.getChildNodes().getLength(); i++)
+ buildVisualNode(node.getChildNodes().item(i), elem);
+ }
+ }
+
+ /**
+ * Checks, whether it is necessary to re-create an element at change of
+ * attribute
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceElement
+ * The current element of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @param visualNode
+ * The current node of the visual tree.
+ * @param data
+ * The arbitrary data, built by a method <code>create</code>
+ * @param name
+ * Attribute name
+ * @param value
+ * Attribute value
+ * @return <code>true</code> if it is required to re-create an element at
+ * a modification of attribute, <code>false</code> otherwise.
+ */
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, Document visualDocument, Element visualNode,
+ Object data, String name, String value) {
+ return true;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessageTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessageTemplate.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessageTemplate.java 2007-09-20
11:41:40 UTC (rev 3730)
@@ -0,0 +1,512 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.richfaces.template;
+
+import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
+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.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/**
+ *
+ * @author ezheleznyakov(a)exadel.com
+ *
+ */
+public class RichFacesMessageTemplate extends VpeAbstractTemplate {
+
+ protected static String PASSED_LABEL_ATTRIBUTE_NAME = "passedLabel";
+ protected static String LABEL_CLASS_ATTRIBUTE_NAME = "labelClass";
+ protected static String MARKER_CLASS_ATTRIBUTE_NAME = "markerClass";
+ protected static String MARKER_STYLE_ATTRIBUTE_NAME = "markerStyle";
+
+ protected static String ERROR_MARKER_CLASS_ATTRIBUTE_NAME =
"errorMarkerClass";
+ protected static String ERROR_LABEL_CLASS_ATTRIBUTE_NAME = "errorLabelClass";
+ protected static String ERROR_CLASS_ATTRIBUTE_NAME = "errorClass";
+
+ protected static String FATAL_MARKER_CLASS_ATTRIBUTE_NAME =
"fatalMarkerClass";
+ protected static String FATAL_LABEL_CLASS_ATTRIBUTE_NAME = "fatalLabelClass";
+ protected static String FATAL_CLASS_ATTRIBUTE_NAME = "fatalClass";
+
+ protected static String INFO_MARKER_CLASS_ATTRIBUTE_NAME = "infoMarkerClass";
+ protected static String INFO_LABEL_CLASS_ATTRIBUTE_NAME = "infoLabelClass";
+ protected static String INFO_CLASS_ATTRIBUTE_NAME = "infoClass";
+
+ protected static String WARN_MARKER_CLASS_ATTRIBUTE_NAME = "warnMarkerClass";
+ protected static String WARN_LABEL_CLASS_ATTRIBUTE_NAME = "warnLabelClass";
+ protected static String WARN_CLASS_ATTRIBUTE_NAME = "warnClass";
+
+ protected static String ERROR_MESSAGE = "Error message";
+ protected static String FATAL_MESSAGE = "Fatal message";
+ protected static String INFO_MESSAGE = "Info message";
+ protected static String WARNING_MESSAGE = "Warning message";
+
+ protected String passedLabelValue;
+ protected String labelClassValue;
+ protected String markerClassValue;
+ protected String markerStyleValue;
+ protected String errorMarkerClassValue;
+ protected String errorLabelClassValue;
+ protected String errorClassValue;
+ protected String fatalMarkerClassValue;
+ protected String fatalLabelClassValue;
+ protected String fatalClassValue;
+ protected String infoMarkerClassValue;
+ protected String infoLabelClassValue;
+ protected String infoClassValue;
+ protected String warnMarkerClassValue;
+ protected String warnLabelClassValue;
+ protected String warnClassValue;
+ protected String styleValue;
+ protected String styleClassValue;
+
+ protected static String[] markers = { "passedMarker",
"errorMarker",
+ "fatalMarker", "infoMarker", "warnMarker" };
+
+ protected static String FACET_TAG_NAME = "f:facet";
+
+ protected static String NAME_ATTRIBUTE_NAME = "name";
+
+ private Element td1; // passed marker
+ private Element td2; // passed label
+
+ private Element tr2; // error message
+ private Element td3; // error marker
+ private Element td4; // error label
+
+ private Element tr3; // fatal message
+ private Element td5; // fatal marker
+ private Element td6; // fatal label
+
+ private Element tr4; // info message
+ private Element td7; // info marker
+ private Element td8; // info label
+
+ private Element tr5; // warn message
+ private Element td9; // warn marker
+ private Element td10; // warn label
+
+ protected VpeCreationData creationData;
+
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ Document visualDocument) {
+
+ passedLabelValue = ((Element) sourceNode)
+ .getAttribute(PASSED_LABEL_ATTRIBUTE_NAME);
+ labelClassValue = ((Element) sourceNode)
+ .getAttribute(LABEL_CLASS_ATTRIBUTE_NAME);
+ markerClassValue = ((Element) sourceNode)
+ .getAttribute(MARKER_CLASS_ATTRIBUTE_NAME);
+ markerStyleValue = ((Element) sourceNode)
+ .getAttribute(MARKER_STYLE_ATTRIBUTE_NAME);
+
+ errorMarkerClassValue = ((Element) sourceNode)
+ .getAttribute(ERROR_MARKER_CLASS_ATTRIBUTE_NAME);
+ errorLabelClassValue = ((Element) sourceNode)
+ .getAttribute(ERROR_LABEL_CLASS_ATTRIBUTE_NAME);
+ errorClassValue = ((Element) sourceNode)
+ .getAttribute(ERROR_CLASS_ATTRIBUTE_NAME);
+
+ fatalMarkerClassValue = ((Element) sourceNode)
+ .getAttribute(FATAL_MARKER_CLASS_ATTRIBUTE_NAME);
+ fatalLabelClassValue = ((Element) sourceNode)
+ .getAttribute(FATAL_LABEL_CLASS_ATTRIBUTE_NAME);
+ fatalClassValue = ((Element) sourceNode)
+ .getAttribute(FATAL_CLASS_ATTRIBUTE_NAME);
+
+ infoMarkerClassValue = ((Element) sourceNode)
+ .getAttribute(INFO_MARKER_CLASS_ATTRIBUTE_NAME);
+ infoLabelClassValue = ((Element) sourceNode)
+ .getAttribute(INFO_LABEL_CLASS_ATTRIBUTE_NAME);
+ infoClassValue = ((Element) sourceNode)
+ .getAttribute(INFO_CLASS_ATTRIBUTE_NAME);
+
+ warnMarkerClassValue = ((Element) sourceNode)
+ .getAttribute(WARN_MARKER_CLASS_ATTRIBUTE_NAME);
+ warnLabelClassValue = ((Element) sourceNode)
+ .getAttribute(WARN_LABEL_CLASS_ATTRIBUTE_NAME);
+ warnClassValue = ((Element) sourceNode)
+ .getAttribute(WARN_CLASS_ATTRIBUTE_NAME);
+
+ styleValue = ((Element) sourceNode)
+ .getAttribute(HtmlComponentUtil.HTML_STYLE_ATTR);
+ styleClassValue = ((Element) sourceNode)
+ .getAttribute(HtmlComponentUtil.HTML_STYLECLASS_ATTR);
+
+ createRichMessage(visualDocument, sourceNode);
+
+ return creationData;
+ }
+
+ protected void createRichMessage(Document visualDocument, Node sourceNode) {
+
+ // -------------------create common table
+ Element tableHeader = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+
+ creationData = new VpeCreationData(tableHeader);
+
+ Element tr = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+
+ // in this td append not f:facet
+ Element td01 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+
+ Element td02 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+
+ // ----------------create second table
+ Element table = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+
+ if (styleValue != null && !styleValue.trim().equals(""))
+ table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, styleValue);
+ if (styleClassValue != null && !styleClassValue.trim().equals(""))
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ styleClassValue);
+
+ // Create first row PASSED
+ Element tr1 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+
+ td1 = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
+
+ td1.setAttribute(HtmlComponentUtil.HTML_ALIGN_ATTR,
+ HtmlComponentUtil.HTML_ALIGN_RIGHT_VALUE);
+
+ // set markerClass
+ if (markerClassValue != null && !markerClassValue.trim().equals(""))
+ td1.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ markerClassValue);
+
+ // set markerStyle
+ if (markerStyleValue != null && !markerStyleValue.trim().equals(""))
+ td1.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ markerStyleValue);
+
+ td2 = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
+
+ // set labelClass
+ if (labelClassValue != null && !labelClassValue.trim().equals(""))
+ td2
+ .setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ labelClassValue);
+
+ Text passedText = visualDocument
+ .createTextNode(passedLabelValue == null ? ""
+ : passedLabelValue);
+ // ---------------------------------------------------------------------
+
+ // Create second row ERROR
+ tr2 = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR);
+
+ // set errorClass
+ if (errorClassValue != null && !errorClassValue.trim().equals(""))
+ tr2
+ .setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ errorClassValue);
+
+ td3 = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
+ td3.setAttribute(HtmlComponentUtil.HTML_ALIGN_ATTR,
+ HtmlComponentUtil.HTML_ALIGN_RIGHT_VALUE);
+
+ // set errorMarkerClass
+ if (errorMarkerClassValue != null
+ && !errorMarkerClassValue.trim().equals(""))
+ td3.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ errorMarkerClassValue);
+
+ td4 = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
+
+ // set errorLabelClass
+ if (errorLabelClassValue != null
+ && !errorLabelClassValue.trim().equals(""))
+ td4.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ errorLabelClassValue);
+
+ Text errorText = visualDocument.createTextNode(ERROR_MESSAGE);
+ // ---------------------------------------------------------------------
+
+ // Create third row FATAL
+ tr3 = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR);
+
+ // set fatalClass
+ if (fatalClassValue != null && !fatalClassValue.trim().equals(""))
+ tr3
+ .setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ fatalClassValue);
+
+ td5 = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
+ td5.setAttribute(HtmlComponentUtil.HTML_ALIGN_ATTR,
+ HtmlComponentUtil.HTML_ALIGN_RIGHT_VALUE);
+
+ // set fatalMarkerClass
+ if (fatalMarkerClassValue != null
+ && !fatalMarkerClassValue.trim().equals(""))
+ td5.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ fatalMarkerClassValue);
+
+ td6 = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
+
+ // set fatalLabelClass
+ if (fatalLabelClassValue != null
+ && !fatalLabelClassValue.trim().equals(""))
+ td6.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ fatalLabelClassValue);
+
+ Text fatalText = visualDocument.createTextNode(FATAL_MESSAGE);
+ // ---------------------------------------------------------------------
+
+ // Create four row INFO
+ tr4 = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR);
+
+ // set infoClass
+ if (infoClassValue != null && !infoClassValue.trim().equals(""))
+ tr4.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, infoClassValue);
+
+ td7 = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
+ td7.setAttribute(HtmlComponentUtil.HTML_ALIGN_ATTR,
+ HtmlComponentUtil.HTML_ALIGN_RIGHT_VALUE);
+
+ // set infoMarkerClass
+ if (infoMarkerClassValue != null
+ && !infoMarkerClassValue.trim().equals(""))
+ td7.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ infoMarkerClassValue);
+
+ td8 = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
+
+ // set infoLabelClass
+ if (infoLabelClassValue != null
+ && !infoLabelClassValue.trim().equals(""))
+ td8.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ infoLabelClassValue);
+
+ Text infoText = visualDocument.createTextNode(INFO_MESSAGE);
+ // ---------------------------------------------------------------------
+
+ // Create fifth row WARNING
+ tr5 = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR);
+
+ // set warnClass
+ if (warnClassValue != null && !warnClassValue.trim().equals(""))
+ tr5.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, warnClassValue);
+
+ td9 = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
+ td9.setAttribute(HtmlComponentUtil.HTML_ALIGN_ATTR,
+ HtmlComponentUtil.HTML_ALIGN_RIGHT_VALUE);
+
+ // set warnMarkerClass
+ if (warnMarkerClassValue != null
+ && !warnMarkerClassValue.trim().equals(""))
+ td9.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ warnMarkerClassValue);
+
+ td10 = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
+
+ // set warnLabelClass
+ if (warnLabelClassValue != null
+ && !warnLabelClassValue.trim().equals(""))
+ td10.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ warnLabelClassValue);
+
+ Text warnText = visualDocument.createTextNode(WARNING_MESSAGE);
+
+ NodeList nodeList = sourceNode.getChildNodes();
+
+ for (int i = 0; i < nodeList.getLength(); i++) {
+
+ if (!(nodeList.item(i) instanceof Element))
+ continue;
+
+ Element elemFacet = (Element) nodeList.item(i);
+ if (elemFacet.getNodeName().equalsIgnoreCase(FACET_TAG_NAME)
+ && searchInMarker(elemFacet
+ .getAttribute(NAME_ATTRIBUTE_NAME))) {
+
+ String markerName = elemFacet.getAttribute(NAME_ATTRIBUTE_NAME)
+ .trim();
+ // if f:facet not empty
+ if (elemFacet.getChildNodes().getLength() != 0)
+ if (markers[0].equalsIgnoreCase(markerName)) {
+ createVisualFacet(td1, elemFacet);
+ } else if (markers[1].equalsIgnoreCase(markerName)) {
+ createVisualFacet(td3, elemFacet);
+ } else if (markers[2].equalsIgnoreCase(markerName)) {
+ createVisualFacet(td5, elemFacet);
+ } else if (markers[3].equalsIgnoreCase(markerName)) {
+ createVisualFacet(td7, elemFacet);
+ } else if (markers[4].equalsIgnoreCase(markerName)) {
+ createVisualFacet(td9, elemFacet);
+ }
+ }
+ }
+
+ addNotFacetComponent(td01, sourceNode);
+
+ tableHeader.appendChild(tr);
+ tr.appendChild(td01);
+ tr.appendChild(td02);
+ td02.appendChild(table);
+
+ table.appendChild(tr1);
+ tr1.appendChild(td1);
+ tr1.appendChild(td2);
+ td2.appendChild(passedText);
+
+ table.appendChild(tr2);
+ tr2.appendChild(td3);
+ tr2.appendChild(td4);
+ td4.appendChild(errorText);
+
+ table.appendChild(tr3);
+ tr3.appendChild(td5);
+ tr3.appendChild(td6);
+ td6.appendChild(fatalText);
+
+ table.appendChild(tr4);
+ tr4.appendChild(td7);
+ tr4.appendChild(td8);
+ td8.appendChild(infoText);
+
+ table.appendChild(tr5);
+ tr5.appendChild(td9);
+ tr5.appendChild(td10);
+ td10.appendChild(warnText);
+ }
+
+ /**
+ * Checks, whether it is necessary to re-create an element at change of
+ * attribute
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceElement
+ * The current element of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @param visualNode
+ * The current node of the visual tree.
+ * @param data
+ * The arbitrary data, built by a method <code>create</code>
+ * @param name
+ * Atrribute name
+ * @param value
+ * Attribute value
+ * @return <code>true</code> if it is required to re-create an element at
+ * a modification of attribute, <code>false</code> otherwise.
+ */
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, Document visualDocument, Element visualNode,
+ Object data, String name, String value) {
+ return true;
+ }
+
+ /**
+ *
+ * @param td01
+ */
+ protected void addNotFacetComponent(Element td01, Node sourceNode) {
+
+ VpeChildrenInfo childrenInfo = new VpeChildrenInfo(td01);
+ creationData.addChildrenInfo(childrenInfo);
+
+ NodeList nodeList = sourceNode.getChildNodes();
+ for (int i = 0; i < nodeList.getLength(); i++)
+ if (!FACET_TAG_NAME.equalsIgnoreCase(nodeList.item(i).getNodeName()
+ .trim()))
+ childrenInfo.addSourceChild(nodeList.item(i));
+
+ }
+
+ /**
+ *
+ * @param markerName
+ * Marker name
+ * @return True if marker name correct or false
+ */
+ protected boolean searchInMarker(String markerName) {
+
+ if (markerName == null)
+ return false;
+
+ for (int i = 0; i < markers.length; i++)
+ if (markers[i].equalsIgnoreCase(markerName.trim()))
+ return true;
+ return false;
+ }
+
+ /**
+ *
+ * @param td
+ * @param elemFacet
+ */
+ protected void createVisualFacet(Element td, Element elemFacet) {
+ VpeChildrenInfo childrenInfo = new VpeChildrenInfo(td);
+ creationData.addChildrenInfo(childrenInfo);
+
+ NodeList nodeList = elemFacet.getChildNodes();
+
+ for (int i = 0; i < nodeList.getLength(); i++)
+ if (!(nodeList.item(i) instanceof Element))
+ continue;
+ else {
+ childrenInfo.addSourceChild(nodeList.item(i));
+ return;
+ }
+ }
+}
+
+// HTML code component
+// <html>
+// <body>
+//
+// <table border="1px" style="border: 2px solid black;">
+// <tr>
+// <td>
+// ssdfsd
+// <p/>
+// sdfsdf
+// </td>
+// <td>
+// <table border="1px" style="color: red; border: 2px solid blue;"
>
+// <tr>
+// <td></td>
+// <td>Passed message</td>
+// </tr>
+// <tr>
+// <td><img/></td>
+// <td>Error message</td>
+// </tr>
+// <tr>
+// <td></td>
+// <td>Fatal message</td>
+// </tr>
+// <tr>
+// <td></td>
+// <td>Info message</td>
+// </tr>
+// <tr>
+// <td></td>
+// <td>Warn message</td>
+// </tr>
+// </table>
+// </td>
+// <tr>
+// </table>
+// </body>
+// </html>
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessageTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessagesTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessagesTemplate.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessagesTemplate.java 2007-09-20
11:41:40 UTC (rev 3730)
@@ -0,0 +1,319 @@
+package org.jboss.tools.jsf.vpe.richfaces.template;
+
+import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+public class RichFacesMessagesTemplate extends RichFacesMessageTemplate {
+
+ private static String LAYOUT_ATTRIBUTE_NAME = "layout";
+ private static String LAYOUT_ATTRIBUTE_VALUE_TABLE = "table";
+
+ private String layoutValue;
+
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ Document visualDocument) {
+
+ passedLabelValue = ((Element) sourceNode)
+ .getAttribute(PASSED_LABEL_ATTRIBUTE_NAME);
+ labelClassValue = ((Element) sourceNode)
+ .getAttribute(LABEL_CLASS_ATTRIBUTE_NAME);
+ markerClassValue = ((Element) sourceNode)
+ .getAttribute(MARKER_CLASS_ATTRIBUTE_NAME);
+ markerStyleValue = ((Element) sourceNode)
+ .getAttribute(MARKER_STYLE_ATTRIBUTE_NAME);
+
+ errorMarkerClassValue = ((Element) sourceNode)
+ .getAttribute(ERROR_MARKER_CLASS_ATTRIBUTE_NAME);
+ errorLabelClassValue = ((Element) sourceNode)
+ .getAttribute(ERROR_LABEL_CLASS_ATTRIBUTE_NAME);
+ errorClassValue = ((Element) sourceNode)
+ .getAttribute(ERROR_CLASS_ATTRIBUTE_NAME);
+
+ fatalMarkerClassValue = ((Element) sourceNode)
+ .getAttribute(FATAL_MARKER_CLASS_ATTRIBUTE_NAME);
+ fatalLabelClassValue = ((Element) sourceNode)
+ .getAttribute(FATAL_LABEL_CLASS_ATTRIBUTE_NAME);
+ fatalClassValue = ((Element) sourceNode)
+ .getAttribute(FATAL_CLASS_ATTRIBUTE_NAME);
+
+ infoMarkerClassValue = ((Element) sourceNode)
+ .getAttribute(INFO_MARKER_CLASS_ATTRIBUTE_NAME);
+ infoLabelClassValue = ((Element) sourceNode)
+ .getAttribute(INFO_LABEL_CLASS_ATTRIBUTE_NAME);
+ infoClassValue = ((Element) sourceNode)
+ .getAttribute(INFO_CLASS_ATTRIBUTE_NAME);
+
+ warnMarkerClassValue = ((Element) sourceNode)
+ .getAttribute(WARN_MARKER_CLASS_ATTRIBUTE_NAME);
+ warnLabelClassValue = ((Element) sourceNode)
+ .getAttribute(WARN_LABEL_CLASS_ATTRIBUTE_NAME);
+ warnClassValue = ((Element) sourceNode)
+ .getAttribute(WARN_CLASS_ATTRIBUTE_NAME);
+
+ styleValue = ((Element) sourceNode)
+ .getAttribute(HtmlComponentUtil.HTML_STYLE_ATTR);
+ styleClassValue = ((Element) sourceNode)
+ .getAttribute(HtmlComponentUtil.HTML_STYLECLASS_ATTR);
+
+ layoutValue = ((Element) sourceNode)
+ .getAttribute(LAYOUT_ATTRIBUTE_NAME);
+
+ if (layoutValue != null
+ && LAYOUT_ATTRIBUTE_VALUE_TABLE.equalsIgnoreCase(layoutValue
+ .trim()))
+ createTableLayout(visualDocument, sourceNode);
+ else
+ createListLayout(visualDocument, sourceNode);
+
+ return creationData;
+ }
+
+ /**
+ * Create <rich:messages> with layout="table"
+ */
+ public void createTableLayout(Document visualDocument, Node sourceNode) {
+
+ createRichMessage(visualDocument, sourceNode);
+
+ }
+
+ /**
+ * Create <rich:messages> with layout="list"
+ */
+ public void createListLayout(Document visualDocument, Node sourceNode) {
+
+ Element table = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+
+ if (styleValue != null && !styleValue.trim().equals(""))
+ table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, styleValue);
+ if (styleClassValue != null && !styleClassValue.trim().equals(""))
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ styleClassValue);
+
+ creationData = new VpeCreationData(table);
+
+ Element tr = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+
+ Element td = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+
+ // create first td for PASSED
+ Element td1 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+
+ Element span1 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_SPAN);
+
+ // set markerClass
+ if (markerClassValue != null && !markerClassValue.trim().equals(""))
+ span1.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ markerClassValue);
+
+ // set markerStyle
+ if (markerStyleValue != null && !markerStyleValue.trim().equals(""))
+ span1.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ markerStyleValue);
+
+ Element span2 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_SPAN);
+
+ if (labelClassValue != null && !labelClassValue.trim().equals(""))
+ span2.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ labelClassValue);
+
+ Text passedText = visualDocument
+ .createTextNode(passedLabelValue == null ? ""
+ : passedLabelValue);
+ // -----------------------------------------------------------
+
+ // Create second td for ERROR
+ Element td2 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ // set errorClass
+ if (errorClassValue != null && !errorClassValue.trim().equals(""))
+ td2
+ .setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ errorClassValue);
+
+ Element span3 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_SPAN);
+
+ // set errorMarkerClass
+ if (errorMarkerClassValue != null
+ && !errorMarkerClassValue.trim().equals(""))
+ span3.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ errorMarkerClassValue);
+
+ Element span4 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_SPAN);
+
+ // set errorLabelClass
+ if (errorLabelClassValue != null
+ && !errorLabelClassValue.trim().equals(""))
+ span4.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ errorLabelClassValue);
+
+ Text errorText = visualDocument.createTextNode(ERROR_MESSAGE);
+ // -------------------------------------------------------------
+
+ // Create third td for FATAL
+ Element td3 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+
+ // set fatalClass
+ if (fatalClassValue != null && !fatalClassValue.trim().equals(""))
+ td3
+ .setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ fatalClassValue);
+
+ Element span5 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_SPAN);
+
+ // set fatalMarkerClass
+ if (fatalMarkerClassValue != null
+ && !fatalMarkerClassValue.trim().equals(""))
+ span5.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ fatalMarkerClassValue);
+
+ Element span6 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_SPAN);
+
+ // set fatalLabelClass
+ if (fatalLabelClassValue != null
+ && !fatalLabelClassValue.trim().equals(""))
+ span6.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ fatalLabelClassValue);
+
+ Text fatalText = visualDocument.createTextNode(FATAL_MESSAGE);
+ // ---------------------------------------------------------------------------
+
+ // Create four td for INFO
+
+ Element td4 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+
+ // set infoClass
+ if (infoClassValue != null && !infoClassValue.trim().equals(""))
+ td4.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, infoClassValue);
+
+ Element span7 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_SPAN);
+
+ // set infoMarkerClass
+ if (infoMarkerClassValue != null
+ && !infoMarkerClassValue.trim().equals(""))
+ span7.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ infoMarkerClassValue);
+
+ Element span8 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_SPAN);
+
+ // set infoLabelClass
+ if (infoLabelClassValue != null
+ && !infoLabelClassValue.trim().equals(""))
+ span8.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ infoLabelClassValue);
+
+ Text infoText = visualDocument.createTextNode(INFO_MESSAGE);
+ // --------------------------------------------------------------------
+
+ // Create fifth for WARN
+
+ Element td5 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+
+ // set warnClass
+ if (warnClassValue != null && !warnClassValue.trim().equals(""))
+ td5.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, warnClassValue);
+
+ Element span9 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_SPAN);
+
+ // set warnMarkerClass
+ if (warnMarkerClassValue != null
+ && !warnMarkerClassValue.trim().equals(""))
+ span9.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ warnMarkerClassValue);
+
+ Element span10 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_SPAN);
+
+ // set warnLabelClass
+ if (warnLabelClassValue != null
+ && !warnLabelClassValue.trim().equals(""))
+ span10.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ warnLabelClassValue);
+
+ Text warnText = visualDocument.createTextNode(WARNING_MESSAGE);
+ // ---------------------------------------------------------------------
+
+ NodeList nodeList = sourceNode.getChildNodes();
+
+ for (int i = 0; i < nodeList.getLength(); i++) {
+
+ if (!(nodeList.item(i) instanceof Element))
+ continue;
+
+ Element elemFacet = (Element) nodeList.item(i);
+
+ if (elemFacet.getNodeName().equalsIgnoreCase(FACET_TAG_NAME)
+ && searchInMarker(elemFacet
+ .getAttribute(NAME_ATTRIBUTE_NAME))) {
+
+ String markerName = elemFacet.getAttribute(NAME_ATTRIBUTE_NAME)
+ .trim();
+
+ if (elemFacet.getChildNodes().getLength() != 0)
+ if (markers[0].equalsIgnoreCase(markerName)) {
+ createVisualFacet(span1, elemFacet);
+ } else if (markers[1].equalsIgnoreCase(markerName)) {
+ createVisualFacet(span3, elemFacet);
+ } else if (markers[2].equalsIgnoreCase(markerName)) {
+ createVisualFacet(span5, elemFacet);
+ } else if (markers[3].equalsIgnoreCase(markerName)) {
+ createVisualFacet(span7, elemFacet);
+ } else if (markers[4].equalsIgnoreCase(markerName)) {
+ createVisualFacet(span9, elemFacet);
+ }
+ }
+ }
+
+ addNotFacetComponent(td, sourceNode);
+
+ table.appendChild(tr);
+ tr.appendChild(td);
+
+ tr.appendChild(td1);
+ td1.appendChild(span1);
+ td1.appendChild(span2);
+ span2.appendChild(passedText);
+
+ tr.appendChild(td2);
+ td2.appendChild(span3);
+ td2.appendChild(span4);
+ span4.appendChild(errorText);
+
+ tr.appendChild(td3);
+ td3.appendChild(span5);
+ td3.appendChild(span6);
+ span6.appendChild(fatalText);
+
+ tr.appendChild(td4);
+ td4.appendChild(span7);
+ td4.appendChild(span8);
+ span8.appendChild(infoText);
+
+ tr.appendChild(td5);
+ td5.appendChild(span9);
+ td5.appendChild(span10);
+ span10.appendChild(warnText);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessagesTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesVirtualEarthTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesVirtualEarthTemplate.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesVirtualEarthTemplate.java 2007-09-20
11:41:40 UTC (rev 3730)
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.richfaces.template;
+
+import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
+import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+/**
+ *
+ * @author ezheleznyakov(a)exadel.com
+ *
+ */
+public class RichFacesVirtualEarthTemplate extends VpeAbstractTemplate {
+
+ private static String EARTH_AERIAL = "/virtualearth/earth_aerial.png";
+ private static String EARTH_HYBRID = "/virtualearth/earth_hybrid.png";
+ private static String EARTH_ROAD = "/virtualearth/earth_road.png";
+
+ private static String MAP_STYLE_ATTRIBUTE_NAME = "mapStyle";
+
+ private static String MAP_STYLE_VALUES[] = { "road", "aerial",
"hybrid" };
+
+ private static String STYLE_CLASS_ATTR_NAME = "styleClass";
+
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ Document visualDocument) {
+
+ Element img = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_IMG);
+
+ String mapStyleValue = ((Element) sourceNode)
+ .getAttribute(MAP_STYLE_ATTRIBUTE_NAME);
+
+ if (mapStyleValue != null && searchInMapStyleValues(mapStyleValue)) {
+ if (mapStyleValue.equalsIgnoreCase(MAP_STYLE_VALUES[0]))
+ ComponentUtil.setImg(img, EARTH_ROAD);
+ else if (mapStyleValue.equalsIgnoreCase(MAP_STYLE_VALUES[1]))
+ ComponentUtil.setImg(img, EARTH_AERIAL);
+ else if (mapStyleValue.equalsIgnoreCase(MAP_STYLE_VALUES[2]))
+ ComponentUtil.setImg(img, EARTH_HYBRID);
+ } else
+ ComponentUtil.setImg(img, EARTH_ROAD);
+
+ copyStyleAttribute(img, sourceNode);
+
+ if (((Element) sourceNode).getAttribute(STYLE_CLASS_ATTR_NAME) != null)
+ img.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ ((Element) sourceNode).getAttribute(STYLE_CLASS_ATTR_NAME));
+
+ return new VpeCreationData(img);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
com.exadel.vpe.editor.template.VpeAbstractTemplate#setAttribute(com.exadel.vpe.editor.context.VpePageContext,
+ * org.w3c.dom.Element, org.w3c.dom.Document, org.w3c.dom.Node,
+ * java.lang.Object, java.lang.String, java.lang.String)
+ */
+ public void setAttribute(VpePageContext pageContext, Element sourceElement,
+ Document visualDocument, Node visualNode, Object data, String name,
+ String value) {
+
+ Element img = (Element) visualNode;
+
+ if (name.equalsIgnoreCase(MAP_STYLE_ATTRIBUTE_NAME)) {
+ if (value.trim().equalsIgnoreCase("")
+ || !searchInMapStyleValues(value)) {
+ ComponentUtil.setImg(img, EARTH_ROAD);
+ return;
+ }
+
+ if (value.equalsIgnoreCase(MAP_STYLE_VALUES[0]))
+ ComponentUtil.setImg(img, EARTH_ROAD);
+ else if (value.equalsIgnoreCase(MAP_STYLE_VALUES[1]))
+ ComponentUtil.setImg(img, EARTH_AERIAL);
+ else if (value.equalsIgnoreCase(MAP_STYLE_VALUES[2]))
+ ComponentUtil.setImg(img, EARTH_HYBRID);
+ return;
+ }
+
+ if (STYLE_CLASS_ATTR_NAME.equals(name))
+ img.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, value);
+ else
+ img.setAttribute(name, value);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
com.exadel.vpe.editor.template.VpeAbstractTemplate#removeAttribute(com.exadel.vpe.editor.context.VpePageContext,
+ * org.w3c.dom.Element, org.w3c.dom.Document, org.w3c.dom.Node,
+ * java.lang.Object, java.lang.String)
+ */
+ public void removeAttribute(VpePageContext pageContext,
+ Element sourceElement, Document visualDocument, Node visualNode,
+ Object data, String name) {
+
+ Element img = (Element) visualNode;
+
+ if (name.equalsIgnoreCase(MAP_STYLE_ATTRIBUTE_NAME)) {
+ ComponentUtil.setImg(img, EARTH_ROAD);
+ return;
+ }
+
+ if (STYLE_CLASS_ATTR_NAME.equals(name))
+ img.removeAttribute(HtmlComponentUtil.HTML_CLASS_ATTR);
+ else
+ img.removeAttribute(name);
+ }
+
+ /**
+ *
+ * @param value
+ * Value of mapStyle attribute
+ * @return True if value of mapStyle attribute correct or false
+ */
+ private boolean searchInMapStyleValues(String mapStyleValue) {
+
+ for (int i = 0; i < MAP_STYLE_VALUES.length; i++)
+ if (MAP_STYLE_VALUES[i].equalsIgnoreCase(mapStyleValue.trim()))
+ return true;
+ return false;
+ }
+
+ /**
+ *
+ * @param img
+ * @param sourceNode
+ * The current node of the source tree.
+ */
+ private void copyStyleAttribute(Element img, Node sourceNode) {
+ NamedNodeMap namedNodeMap = sourceNode.getAttributes();
+ for (int i = 0; i < namedNodeMap.getLength(); i++) {
+ Node attribute = namedNodeMap.item(i);
+ if (attribute.getNodeName().equalsIgnoreCase(
+ HtmlComponentUtil.HTML_STYLE_ATTR)) {
+ img.setAttribute(attribute.getNodeName(), attribute
+ .getNodeValue());
+ return;
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesVirtualEarthTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2007-09-20
09:03:53 UTC (rev 3729)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2007-09-20
11:41:40 UTC (rev 3730)
@@ -451,4 +451,86 @@
<vpe:template children="no" modify="no">
</vpe:template>
</vpe:tag>
+
+ <vpe:tag name="rich:virtualEarth" case-sensitive="yes">
+ <vpe:template children="no" modify="yes"
+
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesVirtualEarthTemplate">
+
+ <vpe:resize>
+ <vpe:width width-attr="style.width" />
+ <vpe:height height-attr="style.height" />
+ </vpe:resize>
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ <vpe:drop container="no"></vpe:drop>
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="rich:toolTip" case-sensitive="yes">
+ <vpe:template children="no" modify="yes">
+ <span style="display:none">
+ </span>
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="rich:effect" case-sensitive="yes">
+ <vpe:template children="no" modify="yes">
+ <span style="display:none">
+ </span>
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="rich:insert" case-sensetive="yes">
+ <vpe:template children="yes" modify="yes"
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesInsertTemplate">
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ <vpe:drop container="yes"/>
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="rich:message" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes"
+
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesMessageTemplate">
+
+ <vpe:resize>
+ <vpe:width width-attr="style.width" />
+ <vpe:height height-attr="style.height" />
+ </vpe:resize>
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ <vpe:drop container="yes"/>
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="rich:messages" case-sensitive="yes">
+ <vpe:template children="yes" modify="yes"
+
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesMessagesTemplate">
+
+ <vpe:resize>
+ <vpe:width width-attr="style.width" />
+ <vpe:height height-attr="style.height" />
+ </vpe:resize>
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ <vpe:drop container="yes"/>
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="rich:changeExpandListener"
case-sensitive="yes">
+ <vpe:template children="no" modify="yes">
+ <span style="display:none">
+ </span>
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="rich:nodeSelectListener" case-sensitive="yes">
+ <vpe:template children="no" modify="yes">
+ <span style="display:none">
+ </span>
+ </vpe:template>
+ </vpe:tag>
</vpe:templates>
\ No newline at end of file