Author: scabanovich
Date: 2011-12-01 17:02:50 -0500 (Thu, 01 Dec 2011)
New Revision: 36850
Modified:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/CSSPlugin.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/dialog/AbstractCSSDialog.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/dialog/widgets/ImageCombo.java
Log:
JBIDE-10228
https://issues.jboss.org/browse/JBIDE-10228
ImageRegistry is used to manage images.
Modified:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/CSSPlugin.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/CSSPlugin.java 2011-12-01
20:21:57 UTC (rev 36849)
+++
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/CSSPlugin.java 2011-12-01
22:02:50 UTC (rev 36850)
@@ -32,6 +32,7 @@
* The constructor
*/
public CSSPlugin() {
+ plugin = this;
}
/*
@@ -43,7 +44,6 @@
*/
public void start(BundleContext context) throws Exception {
super.start(context);
- plugin = this;
}
/*
@@ -54,7 +54,6 @@
* )
*/
public void stop(BundleContext context) throws Exception {
- plugin = null;
super.stop(context);
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/dialog/AbstractCSSDialog.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/dialog/AbstractCSSDialog.java 2011-12-01
20:21:57 UTC (rev 36849)
+++
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/dialog/AbstractCSSDialog.java 2011-12-01
22:02:50 UTC (rev 36850)
@@ -83,8 +83,7 @@
/*
* Set the dialog image
*/
- setTitleImage(ModelUIImages.getImageDescriptor(
- ModelUIImages.WIZARD_DEFAULT).createImage());
+ setTitleImage(ModelUIImages.getImage(ModelUIImages.WIZARD_DEFAULT));
Composite parentComposite = (Composite) super.createDialogArea(parent);
GridData gridData = (GridData) parentComposite.getLayoutData();
Modified:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/dialog/widgets/ImageCombo.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/dialog/widgets/ImageCombo.java 2011-12-01
20:21:57 UTC (rev 36849)
+++
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/dialog/widgets/ImageCombo.java 2011-12-01
22:02:50 UTC (rev 36850)
@@ -12,10 +12,9 @@
import java.util.Arrays;
+import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
@@ -39,6 +38,7 @@
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.TypedListener;
import org.eclipse.swt.widgets.Widget;
+import org.jboss.tools.jst.css.CSSPlugin;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
import org.jboss.tools.jst.jsp.util.Constants;
@@ -232,17 +232,10 @@
TableItem newItem = new TableItem(this.table, SWT.NONE);
newItem.setText(string);
-
- if (image != null) {
- newItem.setImage(image);
+
+ if(image != null) {
+ newItem.setImage(image);
}
-
- newItem.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- TableItem item = (TableItem) e.getSource();
- item.getImage().dispose();
- }
- });
}
/**
@@ -289,12 +282,6 @@
if (image != null) {
newItem.setImage(image);
- newItem.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- TableItem item = (TableItem) e.getSource();
- item.getImage().dispose();
- }
- });
}
}
@@ -321,6 +308,21 @@
* @see #add(String,int)
*/
public void add(String string, RGB rgb) {
+ add(string, getImageByColor(string, rgb));
+ }
+
+ Image getImageByColor(String string, RGB rgb) {
+ ImageRegistry registry = CSSPlugin.getDefault().getImageRegistry();
+ Image result = registry.get(string);
+ if(result == null) {
+ result = newImageByColor(string, rgb);
+ registry.put(string, result);
+ }
+ return result;
+ }
+
+ private Image newImageByColor(String string, RGB rgb) {
+ System.out.println("-->" + string);
Color white = new Color(getDisplay(), Constants.RGB_WHITE);
Color black = new Color(getDisplay(), Constants.RGB_BLACK);
Color color = new Color(getDisplay(), rgb);
@@ -353,7 +355,7 @@
color.dispose();
black.dispose();
white.dispose();
- add(string, icon);
+ return icon;
}
/**