This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
We need an API for retrieving recent projects. The same functionality, currently implemented in projects/projectui OpenProjectsList#getRecentProjects which is not exposed via API. We show the list of recent projects in our welcome screen impl.
Could be a friend API from projectui or projectuiapi, but I would not want to expose such a thing as a general public API; it is part of the UI implementation, and the welcome screen is merely trying to extend the UI implementation (without having to supply a complete impl on its own).
*** Issue 58462 has been marked as a duplicate of this issue. ***
Not for 5.0, I think.
From a discussion with Honza L. there can be two ways: - Misuse ProjectInformation class to provide list of recent project infos where probably not all methods will be implemented. Friend API will be provided from org.netbeans.modules.project.ui.api package - RecentProjects class with static method getRecentProjectInfos. - Or provide special class just providing necessary info: displayName, project, maybe icon. That class would be only for the friend API.
Signatures of the new friend API: package org.netbeans.modules.project.ui.api; public final class RecentProjects { public static List/*<ProjectInformationLite>*/ getRecentProjectsInformation(); } public interface ProjectInformationLite { String getDisplayName(); Icon getIcon(); URL getURL(); }
What does the URL point to? And how whould I opne of the projects in the list? Why not provide a list of Project's?
The url points to project folder location. Getting the project from url: FileObject dir = URLMapper.findFileObject(url); Project p = ProjectManager.getDefault().findProject(dir); I think that the API should be as lightweight as possible and creating Project objects can be done by the user of the API. Exposing current API is not good idea because it actually instantiates all those projects in the list and that's not what should be done during IDE startup.
Sounds good.
Please provide code name base of the module that will use this API. Thanks.
the current codename base for the welcome screen is org.netbeans.modules.startpage (subject to change in the future - api reviews etc) please note that i also need some kind of change listener to be notified when the list of recent projects is modified (new entries added/removed)
com.sun.tools.swdev.sunstudio.welcome. Is this what you are asking for? Perhaps I don't know how 'Friend' APIs work. If you code the above package into the code (that's what you do, right?), would I be able to use the API from a sub package under welcome i.e. com.sun.tools.swdev.sunstudio.welcome.xyz?
I think that's it. Code name base is the string after "OpenIDE-Module:" in the manifest file of nb module (without the part after slash, including the slash if there is some). Yes the API will be visible in any your subpackage. Friend API is only nb term and cannot be forced somehow. Only if your develop modules using apisupport in nb IDE the friend API won't be accessible for modules that are not explicitly mentioned.
OK, the module name in where this friend api will be used is: com.sun.tools.swdev.sunstudio/2 That's what you want, correct? And I don;t quite understand your last comment. Do I need to do anything special in my module in order to use this friend API?
Yes that's it. No nothing special, you just need to declare dependency on module Project UI.
Created attachment 29209 [details] patch
I've attached proposed implementation. apichanges.xml document is missing, I don't know if it's required for initial API implementation. Tests are not included either, they will be delivered before final commit.
Created attachment 29246 [details] Test class
Should I consider this issue as reviewed and proceed with commit?
I like that we are exposing just simplified set of information here because it can be really expensing to compute full info about projects. Perhaps we can commit generified version of this API directly to use type collections. The only question: do we really want to store raw icon data? cannot we internally store only URL of icon resource (if we cannot read from such URL that is likely kind of nbres:... it probably means we will not be able to load the project too)? It can be usefull to discuss this with Radek M. how it will work with planned migration to preferences.
Well, I do not like storing icon data either, but I do not see any other option: the only thing that the projectui gets is an Icon instance. It is usually created like this: new ImageIcon(Utilities.loadImage("org/netbeans/modules/java/j2seproject/ui/resources/j2seProject.gif")) (but this is an implementation detail). I do not know about any way to map this Icon to URL. BTW: What about making the ProjectInformationLite a final class?
Do not specify OpenIDE-Module-Friends in manifest.mf. This is added during the build acc. to information in project.xml. You have to put at least the getRecentProjectsInformation() method (which should BTW be named getRecentProjectInformation()) in the new friend package, or no one will be able to use it. Didn't you try actually building one of the friend modules to use the patch, such as startpage? Best to commit at least one friend client together with the new API, to ensure that it is actually usable. Test cases do not need to give a suite() method in typical cases. ProjectInformationLite should be marked @since x.y, and manifest.mf should increment its spec version to x.y. You can use svuid=1L (or whatever) for newly written serializable classes. You do not need to generate some number. I might suggest a different interface name than ProjectInformationLite. It's not very descriptive and "lite" should be reserved for beer, it's not a real word. Perhaps "UnloadedProjectInformation". By the way, you could consider just using the normal ProjectInformation as the interface, reducing the size of the API. Makes things a little easier for clients - they can just call getProject as usual. (Could return null if not loadable.) Like the current ProjectReference, it could keep a WeakReference to a Project in case it exists, in which case it would delegate to the live Project. I.e. something like public TransientProjectInformation(Project p) { project = new WeakReference(p); name = getName(); // project.get() != null, so uses p displayName = getDisplayName(); icon = getIcon(); url = p.getProjectDirectory().getURL(); } private URL url; private String name, displayName; private ExtIcon icon; private transient WeakReference<Project> project; public Project getProject() { Project p = project.get(); if (p == null) { try { FileObject d = URLMapper.toFileObject(url); if (d != null) { p = ProjectManager.getDefault().findProject(d); if (p != null) { project = new WeakReference(p); } } } catch (IOException e) {e.pst();} } return p; } public String getName() { Project p = project.get(); if (p != null) { return ProjectUtils.getInformation(p).getName(); } else { return name; } } // ... similar for displayName, icon // PropertyChangeSupport - delegate to live project if available, fire general change also if project field set
Fixed. Changes from proposed implementation are: - interface ProjectInformtationLite changed to final class UnloadedProjectInformation - Methods in RecentProjects are not static but the class provides getDefault() method Most of Jesse's comments are fixed. Checking in projects/projectui/nbproject/project.xml; /cvs/projects/projectui/nbproject/project.xml,v <-- project.xml new revision: 1.24; previous revision: 1.23 done Checking in projects/projectui/nbproject/project.properties; /cvs/projects/projectui/nbproject/project.properties,v <-- project.properties new revision: 1.11; previous revision: 1.10 done RCS file: /cvs/projects/projectui/test/unit/src/org/netbeans/modules/project/ui/api/testimage.png,v done Checking in projects/projectui/test/unit/src/org/netbeans/modules/project/ui/api/testimage.png; /cvs/projects/projectui/test/unit/src/org/netbeans/modules/project/ui/api/testimage.png,v <-- testimage.png initial revision: 1.1 done RCS file: /cvs/projects/projectui/test/unit/src/org/netbeans/modules/project/ui/api/RecentProjectsTest.java,v done Checking in projects/projectui/test/unit/src/org/netbeans/modules/project/ui/api/RecentProjectsTest.java; /cvs/projects/projectui/test/unit/src/org/netbeans/modules/project/ui/api/RecentProjectsTest.java,v <-- RecentProjectsTest.java initial revision: 1.1 done RCS file: /cvs/projects/projectui/src/org/netbeans/modules/project/ui/api/RecentProjects.java,v done Checking in projects/projectui/src/org/netbeans/modules/project/ui/api/RecentProjects.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/api/RecentProjects.java,v <-- RecentProjects.java initial revision: 1.1 done RCS file: /cvs/projects/projectui/src/org/netbeans/modules/project/ui/api/ProjectInfoAccessorImpl.java,v done Checking in projects/projectui/src/org/netbeans/modules/project/ui/api/ProjectInfoAccessorImpl.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/api/ProjectInfoAccessorImpl.java,v <-- ProjectInfoAccessorImpl.java initial revision: 1.1 done RCS file: /cvs/projects/projectui/src/org/netbeans/modules/project/ui/api/UnloadedProjectInformation.java,v done Checking in projects/projectui/src/org/netbeans/modules/project/ui/api/UnloadedProjectInformation.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/api/UnloadedProjectInformation.java,v <-- UnloadedProjectInformation.java initial revision: 1.1 done Checking in projects/projectui/src/org/netbeans/modules/project/ui/OpenProjectListSettings.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/OpenProjectListSettings.java,v <-- OpenProjectListSettings.java new revision: 1.17; previous revision: 1.16 done RCS file: /cvs/projects/projectui/src/org/netbeans/modules/project/ui/ProjectInfoAccessor.java,v done Checking in projects/projectui/src/org/netbeans/modules/project/ui/ProjectInfoAccessor.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/ProjectInfoAccessor.java,v <-- ProjectInfoAccessor.java initial revision: 1.1 done Checking in projects/projectui/src/org/netbeans/modules/project/ui/OpenProjectList.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/OpenProjectList.java,v <-- OpenProjectList.java new revision: 1.51; previous revision: 1.50 done RCS file: /cvs/projects/projectui/src/org/netbeans/modules/project/ui/ExtIcon.java,v done Checking in projects/projectui/src/org/netbeans/modules/project/ui/ExtIcon.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/ExtIcon.java,v <-- ExtIcon.java initial revision: 1.1 done RCS file: /cvs/projects/projectui/apichanges.xml,v done Checking in projects/projectui/apichanges.xml; /cvs/projects/projectui/apichanges.xml,v <-- apichanges.xml initial revision: 1.1 done Checking in projects/projectui/arch.xml; /cvs/projects/projectui/arch.xml,v <-- arch.xml new revision: 1.11; previous revision: 1.10 done Checking in ide/golden/friend-packages.txt; /cvs/ide/golden/friend-packages.txt,v <-- friend-packages.txt new revision: 1.16; previous revision: 1.15 done
Could you please also add com.sun.rave.project.jsf to the friend list? Creator needs these APIs for its welcome page too. Thanks!
Wait a minute. Which Creator release are you talking about? As of now, mkubec's change is available in NB trunk only. By the time Creator can effectively make use of this change, it should be based on a common binary (and thus reuse the NB welcome page), the respective source can be possibly repackaged, etc. Please clarify why you think the package needs to be declared as a friend now.
When Creator 'pack' is used as an extension of NetBeans, then yes, Creator will reuse the welcome page of NetBeans. But when Creator as a 'product', it will have its own welcome page.
Perhaps it will, but still... it makes little sense to make this change in the trunk codeline now. There is no plan to backport it into release55 branch.
Is the set of friend packages valid for release55_mars branch? com.sun.tools.swdev.sunstudio org.netbeans.modules.startpage
Created attachment 35328 [details] diff against release55_mars branch
I've attached diff for release55_mars branch. Note that spec. version is increased to 1.9.1.1 on that branch, because the API was introduced in version 1.9.0. Trunk version will be increased to 1.10.0.
I can only speak for SunStudio, com.sun.tools.swdev.sunstudio package is correct.
For Creator, we need com.sun.rave.project.jsf in the friend package.
Just a question, is Creator going to be based on release55_mars branch?
Integrated to release55_mars. Checking in src/org/netbeans/modules/project/ui/api/UnloadedProjectInformation.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/api/UnloadedProjectInformation.java,v <-- UnloadedProjectInformation.java new revision: 1.2.6.1; previous revision: 1.2 done Checking in src/org/netbeans/modules/project/ui/api/ProjectInfoAccessorImpl.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/api/ProjectInfoAccessorImpl.java,v <-- ProjectInfoAccessorImpl.java new revision: 1.2.6.1; previous revision: 1.2 done Checking in src/org/netbeans/modules/project/ui/api/RecentProjects.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/api/RecentProjects.java,v <-- RecentProjects.java new revision: 1.2.6.1; previous revision: 1.2 done Checking in src/org/netbeans/modules/project/ui/OpenProjectListSettings.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/OpenProjectListSettings.java,v <-- OpenProjectListSettings.java new revision: 1.16.34.1.18.1; previous revision: 1.16.34.1 done Checking in src/org/netbeans/modules/project/ui/ExtIcon.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/ExtIcon.java,v <-- ExtIcon.java new revision: 1.2.6.1; previous revision: 1.2 done Checking in src/org/netbeans/modules/project/ui/OpenProjectList.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/OpenProjectList.java,v <-- OpenProjectList.java new revision: 1.35.6.2.2.3.10.1; previous revision: 1.35.6.2.2.3 done Checking in src/org/netbeans/modules/project/ui/ProjectInfoAccessor.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/ProjectInfoAccessor.java,v <-- ProjectInfoAccessor.java new revision: 1.2.6.1; previous revision: 1.2 done Checking in nbproject/project.xml; /cvs/projects/projectui/nbproject/project.xml,v <-- project.xml new revision: 1.20.8.1.2.1.18.1; previous revision: 1.20.8.1.2.1 done Checking in nbproject/project.properties; /cvs/projects/projectui/nbproject/project.properties,v <-- project.properties new revision: 1.7.8.1.2.4.2.1; previous revision: 1.7.8.1.2.4 done
> Just a question, is Creator going to be based on release55_mars branch? No, Creator has no plan to run on the release55_mars branch. However, we need to make sure it is friend package in the main trunk.
Integrated to release551 branch. Checking in src/org/netbeans/modules/project/ui/OpenProjectList.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/OpenProjectList.java,v <-- OpenProjectList.java new revision: 1.35.6.2.2.3.14.1; previous revision: 1.35.6.2.2.3 done Checking in src/org/netbeans/modules/project/ui/ExtIcon.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/ExtIcon.java,v <-- ExtIcon.java new revision: 1.3.2.1; previous revision: 1.3 done Checking in src/org/netbeans/modules/project/ui/ProjectInfoAccessor.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/ProjectInfoAccessor.java,v <-- ProjectInfoAccessor.java new revision: 1.2.10.1; previous revision: 1.2 done Checking in src/org/netbeans/modules/project/ui/OpenProjectListSettings.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/OpenProjectListSettings.java,v <-- OpenProjectListSettings.java new revision: 1.16.34.1.22.1; previous revision: 1.16.34.1 done Checking in src/org/netbeans/modules/project/ui/api/RecentProjects.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/api/RecentProjects.java,v <-- RecentProjects.java new revision: 1.2.10.1; previous revision: 1.2 done Checking in src/org/netbeans/modules/project/ui/api/UnloadedProjectInformation.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/api/UnloadedProjectInformation.java,v <-- UnloadedProjectInformation.java new revision: 1.2.10.1; previous revision: 1.2 done Checking in src/org/netbeans/modules/project/ui/api/ProjectInfoAccessorImpl.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/api/ProjectInfoAccessorImpl.java,v <-- ProjectInfoAccessorImpl.java new revision: 1.2.10.1; previous revision: 1.2 done Checking in nbproject/project.properties; /cvs/projects/projectui/nbproject/project.properties,v <-- project.properties new revision: 1.7.8.1.2.4.6.1; previous revision: 1.7.8.1.2.4 done Checking in nbproject/project.xml; /cvs/projects/projectui/nbproject/project.xml,v <-- project.xml new revision: 1.20.8.1.2.1.22.1; previous revision: 1.20.8.1.2.1 done
Milan you forgot to merge the patch to ide/golden/friend-packages.txt to release551 (and I guess release55mars as well), resulting in a build failure: http://deadlock.nbextras.org/hudson/job/release551/1813/
Done. Thanks for catching. release55_mars is OK. Sorry for that. Checking in friend-packages.txt; /cvs/ide/golden/friend-packages.txt,v <-- friend-packages.txt new revision: 1.15.4.1.2.134.6.5; previous revision: 1.15.4.1.2.134.6.4 done