Author: ezheleznyakov
Date: 2007-08-28 12:42:36 -0400 (Tue, 28 Aug 2007)
New Revision: 3392
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/virtualearth/
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/virtualearth/earth_aerial.jpg
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/virtualearth/earth_hybrid.jpg
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/virtualearth/earth_road.jpg
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesVirtualEarthTemplate.java
Modified:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/META-INF/MANIFEST.MF
Log:
Create <rich:virtualEarth> template
Modified:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/META-INF/MANIFEST.MF
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/META-INF/MANIFEST.MF 2007-08-28
16:04:41 UTC (rev 3391)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/META-INF/MANIFEST.MF 2007-08-28
16:42:36 UTC (rev 3392)
@@ -12,6 +12,7 @@
org.jboss.tools.common.model,
org.eclipse.wst.sse.ui,
org.eclipse.ui.workbench.texteditor,
- org.eclipse.ui.ide
+ org.eclipse.ui.ide,
+ org.mozilla.xpcom
Eclipse-LazyStart: true
Bundle-Vendor: Red Hat, Inc.
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/virtualearth/earth_aerial.jpg
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/virtualearth/earth_aerial.jpg
___________________________________________________________________
Name: svn:mime-type
+ image/jpeg
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/virtualearth/earth_hybrid.jpg
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/virtualearth/earth_hybrid.jpg
___________________________________________________________________
Name: svn:mime-type
+ image/jpeg
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/virtualearth/earth_road.jpg
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/virtualearth/earth_road.jpg
___________________________________________________________________
Name: svn:mime-type
+ image/jpeg
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesVirtualEarthTemplate.java
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesVirtualEarthTemplate.java
(rev 0)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesVirtualEarthTemplate.java 2007-08-28
16:42:36 UTC (rev 3392)
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * 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.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+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.jpg";
+ private static String EARTH_HYBRID = "/virtualearth/earth_hybrid.jpg";
+ private static String EARTH_ROAD = "/virtualearth/earth_road.jpg";
+
+ 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";
+
+ @Override
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+
+ nsIDOMElement 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);
+ }
+
+ /**
+ *
+ * @param value
+ * Value of mapStyle attribute
+ * @return True or 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(nsIDOMElement 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:
branches/jbosstools_xulrunner/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