Skip to content

Commit f7c8ac4

Browse files
committed
disabled icon logic
1 parent 99aee45 commit f7c8ac4

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
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-2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,22 @@ public ImageData getImageData(int zoom) {
9999
return URLImageDescriptor.getImageData(url, zoom);
100100
}
101101

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+
}
102118
}
103119

104120
private static long cumulativeTime;
@@ -166,15 +182,31 @@ private static ImageData getImageData(String url, int zoom) {
166182
return null;
167183
}
168184

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+
169197
private static ImageData getImageData(URL url) {
170-
return getImageData(url, 0);
198+
return getImageData(url, 0, SWT.IMAGE_COPY);
171199
}
172200

173201
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) {
174206
ImageData result = null;
175207
try (InputStream in = getStream(url)) {
176208
if (in != null) {
177-
result = new ImageData(in, zoom);
209+
result = new ImageData(in, zoom, flag);
178210
}
179211
} catch (SWTException e) {
180212
if (e.code != SWT.ERROR_INVALID_IMAGE) {

0 commit comments

Comments
 (0)