Skip to content

Commit

Permalink
取消标题
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzhihang committed Jan 14, 2021
1 parent 2031cb0 commit 0be9d64
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 23 deletions.
10 changes: 5 additions & 5 deletions src/main/java/com/liuzhihang/doc/view/dto/DocView.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
public class DocView {

private String methodFullName;
private String fullClassName;

/**
* 文档名称
Expand Down Expand Up @@ -214,11 +214,11 @@ public void setReqParamList(List<Param> reqParamList) {
this.reqParamList = reqParamList;
}

public String getMethodFullName() {
return methodFullName;
public String getFullClassName() {
return fullClassName;
}

public void setMethodFullName(String methodFullName) {
this.methodFullName = methodFullName;
public void setFullClassName(String fullClassName) {
this.fullClassName = fullClassName;
}
}
8 changes: 4 additions & 4 deletions src/main/java/com/liuzhihang/doc/view/dto/DocViewData.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ public class DocViewData {
private final String responseExample;


private final String methodFullName;
private final String fullClassName;

public DocViewData(DocView docView) {

this.methodFullName = docView.getMethodFullName();
this.fullClassName = docView.getFullClassName();
this.name = docView.getName();
this.desc = docView.getDesc();
this.path = docView.getPath();
Expand Down Expand Up @@ -248,7 +248,7 @@ public String getRequestParam() {
}


public String getMethodFullName() {
return methodFullName;
public String getFullClassName() {
return fullClassName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,9 @@ public DocView buildClassMethodDoc(Settings settings, PsiClass psiClass, @NotNul

String name = CustomPsiCommentUtils.getComment(psiMethod.getDocComment(), "name", false);

String methodFullName = psiClass.getName() + "#" + psiMethod.getName();

DocView docView = new DocView();
docView.setMethodFullName(methodFullName);
docView.setName(StringUtils.isBlank(name) ? methodFullName : name);
docView.setFullClassName(psiClass.getQualifiedName());
docView.setName(StringUtils.isBlank(name) ? psiMethod.getName() : name);
docView.setDesc(desc);
docView.setPath(path);
docView.setMethod(method);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,10 @@ public DocView buildClassMethodDoc(Settings settings, PsiClass psiClass, @NotNul

String name = CustomPsiCommentUtils.getComment(psiMethod.getDocComment(), "name", false);

String methodFullName = psiClass.getName() + "#" + psiMethod.getName();

DocView docView = new DocView();
docView.setMethodFullName(methodFullName);
docView.setName(StringUtils.isBlank(name) ? methodFullName : name);
docView.setFullClassName(psiClass.getQualifiedName());
docView.setName(StringUtils.isBlank(name) ? psiMethod.getName() : name);
docView.setDesc(desc);
docView.setPath(path);
docView.setMethod(method);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/liuzhihang/doc/view/ui/Preview.form
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<properties/>
<border type="none"/>
<children>
<component id="2c18c" class="javax.swing.JLabel" binding="docNameLabel">
<component id="2c18c" class="javax.swing.JLabel" binding="fullClassName">
<constraints border-constraint="West"/>
<properties>
<text value=""/>
Expand Down
32 changes: 26 additions & 6 deletions src/main/java/com/liuzhihang/doc/view/ui/PreviewForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiFile;
import com.intellij.ui.GuiUtils;
import com.intellij.ui.WindowMoveListener;
import com.intellij.ui.components.JBScrollBar;
import com.intellij.ui.components.JBScrollPane;
import com.intellij.util.ui.JBUI;
Expand All @@ -45,6 +46,7 @@
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.MouseEvent;
import java.util.Map;
import java.util.Vector;
import java.util.concurrent.atomic.AtomicBoolean;
Expand All @@ -67,7 +69,7 @@ public class PreviewForm {
private JPanel previewPane;
private JPanel rootToolPane;
private JPanel previewEditorPane;
private JLabel docNameLabel;
private JLabel fullClassName;

private EditorEx markdownEditor;
private Document markdownDocument = EditorFactory.getInstance().createDocument("");
Expand Down Expand Up @@ -99,6 +101,15 @@ public PreviewForm(@Nullable Project project, PsiFile psiFile, Editor editor, Ps
// 生成文档
buildDoc();
catalogList.setSelectedIndex(0);

addMouseListeners();
}

private void addMouseListeners() {
WindowMoveListener windowMoveListener = new WindowMoveListener(rootJPanel);
rootJPanel.addMouseListener(windowMoveListener);
rootJPanel.addMouseMotionListener(windowMoveListener);

}

@NotNull
Expand All @@ -116,19 +127,26 @@ public void popup() {
.setProject(project)
// 上下文要给,否则窗口相关设置无效,默认值为 true
.setResizable(true)
.setTitle("Doc View")
.setTitle(null)
.setMovable(true)
// .setAdText("此处可以在底部设置一些广告内容")
// 是否在其他窗口打开时,关闭窗口,默认值 false
// .setCancelOnOtherWindowOpen(true)
// 是否可以使用ESC关闭窗口,默认值 true
// .setCancelKeyEnabled(false)
// 是否在外部点击时关闭窗口,可以通过设置此值来锁定窗口不消失 默认值 true
.setRequestFocus(true)
.setModalContext(false)
.setCancelOnClickOutside(false)
.setDimensionServiceKey(project, DOC_VIEW_POPUP, true)
.setBelongsToGlobalPopupStack(true)
.setDimensionServiceKey(null, DOC_VIEW_POPUP, true)
.setLocateWithinScreenBounds(false)
// 点击窗口外部位置,并且当前窗口未固定,则关闭
.setCancelOnMouseOutCallback(event -> event.getClickCount() > 0 && !myIsPinned.get())

.setCancelOnMouseOutCallback(event -> event.getID() == MouseEvent.MOUSE_PRESSED
&& event.getClickCount() > 0
&& !myIsPinned.get())
.setCancelOnOtherWindowOpen(false)
.createPopup();

popup.showCenteredInCurrentWindow(project);
Expand All @@ -145,7 +163,7 @@ private void initUI() {
previewEditorPane.setBorder(JBUI.Borders.empty());
previewPane.setBorder(JBUI.Borders.empty());
viewPane.setBorder(JBUI.Borders.empty());
docNameLabel.setBorder(JBUI.Borders.emptyLeft(5));
fullClassName.setBorder(JBUI.Borders.emptyLeft(5));

catalogList.setBackground(UIUtil.getTextFieldBackground());
leftScrollPane.setBackground(UIUtil.getTextFieldBackground());
Expand Down Expand Up @@ -183,6 +201,8 @@ public boolean isDumbAware() {

@Override
public boolean isSelected(@NotNull AnActionEvent e) {


return myIsPinned.get();
}

Expand Down Expand Up @@ -322,7 +342,7 @@ private void buildDoc() {

currentDocView = docMap.get(selectedValue);

docNameLabel.setText(currentDocView.getMethodFullName());
fullClassName.setText(currentDocView.getFullClassName());

// 将 docView 按照模版转换
DocViewData docViewData = new DocViewData(currentDocView);
Expand Down

0 comments on commit 0be9d64

Please sign in to comment.