├── .gitattributes ├── .gitignore ├── .idea ├── .gitignore ├── compiler.xml ├── gradle.xml ├── inspectionProfiles │ └── Project_Default.xml ├── jarRepositories.xml ├── misc.xml ├── uiDesigner.xml └── vcs.xml ├── LICENSE ├── StopCoding.iml ├── StopCoding.ipr ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── image ├── step.gif ├── step1.png ├── step2.png └── step3.png ├── readme.md ├── readme_ZH.md └── src └── main ├── java └── icu │ └── jogeen │ └── stopcoding │ ├── StopCodingInitializer.java │ ├── StopCodingSettingAction.java │ ├── data │ ├── DataCenter.java │ └── SettingData.java │ ├── service │ └── TimerService.java │ ├── task │ ├── RestTask.java │ └── WorkTask.java │ └── ui │ ├── SettingDialog.form │ ├── SettingDialog.java │ ├── TipsDialog.form │ └── TipsDialog.java └── resources ├── META-INF ├── plugin.xml ├── pluginIcon.svg └── pluginIcon_dark.svg └── img └── stop.png /.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | ### JetBrains template 7 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 8 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 9 | 10 | # User-specific stuff 11 | .idea/**/workspace.xml 12 | .idea/**/tasks.xml 13 | .idea/**/usage.statistics.xml 14 | .idea/**/dictionaries 15 | .idea/**/shelf 16 | 17 | # Generated files 18 | .idea/**/contentModel.xml 19 | 20 | # Sensitive or high-churn files 21 | .idea/**/dataSources/ 22 | .idea/**/dataSources.ids 23 | .idea/**/dataSources.local.xml 24 | .idea/**/sqlDataSources.xml 25 | .idea/**/dynamic.xml 26 | .idea/**/uiDesigner.xml 27 | .idea/**/dbnavigator.xml 28 | 29 | # Gradle 30 | .idea/**/gradle.xml 31 | .idea/**/libraries 32 | 33 | # Gradle and Maven with auto-import 34 | # When using Gradle or Maven with auto-import, you should exclude module files, 35 | # since they will be recreated, and may cause churn. Uncomment if using 36 | # auto-import. 37 | # .idea/artifacts 38 | # .idea/compiler.xml 39 | # .idea/jarRepositories.xml 40 | # .idea/modules.xml 41 | # .idea/*.iml 42 | # .idea/modules 43 | # *.iml 44 | # *.ipr 45 | 46 | # CMake 47 | cmake-build-*/ 48 | 49 | # Mongo Explorer plugin 50 | .idea/**/mongoSettings.xml 51 | 52 | # File-based project format 53 | *.iws 54 | 55 | # IntelliJ 56 | out/ 57 | 58 | # mpeltonen/sbt-idea plugin 59 | .idea_modules/ 60 | 61 | # JIRA plugin 62 | atlassian-ide-plugin.xml 63 | 64 | # Cursive Clojure plugin 65 | .idea/replstate.xml 66 | 67 | # Crashlytics plugin (for Android Studio and IntelliJ) 68 | com_crashlytics_export_strings.xml 69 | crashlytics.properties 70 | crashlytics-build.properties 71 | fabric.properties 72 | 73 | # Editor-based Rest Client 74 | .idea/httpRequests 75 | 76 | # Android studio 3.1+ serialized cache file 77 | .idea/caches/build_file_checksums.ser 78 | 79 | ### Gradle template 80 | .gradle 81 | **/build/ 82 | !src/**/build/ 83 | 84 | # Ignore Gradle GUI config 85 | gradle-app.setting 86 | 87 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 88 | !gradle-wrapper.jar 89 | 90 | # Cache of project 91 | .gradletasknamecache 92 | 93 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 94 | # gradle/wrapper/gradle-wrapper.properties 95 | 96 | ### macOS template 97 | # General 98 | .DS_Store 99 | .AppleDouble 100 | .LSOverride 101 | 102 | # Icon must end with two \r 103 | Icon 104 | 105 | # Thumbnails 106 | ._* 107 | 108 | # Files that might appear in the root of a volume 109 | .DocumentRevisions-V100 110 | .fseventsd 111 | .Spotlight-V100 112 | .TemporaryItems 113 | .Trashes 114 | .VolumeIcon.icns 115 | .com.apple.timemachine.donotpresent 116 | 117 | # Directories potentially created on remote AFP share 118 | .AppleDB 119 | .AppleDesktop 120 | Network Trash Folder 121 | Temporary Items 122 | .apdisk 123 | 124 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Default ignored files 3 | /workspace.xml -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 17 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 36 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 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 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /StopCoding.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /StopCoding.ipr: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 89 | 90 | 91 | 1.6 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | id "org.jetbrains.intellij" version "0.6.3" 4 | } 5 | 6 | repositories { 7 | mavenCentral() 8 | } 9 | 10 | // See https://github.com/JetBrains/gradle-intellij-plugin/ 11 | intellij { 12 | plugins = ['java'] 13 | version '2020.2.2' 14 | intellij.updateSinceUntilBuild false 15 | } 16 | 17 | java{ 18 | sourceCompatibility = JavaVersion.VERSION_1_8 19 | targetCompatibility = JavaVersion.VERSION_1_8 20 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jogeen/StopCoding/2e68bb929ff58d1f959e8193d3fb2e93581d55e3/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /image/step.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jogeen/StopCoding/2e68bb929ff58d1f959e8193d3fb2e93581d55e3/image/step.gif -------------------------------------------------------------------------------- /image/step1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jogeen/StopCoding/2e68bb929ff58d1f959e8193d3fb2e93581d55e3/image/step1.png -------------------------------------------------------------------------------- /image/step2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jogeen/StopCoding/2e68bb929ff58d1f959e8193d3fb2e93581d55e3/image/step2.png -------------------------------------------------------------------------------- /image/step3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jogeen/StopCoding/2e68bb929ff58d1f959e8193d3fb2e93581d55e3/image/step3.png -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ## StopCoding 2 | ![](https://img.shields.io/github/stars/jogeen/StopCoding) 3 | ![](https://img.shields.io/jetbrains/plugin/d/15740) 4 | ![](https://img.shields.io/badge/Version-V1.2-orange) 5 | ![](https://img.shields.io/github/license/jogeen/StopCoding) 6 | 7 | [中文说明](https://github.com/jogeen/StopCoding/blob/master/readme_ZH.md) 8 | 9 | ![](https://raw.githubusercontent.com/jogeen/StopCoding/master/image/step.gif) 10 | ### Introduce 11 | - This is a work timer.It can set every working period to remind you that it's time to have a rest, drink some water and exercise your body. 12 | Only in this way can you really work healthily 13 | - In the tools menu bar, open stopcoding. 14 | - Set working hours and rest time, and save them. 15 | - When the set time comes, there will be a pop-up box to remind you to rest, so that you can not operate idea temporarily. 16 | 17 | 18 | ### ChangeLog 19 | - V1.2 add icon(Thanks for the icon provided by my good friend Hu Wei). 20 | - V1.1 update Guide to use. 21 | - V1.0 release. 22 | 23 | ### Installation 24 | 25 | 1. Search and install stopcoding plug-in directly in idea (officially approved) 26 | 2. Intranet development of small partners can download after the local installation [Download](https://plugins.jetbrains.com/files/15740/108158/StopCoding.jar?updateId=108158&pluginId=15740&family=INTELLIJ) 27 | 28 | ### How to use 29 | - Step1. In the menu bar tools->StopCoding 30 | 31 | ![](https://raw.githubusercontent.com/jogeen/StopCoding/master/image/step1.png) 32 | 33 | - Step2. Set the parameters that suit you and save them。 34 | 35 | ![](https://raw.githubusercontent.com/jogeen/StopCoding/master/image/step2.png) 36 | 37 | - Step3. Then happy coding, no need to worry about their addiction. At the end of working hours, she will pop up the next box to remind you. Of course, this box can't be closed. It will close automatically only when you have enough rest time. 38 | 39 | ![](https://raw.githubusercontent.com/jogeen/StopCoding/master/image/step3.png) 40 | 41 | ### My Other Plugins 42 | 43 | - [MarkBook](https://github.com/jogeen/MarkBook) 44 | -------------------------------------------------------------------------------- /readme_ZH.md: -------------------------------------------------------------------------------- 1 | ## StopCoding(Idea防沉迷插件) 2 | ![](https://img.shields.io/github/stars/jogeen/StopCoding) 3 | ![](https://img.shields.io/jetbrains/plugin/d/15740) 4 | ![](https://img.shields.io/badge/Version-V1.2-orange) 5 | ![](https://img.shields.io/github/license/jogeen/StopCoding) 6 | 7 | ![](https://raw.githubusercontent.com/jogeen/StopCoding/master/image/step.gif) 8 | ### 介绍 9 | - 如果你也经常沉迷于写代码,忘了起身休息喝水,那么试试这个插件吧 10 | - 在菜单栏的Tools中,打开StopCoding插件进行设置 11 | - 设置工作时间和休息时间,并且保存 12 | - 当设置的时间一到,就会有弹框提醒你休息,让你暂时不能操作idea 13 | 14 | ### 变更日志 15 | 16 | - V1.2 添加图标(感谢好友HuWei设计的插件图标). 17 | - V1.1 更新使用指南. 18 | - V1.0 发布. 19 | 20 | ### 安装 21 | 22 | 1. 在idea中直接搜索安装StopCoding插件(官方已经审核通过) 23 | 2. 内网开发的小伙伴 可以下载之后进行本地安装 [下载地址](https://plugins.jetbrains.com/files/15740/108158/StopCoding.jar?updateId=108158&pluginId=15740&family=INTELLIJ) 24 | 25 | ### 使用 26 | - Step1. 然后在菜单栏中tools->StopCoding 27 | 28 | ![](https://raw.githubusercontent.com/jogeen/StopCoding/master/image/step1.png) 29 | 30 | - Step2. 设置适合你的参数然后保存。 31 | 32 | ![](https://raw.githubusercontent.com/jogeen/StopCoding/master/image/step2.png) 33 | 34 | - Step3. 然后快乐的Coding吧,再不用担心自己会沉迷了。工作时间结束,她会弹出下框进行提醒,当然,这个框是关不掉的.只有你休息了足够的时间它才会自动关闭. 35 | 36 | ![](https://raw.githubusercontent.com/jogeen/StopCoding/master/image/step3.png) 37 | ### 我的其它插件 38 | [MarkBook](https://github.com/jogeen/MarkBook) 39 | -------------------------------------------------------------------------------- /src/main/java/icu/jogeen/stopcoding/StopCodingInitializer.java: -------------------------------------------------------------------------------- 1 | package icu.jogeen.stopcoding; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import com.intellij.ide.util.PropertiesComponent; 5 | import com.intellij.openapi.application.PreloadingActivity; 6 | import com.intellij.openapi.diagnostic.Logger; 7 | import com.intellij.openapi.progress.ProgressIndicator; 8 | import icu.jogeen.stopcoding.data.DataCenter; 9 | import icu.jogeen.stopcoding.data.SettingData; 10 | import icu.jogeen.stopcoding.service.TimerService; 11 | public class StopCodingInitializer extends PreloadingActivity { 12 | 13 | private static final Logger LOG = Logger.getInstance(StopCodingInitializer.class); 14 | 15 | @Override 16 | public void preload(@NotNull ProgressIndicator indicator) { 17 | SettingData settings = new SettingData(); 18 | PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(); 19 | propertiesComponent.loadFields(settings); 20 | DataCenter.settingData = settings; 21 | if (settings.isOpen()) { 22 | LOG.info("open timer"); 23 | TimerService.openTimer(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/icu/jogeen/stopcoding/StopCodingSettingAction.java: -------------------------------------------------------------------------------- 1 | package icu.jogeen.stopcoding; 2 | 3 | import com.intellij.openapi.actionSystem.AnAction; 4 | import com.intellij.openapi.actionSystem.AnActionEvent; 5 | import com.intellij.openapi.components.ApplicationComponent; 6 | import icu.jogeen.stopcoding.ui.SettingDialog; 7 | 8 | public class StopCodingSettingAction extends AnAction implements ApplicationComponent { 9 | 10 | @Override 11 | public void actionPerformed(AnActionEvent e) { 12 | SettingDialog settingDialog = new SettingDialog(); 13 | settingDialog.setVisible(true); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/icu/jogeen/stopcoding/data/DataCenter.java: -------------------------------------------------------------------------------- 1 | package icu.jogeen.stopcoding.data; 2 | 3 | import java.time.LocalDateTime; 4 | import java.time.format.DateTimeFormatter; 5 | import java.util.Timer; 6 | import java.util.regex.Pattern; 7 | 8 | public class DataCenter { 9 | public static final Integer CLOSE = 0; 10 | public static final Integer WORKING = 1; 11 | public static final Integer RESTING = 2; 12 | 13 | public static SettingData settingData = new SettingData(); 14 | public static Integer status = CLOSE; 15 | public static LocalDateTime nextWorkTime; 16 | public static LocalDateTime nextRestTime; 17 | 18 | public static Timer workTimer = new Timer(); 19 | public static Timer reskTimer = new Timer(); 20 | 21 | public static int restCountDownSecond = -1; 22 | 23 | 24 | public static boolean isInteger(String str) { 25 | Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$"); 26 | return pattern.matcher(str).matches(); 27 | } 28 | 29 | public static String getSettingDesc() { 30 | 31 | if (CLOSE.equals(DataCenter.status)) { 32 | return "Stopcoding is stopping"; 33 | } 34 | DateTimeFormatter df = DateTimeFormatter.ofPattern("HH:mm:ss"); 35 | if (WORKING.equals(status)) { 36 | return "Next break:" + df.format(nextRestTime); 37 | } 38 | if (RESTING.equals(status)) { 39 | return "Break end time:" + df.format(nextWorkTime); 40 | } 41 | return ""; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/icu/jogeen/stopcoding/data/SettingData.java: -------------------------------------------------------------------------------- 1 | package icu.jogeen.stopcoding.data; 2 | 3 | import com.intellij.ide.util.PropertyName; 4 | public class SettingData { 5 | 6 | public static final int DEFAULT_WORK_TIME = 1; 7 | public static final int DEFAULT_REST_TIME = 2; 8 | 9 | @PropertyName("StopCoding:SettingData:isOpen") 10 | private boolean isOpen = false; 11 | 12 | @PropertyName("StopCoding:SettingData:workTime") 13 | private int workTime = DEFAULT_WORK_TIME; 14 | 15 | @PropertyName("StopCoding:SettingData:restTime") 16 | private int restTime = DEFAULT_REST_TIME; 17 | 18 | public boolean isOpen() { 19 | return isOpen; 20 | } 21 | 22 | public void setOpen(boolean open) { 23 | isOpen = open; 24 | } 25 | 26 | public int getWorkTime() { 27 | return workTime; 28 | } 29 | 30 | public void setWorkTime(int workTime) { 31 | this.workTime = workTime; 32 | } 33 | 34 | public int getRestTime() { 35 | return restTime; 36 | } 37 | 38 | public void setRestTime(int restTime) { 39 | this.restTime = restTime; 40 | } 41 | 42 | public static SettingData of(boolean selected, int restTimeTFText, int worTimeTFText) { 43 | SettingData settings = new SettingData(); 44 | settings.setRestTime(restTimeTFText); 45 | settings.setWorkTime(worTimeTFText); 46 | settings.setOpen(selected); 47 | return settings; 48 | } 49 | 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/icu/jogeen/stopcoding/service/TimerService.java: -------------------------------------------------------------------------------- 1 | package icu.jogeen.stopcoding.service; 2 | 3 | import icu.jogeen.stopcoding.data.DataCenter; 4 | import icu.jogeen.stopcoding.data.SettingData; 5 | import icu.jogeen.stopcoding.task.WorkTask; 6 | 7 | import java.time.LocalDateTime; 8 | import java.time.ZoneId; 9 | import java.time.format.DateTimeFormatter; 10 | import java.util.Date; 11 | import java.util.Timer; 12 | 13 | public class TimerService { 14 | 15 | public static SettingData saveSetting(boolean selected,String restTimeTFText,String worTimeTFText){ 16 | DataCenter.settingData = SettingData.of(selected, 17 | DataCenter.isInteger(restTimeTFText) ? Integer.parseInt(restTimeTFText) : SettingData.DEFAULT_REST_TIME, 18 | DataCenter.isInteger(worTimeTFText) ? Integer.parseInt(worTimeTFText) : SettingData.DEFAULT_WORK_TIME); 19 | return DataCenter.settingData; 20 | } 21 | 22 | 23 | /** 24 | * 休息倒计时 25 | */ 26 | public static void restCountDown() { 27 | DataCenter.restCountDownSecond--; 28 | } 29 | 30 | /** 31 | * 初始化休息倒计时间 32 | */ 33 | public static void initRestCountDown() { 34 | if (DataCenter.restCountDownSecond == -1) { 35 | DataCenter.restCountDownSecond = 60 * DataCenter.settingData.getRestTime(); 36 | } 37 | } 38 | 39 | /** 40 | * 设置下一次工作时间 41 | */ 42 | public static void resetNextWorkTime() { 43 | DataCenter.nextWorkTime = LocalDateTime.now().plusMinutes(DataCenter.settingData.getRestTime()); 44 | 45 | } 46 | 47 | /** 48 | * 设置下一次休息时间 49 | */ 50 | public static void resetNexRestTime() { 51 | DataCenter.nextRestTime = LocalDateTime.now().plusMinutes(DataCenter.settingData.getWorkTime()); 52 | 53 | } 54 | 55 | public static String openTimer() { 56 | //清楚之前的所有任务 57 | DataCenter.workTimer.cancel(); 58 | //创建开启定时任务 59 | DataCenter.workTimer = new Timer(); 60 | // 61 | resetNexRestTime(); 62 | DataCenter.workTimer.schedule(new WorkTask(), Date.from(DataCenter.nextRestTime.atZone(ZoneId.systemDefault()).toInstant())); 63 | DataCenter.status = DataCenter.WORKING; 64 | DataCenter.settingData.setOpen(true); 65 | return String.format("Start StopCoding countdown, after %s minutes, the next rest time is %s", DataCenter.settingData.getWorkTime(), getDateStr(DataCenter.nextRestTime)); 66 | } 67 | 68 | 69 | public static String closeTimer() { 70 | //清除之前的所有任务 71 | DataCenter.workTimer.cancel(); 72 | DataCenter.settingData.setOpen(false); 73 | DataCenter.status = DataCenter.CLOSE; 74 | return "Stop StopCoding"; 75 | } 76 | 77 | public static String getCountDownDesc(int time) { 78 | if (time > 0) { 79 | int hour = time / (60 * 60); 80 | int minute = (time % (60 * 60)) / 60; 81 | int second = time % 60; 82 | return "Rest countdown:" + String.format("%s:%s:%s", fillZero(hour), fillZero(minute), fillZero(second)); 83 | } 84 | return "The rest is over"; 85 | } 86 | 87 | 88 | public static String fillZero(int time) { 89 | if (time < 10) { 90 | return "0" + time; 91 | } 92 | return "" + time; 93 | 94 | } 95 | 96 | 97 | public static String getDateStr(LocalDateTime localDateTime) { 98 | DateTimeFormatter df = DateTimeFormatter.ofPattern("HH:mm:ss"); 99 | return df.format(localDateTime); 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/icu/jogeen/stopcoding/task/RestTask.java: -------------------------------------------------------------------------------- 1 | package icu.jogeen.stopcoding.task; 2 | 3 | import com.intellij.notification.Notification; 4 | import com.intellij.notification.NotificationDisplayType; 5 | import com.intellij.notification.NotificationGroup; 6 | import com.intellij.notification.Notifications; 7 | import com.intellij.openapi.ui.MessageType; 8 | import icu.jogeen.stopcoding.data.DataCenter; 9 | import icu.jogeen.stopcoding.service.TimerService; 10 | import icu.jogeen.stopcoding.ui.TipsDialog; 11 | 12 | import javax.swing.*; 13 | import java.util.TimerTask; 14 | 15 | public class RestTask extends TimerTask { 16 | TipsDialog tipsDialog; 17 | 18 | 19 | public RestTask(TipsDialog tipsDialog) { 20 | this.tipsDialog = tipsDialog; 21 | } 22 | 23 | @Override 24 | public void run() { 25 | //设置下次工作时间(休息结束的时间) 26 | TimerService.resetNextWorkTime(); 27 | //初始化休息倒计时 28 | TimerService.initRestCountDown(); 29 | TimerService.restCountDown();//倒计时 30 | if (DataCenter.restCountDownSecond >= 0) { //休息时间内 31 | String desc = TimerService.getCountDownDesc(DataCenter.restCountDownSecond); 32 | tipsDialog.setDesc(String.format("Take a break,StopCoding! %s", desc)); 33 | } else {//休息时间结束 34 | DataCenter.reskTimer.cancel(); //关闭定时器 35 | tipsDialog.dispose(); //关闭提示窗口 36 | String notifyStr = TimerService.openTimer();// 开启工作计时器 37 | //发一个通知 38 | NotificationGroup notificationGroup = new NotificationGroup("StopCoding", NotificationDisplayType.BALLOON, true); 39 | Notification notification = notificationGroup.createNotification(notifyStr, MessageType.INFO); 40 | Notifications.Bus.notify(notification); 41 | 42 | JOptionPane.showMessageDialog(null, notifyStr, "tips",JOptionPane.INFORMATION_MESSAGE); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/icu/jogeen/stopcoding/task/WorkTask.java: -------------------------------------------------------------------------------- 1 | package icu.jogeen.stopcoding.task; 2 | 3 | import icu.jogeen.stopcoding.data.DataCenter; 4 | import icu.jogeen.stopcoding.ui.TipsDialog; 5 | 6 | import java.time.LocalDateTime; 7 | import java.util.TimerTask; 8 | 9 | public class WorkTask extends TimerTask { 10 | @Override 11 | public void run() { 12 | DataCenter.status = DataCenter.RESTING; 13 | DataCenter.nextWorkTime = LocalDateTime.now().plusMinutes(DataCenter.settingData.getRestTime()); 14 | TipsDialog tipsDialog = new TipsDialog(); 15 | tipsDialog.setVisible(true); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/icu/jogeen/stopcoding/ui/SettingDialog.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 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 |
157 | -------------------------------------------------------------------------------- /src/main/java/icu/jogeen/stopcoding/ui/SettingDialog.java: -------------------------------------------------------------------------------- 1 | package icu.jogeen.stopcoding.ui; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.awt.event.ActionListener; 5 | import java.awt.event.KeyEvent; 6 | import java.awt.event.WindowAdapter; 7 | import java.awt.event.WindowEvent; 8 | import javax.swing.JButton; 9 | import javax.swing.JComponent; 10 | import javax.swing.JDialog; 11 | import javax.swing.JLabel; 12 | import javax.swing.JOptionPane; 13 | import javax.swing.JPanel; 14 | import javax.swing.JRadioButton; 15 | import javax.swing.JTextField; 16 | import javax.swing.KeyStroke; 17 | import javax.swing.event.ChangeEvent; 18 | import javax.swing.event.ChangeListener; 19 | import com.intellij.ide.util.PropertiesComponent; 20 | import com.intellij.notification.Notification; 21 | import com.intellij.notification.NotificationDisplayType; 22 | import com.intellij.notification.NotificationGroup; 23 | import com.intellij.notification.Notifications; 24 | import com.intellij.openapi.ui.MessageType; 25 | import icu.jogeen.stopcoding.data.DataCenter; 26 | import icu.jogeen.stopcoding.data.SettingData; 27 | import icu.jogeen.stopcoding.service.TimerService; 28 | 29 | public class SettingDialog extends JDialog { 30 | private JPanel contentPane; 31 | private JButton buttonOK; 32 | private JButton buttonCancel; 33 | private JRadioButton openRbtn; 34 | private JTextField workTimeTF; 35 | private JTextField restTimeTF; 36 | private JLabel descJL; 37 | 38 | public SettingDialog() { 39 | setContentPane(contentPane); 40 | setModal(true); 41 | getRootPane().setDefaultButton(buttonOK); 42 | setTitle("StopCoding Setting"); 43 | setLocation(400, 200);//距离屏幕左上角的其实位置 44 | setSize(500, 300);//对话框的长宽 45 | 46 | //绑定确定按钮事件 47 | buttonOK.addActionListener(new ActionListener() { 48 | public void actionPerformed(ActionEvent e) { 49 | onOK(); 50 | } 51 | }); 52 | //绑定取消按钮事件 53 | buttonCancel.addActionListener(new ActionListener() { 54 | public void actionPerformed(ActionEvent e) { 55 | onCancel(); 56 | } 57 | }); 58 | //绑定关闭按钮事件 59 | setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); 60 | addWindowListener(new WindowAdapter() { 61 | public void windowClosing(WindowEvent e) { 62 | onCancel(); 63 | } 64 | }); 65 | contentPane.registerKeyboardAction(new ActionListener() { 66 | public void actionPerformed(ActionEvent e) { 67 | onCancel(); 68 | } 69 | }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); 70 | //绑定启用选择按钮时间 71 | openRbtn.addChangeListener(new ChangeListener() { 72 | @Override 73 | public void stateChanged(ChangeEvent e) { 74 | openRbtn.setText(openRbtn.isSelected() ? "Running" : "Stopped"); 75 | } 76 | }); 77 | 78 | //初始化渲染设置界面 79 | SettingData settings = new SettingData(); 80 | PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(); 81 | propertiesComponent.loadFields(settings); 82 | DataCenter.settingData = settings; 83 | openRbtn.setSelected(DataCenter.settingData.isOpen()); 84 | workTimeTF.setText(DataCenter.settingData.getWorkTime() + ""); 85 | restTimeTF.setText(DataCenter.settingData.getRestTime() + ""); 86 | descJL.setText(DataCenter.getSettingDesc()); 87 | openRbtn.setText(openRbtn.isSelected() ? "Running" : "Stopped"); 88 | } 89 | 90 | /** 91 | * 点击确定 92 | */ 93 | private void onOK() { 94 | //保持设置 95 | SettingData settings = TimerService.saveSetting(openRbtn.isSelected(), restTimeTF.getText(), workTimeTF.getText()); 96 | PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(); 97 | propertiesComponent.saveFields(settings); 98 | 99 | String notifyStr; 100 | if (openRbtn.isSelected()) { 101 | //开启定时 102 | notifyStr = TimerService.openTimer(); 103 | } else { 104 | //关闭定时 105 | notifyStr = TimerService.closeTimer(); 106 | } 107 | NotificationGroup notificationGroup = new NotificationGroup("StopCoding", NotificationDisplayType.BALLOON, true); 108 | Notification notification = notificationGroup.createNotification(notifyStr, MessageType.INFO); 109 | Notifications.Bus.notify(notification); 110 | 111 | JOptionPane.showMessageDialog(null, notifyStr, "tips",JOptionPane.INFORMATION_MESSAGE); 112 | dispose(); 113 | } 114 | 115 | 116 | private void onCancel() { 117 | // add your code here if necessary 118 | dispose(); 119 | } 120 | 121 | 122 | public static void main(String[] args) { 123 | SettingDialog dialog = new SettingDialog(); 124 | dialog.pack(); 125 | dialog.setVisible(true); 126 | System.exit(0); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/main/java/icu/jogeen/stopcoding/ui/TipsDialog.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 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 |
75 | -------------------------------------------------------------------------------- /src/main/java/icu/jogeen/stopcoding/ui/TipsDialog.java: -------------------------------------------------------------------------------- 1 | package icu.jogeen.stopcoding.ui; 2 | 3 | import icu.jogeen.stopcoding.data.DataCenter; 4 | import icu.jogeen.stopcoding.service.TimerService; 5 | import icu.jogeen.stopcoding.task.RestTask; 6 | import icu.jogeen.stopcoding.task.WorkTask; 7 | 8 | import javax.swing.*; 9 | import java.awt.*; 10 | import java.awt.event.*; 11 | import java.time.LocalDateTime; 12 | import java.time.ZoneId; 13 | import java.time.format.DateTimeFormatter; 14 | import java.util.Date; 15 | import java.util.Timer; 16 | 17 | public class TipsDialog extends JDialog { 18 | private JPanel contentPane; 19 | private JButton buttonOK; 20 | private JLabel tipsJL; 21 | 22 | public TipsDialog() { 23 | setContentPane(contentPane); 24 | setModal(true); 25 | getRootPane().setDefaultButton(buttonOK); 26 | setTitle("StopCoding"); 27 | setLocation(400, 200);//距离屏幕左上角的其实位置 28 | setSize(500, 200);//对话框的长宽 29 | 30 | buttonOK.addActionListener(new ActionListener() { 31 | public void actionPerformed(ActionEvent e) { 32 | onOK(); 33 | } 34 | }); 35 | setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); 36 | addWindowListener(new WindowAdapter() { 37 | public void windowClosing(WindowEvent e) { 38 | onCancel(); 39 | } 40 | }); 41 | 42 | contentPane.registerKeyboardAction(new ActionListener() { 43 | public void actionPerformed(ActionEvent e) { 44 | onCancel(); 45 | } 46 | }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); 47 | DataCenter.reskTimer = new Timer(); 48 | DataCenter.reskTimer.schedule(new RestTask(this), new Date(), 1000); 49 | } 50 | 51 | private void onOK() { 52 | handle(); 53 | } 54 | 55 | private void onCancel() { 56 | handle(); 57 | } 58 | 59 | private void handle() { 60 | //do nothing! 61 | JOptionPane.showMessageDialog(null, "Go to have a rest. When the time comes, I'll turn it off automatically.", "tips",JOptionPane.INFORMATION_MESSAGE); 62 | } 63 | 64 | public void setDesc(String desc) { 65 | tipsJL.setText(desc); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | icu.jogeen.StopCoding.id 3 | StopCoding 4 | 1.2.1 5 | jogeen 6 | 7 | This is a work timer.It can set every working period to remind you that it's time to have a rest, drink some water and exercise your body. 9 | Only in this way can you really work healthily

10 |
    11 |
  1. In the tools menu bar, open stopcoding.
  2. 12 |
  3. Set working hours and rest time, and save them.
  4. 13 |
  5. When the set time comes, there will be a pop-up box to remind you to rest, so that you can not operate idea temporarily.
  6. 14 |
15 |
16 |

如果你也经常沉迷于写代码,忘了起身休息喝水,那么试试这个插件吧

17 |
    18 |
  1. 在菜单栏的Tools中,打开StopCoding插件进行设置
  2. 19 |
  3. 设置工作时间和休息时间,并且保存
  4. 20 |
  5. 当设置的时间一到,就会有弹框提醒你休息,让你暂时不能操作idea
  6. 21 |
22 |

项目地址:https://github.com/jogeen/StopCoding

23 | ]]>
24 | 25 | 27 |
  • V1.2 add icon(Thanks for the icon provided by my good friend Hu Wei).
  • 28 |
  • V1.1 update Guide to use.
  • 29 |
  • V1.0 release.
  • 30 | 31 | ]]> 32 |
    33 | 34 | 35 | 36 | com.intellij.modules.lang 37 | 38 | 39 | 40 | 41 | 42 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |
    -------------------------------------------------------------------------------- /src/main/resources/META-INF/pluginIcon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/pluginIcon_dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/main/resources/img/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jogeen/StopCoding/2e68bb929ff58d1f959e8193d3fb2e93581d55e3/src/main/resources/img/stop.png --------------------------------------------------------------------------------