├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src └── main ├── java ├── bean │ ├── ArtifactDetail.java │ ├── ArtifactItem.java │ ├── DependenceGroupItem.java │ ├── GroupResult.java │ ├── PackageItem.java │ ├── PackageResult.java │ ├── RepositoryItem.java │ └── VersionItem.java ├── core │ └── Callback.java ├── model │ ├── ArtifactTableModel.java │ ├── GroupTableModel.java │ ├── PackageTableModel.java │ └── VersionTableModel.java ├── utils │ ├── ClipboardUtil.java │ ├── HttpUtil.java │ ├── MavenDataUtil.java │ ├── NotificationUtils.java │ └── NpmDataUtil.java └── view │ ├── ArtifactTable.java │ ├── DetailDialog.form │ ├── DetailDialog.java │ ├── MainWindow.form │ ├── MainWindow.java │ ├── MavenWindow.form │ ├── MavenWindow.java │ ├── NpmWindow.form │ └── NpmWindow.java └── resources ├── META-INF ├── plugin.xml └── pluginIcon.svg └── maven.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Project exclude paths 2 | /.gradle/ 3 | /build/ 4 | /build/classes/java/main/ 5 | /.idea/ 6 | /out/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021-present jimeng(Kimen) Tang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Jetbrains Plugin: Search in Repository 2 | 3 | ![GitHub release (latest by date)](https://img.shields.io/github/v/release/kimentanm/search-in-repo?label=version&style=flat-square&logo=github&color=green) 4 | ![star](https://img.shields.io/github/stars/kimentanm/search-in-repo?style=flat-square&logo=github) 5 | 6 | Jetbrains插件,支持Jetbrains全系IDE。一款依赖查询工具,输入查询关键词,选择版本即可获得相应的依赖信息(支持Maven仓库和NPM仓库)。 7 | 8 | > Maven依赖查询当前暂时仅支持Maven和Gradle两种依赖 9 | 10 | > 本插件解决了,访问mvnrepository.com时会出现`One more step`验证的问题 11 | > 12 | 13 | ## 安装 14 | #### 从Intellij Plugin仓库下载 15 | 在Plugin repository中搜索Search in Repository 16 | [Plugin HomePage](https://plugins.jetbrains.com/plugin/16427-search-in-repository) 17 | ![](https://gitee.com/Kimentanm/image-store/raw/master/img/20210326090134.png) 18 | 19 | #### 源码编译 20 | - 使用Gradle的`buildPlugin`脚本构建 21 | - 项目根路径找到build/distributions/search-in-repo-x.x.x.zip文件 22 | - IDE中选择`Install plugin from disk`,选择上述zip文件 23 | - 下载zip文件 [search-in-repo-1.3.5.zip](https://img.whalenas.com:283/file/search-in-repo-1.3.5.zip) 24 | 25 | ## 使用 26 | - 插件安装好,在IDE的右侧菜单栏会出现一个`Search`菜单 27 | - 先输入关键词搜索,比如输入`mybatis`,然后点击`search`按钮或者直接回车 28 | ![](https://gitee.com/Kimentanm/image-store/raw/master/img/20210330140011.png) 29 | - 使用`Prev`和`Next`按钮切换分页 30 | - 双击某一列,搜索详细版本列表 31 | ![](https://cdn.jsdelivr.net/gh/kimentanm/image-store/img/20210322214918.png) 32 | - 双击某一列,弹出详情窗口,直接复制或者点击`Copy`按钮 33 | ![image-20210324164221706](https://gitee.com/Kimentanm/image-store/raw/master/img/20210324164221.png) 34 | 35 | ## 预览 36 | ![](https://gitee.com/Kimentanm/image-store/raw/master/img/20210330140520.png) 37 | ![](https://gitee.com/Kimentanm/image-store/raw/master/img/20210330140625.png) 38 | 39 | ## Change Notes 40 | - v1.3.5 41 | 修复适配最新版本编辑器 42 | - v1.3.4 43 | 适配最新版本编辑器 44 | - v1.3.3 45 | 修复双击复制NPM命令错误的问题 46 | - v1.3.2 47 | 双击NPM依赖可复制install命令到剪贴板中 48 | fix bugs 49 | - v1.3.0 50 | 新增Maven Repository Tab 51 | fix bugs 52 | - v1.2.2 53 | NPM增加名称列 54 | 解决NPM包搜索结果无法展示的问题 55 | - v1.2.1 56 | 新增错误信息提示 57 | fix bugs 58 | - v1.2.0 59 | 新增NPM依赖查询 60 | - v1.1.1 61 | 发布插件到Jetbrains插件仓库 62 | 增加插件英文介绍 63 | 解决插件适配性问题 64 | - v1.1.0 65 | 新增排序条件 `relevance | popular | newest` 66 | 解决排序失效的bug 67 | 解决分页错误的bug 68 | - v1.0.0 69 | 发布的第一个版本,基础功能均已完成。 70 | 输入ArtifactId关键字,选择版本即可查询到相关依赖信息 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | id 'org.jetbrains.intellij' version '1.17.4' 4 | } 5 | 6 | group 'com.kimen.plugin' 7 | version '1.3.5' 8 | 9 | sourceCompatibility = JavaVersion.VERSION_17 10 | 11 | repositories { 12 | mavenCentral() 13 | jcenter() 14 | } 15 | 16 | dependencies { 17 | testImplementation group: 'junit', name: 'junit', version: '4.12' 18 | } 19 | 20 | // See https://github.com/JetBrains/gradle-intellij-plugin/ 21 | intellij { 22 | version = '2024.1' 23 | updateSinceUntilBuild = true 24 | sameSinceUntilBuild = false 25 | } 26 | 27 | patchPluginXml { 28 | sinceBuild = '191.*' 29 | untilBuild = null 30 | } 31 | 32 | tasks.withType(JavaCompile) { 33 | options.encoding = "UTF-8" 34 | } 35 | buildSearchableOptions.enabled = false -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kimentanm/search-in-repo/4127a640307c4f9662b7765fc2c6a9c88cd18747/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Jul 15 10:09:28 CST 2020 2 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip 3 | distributionBase=GRADLE_USER_HOME 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'search-in-repo' 2 | 3 | -------------------------------------------------------------------------------- /src/main/java/bean/ArtifactDetail.java: -------------------------------------------------------------------------------- 1 | package bean; 2 | 3 | public class ArtifactDetail { 4 | 5 | private String artifactId; 6 | private String version; 7 | private String license; 8 | private String category; 9 | private String organization; 10 | private String homePage; 11 | private String date; 12 | private String repository; 13 | private String mavenContent; 14 | private String gradleContent; 15 | 16 | public String getArtifactId() { 17 | return artifactId == null ? "" : artifactId; 18 | } 19 | 20 | public void setArtifactId(String artifactId) { 21 | this.artifactId = artifactId; 22 | } 23 | 24 | public String getVersion() { 25 | return version == null ? "" : version; 26 | } 27 | 28 | public void setVersion(String version) { 29 | this.version = version; 30 | } 31 | 32 | public String getLicense() { 33 | return license == null ? "" : license; 34 | } 35 | 36 | public void setLicense(String license) { 37 | this.license = license; 38 | } 39 | 40 | public String getCategory() { 41 | return category == null ? "" : category; 42 | } 43 | 44 | public void setCategory(String category) { 45 | this.category = category; 46 | } 47 | 48 | public String getOrganization() { 49 | return organization == null ? "" : organization; 50 | } 51 | 52 | public void setOrganization(String organization) { 53 | this.organization = organization; 54 | } 55 | 56 | public String getHomePage() { 57 | return homePage == null ? "" : homePage; 58 | } 59 | 60 | public void setHomePage(String homePage) { 61 | this.homePage = homePage; 62 | } 63 | 64 | public String getDate() { 65 | return date == null ? "" : date; 66 | } 67 | 68 | public void setDate(String date) { 69 | this.date = date; 70 | } 71 | 72 | public String getRepository() { 73 | return repository == null ? "" : repository; 74 | } 75 | 76 | public void setRepository(String repository) { 77 | this.repository = repository; 78 | } 79 | 80 | public String getMavenContent() { 81 | return mavenContent; 82 | } 83 | 84 | public void setMavenContent(String mavenContent) { 85 | this.mavenContent = mavenContent; 86 | } 87 | 88 | public String getGradleContent() { 89 | return gradleContent; 90 | } 91 | 92 | public void setGradleContent(String gradleContent) { 93 | this.gradleContent = gradleContent; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/bean/ArtifactItem.java: -------------------------------------------------------------------------------- 1 | package bean; 2 | 3 | import utils.MavenDataUtil; 4 | 5 | public class ArtifactItem { 6 | 7 | private String version; 8 | private String repository; 9 | private String usages; 10 | private String date; 11 | private String groupId; 12 | private String artifactId; 13 | 14 | public ArtifactItem() { 15 | } 16 | 17 | public String getVersion() { 18 | return version; 19 | } 20 | 21 | public void setVersion(String version) { 22 | this.version = version; 23 | } 24 | 25 | public String getRepository() { 26 | return repository; 27 | } 28 | 29 | public void setRepository(String repository) { 30 | this.repository = repository; 31 | } 32 | 33 | public String getUsages() { 34 | return usages; 35 | } 36 | 37 | public void setUsages(String usages) { 38 | this.usages = usages; 39 | } 40 | 41 | public String getDate() { 42 | return date; 43 | } 44 | 45 | public void setDate(String date) { 46 | this.date = date; 47 | } 48 | 49 | public String getGroupId() { 50 | return groupId; 51 | } 52 | 53 | public void setGroupId(String groupId) { 54 | this.groupId = groupId; 55 | } 56 | 57 | public String getArtifactId() { 58 | return artifactId; 59 | } 60 | 61 | public void setArtifactId(String artifactId) { 62 | this.artifactId = artifactId; 63 | } 64 | 65 | public Object getValueByColumn(String columnName) { 66 | switch (columnName) { 67 | case "Version": 68 | return getVersion(); 69 | case "Repository": 70 | return getRepository(); 71 | case "Usages": 72 | return MavenDataUtil.parseInt(getUsages()); 73 | case "Date": 74 | return getDate(); 75 | default: 76 | return ""; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/bean/DependenceGroupItem.java: -------------------------------------------------------------------------------- 1 | package bean; 2 | 3 | import utils.MavenDataUtil; 4 | 5 | import javax.swing.*; 6 | 7 | public class DependenceGroupItem { 8 | 9 | private ImageIcon imageIcon; 10 | private String artifactLabel; 11 | private String artifactId; 12 | private String groupLabel; 13 | private String usagesLabel; 14 | 15 | public ImageIcon getImageIcon() { 16 | return imageIcon; 17 | } 18 | 19 | public void setImageIcon(ImageIcon imageIcon) { 20 | this.imageIcon = imageIcon; 21 | } 22 | 23 | public String getArtifactLabel() { 24 | return artifactLabel; 25 | } 26 | 27 | public void setArtifactLabel(String artifactLabel) { 28 | this.artifactLabel = artifactLabel; 29 | } 30 | 31 | public String getGroupLabel() { 32 | return groupLabel; 33 | } 34 | 35 | public void setGroupLabel(String groupLabel) { 36 | this.groupLabel = groupLabel; 37 | } 38 | 39 | public String getUsagesLabel() { 40 | return usagesLabel; 41 | } 42 | 43 | public void setUsagesLabel(String usagesLabel) { 44 | this.usagesLabel = usagesLabel; 45 | } 46 | 47 | public String getArtifactId() { 48 | return artifactId; 49 | } 50 | 51 | public void setArtifactId(String artifactId) { 52 | this.artifactId = artifactId; 53 | } 54 | 55 | public Object getValueByColumn(String columnName) { 56 | switch (columnName) { 57 | case "Group ID": 58 | return getGroupLabel(); 59 | case "Artifact Title" : 60 | return getArtifactLabel(); 61 | case "Artifact ID": 62 | return getArtifactId(); 63 | case "Usages": 64 | return MavenDataUtil.parseInt(getUsagesLabel()); 65 | default: 66 | return ""; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/bean/GroupResult.java: -------------------------------------------------------------------------------- 1 | package bean; 2 | 3 | import java.util.List; 4 | 5 | public class GroupResult { 6 | 7 | private List data; 8 | private int totalPage; 9 | 10 | public List getData() { 11 | return data; 12 | } 13 | 14 | public void setData(List data) { 15 | this.data = data; 16 | } 17 | 18 | public int getTotalPage() { 19 | return totalPage; 20 | } 21 | 22 | public void setTotalPage(int totalPage) { 23 | this.totalPage = totalPage; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/bean/PackageItem.java: -------------------------------------------------------------------------------- 1 | package bean; 2 | 3 | public class PackageItem { 4 | 5 | private String packageName; 6 | private String description; 7 | private String author; 8 | private String lastVersion; 9 | 10 | public String getPackageName() { 11 | return packageName; 12 | } 13 | 14 | public void setPackageName(String packageName) { 15 | this.packageName = packageName; 16 | } 17 | 18 | public String getDescription() { 19 | return description; 20 | } 21 | 22 | public void setDescription(String description) { 23 | this.description = description; 24 | } 25 | 26 | public String getAuthor() { 27 | return author; 28 | } 29 | 30 | public void setAuthor(String author) { 31 | this.author = author; 32 | } 33 | 34 | public String getLastVersion() { 35 | return lastVersion; 36 | } 37 | 38 | public void setLastVersion(String lastVersion) { 39 | this.lastVersion = lastVersion; 40 | } 41 | 42 | public Object getValueByColumn(String columnName) { 43 | switch (columnName) { 44 | case "Package Name": 45 | return getPackageName(); 46 | case "Author": 47 | return getAuthor(); 48 | case "Last Version": 49 | return getLastVersion(); 50 | case "Description": 51 | return getDescription(); 52 | default: 53 | return ""; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/bean/PackageResult.java: -------------------------------------------------------------------------------- 1 | package bean; 2 | 3 | import java.util.List; 4 | 5 | public class PackageResult { 6 | 7 | private List data; 8 | private int totalPage; 9 | 10 | public List getData() { 11 | return data; 12 | } 13 | 14 | public void setData(List data) { 15 | this.data = data; 16 | } 17 | 18 | public int getTotalPage() { 19 | return totalPage; 20 | } 21 | 22 | public void setTotalPage(int totalPage) { 23 | this.totalPage = totalPage; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/bean/RepositoryItem.java: -------------------------------------------------------------------------------- 1 | package bean; 2 | 3 | public class RepositoryItem { 4 | 5 | private String title; 6 | private String path; 7 | 8 | public String getTitle() { 9 | return title; 10 | } 11 | 12 | public void setTitle(String title) { 13 | this.title = title; 14 | } 15 | 16 | public String getPath() { 17 | return path; 18 | } 19 | 20 | public void setPath(String path) { 21 | this.path = path; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/bean/VersionItem.java: -------------------------------------------------------------------------------- 1 | package bean; 2 | 3 | public class VersionItem { 4 | 5 | private String version; 6 | private Integer downloads; 7 | private String published; 8 | private String packageName; 9 | 10 | public String getVersion() { 11 | return version; 12 | } 13 | 14 | public void setVersion(String version) { 15 | this.version = version; 16 | } 17 | 18 | public Integer getDownloads() { 19 | return downloads; 20 | } 21 | 22 | public void setDownloads(Integer downloads) { 23 | this.downloads = downloads; 24 | } 25 | 26 | public String getPublished() { 27 | return published; 28 | } 29 | 30 | public void setPublished(String published) { 31 | this.published = published; 32 | } 33 | 34 | public String getPackageName() { 35 | return packageName; 36 | } 37 | 38 | public void setPackageName(String packageName) { 39 | this.packageName = packageName; 40 | } 41 | 42 | public Object getValueByColumn(String columnName) { 43 | switch (columnName) { 44 | case "Version": 45 | return getVersion(); 46 | case "Weekly Downloads": 47 | return getDownloads(); 48 | case "Published": 49 | return getPublished(); 50 | case "Package Name": 51 | return getPackageName(); 52 | default: 53 | return ""; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/core/Callback.java: -------------------------------------------------------------------------------- 1 | package core; 2 | 3 | /** 4 | * Created by kimen on 2018/6/14. 5 | */ 6 | 7 | public interface Callback { 8 | 9 | /** 10 | * 数据请求成功 11 | * @param data 请求到的数据 12 | */ 13 | void onSuccess(T data); 14 | /** 15 | * 使用网络API接口请求方式时,虽然已经请求成功但是由 16 | * 于{@code msg}的原因无法正常返回数据。 17 | */ 18 | void onFailure(String msg); 19 | /** 20 | * 请求数据失败,指在请求网络API接口请求方式时,出现无法联网、 21 | * 缺少权限,内存泄露等原因导致无法连接到请求数据源。 22 | */ 23 | void onError(String mdg); 24 | 25 | /** 26 | * 当请求数据结束时,无论请求结果是成功,失败或是抛出异常都会执行此方法给用户做处理,通常做网络 27 | * 请求时可以在此处隐藏“正在加载”的等待控件 28 | */ 29 | void onComplete(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/model/ArtifactTableModel.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import bean.ArtifactItem; 4 | import com.intellij.ui.table.JBTable; 5 | import org.apache.commons.lang3.StringUtils; 6 | 7 | import javax.swing.*; 8 | import javax.swing.table.DefaultTableCellRenderer; 9 | import javax.swing.table.DefaultTableModel; 10 | import javax.swing.table.JTableHeader; 11 | import javax.swing.table.TableColumnModel; 12 | import java.awt.*; 13 | import java.util.List; 14 | import java.util.Vector; 15 | 16 | public class ArtifactTableModel extends DefaultTableModel { 17 | 18 | private final String[] columnNames = {"Index", "Version", "Repository", "Usages", "Date"}; 19 | 20 | private final Class[] types = { Integer.class, String.class, String.class, Integer.class, String.class }; 21 | 22 | private JTable table; 23 | 24 | private List data; 25 | 26 | public ArtifactTableModel(JTable table) { 27 | this.table = table; 28 | table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 29 | table.setRowHeight(30); 30 | table.setModel(this); 31 | setColumnIdentifiers(columnNames); 32 | // 设置表头样式 33 | JTableHeader tableHeader = table.getTableHeader(); 34 | tableHeader.setFont(new Font(null, Font.BOLD, 12)); 35 | TableColumnModel columnModel = table.getColumnModel(); 36 | columnModel.getColumn(0).setPreferredWidth(80); 37 | for (int i = 1; i < columnNames.length; i++) { 38 | columnModel.getColumn(i).setPreferredWidth(125); 39 | } 40 | DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); 41 | renderer.setHorizontalAlignment(JTextField.CENTER); 42 | table.getColumn("Index").setCellRenderer(renderer); 43 | } 44 | 45 | private Vector convertData(ArtifactItem artifactItem) { 46 | // 与columnNames中的元素保持一致 47 | Vector v = new Vector(columnNames.length); 48 | for (String columnName : columnNames) { 49 | v.addElement(artifactItem.getValueByColumn(columnName)); 50 | } 51 | return v; 52 | } 53 | 54 | /** 55 | * 查找列项中的valueName所在的行 56 | * 57 | * @param columnIndex 列号 58 | * @param value 值 59 | * @return 如果不存在返回-1 60 | */ 61 | protected int findRowIndex(int columnIndex, String value) { 62 | int rowCount = getRowCount(); 63 | for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { 64 | Object valueAt = getValueAt(rowIndex, columnIndex); 65 | if (StringUtils.equalsIgnoreCase(value, valueAt.toString())) { 66 | return rowIndex; 67 | } 68 | } 69 | return -1; 70 | } 71 | 72 | /** 73 | * 参考源码{@link DefaultTableModel#setValueAt},此为直接更新行,提高点效率 74 | * 75 | * @param rowIndex 76 | * @param rowData 77 | */ 78 | protected void updateRow(int rowIndex, Vector rowData) { 79 | dataVector.set(rowIndex, rowData); 80 | // 通知listeners刷新ui 81 | fireTableRowsUpdated(rowIndex, rowIndex); 82 | } 83 | 84 | /** 85 | * 按照编码顺序初始化,for 每次刷新都乱序,没办法控制显示顺序 86 | * 87 | * @param list 88 | */ 89 | public void setupTable(List list) { 90 | this.data = list; 91 | for (int i = 0; i < list.size(); i++) { 92 | updateData(list.get(i), i); 93 | } 94 | } 95 | 96 | private void updateData(ArtifactItem artifactItem, int index) { 97 | Vector convertData = convertData(artifactItem); 98 | convertData.set(0, index + 1); 99 | addRow(convertData); 100 | } 101 | 102 | /** 103 | * 设置表格条纹(斑马线) 104 | * 105 | * @param striped true设置条纹 106 | * @throws RuntimeException 如果table不是{@link JBTable}类型,请自行实现setStriped 107 | */ 108 | public void setStriped(boolean striped) { 109 | if (table instanceof JBTable) { 110 | ((JBTable) table).setStriped(striped); 111 | } else { 112 | throw new RuntimeException("table不是JBTable类型,请自行实现setStriped"); 113 | } 114 | } 115 | 116 | @Override 117 | public boolean isCellEditable(int row, int column) { 118 | return false; 119 | } 120 | 121 | public List getData() { 122 | return data; 123 | } 124 | 125 | @Override 126 | public Class getColumnClass(int columnIndex) { 127 | return types[columnIndex]; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /src/main/java/model/GroupTableModel.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import bean.DependenceGroupItem; 4 | import com.intellij.ui.table.JBTable; 5 | import org.apache.commons.lang3.StringUtils; 6 | 7 | import javax.swing.*; 8 | import javax.swing.table.DefaultTableCellRenderer; 9 | import javax.swing.table.DefaultTableModel; 10 | import javax.swing.table.JTableHeader; 11 | import javax.swing.table.TableColumnModel; 12 | import java.awt.*; 13 | import java.util.List; 14 | import java.util.Vector; 15 | 16 | public class GroupTableModel extends DefaultTableModel { 17 | 18 | private final String[] columnNames = { "Index", "Artifact Title", "Artifact ID", "Group ID", "Usages" }; 19 | 20 | private final Class[] types = { Integer.class, String.class, String.class, String.class, Integer.class }; 21 | 22 | private JTable table; 23 | 24 | private List data; 25 | 26 | public GroupTableModel(JTable table) { 27 | this.table = table; 28 | table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 29 | table.setRowHeight(30); 30 | table.setModel(this); 31 | setColumnIdentifiers(columnNames); 32 | // 设置表头样式 33 | JTableHeader tableHeader = table.getTableHeader(); 34 | tableHeader.setFont(new Font(null, Font.BOLD, 12)); 35 | TableColumnModel columnModel = table.getColumnModel(); 36 | columnModel.getColumn(0).setPreferredWidth(80); 37 | columnModel.getColumn(1).setPreferredWidth(200); 38 | columnModel.getColumn(2).setPreferredWidth(200); 39 | columnModel.getColumn(3).setPreferredWidth(200); 40 | columnModel.getColumn(4).setPreferredWidth(100); 41 | DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); 42 | renderer.setHorizontalAlignment(JTextField.CENTER); 43 | table.getColumn("Index").setCellRenderer(renderer); 44 | } 45 | 46 | private Vector convertData(DependenceGroupItem groupItem) { 47 | // 与columnNames中的元素保持一致 48 | Vector v = new Vector(columnNames.length); 49 | for (String columnName : columnNames) { 50 | v.addElement(groupItem.getValueByColumn(columnName)); 51 | } 52 | return v; 53 | } 54 | 55 | /** 56 | * 查找列项中的valueName所在的行 57 | * 58 | * @param columnIndex 列号 59 | * @param value 值 60 | * @return 如果不存在返回-1 61 | */ 62 | protected int findRowIndex(int columnIndex, String value) { 63 | int rowCount = getRowCount(); 64 | for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { 65 | Object valueAt = getValueAt(rowIndex, columnIndex); 66 | if (StringUtils.equalsIgnoreCase(value, valueAt.toString())) { 67 | return rowIndex; 68 | } 69 | } 70 | return -1; 71 | } 72 | 73 | /** 74 | * 参考源码{@link DefaultTableModel#setValueAt},此为直接更新行,提高点效率 75 | * 76 | * @param rowIndex 77 | * @param rowData 78 | */ 79 | protected void updateRow(int rowIndex, Vector rowData) { 80 | dataVector.set(rowIndex, rowData); 81 | // 通知listeners刷新ui 82 | fireTableRowsUpdated(rowIndex, rowIndex); 83 | } 84 | 85 | /** 86 | * 按照编码顺序初始化,for 每次刷新都乱序,没办法控制显示顺序 87 | * 88 | * @param list 89 | */ 90 | public void setupTable(List list) { 91 | this.data = list; 92 | for (int i = 0; i < list.size(); i++) { 93 | updateData(list.get(i), i); 94 | } 95 | } 96 | 97 | private void updateData(DependenceGroupItem groupItem, int index) { 98 | Vector convertData = convertData(groupItem); 99 | convertData.set(0, index + 1); 100 | addRow(convertData); 101 | } 102 | 103 | /** 104 | * 设置表格条纹(斑马线) 105 | * 106 | * @param striped true设置条纹 107 | * @throws RuntimeException 如果table不是{@link JBTable}类型,请自行实现setStriped 108 | */ 109 | public void setStriped(boolean striped) { 110 | if (table instanceof JBTable) { 111 | ((JBTable) table).setStriped(striped); 112 | } else { 113 | throw new RuntimeException("table不是JBTable类型,请自行实现setStriped"); 114 | } 115 | } 116 | 117 | @Override 118 | public boolean isCellEditable(int row, int column) { 119 | return false; 120 | } 121 | 122 | public List getData() { 123 | return data; 124 | } 125 | 126 | @Override 127 | public Class getColumnClass(int columnIndex) { 128 | return types[columnIndex]; 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/main/java/model/PackageTableModel.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import bean.PackageItem; 4 | import com.intellij.ui.table.JBTable; 5 | import org.apache.commons.lang3.StringUtils; 6 | 7 | import javax.swing.*; 8 | import javax.swing.table.DefaultTableCellRenderer; 9 | import javax.swing.table.DefaultTableModel; 10 | import javax.swing.table.JTableHeader; 11 | import javax.swing.table.TableColumnModel; 12 | import java.awt.*; 13 | import java.util.List; 14 | import java.util.Vector; 15 | 16 | public class PackageTableModel extends DefaultTableModel { 17 | 18 | private final String[] columnNames = { "Index", "Package Name", "Author", "Last Version", "Description"}; 19 | 20 | private JBTable table; 21 | 22 | private List data; 23 | 24 | public PackageTableModel(JBTable table) { 25 | this.table = table; 26 | table.setAutoResizeMode(JBTable.AUTO_RESIZE_OFF); 27 | table.setRowHeight(30); 28 | table.setModel(this); 29 | setColumnIdentifiers(columnNames); 30 | // 设置表头样式 31 | JTableHeader tableHeader = table.getTableHeader(); 32 | tableHeader.setFont(new Font(null, Font.BOLD, 12)); 33 | TableColumnModel columnModel = table.getColumnModel(); 34 | columnModel.getColumn(0).setPreferredWidth(80); 35 | columnModel.getColumn(1).setPreferredWidth(200); 36 | columnModel.getColumn(2).setPreferredWidth(100); 37 | columnModel.getColumn(3).setPreferredWidth(100); 38 | columnModel.getColumn(4).setPreferredWidth(300); 39 | DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); 40 | renderer.setHorizontalAlignment(JTextField.CENTER); 41 | table.getColumn("Index").setCellRenderer(renderer); 42 | } 43 | 44 | private Vector convertData(PackageItem packageItem) { 45 | // 与columnNames中的元素保持一致 46 | Vector v = new Vector(columnNames.length); 47 | for (String columnName : columnNames) { 48 | v.addElement(packageItem.getValueByColumn(columnName)); 49 | } 50 | return v; 51 | } 52 | 53 | /** 54 | * 查找列项中的valueName所在的行 55 | * 56 | * @param columnIndex 列号 57 | * @param value 值 58 | * @return 如果不存在返回-1 59 | */ 60 | protected int findRowIndex(int columnIndex, String value) { 61 | int rowCount = getRowCount(); 62 | for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { 63 | Object valueAt = getValueAt(rowIndex, columnIndex); 64 | if (StringUtils.equalsIgnoreCase(value, valueAt.toString())) { 65 | return rowIndex; 66 | } 67 | } 68 | return -1; 69 | } 70 | 71 | /** 72 | * 参考源码{@link DefaultTableModel#setValueAt},此为直接更新行,提高点效率 73 | * 74 | * @param rowIndex 75 | * @param rowData 76 | */ 77 | protected void updateRow(int rowIndex, Vector rowData) { 78 | dataVector.set(rowIndex, rowData); 79 | // 通知listeners刷新ui 80 | fireTableRowsUpdated(rowIndex, rowIndex); 81 | } 82 | 83 | /** 84 | * 按照编码顺序初始化,for 每次刷新都乱序,没办法控制显示顺序 85 | * 86 | * @param list 87 | */ 88 | public void setupTable(List list) { 89 | this.data = list; 90 | for (int i = 0; i < list.size(); i++) { 91 | updateData(list.get(i), i); 92 | } 93 | } 94 | 95 | private void updateData(PackageItem packageItem, int index) { 96 | Vector convertData = convertData(packageItem); 97 | convertData.set(0, index + 1); 98 | addRow(convertData); 99 | } 100 | 101 | /** 102 | * 设置表格条纹(斑马线) 103 | * 104 | * @param striped true设置条纹 105 | * @throws RuntimeException 如果table不是{@link JBTable}类型,请自行实现setStriped 106 | */ 107 | public void setStriped(boolean striped) { 108 | if (table instanceof JBTable) { 109 | ((JBTable) table).setStriped(striped); 110 | } else { 111 | throw new RuntimeException("table不是JBTable类型,请自行实现setStriped"); 112 | } 113 | } 114 | 115 | @Override 116 | public boolean isCellEditable(int row, int column) { 117 | return false; 118 | } 119 | 120 | public List getData() { 121 | return data; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /src/main/java/model/VersionTableModel.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import bean.VersionItem; 4 | import com.intellij.ui.table.JBTable; 5 | import org.apache.commons.lang3.StringUtils; 6 | 7 | import javax.swing.*; 8 | import javax.swing.table.DefaultTableCellRenderer; 9 | import javax.swing.table.DefaultTableModel; 10 | import javax.swing.table.JTableHeader; 11 | import javax.swing.table.TableColumnModel; 12 | import java.awt.*; 13 | import java.util.List; 14 | import java.util.Vector; 15 | 16 | public class VersionTableModel extends DefaultTableModel { 17 | 18 | private final String[] columnNames = { "Index", "Package Name", "Version", "Weekly Downloads", "Published" }; 19 | 20 | private final Class[] types = { Integer.class, String.class, String.class, Integer.class, String.class }; 21 | 22 | private JBTable table; 23 | 24 | private List data; 25 | 26 | public VersionTableModel(JBTable table) { 27 | this.table = table; 28 | table.setAutoResizeMode(JBTable.AUTO_RESIZE_OFF); 29 | table.setRowHeight(30); 30 | table.setModel(this); 31 | setColumnIdentifiers(columnNames); 32 | // 设置表头样式 33 | JTableHeader tableHeader = table.getTableHeader(); 34 | tableHeader.setFont(new Font(null, Font.BOLD, 12)); 35 | TableColumnModel columnModel = table.getColumnModel(); 36 | columnModel.getColumn(0).setPreferredWidth(80); 37 | columnModel.getColumn(1).setPreferredWidth(200); 38 | columnModel.getColumn(2).setPreferredWidth(100); 39 | columnModel.getColumn(3).setPreferredWidth(150); 40 | columnModel.getColumn(4).setPreferredWidth(100); 41 | DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); 42 | renderer.setHorizontalAlignment(JTextField.CENTER); 43 | table.getColumn("Index").setCellRenderer(renderer); 44 | } 45 | 46 | private Vector convertData(VersionItem versionItem) { 47 | // 与columnNames中的元素保持一致 48 | Vector v = new Vector(columnNames.length); 49 | for (String columnName : columnNames) { 50 | v.addElement(versionItem.getValueByColumn(columnName)); 51 | } 52 | return v; 53 | } 54 | 55 | /** 56 | * 查找列项中的valueName所在的行 57 | * 58 | * @param columnIndex 列号 59 | * @param value 值 60 | * @return 如果不存在返回-1 61 | */ 62 | protected int findRowIndex(int columnIndex, String value) { 63 | int rowCount = getRowCount(); 64 | for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { 65 | Object valueAt = getValueAt(rowIndex, columnIndex); 66 | if (StringUtils.equalsIgnoreCase(value, valueAt.toString())) { 67 | return rowIndex; 68 | } 69 | } 70 | return -1; 71 | } 72 | 73 | /** 74 | * 参考源码{@link DefaultTableModel#setValueAt},此为直接更新行,提高点效率 75 | * 76 | * @param rowIndex 77 | * @param rowData 78 | */ 79 | protected void updateRow(int rowIndex, Vector rowData) { 80 | dataVector.set(rowIndex, rowData); 81 | // 通知listeners刷新ui 82 | fireTableRowsUpdated(rowIndex, rowIndex); 83 | } 84 | 85 | /** 86 | * 按照编码顺序初始化,for 每次刷新都乱序,没办法控制显示顺序 87 | * 88 | * @param list 89 | */ 90 | public void setupTable(List list) { 91 | this.data = list; 92 | for (int i = 0; i < list.size(); i++) { 93 | updateData(list.get(i), i); 94 | } 95 | } 96 | 97 | private void updateData(VersionItem packageItem, int index) { 98 | Vector convertData = convertData(packageItem); 99 | convertData.set(0, index + 1); 100 | addRow(convertData); 101 | } 102 | 103 | /** 104 | * 设置表格条纹(斑马线) 105 | * 106 | * @param striped true设置条纹 107 | * @throws RuntimeException 如果table不是{@link JBTable}类型,请自行实现setStriped 108 | */ 109 | public void setStriped(boolean striped) { 110 | if (table instanceof JBTable) { 111 | ((JBTable) table).setStriped(striped); 112 | } else { 113 | throw new RuntimeException("table不是JBTable类型,请自行实现setStriped"); 114 | } 115 | } 116 | 117 | @Override 118 | public boolean isCellEditable(int row, int column) { 119 | return false; 120 | } 121 | 122 | public List getData() { 123 | return data; 124 | } 125 | 126 | @Override 127 | public Class getColumnClass(int columnIndex) { 128 | return types[columnIndex]; 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/main/java/utils/ClipboardUtil.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import java.awt.*; 4 | import java.awt.datatransfer.Clipboard; 5 | import java.awt.datatransfer.StringSelection; 6 | import java.awt.datatransfer.Transferable; 7 | 8 | public class ClipboardUtil { 9 | 10 | /** 11 | * 把文本设置到剪贴板(复制) 12 | */ 13 | public static void setClipboardString(String text) { 14 | // 获取系统剪贴板 15 | Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); 16 | // 封装文本内容 17 | Transferable trans = new StringSelection(text); 18 | // 把文本内容设置到系统剪贴板 19 | clipboard.setContents(trans, null); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/utils/HttpUtil.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | import java.net.HttpURLConnection; 7 | import java.net.URL; 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | public class HttpUtil { 12 | 13 | public static String sendGet(String url) throws IOException { 14 | return HttpUtil.sendGet(url, new HashMap<>()); 15 | } 16 | 17 | /** 18 | * 19 | * @param url 请求地址 20 | * @param headers 请求头 21 | * @return 22 | * @throws IOException 23 | */ 24 | public static String sendGet(String url, Map headers) throws IOException { 25 | String msg = ""; 26 | HttpURLConnection httpURLConnection = null; 27 | URL requestUrl = new URL(url); 28 | try { 29 | httpURLConnection = (HttpURLConnection) requestUrl.openConnection(); 30 | httpURLConnection.connect(); 31 | int code = httpURLConnection.getResponseCode(); 32 | if (code == 200) { // 正常响应 33 | // 从流中读取响应信息 34 | BufferedReader reader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream())); 35 | String line = null; 36 | while ((line = reader.readLine()) != null) { // 循环从流中读取 37 | msg += line + "\n"; 38 | } 39 | reader.close(); // 关闭流 40 | } 41 | 42 | } catch (Exception e) { 43 | 44 | } finally { 45 | // 断开连接,释放资源 46 | if (null != httpURLConnection){ 47 | try { 48 | httpURLConnection.disconnect(); 49 | } catch (Exception e){ 50 | 51 | } 52 | } 53 | } 54 | return msg; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/utils/MavenDataUtil.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import bean.*; 4 | import com.intellij.openapi.application.ApplicationManager; 5 | import core.Callback; 6 | import org.apache.commons.lang3.StringUtils; 7 | import org.jsoup.Jsoup; 8 | import org.jsoup.nodes.Document; 9 | import org.jsoup.nodes.Element; 10 | import org.jsoup.select.Elements; 11 | import view.ArtifactTable; 12 | 13 | import java.util.ArrayList; 14 | import java.util.Arrays; 15 | import java.util.List; 16 | import java.util.regex.Matcher; 17 | import java.util.regex.Pattern; 18 | 19 | public class MavenDataUtil { 20 | 21 | private final static String BASE_URL = "https://mf-edu.kimen.com.cn/transmit/mvnrepository"; 22 | 23 | private final static String ERROR_MSG = "Some errors occurred in the search, please submit your search content to GitHub Issue and we will fix it soon."; 24 | 25 | private final static String FAILURE_MSG = "The server is down. Please try again in 10 minutes"; 26 | 27 | public static void searchRepositoryList(DependenceGroupItem groupItem, Callback> callback) { 28 | String artifactId = groupItem.getArtifactId(); 29 | String groupId = groupItem.getGroupLabel(); 30 | ApplicationManager.getApplication().executeOnPooledThread(() -> { 31 | try { 32 | String result = HttpUtil.sendGet(BASE_URL + "/artifact/" + groupId + "/" + artifactId); 33 | if (!result.contains("Cloudflare")) { 34 | Document document = Jsoup.parse(result); 35 | Element snippets = document.getElementById("snippets"); 36 | Element repositoryTabs = snippets.getElementsByClass("tabs").get(0); 37 | Elements elements = repositoryTabs.getElementsByTag("a"); 38 | List repositoryList = new ArrayList<>(); 39 | elements.forEach(element -> { 40 | RepositoryItem item = new RepositoryItem(); 41 | item.setPath(element.attr("href")); 42 | item.setTitle(element.text()); 43 | repositoryList.add(item); 44 | }); 45 | callback.onSuccess(repositoryList); 46 | } else { 47 | callback.onFailure(FAILURE_MSG); 48 | } 49 | } catch (Exception e1) { 50 | e1.printStackTrace(); 51 | callback.onError(getErrorMsg()); 52 | } finally { 53 | callback.onComplete(); 54 | } 55 | }); 56 | } 57 | 58 | public static void searchGroupList(String value, String currentPage, String sortText, Callback callback) { 59 | ApplicationManager.getApplication().executeOnPooledThread(() -> { 60 | try { 61 | String result = HttpUtil.sendGet(BASE_URL + "/search?q=" + value + "&p=" + currentPage + "&sort=" + sortText); 62 | // 如果返回了"On more step"认证信息,则提示用户过一会再试 63 | if (!result.contains("Cloudflare")) { 64 | Document document = Jsoup.parse(result); 65 | // 获取分页信息 66 | String totalPage = document.getElementById("maincontent").child(0).child(0).text(); 67 | // 获取GroupList信息 68 | Elements dependenceDom = document.getElementsByClass("im-header"); 69 | List list = new ArrayList<>(); 70 | dependenceDom.forEach(item -> { 71 | Element titleDom = item.getElementsByClass("im-title").first(); 72 | Element subTitleDom = item.getElementsByClass("im-subtitle").first(); 73 | Element artifactTitle = titleDom.getElementsByTag("a").first(); 74 | Element usage = titleDom.getElementsByClass("im-usage").first(); 75 | Elements subTitleArray = subTitleDom.getElementsByTag("a"); 76 | Element groupId = subTitleArray.first(); 77 | Element artifactId = subTitleArray.get(1); 78 | DependenceGroupItem groupItem = new DependenceGroupItem(); 79 | groupItem.setArtifactLabel(artifactTitle.text()); 80 | groupItem.setGroupLabel(groupId.text()); 81 | groupItem.setUsagesLabel(usage == null ? "0" : usage.text().split(" ")[0]); 82 | groupItem.setArtifactId(artifactId.text()); 83 | list.add(groupItem); 84 | }); 85 | GroupResult data = new GroupResult(); 86 | data.setData(list); 87 | data.setTotalPage(Integer.parseInt(totalPage)); 88 | callback.onSuccess(data); 89 | } else { 90 | callback.onFailure(FAILURE_MSG); 91 | } 92 | } catch (Exception e) { 93 | e.printStackTrace(); 94 | callback.onError(getErrorMsg()); 95 | } finally { 96 | callback.onComplete(); 97 | } 98 | }); 99 | } 100 | 101 | public static void searchArtifactList(ArtifactTable artifactTable, Callback> callback) { 102 | DependenceGroupItem groupItem = artifactTable.getGroupItem(); 103 | String repositoryPath = artifactTable.getRepositoryPath(); 104 | String artifactId = groupItem.getArtifactId(); 105 | String groupId = groupItem.getGroupLabel(); 106 | ApplicationManager.getApplication().executeOnPooledThread(() -> { 107 | try { 108 | String result = HttpUtil.sendGet(BASE_URL + repositoryPath); 109 | if (!result.contains("Cloudflare")) { 110 | Document document = Jsoup.parse(result); 111 | Element versionTable = document.getElementsByClass("grid versions").get(0); 112 | Elements tbodyList = versionTable.getElementsByTag("tbody"); 113 | Elements thList = versionTable.getElementsByTag("th"); 114 | List list = new ArrayList<>(); 115 | tbodyList.forEach(tbody -> { 116 | Elements trList = tbody.children(); 117 | trList.forEach(tr -> { 118 | Elements tdList = tr.children(); 119 | int offset = 0; 120 | if (tdList.size() < thList.size()) { 121 | offset = -1; 122 | } 123 | ArtifactItem artifactItem = new ArtifactItem(); 124 | String versionText = tdList.get(getIndexFromThList(thList, "Version") + offset).text(); 125 | String repositoryText = tdList.get(getIndexFromThList(thList, "Repository") + offset).text(); 126 | String usagesText = tdList.get(getIndexFromThList(thList, "Usages") + offset).text(); 127 | String offsetText = tdList.get(getIndexFromThList(thList, "Date") + offset).text(); 128 | artifactItem.setVersion(versionText); 129 | artifactItem.setRepository(repositoryText); 130 | artifactItem.setUsages(usagesText); 131 | artifactItem.setDate(offsetText); 132 | artifactItem.setGroupId(groupId); 133 | artifactItem.setArtifactId(artifactId); 134 | list.add(artifactItem); 135 | }); 136 | }); 137 | callback.onSuccess(list); 138 | } else { 139 | callback.onFailure(FAILURE_MSG); 140 | } 141 | } catch (Exception e1) { 142 | e1.printStackTrace(); 143 | callback.onError(getErrorMsg()); 144 | } finally { 145 | callback.onComplete(); 146 | } 147 | }); 148 | } 149 | 150 | private static int getIndexFromThList(Elements thList, String thName) { 151 | for (int i = 0; i < thList.size(); i++) { 152 | if (thName.equals(thList.get(i).text())) { 153 | return i; 154 | } 155 | } 156 | return 0; 157 | } 158 | 159 | public static void searchArtifactDetail(ArtifactItem artifactItem, Callback callback) { 160 | ApplicationManager.getApplication().executeOnPooledThread(() -> { 161 | try { 162 | String result = HttpUtil.sendGet(BASE_URL + "/artifact/" + artifactItem.getGroupId() + "/" + artifactItem.getArtifactId() + "/" + artifactItem.getVersion()); 163 | if (!result.contains("Cloudflare")) { 164 | Document document = Jsoup.parse(result); 165 | Element table = document.getElementsByTag("table").get(0); 166 | Elements trList = table.getElementsByTag("tr"); 167 | Element maven = document.getElementById("maven-a"); 168 | Element gradle = document.getElementById("gradle-a"); 169 | ArtifactDetail detail = new ArtifactDetail(); 170 | detail.setArtifactId(artifactItem.getArtifactId()); 171 | detail.setVersion(artifactItem.getVersion()); 172 | detail.setMavenContent(toValue(maven.text())); 173 | detail.setGradleContent(toValue(gradle.text())); 174 | trList.forEach(tr -> { 175 | String key = tr.child(0).text(); 176 | String value = tr.child(1).text(); 177 | if ("License".equals(key)) { 178 | detail.setLicense(value); 179 | } else if ("Categories".equals(key)) { 180 | detail.setCategory(value); 181 | } else if ("Organization".equals(key)) { 182 | detail.setOrganization(value); 183 | } else if ("HomePage".equals(key)) { 184 | detail.setHomePage(value); 185 | } else if ("Date".equals(key)) { 186 | detail.setDate(value); 187 | } else if ("Repositories".equals(key)) { 188 | detail.setRepository(value); 189 | } 190 | }); 191 | callback.onSuccess(detail); 192 | } else { 193 | callback.onFailure(FAILURE_MSG); 194 | } 195 | } catch (Exception e1) { 196 | e1.printStackTrace(); 197 | callback.onError(getErrorMsg()); 198 | } finally { 199 | callback.onComplete(); 200 | } 201 | }); 202 | } 203 | 204 | private static String toValue(String text) { 205 | List split = Arrays.asList(text.split("\n")); 206 | StringBuilder sb = new StringBuilder(); 207 | for (int i = 1; i < split.size(); i++) { 208 | sb.append(split.get(i)); 209 | if (i != split.size() - 1) { 210 | sb.append("\n"); 211 | } 212 | } 213 | return sb.toString(); 214 | } 215 | 216 | public static Integer parseInt(String content) { 217 | Matcher matcher = null; 218 | if (StringUtils.isBlank(content)) { 219 | return 0; 220 | } 221 | matcher = Pattern.compile("[0-9.]+").matcher(content.replaceAll(",", "")); 222 | while (matcher.find()) { 223 | return Integer.parseInt(matcher.group()); 224 | } 225 | return 0; 226 | } 227 | 228 | private static String getErrorMsg() { 229 | String msg = ERROR_MSG; 230 | try { 231 | msg = HttpUtil.sendGet("https://img.whalenas.com:283/file/msg.txt"); 232 | } catch (Exception e) { 233 | } 234 | return msg; 235 | } 236 | } 237 | -------------------------------------------------------------------------------- /src/main/java/utils/NotificationUtils.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import com.intellij.notification.NotificationDisplayType; 4 | import com.intellij.notification.NotificationGroup; 5 | import com.intellij.notification.NotificationType; 6 | import com.intellij.notification.Notifications; 7 | import com.intellij.openapi.project.Project; 8 | 9 | /** 10 | * 消息通知类 11 | */ 12 | public class NotificationUtils { 13 | 14 | private static final NotificationGroup notificationGroup = new NotificationGroup("ApiDoc.NotificationGroup", NotificationDisplayType.BALLOON, true); 15 | 16 | public static void warnNotify(String message, Project project) { 17 | Notifications.Bus.notify(notificationGroup.createNotification(message, NotificationType.WARNING), project); 18 | } 19 | 20 | public static void infoNotify(String message, Project project) { 21 | Notifications.Bus.notify(notificationGroup.createNotification(message, NotificationType.INFORMATION), project); 22 | } 23 | 24 | public static void errorNotify(String message, Project project) { 25 | Notifications.Bus.notify(notificationGroup.createNotification(message, NotificationType.ERROR), project); 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/main/java/utils/NpmDataUtil.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import bean.PackageItem; 4 | import bean.PackageResult; 5 | import bean.VersionItem; 6 | import com.intellij.openapi.application.ApplicationManager; 7 | import core.Callback; 8 | import org.jsoup.Jsoup; 9 | import org.jsoup.nodes.Document; 10 | import org.jsoup.nodes.Element; 11 | import org.jsoup.select.Elements; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | public class NpmDataUtil { 17 | 18 | private final static String BASE_URL = "https://www.npmjs.com"; 19 | 20 | private final static String ERROR_MSG = "Some errors occurred in the search, please submit your search content to GitHub Issue and we will fix it soon."; 21 | 22 | public static void searchPackageList(String value, String currentPage, String sortText, Callback callback) { 23 | ApplicationManager.getApplication().executeOnPooledThread(() -> { 24 | try { 25 | String result = HttpUtil.sendGet(BASE_URL + "/search?q=" + value + "&page=" + currentPage + "&ranking=" + sortText); 26 | Document document = Jsoup.parse(result); 27 | Elements packageElements = document.getElementsByTag("section"); 28 | List list = new ArrayList<>(); 29 | packageElements.forEach(item -> { 30 | Element packageElement = item.child(0); 31 | String packageName = packageElement.child(0).child(0).text(); 32 | String description = packageElement.child(2).text(); 33 | String author = packageElement.child(packageElement.childNodeSize() - 1).child(0).text(); 34 | String lastVersion = packageElement.child(packageElement.childNodeSize() - 1).child(1).text().split(" ")[1]; 35 | PackageItem packageItem = new PackageItem(); 36 | packageItem.setPackageName(packageName); 37 | packageItem.setDescription(description); 38 | packageItem.setAuthor(author); 39 | packageItem.setLastVersion(lastVersion); 40 | list.add(packageItem); 41 | }); 42 | String totalPage = document.getElementById("main").child(0).getElementsByTag("h2").get(0).text().split(" ")[0]; 43 | PackageResult packageResult = new PackageResult(); 44 | packageResult.setTotalPage(Integer.parseInt(totalPage)); 45 | packageResult.setData(list); 46 | callback.onSuccess(packageResult); 47 | } catch (Exception e) { 48 | e.printStackTrace(); 49 | callback.onError(ERROR_MSG); 50 | } finally { 51 | callback.onComplete(); 52 | } 53 | }); 54 | 55 | } 56 | 57 | public static void searchVersionList(PackageItem packageItem, Callback> callback) { 58 | ApplicationManager.getApplication().executeOnPooledThread(() -> { 59 | try { 60 | String result = HttpUtil.sendGet(BASE_URL + "/package/" + packageItem.getPackageName() + "?activeTab=versions"); 61 | Document document = Jsoup.parse(result); 62 | Element child = document.getElementById("tabpanel-versions").child(0); 63 | Element versionElement = child.child(child.childNodeSize() - 1); 64 | Elements versionList = versionElement.getElementsByTag("tbody").get(0).getElementsByTag("tr"); 65 | List list = new ArrayList<>(); 66 | for (int i = 1; i < versionList.size(); i++) { 67 | Element versionItem = versionList.get(i); 68 | Elements children = versionItem.children(); 69 | if (children.size() == 3) { 70 | String version = children.get(0).text(); 71 | String downloads = children.get(1).text(); 72 | downloads = downloads.replace(",", ""); 73 | String published = children.get(2).text(); 74 | VersionItem item = new VersionItem(); 75 | item.setVersion(version); 76 | item.setDownloads(Integer.parseInt(downloads)); 77 | item.setPublished(published); 78 | item.setPackageName(packageItem.getPackageName()); 79 | list.add(item); 80 | } 81 | } 82 | callback.onSuccess(list); 83 | } catch (Exception e) { 84 | e.printStackTrace(); 85 | callback.onError(ERROR_MSG); 86 | } finally { 87 | callback.onComplete(); 88 | } 89 | }); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/view/ArtifactTable.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import bean.ArtifactDetail; 4 | import bean.ArtifactItem; 5 | import bean.DependenceGroupItem; 6 | import com.intellij.openapi.project.Project; 7 | import com.intellij.ui.DoubleClickListener; 8 | import com.intellij.ui.table.JBTable; 9 | import core.Callback; 10 | import model.ArtifactTableModel; 11 | import org.apache.commons.collections.CollectionUtils; 12 | import utils.MavenDataUtil; 13 | import utils.NotificationUtils; 14 | 15 | import javax.swing.*; 16 | import javax.swing.table.TableModel; 17 | import javax.swing.table.TableRowSorter; 18 | import java.awt.*; 19 | import java.awt.event.MouseEvent; 20 | import java.util.List; 21 | 22 | public class ArtifactTable extends JPanel { 23 | 24 | private JBTable artifactTable; 25 | private ArtifactTableModel artifactTableModel; 26 | private DependenceGroupItem groupItem; 27 | 28 | private DetailDialog detailDialog; 29 | 30 | private Project project; 31 | 32 | private boolean artifactLoading = false; 33 | 34 | private String repositoryPath; 35 | 36 | public ArtifactTable(DependenceGroupItem groupItem, Project project, DetailDialog detailDialog, String repositoryPath) { 37 | super(false); 38 | artifactTable = new JBTable(); 39 | this.groupItem = groupItem; 40 | this.repositoryPath = repositoryPath; 41 | this.project = project; 42 | artifactTableModel = new ArtifactTableModel(artifactTable); 43 | TableRowSorter sorter = new TableRowSorter<>(artifactTableModel); 44 | artifactTable.setRowSorter(sorter); 45 | artifactTable.setFillsViewportHeight(true); 46 | // 解决table无法充满scrollPane 47 | artifactTable.setPreferredScrollableViewportSize(new Dimension(400, 1000)); 48 | 49 | setLayout(new GridLayout(1,1)); 50 | JScrollPane scrollPane = new JScrollPane(artifactTable); 51 | add(scrollPane); 52 | this.detailDialog = detailDialog; 53 | // 双击获取ArtifactDetail 54 | handleDbClickArtifactList(); 55 | } 56 | 57 | public DependenceGroupItem getGroupItem() { 58 | return groupItem; 59 | } 60 | 61 | public void setPaintBusy(boolean busy) { 62 | artifactTable.setPaintBusy(busy); 63 | } 64 | 65 | public void setArtifactLoading(boolean loading) { 66 | artifactLoading = loading; 67 | } 68 | 69 | private void handleDbClickArtifactList() { 70 | (new DoubleClickListener() { 71 | @Override 72 | protected boolean onDoubleClick(MouseEvent event) { 73 | if (!artifactLoading) { 74 | artifactTable.setPaintBusy(true); 75 | artifactLoading = true; 76 | detailDialog.dispose(); 77 | int selectedRow = artifactTable.getSelectedRow(); 78 | ArtifactItem artifactItem = artifactTableModel.getData().get(selectedRow); 79 | MavenDataUtil.searchArtifactDetail(artifactItem, new Callback() { 80 | @Override 81 | public void onSuccess(ArtifactDetail detail) { 82 | detailDialog.setData(detail); 83 | detailDialog.getCopyMaven().addActionListener(e -> NotificationUtils.infoNotify("Copy Maven dependence success", project)); 84 | detailDialog.getCopyGradle().addActionListener(e -> NotificationUtils.infoNotify("Copy Gradle dependence success", project)); 85 | detailDialog.showDialog(650, 550, true, false); 86 | } 87 | 88 | @Override 89 | public void onFailure(String msg) { 90 | NotificationUtils.errorNotify(msg, project); 91 | } 92 | 93 | @Override 94 | public void onError(String msg) { 95 | NotificationUtils.errorNotify(msg, project); 96 | } 97 | 98 | @Override 99 | public void onComplete() { 100 | artifactTable.setPaintBusy(false); 101 | artifactLoading = false; 102 | } 103 | }); 104 | } 105 | return false; 106 | } 107 | }).installOn(artifactTable); 108 | } 109 | 110 | public void removeAllElements() { 111 | artifactTableModel.getDataVector().removeAllElements(); 112 | } 113 | 114 | public void setupTable(List list) { 115 | artifactTableModel.setupTable(list); 116 | } 117 | 118 | public String getRepositoryPath() { 119 | return repositoryPath; 120 | } 121 | 122 | public boolean hasData() { 123 | return !CollectionUtils.isEmpty(artifactTableModel.getData()); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/main/java/view/DetailDialog.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 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 |
267 | -------------------------------------------------------------------------------- /src/main/java/view/DetailDialog.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import bean.ArtifactDetail; 4 | import com.intellij.ui.components.JBLabel; 5 | import com.intellij.util.Alarm; 6 | import com.intellij.util.AlarmFactory; 7 | import utils.ClipboardUtil; 8 | 9 | import javax.swing.*; 10 | import java.awt.*; 11 | import java.awt.datatransfer.Clipboard; 12 | import java.awt.datatransfer.StringSelection; 13 | import java.awt.datatransfer.Transferable; 14 | 15 | public class DetailDialog extends JDialog { 16 | private JPanel contentPane; 17 | private JBLabel artifactId; 18 | private JTextArea mavenContent; 19 | private JTextArea gradleContent; 20 | private JBLabel versionContent; 21 | private JBLabel licenseContent; 22 | private JBLabel categoryContent; 23 | private JBLabel organizationContent; 24 | private JBLabel homePageContent; 25 | private JBLabel dateContent; 26 | private JBLabel repositoryContent; 27 | private JButton copyMaven; 28 | private JButton copyGradle; 29 | 30 | public DetailDialog() { 31 | // setContentPane(contentPane); 32 | // setModal(true); 33 | // setTitle("Artifact Detail"); 34 | } 35 | 36 | public void setData(ArtifactDetail detail) { 37 | artifactId.setCopyable(true); 38 | artifactId.setText(detail.getArtifactId()); 39 | versionContent.setText(detail.getVersion()); 40 | versionContent.setCopyable(true); 41 | licenseContent.setText(detail.getLicense()); 42 | licenseContent.setCopyable(true); 43 | categoryContent.setText(detail.getCategory()); 44 | categoryContent.setCopyable(true); 45 | organizationContent.setText(detail.getOrganization()); 46 | organizationContent.setCopyable(true); 47 | homePageContent.setText(detail.getHomePage()); 48 | homePageContent.setCopyable(true); 49 | dateContent.setText(detail.getDate()); 50 | dateContent.setCopyable(true); 51 | repositoryContent.setText(detail.getRepository()); 52 | repositoryContent.setCopyable(true); 53 | mavenContent.setText(detail.getMavenContent()); 54 | gradleContent.setText(detail.getGradleContent()); 55 | copyMaven.addActionListener(e -> ClipboardUtil.setClipboardString(mavenContent.getText())); 56 | copyGradle.addActionListener(e -> ClipboardUtil.setClipboardString(gradleContent.getText())); 57 | } 58 | 59 | public JButton getCopyMaven() { 60 | return copyMaven; 61 | } 62 | 63 | public void setCopyMaven(JButton copyMaven) { 64 | this.copyMaven = copyMaven; 65 | } 66 | 67 | public JButton getCopyGradle() { 68 | return copyGradle; 69 | } 70 | 71 | public void setCopyGradle(JButton copyGradle) { 72 | this.copyGradle = copyGradle; 73 | } 74 | 75 | public void showDialog(int width, int height, boolean isInCenter, boolean isResizeable) { 76 | pack(); 77 | setResizable(isResizeable); 78 | setSize(width, height); 79 | if (isInCenter) { 80 | setLocation(Toolkit.getDefaultToolkit().getScreenSize().width / 2 - width / 2, Toolkit.getDefaultToolkit().getScreenSize().height / 2 - height / 2); 81 | } 82 | setVisible(true); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/view/MainWindow.form: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | -------------------------------------------------------------------------------- /src/main/java/view/MainWindow.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import com.intellij.ide.plugins.PluginManager; 4 | import com.intellij.openapi.application.ex.ApplicationInfoEx; 5 | import com.intellij.openapi.project.Project; 6 | import com.intellij.openapi.wm.ToolWindow; 7 | import com.intellij.openapi.wm.ToolWindowFactory; 8 | import com.intellij.ui.content.Content; 9 | import com.intellij.ui.content.ContentFactory; 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | import javax.swing.*; 13 | 14 | public class MainWindow implements ToolWindowFactory { 15 | 16 | private JPanel mainPanel; 17 | private NpmWindow npmWindow; 18 | private MavenWindow mavenWindow; 19 | 20 | @Override 21 | public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) { 22 | String fullApplicationName = ApplicationInfoEx.getInstanceEx().getFullApplicationName(); 23 | npmWindow = new NpmWindow(project); 24 | mavenWindow = new MavenWindow(project); 25 | ContentFactory contentFactory = ContentFactory.SERVICE.getInstance(); 26 | Content mavenContent = contentFactory.createContent(mavenWindow.getMavenPanel(), "MAVEN", false); 27 | Content npmContent = contentFactory.createContent(npmWindow.getNpmPanel(), "NPM", false); 28 | if (fullApplicationName.startsWith("WebStorm")) { 29 | toolWindow.getContentManager().addContent(npmContent); 30 | toolWindow.getContentManager().addContent(mavenContent); 31 | } else { 32 | toolWindow.getContentManager().addContent(mavenContent); 33 | toolWindow.getContentManager().addContent(npmContent); 34 | } 35 | } 36 | 37 | @Override 38 | public void init(@NotNull ToolWindow toolWindow) {} 39 | 40 | @Override 41 | public boolean shouldBeAvailable(@NotNull Project project) { 42 | return true; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/view/MavenWindow.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 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 |
188 | -------------------------------------------------------------------------------- /src/main/java/view/MavenWindow.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import bean.ArtifactItem; 4 | import bean.DependenceGroupItem; 5 | import bean.GroupResult; 6 | import bean.RepositoryItem; 7 | import com.intellij.openapi.project.Project; 8 | import com.intellij.openapi.util.text.StringUtil; 9 | import com.intellij.ui.DoubleClickListener; 10 | import com.intellij.ui.components.JBTabbedPane; 11 | import com.intellij.ui.components.JBTextField; 12 | import com.intellij.ui.table.JBTable; 13 | import core.Callback; 14 | import model.GroupTableModel; 15 | import org.apache.commons.collections.CollectionUtils; 16 | import utils.MavenDataUtil; 17 | import utils.NotificationUtils; 18 | 19 | import javax.swing.*; 20 | import javax.swing.table.TableModel; 21 | import javax.swing.table.TableRowSorter; 22 | import java.awt.event.MouseEvent; 23 | import java.util.List; 24 | 25 | public class MavenWindow { 26 | private JPanel mavenPanel; 27 | private JBTextField searchText; 28 | private JButton searchButton; 29 | private JBTable groupTable; 30 | private JButton prevButton; 31 | private JButton nextButton; 32 | private JLabel currentPage; 33 | private JLabel totalPage; 34 | private JComboBox sortSelect; 35 | private JTabbedPane repositoryTab; 36 | private Project project; 37 | private GroupTableModel groupTableModel; 38 | // private DetailDialog detailDialog; 39 | 40 | private final String[] sortLabel = {"relevance", "popular", "newest"}; 41 | 42 | private String currentSearchText; 43 | 44 | /** 45 | * 防止多次点击按钮 46 | */ 47 | private boolean groupTableLoading = false; 48 | 49 | private boolean searchRepositoryLoading = false; 50 | 51 | public MavenWindow(Project project) { 52 | this.project = project; 53 | // detailDialog = new DetailDialog(); 54 | DefaultComboBoxModel model = new DefaultComboBoxModel(sortLabel); 55 | sortSelect.setModel(model); 56 | groupTableModel = new GroupTableModel(groupTable); 57 | TableRowSorter sorter1 = new TableRowSorter<>(groupTableModel); 58 | groupTable.setRowSorter(sorter1); 59 | searchText.addActionListener(e -> handleSearch()); 60 | searchButton.addActionListener(e -> handleSearch()); 61 | // 上一页 62 | prevButton.addActionListener(e -> { 63 | if (!groupTableLoading) { 64 | int currentPageValue = Integer.parseInt(currentPage.getText()); 65 | if (currentPageValue > 1) { 66 | currentPage.setText(--currentPageValue + ""); 67 | searchGroupList(groupTableModel); 68 | } 69 | } 70 | }); 71 | // 下一页 72 | nextButton.addActionListener(e -> { 73 | if (!groupTableLoading) { 74 | int totalPageValue = Integer.parseInt(totalPage.getText()); 75 | int currentPageValue = Integer.parseInt(currentPage.getText()); 76 | if (currentPageValue < totalPageValue) { 77 | currentPage.setText(++currentPageValue + ""); 78 | searchGroupList(groupTableModel); 79 | } 80 | } 81 | }); 82 | // 设置Tab为滚动模式 83 | repositoryTab.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); 84 | repositoryTab.addChangeListener(e -> { 85 | int n = repositoryTab.getSelectedIndex(); 86 | n = n == -1 ? 0 : n; 87 | ArtifactTable artifactTable = (ArtifactTable) repositoryTab.getComponentAt(n); 88 | if (!artifactTable.hasData()) { 89 | searchArtifactList(artifactTable); 90 | } 91 | }); 92 | // 双击获取RepositoryList 93 | handleDbClickGroupList(); 94 | } 95 | 96 | private void handleDbClickGroupList() { 97 | (new DoubleClickListener() { 98 | @Override 99 | protected boolean onDoubleClick(MouseEvent event) { 100 | if (!searchRepositoryLoading) { 101 | searchRepositoryLoading = true; 102 | repositoryTab.removeAll(); 103 | // repositoryTab.setSelectedIndex(0); 104 | int selectedRow = groupTable.getSelectedRow(); 105 | DependenceGroupItem groupItem = groupTableModel.getData().get(selectedRow); 106 | MavenDataUtil.searchRepositoryList(groupItem, new Callback>() { 107 | @Override 108 | public void onSuccess(List data) { 109 | // if (!CollectionUtils.isEmpty(data)) { 110 | // data.forEach(repository -> { 111 | // ArtifactTable artifactTable = new ArtifactTable(groupItem, project, detailDialog, repository.getPath()); 112 | // repositoryTab.addTab(repository.getTitle(), artifactTable); 113 | // }); 114 | // repositoryTab.setSelectedIndex(0); 115 | // } 116 | } 117 | 118 | @Override 119 | public void onFailure(String msg) { 120 | 121 | } 122 | 123 | @Override 124 | public void onError(String msg) { 125 | NotificationUtils.errorNotify(msg, project); 126 | } 127 | 128 | @Override 129 | public void onComplete() { 130 | searchRepositoryLoading = false; 131 | } 132 | }); 133 | } 134 | return false; 135 | } 136 | }).installOn(groupTable); 137 | } 138 | 139 | private void searchArtifactList(ArtifactTable artifactTable) { 140 | artifactTable.setPaintBusy(true); 141 | artifactTable.setArtifactLoading(true); 142 | MavenDataUtil.searchArtifactList(artifactTable, new Callback>() { 143 | @Override 144 | public void onSuccess(List list) { 145 | artifactTable.removeAllElements(); 146 | artifactTable.setupTable(list); 147 | } 148 | 149 | @Override 150 | public void onFailure(String msg) { 151 | 152 | } 153 | 154 | @Override 155 | public void onError(String msg) { 156 | NotificationUtils.errorNotify(msg, project); 157 | } 158 | 159 | @Override 160 | public void onComplete() { 161 | artifactTable.setPaintBusy(false); 162 | artifactTable.setArtifactLoading(false); 163 | } 164 | }); 165 | } 166 | 167 | private void handleSearch() { 168 | if (!groupTableLoading) { 169 | currentPage.setText("1"); 170 | totalPage.setText("1"); 171 | currentSearchText = searchText.getText(); 172 | searchGroupList(groupTableModel); 173 | } 174 | } 175 | 176 | private void searchGroupList(GroupTableModel groupTableModel) { 177 | if (!StringUtil.isEmpty(currentSearchText)) { 178 | String currentPageText = currentPage.getText(); 179 | String sortText = sortLabel[sortSelect.getSelectedIndex()]; 180 | groupTableLoading = true; 181 | groupTable.setPaintBusy(true); 182 | MavenDataUtil.searchGroupList(currentSearchText, currentPageText, sortText, new Callback() { 183 | 184 | @Override 185 | public void onSuccess(GroupResult result) { 186 | List list = result.getData(); 187 | int totalPageValue = result.getTotalPage(); 188 | totalPage.setText((int) Math.ceil(totalPageValue / 10) + 1 + ""); 189 | groupTableModel.getDataVector().removeAllElements(); 190 | groupTableModel.setupTable(list); 191 | } 192 | 193 | @Override 194 | public void onFailure(String msg) { 195 | 196 | } 197 | 198 | @Override 199 | public void onError(String msg) { 200 | NotificationUtils.errorNotify(msg, project); 201 | } 202 | 203 | @Override 204 | public void onComplete() { 205 | groupTableLoading = false; 206 | groupTable.setPaintBusy(false); 207 | } 208 | }); 209 | } 210 | } 211 | 212 | public JPanel getMavenPanel() { 213 | return mavenPanel; 214 | } 215 | } 216 | -------------------------------------------------------------------------------- /src/main/java/view/NpmWindow.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 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 |
177 | -------------------------------------------------------------------------------- /src/main/java/view/NpmWindow.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import bean.*; 4 | import com.intellij.openapi.project.Project; 5 | import com.intellij.openapi.util.text.StringUtil; 6 | import com.intellij.ui.DoubleClickListener; 7 | import com.intellij.ui.components.JBTextField; 8 | import com.intellij.ui.table.JBTable; 9 | import core.Callback; 10 | import model.PackageTableModel; 11 | import model.VersionTableModel; 12 | import utils.ClipboardUtil; 13 | import utils.NotificationUtils; 14 | import utils.NpmDataUtil; 15 | 16 | import javax.swing.*; 17 | import javax.swing.table.TableModel; 18 | import javax.swing.table.TableRowSorter; 19 | import java.awt.event.MouseEvent; 20 | import java.util.List; 21 | 22 | public class NpmWindow { 23 | private JBTable versionTable; 24 | private JBTable packageTable; 25 | private JButton prevButton; 26 | private JButton nextButton; 27 | private JLabel currentPage; 28 | private JLabel totalPage; 29 | private JBTextField searchText; 30 | private JComboBox sortSelect; 31 | private JButton searchButton; 32 | private JPanel npmPanel; 33 | private PackageTableModel packageTableModel; 34 | private VersionTableModel versionTableModel; 35 | private String currentSearchText; 36 | private boolean packageTableLoading = false; 37 | private boolean versionTableLoading = false; 38 | 39 | private Project project; 40 | 41 | private final String[] sortLabel = { "optimal", "popularity", "quality", "maintenance"}; 42 | 43 | public NpmWindow(Project project) { 44 | this.project = project; 45 | DefaultComboBoxModel model = new DefaultComboBoxModel(sortLabel); 46 | sortSelect.setModel(model); 47 | packageTableModel = new PackageTableModel(packageTable); 48 | versionTableModel = new VersionTableModel(versionTable); 49 | TableRowSorter versionSorter = new TableRowSorter(versionTableModel); 50 | versionTable.setRowSorter(versionSorter); 51 | searchText.addActionListener(e -> handleSearch()); 52 | searchButton.addActionListener(e -> handleSearch()); 53 | // 上一页 54 | prevButton.addActionListener(e -> { 55 | if (!packageTableLoading) { 56 | int currentPageValue = Integer.parseInt(currentPage.getText()); 57 | if (currentPageValue > 1) { 58 | currentPage.setText(--currentPageValue + ""); 59 | searchGroupList(); 60 | } 61 | } 62 | }); 63 | // 下一页 64 | nextButton.addActionListener(e -> { 65 | if (!packageTableLoading) { 66 | int totalPageValue = Integer.parseInt(totalPage.getText()); 67 | int currentPageValue = Integer.parseInt(currentPage.getText()); 68 | if (currentPageValue < totalPageValue) { 69 | currentPage.setText(++currentPageValue + ""); 70 | searchGroupList(); 71 | } 72 | } 73 | }); 74 | handleDbClickPackageList(); 75 | handleDbClickVersionList(); 76 | } 77 | 78 | private void handleDbClickVersionList() { 79 | (new DoubleClickListener() { 80 | @Override 81 | protected boolean onDoubleClick(MouseEvent event) { 82 | if (!versionTableLoading) { 83 | int selectedRow = versionTable.getSelectedRow(); 84 | VersionItem versionItem = versionTableModel.getData().get(selectedRow); 85 | String commandText = "npm i -S " + versionItem.getPackageName() + "@" + versionItem.getVersion(); 86 | ClipboardUtil.setClipboardString(commandText); 87 | NotificationUtils.infoNotify("Copy install command success.\n\n" + commandText, project); 88 | } 89 | return false; 90 | } 91 | }).installOn(versionTable); 92 | } 93 | 94 | private void handleDbClickPackageList() { 95 | (new DoubleClickListener() { 96 | @Override 97 | protected boolean onDoubleClick(MouseEvent event) { 98 | if (!versionTableLoading) { 99 | versionTable.setPaintBusy(true); 100 | versionTableLoading = true; 101 | // detailDialog.dispose(); 102 | int selectedRow = packageTable.getSelectedRow(); 103 | PackageItem packageItem = packageTableModel.getData().get(selectedRow); 104 | NpmDataUtil.searchVersionList(packageItem, new Callback<>() { 105 | @Override 106 | public void onSuccess(List list) { 107 | versionTableModel.getDataVector().removeAllElements(); 108 | versionTableModel.setupTable(list); 109 | } 110 | 111 | @Override 112 | public void onFailure(String msg) { 113 | 114 | } 115 | 116 | @Override 117 | public void onError(String msg) { 118 | NotificationUtils.errorNotify(msg, project); 119 | } 120 | 121 | @Override 122 | public void onComplete() { 123 | versionTable.setPaintBusy(false); 124 | versionTableLoading = false; 125 | } 126 | }); 127 | } 128 | return false; 129 | } 130 | }).installOn(packageTable); 131 | } 132 | 133 | private void handleSearch() { 134 | currentPage.setText("1"); 135 | totalPage.setText("1"); 136 | currentSearchText = searchText.getText(); 137 | searchGroupList(); 138 | } 139 | 140 | private void searchGroupList() { 141 | if (!StringUtil.isEmpty(currentSearchText)) { 142 | String currentPageText = currentPage.getText(); 143 | String pageValue = Integer.parseInt(currentPageText) - 1 + ""; 144 | String sortText = sortLabel[sortSelect.getSelectedIndex()]; 145 | packageTableLoading = true; 146 | packageTable.setPaintBusy(true); 147 | NpmDataUtil.searchPackageList(currentSearchText, pageValue, sortText, new Callback<>() { 148 | 149 | @Override 150 | public void onSuccess(PackageResult result) { 151 | List list = result.getData(); 152 | int totalPageValue = result.getTotalPage(); 153 | totalPage.setText((int) Math.ceil(totalPageValue / 10) + 1 + ""); 154 | packageTableModel.getDataVector().removeAllElements(); 155 | versionTableModel.getDataVector().removeAllElements(); 156 | packageTableModel.setupTable(list); 157 | } 158 | 159 | @Override 160 | public void onFailure(String msg) { 161 | 162 | } 163 | 164 | @Override 165 | public void onError(String msg) { 166 | NotificationUtils.errorNotify(msg, project); 167 | } 168 | 169 | @Override 170 | public void onComplete() { 171 | packageTableLoading = false; 172 | packageTable.setPaintBusy(false); 173 | } 174 | }); 175 | } 176 | } 177 | 178 | public JPanel getNpmPanel() { 179 | return npmPanel; 180 | } 181 | } 182 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | com.kimen.plugin 3 | Search In Repository 4 | Kimen 5 | 6 | Repository helper plugin


8 | 9 |

The plugin provides a query tool to search Maven or NPM dependencies info in the IDE

10 |
11 | Maven: 12 |
    13 |
  • 14 | Double-click a row of the artifact list to query all versions of the artifact 15 |
  • 16 |
  • 17 | Double-click a version of the artifact list to query the details of that version 18 |
  • 19 |
  • 20 | Copy the dependency information or click the button 21 |
  • 22 |
23 |
24 | NPM: 25 |
    26 |
  • 27 | Get a list of related packages by searching keywords 28 |
  • 29 |
  • 30 | Double-click a row of the package list to query all versions of the package 31 |
  • 32 |
33 | 34 |

该插件提供一个查询工具方便在IDE中直接搜索Maven和NPM的依赖信息

35 |
36 | Maven: 37 |
    38 |
  • 39 | 双击Artifact列表的某一行查询Artifact所有版本 40 |
  • 41 |
  • 42 | 双击Artifact列表的某一版本查询该版本的详情 43 |
  • 44 |
  • 45 | 直接复制或者点击按钮复制依赖信息 46 |
  • 47 |
48 |
49 | NPM: 50 |
    51 |
  • 52 | 搜索关键词,获取相关Package列表 53 |
  • 54 |
  • 55 | 双击Package列表的某一项查询该Package的所有版本信息 56 |
  • 57 |
58 |
59 |

Source Code:Github | Issues

60 |
61 | ]]>
62 | 63 | 65 |
  • v1.3.5
    66 | Adapt the latest version 67 |
  • 68 |
  • v1.3.4
    69 | Adapt the latest version 70 |
  • 71 |
  • v1.3.3
    72 | Fix bug about copying NPM command 73 |
  • 74 |
  • v1.3.2
    75 | Db click NPM dependency to copy install command
    76 | Fix bugs 77 |
  • 78 |
  • v1.3.0
    79 | Add Maven Repository Tab
    80 | Fix bugs 81 |
  • 82 |
  • v1.2.2
    83 | Add Package Name column to NPM
    84 | Fix bugs 85 |
  • 86 |
  • v1.2.1
    87 | Add error message
    88 | Fix bugs 89 |
  • 90 |
  • v1.2.0
    91 | Add function of querying NPM dependencies info 92 |
  • 93 |
  • v1.1.1
    94 | Update the English introduction of plugin
    95 | Fix the compatibility 96 |
  • 97 |
  • v1.1.0
    98 | Added sort condition: relevance | popular | newest
    99 | Fix the bug of sort
    100 | Fix the bug of paging 101 |
  • 102 |
  • v1.0.0
    103 | Release the first version, the basic features have been completed
    104 | Enter the keyword and select the version to query the dependency information 105 |
  • 106 | 107 | ]]> 108 |
    109 | 110 | com.intellij.modules.platform 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 |
    -------------------------------------------------------------------------------- /src/main/resources/META-INF/pluginIcon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/main/resources/maven.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kimentanm/search-in-repo/4127a640307c4f9662b7765fc2c6a9c88cd18747/src/main/resources/maven.png --------------------------------------------------------------------------------