@@ -101,11 +101,11 @@ protected void textChanged(@NotNull DocumentEvent documentEvent) {
101101 }
102102
103103 private void onAddConfig () {
104- currentConfig = Config .INSTANCE .getTEMPLATE_ANDROID_APPLICATION ();
105- configs .add (currentConfig );
106- templateListModel .addElement (currentConfig .getTemplateName ());
104+ Module newConfig = Config .INSTANCE .getTEMPLATE_ANDROID_APPLICATION (). clone ();
105+ configs .add (newConfig );
106+ templateListModel .addElement (newConfig .getTemplateName ());
107107 listTemplate .doLayout ();
108- listTemplate .setSelectedIndex (configs .indexOf (currentConfig ));
108+ listTemplate .setSelectedIndex (configs .indexOf (newConfig ));
109109 }
110110
111111 private void onRemoveConfig () {
@@ -122,11 +122,11 @@ private void onCopyConfig() {
122122 if (noSelectedConfig ()) {
123123 return ;
124124 }
125- currentConfig = currentConfig .clone ();
126- configs .add (currentConfig );
127- templateListModel .addElement (currentConfig .getTemplateName ());
125+ Module newConfig = currentConfig .clone ();
126+ configs .add (newConfig );
127+ templateListModel .addElement (newConfig .getTemplateName ());
128128 listTemplate .doLayout ();
129- listTemplate .setSelectedIndex (configs .indexOf (currentConfig ));
129+ listTemplate .setSelectedIndex (configs .indexOf (newConfig ));
130130 }
131131
132132 private void loadConfig () {
@@ -144,14 +144,15 @@ private void onConfigSelect(int index) {
144144 }
145145 currentConfig = configs .get (index );
146146 tfName .setText (currentConfig .getTemplateName ());
147- panelPreview .setModuleConfig (currentConfig );
148147
149- // update file template and placeholder table
148+ // update tree, file template and placeholder table
149+ panelPreview .setModuleConfig (currentConfig );
150150 tableFileTemp .setPairData (currentConfig .getTemplate ().getFileTemplates ());
151151 tablePlaceholder .setPairData (currentConfig .getTemplate ().getPlaceHolderMap ());
152152 }
153153
154154 private void cacheConfig () {
155+ if (currentConfig == null ) return ;
155156 currentConfig .getTemplate ().setFileTemplates (tableFileTemp .getPairResult ());
156157 currentConfig .getTemplate ().setPlaceHolderMap (tablePlaceholder .getPairResult ());
157158 }
0 commit comments