Bug 57073 - API for retrieving recent projects is needed
API for retrieving recent projects is needed
Status: RESOLVED FIXED
Product: projects
Classification: Unclassified
Component: Generic Projects UI
4.x
All All
: P2 (vote)
: 6.x
Assigned To: Milan Kubec
issues@projects
OSLO, BIN_COMP SSBACKPORT SSX3 INMARS
: API, API_REVIEW_FAST
: 58462 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-03-28 21:31 UTC by Peter Zavadsky
Modified: 2006-11-21 08:50 UTC (History)
6 users (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments
patch (30.71 KB, patch)
2006-03-10 14:21 UTC, Milan Kubec
Details | Diff
Test class (10.07 KB, text/plain)
2006-03-15 12:23 UTC, Milan Kubec
Details
diff against release55_mars branch (25.65 KB, patch)
2006-10-18 15:13 UTC, Milan Kubec
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Zavadsky 2005-03-28 21:31:06 UTC
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.
Comment 1 Jesse Glick 2005-03-29 16:28:09 UTC
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).
Comment 2 Jan Lahoda 2005-11-08 13:38:17 UTC
*** Issue 58462 has been marked as a duplicate of this issue. ***
Comment 3 Jan Lahoda 2005-11-08 13:38:42 UTC
Not for 5.0, I think.
Comment 4 Milan Kubec 2006-02-28 14:21:26 UTC
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.
Comment 5 Milan Kubec 2006-03-08 15:23:50 UTC
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();
}
Comment 6 Thomas Preisler 2006-03-08 15:40:59 UTC
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?
Comment 7 Milan Kubec 2006-03-08 15:57:18 UTC
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.
Comment 8 Thomas Preisler 2006-03-08 16:54:35 UTC
Sounds good.
Comment 9 Milan Kubec 2006-03-09 14:32:43 UTC
Please provide code name base of the module that will use this API. Thanks.
Comment 10 Stanislav Aubrecht 2006-03-09 14:46:17 UTC
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)
Comment 11 Thomas Preisler 2006-03-09 16:46:27 UTC
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?
Comment 12 Milan Kubec 2006-03-09 22:08:36 UTC
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.

Comment 13 Thomas Preisler 2006-03-09 22:20:31 UTC
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?
Comment 14 Milan Kubec 2006-03-09 22:53:52 UTC
Yes that's it.

No nothing special, you just need to declare dependency on module Project UI.
Comment 15 Milan Kubec 2006-03-10 14:21:18 UTC
Created attachment 29209 [details]
patch
Comment 16 Milan Kubec 2006-03-10 14:28:39 UTC
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.
Comment 17 Milan Kubec 2006-03-15 12:23:19 UTC
Created attachment 29246 [details]
Test class
Comment 18 Milan Kubec 2006-03-17 07:53:45 UTC
Should I consider this issue as reviewed and proceed with commit?
Comment 19 _ rkubacki 2006-03-17 08:21:27 UTC
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.
Comment 20 Jan Lahoda 2006-03-17 09:47:20 UTC
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?
Comment 21 Jesse Glick 2006-03-17 11:17:06 UTC
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
Comment 22 Milan Kubec 2006-03-20 12:31:26 UTC
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
Comment 23 _ potingwu 2006-05-23 18:56:47 UTC
Could you please also add com.sun.rave.project.jsf to the friend list? Creator
needs these APIs for its welcome page too. Thanks!
Comment 24 Jan Chalupa 2006-05-23 20:06:47 UTC
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.
Comment 25 _ potingwu 2006-05-23 20:15:39 UTC
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.
Comment 26 Jan Chalupa 2006-05-23 20:22:46 UTC
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.
Comment 27 Milan Kubec 2006-10-18 12:15:28 UTC
Is the set of friend packages valid for release55_mars branch?
com.sun.tools.swdev.sunstudio
org.netbeans.modules.startpage
Comment 28 Milan Kubec 2006-10-18 15:13:54 UTC
Created attachment 35328 [details]
diff against release55_mars branch
Comment 29 Milan Kubec 2006-10-18 15:15:51 UTC
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.
Comment 30 Thomas Preisler 2006-10-18 18:09:53 UTC
I can only speak for SunStudio, com.sun.tools.swdev.sunstudio package is correct.
Comment 31 _ potingwu 2006-10-18 18:21:02 UTC
For Creator, we need com.sun.rave.project.jsf in the friend package.
Comment 32 Milan Kubec 2006-10-19 12:10:17 UTC
Just a question, is Creator going to be based on release55_mars branch?
Comment 33 Milan Kubec 2006-10-20 14:40:46 UTC
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
Comment 34 _ potingwu 2006-10-20 18:16:35 UTC
> 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.
Comment 35 Milan Kubec 2006-11-20 11:39:42 UTC
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
Comment 36 Jesse Glick 2006-11-21 00:55:52 UTC
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/
Comment 37 Milan Kubec 2006-11-21 08:50:17 UTC
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


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo