Author: dmaliarevich
Date: 2008-05-28 04:38:30 -0400 (Wed, 28 May 2008)
New Revision: 8390
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/unresolved_image.gif
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.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-2043,
Template was added for <img> tag, if there is an alt attribute it is displayed,
otherwise unknown images is displayed.
Method in VpeStyleUtil was corrected, references to this method in Panel Menu Group and
Item were corrected.
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/unresolved_image.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/unresolved_image.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java 2008-05-28
08:38:22 UTC (rev 8389)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/VpePlugin.java 2008-05-28
08:38:30 UTC (rev 8390)
@@ -107,5 +107,16 @@
}
}
+ 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();
+ }
+
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2008-05-28
08:38:22 UTC (rev 8389)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2008-05-28
08:38:30 UTC (rev 8390)
@@ -84,6 +84,8 @@
public static final String ATTR_ROWS = "rows"; //$NON-NLS-1$
public static final String ATTR_COLS = "cols"; //$NON-NLS-1$
public static final String ATTR_VALIGN = "valign"; //$NON-NLS-1$
+ public static final String ATTR_SRC = "src"; //$NON-NLS-1$
+ public static final String ATTR_ALT = "alt"; //$NON-NLS-1$
public static final String VALUE_TOP_ALIGN = "top"; //$NON-NLS-1$
public static final String VALUE_MIDDLE_ALIGN = "middle"; //$NON-NLS-1$
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-05-28
08:38:22 UTC (rev 8389)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2008-05-28
08:38:30 UTC (rev 8390)
@@ -26,6 +26,7 @@
import org.jboss.tools.common.model.project.IModelNature;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.jst.web.project.WebProject;
+import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.css.ResourceReference;
@@ -38,8 +39,10 @@
public class VpeStyleUtil {
- public static final String ATTRIBUTE_STYLE = "style"; //$NON-NLS-1$
+ public static final String UNRESOLVED_IMAGE_PATH =
"org/jboss/tools/vpe/editor/mozilla/icons/unresolved_image.gif"; //$NON-NLS-1$
+ public static final String ATTRIBUTE_STYLE = "style"; //$NON-NLS-1$
+
public static final String PARAMETER_POSITION = "position"; //$NON-NLS-1$
public static final String PARAMETER_TOP = "top"; //$NON-NLS-1$
public static final String PARAMETER_LEFT = "left"; //$NON-NLS-1$
@@ -517,23 +520,36 @@
*
* @param path image "src" attribute value
* @param pageContext the pageContext
+ * @param showUnresolvedImage flag to display unresolved image
*
* @return the full path to image "src" attribute
*/
public static String addFullPathToImgSrc(String path,
- VpePageContext pageContext) {
+ VpePageContext pageContext, boolean showUnresolvedImage) {
IPath tagPath = new Path(path);
if (tagPath.isEmpty()) {
- return path;
+ if (showUnresolvedImage) {
+ return FILE_PROTOCOL + SLASH + SLASH
+ + getAbsoluteResourcePath(UNRESOLVED_IMAGE_PATH);
+ } else {
+ return path;
+ }
}
+
+
String device = (tagPath.getDevice() == null ? tagPath.segment(0)
: tagPath.getDevice());
if (device != null
&& (HTTP_PROTOCOL.equalsIgnoreCase(device) || FILE_PROTOCOL
.equalsIgnoreCase(device))) {
- return path;
+ if (showUnresolvedImage) {
+ return FILE_PROTOCOL + SLASH + SLASH
+ + getAbsoluteResourcePath(UNRESOLVED_IMAGE_PATH);
+ } else {
+ return path;
+ }
}
File locFile = tagPath.toFile();
@@ -593,7 +609,12 @@
}
}
}
- return path;
+ if (showUnresolvedImage) {
+ return FILE_PROTOCOL + SLASH + SLASH
+ + getAbsoluteResourcePath(UNRESOLVED_IMAGE_PATH);
+ } else {
+ return path;
+ }
}
/**
@@ -684,5 +705,17 @@
.getDOMDocument().createTextNode(text));
}
+
+ public static String getAbsoluteResourcePath(String resourcePathInPlugin) {
+ String pluginPath = VpePlugin.getPluginResourcePath();
+ IPath pluginFile = new Path(pluginPath);
+ File file = pluginFile.append(resourcePathInPlugin).toFile();
+ if (file.exists()) {
+ return file.getAbsolutePath();
+ } else {
+ throw new RuntimeException("Can't get path for " //$NON-NLS-1$
+ + resourcePathInPlugin);
+ }
+ }
}
\ No newline at end of file