55import com .dengzii .plugin .template .template .AucTemplate ;
66import com .intellij .icons .AllIcons ;
77import com .intellij .openapi .options .SearchableConfigurable ;
8- import com .intellij .openapi .roots .ui .componentsList .components .ScrollablePanel ;
98import com .intellij .ui .DocumentAdapter ;
109import com .intellij .ui .components .JBList ;
11- import com .intellij .ui .table .JBTable ;
1210import org .jetbrains .annotations .Nls ;
1311import org .jetbrains .annotations .NotNull ;
1412import org .jetbrains .annotations .Nullable ;
@@ -35,11 +33,11 @@ public class ConfigurePanel extends JPanel implements SearchableConfigurable {
3533 private JButton btRemove ;
3634 private JButton btCopy ;
3735
38- private JTextArea taPlaceholder ;
3936 private JTextField tfName ;
40- private JBTable JB ;
4137 private JBList listTemplate ;
4238 private JPanel panelStructure ;
39+ private JPanel panelPlaceholder ;
40+ private JPanel panelFileTemp ;
4341
4442 private List <Module > configs ;
4543 private DefaultListModel <String > model ;
@@ -49,10 +47,23 @@ public class ConfigurePanel extends JPanel implements SearchableConfigurable {
4947 private ConfigurePanel panel ;
5048 private PreviewPanel previewPanel ;
5149
50+ private EditableTable tablePlaceholder ;
51+ private EditableTable tableFileTemp ;
52+
5253 private ConfigurePanel () {
54+
55+ initComponent ();
56+ initPanel ();
57+ }
58+
59+ private void initComponent () {
5360 setLayout (new BorderLayout ());
5461 add (contentPane );
55- initPanel ();
62+
63+ tablePlaceholder = new EditableTable (new String []{"Placeholder" , "Default Value" });
64+ tableFileTemp = new EditableTable (new String []{"FileName" , "Template" });
65+ panelPlaceholder .add (tablePlaceholder , BorderLayout .CENTER );
66+ panelFileTemp .add (tableFileTemp , BorderLayout .CENTER );
5667 }
5768
5869 @ Override
@@ -61,6 +72,7 @@ public void apply() {
6172 panel .apply ();
6273 return ;
6374 }
75+ cacheConfig ();
6476 Config .INSTANCE .saveModuleTemplates (configs );
6577 }
6678
@@ -79,13 +91,13 @@ public JComponent createComponent() {
7991
8092 @ Override
8193 public boolean isModified () {
82- return true ;//currentConfig != null && !tfName.getText().equals(currentConfig.getTemplateName());
94+ return true ;
8395 }
8496
8597 @ Nls (capitalization = Nls .Capitalization .Title )
8698 @ Override
8799 public String getDisplayName () {
88- return "Module Template Generator " ;
100+ return "Directory Template" ;
89101 }
90102
91103 private void onAdd () {
@@ -130,9 +142,21 @@ private void onTemplateSelect(int index) {
130142 if (currentConfig == configs .get (index )) {
131143 return ;
132144 }
145+ if (currentConfig != null ) {
146+ cacheConfig ();
147+ }
133148 currentConfig = configs .get (index );
134149 tfName .setText (currentConfig .getTemplateName ());
135150 previewPanel .setModuleConfig (currentConfig );
151+
152+ // update file template and placeholder table
153+ tableFileTemp .setPairData (currentConfig .getTemplate ().getFileTemplates ());
154+ tablePlaceholder .setPairData (currentConfig .getTemplate ().getPlaceHolderMap ());
155+ }
156+
157+ private void cacheConfig () {
158+ currentConfig .getTemplate ().setFileTemplates (tableFileTemp .getPairResult ());
159+ currentConfig .getTemplate ().setPlaceHolderMap (tablePlaceholder .getPairResult ());
136160 }
137161
138162 private void initPanel () {
0 commit comments