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/02 21:10:29 UTC

[GitHub] [netbeans] errael commented on a change in pull request #1980: [NETBEANS-2446] Use *parent* of saved projectFolder as projectLocation

errael commented on a change in pull request #1980: [NETBEANS-2446] Use *parent* of saved projectFolder as projectLocation
URL: https://github.com/apache/netbeans/pull/1980#discussion_r386651798
 
 

 ##########
 File path: java/maven/src/org/netbeans/modules/maven/newproject/BasicPanelVisual.java
 ##########
 @@ -562,7 +562,9 @@ void read(WizardDescriptor settings) {
         File projectLocation = (File) settings.getProperty(CommonProjectActions.PROJECT_PARENT_FOLDER); //NOI18N
         if (projectLocation == null || projectLocation.getParentFile() == null || !projectLocation.getParentFile().isDirectory()) {
             projectLocation = ProjectChooser.getProjectsFolder();
-        } 
+        } else {
+            projectLocation = projectLocation.getParentFile();
 
 Review comment:
   The naming caused me considerable confusion. 
   
   Note that your suggestion `d.putProperty("projdir", folder.getParentFile())` produces different and incorrect results. The String value of the property name ...PROJECT_PARENT_FOLDER is "projdir"; and in older areas of code is a literal string rather than a define. Your suggestion, save folder.getParentFile() as property value was actually my first attempt to fix this. Things got weird and changes started radiating; reverted that attempt. The property "projdir" is globally used by the wizard infrastructure and it means the base directory of the new project and not the parent directory of the newly created project directory.
   
   After a circuitous route, I decided to find the the screen for a plain old java project. It is 
   `java/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/wizards/PanelProjectLocationVisual.java`
   and it uses the same names and has similar code to its maven counterpart. (Undoubtedly the prototype for this screen)
   
   So, while it's tempting to rename things so they make sense. I am hesitant to diverge from the original code. BTW, in the code you quote from the store() method, renaming the variable `parentFolder` to `projectDirectory` would be accurate. Then when the two lines are restored it would be like saying `projectLocation = projectDirectory.getParentFile()`. It could have read like that, but the original code was probably avoiding declaring new variables. Note that in the code in read() `projectLocation = ProjectChooser.getProjectsFolder()` retrieves the default value for where to put new projects the other branch of the "if" statement is working with the value of "projdir" and does ["projdir"].getParentFile(). 

----------------------------------------------------------------
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