Author: vrubezhny
Date: 2008-12-02 13:55:44 -0500 (Tue, 02 Dec 2008)
New Revision: 12221
Added:
trunk/common/plugins/org.jboss.tools.common.kb/images/
trunk/common/plugins/org.jboss.tools.common.kb/images/ca/
trunk/common/plugins/org.jboss.tools.common.kb/images/ca/icons_Enumeration.gif
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/build.properties
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbPlugin.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldStore.java
Log:
JBIDE-3133 New icons for proposals in JSF/Seam Code Assist.
The icons support and a set of common icons are added to the KB.
Modified: trunk/common/plugins/org.jboss.tools.common.kb/build.properties
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/build.properties 2008-12-02 18:40:04
UTC (rev 12220)
+++ trunk/common/plugins/org.jboss.tools.common.kb/build.properties 2008-12-02 18:55:44
UTC (rev 12221)
@@ -7,7 +7,8 @@
docs/,\
about.html,\
META-INF/,\
- kb.jar
+ kb.jar,\
+ images/
jars.compile.order = kb.jar
output.kb.jar = bin/
source.kb.jar = src/,\
Added: trunk/common/plugins/org.jboss.tools.common.kb/images/ca/icons_Enumeration.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/common/plugins/org.jboss.tools.common.kb/images/ca/icons_Enumeration.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbPlugin.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbPlugin.java 2008-12-02
18:40:04 UTC (rev 12220)
+++
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbPlugin.java 2008-12-02
18:55:44 UTC (rev 12221)
@@ -12,9 +12,13 @@
import java.io.File;
import java.io.IOException;
+import java.util.HashMap;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.jboss.tools.common.kb.configuration.KbConfigurationFactory;
import org.jboss.tools.common.log.BaseUIPlugin;
import org.jboss.tools.common.log.IPluginLog;
@@ -31,6 +35,11 @@
// The shared instance
private static KbPlugin plugin;
+ // A Map to save a descriptor for each image
+ private HashMap fImageDescRegistry = null;
+
+ public static final String CA_ENUMERATION_IMAGE_PATH =
"images/ca/icons_Enumeration.gif";
+
public KbPlugin() {
}
@@ -86,4 +95,104 @@
public static IPluginLog getPluginLog() {
return getDefault();
}
+
+ /**
+ * Creates an image from the given resource and adds the image to the
+ * image registry.
+ *
+ * @param resource
+ * @return Image
+ */
+ private Image createImage(String resource) {
+ ImageDescriptor desc = getImageDescriptorFromRegistry(resource);
+ Image image = null;
+
+ if (desc != null) {
+ image = desc.createImage();
+ // dont add the missing image descriptor image to the image
+ // registry
+ if (!desc.equals(ImageDescriptor.getMissingImageDescriptor())) {
+ getImageRegistry().put(resource, image);
+ }
+ }
+ return image;
+ }
+
+ /**
+ * Creates an image descriptor from the given imageFilePath and adds the
+ * image descriptor to the image descriptor registry. If an image
+ * descriptor could not be created, the default "missing" image descriptor
+ * is returned but not added to the image descriptor registry.
+ *
+ * @param imageFilePath
+ * @return ImageDescriptor image descriptor for imageFilePath or default
+ * "missing" image descriptor if resource could not be found
+ */
+ private ImageDescriptor createImageDescriptor(String imageFilePath) {
+ ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID,
imageFilePath);
+ if (imageDescriptor != null) {
+ getImageDescriptorRegistry().put(imageFilePath, imageDescriptor);
+ }
+ else {
+ imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
+ }
+
+ return imageDescriptor;
+ }
+
+ /**
+ * Retrieves the image associated with resource from the image registry.
+ * If the image cannot be retrieved, attempt to find and load the image at
+ * the location specified in resource.
+ *
+ * @param resource
+ * the image to retrieve
+ * @return Image the image associated with resource or null if one could
+ * not be found
+ */
+ public Image getImage(String resource) {
+ Image image = getImageRegistry().get(resource);
+ if (image == null) {
+ // create an image
+ image = createImage(resource);
+ }
+ return image;
+ }
+
+ /**
+ * Retrieves the image descriptor associated with resource from the image
+ * descriptor registry. If the image descriptor cannot be retrieved,
+ * attempt to find and load the image descriptor at the location specified
+ * in resource.
+ *
+ * @param resource
+ * the image descriptor to retrieve
+ * @return ImageDescriptor the image descriptor assocated with resource or
+ * the default "missing" image descriptor if one could not be
+ * found
+ */
+ public ImageDescriptor getImageDescriptorFromRegistry(String resource) {
+ ImageDescriptor imageDescriptor = null;
+ Object o = getImageDescriptorRegistry().get(resource);
+ if (o == null) {
+ // create a descriptor
+ imageDescriptor = createImageDescriptor(resource);
+ }
+ else {
+ imageDescriptor = (ImageDescriptor) o;
+ }
+ return imageDescriptor;
+ }
+
+ /**
+ * Returns the image descriptor registry for this plugin.
+ *
+ * @return HashMap - image descriptor registry for this plugin
+ */
+ private HashMap getImageDescriptorRegistry() {
+ if (fImageDescRegistry == null) {
+ fImageDescRegistry = new HashMap();
+ }
+ return fImageDescRegistry;
+ }
}
\ No newline at end of file
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java 2008-12-02
18:40:04 UTC (rev 12220)
+++
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java 2008-12-02
18:55:44 UTC (rev 12221)
@@ -12,6 +12,8 @@
import java.io.Serializable;
+import org.eclipse.swt.graphics.Image;
+
/**
* Describes a proposal for content assistants
* @author igels
@@ -32,6 +34,8 @@
private String label;
private String contextInfo;
+ private Image image;
+ private boolean emptyImage = true;
private String replacementString;
private boolean emptyContextInfo = true;
private int relevance = R_NONE;
@@ -67,6 +71,13 @@
}
/**
+ * @return
+ */
+ public Image getImage() {
+ return image;
+ }
+
+ /**
* @return
*/
public String getLabel() {
@@ -93,6 +104,16 @@
/**
* @param string
*/
+ public void setImage(Image img) {
+ this.image = img;
+ if(this.image != null) {
+ emptyImage = false;
+ }
+ }
+
+ /**
+ * @param string
+ */
public void setLabel(String string) {
label = string;
}
@@ -114,6 +135,13 @@
/**
* @return
*/
+ public boolean hasImage() {
+ return !emptyImage;
+ }
+
+ /**
+ * @return
+ */
public int getPosition() {
if(position==-1 && getReplacementString()!=null) {
return getReplacementString().length();
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldStore.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldStore.java 2008-12-02
18:40:04 UTC (rev 12220)
+++
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldStore.java 2008-12-02
18:55:44 UTC (rev 12221)
@@ -796,7 +796,7 @@
proposal.setReplacementString(value);
proposal.setContextInfo(null);
proposal.setPosition(value.length());
-
+ proposal.setImage(KbPlugin.getDefault().getImage(KbPlugin.CA_ENUMERATION_IMAGE_PATH));
enumeration.add(proposal);
}
}
Show replies by date