Skip to content

Commit ae91ded

Browse files
authored
Merge pull request #94 from hza/master
plugin description update
2 parents e6f56a0 + a493f6f commit ae91ded

File tree

2 files changed

+80
-18
lines changed

2 files changed

+80
-18
lines changed

src/main/resources/META-INF/plugin.xml

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,30 @@
88
|&nbsp<a href="https://github.com/gejun123456/intellij-generateAllSetMethod/issues">Issues</a></p>
99
<p> 一键调用一个对象的所有的set方法,get方法等</p>
1010
<p>在方法上生成两个对象的转换</p>
11-
<p> generate call to class all setter method by alt+enter on the variable class</p>
12-
<p> generate a converter two object when they have same field</p>
13-
<p> generate default value when returnType is List Set Map </p>
14-
<p> generate call to assertThat on all getter method</p>
15-
<p> generate call to getter method</p>
16-
<p> like a user class has setName, setPassword methods</p>
17-
<p> generate converter between two class like aa.setHello(bb.getHello()) on method</p>
18-
<p> <b>User</b> user = new User();</p>
19-
<p> then alt+enter on User</p>
20-
<p> will generate following</p>
21-
<p> user.setName("");</p>
22-
<p> user.setPassword("");</p>
23-
<p> support all your class set method including super class</p>
24-
<p> support kotlin
25-
<p> view more on <a href ="https://github.com/gejun123456/intellij-generateAllSetMethod">https://github.com/gejun123456/intellij-generateAllSetMethod</a></p>
11+
<br/>
12+
<p><b>Features</b></p>
13+
<ul>
14+
<li>generate all setters by pressing Alt+Enter on the variable's class</li>
15+
<li>generate all setters with default values for most types including List, Set and Map</li>
16+
<li>generate a converter between two classes that have matching fields</li>
17+
<li>generate assertThat calls for all getter methods</li>
18+
</ul>
19+
20+
<p><b>Usage</b></p>
21+
<p>Let some class User has setName and setPassword methods and you have a declaration:<br/>
22+
<div style="margin: 10px">
23+
<code>User user = <b>new</b> User();</code>
24+
</div>
25+
Set the caret to the word User and press Alt+Enter key. The plugin will produce the code:</p>
26+
<div style="margin: 10px">
27+
<code>
28+
user.setName("");<br/>
29+
user.setPassword("");<br/>
30+
</code>
31+
</div>
32+
33+
<p>Works with Java and Kotlin programming languages.</p>
34+
<p>View more on <a href ="https://github.com/gejun123456/intellij-generateAllSetMethod">https://github.com/gejun123456/intellij-generateAllSetMethod</a></p>
2635
]]></description>
2736

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

171180
<applicationConfigurable instance="com.bruce.intellijplugin.generatesetter.template.MySettings"/>
172-
<!-- <intentionAction>-->
173-
<!-- <className>com.bruce.intellijplugin.generatesetter.actions.GenerateByTemplateAction</className>-->
174-
<!-- </intentionAction>-->
181+
<!-- <intentionAction>-->
182+
<!-- <className>com.bruce.intellijplugin.generatesetter.actions.GenerateByTemplateAction</className>-->
183+
<!-- </intentionAction>-->
175184
</extensions>
176185
</idea-plugin>

src/test/java/html/HtmlViewer.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package html;
2+
3+
import com.intellij.ui.components.JBScrollPane;
4+
5+
import javax.swing.*;
6+
import javax.swing.text.Document;
7+
import javax.swing.text.html.HTMLEditorKit;
8+
import javax.swing.text.html.StyleSheet;
9+
import java.awt.*;
10+
import java.nio.file.Files;
11+
import java.nio.file.Paths;
12+
import java.util.regex.Matcher;
13+
import java.util.regex.Pattern;
14+
15+
public class HtmlViewer {
16+
public static void main(String[] args) {
17+
SwingUtilities.invokeLater(() -> {
18+
try {
19+
new HtmlViewer().show();
20+
} catch (Exception e) {
21+
throw new RuntimeException(e);
22+
}
23+
});
24+
}
25+
26+
public void show() throws Exception {
27+
JEditorPane jEditorPane = new JEditorPane();
28+
jEditorPane.setEditable(false);
29+
JScrollPane scrollPane = new JBScrollPane(jEditorPane);
30+
HTMLEditorKit kit = new HTMLEditorKit();
31+
jEditorPane.setEditorKit(kit);
32+
StyleSheet styleSheet = kit.getStyleSheet();
33+
styleSheet.addRule("body { color:#000; margin: 4px; font-size: 10px; }");
34+
35+
String xml = new String(Files.readAllBytes(Paths.get("src/main/resources/META-INF/plugin.xml")));
36+
Pattern pattern = Pattern.compile("<description><!\\[CDATA\\[(?<html>.*)]]></description>",
37+
Pattern.MULTILINE | Pattern.DOTALL);
38+
Matcher matcher = pattern.matcher(xml);
39+
String html = matcher.find() ? matcher.group("html") : "fail";
40+
41+
Document document = kit.createDefaultDocument();
42+
jEditorPane.setDocument(document);
43+
jEditorPane.setText(html);
44+
45+
JFrame frame = new JFrame("Html Viewer");
46+
frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
47+
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
48+
frame.setSize(new Dimension(400, 600));
49+
//frame.pack();
50+
frame.setLocationRelativeTo(null);
51+
frame.setVisible(true);
52+
}
53+
}

0 commit comments

Comments
 (0)