# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: E:\sources\netbeans.org\trunk\projects\projectui # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: manifest.mf *** E:\sources\netbeans.org\trunk\projects\projectui\manifest.mf Base (1.6) --- E:\sources\netbeans.org\trunk\projects\projectui\manifest.mf Locally Modified (Based On 1.6) *************** *** 4,7 **** --- 4,8 ---- OpenIDE-Module-Layer: org/netbeans/modules/project/ui/resources/layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/project/ui/Bundle.properties OpenIDE-Module-Provides: org.netbeans.modules.project.uiapi.ActionsFactory, org.netbeans.modules.project.uiapi.OpenProjectsTrampoline, org.netbeans.modules.project.uiapi.ProjectChooserFactory + OpenIDE-Module-Friends: org.netbeans.modules.startpage, com.sun.tools.swdev.sunstudio Index: src/org/netbeans/modules/project/ui/api/RecentProjects.java *** E:\sources\netbeans.org\trunk\projects\projectui\src\org\netbeans\modules\project\ui\api\RecentProjects.java No Base Revision --- E:\sources\netbeans.org\trunk\projects\projectui\src\org\netbeans\modules\project\ui\api\RecentProjects.java Locally New *************** *** 1,0 **** --- 1,59 ---- + /* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.netbeans.modules.project.ui.api; + + import java.beans.PropertyChangeListener; + import java.util.List; + + import org.netbeans.modules.project.ui.OpenProjectList; + + /** + * Provides simple information about recent projects + * @author Milan Kubec + */ + public final class RecentProjects { + + /** + * Property representing recent projects + */ + public static final String PROP_RECENT_PROJECTS = OpenProjectList.PROPERTY_RECENT_PROJECTS; + + /** + * Gets simple info (@link ProjectInformationLite) about recent projects in IDE. + * Project in the list might not exist or might not be valid e.g. in case when + * project was deleted or changed. It's responsibility of the user of the API + * to make sure the project exists and is valid. + * @return list of project information about recently opened projects + */ + public static List/**/ getRecentProjectsInformation() { + return OpenProjectList.getDefault().getRecentProjectsInformation(); + } + + /** + * Adds a listener, use WeakListener or properly remove listeners + * @param listener listener to be added + */ + public static void addPropertyChangeListener(PropertyChangeListener listener) { + OpenProjectList.getDefault().addPropertyChangeListener(listener); + } + + /** + * Removes a listener + * @param listener listener to be removed + */ + public static void removePropertyChangeListener(PropertyChangeListener listener) { + OpenProjectList.getDefault().removePropertyChangeListener(listener); + } + + } Index: nbproject/project.xml *** E:\sources\netbeans.org\trunk\projects\projectui\nbproject\project.xml Base (1.23) --- E:\sources\netbeans.org\trunk\projects\projectui\nbproject\project.xml Locally Modified (Based On 1.23) *************** *** 194,200 **** ! --- 194,204 ---- ! ! com.sun.tools.swdev.sunstudio ! org.netbeans.modules.startpage ! org.netbeans.modules.project.ui.api ! Index: arch.xml *** E:\sources\netbeans.org\trunk\projects\projectui\arch.xml Base (1.10) --- E:\sources\netbeans.org\trunk\projects\projectui\arch.xml Locally Modified (Based On 1.10) *************** *** 16,24 **** ]> &api-questions; --- 16,24 ---- ]> &api-questions; *************** *** 41,47 **** -->

! No exported API; just GUI.

--- 41,47 ---- -->

! Module provides general implementation of projects UI and exports client friend API only.

*************** *** 63,68 **** --- 63,69 ----

Unit tests would be appropriate for some code areas; currently few exist. IDE-wide functional tests cover most of the module’s functionality. + Basic API functionality is covered by unit tests.

*************** *** 89,94 **** --- 90,103 ---- + + + + + + +

N/A *************** *** 358,364 **** Do you deploy just module JAR file(s) or other files as well? ! If your module consists of just one module JAR file, just confirm that. If it uses more than one JAR, describe where they are located, how they refer to each other. If it consist of module JAR(s) and other files, please describe --- 406,418 ---- Do you deploy just module JAR file(s) or other files as well? ! Usually a module consist of one JAR file (perhaps with Class-Path ! extensions) and also a configuration file that enables it. If you ! have any other files, use ! <api group="java.io.File" name="yourname" type="export" category="friend">...</api> ! to define the location, name and stability of your files (of course ! changing "yourname" and "friend" to suit your needs). ! If it uses more than one JAR, describe where they are located, how they refer to each other. If it consist of module JAR(s) and other files, please describe *************** *** 401,407 **** NetBeans module system allows restriction of access rights to public classes of your module from other modules. This prevents unwanted dependencies of others on your code and should be used ! whenever possible ( public packages ). If you do not restrict access to your classes you are making it too easy for other people to misuse your implementation --- 455,461 ---- NetBeans module system allows restriction of access rights to public classes of your module from other modules. This prevents unwanted dependencies of others on your code and should be used ! whenever possible ( public packages ). If you do not restrict access to your classes you are making it too easy for other people to misuse your implementation *************** *** 411,422 **** -->

! No public packages.

--- 465,476 ---- --> +

! There is package org.netbeans.modules.project.ui.api which is public and exposed ! as friend API.

+
*************** *** 437,442 **** --- 494,519 ---- + +

+ No Ant tasks. +

+
+ + + + --- 741,764 ---- *************** *** 794,800 **** --- 888,902 ---- *************** *** 981,987 **** --> -

    Actions for the Projects tab root context menu are taken from --- 1083,1088 ---- *************** *** 989,995 **** to place entries below sep-below-main-actions.instance.

    -
--- 1090,1095 ---- Index: src/org/netbeans/modules/project/ui/OpenProjectList.java *** E:\sources\netbeans.org\trunk\projects\projectui\src\org\netbeans\modules\project\ui\OpenProjectList.java Base (1.50) --- E:\sources\netbeans.org\trunk\projects\projectui\src\org\netbeans\modules\project\ui\OpenProjectList.java Locally Modified (Based On 1.50) *************** *** 16,21 **** --- 16,22 ---- import java.awt.Dimension; import java.awt.Frame; import java.awt.Rectangle; + import java.awt.image.BufferedImage; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.io.File; *************** *** 36,41 **** --- 37,44 ---- import java.util.Map; import java.util.Set; import java.util.StringTokenizer; + import javax.swing.Icon; + import javax.swing.ImageIcon; import javax.swing.JDialog; import javax.swing.SwingUtilities; import org.netbeans.api.progress.ProgressHandle; *************** *** 43,48 **** --- 46,52 ---- import org.netbeans.api.project.Project; import org.netbeans.api.project.ProjectManager; import org.netbeans.api.project.ProjectUtils; + import org.netbeans.modules.project.ui.api.ProjectInformationLite; import org.netbeans.modules.project.uiapi.ProjectOpenedTrampoline; import org.netbeans.spi.project.SubprojectProvider; import org.netbeans.spi.project.ui.PrivilegedTemplates; *************** *** 420,425 **** --- 424,433 ---- return recentProjects.isEmpty(); } + public synchronized List/**/ getRecentProjectsInformation() { + return recentProjects.getRecentProjectsInfo(); + } + /** As this class is singletnon, which is not GCed it is good idea to *add WeakListeners or remove the listeners properly. */ *************** *** 735,741 **** */ private static class RecentProjectList { ! private List /**/ recentProjects; private int size; --- 743,750 ---- */ private static class RecentProjectList { ! private List/**/ recentProjects; ! private List/**/ recentProjectsInfos; private int size; *************** *** 745,750 **** --- 754,760 ---- public RecentProjectList( int size ) { this.size = size; recentProjects = new ArrayList( size ); + recentProjectsInfos = new ArrayList(size); if (ERR.isLoggable(ErrorManager.INFORMATIONAL)) { ERR.log("created a RecentProjectList: size=" + size); } *************** *** 761,769 **** --- 771,788 ---- if ( recentProjects.size() == size ) { // Need some space for the newly added project recentProjects.remove( size - 1 ); + recentProjectsInfos.remove(size - 1); } recentProjects.add( 0, new ProjectReference( p ) ); + try { + recentProjectsInfos.add(0, new RecentProjectInfo( + ProjectUtils.getInformation(p).getDisplayName(), + p.getProjectDirectory().getURL(), + ProjectUtils.getInformation(p).getIcon())); + } catch(FileStateInvalidException ex) { + ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); } + } else { if (ERR.isLoggable(ErrorManager.INFORMATIONAL)) { ERR.log("re-add recent project: " + p); *************** *** 771,778 **** --- 790,806 ---- // Project is in list => just move it to first place recentProjects.remove( index ); recentProjects.add( 0, new ProjectReference( p ) ); + recentProjectsInfos.remove(index); + try { + recentProjectsInfos.add(0, new RecentProjectInfo( + ProjectUtils.getInformation(p).getDisplayName(), + p.getProjectDirectory().getURL(), + ProjectUtils.getInformation(p).getIcon())); + } catch(FileStateInvalidException ex) { + ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); } } + } public boolean remove( Project p ) { int index = getIndex( p ); *************** *** 781,786 **** --- 809,815 ---- ERR.log("remove recent project: " + p); } recentProjects.remove( index ); + recentProjectsInfos.remove(index); return true; } return false; *************** *** 821,826 **** --- 850,857 ---- public void load() { List/**/ URLs = OpenProjectListSettings.getInstance().getRecentProjectsURLs(); + List/**/ names = OpenProjectListSettings.getInstance().getRecentProjectsDisplayNames(); + List/**/ icons = OpenProjectListSettings.getInstance().getRecentProjectsIcons(); if (ERR.isLoggable(ErrorManager.INFORMATIONAL)) { ERR.log("recent project list load: " + URLs); } *************** *** 828,834 **** --- 859,873 ---- for ( Iterator it = URLs.iterator(); it.hasNext(); ) { recentProjects.add( new ProjectReference( (URL)it.next() ) ); } + recentProjectsInfos.clear(); + for (Iterator iterNames = names.iterator(), iterURLs = URLs.iterator(), iterIcons = icons.iterator(); + (iterNames.hasNext() && iterURLs.hasNext() && iterIcons.hasNext()); ) { + String name = (String) iterNames.next(); + URL url = (URL) iterURLs.next(); + Icon icon = ((ExtIcon) iterIcons.next()).getIcon(); + recentProjectsInfos.add(new RecentProjectInfo(name, url, icon)); } + } public void save() { List /**/ URLs = new ArrayList( recentProjects.size() ); *************** *** 843,849 **** --- 882,900 ---- ERR.log("recent project list save: " + URLs); } OpenProjectListSettings.getInstance().setRecentProjectsURLs( URLs ); + int listSize = recentProjectsInfos.size(); + List/**/ names = new ArrayList(listSize); + List/**/ icons = new ArrayList(listSize); + for (Iterator it = recentProjectsInfos.iterator(); it.hasNext(); ) { + ProjectInformationLite prjInfo = (ProjectInformationLite) it.next(); + names.add(prjInfo.getDisplayName()); + ExtIcon extIcon = new ExtIcon(); + extIcon.setIcon(prjInfo.getIcon()); + icons.add(extIcon); } + OpenProjectListSettings.getInstance().setRecentProjectsDisplayNames(names); + OpenProjectListSettings.getInstance().setRecentProjectsIcons(icons); + } private int getIndex( Project p ) { *************** *** 870,875 **** --- 921,956 ---- return -1; } + private List/**/ getRecentProjectsInfo() { + return recentProjectsInfos; + } + + private static class RecentProjectInfo implements ProjectInformationLite { + + private String displayName; + private URL prjURL; + private Icon icon; + + public RecentProjectInfo(String nm, URL url, Icon icn) { + displayName = nm; + prjURL = url; + icon = icn; + } + + public Icon getIcon() { + return icon; + } + + public String getDisplayName() { + return displayName; + } + + public URL getURL() { + return prjURL; + } + + } + private static class ProjectReference { private WeakReference projectReference; Index: src/org/netbeans/modules/project/ui/OpenProjectListSettings.java *** E:\sources\netbeans.org\trunk\projects\projectui\src\org\netbeans\modules\project\ui\OpenProjectListSettings.java Base (1.16) --- E:\sources\netbeans.org\trunk\projects\projectui\src\org\netbeans\modules\project\ui\OpenProjectListSettings.java Locally Modified (Based On 1.16) *************** *** 34,39 **** --- 34,41 ---- private static final String OPEN_AS_MAIN = "OpenAsMain"; //NOI18N private static final String MAIN_PROJECT_URL = "MainProjectURL"; //NOI18N private static final String RECENT_PROJECTS_URLS = "RecentProjectsURLs"; //NOI18N + private static final String RECENT_PROJECTS_DISPLAY_NAMES = "RecentProjectsDisplayNames"; //NOI18N + private static final String RECENT_PROJECTS_DISPLAY_ICONS = "RecentProjectsIcons"; //NOI18N private static final String PROP_PROJECTS_FOLDER = "projectsFolder"; //NOI18N private static final String RECENT_TEMPLATES = "recentlyUsedTemplates"; // NOI18N private static final String PROP_PROJECT_CATEGORY = "lastSelectedProjectCategory"; //NOI18N *************** *** 103,112 **** --- 105,132 ---- return list == null ? new ArrayList( 5 ) : list; } + public List/**/ getRecentProjectsDisplayNames() { + List list = (List) getProperty(RECENT_PROJECTS_DISPLAY_NAMES); + return list == null ? new ArrayList(5) : list; + } + + public List/**/ getRecentProjectsIcons() { + List list = (List) getProperty(RECENT_PROJECTS_DISPLAY_ICONS); + return list == null ? new ArrayList(5) : list; + } + public void setRecentProjectsURLs( List/**/ list ) { putProperty( RECENT_PROJECTS_URLS, list, true ); } + public void setRecentProjectsDisplayNames(List/**/ list) { + putProperty(RECENT_PROJECTS_DISPLAY_NAMES, list, true); + } + + public void setRecentProjectsIcons(List/**/ list) { + putProperty(RECENT_PROJECTS_DISPLAY_ICONS, list, true); + } + public File getProjectsFolder () { String result = (String) this.getProperty (PROP_PROJECTS_FOLDER); if (result == null) { Index: src/org/netbeans/modules/project/ui/ExtIcon.java *** E:\sources\netbeans.org\trunk\projects\projectui\src\org\netbeans\modules\project\ui\ExtIcon.java No Base Revision --- E:\sources\netbeans.org\trunk\projects\projectui\src\org\netbeans\modules\project\ui\ExtIcon.java Locally New *************** *** 1,0 **** --- 1,88 ---- + /* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.netbeans.modules.project.ui; + + import java.awt.Image; + import java.awt.Toolkit; + import java.awt.image.BufferedImage; + import java.awt.image.ColorModel; + import java.awt.image.ImageObserver; + import java.awt.image.MemoryImageSource; + import java.awt.image.PixelGrabber; + + import java.io.Externalizable; + import java.io.IOException; + import java.io.ObjectInput; + import java.io.ObjectOutput; + + import javax.swing.Icon; + import javax.swing.ImageIcon; + import javax.swing.JPanel; + + /** + * Class for persisting icons + * @author Milan Kubec + */ + public class ExtIcon implements Externalizable { + + private static final long serialVersionUID = -8800765296866762961L; + + private Image image; + private int width; + private int height; + + public ExtIcon() { + } + + public void setIcon(Icon icn) { + width = icn.getIconWidth(); + height = icn.getIconHeight(); + image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + icn.paintIcon(new JPanel(), image.getGraphics(), 0, 0); + } + + public Icon getIcon() { + return new ImageIcon(image); + } + + public void writeExternal(ObjectOutput out) throws IOException { + int[] pixels = new int[width * height]; + if (image != null) { + try { + PixelGrabber pg = new PixelGrabber(image, 0, 0, width, height, pixels, 0, width); + pg.grabPixels(); + if ((pg.getStatus() & ImageObserver.ABORT) != 0) { + throw new IOException("Cannot load image data"); + } + } catch (InterruptedException e) { + throw new IOException("Loading image interrupted"); + } + } + out.writeInt(width); + out.writeInt(height); + out.writeObject(pixels); + } + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + width = in.readInt(); + height = in.readInt(); + int[] pixels = (int[]) (in.readObject()); + if (pixels != null) { + Toolkit toolkit = Toolkit.getDefaultToolkit(); + ColorModel cm = ColorModel.getRGBdefault(); + image = toolkit.createImage(new MemoryImageSource(width, height, cm, pixels, 0, width)); + } + } + + } Index: src/org/netbeans/modules/project/ui/api/ProjectInformationLite.java *** E:\sources\netbeans.org\trunk\projects\projectui\src\org\netbeans\modules\project\ui\api\ProjectInformationLite.java No Base Revision --- E:\sources\netbeans.org\trunk\projects\projectui\src\org\netbeans\modules\project\ui\api\ProjectInformationLite.java Locally New *************** *** 1,0 **** --- 1,46 ---- + /* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.netbeans.modules.project.ui.api; + + import java.net.URL; + import javax.swing.Icon; + + /** + * Lite version of information about project. + * @author Milan Kubec + */ + public interface ProjectInformationLite { + + /** + * Gets a human-readable display name for the project. + * May contain spaces, international characters, etc. + * @return a display name for the project + */ + String getDisplayName(); + + /** + * Gets icon for given project. + * Usually determined by the project type. + * @return icon of the project. + */ + Icon getIcon(); + + /** + * Gets URL of the project folder location + * Use {@link ProjectManager#findProject} to get the project + * @return url of the project folder + */ + URL getURL(); + + }