├── .editorconfig ├── .github └── workflows │ ├── build.yml │ └── gradle-wrapper-validation.yml ├── .gitignore ├── LICENSE.md ├── README.md ├── art ├── screen1.png └── screen2.png ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── resources ├── META-INF │ ├── plugin.xml │ └── pluginIcon.svg └── icons │ ├── ic_check_circle.png │ └── ic_palette.png └── src └── main └── kotlin └── com └── dvd └── intellijdea └── materialcolorpalette ├── ColorRender.kt ├── Colors.kt ├── MaterialColor.kt ├── Palette.form ├── Palette.kt ├── ToolWindowFactory.kt └── UtilsEnvironment.kt /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | # Unix-style newlines with a newline ending every file 5 | [*] 6 | end_of_line = lf 7 | insert_final_newline = true 8 | charset = utf-8 9 | 10 | [*.kt] 11 | indent_style = space 12 | indent_size = 4 13 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: IntelliJ plugin check 2 | on: push 3 | jobs: 4 | build: 5 | runs-on: ${{ matrix.os }} 6 | strategy: 7 | matrix: 8 | os: [windows-latest, ubuntu-latest, macOS-latest] 9 | steps: 10 | - uses: actions/checkout@master 11 | - name: Set up JDK 1.8 12 | uses: actions/setup-java@master 13 | with: 14 | java-version: 1.8 15 | - name: Build & check plugin 16 | run: | 17 | ./gradlew verifyPlugin 18 | -------------------------------------------------------------------------------- /.github/workflows/gradle-wrapper-validation.yml: -------------------------------------------------------------------------------- 1 | name: "Validate Gradle Wrapper" 2 | on: [push, pull_request] 3 | 4 | jobs: 5 | validation: 6 | name: "Validation" 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | - uses: gradle/wrapper-validation-action@v1 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.ipr 3 | *.iws 4 | *.iml 5 | out/ 6 | gen/ 7 | .idea_modules/ 8 | atlassian-ide-plugin.xml 9 | build/ 10 | build.properties 11 | .gradle 12 | /gradle.properties 13 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Apache License 2 | ============== 3 | 4 | _Version 2.0, January 2004_ 5 | _<>_ 6 | 7 | ### Terms and Conditions for use, reproduction, and distribution 8 | 9 | #### 1. Definitions 10 | 11 | “License” shall mean the terms and conditions for use, reproduction, and 12 | distribution as defined by Sections 1 through 9 of this document. 13 | 14 | “Licensor” shall mean the copyright owner or entity authorized by the copyright 15 | owner that is granting the License. 16 | 17 | “Legal Entity” shall mean the union of the acting entity and all other entities 18 | that control, are controlled by, or are under common control with that entity. 19 | For the purposes of this definition, “control” means **(i)** the power, direct or 20 | indirect, to cause the direction or management of such entity, whether by 21 | contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the 22 | outstanding shares, or **(iii)** beneficial ownership of such entity. 23 | 24 | “You” (or “Your”) shall mean an individual or Legal Entity exercising 25 | permissions granted by this License. 26 | 27 | “Source” form shall mean the preferred form for making modifications, including 28 | but not limited to software source code, documentation source, and configuration 29 | files. 30 | 31 | “Object” form shall mean any form resulting from mechanical transformation or 32 | translation of a Source form, including but not limited to compiled object code, 33 | generated documentation, and conversions to other media types. 34 | 35 | “Work” shall mean the work of authorship, whether in Source or Object form, made 36 | available under the License, as indicated by a copyright notice that is included 37 | in or attached to the work (an example is provided in the Appendix below). 38 | 39 | “Derivative Works” shall mean any work, whether in Source or Object form, that 40 | is based on (or derived from) the Work and for which the editorial revisions, 41 | annotations, elaborations, or other modifications represent, as a whole, an 42 | original work of authorship. For the purposes of this License, Derivative Works 43 | shall not include works that remain separable from, or merely link (or bind by 44 | name) to the interfaces of, the Work and Derivative Works thereof. 45 | 46 | “Contribution” shall mean any work of authorship, including the original version 47 | of the Work and any modifications or additions to that Work or Derivative Works 48 | thereof, that is intentionally submitted to Licensor for inclusion in the Work 49 | by the copyright owner or by an individual or Legal Entity authorized to submit 50 | on behalf of the copyright owner. For the purposes of this definition, 51 | “submitted” means any form of electronic, verbal, or written communication sent 52 | to the Licensor or its representatives, including but not limited to 53 | communication on electronic mailing lists, source code control systems, and 54 | issue tracking systems that are managed by, or on behalf of, the Licensor for 55 | the purpose of discussing and improving the Work, but excluding communication 56 | that is conspicuously marked or otherwise designated in writing by the copyright 57 | owner as “Not a Contribution.” 58 | 59 | “Contributor” shall mean Licensor and any individual or Legal Entity on behalf 60 | of whom a Contribution has been received by Licensor and subsequently 61 | incorporated within the Work. 62 | 63 | #### 2. Grant of Copyright License 64 | 65 | Subject to the terms and conditions of this License, each Contributor hereby 66 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, 67 | irrevocable copyright license to reproduce, prepare Derivative Works of, 68 | publicly display, publicly perform, sublicense, and distribute the Work and such 69 | Derivative Works in Source or Object form. 70 | 71 | #### 3. Grant of Patent License 72 | 73 | Subject to the terms and conditions of this License, each Contributor hereby 74 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, 75 | irrevocable (except as stated in this section) patent license to make, have 76 | made, use, offer to sell, sell, import, and otherwise transfer the Work, where 77 | such license applies only to those patent claims licensable by such Contributor 78 | that are necessarily infringed by their Contribution(s) alone or by combination 79 | of their Contribution(s) with the Work to which such Contribution(s) was 80 | submitted. If You institute patent litigation against any entity (including a 81 | cross-claim or counterclaim in a lawsuit) alleging that the Work or a 82 | Contribution incorporated within the Work constitutes direct or contributory 83 | patent infringement, then any patent licenses granted to You under this License 84 | for that Work shall terminate as of the date such litigation is filed. 85 | 86 | #### 4. Redistribution 87 | 88 | You may reproduce and distribute copies of the Work or Derivative Works thereof 89 | in any medium, with or without modifications, and in Source or Object form, 90 | provided that You meet the following conditions: 91 | 92 | * **(a)** You must give any other recipients of the Work or Derivative Works a copy of 93 | this License; and 94 | * **(b)** You must cause any modified files to carry prominent notices stating that You 95 | changed the files; and 96 | * **(c)** You must retain, in the Source form of any Derivative Works that You distribute, 97 | all copyright, patent, trademark, and attribution notices from the Source form 98 | of the Work, excluding those notices that do not pertain to any part of the 99 | Derivative Works; and 100 | * **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any 101 | Derivative Works that You distribute must include a readable copy of the 102 | attribution notices contained within such NOTICE file, excluding those notices 103 | that do not pertain to any part of the Derivative Works, in at least one of the 104 | following places: within a NOTICE text file distributed as part of the 105 | Derivative Works; within the Source form or documentation, if provided along 106 | with the Derivative Works; or, within a display generated by the Derivative 107 | Works, if and wherever such third-party notices normally appear. The contents of 108 | the NOTICE file are for informational purposes only and do not modify the 109 | License. You may add Your own attribution notices within Derivative Works that 110 | You distribute, alongside or as an addendum to the NOTICE text from the Work, 111 | provided that such additional attribution notices cannot be construed as 112 | modifying the License. 113 | 114 | You may add Your own copyright statement to Your modifications and may provide 115 | additional or different license terms and conditions for use, reproduction, or 116 | distribution of Your modifications, or for any such Derivative Works as a whole, 117 | provided Your use, reproduction, and distribution of the Work otherwise complies 118 | with the conditions stated in this License. 119 | 120 | #### 5. Submission of Contributions 121 | 122 | Unless You explicitly state otherwise, any Contribution intentionally submitted 123 | for inclusion in the Work by You to the Licensor shall be under the terms and 124 | conditions of this License, without any additional terms or conditions. 125 | Notwithstanding the above, nothing herein shall supersede or modify the terms of 126 | any separate license agreement you may have executed with Licensor regarding 127 | such Contributions. 128 | 129 | #### 6. Trademarks 130 | 131 | This License does not grant permission to use the trade names, trademarks, 132 | service marks, or product names of the Licensor, except as required for 133 | reasonable and customary use in describing the origin of the Work and 134 | reproducing the content of the NOTICE file. 135 | 136 | #### 7. Disclaimer of Warranty 137 | 138 | Unless required by applicable law or agreed to in writing, Licensor provides the 139 | Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, 140 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, 141 | including, without limitation, any warranties or conditions of TITLE, 142 | NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are 143 | solely responsible for determining the appropriateness of using or 144 | redistributing the Work and assume any risks associated with Your exercise of 145 | permissions under this License. 146 | 147 | #### 8. Limitation of Liability 148 | 149 | In no event and under no legal theory, whether in tort (including negligence), 150 | contract, or otherwise, unless required by applicable law (such as deliberate 151 | and grossly negligent acts) or agreed to in writing, shall any Contributor be 152 | liable to You for damages, including any direct, indirect, special, incidental, 153 | or consequential damages of any character arising as a result of this License or 154 | out of the use or inability to use the Work (including but not limited to 155 | damages for loss of goodwill, work stoppage, computer failure or malfunction, or 156 | any and all other commercial damages or losses), even if such Contributor has 157 | been advised of the possibility of such damages. 158 | 159 | #### 9. Accepting Warranty or Additional Liability 160 | 161 | While redistributing the Work or Derivative Works thereof, You may choose to 162 | offer, and charge a fee for, acceptance of support, warranty, indemnity, or 163 | other liability obligations and/or rights consistent with this License. However, 164 | in accepting such obligations, You may act only on Your own behalf and on Your 165 | sole responsibility, not on behalf of any other Contributor, and only if You 166 | agree to indemnify, defend, and hold each Contributor harmless for any liability 167 | incurred by, or claims asserted against, such Contributor by reason of your 168 | accepting any such warranty or additional liability. 169 | 170 | _END OF TERMS AND CONDITIONS_ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | material-color-palette-plugin 2 | ============================= 3 | ![IntelliJ plugin check](https://github.com/DVDAndroid/material-color-palette-plugin/workflows/IntelliJ%20plugin%20check/badge.svg) 4 | 5 | This plugin helps you add a Material Color value into the project 6 | 7 | [JetBrains Plugin Repository](https://plugins.jetbrains.com/plugin/8590) 8 | 9 | ## Screenshots 10 | 11 | ![](./art/screen2.png) 12 | 13 | ![](./art/screen1.png) 14 | 15 | ## Compatibility 16 | 17 | - All JetBrains IDEs 2019.1+ 18 | - Android Studio 3.5+ 19 | 20 | ## Installation 21 | 22 | - Preferences > Plugins > Browse repositories... > Search for "Material Color Palette" > Install Plugin 23 | - Restart IDE (if your IDE doesn't support dynamic plugins) 24 | -------------------------------------------------------------------------------- /art/screen1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DVDAndroid/material-color-palette-plugin/456fa7099504030e84947c8d8befa3eac7532b8d/art/screen1.png -------------------------------------------------------------------------------- /art/screen2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DVDAndroid/material-color-palette-plugin/456fa7099504030e84947c8d8befa3eac7532b8d/art/screen2.png -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "org.jetbrains.kotlin.jvm" version "1.3.72" 3 | id 'org.jetbrains.intellij' version "0.4.21" 4 | } 5 | 6 | group 'com.dvd.intellijidea' 7 | version "2.0.1" 8 | 9 | apply plugin: 'java' 10 | apply plugin: 'kotlin' 11 | 12 | sourceCompatibility = 1.8 13 | 14 | compileKotlin { 15 | kotlinOptions.jvmTarget = "1.8" 16 | } 17 | 18 | repositories { 19 | mavenCentral() 20 | } 21 | 22 | intellij { 23 | pluginName 'Material Color Palette' 24 | plugins = ['android'] 25 | patchPluginXml { 26 | sinceBuild = "191.*" 27 | } 28 | } 29 | 30 | sourceSets { 31 | main { 32 | java.srcDirs = ['src/main/java', 'src/main/kotlin'] 33 | kotlin.srcDirs = ['src/main/java', 'src/main/kotlin'] 34 | resources.srcDirs = ['resources'] 35 | } 36 | } 37 | 38 | publishPlugin { 39 | if (project.hasProperty('PUBLISH_TOKEN')) 40 | token PUBLISH_TOKEN 41 | } 42 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DVDAndroid/material-color-palette-plugin/456fa7099504030e84947c8d8befa3eac7532b8d/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.0-all.zip 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStorePath=wrapper/dists 5 | zipStoreBase=GRADLE_USER_HOME 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS='"-Xmx64m"' 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS="-Xmx64m" 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /resources/META-INF/plugin.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | com.dvd.intellijdea.materialcolorpalette 19 | Material Color Palette 20 | dvdandroid 21 | 22 | 25 | 26 | 28 |
  • Code fixes
  • 29 |
  • Added support for clipboard
  • 30 | 31 | 1.2:
      32 |
    • Fixed pasting in wrong window
    • 33 |
    34 | ]]>
    35 | 36 | com.intellij.modules.platform 37 | 38 | 39 | 42 | 43 | 44 |
    45 | -------------------------------------------------------------------------------- /resources/META-INF/pluginIcon.svg: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /resources/icons/ic_check_circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DVDAndroid/material-color-palette-plugin/456fa7099504030e84947c8d8befa3eac7532b8d/resources/icons/ic_check_circle.png -------------------------------------------------------------------------------- /resources/icons/ic_palette.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DVDAndroid/material-color-palette-plugin/456fa7099504030e84947c8d8befa3eac7532b8d/resources/icons/ic_palette.png -------------------------------------------------------------------------------- /src/main/kotlin/com/dvd/intellijdea/materialcolorpalette/ColorRender.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 dvdandroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.dvd.intellijdea.materialcolorpalette 18 | 19 | import java.awt.Color 20 | import java.awt.Component 21 | import java.awt.Dimension 22 | import java.awt.GridBagLayout 23 | import java.io.IOException 24 | import javax.imageio.ImageIO 25 | import javax.swing.* 26 | 27 | class ColorRender(private val children: Boolean) : JPanel(), ListCellRenderer { 28 | 29 | private var name = JLabel() 30 | private lateinit var icon: JLabel 31 | 32 | init { 33 | try { 34 | val bufImg = ImageIO.read(javaClass.getResource("/icons/ic_check_circle.png")) 35 | icon = JLabel(ImageIcon(bufImg)) 36 | } catch (ignored: IOException) { 37 | } 38 | } 39 | 40 | override fun getListCellRendererComponent( 41 | list: JList, 42 | color: MaterialColor, 43 | index: Int, 44 | isSelected: Boolean, 45 | cellHasFocus: Boolean 46 | ): Component { 47 | val size = 100 48 | 49 | layout = GridBagLayout() 50 | background = Color.decode(color.hexCode) 51 | toolTipText = "${color.fixedName} (${color.hexCode})" 52 | 53 | minimumSize = Dimension(size, size) 54 | maximumSize = Dimension(size, size) 55 | preferredSize = Dimension(size, size) 56 | 57 | if (children) 58 | name.text = "A?\\d+".toRegex().find(color.fixedName)?.groups?.get(0)?.value 59 | else 60 | name.text = "\\D+".toRegex().find(color.fixedName)?.groups?.get(0)?.value 61 | 62 | 63 | add(name) 64 | 65 | if (isSelected) add(icon) 66 | else remove(icon) 67 | 68 | return this 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/kotlin/com/dvd/intellijdea/materialcolorpalette/Colors.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 dvdandroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | //@formatter:off 17 | package com.dvd.intellijdea.materialcolorpalette 18 | 19 | object Colors { 20 | 21 | private val red_50 = MaterialColor("red_50", "#FFEBEE") 22 | private val red_100 = MaterialColor("red_100", "#FFCDD2") 23 | private val red_200 = MaterialColor("red_200", "#EF9A9A") 24 | private val red_300 = MaterialColor("red_300", "#E57373") 25 | private val red_400 = MaterialColor("red_400", "#EF5350") 26 | private val red_500 = MaterialColor("red_500", "#F44336") 27 | private val red_600 = MaterialColor("red_600", "#E53935") 28 | private val red_700 = MaterialColor("red_700", "#D32F2F") 29 | private val red_800 = MaterialColor("red_800", "#C62828") 30 | private val red_900 = MaterialColor("red_900", "#B71C1C") 31 | private val red_A100 = MaterialColor("red_A100", "#FF8A80") 32 | private val red_A200 = MaterialColor("red_A200", "#FF5252") 33 | private val red_A400 = MaterialColor("red_A400", "#FF1744") 34 | private val red_A700 = MaterialColor("red_A700", "#D50000") 35 | 36 | private val pink_50 = MaterialColor("pink_50", "#FCE4EC") 37 | private val pink_100 = MaterialColor("pink_100", "#F8BBD0") 38 | private val pink_200 = MaterialColor("pink_200", "#F48FB1") 39 | private val pink_300 = MaterialColor("pink_300", "#F06292") 40 | private val pink_400 = MaterialColor("pink_400", "#EC407A") 41 | private val pink_500 = MaterialColor("pink_500", "#E91E63") 42 | private val pink_600 = MaterialColor("pink_600", "#D81B60") 43 | private val pink_700 = MaterialColor("pink_700", "#C2185B") 44 | private val pink_800 = MaterialColor("pink_800", "#AD1457") 45 | private val pink_900 = MaterialColor("pink_900", "#880E4F") 46 | private val pink_A100 = MaterialColor("pink_A100", "#FF80AB") 47 | private val pink_A200 = MaterialColor("pink_A200", "#FF4081") 48 | private val pink_A400 = MaterialColor("pink_A400", "#F50057") 49 | private val pink_A700 = MaterialColor("pink_A700", "#C51162") 50 | 51 | private val purple_50 = MaterialColor("purple_50", "#F3E5F5") 52 | private val purple_100 = MaterialColor("purple_100", "#E1BEE7") 53 | private val purple_200 = MaterialColor("purple_200", "#CE93D8") 54 | private val purple_300 = MaterialColor("purple_300", "#BA68C8") 55 | private val purple_400 = MaterialColor("purple_400", "#AB47BC") 56 | private val purple_500 = MaterialColor("purple_500", "#9C27B0") 57 | private val purple_600 = MaterialColor("purple_600", "#8E24AA") 58 | private val purple_700 = MaterialColor("purple_700", "#7B1FA2") 59 | private val purple_800 = MaterialColor("purple_800", "#6A1B9A") 60 | private val purple_900 = MaterialColor("purple_900", "#4A148C") 61 | private val purple_A100 = MaterialColor("purple_A100", "#EA80FC") 62 | private val purple_A200 = MaterialColor("purple_A200", "#E040FB") 63 | private val purple_A400 = MaterialColor("purple_A400", "#D500F9") 64 | private val purple_A700 = MaterialColor("purple_A700", "#AA00FF") 65 | 66 | private val deep_purple_50 = MaterialColor("deep_purple_50", "#EDE7F6") 67 | private val deep_purple_100 = MaterialColor("deep_purple_100", "#D1C4E9") 68 | private val deep_purple_200 = MaterialColor("deep_purple_200", "#B39DDB") 69 | private val deep_purple_300 = MaterialColor("deep_purple_300", "#9575CD") 70 | private val deep_purple_400 = MaterialColor("deep_purple_400", "#7E57C2") 71 | private val deep_purple_500 = MaterialColor("deep_purple_500", "#673AB7") 72 | private val deep_purple_600 = MaterialColor("deep_purple_600", "#5E35B1") 73 | private val deep_purple_700 = MaterialColor("deep_purple_700", "#512DA8") 74 | private val deep_purple_800 = MaterialColor("deep_purple_800", "#4527A0") 75 | private val deep_purple_900 = MaterialColor("deep_purple_900", "#311B92") 76 | private val deep_purple_A100 = MaterialColor("deep_purple_A100", "#B388FF") 77 | private val deep_purple_A200 = MaterialColor("deep_purple_A200", "#7C4DFF") 78 | private val deep_purple_A400 = MaterialColor("deep_purple_A400", "#651FFF") 79 | private val deep_purple_A700 = MaterialColor("deep_purple_A700", "#6200EA") 80 | 81 | private val indigo_50 = MaterialColor("indigo_50", "#E8EAF6") 82 | private val indigo_100 = MaterialColor("indigo_100", "#C5CAE9") 83 | private val indigo_200 = MaterialColor("indigo_200", "#9FA8DA") 84 | private val indigo_300 = MaterialColor("indigo_300", "#7986CB") 85 | private val indigo_400 = MaterialColor("indigo_400", "#5C6BC0") 86 | private val indigo_500 = MaterialColor("indigo_500", "#3F51B5") 87 | private val indigo_600 = MaterialColor("indigo_600", "#3949AB") 88 | private val indigo_700 = MaterialColor("indigo_700", "#303F9F") 89 | private val indigo_800 = MaterialColor("indigo_800", "#283593") 90 | private val indigo_900 = MaterialColor("indigo_900", "#1A237E") 91 | private val indigo_A100 = MaterialColor("indigo_A100", "#8C9EFF") 92 | private val indigo_A200 = MaterialColor("indigo_A200", "#536DFE") 93 | private val indigo_A400 = MaterialColor("indigo_A400", "#3D5AFE") 94 | private val indigo_A700 = MaterialColor("indigo_A700", "#304FFE") 95 | 96 | private val blue_50 = MaterialColor("blue_50", "#E3F2FD") 97 | private val blue_100 = MaterialColor("blue_100", "#BBDEFB") 98 | private val blue_200 = MaterialColor("blue_200", "#90CAF9") 99 | private val blue_300 = MaterialColor("blue_300", "#64B5F6") 100 | private val blue_400 = MaterialColor("blue_400", "#42A5F5") 101 | private val blue_500 = MaterialColor("blue_500", "#2196F3") 102 | private val blue_600 = MaterialColor("blue_600", "#1E88E5") 103 | private val blue_700 = MaterialColor("blue_700", "#1976D2") 104 | private val blue_800 = MaterialColor("blue_800", "#1565C0") 105 | private val blue_900 = MaterialColor("blue_900", "#0D47A1") 106 | private val blue_A100 = MaterialColor("blue_A100", "#82B1FF") 107 | private val blue_A200 = MaterialColor("blue_A200", "#448AFF") 108 | private val blue_A400 = MaterialColor("blue_A400", "#2979FF") 109 | private val blue_A700 = MaterialColor("blue_A700", "#2962FF") 110 | 111 | private val light_blue_50 = MaterialColor("light_blue_50", "#E1F5FE") 112 | private val light_blue_100 = MaterialColor("light_blue_100", "#B3E5FC") 113 | private val light_blue_200 = MaterialColor("light_blue_200", "#81D4FA") 114 | private val light_blue_300 = MaterialColor("light_blue_300", "#4FC3F7") 115 | private val light_blue_400 = MaterialColor("light_blue_400", "#29B6F6") 116 | private val light_blue_500 = MaterialColor("light_blue_500", "#03A9F4") 117 | private val light_blue_600 = MaterialColor("light_blue_600", "#039BE5") 118 | private val light_blue_700 = MaterialColor("light_blue_700", "#0288D1") 119 | private val light_blue_800 = MaterialColor("light_blue_800", "#0277BD") 120 | private val light_blue_900 = MaterialColor("light_blue_900", "#01579B") 121 | private val light_blue_A100 = MaterialColor("light_blue_A100", "#80D8FF") 122 | private val light_blue_A200 = MaterialColor("light_blue_A200", "#40C4FF") 123 | private val light_blue_A400 = MaterialColor("light_blue_A400", "#00B0FF") 124 | private val light_blue_A700 = MaterialColor("light_blue_A700", "#0091EA") 125 | 126 | private val cyan_50 = MaterialColor("cyan_50", "#E0F7FA") 127 | private val cyan_100 = MaterialColor("cyan_100", "#B2EBF2") 128 | private val cyan_200 = MaterialColor("cyan_200", "#80DEEA") 129 | private val cyan_300 = MaterialColor("cyan_300", "#4DD0E1") 130 | private val cyan_400 = MaterialColor("cyan_400", "#26C6DA") 131 | private val cyan_500 = MaterialColor("cyan_500", "#00BCD4") 132 | private val cyan_600 = MaterialColor("cyan_600", "#00ACC1") 133 | private val cyan_700 = MaterialColor("cyan_700", "#0097A7") 134 | private val cyan_800 = MaterialColor("cyan_800", "#00838F") 135 | private val cyan_900 = MaterialColor("cyan_900", "#006064") 136 | private val cyan_A100 = MaterialColor("cyan_A100", "#84FFFF") 137 | private val cyan_A200 = MaterialColor("cyan_A200", "#18FFFF") 138 | private val cyan_A400 = MaterialColor("cyan_A400", "#00E5FF") 139 | private val cyan_A700 = MaterialColor("cyan_A700", "#00B8D4") 140 | 141 | private val teal_50 = MaterialColor("teal_50", "#E0F2F1") 142 | private val teal_100 = MaterialColor("teal_100", "#B2DFDB") 143 | private val teal_200 = MaterialColor("teal_200", "#80CBC4") 144 | private val teal_300 = MaterialColor("teal_300", "#4DB6AC") 145 | private val teal_400 = MaterialColor("teal_400", "#26A69A") 146 | private val teal_500 = MaterialColor("teal_500", "#009688") 147 | private val teal_600 = MaterialColor("teal_600", "#00897B") 148 | private val teal_700 = MaterialColor("teal_700", "#00796B") 149 | private val teal_800 = MaterialColor("teal_800", "#00695C") 150 | private val teal_900 = MaterialColor("teal_900", "#004D40") 151 | private val teal_A100 = MaterialColor("teal_A100", "#A7FFEB") 152 | private val teal_A200 = MaterialColor("teal_A200", "#64FFDA") 153 | private val teal_A400 = MaterialColor("teal_A400", "#1DE9B6") 154 | private val teal_A700 = MaterialColor("teal_A700", "#00BFA5") 155 | 156 | private val green_50 = MaterialColor("green_50", "#E8F5E9") 157 | private val green_100 = MaterialColor("green_100", "#C8E6C9") 158 | private val green_200 = MaterialColor("green_200", "#A5D6A7") 159 | private val green_300 = MaterialColor("green_300", "#81C784") 160 | private val green_400 = MaterialColor("green_400", "#66BB6A") 161 | private val green_500 = MaterialColor("green_500", "#4CAF50") 162 | private val green_600 = MaterialColor("green_600", "#43A047") 163 | private val green_700 = MaterialColor("green_700", "#388E3C") 164 | private val green_800 = MaterialColor("green_800", "#2E7D32") 165 | private val green_900 = MaterialColor("green_900", "#1B5E20") 166 | private val green_A100 = MaterialColor("green_A100", "#B9F6CA") 167 | private val green_A200 = MaterialColor("green_A200", "#69F0AE") 168 | private val green_A400 = MaterialColor("green_A400", "#00E676") 169 | private val green_A700 = MaterialColor("green_A700", "#00C853") 170 | 171 | private val light_green_50 = MaterialColor("light_green_50", "#F1F8E9") 172 | private val light_green_100 = MaterialColor("light_green_100", "#DCEDC8") 173 | private val light_green_200 = MaterialColor("light_green_200", "#C5E1A5") 174 | private val light_green_300 = MaterialColor("light_green_300", "#AED581") 175 | private val light_green_400 = MaterialColor("light_green_400", "#9CCC65") 176 | private val light_green_500 = MaterialColor("light_green_500", "#8BC34A") 177 | private val light_green_600 = MaterialColor("light_green_600", "#7CB342") 178 | private val light_green_700 = MaterialColor("light_green_700", "#689F38") 179 | private val light_green_800 = MaterialColor("light_green_800", "#558B2F") 180 | private val light_green_900 = MaterialColor("light_green_900", "#33691E") 181 | private val light_green_A100 = MaterialColor("light_green_A100", "#CCFF90") 182 | private val light_green_A200 = MaterialColor("light_green_A200", "#B2FF59") 183 | private val light_green_A400 = MaterialColor("light_green_A400", "#76FF03") 184 | private val light_green_A700 = MaterialColor("light_green_A700", "#64DD17") 185 | 186 | private val lime_50 = MaterialColor("lime_50", "#F9FBE7") 187 | private val lime_100 = MaterialColor("lime_100", "#F0F4C3") 188 | private val lime_200 = MaterialColor("lime_200", "#E6EE9C") 189 | private val lime_300 = MaterialColor("lime_300", "#DCE775") 190 | private val lime_400 = MaterialColor("lime_400", "#D4E157") 191 | private val lime_500 = MaterialColor("lime_500", "#CDDC39") 192 | private val lime_600 = MaterialColor("lime_600", "#C0CA33") 193 | private val lime_700 = MaterialColor("lime_700", "#AFB42B") 194 | private val lime_800 = MaterialColor("lime_800", "#9E9D24") 195 | private val lime_900 = MaterialColor("lime_900", "#827717") 196 | private val lime_A100 = MaterialColor("lime_A100", "#F4FF81") 197 | private val lime_A200 = MaterialColor("lime_A200", "#EEFF41") 198 | private val lime_A400 = MaterialColor("lime_A400", "#C6FF00") 199 | private val lime_A700 = MaterialColor("lime_A700", "#AEEA00") 200 | 201 | private val yellow_50 = MaterialColor("yellow_50", "#FFFDE7") 202 | private val yellow_100 = MaterialColor("yellow_100", "#FFF9C4") 203 | private val yellow_200 = MaterialColor("yellow_200", "#FFF59D") 204 | private val yellow_300 = MaterialColor("yellow_300", "#FFF176") 205 | private val yellow_400 = MaterialColor("yellow_400", "#FFEE58") 206 | private val yellow_500 = MaterialColor("yellow_500", "#FFEB3B") 207 | private val yellow_600 = MaterialColor("yellow_600", "#FDD835") 208 | private val yellow_700 = MaterialColor("yellow_700", "#FBC02D") 209 | private val yellow_800 = MaterialColor("yellow_800", "#F9A825") 210 | private val yellow_900 = MaterialColor("yellow_900", "#F57F17") 211 | private val yellow_A100 = MaterialColor("yellow_A100", "#FFFF8D") 212 | private val yellow_A200 = MaterialColor("yellow_A200", "#FFFF00") 213 | private val yellow_A400 = MaterialColor("yellow_A400", "#FFEA00") 214 | private val yellow_A700 = MaterialColor("yellow_A700", "#FFD600") 215 | 216 | 217 | private val amber_50 = MaterialColor("amber_50", "#FFF8E1") 218 | private val amber_100 = MaterialColor("amber_100", "#FFECB3") 219 | private val amber_200 = MaterialColor("amber_200", "#FFE082") 220 | private val amber_300 = MaterialColor("amber_300", "#FFD54F") 221 | private val amber_400 = MaterialColor("amber_400", "#FFCA28") 222 | private val amber_500 = MaterialColor("amber_500", "#FFC107") 223 | private val amber_600 = MaterialColor("amber_600", "#FFB300") 224 | private val amber_700 = MaterialColor("amber_700", "#FFA000") 225 | private val amber_800 = MaterialColor("amber_800", "#FF8F00") 226 | private val amber_900 = MaterialColor("amber_900", "#FF6F00") 227 | private val amber_A100 = MaterialColor("amber_A100", "#FFE57F") 228 | private val amber_A200 = MaterialColor("amber_A200", "#FFD740") 229 | private val amber_A400 = MaterialColor("amber_A400", "#FFC400") 230 | private val amber_A700 = MaterialColor("amber_A700", "#FFAB00") 231 | 232 | private val orange_50 = MaterialColor("orange_50", "#FFF3E0") 233 | private val orange_100 = MaterialColor("orange_100", "#FFE0B2") 234 | private val orange_200 = MaterialColor("orange_200", "#FFCC80") 235 | private val orange_300 = MaterialColor("orange_300", "#FFB74D") 236 | private val orange_400 = MaterialColor("orange_400", "#FFA726") 237 | private val orange_500 = MaterialColor("orange_500", "#FF9800") 238 | private val orange_600 = MaterialColor("orange_600", "#FB8C00") 239 | private val orange_700 = MaterialColor("orange_700", "#F57C00") 240 | private val orange_800 = MaterialColor("orange_800", "#EF6C00") 241 | private val orange_900 = MaterialColor("orange_900", "#E65100") 242 | private val orange_A100 = MaterialColor("orange_A100", "#FFD180") 243 | private val orange_A200 = MaterialColor("orange_A200", "#FFAB40") 244 | private val orange_A400 = MaterialColor("orange_A400", "#FF9100") 245 | private val orange_A700 = MaterialColor("orange_A700", "#FF6D00") 246 | 247 | private val deep_orange_50 = MaterialColor("deep_orange_50", "#FBE9E7") 248 | private val deep_orange_100 = MaterialColor("deep_orange_100", "#FFCCBC") 249 | private val deep_orange_200 = MaterialColor("deep_orange_200", "#FFAB91") 250 | private val deep_orange_300 = MaterialColor("deep_orange_300", "#FF8A65") 251 | private val deep_orange_400 = MaterialColor("deep_orange_400", "#FF7043") 252 | private val deep_orange_500 = MaterialColor("deep_orange_500", "#FF5722") 253 | private val deep_orange_600 = MaterialColor("deep_orange_600", "#F4511E") 254 | private val deep_orange_700 = MaterialColor("deep_orange_700", "#E64A19") 255 | private val deep_orange_800 = MaterialColor("deep_orange_800", "#D84315") 256 | private val deep_orange_900 = MaterialColor("deep_orange_900", "#BF360C") 257 | private val deep_orange_A100 = MaterialColor("deep_orange_A100", "#FF9E80") 258 | private val deep_orange_A200 = MaterialColor("deep_orange_A200", "#FF6E40") 259 | private val deep_orange_A400 = MaterialColor("deep_orange_A400", "#FF3D00") 260 | private val deep_orange_A700 = MaterialColor("deep_orange_A700", "#DD2C00") 261 | 262 | private val brown_50 = MaterialColor("brown_50", "#EFEBE9") 263 | private val brown_100 = MaterialColor("brown_100", "#D7CCC8") 264 | private val brown_200 = MaterialColor("brown_200", "#BCAAA4") 265 | private val brown_300 = MaterialColor("brown_300", "#A1887F") 266 | private val brown_400 = MaterialColor("brown_400", "#8D6E63") 267 | private val brown_500 = MaterialColor("brown_500", "#795548") 268 | private val brown_600 = MaterialColor("brown_600", "#6D4C41") 269 | private val brown_700 = MaterialColor("brown_700", "#5D4037") 270 | private val brown_800 = MaterialColor("brown_800", "#4E342E") 271 | private val brown_900 = MaterialColor("brown_900", "#3E2723") 272 | 273 | private val grey_50 = MaterialColor("grey_50", "#FAFAFA") 274 | private val grey_100 = MaterialColor("grey_100", "#F5F5F5") 275 | private val grey_200 = MaterialColor("grey_200", "#EEEEEE") 276 | private val grey_300 = MaterialColor("grey_300", "#E0E0E0") 277 | private val grey_400 = MaterialColor("grey_400", "#BDBDBD") 278 | private val grey_500 = MaterialColor("grey_500", "#9E9E9E") 279 | private val grey_600 = MaterialColor("grey_600", "#757575") 280 | private val grey_700 = MaterialColor("grey_700", "#616161") 281 | private val grey_800 = MaterialColor("grey_800", "#424242") 282 | private val grey_900 = MaterialColor("grey_900", "#212121") 283 | 284 | private val blue_grey_50 = MaterialColor("blue_grey_50", "#ECEFF1") 285 | private val blue_grey_100 = MaterialColor("blue_grey_100", "#CFD8DC") 286 | private val blue_grey_200 = MaterialColor("blue_grey_200", "#B0BEC5") 287 | private val blue_grey_300 = MaterialColor("blue_grey_300", "#90A4AE") 288 | private val blue_grey_400 = MaterialColor("blue_grey_400", "#78909C") 289 | private val blue_grey_500 = MaterialColor("blue_grey_500", "#607D8B") 290 | private val blue_grey_600 = MaterialColor("blue_grey_600", "#546E7A") 291 | private val blue_grey_700 = MaterialColor("blue_grey_700", "#455A64") 292 | private val blue_grey_800 = MaterialColor("blue_grey_800", "#37474F") 293 | private val blue_grey_900 = MaterialColor("blue_grey_900", "#263238") 294 | 295 | private val red = arrayOf( 296 | red_50, red_100, red_200, red_300, red_400, red_500, red_600, red_700, red_800, red_900, 297 | red_A100, red_A200, red_A400, red_A700 298 | ) 299 | 300 | private val pink = arrayOf( 301 | pink_50, pink_100, pink_200, pink_300, pink_400, pink_500, pink_600, pink_700, pink_800, pink_900, 302 | pink_A100, pink_A200, pink_A400, pink_A700 303 | ) 304 | 305 | private val purple = arrayOf( 306 | purple_50, purple_100, purple_200, purple_300, purple_400, purple_500, 307 | purple_600, purple_700, purple_800, purple_900, 308 | purple_A100, purple_A200, purple_A400, purple_A700 309 | ) 310 | 311 | private val deep_purple = arrayOf( 312 | deep_purple_50, deep_purple_100, deep_purple_200, deep_purple_300, deep_purple_400, deep_purple_500, 313 | deep_purple_600, deep_purple_700, deep_purple_800, deep_purple_900, 314 | deep_purple_A100, deep_purple_A200, deep_purple_A400, deep_purple_A700 315 | ) 316 | 317 | private val indigo = arrayOf( 318 | indigo_50, indigo_100, indigo_200, indigo_300, indigo_400, indigo_500, 319 | indigo_600, indigo_700, indigo_800, indigo_900, 320 | indigo_A100, indigo_A200, indigo_A400, indigo_A700 321 | ) 322 | 323 | private val blue = arrayOf( 324 | blue_50, blue_100, blue_200, blue_300, blue_400, blue_500, 325 | blue_600, blue_700, blue_800, blue_900, 326 | blue_A100, blue_A200, blue_A400, blue_A700 327 | ) 328 | 329 | private val light_blue = arrayOf( 330 | light_blue_50, light_blue_100, light_blue_200, light_blue_300, light_blue_400, light_blue_500, 331 | light_blue_600, light_blue_700, light_blue_800, light_blue_900, 332 | light_blue_A100, light_blue_A200, light_blue_A400, light_blue_A700 333 | ) 334 | 335 | private val cyan = arrayOf( 336 | cyan_50, cyan_100, cyan_200, cyan_300, cyan_400, cyan_500, 337 | cyan_600, cyan_700, cyan_800, cyan_900, 338 | cyan_A100, cyan_A200, cyan_A400, cyan_A700 339 | ) 340 | 341 | private val teal = arrayOf( 342 | teal_50, teal_100, teal_200, teal_300, teal_400, teal_500, 343 | teal_600, teal_700, teal_800, teal_900, 344 | teal_A100, teal_A200, teal_A400, teal_A700 345 | ) 346 | 347 | private val green = arrayOf( 348 | green_50, green_100, green_200, green_300, green_400, green_500, 349 | green_600, green_700, green_800, green_900, 350 | green_A100, green_A200, green_A400, green_A700 351 | ) 352 | 353 | private val light_green = arrayOf( 354 | light_green_50, light_green_100, light_green_200, light_green_300, light_green_400, light_green_500, 355 | light_green_600, light_green_700, light_green_800, light_green_900, 356 | light_green_A100, light_green_A200, light_green_A400, light_green_A700 357 | ) 358 | 359 | private val lime = arrayOf( 360 | lime_50, lime_100, lime_200, lime_300, lime_400, lime_500, 361 | lime_600, lime_700, lime_800, lime_900, 362 | lime_A100, lime_A200, lime_A400, lime_A700 363 | ) 364 | 365 | private val yellow = arrayOf( 366 | yellow_50, yellow_100, yellow_200, yellow_300, yellow_400, yellow_500, 367 | yellow_600, yellow_700, yellow_800, yellow_900, 368 | yellow_A100, yellow_A200, yellow_A400, yellow_A700 369 | ) 370 | 371 | private val amber = arrayOf( 372 | amber_50, amber_100, amber_200, amber_300, amber_400, amber_500, 373 | amber_600, amber_700, amber_800, amber_900, 374 | amber_A100, amber_A200, amber_A400, amber_A700 375 | ) 376 | 377 | private val orange = arrayOf( 378 | orange_50, orange_100, orange_200, orange_300, orange_400, orange_500, 379 | orange_600, orange_700, orange_800, orange_900, 380 | orange_A100, orange_A200, orange_A400, orange_A700 381 | ) 382 | 383 | private val deep_orange = arrayOf( 384 | deep_orange_50, deep_orange_100, deep_orange_200, deep_orange_300, deep_orange_400, deep_orange_500, 385 | deep_orange_600, deep_orange_700, deep_orange_800, deep_orange_900, 386 | deep_orange_A100, deep_orange_A200, deep_orange_A400, deep_orange_A700 387 | ) 388 | 389 | private val brown = arrayOf( 390 | brown_50, brown_100, brown_200, brown_300, brown_400, brown_500, 391 | brown_600, brown_700, brown_800, brown_900 392 | ) 393 | 394 | private val grey = arrayOf( 395 | grey_50, grey_100, grey_200, grey_300, grey_400, grey_500, 396 | grey_600, grey_700, grey_800, grey_900 397 | ) 398 | 399 | private val blue_grey = arrayOf( 400 | blue_grey_50, blue_grey_100, blue_grey_200, blue_grey_300, blue_grey_400, blue_grey_500, 401 | blue_grey_600, blue_grey_700, blue_grey_800, blue_grey_900 402 | ) 403 | 404 | val allColors = arrayOf( 405 | red, pink, purple, deep_purple, indigo, blue, 406 | light_blue, cyan,teal, green, light_green, lime, 407 | yellow, amber, orange, deep_orange, brown, grey, blue_grey 408 | ) 409 | 410 | } 411 | -------------------------------------------------------------------------------- /src/main/kotlin/com/dvd/intellijdea/materialcolorpalette/MaterialColor.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 dvdandroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.dvd.intellijdea.materialcolorpalette 18 | 19 | data class MaterialColor(val name: String, val hexCode: String) { 20 | 21 | companion object { 22 | private const val COLOR_RES = "%s" 23 | } 24 | 25 | val fixedName = capitalize(name) 26 | val colorRes = COLOR_RES.format(name, hexCode) 27 | 28 | private fun capitalize(str: String): String { 29 | val words = str.split("_".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() 30 | val ret = StringBuilder() 31 | for (i in words.indices) { 32 | ret.append(Character.toUpperCase(words[i][0])) 33 | ret.append(words[i].substring(1)) 34 | if (i < words.size - 1) { 35 | ret.append(' ') 36 | } 37 | } 38 | return ret.toString() 39 | } 40 | 41 | override fun toString() = fixedName 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/kotlin/com/dvd/intellijdea/materialcolorpalette/Palette.form: -------------------------------------------------------------------------------- 1 | 2 |
    3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
    35 | -------------------------------------------------------------------------------- /src/main/kotlin/com/dvd/intellijdea/materialcolorpalette/Palette.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 dvdandroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.dvd.intellijdea.materialcolorpalette 18 | 19 | import com.dvd.intellijdea.materialcolorpalette.Colors.allColors 20 | import java.awt.Toolkit 21 | import java.awt.datatransfer.StringSelection 22 | import java.awt.event.MouseAdapter 23 | import java.awt.event.MouseEvent 24 | import javax.swing.* 25 | 26 | class Palette { 27 | 28 | lateinit var panel: JPanel 29 | private lateinit var parentColors: JList 30 | private lateinit var childrenColors: JList 31 | private var lastIndex: Int = 0 32 | 33 | init { 34 | val listModel = DefaultListModel() 35 | allColors.forEach { listModel.addElement(it[5]) } 36 | 37 | parentColors.apply { 38 | layoutOrientation = JList.HORIZONTAL_WRAP 39 | cellRenderer = ColorRender(false) 40 | model = listModel 41 | visibleRowCount = 5 42 | 43 | addMouseListener(RightClickPopup()) 44 | } 45 | 46 | childrenColors.apply { 47 | layoutOrientation = JList.HORIZONTAL_WRAP 48 | cellRenderer = ColorRender(true) 49 | 50 | addMouseListener(RightClickPopup()) 51 | } 52 | } 53 | 54 | inner class RightClickPopup : MouseAdapter() { 55 | 56 | override fun mousePressed(event: MouseEvent?) { 57 | val list = event?.source as JList<*> 58 | if (list.locationToIndex(event.point) == -1 && !event.isShiftDown) { 59 | list.clearSelection() 60 | return 61 | } 62 | 63 | val index = list.locationToIndex(event.point) 64 | if (index != -1 && !list.getCellBounds(index, index).contains(event.point)) return 65 | 66 | if (list == parentColors) { 67 | val children = DefaultListModel() 68 | 69 | allColors[index].forEach { children.addElement(it) } 70 | 71 | lastIndex = index 72 | 73 | childrenColors.apply { 74 | model = children 75 | visibleRowCount = 4 76 | } 77 | 78 | if (SwingUtilities.isRightMouseButton(event)) { 79 | buildPopup(list, index).show(event.component, event.x, event.y) 80 | } 81 | } else { 82 | buildPopup(list, index).show(event.component, event.x, event.y) 83 | } 84 | 85 | list.selectedIndex = index 86 | } 87 | 88 | private fun buildPopup(list: JList<*>, index: Int): JPopupMenu { 89 | val popup = JPopupMenu() 90 | 91 | if (list == childrenColors) { 92 | val hexThisItem = JMenuItem(String.format(PASTE, "this", "HEX code")) 93 | hexThisItem.addActionListener { UtilsEnvironment.insertInEditor(allColors[lastIndex][index].hexCode) } 94 | 95 | val colorResThisItem = JMenuItem(String.format(PASTE, "this", "resource")) 96 | colorResThisItem.addActionListener { UtilsEnvironment.insertInEditor(allColors[lastIndex][index].colorRes) } 97 | 98 | val clipboardThisItem = JMenuItem(String.format(COPY, "this")) 99 | clipboardThisItem.addActionListener { copyToClipboard(allColors[lastIndex][index].hexCode) } 100 | 101 | popup.add(hexThisItem) 102 | popup.add(colorResThisItem) 103 | popup.add(clipboardThisItem) 104 | 105 | return popup 106 | } 107 | 108 | val hex500Item = JMenuItem(String.format(PASTE, "primary", "HEX code")) 109 | hex500Item.addActionListener { UtilsEnvironment.insertInEditor(allColors[index][5].hexCode) } 110 | 111 | val colorRes500Item = JMenuItem(String.format(PASTE, "primary", "resource")) 112 | colorRes500Item.addActionListener { UtilsEnvironment.insertInEditor(allColors[index][5].colorRes) } 113 | 114 | val clipboard500Item = JMenuItem(String.format(COPY, "primary")) 115 | clipboard500Item.addActionListener { copyToClipboard(allColors[index][5].hexCode) } 116 | 117 | val hex700Item = JMenuItem(String.format(PASTE, "dark primary", "HEX code")) 118 | hex700Item.addActionListener { UtilsEnvironment.insertInEditor(allColors[index][7].hexCode) } 119 | 120 | val colorRes700Item = JMenuItem(String.format(PASTE, "dark primary", "resource")) 121 | colorRes700Item.addActionListener { UtilsEnvironment.insertInEditor(allColors[index][7].colorRes) } 122 | 123 | val clipboard700Item = JMenuItem(String.format(COPY, "dark primary")) 124 | clipboard700Item.addActionListener { copyToClipboard(allColors[index][7].hexCode) } 125 | 126 | popup.apply { 127 | add(hex500Item) 128 | add(colorRes500Item) 129 | add(clipboard500Item) 130 | addSeparator() 131 | add(hex700Item) 132 | add(colorRes700Item) 133 | add(clipboard700Item) 134 | } 135 | 136 | 137 | if (index < 16) { 138 | val hexAccentItem = JMenuItem(String.format(PASTE, "accent", "HEX code")) 139 | hexAccentItem.addActionListener { UtilsEnvironment.insertInEditor(allColors[index][11].hexCode) } 140 | 141 | val colorResAccentItem = JMenuItem(String.format(PASTE, "accent", "resource")) 142 | colorResAccentItem.addActionListener { UtilsEnvironment.insertInEditor(allColors[index][11].colorRes) } 143 | 144 | val clipboardAccentItem = JMenuItem(String.format(COPY, "accent")) 145 | clipboardAccentItem.addActionListener { copyToClipboard(allColors[index][11].hexCode) } 146 | 147 | popup.apply { 148 | addSeparator() 149 | add(hexAccentItem) 150 | add(colorResAccentItem) 151 | add(clipboardAccentItem) 152 | } 153 | } 154 | 155 | return popup 156 | } 157 | 158 | private fun copyToClipboard(colorRes: String) = 159 | Toolkit.getDefaultToolkit().systemClipboard.setContents(StringSelection(colorRes), null) 160 | } 161 | 162 | companion object { 163 | private const val COPY = "Copy %s HEX color in clipboard" 164 | private const val PASTE = "Paste %s color as %s" 165 | } 166 | 167 | } 168 | -------------------------------------------------------------------------------- /src/main/kotlin/com/dvd/intellijdea/materialcolorpalette/ToolWindowFactory.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 dvdandroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.dvd.intellijdea.materialcolorpalette 18 | 19 | import com.intellij.openapi.project.Project 20 | import com.intellij.openapi.ui.SimpleToolWindowPanel 21 | import com.intellij.ui.content.ContentFactory 22 | import java.awt.BorderLayout 23 | 24 | class ToolWindowFactory : com.intellij.openapi.wm.ToolWindowFactory { 25 | 26 | override fun createToolWindowContent(project: Project, toolWindow: com.intellij.openapi.wm.ToolWindow) { 27 | val newToolWindow = ToolWindow() 28 | val content = ContentFactory.SERVICE.getInstance().createContent(newToolWindow, "", false) 29 | 30 | toolWindow.apply { 31 | toolWindow.title = "Material Palette" 32 | toolWindow.setAvailable(true, null) 33 | 34 | toolWindow.contentManager.addContent(content) 35 | } 36 | } 37 | 38 | inner class ToolWindow : SimpleToolWindowPanel(false) { 39 | init { 40 | add(Palette().panel, BorderLayout.CENTER) 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/kotlin/com/dvd/intellijdea/materialcolorpalette/UtilsEnvironment.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 dvdandroid 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.dvd.intellijdea.materialcolorpalette 18 | 19 | import com.intellij.ide.DataManager 20 | import com.intellij.openapi.actionSystem.PlatformDataKeys 21 | import com.intellij.openapi.application.ApplicationManager 22 | import com.intellij.openapi.command.CommandProcessor 23 | import com.intellij.openapi.command.UndoConfirmationPolicy 24 | import com.intellij.openapi.editor.Editor 25 | import com.intellij.openapi.fileEditor.FileDocumentManager 26 | import com.intellij.openapi.fileEditor.FileEditorManager 27 | import com.intellij.openapi.project.Project 28 | import com.intellij.openapi.project.ProjectManager 29 | import com.intellij.psi.codeStyle.CodeStyleManager 30 | import com.intellij.psi.util.PsiUtilBase 31 | import java.util.concurrent.TimeUnit 32 | 33 | object UtilsEnvironment { 34 | 35 | private val openProject: Project? 36 | get() = DataManager.getInstance().dataContextFromFocusAsync.blockingGet(1, TimeUnit.SECONDS)?.getData( 37 | PlatformDataKeys.PROJECT 38 | ) as Project 39 | 40 | fun insertInEditor(text: String?) { 41 | val project = openProject 42 | val editor = getEditor(project) 43 | 44 | ProjectManager.getInstance().openProjects 45 | 46 | if (project != null && editor != null && text != null && text.isNotEmpty()) { 47 | val caretModel = editor.caretModel 48 | val currentOffset = caretModel.offset 49 | val selectionModel = editor.selectionModel 50 | 51 | CommandProcessor.getInstance().executeCommand(project, { 52 | ApplicationManager.getApplication().runWriteAction { 53 | val textLen = text.length 54 | val document = editor.document 55 | 56 | if (selectionModel.hasSelection()) { 57 | val selectionStart = selectionModel.selectionStart 58 | document.replaceString(selectionStart, selectionModel.selectionEnd, text) 59 | selectionModel.removeSelection() 60 | editor.caretModel.moveToOffset(selectionStart + textLen) 61 | } else { 62 | document.insertString(currentOffset, text) 63 | editor.caretModel.moveToOffset(currentOffset + textLen) 64 | } 65 | 66 | FileDocumentManager.getInstance().getFile(document)?.let { 67 | PsiUtilBase.getPsiFileInEditor(editor, project)?.let { psiFile -> 68 | CodeStyleManager.getInstance(project) 69 | .reformatText(psiFile, currentOffset, currentOffset + textLen) 70 | } 71 | } 72 | } 73 | }, "Paste", UndoConfirmationPolicy.DO_NOT_REQUEST_CONFIRMATION) 74 | 75 | FileDocumentManager.getInstance().getFile(editor.document)?.let { file -> 76 | FileEditorManager.getInstance(project).openFile(file, true) 77 | } 78 | } 79 | } 80 | 81 | private fun getEditor(curProject: Project?): Editor? { 82 | var pr = curProject 83 | if (pr == null) pr = openProject 84 | 85 | if (pr != null) { 86 | val manager = FileEditorManager.getInstance(pr) 87 | 88 | return manager.selectedTextEditor 89 | } 90 | 91 | return null 92 | } 93 | 94 | } 95 | --------------------------------------------------------------------------------