mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
images: choose same HiDPI icon when requested is absent
This commit is contained in:
@@ -15,14 +15,60 @@
|
||||
*/
|
||||
package org.jetbrains.idea.devkit.icons;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.intellij.images.thumbnail.actions.ThemeFilter;
|
||||
|
||||
public enum Theme {
|
||||
WHITE(null, "Default"),
|
||||
HIGH_DPI_WHITE("@2x", "Default HiDPI"),
|
||||
DARK("dark", "Darcula"),
|
||||
HIGH_DPI_DARK("@2x_dark", "Darcula HiDPI");
|
||||
public enum Theme implements ThemeFilter{
|
||||
WHITE(null, "Default") {
|
||||
@Override
|
||||
public boolean accepts(VirtualFile fileName) {
|
||||
String nameWithoutExtension = FileUtil.getNameWithoutExtension(fileName.getName());
|
||||
for (Theme theme : values()) {
|
||||
String extension = theme.getExtension();
|
||||
if (extension != null && nameWithoutExtension.endsWith(extension)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
},
|
||||
HIGH_DPI_WHITE("@2x", "Default HiDPI") {
|
||||
@Override
|
||||
public boolean accepts(VirtualFile fileName) {
|
||||
return FileUtil.getNameWithoutExtension(fileName.getName()).endsWith(getExtension());
|
||||
}
|
||||
},
|
||||
DARK("_dark", "Darcula") {
|
||||
@Override
|
||||
public boolean accepts(VirtualFile file) {
|
||||
String name = FileUtil.getNameWithoutExtension(file.getName());
|
||||
if (name.endsWith(getExtension()) && !name.endsWith(HIGH_DPI_DARK.getExtension())) {
|
||||
return true;
|
||||
}
|
||||
VirtualFile parent = file.getParent();
|
||||
if (parent != null && parent.findChild(name + "_dark.png") != null) {
|
||||
return false;
|
||||
}
|
||||
return WHITE.accepts(file);
|
||||
}
|
||||
},
|
||||
HIGH_DPI_DARK("@2x_dark", "Darcula HiDPI") {
|
||||
@Override
|
||||
public boolean accepts(VirtualFile file) {
|
||||
String name = FileUtil.getNameWithoutExtension(file.getName());
|
||||
if (name.endsWith(getExtension())) {
|
||||
return true;
|
||||
}
|
||||
VirtualFile parent = file.getParent();
|
||||
if (parent != null && parent.findChild(name + "_dark.png") != null) {
|
||||
return false;
|
||||
}
|
||||
return HIGH_DPI_WHITE.accepts(file);
|
||||
}
|
||||
};
|
||||
private final String myExtension;
|
||||
private final String myDisplayName;
|
||||
|
||||
@@ -39,26 +85,8 @@ public enum Theme {
|
||||
return myDisplayName;
|
||||
}
|
||||
|
||||
public boolean accepts(VirtualFile fileName) {
|
||||
String nameWithoutExtension = FileUtil.getNameWithoutExtension(fileName.getName());
|
||||
if (myExtension != null) {
|
||||
if (nameWithoutExtension.endsWith(myExtension)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
VirtualFile parent = fileName.getParent();
|
||||
if (parent != null && parent.findChild(nameWithoutExtension + myExtension + ".png") != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (Theme theme : values()) {
|
||||
String extension = theme.getExtension();
|
||||
if (extension != null && nameWithoutExtension.endsWith(extension)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicableToProject(Project project) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user