Skip to content

Commit 2776a89

Browse files
authored
Merge pull request #19 from XieEDeHeiShou/master
master
2 parents a54ed4e + 8b558ad commit 2776a89

File tree

11 files changed

+349
-251
lines changed

11 files changed

+349
-251
lines changed

.idea/workspace.xml

Lines changed: 285 additions & 236 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MVPHelper.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
88
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
99
</content>
10-
<orderEntry type="jdk" jdkName="IntelliJ IDEA IU-171.4073.35" jdkType="IDEA JDK" />
10+
<orderEntry type="inheritedJdk" />
1111
<orderEntry type="sourceFolder" forTests="false" />
1212
</component>
1313
</module>
Binary file not shown.

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
![suffix_support](img/suffix_support.gif)
2121

22+
日志输出(气球偶尔会闪现一下,可以在Event Log里关闭):
23+
24+
![log](img/log.gif)
25+
2226
错误提示:
2327

2428
![error_package](img/error_package.gif)
@@ -49,8 +53,8 @@
4953

5054
### 或者
5155
#### 第一步
52-
下载[MvpHelper_v2_1_release.jar](MVPHelper_v2_1_release.jar)
53-
或者前往 [releases](https://github.com/XieEDeHeiShou/MVPHelper/releases/tag/2.1)
56+
下载[MvpHelper_v2_2_release.jar](MVPHelper_v2_2_release.jar)
57+
或者前往 [releases](https://github.com/XieEDeHeiShou/MVPHelper/releases/tag/2.2)
5458

5559
#### 第二步
5660
安装插件
@@ -101,7 +105,11 @@
101105
+ [AndroidStudio/IDEA插件开发学习](http://www.jianshu.com/p/0117d4b1eb00) (中文博客)
102106

103107
## 更新日志
104-
### v2.0版 -基于Intellij Open Api 实现 by [XieEDeHeiShou](https://github.com/XieEDeHeiShou)
108+
### v2.x版 -基于Intellij Open Api 实现 by [XieEDeHeiShou](https://github.com/XieEDeHeiShou)
109+
+ 2017-04-27
110+
+ 修复实现类修饰符异常 package-private -> public
111+
+ 新增日志类EventLogger
112+
+ MvpHelper_v2_2_release.jar
105113
+ 2017-04-25
106114
+ 实现配置信息的存取
107115
+ 实现运行时加载配置信息
@@ -132,7 +140,7 @@
132140
+ Java源文件的文件名是否以 ```Presenter``` 结尾, 并处于 ```presenter``` 包下
133141

134142

135-
### v1.1版 -基于Java IO Api 实现 by [githubwing](https://github.com/githubwing)
143+
### v1.x版 -基于Java IO Api 实现 by [githubwing](https://github.com/githubwing)
136144
+ 2017-04-10 将源文件分包并尝试重构
137145
+ 2017-04-09 移除源文件中的 ```C``` 语言异味
138146
+ 2017-04-06 分支自[原仓库](https://github.com/githubwing/MVPHelper), 并向源文件中追加注释, 以便阅读

README_EN.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Suffix support:
1919

2020
![suffix_support](img/suffix_support.gif)
2121

22+
Log (unexpected balloon may appear, just disable it in the Event Log):
23+
![log](img/log.gif)
24+
2225
Error dialog:
2326

2427
![error_package](img/error_package.gif)
@@ -49,8 +52,8 @@ will greatly reduce the number of source files:
4952

5053
### Or install plugin.jar
5154
#### step1
52-
Download [MvpHelper_v2_1_release.jar](MVPHelper_v2_1_release.jar)
53-
or redirect to [releases](https://github.com/XieEDeHeiShou/MVPHelper/releases/tag/2.1)
55+
Download [MvpHelper_v2_2_release.jar](MVPHelper_v2_2_release.jar)
56+
or redirect to [releases](https://github.com/XieEDeHeiShou/MVPHelper/releases/tag/2.2)
5457

5558
#### step2
5659
Install it.
@@ -61,7 +64,7 @@ Install it.
6164
In ```Contract``` or ```Presenter``` ,click ```Generate``` menu or try hot-key ```Alt + Insert```,
6265
select ```Mvp Helper``` .
6366

64-
## Features
67+
## Feature
6568
+ Remove hot-key ```Meta + 1```
6669
+ MvpHelper menu will not appear in un-java files when use hot key ```Alt + Insert```
6770
+ No more root package limit (v1.0 only support com,org,me...)
@@ -100,7 +103,11 @@ select ```Mvp Helper``` .
100103
+ [AndroidStudio/IDEA插件开发学习](http://www.jianshu.com/p/0117d4b1eb00) (Chinese blog)
101104

102105
## Change log
103-
### v2.0 -Based on Intellij Open Api, by [XieEDeHeiShou](https://github.com/XieEDeHeiShou)
106+
### v2.x -Based on Intellij Open Api, by [XieEDeHeiShou](https://github.com/XieEDeHeiShou)
107+
+ 2017-04-27
108+
+ Fix generated class modifier bug:package-private -> public
109+
+ Add EventLogger
110+
+ MvpHelper_v2_2_release.jar
104111
+ 2017-04-25
105112
+ Save and load configurations.
106113
+ Load config while running.
@@ -130,7 +137,7 @@ select ```Mvp Helper``` .
130137
+ Is the document END WITH ```Contract``` and UNDER a ```contract``` package
131138
+ Is the document END WITH ```Presneter``` and UNDER a ```presenter``` package
132139

133-
### v1.1 -Based on Java IO Api, by [githubwing](https://github.com/githubwing)
140+
### v1.x -Based on Java IO Api, by [githubwing](https://github.com/githubwing)
134141
+ 2017-04-10 Try to rebuild the project with Intellij Open Api.
135142
+ 2017-04-09 Remove ```C``` smell form original source code.
136143
+ 2017-04-06 Fork form [original repe](https://github.com/githubwing/MVPHelper), add comment lines for reading.

img/log.gif

697 KB
Loading

resources/META-INF/plugin.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
55
<idea-version since-build="141.0"/>
66
<name>MVPHelper</name>
7-
<version>2.1</version>
7+
<version>2.2</version>
88
<vendor email="[email protected]" url="https://github.com/githubwing/MVPHelper"/>
99
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
1010
on how to target different products -->
1111
<!-- uncomment to enable plugin in all products
1212
<depends>com.intellij.modules.lang</depends>
1313
-->
1414
<description>
15-
A plugin that helps you to create classes and interfaces for MVP. Click Generate --> MVPHelper in Contract or
16-
Presenter class. see the https://github.com/githubwing/MVPHelper
15+
A plugin that helps you to create classes and interfaces for MVP.
16+
Click 'Generate' --> 'Mvp Helper' in Contract or Presenter class.
17+
For more detail see the link below.
1718
</description>
1819

1920
<extensions defaultExtensionNs="com.intellij">
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.wingsofts.mvphelper.biz;
2+
3+
import com.intellij.notification.Notification;
4+
import com.intellij.notification.NotificationType;
5+
import com.intellij.notification.Notifications;
6+
7+
/**
8+
* @author Administrator
9+
* @since 2017/4/27
10+
*/
11+
public class EventLogger {
12+
private static final String GROUP_ID = "Mvp Helper";//The unique group id where "Event Log" could use to group your messages together.
13+
private static final String TITLE = "Mvp Helper Event Log";//The title on Balloon
14+
15+
/**
16+
* Print log to "Event Log"
17+
*/
18+
public static void log(String msg) {
19+
Notification notification = new Notification(GROUP_ID, TITLE, msg, NotificationType.INFORMATION);//build a notification
20+
Notifications.Bus.notify(notification);//use the default bus to notify (application level)
21+
//noinspection ConstantConditions: since the notification has been notified, the balloon won't be null.
22+
notification.getBalloon().hide(true);//try to hide the balloon immediately.
23+
}
24+
}

src/com/wingsofts/mvphelper/biz/dir/generator/impl/BaseDirGenerator.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
import java.util.ResourceBundle;
1515

16+
import static com.wingsofts.mvphelper.biz.EventLogger.log;
17+
1618
/**
1719
* @author DengChao
1820
* @see #moveDirPointer(PsiDirectory, String)
@@ -110,6 +112,7 @@ protected PsiDirectory moveDirPointer(@NotNull final PsiDirectory currentDir, @N
110112
if (subDirectory[0] == null) {
111113
WriteCommandAction.runWriteCommandAction(currentDir.getProject(), () -> {
112114
subDirectory[0] = currentDir.createSubdirectory(subPackage);
115+
log("BaseDirGenerator: " + currentDir.getVirtualFile().getPath() + "/" + subPackage + " generated");
113116
});
114117
}
115118
return subDirectory[0];

src/com/wingsofts/mvphelper/biz/file/generator/impl/BaseFileGenerator.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import com.wingsofts.mvphelper.biz.config.impl.MvpConfig;
1111
import com.wingsofts.mvphelper.biz.file.generator.FileGenerator;
1212

13+
import static com.wingsofts.mvphelper.biz.EventLogger.log;
14+
1315
/**
1416
* The base file generator, provide basic functions for child-class.
1517
*
@@ -18,6 +20,7 @@
1820
*/
1921
@SuppressWarnings({"ConstantConditions", "WeakerAccess"})
2022
abstract class BaseFileGenerator implements FileGenerator {
23+
// private final org.apache.log4j.Logger logger;
2124
protected Project myProject;//current java project
2225
protected PsiDirectory myContractDir;//the contract package dir
2326
protected PsiDirectory myModelDir;//the model package dir
@@ -66,17 +69,18 @@ protected void generateFile(final PsiDirectory directory, final String fileName,
6669
psiClass = psiClasses[0];
6770
javaFile = (PsiJavaFile) psiClass.getContainingFile();
6871
javaFile.delete();//then delete the old one
69-
System.out.println("JavaModeFileGenerator.generateFile: " + fixedFileName + " old file deleted");
72+
log("BaseFileGenerator: " + fixedFileName + " old file deleted");
7073
}//and re-generate one
7174
psiClass = myDirectoryService.createClass(directory, fixedFileName, type);
7275
javaFile = (PsiJavaFile) psiClass.getContainingFile();
7376
PsiPackage psiPackage = myDirectoryService.getPackage(directory);
7477
javaFile.setPackageName(psiPackage.getQualifiedName());
75-
System.out.println("JavaModeFileGenerator.generateFile: " + fixedFileName + " generated");
78+
log("BaseFileGenerator: " + fixedFileName + " generated");
7679
listener.onJavaFileGenerated(javaFile, psiClass);
7780
});
7881
}
7982

83+
8084
@FunctionalInterface
8185
protected interface onFileGeneratedListener {
8286
/**

0 commit comments

Comments
 (0)