# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: E:\sources\netbeans.org\release55_mars\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: src/org/netbeans/modules/project/ui/api/UnloadedProjectInformation.java *** E:\sources\netbeans.org\release55_mars\projects\projectui\src\org\netbeans\modules\project\ui\api\UnloadedProjectInformation.java No Base Revision --- E:\sources\netbeans.org\release55_mars\projects\projectui\src\org\netbeans\modules\project\ui\api\UnloadedProjectInformation.java Locally New *************** *** 1,0 **** --- 1,78 ---- + /* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software 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; + + import org.netbeans.modules.project.ui.ProjectInfoAccessor; + + /** + * Lite version of information about project. + * @author Milan Kubec + * @since 1.9.0 + */ + public final class UnloadedProjectInformation { + + private String displayName; + private Icon icon; + private URL url; + + static { + ProjectInfoAccessor.DEFAULT = new ProjectInfoAccessorImpl(); + } + + /** + * Creates a new instance of UnloadedProjectInformation + */ + UnloadedProjectInformation(String displayName, Icon icon, URL url) { + this.displayName = displayName; + this.icon = icon; + this.url = url; + } + + /** + * Gets a human-readable display name for the project. + * May contain spaces, international characters, etc. + * @return a display name for the project + */ + public String getDisplayName() { + return displayName; + } + + /** + * Gets icon for given project. + * Usually determined by the project type. + * @return icon of the project. + */ + public Icon getIcon() { + return icon; + } + + /** + * Gets URL of the project folder location + * Use {@link ProjectManager#findProject} to get the project + * @return url of the project folder + */ + public URL getURL() { + return url; + } + + } Index: src/org/netbeans/modules/project/ui/OpenProjectListSettings.java *** E:\sources\netbeans.org\release55_mars\projects\projectui\src\org\netbeans\modules\project\ui\OpenProjectListSettings.java Base (1.16.34.1) --- E:\sources\netbeans.org\release55_mars\projects\projectui\src\org\netbeans\modules\project\ui\OpenProjectListSettings.java Locally Modified (Based On 1.16.34.1) *************** *** 40,45 **** --- 40,47 ---- 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 *************** *** 109,118 **** --- 111,138 ---- 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\release55_mars\projects\projectui\src\org\netbeans\modules\project\ui\ExtIcon.java No Base Revision --- E:\sources\netbeans.org\release55_mars\projects\projectui\src\org\netbeans\modules\project\ui\ExtIcon.java Locally New *************** *** 1,0 **** --- 1,94 ---- + /* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software 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: nbproject/project.xml *** E:\sources\netbeans.org\release55_mars\projects\projectui\nbproject\project.xml Base (1.20.8.1.2.1) --- E:\sources\netbeans.org\release55_mars\projects\projectui\nbproject\project.xml Locally Modified (Based On 1.20.8.1.2.1) *************** *** 204,210 **** ! --- 204,214 ---- ! ! com.sun.tools.swdev.sunstudio ! org.netbeans.modules.startpage ! org.netbeans.modules.project.ui.api ! Index: src/org/netbeans/modules/project/ui/api/ProjectInfoAccessorImpl.java *** E:\sources\netbeans.org\release55_mars\projects\projectui\src\org\netbeans\modules\project\ui\api\ProjectInfoAccessorImpl.java No Base Revision --- E:\sources\netbeans.org\release55_mars\projects\projectui\src\org\netbeans\modules\project\ui\api\ProjectInfoAccessorImpl.java Locally New *************** *** 1,0 **** --- 1,37 ---- + /* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software 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; + + import org.netbeans.modules.project.ui.ProjectInfoAccessor; + + /** + * Helper class to create instances of class with package private constructor + * @author Milan Kubec + */ + final class ProjectInfoAccessorImpl extends ProjectInfoAccessor { + + public UnloadedProjectInformation getProjectInfo(String name, Icon icon, URL url) { + return new UnloadedProjectInformation(name, icon, url); + } + + } Index: src/org/netbeans/modules/project/ui/OpenProjectList.java *** E:\sources\netbeans.org\release55_mars\projects\projectui\src\org\netbeans\modules\project\ui\OpenProjectList.java Base (1.35.6.2.2.3) --- E:\sources\netbeans.org\release55_mars\projects\projectui\src\org\netbeans\modules\project\ui\OpenProjectList.java Locally Modified (Based On 1.35.6.2.2.3) *************** *** 42,47 **** --- 42,48 ---- import java.util.Map; import java.util.Set; import java.util.StringTokenizer; + import javax.swing.Icon; import javax.swing.JDialog; import javax.swing.SwingUtilities; import org.netbeans.api.progress.ProgressHandle; *************** *** 49,54 **** --- 50,56 ---- 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.UnloadedProjectInformation; import org.netbeans.modules.project.uiapi.ProjectOpenedTrampoline; import org.netbeans.spi.project.SubprojectProvider; import org.netbeans.spi.project.ui.PrivilegedTemplates; *************** *** 429,434 **** --- 431,440 ---- 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. */ *************** *** 744,750 **** */ private static class RecentProjectList { ! private List /**/ recentProjects; private int size; --- 750,757 ---- */ private static class RecentProjectList { ! private List/**/ recentProjects; ! private List/**/ recentProjectsInfos; private int size; *************** *** 754,759 **** --- 761,767 ---- 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); } *************** *** 770,778 **** --- 778,795 ---- 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, ProjectInfoAccessor.DEFAULT.getProjectInfo( + ProjectUtils.getInformation(p).getDisplayName(), + ProjectUtils.getInformation(p).getIcon(), + p.getProjectDirectory().getURL())); + } catch(FileStateInvalidException ex) { + ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); } + } else { if (ERR.isLoggable(ErrorManager.INFORMATIONAL)) { ERR.log("re-add recent project: " + p); *************** *** 780,787 **** --- 797,813 ---- // 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, ProjectInfoAccessor.DEFAULT.getProjectInfo( + ProjectUtils.getInformation(p).getDisplayName(), + ProjectUtils.getInformation(p).getIcon(), + p.getProjectDirectory().getURL())); + } catch(FileStateInvalidException ex) { + ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); } } + } public boolean remove( Project p ) { int index = getIndex( p ); *************** *** 790,795 **** --- 816,822 ---- ERR.log("remove recent project: " + p); } recentProjects.remove( index ); + recentProjectsInfos.remove(index); return true; } return false; *************** *** 830,835 **** --- 857,864 ---- 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); } *************** *** 837,843 **** --- 866,880 ---- 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(ProjectInfoAccessor.DEFAULT.getProjectInfo(name, icon, url)); } + } public void save() { List /**/ URLs = new ArrayList( recentProjects.size() ); *************** *** 852,858 **** --- 889,907 ---- 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(); ) { + UnloadedProjectInformation prjInfo = (UnloadedProjectInformation) 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 ) { *************** *** 879,884 **** --- 928,937 ---- return -1; } + private List/**/ getRecentProjectsInfo() { + return recentProjectsInfos; + } + private static class ProjectReference { private WeakReference projectReference; Index: src/org/netbeans/modules/project/ui/ProjectInfoAccessor.java *** E:\sources\netbeans.org\release55_mars\projects\projectui\src\org\netbeans\modules\project\ui\ProjectInfoAccessor.java No Base Revision --- E:\sources\netbeans.org\release55_mars\projects\projectui\src\org\netbeans\modules\project\ui\ProjectInfoAccessor.java Locally New *************** *** 1,0 **** --- 1,47 ---- + /* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.netbeans.modules.project.ui; + + import java.net.URL; + import javax.swing.Icon; + + import org.netbeans.modules.project.ui.api.UnloadedProjectInformation; + + /** + * Accessor for UnloadedProjectInformation class + * @author Milan Kubec + */ + public abstract class ProjectInfoAccessor { + + public static ProjectInfoAccessor DEFAULT; + + static { + Class c = UnloadedProjectInformation.class; + try { + Class.forName(c.getName(), true, c.getClassLoader()); + } catch (ClassNotFoundException cnfe) { + assert false : cnfe; + } + assert DEFAULT != null; + } + + public abstract UnloadedProjectInformation getProjectInfo(String dn, Icon ic, URL ur); + + } Index: nbproject/project.properties *** E:\sources\netbeans.org\release55_mars\projects\projectui\nbproject\project.properties Base (1.7.8.1.2.4) --- E:\sources\netbeans.org\release55_mars\projects\projectui\nbproject\project.properties Locally Modified (Based On 1.7.8.1.2.4) *************** *** 15,21 **** # Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun # Microsystems, Inc. All Rights Reserved. ! spec.version.base=1.7.22 javadoc.arch=${basedir}/arch.xml --- 15,21 ---- # Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun # Microsystems, Inc. All Rights Reserved. ! spec.version.base=1.9.1.1 javadoc.arch=${basedir}/arch.xml Index: src/org/netbeans/modules/project/ui/api/RecentProjects.java *** E:\sources\netbeans.org\release55_mars\projects\projectui\src\org\netbeans\modules\project\ui\api\RecentProjects.java No Base Revision --- E:\sources\netbeans.org\release55_mars\projects\projectui\src\org\netbeans\modules\project\ui\api\RecentProjects.java Locally New *************** *** 1,0 **** --- 1,97 ---- + /* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.netbeans.modules.project.ui.api; + + import java.beans.PropertyChangeEvent; + import java.beans.PropertyChangeListener; + import java.beans.PropertyChangeSupport; + + import java.util.List; + + import org.netbeans.modules.project.ui.OpenProjectList; + + /** + * Provides simple information about recent projects and fires PropertyChangeEvent + * in case of change in the list of recent projects + * @author Milan Kubec + * @since 1.9.0 + */ + public final class RecentProjects { + + /** + * Property representing recent project information + */ + public static final String PROP_RECENT_PROJECT_INFO = "RecentProjectInformation"; // NOI18N + + private static RecentProjects INSTANCE; + + private PropertyChangeSupport pch; + + public static RecentProjects getDefault() { + if (INSTANCE == null) { + return new RecentProjects(); + } else { + return INSTANCE; + } + } + + /** + * Creates a new instance of RecentProjects + */ + private RecentProjects() { + pch = new PropertyChangeSupport(this); + OpenProjectList.getDefault().addPropertyChangeListener(new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getPropertyName().equals(OpenProjectList.PROPERTY_RECENT_PROJECTS)) { + pch.firePropertyChange(new PropertyChangeEvent(RecentProjects.class, + PROP_RECENT_PROJECT_INFO, null, null)); + } + } + }); + } + + /** + * Gets simple info (@link UnloadedProjectInformation) 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 List/**/ getRecentProjectInformation() { + return OpenProjectList.getDefault().getRecentProjectsInformation(); + } + + /** + * Adds a listener, use WeakListener or properly remove listeners + * @param listener listener to be added + */ + public void addPropertyChangeListener(PropertyChangeListener listener) { + pch.addPropertyChangeListener(listener); + } + + /** + * Removes a listener + * @param listener listener to be removed + */ + public void removePropertyChangeListener(PropertyChangeListener listener) { + pch.removePropertyChangeListener(listener); + } + + }