Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbateman2007-01-24 01:22:45 +0000
committercbateman2007-01-24 01:22:45 +0000
commit46e5b6cef1829e8021e1cf5461c80e57a8137777 (patch)
tree946ea98e61f18c63be1a8ef6e1432dafbf571cb4 /jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/converter
parent7ac83c642d71b2634a8f6e751214d2dd4558db3d (diff)
downloadwebtools.jsf-46e5b6cef1829e8021e1cf5461c80e57a8137777.tar.gz
webtools.jsf-46e5b6cef1829e8021e1cf5461c80e57a8137777.tar.xz
webtools.jsf-46e5b6cef1829e8021e1cf5461c80e57a8137777.zip
Added the ILabelProvider concept to the HiddenTagConverter in order to defer the creation of hidden tag icon images until getImage is actually called on the tag converter.
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/converter')
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/converter/ConverterFactoryRegistry.java10
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/converter/HiddenTagConverter.java12
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/converter/jsp/JSPConverterFactory.java28
3 files changed, 40 insertions, 10 deletions
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/converter/ConverterFactoryRegistry.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/converter/ConverterFactoryRegistry.java
index 483ecdf9e..65abf05ad 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/converter/ConverterFactoryRegistry.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/converter/ConverterFactoryRegistry.java
@@ -14,6 +14,7 @@ package org.eclipse.jst.pagedesigner.converter;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jst.pagedesigner.IJMTConstants;
import org.eclipse.jst.pagedesigner.PDPlugin;
import org.eclipse.jst.pagedesigner.converter.html.HTMLConverterFactory;
@@ -99,7 +100,14 @@ public class ConverterFactoryRegistry {
int contentType = decl.getContentType();
if (contentType == CMElementDeclaration.EMPTY) {
// if the tag is empty, show it as icon.
- return new HiddenTagConverter(ele, getUnknownImage());
+ return new HiddenTagConverter(ele,
+ new LabelProvider()
+ {
+ public Image getImage(Object element) {
+ return getUnknownImage();
+ }
+ }
+ );
}
return new DefaultUnknownTagConverter(ele);
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/converter/HiddenTagConverter.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/converter/HiddenTagConverter.java
index fe9eb3245..1636cf7ee 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/converter/HiddenTagConverter.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/converter/HiddenTagConverter.java
@@ -14,6 +14,7 @@ package org.eclipse.jst.pagedesigner.converter;
import java.util.Collections;
import java.util.List;
+import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.w3c.dom.Element;
@@ -29,16 +30,18 @@ import org.w3c.dom.Node;
public class HiddenTagConverter implements ITagConverter {
private Element _hostElement;
- private Image _image;
+// private Image _image;
+ private ILabelProvider _labelProvider;
private int _mode;
/**
*
*/
- public HiddenTagConverter(Element host, Image image) {
+ public HiddenTagConverter(Element host, ILabelProvider labelProvider/*Image image*/) {
_hostElement = host;
- _image = image;
+ //_image = image;
+ _labelProvider = labelProvider;
}
/*
@@ -83,7 +86,8 @@ public class HiddenTagConverter implements ITagConverter {
* @see org.eclipse.jst.pagedesigner.visualtag.ITagConverter#getVisualImage()
*/
public Image getVisualImage() {
- return _image;
+ // defer the creation of the image until it is needed
+ return _labelProvider.getImage(this);
}
/*
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/converter/jsp/JSPConverterFactory.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/converter/jsp/JSPConverterFactory.java
index b969136d0..58060db2d 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/converter/jsp/JSPConverterFactory.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/converter/jsp/JSPConverterFactory.java
@@ -11,6 +11,7 @@
*******************************************************************************/
package org.eclipse.jst.pagedesigner.converter.jsp;
+import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jst.pagedesigner.IJMTConstants;
import org.eclipse.jst.pagedesigner.PDPlugin;
import org.eclipse.jst.pagedesigner.converter.HiddenTagConverter;
@@ -26,11 +27,13 @@ import org.w3c.dom.Element;
* @version 1.5
*/
public class JSPConverterFactory implements IConverterFactory {
+ private final ILabelProvider _labelProvider;
+
/**
*
*/
public JSPConverterFactory() {
- // do nothing
+ _labelProvider = new MyLabelProvider();
}
/*
@@ -40,7 +43,6 @@ public class JSPConverterFactory implements IConverterFactory {
*/
public ITagConverter createConverter(Element element, int mode) {
String tagName = element.getLocalName();
- Image image = getJSPSharedImage(tagName);
if (mode == IConverterFactory.MODE_PREVIEW) {
// we want to generate the included page in preview, so
@@ -62,7 +64,7 @@ public class JSPConverterFactory implements IConverterFactory {
c.setMode(mode);
return c;
} else {
- return new HiddenTagConverter(element, image);
+ return new HiddenTagConverter(element, _labelProvider);
}
}
if (IJSPCoreConstants.TAG_ROOT.equalsIgnoreCase(tagName)) {
@@ -71,14 +73,30 @@ public class JSPConverterFactory implements IConverterFactory {
c.setMode(mode);
return c;
}
- return new HiddenTagConverter(element, image);
+ return new HiddenTagConverter(element, _labelProvider);
}
+
+ private static class MyLabelProvider extends org.eclipse.jface.viewers.LabelProvider
+ {
+
+ public Image getImage(Object element)
+ {
+ if (element instanceof ITagConverter)
+ {
+ final Element hostElement = ((ITagConverter)element).getHostElement();
+ final String tagName = hostElement.getLocalName();
+ return getJSPSharedImage(tagName);
+ }
+
+ return null;
+ }
+ }
/**
* @param tagName
* @return
*/
- private Image getJSPSharedImage(String tagName) {
+ private static Image getJSPSharedImage(String tagName) {
Image image = PDPlugin.getDefault().getImage(
"palette/JSP/small/JSP_" + tagName.toUpperCase() + ".gif");
return image;

Back to the top