@@ -483,7 +483,7 @@ private void stopServer(String stripeName, String serverName, Button stopBT) {
483
483
private void startServer (String stripeName , String serverName , Button startBT , Button stopBT , Label stateLBL , Label pidLBL ) {
484
484
File stripeconfig = tcConfigLocationPerStripe .get (stripeName );
485
485
if (stripeconfig == null ) {
486
- generateXML ();
486
+ generateXML (false );
487
487
stripeconfig = tcConfigLocationPerStripe .get (stripeName );
488
488
}
489
489
@@ -688,7 +688,7 @@ private void addVoltronConfigControls() {
688
688
generateTcConfig .addStyleName ("align-bottom" );
689
689
generateTcConfig .setWidth (100 , Unit .PERCENTAGE );
690
690
generateTcConfig .addClickListener ((Button .ClickListener ) event -> {
691
- generateXML ();
691
+ generateXML (true );
692
692
List <String > filenames = tcConfigLocationPerStripe .values ().stream ().map (File ::getName ).collect (Collectors .toList ());
693
693
Notification .show ("Configurations saved:" , "Location: " + settings .getKitPath () + "\n Files: " + filenames , Notification .Type .HUMANIZED_MESSAGE );
694
694
});
@@ -721,7 +721,7 @@ private void changeTrashButtonStatus(String pathname) {
721
721
}
722
722
}
723
723
724
- private void generateXML () {
724
+ private void generateXML (boolean skipConfirmOverwrite ) {
725
725
boolean ee = kitAwareClassLoaderDelegator .isEEKit ();
726
726
727
727
tcConfigLocationPerStripe .clear ();
@@ -848,19 +848,28 @@ private void generateXML() {
848
848
sb .append (" </servers>\n \n " +
849
849
"</tc-config>" );
850
850
851
- String xml = sb .toString ();
852
-
853
- tcConfigXml .setValue (tcConfigXml .getValue () + xml + "\n \n " );
854
-
855
851
String filename = "tc-config-stripe-" + stripeRow + ".xml" ;
856
852
File location = new File (settings .getKitPath (), filename );
857
853
tcConfigLocationPerStripe .put ("stripe-" + stripeRow , location );
858
854
859
- try {
860
- Files .write (location .toPath (), xml .getBytes ("UTF-8" ));
861
- } catch (IOException e ) {
862
- throw new UncheckedIOException (e );
855
+ String xml ;
856
+ if (location .exists () && !skipConfirmOverwrite ) {
857
+ Notification .show ("Config already found: " + location .getName ());
858
+ try {
859
+ xml = new String (Files .readAllBytes (location .toPath ()), "UTF-8" );
860
+ } catch (IOException e ) {
861
+ throw new UncheckedIOException (e );
862
+ }
863
+ } else {
864
+ xml = sb .toString ();
865
+ try {
866
+ Files .write (location .toPath (), xml .getBytes ("UTF-8" ));
867
+ } catch (IOException e ) {
868
+ throw new UncheckedIOException (e );
869
+ }
863
870
}
871
+
872
+ tcConfigXml .setValue (tcConfigXml .getValue () + xml + "\n \n " );
864
873
}
865
874
}
866
875
0 commit comments