Skip to content

Commit 0823bfe

Browse files
committed
disabled icon logic
1 parent c78cac3 commit 0823bfe

File tree

4 files changed

+36
-9
lines changed

4 files changed

+36
-9
lines changed

bundles/org.eclipse.jface/src/org/eclipse/jface/resource/FileImageDescriptor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public ImageData getImageData(int zoom) {
126126
InputStream in = getStream(zoom);
127127
if (in != null) {
128128
try (BufferedInputStream stream = new BufferedInputStream(in)) {
129-
return new ImageData(stream, zoom);
129+
return new ImageData(stream, zoom, SWT.IMAGE_COPY);
130130
} catch (SWTException e) {
131131
if (e.code != SWT.ERROR_INVALID_IMAGE) {
132132
throw e;

bundles/org.eclipse.jface/src/org/eclipse/jface/resource/URLImageDescriptor.java

+34-4
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
import org.eclipse.swt.graphics.ImageData;
4040
import org.eclipse.swt.graphics.ImageDataProvider;
4141
import org.eclipse.swt.graphics.ImageFileNameProvider;
42-
import org.eclipse.swt.graphics.SVGRasterizer;
43-
import org.eclipse.swt.graphics.SVGRasterizerRegistry;
4442

4543
/**
4644
* An ImageDescriptor that gets its information from a URL. This class is not
@@ -101,6 +99,22 @@ public ImageData getImageData(int zoom) {
10199
return URLImageDescriptor.getImageData(url, zoom);
102100
}
103101

102+
@Override
103+
public ImageData getCustomizedImageData(int zoom, int flag) {
104+
return URLImageDescriptor.getCustomizedImageData(url, zoom, flag);
105+
}
106+
107+
@Override
108+
public boolean supportsRasterizationFlag(int flag) {
109+
boolean supportsFlag = flag == SWT.IMAGE_DISABLE || flag == SWT.IMAGE_GRAY || flag == SWT.IMAGE_COPY;
110+
URL tempURL = getURL(url);
111+
if (tempURL != null) {
112+
if (tempURL.toString().endsWith(".svg") && supportsFlag) { //$NON-NLS-1$
113+
return true;
114+
}
115+
}
116+
return false;
117+
}
104118
}
105119

106120
private static long cumulativeTime;
@@ -168,15 +182,31 @@ private static ImageData getImageData(String url, int zoom) {
168182
return null;
169183
}
170184

185+
private static ImageData getCustomizedImageData(String url, int zoom, int flag) {
186+
URL tempURL = getURL(url);
187+
if (tempURL != null) {
188+
try (InputStream in = getStream(tempURL)) {
189+
return getImageData(tempURL, zoom, flag);
190+
} catch (IOException e) {
191+
// ignore.
192+
}
193+
}
194+
return null;
195+
}
196+
171197
private static ImageData getImageData(URL url) {
172-
return getImageData(url, 0);
198+
return getImageData(url, 0, SWT.IMAGE_COPY);
173199
}
174200

175201
private static ImageData getImageData(URL url, int zoom) {
202+
return getImageData(url, zoom, SWT.IMAGE_COPY);
203+
}
204+
205+
private static ImageData getImageData(URL url, int zoom, int flag) {
176206
ImageData result = null;
177207
try (InputStream in = getStream(url)) {
178208
if (in != null) {
179-
result = new ImageData(in, zoom);
209+
result = new ImageData(in, zoom, flag);
180210
}
181211
} catch (SWTException e) {
182212
if (e.code != SWT.ERROR_INVALID_IMAGE) {

bundles/org.eclipse.ui.workbench/META-INF/MANIFEST.MF

+1-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)",
113113
org.eclipse.e4.ui.workbench.addons.swt;bundle-version="0.10.0",
114114
org.eclipse.e4.ui.services;bundle-version="1.3.0",
115115
org.eclipse.emf.ecore.xmi;bundle-version="2.11.0",
116-
org.eclipse.e4.core.di.extensions;bundle-version="0.13.0",
117-
org.eclipse.swt.svg;bundle-version="1.0.0"
116+
org.eclipse.e4.core.di.extensions;bundle-version="0.13.0"
118117
Import-Package: com.ibm.icu.util,
119118
jakarta.annotation;version="[2.1.0,3.0.0)",
120119
jakarta.inject;version="[2.0.0,3.0.0)",

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/Workbench.java

-2
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@
156156
import org.eclipse.swt.graphics.Point;
157157
import org.eclipse.swt.graphics.Rectangle;
158158
import org.eclipse.swt.graphics.Transform;
159-
import org.eclipse.swt.svg.JSVGRasterizer;
160159
import org.eclipse.swt.widgets.Display;
161160
import org.eclipse.swt.widgets.Listener;
162161
import org.eclipse.swt.widgets.Monitor;
@@ -568,7 +567,6 @@ public static Workbench getInstance() {
568567
*/
569568
public static int createAndRunWorkbench(final Display display, final WorkbenchAdvisor advisor) {
570569
final int[] returnCode = new int[1];
571-
JSVGRasterizer.intializeJSVGRasterizer();
572570
Realm.runWithDefault(DisplayRealm.getRealm(display), () -> {
573571
boolean showProgress = PrefUtil.getAPIPreferenceStore()
574572
.getBoolean(IWorkbenchPreferenceConstants.SHOW_PROGRESS_ON_STARTUP);

0 commit comments

Comments
 (0)