You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2020/03/01 05:27:20 UTC

[GitHub] [netbeans] jtulach commented on a change in pull request #1991: [NETBEANS-3918] defer creation of target folder until/if needed

jtulach commented on a change in pull request #1991: [NETBEANS-3918] defer creation of target folder until/if needed
URL: https://github.com/apache/netbeans/pull/1991#discussion_r386078392
 
 

 ##########
 File path: platform/openide.loaders/src/org/openide/loaders/TemplateWizard.java
 ##########
 @@ -244,7 +252,14 @@ public DataFolder getTemplatesFolder () {
     public DataFolder getTargetFolder () throws IOException {
         LOG.log(Level.FINE, "targetFolder={0} for {1}", new Object[] {targetDataFolder, this});
         if (targetDataFolder == null) {
-            throw new IOException(NbBundle.getMessage(TemplateWizard.class, "ERR_NoFilesystem"));
+            // Fix for [NETBEANS-3918] and [NETBEANS-3875]
+            File targetFolderFile = (File) getProperty(PROP_TARGET_FOLDER_HINT);
+            if(targetFolderFile != null) {
+                targetFolderFile.mkdirs();
+                setTargetFolder(DataFolder.findFolder(FileUtil.toFileObject(targetFolderFile)));
 
 Review comment:
   Please note that `TemplateWizard` hasn't yet been using `java.io.File`. This would be the first time and I am not happy about it as it limits the usage of `TemplateWizard` to local disk. Could you consider alternative solution? Could you introduce
   ```java
   public void setTargetFolder(Supplier<DataFolder> toBeCreatedFolder) {
   }
   ```
   e.g. give the code a chance to work with `DataFolder` and `FileObject` only, but delay creation of the actual folder as much as possible?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists