Skip to content

Commit c014158

Browse files
committed
Add NetBeansProjects dir to Favorites tab
- projects dir is now registered as favorite - fixed bug: when a custom project dir location is specified by setting 'netbeans.projects.dir', the dir is now automatically created, instead of falling back to the default dir, which gave the impression that the property isn't working
1 parent beddaf0 commit c014158

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

ide/projectui/src/org/netbeans/modules/project/ui/OpenProjectListSettings.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*/
3939
public class OpenProjectListSettings {
4040

41-
private static OpenProjectListSettings INSTANCE = new OpenProjectListSettings();
41+
private static final OpenProjectListSettings INSTANCE = new OpenProjectListSettings();
4242

4343
private static final String RECENT_PROJECTS_DISPLAY_NAMES = "RecentProjectsDisplayNames"; //NOI18N
4444
private static final String RECENT_PROJECTS_DISPLAY_ICONS = "RecentProjectsIcons"; //NOI18N
@@ -310,8 +310,11 @@ public File getProjectsFolder(boolean create) {
310310
if (result == null || !(new File(result)).exists()) {
311311
// property for overriding default projects dir location
312312
String userPrjDir = System.getProperty("netbeans.projects.dir"); // NOI18N
313-
if (userPrjDir != null) {
313+
if (userPrjDir != null && !userPrjDir.isBlank()) {
314314
File f = new File(userPrjDir);
315+
if (create && !f.exists()) {
316+
f.mkdirs();
317+
}
315318
if (f.exists() && f.isDirectory()) {
316319
return FileUtil.normalizeFile(f);
317320
}

ide/projectui/src/org/netbeans/modules/project/ui/ProjectUtilities.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import org.netbeans.api.actions.Openable;
4545
import org.netbeans.api.project.Project;
4646
import org.netbeans.api.project.ProjectUtils;
47-
import static org.netbeans.modules.project.ui.Bundle.*;
4847
import org.netbeans.modules.project.ui.groups.Group;
4948
import org.netbeans.spi.project.AuxiliaryConfiguration;
5049
import org.netbeans.spi.project.ui.support.ProjectConvertors;
@@ -60,6 +59,7 @@
6059
import org.openide.util.Exceptions;
6160
import org.openide.util.Mutex;
6261
import org.openide.util.NbBundle.Messages;
62+
import org.openide.util.Utilities;
6363
import org.openide.windows.Mode;
6464
import org.openide.windows.TopComponent;
6565
import org.openide.windows.WindowManager;
@@ -68,6 +68,8 @@
6868
import org.w3c.dom.Element;
6969
import org.w3c.dom.NodeList;
7070

71+
import static org.netbeans.modules.project.ui.Bundle.*;
72+
7173
/** The util methods for projectui module.
7274
*
7375
* @author Jiri Rechtacek
@@ -601,6 +603,12 @@ private static List<String> getOpenFilesUrls(Project p, String groupName) {
601603
}
602604
return new ArrayList<>(set);
603605
}
606+
607+
// called from (ide.branding) layer.xml on Favorites tab open
608+
public static URL getProjectsFolder() throws MalformedURLException {
609+
File projectsFolder = OpenProjectListSettings.getInstance().getProjectsFolder(true);
610+
return Utilities.toURI(projectsFolder).toURL();
611+
}
604612

605613
// interface for handling project's documents stored in project private.xml
606614
// it serves for a unit test of OpenProjectList

nb/ide.branding/src/org/netbeans/modules/ide/branding/layer.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@
3838
<attr name="currentFontColorProfile" stringvalue="FlatLaf Light" />
3939
</folder>
4040

41+
<folder name="Favorites">
42+
<file name="NetBeansProjects.shadow">
43+
<attr name="originalFile" methodvalue="org.netbeans.modules.project.ui.ProjectUtilities.getProjectsFolder"/>
44+
<attr name="originalFileSystem" stringvalue="org.netbeans.modules.masterfs.MasterFileSystem"/>
45+
<attr name="position" intvalue="110"/>
46+
</file>
47+
</folder>
48+
4149
<folder name="Windows2">
4250
<folder name="Background">
4351
<attr name="backgroundImage" stringvalue="org/netbeans/modules/ide/branding/apache-netbeans.png" />

0 commit comments

Comments
 (0)