Skip to content

Commit 2818ae4

Browse files
committed
update to 1.2
change default debug ide to android studio, add android studio 3.4 support
1 parent 1cbe342 commit 2818ae4

File tree

7 files changed

+110
-61
lines changed

7 files changed

+110
-61
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Change Log
22

33

4+
## [v1.2](https://plugins.jetbrains.com/plugin/10907-mvpautocodeplus)(2018-11-27)
5+
6+
- Add generate model checkbox state save.
7+
- Change file template format.
8+
- Add Android Studio 3.4 support.
9+
- Fix bug.
10+
411
## [v1.1](https://plugins.jetbrains.com/plugin/10907-mvpautocodeplus)(2018-9-11)
512

613
- Support for not generating Model interfaces and corresponding implementation classes , is more flexible.

build.gradle

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
buildscript {
2-
ext.kotlin_version = '1.2.60'
2+
ext.kotlin_version = '1.3.10'
33

44
repositories {
5+
maven { url 'http://192.168.2.39:8908/repository/maven-public/' }
56
mavenCentral()
67
}
78
dependencies {
@@ -13,7 +14,7 @@ plugins {
1314
id 'org.jetbrains.intellij' version '0.3.4'
1415
}
1516

16-
version '1.1-182'
17+
version '1.2'
1718
group 'com.longforus'
1819

1920

@@ -31,14 +32,11 @@ sourceCompatibility = 1.8
3132
//}
3233

3334
repositories {
35+
// maven{ url 'http://192.168.2.39:8908/repository/maven-public/'}
3436
mavenCentral()
3537
}
3638

37-
dependencies {
38-
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
39-
// compile 'com.squareup:javapoet:1.11.0'
40-
testCompile group: 'junit', name: 'junit', version: '4.12'
41-
}
39+
4240

4341
compileKotlin {
4442
kotlinOptions.jvmTarget = "1.8"
@@ -47,23 +45,38 @@ compileTestKotlin {
4745
kotlinOptions.jvmTarget = "1.8"
4846
}
4947

48+
if (!hasProperty('StudioCompilePath')) {
49+
throw new GradleException("No StudioCompilePath value was set, please create gradle.properties file")
50+
}
5051

5152
intellij {
52-
// version '2018.2'
53-
// plugins 'org.jetbrains.kotlin:1.2.61-release-IJ2018.2-1' //here
54-
version '2018.1'
55-
plugins 'org.jetbrains.kotlin:1.2.60-release-IJ2018.1-1' //here
53+
// version '2018.3'
54+
plugins 'org.jetbrains.kotlin:1.3.10-release-IJ2018.3-1' //here
55+
// version '2018.2'
56+
// plugins 'org.jetbrains.kotlin:1.2.61-release-IJ2018.2-1' //here
57+
// version '2018.1'
58+
// plugins 'org.jetbrains.kotlin:1.2.60-release-IJ2018.1-1' //here
59+
// version '2017.3'
60+
// plugins 'org.jetbrains.kotlin:1.2.61-release-IJ2017.3-1' //here
5661
intellij.updateSinceUntilBuild false
57-
// version '2017.3'
58-
// plugins 'org.jetbrains.kotlin:1.2.61-release-IJ2017.3-1' //here
62+
intellij.localPath = project.hasProperty("StudioRunPath") ? StudioRunPath : StudioCompilePath
5963
}
6064

6165

66+
dependencies {
67+
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
68+
compileOnly fileTree(dir: "$StudioCompilePath/plugins/android/lib", include: ['*.jar'])
69+
compileOnly fileTree(dir: "$StudioCompilePath/lib", include: ['*.jar'])
70+
testCompile fileTree(dir: "$StudioCompilePath/plugins/android/lib", include: ['*.jar'])
71+
testCompile fileTree(dir: "$StudioCompilePath/lib", include: ['*.jar'])
72+
// compile 'com.squareup:javapoet:1.11.0'
73+
// testCompile group: 'junit', name: 'junit', version: '4.12'
74+
}
75+
6276
patchPluginXml {
63-
changeNotes """
64-
<h3>Add IModel interface and implementation class optional generation</h3>
65-
<br/>
66-
<a href="https://github.com/longforus/MvpAutoCodePlus/blob/master/CHANGELOG.md"><b>Full Changelog History</b></a>"""
77+
changeNotes """<h3>Add generate model checkbox state save,change file template format,fix bug</h3>
78+
<br/>
79+
<a href="https://github.com/longforus/MvpAutoCodePlus/blob/master/CHANGELOG.md"><b>Full Changelog History</b></a>"""
6780
}
6881

6982
publishPlugin {
@@ -72,6 +85,18 @@ publishPlugin {
7285
}
7386

7487
//指定编译的编码
75-
tasks.withType(JavaCompile){
88+
tasks.withType(JavaCompile) {
7689
options.encoding = "UTF-8"
7790
}
91+
92+
task verifySetup() {
93+
doLast {
94+
def ideaJar = "$StudioCompilePath/lib/idea.jar"
95+
if (!file(ideaJar).exists()) {
96+
throw new GradleException("$ideaJar not found, set StudioCompilePath in gradle.properties")
97+
}
98+
}
99+
}
100+
101+
102+
compileJava.dependsOn verifySetup

gradle.properties.copyAndChangeMe

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-Dfile.encoding=UTF-8
2+
# Copy this file as gradle.properties
3+
# It will be used for both compiling and running the plugin.
4+
5+
6+
# Path to a downloaded instance of Android Studio
7+
# This is used to add the android plugin dependencies to the project.
8+
# must point to the latest version of Android Studio.
9+
# You'll know it's right if you can find "$StudioCompilePath/lib/idea.jar"
10+
#StudioCompilePath=F:/Android/android-studio-preview/
11+
12+
13+
# Determines which IDE to run when using the "./gradlew runIdea" command.
14+
# This is useful to test the plugin on older versions of Android Studio or Intellij
15+
# Default value: $StudioCompilePath
16+
#StudioRunPath=F:/Android/android-studio-preview/

src/main/java/com/longforus/mvpautocodeplus/ui/EnterKeywordDialog.form

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="6" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
44
<margin top="10" left="10" bottom="10" right="10"/>
55
<constraints>
6-
<xy x="48" y="54" width="586" height="396"/>
6+
<xy x="48" y="54" width="586" height="400"/>
77
</constraints>
88
<properties>
9-
<minimumSize width="400" height="376"/>
9+
<minimumSize width="550" height="400"/>
10+
<preferredSize width="550" height="400"/>
1011
</properties>
1112
<border type="none"/>
1213
<children>

src/main/java/com/longforus/mvpautocodeplus/ui/EnterKeywordDialog.java

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,34 @@
3535
import org.apache.http.util.TextUtils;
3636

3737
public class EnterKeywordDialog extends JDialog {
38-
private static final String NAME_CHECK_STR = "[a-zA-Z]+[0-9a-zA-Z_]";
39-
private final Project mProject;
40-
private JPanel contentPane;
41-
private JButton buttonOK;
42-
private JButton buttonCancel;
43-
private JTextField et_name;
44-
private JRadioButton mJavaRadioButton;
45-
private JRadioButton mKotlinRadioButton;
46-
private JRadioButton mActivityRadioButton;
47-
private JRadioButton mFragmentRadioButton;
48-
private JCheckBox mViewCheckBox;
49-
private JCheckBox mPresenterCheckBox;
50-
private JCheckBox mModelCheckBox;
51-
private JComboBox<String> cob_v;
52-
private JComboBox<String> cob_p;
53-
private JComboBox<String> cob_m;
54-
private JRadioButton mGlobalRadioButton;
55-
private JRadioButton mCurrentProjectRadioButton;
56-
private JCheckBox mcbModel;
57-
private OnOkListener onOkListener;
58-
private PropertiesComponent mState;
38+
private static final String NAME_CHECK_STR = "[a-zA-Z]+[0-9a-zA-Z_]";
39+
private final Project mProject;
40+
private JPanel contentPane;
41+
private JButton buttonOK;
42+
private JButton buttonCancel;
43+
private JTextField et_name;
44+
private JRadioButton mJavaRadioButton;
45+
private JRadioButton mKotlinRadioButton;
46+
private JRadioButton mActivityRadioButton;
47+
private JRadioButton mFragmentRadioButton;
48+
private JCheckBox mViewCheckBox;
49+
private JCheckBox mPresenterCheckBox;
50+
private JCheckBox mModelCheckBox;
51+
private JComboBox<String> cob_v;
52+
private JComboBox<String> cob_p;
53+
private JComboBox<String> cob_m;
54+
private JRadioButton mGlobalRadioButton;
55+
private JRadioButton mCurrentProjectRadioButton;
56+
private JCheckBox mcbModel;
57+
private OnOkListener onOkListener;
58+
private PropertiesComponent mState;
59+
60+
{
61+
// GUI initializer generated by IntelliJ IDEA GUI Designer
62+
// >>> IMPORTANT!! <<<
63+
// DO NOT EDIT OR ADD ANY CODE HERE!
64+
$$$setupUI$$$();
65+
}
5966

6067
private EnterKeywordDialog(Project project) {
6168
mProject = project;
@@ -84,13 +91,8 @@ public void windowClosing(WindowEvent e) {
8491
}
8592
if (mGlobalRadioButton.isSelected()) {
8693
mState = PropertiesComponent.getInstance();
87-
PropertiesComponent instance = PropertiesComponent.getInstance(mProject);
88-
instance.setValue(ConsKt.USE_PROJECT_CONFIG, false);
89-
instance.setValue(ConsKt.GENERATE_MODEL_CONFIG, mcbModel.isSelected());
9094
} else {
9195
mState = PropertiesComponent.getInstance(mProject);
92-
mState.setValue(ConsKt.USE_PROJECT_CONFIG, true);
93-
mState.setValue(ConsKt.GENERATE_MODEL_CONFIG, mcbModel.isSelected());
9496
}
9597
setSavedSuperClass(this, mState);
9698
});
@@ -99,8 +101,8 @@ public void windowClosing(WindowEvent e) {
99101
public static EnterKeywordDialog getDialog(Project project, OnOkListener onOkListener) {
100102
EnterKeywordDialog dialog = new EnterKeywordDialog(project);
101103
Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
102-
int x = (int) screensize.getWidth() / 2 - dialog.getWidth() / 2;
103-
int y = (int) screensize.getHeight() / 2 - dialog.getHeight() / 2;
104+
int x = (int) screensize.getWidth() / 2 - dialog.getPreferredSize().width / 2;
105+
int y = (int) screensize.getHeight() / 2 - dialog.getPreferredSize().height / 2;
104106
dialog.setTitle("MvpAutoCodePlus");
105107
dialog.setLocation(x, y);
106108
dialog.onOkListener = onOkListener;
@@ -111,8 +113,8 @@ public static EnterKeywordDialog getDialog(Project project, OnOkListener onOkLis
111113
dialog.mCurrentProjectRadioButton.setSelected(true);
112114
} else {
113115
dialog.mState = PropertiesComponent.getInstance();
114-
setSavedSuperClass(dialog, dialog.mState);
115116
}
117+
setSavedSuperClass(dialog, dialog.mState);
116118
boolean generateModel = state.getBoolean(ConsKt.GENERATE_MODEL_CONFIG, true);
117119
dialog.mcbModel.setSelected(generateModel);
118120
dialog.pack();
@@ -123,9 +125,9 @@ public static EnterKeywordDialog getDialog(Project project, OnOkListener onOkLis
123125
private static void setSavedSuperClass(EnterKeywordDialog dialog, PropertiesComponent state) {
124126
dialog.mActivityRadioButton.addChangeListener(e -> {
125127
if (dialog.mActivityRadioButton.isSelected()) {
126-
setSuperClass(dialog.cob_v, state.getValue(ConsKt.SUPER_VIEW_ACTIVITY), dialog.mViewCheckBox, ConsKt.IS_NOT_SET + "," + ConsKt.GOTO_SETTING);
128+
setSuperClass(dialog.cob_v, dialog.mState.getValue(ConsKt.SUPER_VIEW_ACTIVITY), dialog.mViewCheckBox, ConsKt.IS_NOT_SET + "," + ConsKt.GOTO_SETTING);
127129
} else {
128-
setSuperClass(dialog.cob_v, state.getValue(ConsKt.SUPER_VIEW_FRAGMENT), dialog.mViewCheckBox, ConsKt.IS_NOT_SET + "," + ConsKt.GOTO_SETTING);
130+
setSuperClass(dialog.cob_v, dialog.mState.getValue(ConsKt.SUPER_VIEW_FRAGMENT), dialog.mViewCheckBox, ConsKt.IS_NOT_SET + "," + ConsKt.GOTO_SETTING);
129131
}
130132
});
131133
setSuperClass(dialog.cob_v, state.getValue(ConsKt.SUPER_VIEW_ACTIVITY), dialog.mViewCheckBox, ConsKt.IS_NOT_SET + "," + ConsKt.GOTO_SETTING);
@@ -155,13 +157,6 @@ private static String getSelectedContent(JComboBox<String> cob) {
155157
}
156158
}
157159

158-
{
159-
// GUI initializer generated by IntelliJ IDEA GUI Designer
160-
// >>> IMPORTANT!! <<<
161-
// DO NOT EDIT OR ADD ANY CODE HERE!
162-
$$$setupUI$$$();
163-
}
164-
165160
private void onCancel() {
166161
// add your code here if necessary
167162
dispose();
@@ -205,6 +200,9 @@ private void onOK() {
205200
return;
206201
}
207202
buttonOK.setEnabled(false);
203+
PropertiesComponent instance = PropertiesComponent.getInstance(mProject);
204+
instance.setValue(ConsKt.USE_PROJECT_CONFIG, !mGlobalRadioButton.isSelected());
205+
instance.setValue(ConsKt.GENERATE_MODEL_CONFIG, mcbModel.isSelected(), true);
208206
if (onOkListener != null) {
209207
onOkListener.onOk(new ItemConfigBean(key, mJavaRadioButton.isSelected(), mActivityRadioButton.isSelected(), getSelectedContent(cob_v), getSelectedContent(cob_p),
210208
getSelectedContent(cob_m), mState, mcbModel.isSelected()));

src/main/kotlin/com/longforus/mvpautocodeplus/MainAction.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,10 @@ class MainAction : AnAction("main", "auto make mvp code", PlatformIcons.CLASS_IC
135135
}
136136
}
137137

138-
override fun update(e: AnActionEvent?) {
139-
val dataContext = e!!.dataContext
138+
139+
override fun update(e: AnActionEvent) {
140+
super.update(e)
141+
val dataContext = e.dataContext
140142
val presentation = e.presentation
141143

142144
val enabled = isAvailable(dataContext)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<!--]]></change-notes>-->
3939

4040
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
41-
<idea-version since-build="171"/>
41+
<idea-version since-build="173"/>
4242
<!--<idea-version since-build="173.3727" until-build="182.*"/>-->
4343
<depends>org.jetbrains.kotlin</depends>
4444
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html

0 commit comments

Comments
 (0)