Author: dmaliarevich
Date: 2008-01-30 09:34:50 -0500 (Wed, 30 Jan 2008)
New Revision: 6031
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/resources/
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/src/org/jboss/tools/jsf/vpe/ajax4jsf/template/
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/src/org/jboss/tools/jsf/vpe/ajax4jsf/template/Ajax4JSFMediaOutput.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/META-INF/MANIFEST.MF
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/src/org/jboss/tools/jsf/vpe/ajax4jsf/Activator.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates/vpe-templates-ajax4jsf.xml
Log:
http://jira.jboss.com/jira/browse/JBIDE-1630
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/META-INF/MANIFEST.MF 2008-01-30
14:10:22 UTC (rev 6030)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/META-INF/MANIFEST.MF 2008-01-30
14:34:50 UTC (rev 6031)
@@ -7,6 +7,8 @@
Bundle-Localization: plugin
Require-Bundle: org.jboss.tools.vpe,
org.eclipse.ui,
- org.eclipse.core.runtime
+ org.eclipse.core.runtime,
+ org.jboss.tools.jst.jsp,
+ org.mozilla.xpcom
Eclipse-LazyStart: true
Bundle-Vendor: Red Hat, Inc.
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/src/org/jboss/tools/jsf/vpe/ajax4jsf/Activator.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/src/org/jboss/tools/jsf/vpe/ajax4jsf/Activator.java 2008-01-30
14:10:22 UTC (rev 6030)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/src/org/jboss/tools/jsf/vpe/ajax4jsf/Activator.java 2008-01-30
14:34:50 UTC (rev 6031)
@@ -10,7 +10,12 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.ajax4jsf;
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
/**
@@ -54,5 +59,16 @@
public static Activator getDefault() {
return plugin;
}
+
+ public static String getPluginResourcePath() {
+ Bundle bundle = Platform.getBundle(PLUGIN_ID);
+ URL url = null;
+ try {
+ url = bundle == null ? null :
FileLocator.resolve(bundle.getEntry("/resources"));
+ } catch (Exception e) {
+ url = bundle.getEntry("/resources");
+ }
+ return (url == null) ? null : url.getPath();
+ }
}
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/src/org/jboss/tools/jsf/vpe/ajax4jsf/template/Ajax4JSFMediaOutput.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/src/org/jboss/tools/jsf/vpe/ajax4jsf/template/Ajax4JSFMediaOutput.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/src/org/jboss/tools/jsf/vpe/ajax4jsf/template/Ajax4JSFMediaOutput.java 2008-01-30
14:34:50 UTC (rev 6031)
@@ -0,0 +1,66 @@
+package org.jboss.tools.jsf.vpe.ajax4jsf.template;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.jboss.tools.jsf.vpe.ajax4jsf.Activator;
+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.Node;
+
+public class Ajax4JSFMediaOutput extends VpeAbstractTemplate {
+
+ public static final String ALT_MEDIA_OTPUT = " mediaOutput";
+
+ public static final String HTML_TAG_DIV = "DIV";
+ public static final String HTML_TAG_IMG = "IMG";
+
+ public static final String ATTR_WIDTH = "WIDTH";
+ public static final String ATTR_HEIGHT = "HEIGHT";
+ public static final String ATTR_SRC = "src";
+ public static final String ATTR_ALT = "alt";
+
+ public static final String IMG_PATH = "mediaOutput/mediaOutput.jpg";
+
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+
+ nsIDOMElement mainDiv = visualDocument
+ .createElement(HTML_TAG_DIV);
+ nsIDOMElement img = visualDocument
+ .createElement(HTML_TAG_IMG);
+
+ img.setAttribute(ATTR_SRC, "file:///" + getAbsoluteResourcePath(IMG_PATH));
+ img.setAttribute(ATTR_ALT, ALT_MEDIA_OTPUT);
+ img.setAttribute(ATTR_WIDTH, "100");
+ img.setAttribute(ATTR_HEIGHT, "50");
+
+ mainDiv.appendChild(img);
+
+ return new VpeCreationData(mainDiv);
+ }
+
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement visualNode, Object data, String name, String value) {
+ return true;
+ }
+
+ public static String getAbsoluteResourcePath(String resourcePathInPlugin) {
+ String pluginPath = Activator.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);
+ }
+ }
+
+}
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/src/org/jboss/tools/jsf/vpe/ajax4jsf/template/Ajax4JSFMediaOutput.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.ajax4jsf/templates/vpe-templates-ajax4jsf.xml
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates/vpe-templates-ajax4jsf.xml 2008-01-30
14:10:22 UTC (rev 6030)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates/vpe-templates-ajax4jsf.xml 2008-01-30
14:34:50 UTC (rev 6031)
@@ -249,10 +249,9 @@
</vpe:tag>
<vpe:tag name="a4j:mediaOutput" case-sensitive="yes">
- <vpe:template children="no" modify="no">
- <div class="{@styleClass}" style="{@style}"
size="{@size}">
- mediaOutput
- </div>
+ <vpe:template children="no" modify="no"
+
class="org.jboss.tools.jsf.vpe.ajax4jsf.template.Ajax4JSFMediaOutput">
+
</vpe:template>
</vpe:tag>