@@ -101,7 +101,27 @@ public Svg2Xml(Svg2XmlGui gui)
101101 String groupXml = new String ();
102102 ByteArrayOutputStream groupBaos = new ByteArrayOutputStream ();
103103 String groupName = stencilUserMarker ;
104- sourceFolder = gui .sourceFileListComponent .getSelectedFiles ()[0 ].getParent ();
104+ boolean areFiles = false ;
105+
106+ //checks if files are selected too, or only folders
107+ for (int i = 0 ; i < gui .sourceFileListComponent .getSelectedFiles ().length ; i ++)
108+ {
109+ if (gui .sourceFileListComponent .getSelectedFiles ()[i ].isFile ())
110+ {
111+ areFiles = true ;
112+ }
113+ }
114+
115+ //if files are selected too, the parent folder is the root of the group naming
116+ if (areFiles )
117+ {
118+ sourceFolder = gui .sourceFileListComponent .getSelectedFiles ()[0 ].getParentFile ().getParent ();
119+ }
120+ else
121+ {
122+ sourceFolder = gui .sourceFileListComponent .getSelectedFiles ()[0 ].getParent ();
123+ }
124+
105125 boolean isGroupNameInConfig = false ;
106126 String lastGroupName = "" ;
107127
@@ -531,7 +551,7 @@ else if (aspectRatio.toLowerCase().equals("variable"))
531551 }
532552 }
533553
534- //check if this is the last file in the group
554+ //if this is the last file in the group
535555 if (i + 1 == gui .sourceFiles .length )
536556 {
537557 isLastInGroup = true ;
@@ -551,21 +571,22 @@ else if (aspectRatio.toLowerCase().equals("variable"))
551571 }
552572 }
553573
554- // here we need some group naming check
574+ // group naming check
555575 String currentPath = gui .sourceFiles [i ].getAbsolutePath ();
556576 currentPath = currentPath .substring (2 , currentPath .lastIndexOf ("." ));
557577
558578 File currFile = new File (gui .sourceFiles [i ].getAbsolutePath ());
559579
560580 if (isNewGroup )
561581 {
562- //if group name wasn't in config, we generate it based on folder structure
582+ //if group name wasn't in config, generate it based on folder structure
563583 if (!isGroupNameInConfig )
564584 {
565- String fullStr = groupName + "." + currFile .getParent ();
566- String srcStr = sourceFolder + File .separator ;
567- groupName = fullStr .replace (srcStr , "" );
568- groupName = groupName .replace (File .separator , "." );
585+ String fullStr = currFile .getParent ().toLowerCase ();
586+ String currName = fullStr .replace (sourceFolder .toLowerCase (), "" );
587+ currName = currName .replace (File .separator , "." );
588+
589+ groupName = stencilUserMarker + currName ;
569590 }
570591
571592 lastGroupName = groupName ;
@@ -576,7 +597,7 @@ else if (aspectRatio.toLowerCase().equals("variable"))
576597 }
577598 else
578599 {
579- // if not a new group then we just add the xml to the group xml
600+ // if not a new group, just add the xml to the group xml
580601 groupXml += Svg2Xml .printDocumentString (destDoc , groupBaos );
581602 }
582603
0 commit comments