Skip to content

Commit b334fbb

Browse files
committed
fix bug#4
1 parent 59088b4 commit b334fbb

File tree

9 files changed

+145
-96
lines changed

9 files changed

+145
-96
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414
getString(R.string.xxxx)
1515
```
1616

17-
可以通过在设置中指定xml 文件位置和feature id
17+
可以通过在设置中指定xml 文件位置和prefix。(suffix 为可选项)
18+
1819
路径:Android Studio / Preferences / Tools / Extract To Special Xml
1920

2021
可以通过指定python 的方式,动态获取feature id。标准:
2122
>可以接受一个参数,参数的内容是项目的地址\
22-
结果需要通过打印到控制台的方式返回
23+
结果需要通过打印到控制台的方式返回\
24+
返回的格式为
25+
> prefix/suffix
2326
2427
比如:
2528

build.gradle

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import java.util.function.Consumer
2+
13
plugins {
24
id 'org.jetbrains.intellij' version '1.3.0'
35
id 'java'
@@ -21,9 +23,12 @@ intellij {
2123
plugins = ['org.jetbrains.kotlin','java']
2224
updateSinceUntilBuild = false
2325
}
26+
2427
patchPluginXml {
25-
sinceBuild = '203.1'
26-
untilBuild = '203.*'
28+
if (!gradle.startParameter.taskNames.contains(":runIde")) {
29+
sinceBuild = '203.1'
30+
untilBuild = '203.*'
31+
}
2732
changeNotes = """
2833
Add change notes here.<br>
2934
<em>most HTML tags may be used</em>"""

src/main/java/com/fuzhengyin/string_appender/AppSettingsComponent.java

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public AppSettingsComponent() {
2121
appSettingsPanel = new AppSettingsPanel();
2222
myMainPanel = appSettingsPanel.contentPanel;
2323
xmlPathText = appSettingsPanel.xmlPath;
24-
featureIdText = appSettingsPanel.featuredId;
24+
featureIdText = appSettingsPanel.prefixTextField;
2525
}
2626

2727
public JPanel getPanel() {
@@ -41,16 +41,16 @@ public void setXmlPath(@NotNull String newText) {
4141
xmlPathText.setText(newText);
4242
}
4343

44-
public String getFeatureId() {
44+
public String getPrefix() {
4545
return featureIdText.getText();
4646
}
4747

48-
public void setFeatureId(String newStatus) {
48+
public void setPrefix(String newStatus) {
4949
featureIdText.setText(newStatus);
5050
}
5151

5252
public int getMaxWordType() {
53-
return appSettingsPanel.maxWordType();
53+
return appSettingsPanel.keyRestrictType();
5454
}
5555

5656
public String getFeatureScriptPath() {
@@ -63,11 +63,10 @@ public int getMaxWord() {
6363

6464
public void setMaxWord(int word) {
6565
appSettingsPanel.spinnerMaxWord.setValue(word);
66-
appSettingsPanel.spinnerMaxLength.setValue(word);
6766
}
6867

69-
public void setMaxWordType(int type) {
70-
appSettingsPanel.setMaxWordType(type);
68+
public void setKeyRestrictType(int type) {
69+
appSettingsPanel.setKeyRestrictType(type);
7170
}
7271

7372
public int getMaxLength() {
@@ -78,19 +77,19 @@ public void setMaxLength(int length) {
7877
appSettingsPanel.spinnerMaxLength.setValue(length);
7978
}
8079

81-
public int getFeatureIdType() {
82-
return appSettingsPanel.featureId();
80+
public int getFixProduceType() {
81+
return appSettingsPanel.fixProduceType();
8382
}
8483

85-
public void setFeatureIdType(int type) {
86-
appSettingsPanel.setFeatureIdType(type);
84+
public void setFixProduceType(int type) {
85+
appSettingsPanel.setFixProduceType(type);
8786
}
8887

8988
public String getFeatureIdScriptPath() {
9089
return appSettingsPanel.featureScriptPath.getText();
9190
}
9291

93-
public void setFeatureIdScriptPath(String path) {
92+
public void setFixProduceScriptPath(String path) {
9493
appSettingsPanel.featureScriptPath.setText(path);
9594
}
9695

@@ -101,4 +100,12 @@ public String getPythonPath() {
101100
public void setPythonPath(String pythonPath) {
102101
appSettingsPanel.pythonPath.setText(pythonPath);
103102
}
103+
104+
public String getSuffix() {
105+
return appSettingsPanel.suffixTextField.getText();
106+
}
107+
108+
public void setSuffix(String suffix) {
109+
appSettingsPanel.suffixTextField.setText(suffix);
110+
}
104111
}

src/main/java/com/fuzhengyin/string_appender/AppSettingsConfigurable.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,40 +40,43 @@ public JComponent createComponent() {
4040
public boolean isModified() {
4141
AppSettingsState settings = AppSettingsState.getInstance();
4242
boolean modified = !mySettingsComponent.getXmlPath().equals(settings.xmlPath);
43-
modified |= !mySettingsComponent.getFeatureId().equals(settings.featureId);
44-
modified |= !mySettingsComponent.getFeatureIdScriptPath().equals(settings.featureScriptPath);
45-
modified |= mySettingsComponent.getFeatureIdType() != settings.featureProduceType;
43+
modified |= !mySettingsComponent.getPrefix().equals(settings.prefix);
44+
modified |= !mySettingsComponent.getFeatureIdScriptPath().equals(settings.fixProduceScriptPath);
45+
modified |= mySettingsComponent.getFixProduceType() != settings.fixProduceType;
4646
modified |= mySettingsComponent.getMaxWordType() != settings.maxWordType;
4747
modified |= mySettingsComponent.getMaxWord() != settings.maxWord;
4848
modified |= mySettingsComponent.getMaxLength() != settings.maxLength;
4949
modified |= !mySettingsComponent.getPythonPath().equals(settings.pythonPath);
50+
modified |= !mySettingsComponent.getSuffix().equals(settings.suffix);
5051
return modified;
5152
}
5253

5354
@Override
5455
public void apply() {
5556
AppSettingsState settings = AppSettingsState.getInstance();
5657
settings.xmlPath = mySettingsComponent.getXmlPath();
57-
settings.featureId = mySettingsComponent.getFeatureId();
58-
settings.featureProduceType = mySettingsComponent.getFeatureIdType();
59-
settings.featureScriptPath = mySettingsComponent.getFeatureScriptPath();
58+
settings.prefix = mySettingsComponent.getPrefix();
59+
settings.fixProduceType = mySettingsComponent.getFixProduceType();
60+
settings.fixProduceScriptPath = mySettingsComponent.getFeatureScriptPath();
6061
settings.maxWordType = mySettingsComponent.getMaxWordType();
6162
settings.maxWord = mySettingsComponent.getMaxWord();
6263
settings.maxLength = mySettingsComponent.getMaxLength();
6364
settings.pythonPath = mySettingsComponent.getPythonPath();
65+
settings.suffix = mySettingsComponent.getSuffix();
6466
}
6567

6668
@Override
6769
public void reset() {
6870
AppSettingsState settings = AppSettingsState.getInstance();
6971
mySettingsComponent.setXmlPath(settings.xmlPath);
70-
mySettingsComponent.setFeatureId(settings.featureId);
71-
mySettingsComponent.setFeatureIdType(settings.featureProduceType);
72-
mySettingsComponent.setFeatureIdScriptPath(settings.featureScriptPath);
72+
mySettingsComponent.setPrefix(settings.prefix);
73+
mySettingsComponent.setFixProduceType(settings.fixProduceType);
74+
mySettingsComponent.setFixProduceScriptPath(settings.fixProduceScriptPath);
75+
mySettingsComponent.setPythonPath(settings.pythonPath);
76+
mySettingsComponent.setKeyRestrictType(settings.maxWordType);
7377
mySettingsComponent.setMaxWord(settings.maxWord);
74-
mySettingsComponent.setMaxWordType(settings.maxWordType);
7578
mySettingsComponent.setMaxLength(settings.maxLength);
76-
mySettingsComponent.setPythonPath(settings.pythonPath);
79+
mySettingsComponent.setSuffix(settings.suffix);
7780
}
7881

7982
@Override

src/main/java/com/fuzhengyin/string_appender/AppSettingsPanel.form

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.fuzhengyin.string_appender.AppSettingsPanel">
3-
<grid id="27dc6" binding="contentPanel" layout-manager="GridLayoutManager" row-count="7" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
3+
<grid id="27dc6" binding="contentPanel" layout-manager="GridLayoutManager" row-count="7" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
44
<margin top="0" left="0" bottom="0" right="0"/>
55
<constraints>
6-
<xy x="20" y="20" width="500" height="234"/>
6+
<xy x="20" y="20" width="607" height="234"/>
77
</constraints>
88
<properties/>
99
<border type="none"/>
@@ -18,7 +18,7 @@
1818
</component>
1919
<component id="abc3b" class="com.intellij.ui.components.JBTextField" binding="xmlPath">
2020
<constraints>
21-
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
21+
<grid row="0" column="2" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
2222
<preferred-size width="150" height="-1"/>
2323
</grid>
2424
</constraints>
@@ -29,42 +29,44 @@
2929
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
3030
</constraints>
3131
<properties>
32-
<text value="Feature Id"/>
32+
<text value="Extra-fix"/>
3333
</properties>
3434
</component>
35-
<component id="6e9d0" class="com.intellij.ui.components.JBTextField" binding="featuredId">
35+
<component id="6e9d0" class="com.intellij.ui.components.JBTextField" binding="prefixTextField">
3636
<constraints>
3737
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
3838
<preferred-size width="150" height="-1"/>
3939
</grid>
4040
</constraints>
41-
<properties/>
41+
<properties>
42+
<toolTipText value="prefix"/>
43+
</properties>
4244
</component>
4345
<component id="6daf2" class="javax.swing.JLabel">
4446
<constraints>
4547
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
4648
</constraints>
4749
<properties>
48-
<text value="restricted"/>
50+
<text value="Restricted"/>
4951
</properties>
5052
</component>
51-
<component id="c88be" class="javax.swing.JRadioButton" binding="fixedString">
53+
<component id="c88be" class="com.intellij.ui.components.JBRadioButton" binding="fixedString">
5254
<constraints>
5355
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
5456
</constraints>
5557
<properties>
5658
<text value="fixed"/>
5759
</properties>
5860
</component>
59-
<component id="1a019" class="javax.swing.JTextField" binding="featureScriptPath">
61+
<component id="1a019" class="com.intellij.ui.components.JBTextField" binding="featureScriptPath">
6062
<constraints>
61-
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
63+
<grid row="2" column="2" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
6264
<preferred-size width="150" height="-1"/>
6365
</grid>
6466
</constraints>
6567
<properties/>
6668
</component>
67-
<component id="21604" class="javax.swing.JRadioButton" binding="scriptRadioButton" default-binding="true">
69+
<component id="21604" class="com.intellij.ui.components.JBRadioButton" binding="scriptRadioButton" default-binding="true">
6870
<constraints>
6971
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
7072
</constraints>
@@ -74,41 +76,41 @@
7476
</component>
7577
<component id="d8a96" class="javax.swing.JButton" binding="selectXmlPath">
7678
<constraints>
77-
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
79+
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
7880
</constraints>
7981
<properties>
8082
<text value="select"/>
8183
</properties>
8284
</component>
8385
<component id="2401f" class="javax.swing.JButton" binding="selectScriptPath">
8486
<constraints>
85-
<grid row="2" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
87+
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
8688
</constraints>
8789
<properties>
8890
<text value="select"/>
8991
</properties>
9092
</component>
91-
<component id="b4af2" class="javax.swing.JRadioButton" binding="maxWordCountRadioButton" default-binding="true">
93+
<component id="b4af2" class="com.intellij.ui.components.JBRadioButton" binding="maxWordCountRadioButton" default-binding="true">
9294
<constraints>
9395
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
9496
</constraints>
9597
<properties>
9698
<text value="max word count"/>
9799
</properties>
98100
</component>
99-
<component id="95a87" class="javax.swing.JSpinner" binding="spinnerMaxWord">
101+
<component id="95a87" class="com.intellij.ui.JBIntSpinner" binding="spinnerMaxWord" custom-create="true">
100102
<constraints>
101-
<grid row="4" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
103+
<grid row="4" column="2" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
102104
</constraints>
103105
<properties/>
104106
</component>
105-
<component id="78608" class="javax.swing.JSpinner" binding="spinnerMaxLength">
107+
<component id="78608" class="com.intellij.ui.JBIntSpinner" binding="spinnerMaxLength" custom-create="true">
106108
<constraints>
107-
<grid row="5" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
109+
<grid row="5" column="2" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
108110
</constraints>
109111
<properties/>
110112
</component>
111-
<component id="6668c" class="javax.swing.JRadioButton" binding="maxLengthRadioButton" default-binding="true">
113+
<component id="6668c" class="com.intellij.ui.components.JBRadioButton" binding="maxLengthRadioButton" default-binding="true">
112114
<constraints>
113115
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
114116
</constraints>
@@ -118,7 +120,7 @@
118120
</component>
119121
<component id="f6693" class="javax.swing.JLabel">
120122
<constraints>
121-
<grid row="6" column="0" row-span="1" col-span="4" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
123+
<grid row="6" column="0" row-span="1" col-span="5" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
122124
</constraints>
123125
<properties>
124126
<text value="如果添加了限制,会在遇到限制的情况下弹窗,由用户自定义key,保持为0为默认值"/>
@@ -132,14 +134,24 @@
132134
<text value="python"/>
133135
</properties>
134136
</component>
135-
<component id="25e44" class="javax.swing.JTextField" binding="pythonPath">
137+
<component id="25e44" class="com.intellij.ui.components.JBTextField" binding="pythonPath">
136138
<constraints>
137-
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
139+
<grid row="3" column="2" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
138140
<preferred-size width="150" height="-1"/>
139141
</grid>
140142
</constraints>
141143
<properties/>
142144
</component>
145+
<component id="dc978" class="com.intellij.ui.components.JBTextField" binding="suffixTextField">
146+
<constraints>
147+
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
148+
<preferred-size width="150" height="-1"/>
149+
</grid>
150+
</constraints>
151+
<properties>
152+
<toolTipText value="suffix"/>
153+
</properties>
154+
</component>
143155
</children>
144156
</grid>
145157
<buttonGroups>

0 commit comments

Comments
 (0)