Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*/
public class OpenProjectListSettings {

private static OpenProjectListSettings INSTANCE = new OpenProjectListSettings();
private static final OpenProjectListSettings INSTANCE = new OpenProjectListSettings();

private static final String RECENT_PROJECTS_DISPLAY_NAMES = "RecentProjectsDisplayNames"; //NOI18N
private static final String RECENT_PROJECTS_DISPLAY_ICONS = "RecentProjectsIcons"; //NOI18N
Expand Down Expand Up @@ -310,8 +310,11 @@ public File getProjectsFolder(boolean create) {
if (result == null || !(new File(result)).exists()) {
// property for overriding default projects dir location
String userPrjDir = System.getProperty("netbeans.projects.dir"); // NOI18N
if (userPrjDir != null) {
if (userPrjDir != null && !userPrjDir.isBlank()) {
File f = new File(userPrjDir);
if (create && !f.exists()) {
f.mkdirs();
}
if (f.exists() && f.isDirectory()) {
return FileUtil.normalizeFile(f);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.netbeans.api.actions.Openable;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectUtils;
import static org.netbeans.modules.project.ui.Bundle.*;
import org.netbeans.modules.project.ui.groups.Group;
import org.netbeans.spi.project.AuxiliaryConfiguration;
import org.netbeans.spi.project.ui.support.ProjectConvertors;
Expand All @@ -60,6 +59,7 @@
import org.openide.util.Exceptions;
import org.openide.util.Mutex;
import org.openide.util.NbBundle.Messages;
import org.openide.util.Utilities;
import org.openide.windows.Mode;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
Expand All @@ -68,6 +68,8 @@
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

import static org.netbeans.modules.project.ui.Bundle.*;

/** The util methods for projectui module.
*
* @author Jiri Rechtacek
Expand Down Expand Up @@ -601,6 +603,12 @@ private static List<String> getOpenFilesUrls(Project p, String groupName) {
}
return new ArrayList<>(set);
}

// called from layer.xml on Favorites tab open
public static URL getProjectsFolder() throws MalformedURLException {
File projectsFolder = OpenProjectListSettings.getInstance().getProjectsFolder(true);
return Utilities.toURI(projectsFolder).toURL();
}

// interface for handling project's documents stored in project private.xml
// it serves for a unit test of OpenProjectList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@
</folder>
</folder>

<folder name="Favorites">
<file name="NetBeansProjects.shadow">
Copy link
Member Author

@mbien mbien Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: i couldn't figure out how to put the display name of "NetBeansProjects" into the bundle. It did change the name within the layer tree, but didn't change within the Favorites tab. I believe "Home" is also not localized unless I overlooked something.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lines -

changed to

String name = super.getDisplayName();

should do this. Pros and cons, although matching the value of

would be desirable for platform apps.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we would have to check if renaming nodes still works, because favorites renames the virtual top level nodes instead of the files. Not sure what will happen when it uses the display name.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, worth making sure. As it changes the name of the shadow (symlink) then hopefully. Forgot to check when playing with this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked and it would rename the virtual file without the display name.

the current Home node registration is:

<folder name="Favorites">
<attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.favorites.Bundle"/>
<file name="Home.shadow">
<attr name="originalFile" methodvalue="org.netbeans.modules.favorites.FavoritesNode.getHome"/>
<attr name="originalFileSystem" stringvalue="org.netbeans.modules.masterfs.MasterFileSystem"/>
<attr name="position" intvalue="100"/>
</file>
</folder>

renaming Home using NB 27 works, but if we would render the display name (e.g HOME42), it would no longer make the update visible and it will keep showing HOME42.

Changing the impl might be a bit too risky for the scope of this PR - who knows what relied on this. I suppose platform applications could remove the item via their layer somehow?

<attr name="originalFile" methodvalue="org.netbeans.modules.project.ui.ProjectUtilities.getProjectsFolder"/>
<attr name="originalFileSystem" stringvalue="org.netbeans.modules.masterfs.MasterFileSystem"/>
<attr name="position" intvalue="110"/>
</file>
</folder>

<folder name="QuickSearch">
<folder name="Projects">
<attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.project.ui.quicksearch.Bundle"/>
Expand Down
Loading