Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add different coloured icons for Java filetypes #35

Merged
merged 5 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion generate/vscode-icons
Submodule vscode-icons updated 305 files
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pluginSinceBuild=231
pluginUntilBuild=241.*
platformType=IC
platformVersion=2023.1
platformPlugins=
platformPlugins=org.jetbrains.kotlin
sgoudham marked this conversation as resolved.
Show resolved Hide resolved
javaVersion=17
gradleVersion=7.3.3
kotlin.stdlib.default.dependency=false
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class PluginSettingsState : PersistentStateComponent<PluginSettingsState> {
var variant = Variant.MOCHA.id

var pythonSupport = true
var javaSupport = true

companion object {
val instance: PluginSettingsState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
}
5 changes: 5 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ For further help, see also:
<p>LICENSE: <a href="https://github.com/catppuccin/jetbrains-icons/blob/main/LICENSE">MIT</a></p>
]]></description>
<depends>com.intellij.modules.platform</depends>
<depends>org.jetbrains.kotlin</depends>
<extensions defaultExtensionNs="com.intellij">
<iconProvider
implementation="com.github.catppuccin.jetbrains_icons.IconProvider"
Expand All @@ -41,6 +42,10 @@ For further help, see also:
implementation="com.github.catppuccin.jetbrains_icons.decorators.PythonProjectViewNodeDecorator"
id="PythonProjectViewNodeDecorator"
/>
<projectViewNodeDecorator
implementation="com.github.catppuccin.jetbrains_icons.decorators.JavaProjectViewNodeDecorator"
id="JavaProjectViewNodeDecorator"
/>
<applicationConfigurable
parentId="appearance"
groupId="com.github.catppuccin.jetbrains_icons"
Expand Down
Loading