Skip to content

Commit

Permalink
Merge pull request #94 from hza/master
Browse files Browse the repository at this point in the history
plugin description update
  • Loading branch information
gejun123456 committed Aug 28, 2023
2 parents e6f56a0 + a493f6f commit ae91ded
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 18 deletions.
45 changes: 27 additions & 18 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,30 @@
|&nbsp<a href="https://github.com/gejun123456/intellij-generateAllSetMethod/issues">Issues</a></p>
<p> 一键调用一个对象的所有的set方法,get方法等</p>
<p>在方法上生成两个对象的转换</p>
<p> generate call to class all setter method by alt+enter on the variable class</p>
<p> generate a converter two object when they have same field</p>
<p> generate default value when returnType is List Set Map </p>
<p> generate call to assertThat on all getter method</p>
<p> generate call to getter method</p>
<p> like a user class has setName, setPassword methods</p>
<p> generate converter between two class like aa.setHello(bb.getHello()) on method</p>
<p> <b>User</b> user = new User();</p>
<p> then alt+enter on User</p>
<p> will generate following</p>
<p> user.setName("");</p>
<p> user.setPassword("");</p>
<p> support all your class set method including super class</p>
<p> support kotlin
<p> view more on <a href ="https://github.com/gejun123456/intellij-generateAllSetMethod">https://github.com/gejun123456/intellij-generateAllSetMethod</a></p>
<br/>
<p><b>Features</b></p>
<ul>
<li>generate all setters by pressing Alt+Enter on the variable's class</li>
<li>generate all setters with default values for most types including List, Set and Map</li>
<li>generate a converter between two classes that have matching fields</li>
<li>generate assertThat calls for all getter methods</li>
</ul>
<p><b>Usage</b></p>
<p>Let some class User has setName and setPassword methods and you have a declaration:<br/>
<div style="margin: 10px">
<code>User user = <b>new</b> User();</code>
</div>
Set the caret to the word User and press Alt+Enter key. The plugin will produce the code:</p>
<div style="margin: 10px">
<code>
user.setName("");<br/>
user.setPassword("");<br/>
</code>
</div>
<p>Works with Java and Kotlin programming languages.</p>
<p>View more on <a href ="https://github.com/gejun123456/intellij-generateAllSetMethod">https://github.com/gejun123456/intellij-generateAllSetMethod</a></p>
]]></description>

<change-notes><![CDATA[
Expand Down Expand Up @@ -169,8 +178,8 @@
<applicationService serviceImplementation="com.bruce.intellijplugin.generatesetter.template.GenerateSetterService"/>

<applicationConfigurable instance="com.bruce.intellijplugin.generatesetter.template.MySettings"/>
<!-- <intentionAction>-->
<!-- <className>com.bruce.intellijplugin.generatesetter.actions.GenerateByTemplateAction</className>-->
<!-- </intentionAction>-->
<!-- <intentionAction>-->
<!-- <className>com.bruce.intellijplugin.generatesetter.actions.GenerateByTemplateAction</className>-->
<!-- </intentionAction>-->
</extensions>
</idea-plugin>
53 changes: 53 additions & 0 deletions src/test/java/html/HtmlViewer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package html;

import com.intellij.ui.components.JBScrollPane;

import javax.swing.*;
import javax.swing.text.Document;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;
import java.awt.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class HtmlViewer {
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
try {
new HtmlViewer().show();
} catch (Exception e) {
throw new RuntimeException(e);
}
});
}

public void show() throws Exception {
JEditorPane jEditorPane = new JEditorPane();
jEditorPane.setEditable(false);
JScrollPane scrollPane = new JBScrollPane(jEditorPane);
HTMLEditorKit kit = new HTMLEditorKit();
jEditorPane.setEditorKit(kit);
StyleSheet styleSheet = kit.getStyleSheet();
styleSheet.addRule("body { color:#000; margin: 4px; font-size: 10px; }");

String xml = new String(Files.readAllBytes(Paths.get("src/main/resources/META-INF/plugin.xml")));
Pattern pattern = Pattern.compile("<description><!\\[CDATA\\[(?<html>.*)]]></description>",
Pattern.MULTILINE | Pattern.DOTALL);
Matcher matcher = pattern.matcher(xml);
String html = matcher.find() ? matcher.group("html") : "fail";

Document document = kit.createDefaultDocument();
jEditorPane.setDocument(document);
jEditorPane.setText(html);

JFrame frame = new JFrame("Html Viewer");
frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(new Dimension(400, 600));
//frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}

0 comments on commit ae91ded

Please sign in to comment.