1
0
mirror of https://github.com/chylex/IntelliJ-Colored-Icons.git synced 2025-05-06 07:34:04 +02:00

Add main plugin files

This commit is contained in:
chylex 2020-07-19 06:50:41 +02:00
commit c30012efe1
11 changed files with 163 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
/.idea/$CACHE_FILE$
/.idea/inspectionProfiles/
/.idea/dictionaries
/dev/
/out/

5
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/

6
.idea/encodings.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

6
.idea/misc.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="IntelliJ IDEA IU-201.7846.76" project-jdk-type="IDEA JDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/IntelliJ-Colored-Icons.iml" filepath="$PROJECT_DIR$/IntelliJ-Colored-Icons.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PLUGIN_MODULE" version="4">
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/resources/META-INF/plugin.xml" />
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,20 @@
<idea-plugin>
<id>com.chylex.intellij.coloredicons</id>
<name>IntelliJ Colored Icons</name>
<version>1.0</version>
<vendor email="contact@chylex.com" url="https://chylex.com">chylex</vendor>
<description>
Adds color to many of the gray IntelliJ platform icons.
Uses resources from https://github.com/JetBrains/intellij-community and some of the official IntelliJ platform plugins.
</description>
<idea-version since-build="183.0"/>
<depends>com.intellij.modules.platform</depends>
<application-components>
<component>
<implementation-class>com.chylex.intellij.coloredicons.IconPatcher</implementation-class>
</component>
</application-components>
</idea-plugin>

4
resources/desktop.ini Normal file
View File

@ -0,0 +1,4 @@
[ViewState]
Mode=
Vid=
FolderType=Pictures

View File

@ -0,0 +1,57 @@
package com.chylex.intellij.coloredicons;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
final class BuildHelpers{
static final class FixSVG{
public static void main(String[] args) throws IOException{
Charset charset = StandardCharsets.UTF_8;
String encoding = charset.name();
String svg12Tag = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"12\" height=\"12\" viewBox=\"0 0 12 12\">";
String svg13Tag = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"13\" height=\"13\" viewBox=\"0 0 13 13\">";
String svg16Tag = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\">";
Set<String> svgTags = new HashSet<>(Arrays.asList(
svg12Tag, svg13Tag, svg16Tag
));
for(File file : FileUtils.listFiles(new File("./resources/icons"), new String[]{ "svg" }, true)){
List<String> lines = FileUtils.readLines(file, charset);
if (lines.get(0).startsWith("<?xml")){
lines.remove(0);
}
if (lines.get(0).startsWith("<!DOCTYPE")){
lines.remove(0);
}
String svg = lines.get(0);
if (svg.startsWith("<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 13 13\"")){
lines.set(0, svg13Tag);
}
else if (svg.startsWith("<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 16 16\"")){
lines.set(0, svg16Tag);
}
else if (svg.startsWith("<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 12 12\"")){
lines.set(0, svg12Tag);
}
else if (!svgTags.contains(svg)){
System.out.println("Error processing <svg> tag in file " + file + " --- " + svg);
continue;
}
FileUtils.writeLines(file, encoding, lines);
}
}
}
}

View File

@ -0,0 +1,33 @@
package com.chylex.intellij.coloredicons;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.IconPathPatcher;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
public class IconPatcher extends IconPathPatcher{
private final ClassLoader classLoader = getClass().getClassLoader();
private final Map<String, String> iconPaths = new HashMap<>();
public IconPatcher(){
IconLoader.installPathPatcher(this);
}
private void addPathWithDark(String path){
iconPaths.put("/" + path + ".svg", "/icons/" + path + ".svg");
iconPaths.put("/" + path + "_dark.svg", "/icons/" + path + "_dark.svg");
}
@Nullable
@Override
public String patchPath(@NotNull String path, ClassLoader classLoader){
return iconPaths.get(path);
}
@Nullable
@Override
public ClassLoader getContextClassLoader(@NotNull String path, ClassLoader originalClassLoader){
return classLoader;
}
}