From f68df7b392a8548d694b896b318ae9e1fa753306 Mon Sep 17 00:00:00 2001 From: "likuo011@deppon.com" Date: Wed, 22 Mar 2023 14:55:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20V3=E9=A2=84=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 73 ++++++++++--------- .../infotip/ActionDescriptionIcon.java | 3 +- .../infotip/ActionDescriptionText.java | 15 ++-- .../com/plugins/infotip/FileDirectory.java | 32 +++++--- .../java/com/plugins/infotip/FileIcons.java | 4 +- .../infotip/IgnoreViewNodeDecorator.java | 7 -- .../java/com/plugins/infotip/XmlEntity.java | 4 +- .../java/com/plugins/infotip/XmlParsing.java | 6 +- src/main/resources/META-INF/plugin.xml | 2 +- 9 files changed, 79 insertions(+), 67 deletions(-) diff --git a/build.gradle b/build.gradle index c3e170e..2a5cb83 100644 --- a/build.gradle +++ b/build.gradle @@ -1,63 +1,70 @@ buildscript { repositories { - maven { url 'https://maven.aliyun.com/repository/public/' } maven { url "https://www.jetbrains.com/intellij-repository/releases/" } + maven { url 'https://maven.aliyun.com/repository/public/' } maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } - mavenLocal() + maven { url "https://plugins.gradle.org/m2/" } mavenCentral() + google() gradlePluginPortal() - } - - dependencies { + mavenLocal() } } plugins { - id 'idea' - //0.4.21 - id 'org.jetbrains.intellij' version '0.7.2' + id 'java' + id 'org.jetbrains.intellij' version '1.13.2' + // Gradle Changelog Plugin + id 'org.jetbrains.changelog' version "1.3.1" + // Gradle Qodana Plugin + id 'org.jetbrains.qodana' version "0.1.13" } -//2.1 插件配置 -apply plugin: 'org.jetbrains.intellij' -apply plugin: 'idea' -apply plugin: 'java' +allprojects { + repositories { + maven { url "https://www.jetbrains.com/intellij-repository/releases/" } + maven { url 'https://maven.aliyun.com/repository/public/' } + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url "https://plugins.gradle.org/m2/" } + mavenCentral() + google() + gradlePluginPortal() + mavenLocal() + } +} group 'com.linkkou' -version '2.2.3' - -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 - -repositories { - mavenCentral() -} +version '3.0.0' dependencies { - testCompile group: 'junit', name: 'junit', version: '4.12' + testImplementation 'junit:junit:4.13.2' + implementation 'org.jetbrains:annotations:24.0.1' } +/*https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html#intellij-platform-based-products-of-recent-ide-versions*/ intellij { - pluginName 'TreeInfotip' + pluginName = 'TreeInfotip' // 开发环境运行时使用的版本 - version '2020.2' + //version = '2022.3.2' //沙箱目录位置,用于保存IDEA的设置,默认在build文件下面,防止clean,放在根目录下。 - sandboxDirectory = "${rootProject.rootDir}/idea-sandbox" - type 'IU' + sandboxDir = "${rootProject.rootDir}/idea-sandbox" + type = 'IU' // 依赖的插件 //plugins = ['DatabaseTools', 'Velocity'] //Disables updating since-build attribute in plugin.xml - updateSinceUntilBuild false - downloadSources false - localPath '/Applications/IntelliJ IDEA.app' - //localPath '/Applications/WebStorm.app' + updateSinceUntilBuild = false + downloadSources = false + //localPath '/Applications/IntelliJ IDEA.app' + localPath = '/Applications/WebStorm.app/Contents' } +runIde { + jvmArgs = [ + "-javaagent:/Applications/jetbra/fineagent.jar=jetbrains", + "--add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED", + "--add-opens=java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED"] +} patchPluginXml { } - -tasks.withType(JavaCompile) { - options.encoding = "UTF-8" -} \ No newline at end of file diff --git a/src/main/java/com/plugins/infotip/ActionDescriptionIcon.java b/src/main/java/com/plugins/infotip/ActionDescriptionIcon.java index 2b69ae1..edfcad7 100644 --- a/src/main/java/com/plugins/infotip/ActionDescriptionIcon.java +++ b/src/main/java/com/plugins/infotip/ActionDescriptionIcon.java @@ -9,6 +9,7 @@ import com.plugins.infotip.ui.Icons; import com.plugins.infotip.ui.IconsList; import org.jetbrains.annotations.NotNull; +import com.intellij.codeInsight.CodeInsightActionHandler; import java.awt.*; @@ -20,7 +21,7 @@ * * @author lk * @version 1.0 - * @date 2021/6/7 14:13 + * 2021/6/7 14:13 */ public class ActionDescriptionIcon extends AnAction { diff --git a/src/main/java/com/plugins/infotip/ActionDescriptionText.java b/src/main/java/com/plugins/infotip/ActionDescriptionText.java index 9e7b2bf..f255e53 100644 --- a/src/main/java/com/plugins/infotip/ActionDescriptionText.java +++ b/src/main/java/com/plugins/infotip/ActionDescriptionText.java @@ -11,12 +11,11 @@ import static com.plugins.infotip.FileDirectory.getBasePath; /** - * A ActionDescription Class * 右键菜单 * * @author lk * @version 1.0 - * @date 2021/6/7 14:13 + * 2021/6/7 14:13 */ public class ActionDescriptionText extends AnAction { @@ -44,12 +43,12 @@ public void onCreatePath(String asbbasePath, XmlFile fileDirectoryXml, Project p }); } - + /** + * 项目构建完毕前就显示 + * @return boolean + */ @Override - public void update(@NotNull AnActionEvent event) { - //在Action显示之前,根据选中文件扩展名判定是否显示此Action - //this.getTemplatePresentation().setIcon(AllIcons.Actions.MenuPaste); + public boolean isDumbAware() { + return true; } - - } diff --git a/src/main/java/com/plugins/infotip/FileDirectory.java b/src/main/java/com/plugins/infotip/FileDirectory.java index 48f07b3..77afcd4 100644 --- a/src/main/java/com/plugins/infotip/FileDirectory.java +++ b/src/main/java/com/plugins/infotip/FileDirectory.java @@ -19,6 +19,7 @@ import com.plugins.infotip.ui.Icons; import org.jetbrains.annotations.NotNull; +import java.awt.*; import java.io.*; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -29,11 +30,11 @@ import static com.plugins.infotip.FileIcons.getAllIcons; /** - * A FileDirectory Class + * 文件目录管理 * * @author lk * @version 1.0 - * @date 2021/6/7 16:48 + * 2021/6/7 16:48 */ public class FileDirectory { @@ -384,7 +385,8 @@ private static VirtualFile getVirtualFile(Method[] methods, Object o) { } /** - * 设置备注 + * 设置备注-文本 + * 核心代码实现 * * @param virtualFile 对象 * @param abstractTreeNode 对象 @@ -393,12 +395,23 @@ private static void setXmlToLocationString(VirtualFile virtualFile, AbstractTree XmlEntity matchPath = getMatchPath(virtualFile, abstractTreeNode.getProject()); if (null != matchPath) { //设置备注 - abstractTreeNode.getPresentation().setLocationString(matchPath.getTitle()); + final PresentationData presentation = abstractTreeNode.getPresentation(); + presentation.getTextAttributesKey(); + //设置背景色 + presentation.setBackground(Color.green); + //设置锚定文本 + presentation.setLocationString(matchPath.getTitle()); + //设置节点本身颜色 + presentation.setForcedTextForeground(Color.blue); + //设置节点本身文本 + presentation.setPresentableText(matchPath.getTitle()); + //设置提示 + presentation.setTooltip(matchPath.getTitle()); } } /** - * 设置备注 + * 设置备注-图标 * * @param virtualFile 对象 * @param data 对象 @@ -429,10 +442,11 @@ private static XmlEntity getMatchPath(VirtualFile virtualFile, Project project) if (listTreeInfo != null) { String basePath = project.getPresentableUrl(); String canonicalPath = virtualFile.getCanonicalPath(); - String asbbasePath = canonicalPath.substring(basePath.length(), canonicalPath.length()); - //Messages.showMessageDialog(project, presentableUrl + ":" + x.getPath(), "Can't Get Path", AllIcons.Actions.Menu_paste); - if (asbbasePath.equals(listTreeInfo.getPath())) { - return listTreeInfo; + if (null != basePath && null != canonicalPath) { + String asbbasePath = canonicalPath.substring(basePath.length(), canonicalPath.length()); + if (asbbasePath.equals(listTreeInfo.getPath())) { + return listTreeInfo; + } } } } diff --git a/src/main/java/com/plugins/infotip/FileIcons.java b/src/main/java/com/plugins/infotip/FileIcons.java index feaddf8..7dcfe22 100644 --- a/src/main/java/com/plugins/infotip/FileIcons.java +++ b/src/main/java/com/plugins/infotip/FileIcons.java @@ -7,11 +7,11 @@ import java.util.ArrayList; /** - * A FileIcons Class + * 获取IDEA内默认的所有图标 * * @author lk * @version 1.0 - * @date 2021/6/18 20:09 + * 2021/6/18 20:09 */ public class FileIcons { diff --git a/src/main/java/com/plugins/infotip/IgnoreViewNodeDecorator.java b/src/main/java/com/plugins/infotip/IgnoreViewNodeDecorator.java index 02b2ff9..d9cb872 100644 --- a/src/main/java/com/plugins/infotip/IgnoreViewNodeDecorator.java +++ b/src/main/java/com/plugins/infotip/IgnoreViewNodeDecorator.java @@ -42,16 +42,9 @@ */ public class IgnoreViewNodeDecorator implements ProjectViewNodeDecorator { - public IgnoreViewNodeDecorator(@NotNull Project project) { - - } - @Override public void decorate(ProjectViewNode node, PresentationData data) { setLocationString(node,data); } - @Override - public void decorate(PackageDependenciesNode node, ColoredTreeCellRenderer cellRenderer) { - } } diff --git a/src/main/java/com/plugins/infotip/XmlEntity.java b/src/main/java/com/plugins/infotip/XmlEntity.java index d1c2197..d635523 100644 --- a/src/main/java/com/plugins/infotip/XmlEntity.java +++ b/src/main/java/com/plugins/infotip/XmlEntity.java @@ -3,11 +3,11 @@ import com.intellij.psi.xml.XmlTag; /** - * A XMLEntity Class + * XML的实体 * * @author lk * @version 1.0 - * @date 2021/6/7 17:11 + * 2021/6/7 17:11 */ public class XmlEntity { /** diff --git a/src/main/java/com/plugins/infotip/XmlParsing.java b/src/main/java/com/plugins/infotip/XmlParsing.java index 968158e..db5223a 100644 --- a/src/main/java/com/plugins/infotip/XmlParsing.java +++ b/src/main/java/com/plugins/infotip/XmlParsing.java @@ -10,17 +10,16 @@ import com.intellij.psi.xml.XmlTag; import com.plugins.infotip.ui.Icons; -import java.util.HashMap; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; /** - * A XmlParsing Class + * XML的解析 * * @author lk * @version 1.0 - * @date 2021/6/7 17:12 + * 2021/6/7 17:12 */ public class XmlParsing { @@ -77,7 +76,6 @@ public void visitElement(final PsiElement element) { } } }); - System.out.println(123); } /** diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index e1b4f0a..b60268b 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -4,7 +4,7 @@ linkkou - 2.2.3 + 3.0.0