-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
14 changed files
with
331 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/com/github/restful/tool/actions/copy/NavigationServiceTreeAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.github.restful.tool.actions.copy; | ||
|
||
import com.github.restful.tool.utils.Bundle; | ||
import com.github.restful.tool.view.icon.Icons; | ||
import com.github.restful.tool.view.window.RestfulToolWindowFactory; | ||
import com.github.restful.tool.view.window.frame.RightToolWindow; | ||
import com.intellij.openapi.actionSystem.AnAction; | ||
import com.intellij.openapi.actionSystem.AnActionEvent; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.psi.PsiMethod; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* @author ZhangYuanSheng | ||
* @version 1.0 | ||
*/ | ||
public class NavigationServiceTreeAction extends AnAction implements CopyOption { | ||
|
||
private RightToolWindow toolWindow; | ||
|
||
public NavigationServiceTreeAction() { | ||
getTemplatePresentation().setText(Bundle.getString("action.NavigateToView.text")); | ||
getTemplatePresentation().setIcon(Icons.Plugin); | ||
} | ||
|
||
@Override | ||
public void actionPerformed(@NotNull AnActionEvent e) { | ||
PsiMethod psiMethod = getPsiMethod(e); | ||
if (psiMethod == null) { | ||
return; | ||
} | ||
if (getToolWindow(e.getProject()) == null) { | ||
return; | ||
} | ||
toolWindow.navigationToView(psiMethod); | ||
} | ||
|
||
private RightToolWindow getToolWindow(@Nullable Project project) { | ||
if (toolWindow != null) { | ||
return toolWindow; | ||
} | ||
return (toolWindow = RestfulToolWindowFactory.getToolWindow(project, true)); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
src/main/java/com/github/restful/tool/beans/ClassTree.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
Copyright (C), 2018-2020, ZhangYuanSheng | ||
FileName: ModuleTree | ||
Author: ZhangYuanSheng | ||
Date: 2020/8/25 16:48 | ||
Description: | ||
History: | ||
<author> <time> <version> <desc> | ||
作者姓名 修改时间 版本号 描述 | ||
*/ | ||
package com.github.restful.tool.beans; | ||
|
||
import com.intellij.icons.AllIcons; | ||
import com.intellij.psi.NavigatablePsiElement; | ||
import com.intellij.psi.PsiClass; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import javax.swing.*; | ||
|
||
/** | ||
* @author ZhangYuanSheng | ||
* @version 1.0 | ||
*/ | ||
public class ClassTree { | ||
|
||
private final PsiClass psiClass; | ||
|
||
/** | ||
* 图标 | ||
*/ | ||
private final Icon icon; | ||
|
||
public ClassTree(@NotNull PsiClass psiClass) { | ||
this.psiClass = psiClass; | ||
this.icon = AllIcons.FileTypes.Java; | ||
} | ||
|
||
public ClassTree(@NotNull PsiClass psiClass, Icon icon) { | ||
this.psiClass = psiClass; | ||
this.icon = icon; | ||
} | ||
|
||
public NavigatablePsiElement getPsiClass() { | ||
return psiClass; | ||
} | ||
|
||
public Icon getIcon() { | ||
return icon; | ||
} | ||
|
||
public String getQualifiedName() { | ||
return psiClass.getQualifiedName(); | ||
} | ||
|
||
public String getName() { | ||
return psiClass.getName(); | ||
} | ||
|
||
public String getSimpleName() { | ||
String[] split = getQualifiedName().split("\\."); | ||
StringBuilder sb = new StringBuilder(); | ||
for (int i = 0; i < split.length - 1; i++) { | ||
sb.append(split[i].charAt(0)).append("."); | ||
} | ||
return sb.append(split[split.length - 1]).toString(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getSimpleName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.