diff --git a/CHANGELOG.md b/CHANGELOG.md index 8aa7c6a..e926945 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ ### Added +- Different colors for Java filetypes (e.g. `Class`: Red, `Interface`: Green, `Record`: Mauve, `Enum`: + Yellow and `Annotation`: Green) ([#35](https://github.com/catppuccin/jetbrains-icons/pull/35)) +- Ability to disable different colors for Java filetypes in settings panel. ([#35](https://github.com/catppuccin/jetbrains-icons/pull/35)) + ### Changed ### Deprecated diff --git a/generate/vscode-icons b/generate/vscode-icons index 9072c43..7bb1fa7 160000 --- a/generate/vscode-icons +++ b/generate/vscode-icons @@ -1 +1 @@ -Subproject commit 9072c437d896dd8d7f4a8063499517ccd44a489e +Subproject commit 7bb1fa75bd737e3fa20a3c900ceb90aaf73a02e2 diff --git a/gradle.properties b/gradle.properties index ca9401e..bb03bed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ pluginSinceBuild=231 pluginUntilBuild=241.* platformType=IC platformVersion=2023.1 -platformPlugins= +platformPlugins=org.jetbrains.kotlin javaVersion=17 gradleVersion=7.3.3 kotlin.stdlib.default.dependency=false diff --git a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/decorators/JavaProjectViewNodeDecorator.kt b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/decorators/JavaProjectViewNodeDecorator.kt new file mode 100644 index 0000000..2792a57 --- /dev/null +++ b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/decorators/JavaProjectViewNodeDecorator.kt @@ -0,0 +1,34 @@ +package com.github.catppuccin.jetbrains_icons.decorators + +import com.github.catppuccin.jetbrains_icons.IconPack +import com.github.catppuccin.jetbrains_icons.settings.PluginSettingsState +import com.github.catppuccin.jetbrains_icons.util.PsiClassUtils +import com.intellij.ide.projectView.PresentationData +import com.intellij.ide.projectView.ProjectViewNode +import com.intellij.ide.projectView.ProjectViewNodeDecorator +import com.intellij.lang.jvm.JvmModifier +import com.intellij.psi.PsiClass +import org.jetbrains.kotlin.idea.codeInsight.SuperDeclaration +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.isAbstract +import org.jetbrains.kotlin.psi.psiUtil.isObjectLiteral + +class JavaProjectViewNodeDecorator : ProjectViewNodeDecorator { + override fun decorate(node: ProjectViewNode<*>, data: PresentationData) { + if (!PluginSettingsState.instance.javaSupport) return + if (node.virtualFile?.isDirectory == true) return + + val icons = IconPack.instance.icons + + when (val value = node.value) { + + is PsiClass -> when { + value.isInterface -> data.setIcon(icons.java_alt_1) + value.isAnnotationType -> data.setIcon(icons.java_alt_1) + value.isEnum -> data.setIcon(icons.java_alt_3) + value.isRecord -> data.setIcon(icons.java_alt_2) + PsiClassUtils.isAbstract(value) -> data.setIcon(icons.java_alt_1) + } + } + } +} diff --git a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/PluginSettings.kt b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/PluginSettings.kt index 3f928c3..a95dcd1 100644 --- a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/PluginSettings.kt +++ b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/PluginSettings.kt @@ -26,13 +26,15 @@ class PluginSettings : Configurable { override fun isModified(): Boolean { val state = PluginSettingsState.instance return packChanged() || - component.additionalSupport.python.isSelected != state.pythonSupport + component.additionalSupport.python.isSelected != state.pythonSupport || + component.additionalSupport.java.isSelected != state.javaSupport } override fun apply() { val state = PluginSettingsState.instance state.pythonSupport = component.additionalSupport.python.isSelected + state.javaSupport = component.additionalSupport.java.isSelected if (packChanged()) { state.variant = component.iconPack.variant diff --git a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/PluginSettingsState.kt b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/PluginSettingsState.kt index addb3bd..401266a 100644 --- a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/PluginSettingsState.kt +++ b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/PluginSettingsState.kt @@ -14,6 +14,7 @@ class PluginSettingsState : PersistentStateComponent { var variant = Variant.MOCHA.id var pythonSupport = true + var javaSupport = true companion object { val instance: PluginSettingsState diff --git a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/views/SettingsAdditionalSupportView.kt b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/views/SettingsAdditionalSupportView.kt index 3098342..2d2a7ea 100644 --- a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/views/SettingsAdditionalSupportView.kt +++ b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/settings/views/SettingsAdditionalSupportView.kt @@ -8,11 +8,14 @@ import javax.swing.JPanel class SettingsAdditionalSupportView : JPanel() { val python = JBCheckBox("Python", PluginSettingsState.instance.pythonSupport) + val java = JBCheckBox("Java Filetypes", PluginSettingsState.instance.javaSupport) init { val form = FormBuilder.createFormBuilder() .addComponent(python) .addTooltip("Override the Python plugin icons") + .addComponent(java) + .addTooltip("Use different colors for Java filetypes (e.g. Class, Interface, Record, etc.)") .panel add(form) diff --git a/src/main/kotlin/com/github/catppuccin/jetbrains_icons/util/PsiClassUtils.kt b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/util/PsiClassUtils.kt new file mode 100644 index 0000000..a2675b9 --- /dev/null +++ b/src/main/kotlin/com/github/catppuccin/jetbrains_icons/util/PsiClassUtils.kt @@ -0,0 +1,10 @@ +package com.github.catppuccin.jetbrains_icons.util + +import com.intellij.psi.PsiClass +import com.intellij.psi.PsiModifier + +object PsiClassUtils { + fun isAbstract(psiClass: PsiClass): Boolean { + return psiClass.hasModifierProperty(PsiModifier.ABSTRACT) + } +} diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index c4e86b3..9b4e1d1 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -31,6 +31,7 @@ For further help, see also:

LICENSE: MIT

]]> com.intellij.modules.platform + org.jetbrains.kotlin +