From: <va...@us...> - 2008-08-30 18:57:57
|
Revision: 13457 http://jedit.svn.sourceforge.net/jedit/?rev=13457&view=rev Author: vanza Date: 2008-08-30 18:57:52 +0000 (Sat, 30 Aug 2008) Log Message: ----------- Code cleanup. . get rid of almost all "unchecked" warnings in PV's sources. The only remaining ones are because of other APIs that PV calls (Swing, jEdit). . cleanup javadoc warnings. . do minor API changes where it makes sense. . use the "foreach" loop wherever it makes sense. Modified Paths: -------------- plugins/ProjectViewer/trunk/projectviewer/ProjectManager.java plugins/ProjectViewer/trunk/projectviewer/ProjectViewer.java plugins/ProjectViewer/trunk/projectviewer/VFSHelper.java plugins/ProjectViewer/trunk/projectviewer/action/SearchAction.java plugins/ProjectViewer/trunk/projectviewer/config/AppLauncher.java plugins/ProjectViewer/trunk/projectviewer/config/ProjectFilterPane.java plugins/ProjectViewer/trunk/projectviewer/config/ProjectViewerConfig.java plugins/ProjectViewer/trunk/projectviewer/gui/OptionPaneBase.java plugins/ProjectViewer/trunk/projectviewer/importer/CVSEntriesFilter.java plugins/ProjectViewer/trunk/projectviewer/importer/Importer.java plugins/ProjectViewer/trunk/projectviewer/importer/RootImporter.java plugins/ProjectViewer/trunk/projectviewer/persist/OldConfigLoader.java plugins/ProjectViewer/trunk/projectviewer/persist/ProjectPersistenceManager.java plugins/ProjectViewer/trunk/projectviewer/vpt/IconComposer.java plugins/ProjectViewer/trunk/projectviewer/vpt/ProjectTreePanel.java plugins/ProjectViewer/trunk/projectviewer/vpt/VPTCompactModel.java plugins/ProjectViewer/trunk/projectviewer/vpt/VPTContextMenu.java plugins/ProjectViewer/trunk/projectviewer/vpt/VPTDirectory.java plugins/ProjectViewer/trunk/projectviewer/vpt/VPTFile.java plugins/ProjectViewer/trunk/projectviewer/vpt/VPTFileListModel.java plugins/ProjectViewer/trunk/projectviewer/vpt/VPTFilteredModel.java plugins/ProjectViewer/trunk/projectviewer/vpt/VPTGroup.java plugins/ProjectViewer/trunk/projectviewer/vpt/VPTNode.java plugins/ProjectViewer/trunk/projectviewer/vpt/VPTProject.java plugins/ProjectViewer/trunk/projectviewer/vpt/VPTRoot.java plugins/ProjectViewer/trunk/projectviewer/vpt/VPTWorkingFileListModel.java Modified: plugins/ProjectViewer/trunk/projectviewer/ProjectManager.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/ProjectManager.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/ProjectManager.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -20,9 +20,7 @@ //{{{ Imports import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; +import java.util.Collections; import java.util.List; import java.util.Properties; import java.util.Stack; @@ -123,8 +121,7 @@ //{{{ -ProjectManager() : <init> private ProjectManager() { - projects = new TreeMap(); - listeners = new HashSet(); + projects = new TreeMap<String,Entry>(); // Loads the configuration try { @@ -137,10 +134,9 @@ //{{{ Instance variables - private ActionSet nodeActions; - private TreeMap projects; - private HashSet listeners; - private List globalFilterList; + private ActionSet nodeActions; + private TreeMap<String,Entry> projects; + private List<VPTFilterData> globalFilterList; //}}} @@ -230,9 +226,8 @@ synchronized (projects) { // save each project's data, if loaded // if not loaded, no need to save. - for (Iterator it = projects.keySet().iterator(); it.hasNext(); ) { - String pName = (String) it.next(); - Entry e = (Entry) projects.get(pName); + for (String pName : projects.keySet()) { + Entry e = projects.get(pName); if (e.isLoaded) { saveProject(e.project, true); } @@ -243,7 +238,7 @@ // save the filter list to a config file Properties p = new Properties(); - List filters = getGlobalFilterList(); + List<VPTFilterData> filters = getGlobalFilterList(); for (int i = 0; i < filters.size(); i++) { VPTFilterData fd = (VPTFilterData) filters.get(i); p.setProperty("filter." + i + ".glob", fd.getGlob()); @@ -331,7 +326,7 @@ //{{{ +renameProject(String, String) : void /** Updates information about a project to reflect its name change. */ public void renameProject(String oldName, String newName) { - Entry e = (Entry) projects.remove(oldName); + Entry e = projects.remove(oldName); projects.put(newName, e); if (e.fileName != null) { try { @@ -376,7 +371,7 @@ * return null. */ public VPTProject getProject(String name) { - Entry e = (Entry) projects.get(name); + Entry e = projects.get(name); if (!e.isLoaded) { synchronized (e) { if (!e.isLoaded) { @@ -405,17 +400,17 @@ return e.project; } //}}} - //{{{ +getProjects() : Iterator + //{{{ +getProjects() : List<VPTProject> /** - * Returns an iterator that points to the (ordered) list of project names - * managed by this manager. The Iterator is read-only. + * Returns a list containing the list of project names + * managed by this manager. The list is read-only. */ - public Iterator getProjects() { - ArrayList lst = new ArrayList(); - for (Iterator it = projects.values().iterator(); it.hasNext(); ) { - lst.add(((Entry)it.next()).project); + public List<VPTProject> getProjects() { + List<VPTProject> lst = new ArrayList<VPTProject>(); + for (Entry e : projects.values()) { + lst.add(e.project); } - return lst.iterator(); + return Collections.unmodifiableList(lst); } //}}} //{{{ +isLoaded(String) : boolean @@ -427,7 +422,7 @@ * @throws NullPointerException If the project does not exist. */ public boolean isLoaded(String pName) { - return ((Entry)projects.get(pName)).isLoaded; + return projects.get(pName).isLoaded; } //}}} //{{{ +hasProject(String) : boolean @@ -442,7 +437,7 @@ * state to "unloaded", freeing memory. */ public void unloadProject(VPTProject p) { - Entry e = (Entry) projects.get(p.getName()); + Entry e = projects.get(p.getName()); saveProject(e.project, true); e.project.removeAllChildren(); e.project.getProperties().clear(); @@ -457,9 +452,9 @@ * * @since PV 2.2.2.0 */ - public List getGlobalFilterList() { + public List<VPTFilterData> getGlobalFilterList() { if (globalFilterList == null) - globalFilterList = new ArrayList(); + globalFilterList = new ArrayList<VPTFilterData>(); return globalFilterList; } //}}} @@ -471,7 +466,8 @@ * * @since PV 2.2.2.0 */ - public void setGlobalFilterList(List globalFilterList) { + public void setGlobalFilterList(List<VPTFilterData> globalFilterList) + { this.globalFilterList = globalFilterList; ProjectViewer.nodeStructureChanged(ProjectViewer.getActiveNode(jEdit.getActiveView())); } //}}} @@ -569,7 +565,7 @@ if (n.isGroup()) writeGroup(GRP_ELEMENT, (VPTGroup)n, out); else if (n.isProject()) - writeProject((Entry)projects.get(n.getName()), out); + writeProject(projects.get(n.getName()), out); } out.write("</"); @@ -603,11 +599,11 @@ /** SAX handler that takes care of reading the configuration file. */ private class PVConfigHandler extends DefaultHandler { - private Stack grpStack; + private Stack<VPTGroup> grpStack; //{{{ +PVConfigHandler() : <init> public PVConfigHandler() { - grpStack = new Stack(); + grpStack = new Stack<VPTGroup>(); grpStack.push(VPTRoot.getInstance()); } //}}} Modified: plugins/ProjectViewer/trunk/projectviewer/ProjectViewer.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/ProjectViewer.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/ProjectViewer.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -395,7 +395,7 @@ //{{{ Attributes private View view; - private HashSet dontAsk; + private HashSet<String> dontAsk; private JPanel topPane; private ProjectTreePanel treePanel; @@ -581,12 +581,13 @@ //{{{ -unloadInactiveProjects(VPTNode) : void /** Checks if some of the projects that are loaded can be unloaded. */ private void unloadInactiveProjects(VPTNode newRoot) { - ArrayList active = null; + List<String> active = null; for (Iterator i = viewers.values().iterator(); i.hasNext(); ) { ViewerEntry ve = (ViewerEntry) i.next(); if (ve.node != null && ve.dockable != this) { - if (active == null) - active = new ArrayList(); + if (active == null) { + active = new ArrayList<String>(); + } if (ve.node.isProject()) { active.add(ve.node.getName()); } else if (!ve.node.isRoot()) { @@ -598,8 +599,7 @@ } ProjectManager pm = ProjectManager.getInstance(); - for (Iterator i = pm.getProjects(); i.hasNext(); ) { - VPTProject p = (VPTProject) i.next(); + for (VPTProject p : pm.getProjects()) { if (pm.isLoaded(p.getName()) && (p != newRoot) && (active == null || !active.contains(p.getName()))) { @@ -610,7 +610,7 @@ } //}}} //{{{ -addProjectsToList(VPTNode, List) : void - private void addProjectsToList(VPTNode src, List l) { + private void addProjectsToList(VPTNode src, List<String> l) { for (int i = 0; i < src.getChildCount(); i++) { VPTNode n = (VPTNode) src.getChildAt(i); if (n.isProject()) { @@ -687,7 +687,7 @@ * plugins/macros can peform actions on a selection of files. */ public List getSelectedFilePaths() { - List obfp = new ArrayList(); + List<String> obfp = new ArrayList<String>(); JTree tree = getCurrentTree(); if (tree == null) return null; @@ -979,7 +979,7 @@ } } else if (config.getAskImport() == ProjectViewerConfig.ASK_ONCE) { if (dontAsk == null) { - dontAsk = new HashSet(); + dontAsk = new HashSet<String>(); } dontAsk.add(bu.getBuffer().getPath()); } Modified: plugins/ProjectViewer/trunk/projectviewer/VFSHelper.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/VFSHelper.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/VFSHelper.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -76,7 +76,7 @@ * * @param vfs The VFS instance. * @param session The session to end. - * @param view A jEdit view. + * @param v A jEdit view. */ public static void endVFSSession(VFS vfs, Object session, View v) { Modified: plugins/ProjectViewer/trunk/projectviewer/action/SearchAction.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/action/SearchAction.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/action/SearchAction.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -24,8 +24,9 @@ import java.io.IOException; import java.io.Reader; +import java.util.Enumeration; import java.util.HashSet; -import java.util.Enumeration; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -167,9 +168,9 @@ pFilter = Pattern.compile(StandardUtilities.globToRE(filter)); } - HashSet fileset = new HashSet(); + Set<String> fileset = new HashSet<String>(); addFiles(node, fileset); - return (String[]) fileset.toArray(new String[fileset.size()]); + return fileset.toArray(new String[fileset.size()]); } //}}} @@ -178,7 +179,9 @@ * Adds all the files below the given node to the list of search files, * recursively. */ - private void addFiles(VPTNode node, HashSet fileset) { + private void addFiles(VPTNode node, + Set<String> fileset) + { Enumeration e = node.children(); if (e != null) while(e.hasMoreElements()) { Modified: plugins/ProjectViewer/trunk/projectviewer/config/AppLauncher.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/config/AppLauncher.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/config/AppLauncher.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -29,7 +29,6 @@ import java.util.Set; import java.util.TreeMap; -import java.util.Iterator; import java.util.Properties; import java.util.regex.Pattern; @@ -58,8 +57,6 @@ */ public class AppLauncher { - //{{{ Singleton method & variable - private static AppLauncher instance; static { // make sure ProjectViewerConfig is loaded before the instance is @@ -80,17 +77,14 @@ return instance; } //}}} - //}}} + private TreeMap<ComparablePattern,String> appCol; //{{{ +AppLauncher() : <init> public AppLauncher() { - appCol = new TreeMap(); + appCol = new TreeMap<ComparablePattern,String>(); } //}}} - //{{{ Private members & variables - private TreeMap appCol; - //}}} //{{{ Public methods @@ -136,8 +130,8 @@ if (inprops != null) { props.load(inprops); - for (Iterator iter = props.keySet().iterator(); iter.hasNext(); ) { - String key = (String) iter.next(); + for (Object _key : props.keySet()) { + String key = (String) _key; String value = props.getProperty(key); this.addAppExt(key, value); } @@ -153,9 +147,8 @@ ProjectPlugin.getResourceAsOutputStream("fileassocs.properties") ) ); - for (Iterator iter = appCol.keySet().iterator(); iter.hasNext(); ) { - ComparablePattern key = (ComparablePattern) iter.next(); - Object value = appCol.get(key); + for (ComparablePattern key : appCol.keySet()) { + String value = appCol.get(key); out.println(key.glob + "=" + value); } @@ -218,8 +211,7 @@ /** Copies the data from another AppLauncher into this one. */ public void copy(AppLauncher other) { appCol.clear(); - for (Iterator it = other.appCol.keySet().iterator(); it.hasNext(); ) { - Object key = it.next(); + for (ComparablePattern key : other.appCol.keySet()) { appCol.put(key, other.appCol.get(key)); } } //}}} @@ -233,8 +225,7 @@ */ public String getAppName(String path) { String name = VFSManager.getVFSForPath(path).getFileName(path); - for (Iterator i = appCol.keySet().iterator(); i.hasNext(); ) { - ComparablePattern re = (ComparablePattern) i.next(); + for (ComparablePattern re : appCol.keySet()) { if (re.matches(name)) { return (String) appCol.get(re); } Modified: plugins/ProjectViewer/trunk/projectviewer/config/ProjectFilterPane.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/config/ProjectFilterPane.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/config/ProjectFilterPane.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -238,16 +238,18 @@ /** * @param appAssoc the collection of extentions and associations */ - public FilterTabelModel(List filterList) { - if (filterList == java.util.Collections.EMPTY_LIST) { - this.filterList = new ArrayList(); + public FilterTabelModel(List<VPTFilterData> filterList) + { + List<VPTFilterData> empty = java.util.Collections.emptyList(); + if (filterList == empty) { + this.filterList = new ArrayList<VPTFilterData>(); } else { this.filterList = filterList; } } //}}} //{{{ +getFilterList() : List - public List getFilterList() { + public List<VPTFilterData> getFilterList() { return filterList; } //}}} @@ -273,7 +275,7 @@ int newIndex = rowIndex + increment; if (newIndex < filterList.size() && newIndex >= 0) { - Object moveEntry = filterList.get(rowIndex); + VPTFilterData moveEntry = filterList.get(rowIndex); filterList.remove(rowIndex); filterList.add(newIndex, moveEntry); } @@ -298,7 +300,7 @@ //{{{ +getValueAt(int, int) : Object public Object getValueAt(int r, int c) { - VPTFilterData fd = (VPTFilterData)filterList.get(r); + VPTFilterData fd = filterList.get(r); switch(c) { case 0: return fd.getGlob(); case 1: return fd.getName(); @@ -313,7 +315,7 @@ jEdit.getProperty("projectviewer.filterconfig.filter"); } //}}} - private List filterList; + private List<VPTFilterData> filterList; } //}}} Modified: plugins/ProjectViewer/trunk/projectviewer/config/ProjectViewerConfig.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/config/ProjectViewerConfig.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/config/ProjectViewerConfig.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -20,8 +20,8 @@ package projectviewer.config; //{{{ Imports -import java.util.Iterator; import java.util.ArrayList; +import java.util.List; import java.util.Properties; import java.util.Stack; import java.util.StringTokenizer; @@ -142,8 +142,8 @@ private String userContextMenu = null; private String lastInitVersion = null; - private ArrayList listeners; - private Stack lastNodes; + private List<PropertyChangeListener> listeners; + private Stack<Object> lastNodes; //}}} @@ -158,7 +158,7 @@ * @param props An object containing the configuration of the plugin. */ private ProjectViewerConfig() { - listeners = new ArrayList(); + listeners = new ArrayList<PropertyChangeListener>(); // loads the properties Properties props = new Properties(); @@ -253,7 +253,7 @@ excludeDirs = props.getProperty(EXCLUDE_DIRS_OPT); // Last path - lastNodes = new Stack(); + lastNodes = new Stack<Object>(); int cnt = 0; boolean foundPath = false; tmp = props.getProperty(LAST_NODE_OPT + "count"); @@ -262,7 +262,7 @@ foundPath = true; cnt = Integer.parseInt(tmp); for (int i = 0; i < cnt; i++) { - Stack path = new Stack(); + Stack<String> path = new Stack<String>(); int j = 0; do { tmp = props.getProperty(LAST_NODE_OPT + i + "." + j); @@ -277,7 +277,7 @@ } } else { // old style single node path - Stack lastPath = new Stack(); + Stack<String> lastPath = new Stack<String>(); while (props.getProperty(LAST_NODE_OPT + cnt) != null) { lastPath.push(props.getProperty(LAST_NODE_OPT + cnt)); cnt++; @@ -675,13 +675,13 @@ // last path int ncnt = 0; - for (Iterator i = lastNodes.iterator(); i.hasNext(); ) { + for (Object node : lastNodes) { int pcnt = 0; - Object node = i.next(); if (node instanceof Stack) { - for (Iterator j = ((Stack)node).iterator(); j.hasNext(); ) { + Stack nodePaths = (Stack) node; + for (Object path : nodePaths) { props.setProperty(LAST_NODE_OPT + ncnt + "." + pcnt, - (String) j.next()); + path.toString()); pcnt++; } } else { @@ -749,8 +749,8 @@ !oldValue.equals(newValue)) && listeners.size() > 0) { PropertyChangeEvent evt = new PropertyChangeEvent(this,property,oldValue,newValue); - for (Iterator i = listeners.iterator(); i.hasNext(); ) { - ((PropertyChangeListener)i.next()).propertyChange(evt); + for (PropertyChangeListener lsnr : listeners) { + lsnr.propertyChange(evt); } } } @@ -812,8 +812,8 @@ * @since PV 2.1.0 */ private void updateLists(Properties importProps) { - for (Iterator i = importProps.keySet().iterator(); i.hasNext(); ) { - String key = (String) i.next(); + for (Object _key : importProps.keySet()) { + String key = (String) _key; if (key.startsWith(EXCLUDE_DIRS_OPT + "-")) { if (needUpdate(key.substring(EXCLUDE_DIRS_OPT.length() + 1))) { excludeDirs = mergeList(excludeDirs, importProps.getProperty(key)); @@ -888,8 +888,8 @@ p.load(inprops); Properties newp = new Properties(); - for (Iterator i = p.keySet().iterator(); i.hasNext(); ) { - String key = (String) i.next(); + for (Object _key : p.keySet()) { + String key = (String) _key; newp.put("*." + key, p.get(key)); } p = newp; Modified: plugins/ProjectViewer/trunk/projectviewer/gui/OptionPaneBase.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/gui/OptionPaneBase.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/gui/OptionPaneBase.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -89,8 +89,8 @@ /** * Shortcut for adding a checkbox with an optional tooltip. * - * @param[in] label Property name for the label / tooltip. - * @param[in] selected Whether the checkbox is checked. + * @param label Property name for the label / tooltip. + * @param selected Whether the checkbox is checked. * * @return The checkbox (already added to the UI). */ Modified: plugins/ProjectViewer/trunk/projectviewer/importer/CVSEntriesFilter.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/importer/CVSEntriesFilter.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/importer/CVSEntriesFilter.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -28,7 +28,9 @@ import java.io.FileNotFoundException; import java.util.HashMap; +import java.util.Map; import java.util.HashSet; +import java.util.Set; import org.xml.sax.Attributes; import org.xml.sax.InputSource; @@ -71,7 +73,7 @@ public class CVSEntriesFilter extends ImporterFileFilter { //{{{ Private members - private HashMap entries = new HashMap(); + private Map<String,Set<String>> entries = new HashMap<String,Set<String>>(); //}}} //{{{ +getDescription() : String @@ -100,15 +102,17 @@ * Returns the set of files from the CVS/Entries file for the given path. * In case the file has not yet been read, parse it. */ - private HashSet getEntries(VFS vfs, String dirPath) { - HashSet h = (HashSet) entries.get(dirPath); + private Set<String> getEntries(VFS vfs, + String dirPath) + { + Set<String> h = entries.get(dirPath); if (h == null) { BufferedReader br = null; Object session; String fPath; View view; - h = new HashSet(); + h = new HashSet<String>(); view = jEdit.getActiveView(); fPath = vfs.constructPath(dirPath, "CVS"); @@ -147,7 +151,7 @@ return h; } //}}} - //{{{ -getSubversionEntries(HashSet, String) : void + //{{{ -getSubversionEntries(Set, String) : void /** * Searches in subversion directories for 1.3 or 1.4 format ".svn/entries" * files, parses them and returns the list of filenames in a target set. @@ -157,7 +161,7 @@ * @param dirPath the location to search for subversion entries. */ private void getSubversionEntries(VFS vfs, - HashSet target, + Set<String> target, String dirPath) { boolean isXml = true; @@ -249,13 +253,13 @@ */ private static class SubversionEntriesHandler extends DefaultHandler { - private HashSet target; + private Set<String> target; private boolean addEntry; private String path; - //{{{ +SubversionEntriesHandler(HashSet) : <init> - public SubversionEntriesHandler(HashSet target) { + //{{{ +SubversionEntriesHandler(Set) : <init> + public SubversionEntriesHandler(Set<String> target) { this.target = target; this.addEntry = false; this.path = null; Modified: plugins/ProjectViewer/trunk/projectviewer/importer/Importer.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/importer/Importer.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/importer/Importer.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -23,10 +23,8 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Collection; import java.util.Enumeration; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Stack; @@ -91,9 +89,9 @@ private Map<VPTNode,VPTNode> addedNodes; /** The list of added files, if any, for event firing purposes. */ - protected ArrayList added; + protected List<VPTFile> added; /** The list of removed files, if any, for event firing purposes. */ - protected ArrayList removed; + protected List<VPTFile> removed; /** Whether this class should automatically fire the project event. */ protected boolean fireEvent = true; @@ -265,7 +263,7 @@ * @param path Path to insert (should be under the given root). * * @return The newly created node. - * @throw IOException If an I/O error occur. + * @throws IOException If an I/O error occur. * * @since PV 3.0.0 */ @@ -356,7 +354,9 @@ protected void registerFile(VPTFile file) { project.registerNodePath(file); if (!contains(removed, file)) { - if (added == null) added = new ArrayList(); + if (added == null) { + added = new ArrayList<VPTFile>(); + } added.add(file); } } //}}} @@ -371,20 +371,24 @@ protected void unregisterFile(VPTFile file) { project.unregisterNodePath(file); if (!contains(added, file)) { - if (removed == null) removed = new ArrayList(); + if (removed == null) { + removed = new ArrayList<VPTFile>(); + } removed.add(file); } } //}}} - //{{{ -contains(ArrayList, VPTFile) : boolean + /** * Checks whether the given list contains the given file or not. If the * file is found, it is removed from the list. */ - private boolean contains(ArrayList list, VPTFile file) { + private boolean contains(List<VPTFile> list, + VPTFile file) + { if (list != null) for (int i = 0; i < list.size(); i++) { - if (((VPTNode)list.get(i)).compareToNode(file) == 0) { + if (list.get(i).compareTo(file) == 0) { list.remove(i); return true; } Modified: plugins/ProjectViewer/trunk/projectviewer/importer/RootImporter.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/importer/RootImporter.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/importer/RootImporter.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -21,9 +21,9 @@ //{{{ Imports import java.io.IOException; -import java.util.Iterator; import java.util.ArrayList; import java.util.Enumeration; +import java.util.List; import java.awt.Component; @@ -112,8 +112,8 @@ oldRoot = project.getRootPath(); } Enumeration e = project.children(); - ArrayList toRemove = new ArrayList(); - removed = new ArrayList(); + List<VPTNode> toRemove = new ArrayList<VPTNode>(); + removed = new ArrayList<VPTFile>(); while (e.hasMoreElements()) { VPTNode n = (VPTNode) e.nextElement(); // need to handle "virtual directories", which mess up the @@ -126,8 +126,7 @@ } } if (toRemove.size() > 0) { - for (Iterator i = toRemove.iterator(); i.hasNext(); ) { - VPTNode n = (VPTNode) i.next(); + for (VPTNode n : toRemove) { if (n.isDirectory()) { unregisterFiles((VPTDirectory)n); } else if (n.isFile()) { Modified: plugins/ProjectViewer/trunk/projectviewer/persist/OldConfigLoader.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/persist/OldConfigLoader.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/persist/OldConfigLoader.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -26,7 +26,7 @@ import java.util.Stack; import java.util.HashMap; -import java.util.Iterator; +import java.util.Map; import java.util.Properties; import org.gjt.sp.util.Log; @@ -124,7 +124,7 @@ if (props == null) return; - HashMap paths = new HashMap(); + Map<String,VPTNode> paths = new HashMap<String,VPTNode>(); // ensures that the path does not have a trailing '/' @@ -139,8 +139,8 @@ p.setProperty("projectviewer.folder_tree_state", (String) props.get("folderTreeState")); } - for (Iterator it = props.keySet().iterator(); it.hasNext(); ) { - String key = (String) it.next(); + for (Object _key : props.keySet()) { + String key = (String) _key; if (key.startsWith("file")) { File f = new File(props.getProperty(key)); VPTNode parent = ensureDirAdded(p, f.getParent(), paths); @@ -168,7 +168,7 @@ String suffix = ".project." + idx; String fileName = props.getProperty(prefix + counter + suffix); - HashMap paths = new HashMap(); + Map<String,VPTNode> paths = new HashMap<String,VPTNode>(); while (fileName != null) { File f = new File(fileName); @@ -192,7 +192,10 @@ * @param dirs A HashMap containing the already added dirs (key = path). * @return The VPTNode representing the given directory. */ - private static VPTNode ensureDirAdded(VPTProject p, String path, HashMap dirs) { + private static VPTNode ensureDirAdded(VPTProject p, + String path, + Map<String,VPTNode> dirs) + { if (path.equals(p.getRootPath())) { return p; } @@ -200,7 +203,7 @@ return (VPTNode) dirs.get(path); } - Stack toAdd = new Stack(); + Stack<VPTNode> toAdd = new Stack<VPTNode>(); VPTNode dir = new VPTDirectory(path); dirs.put(path, dir); toAdd.push(dir); Modified: plugins/ProjectViewer/trunk/projectviewer/persist/ProjectPersistenceManager.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/persist/ProjectPersistenceManager.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/persist/ProjectPersistenceManager.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -181,14 +181,14 @@ private VPTProject proj; private VPTNode currNode; - private Stack openNodes; + private Stack<String> openNodes; //}}} //{{{ +ProjectHandler(VPTProject) : <init> public ProjectHandler(VPTProject proj) { this.proj = proj; this.currNode = proj; - this.openNodes = new Stack(); + this.openNodes = new Stack<String>(); } //}}} //{{{ +startElement(String) : void Modified: plugins/ProjectViewer/trunk/projectviewer/vpt/IconComposer.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/vpt/IconComposer.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/vpt/IconComposer.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -20,6 +20,7 @@ //{{{ Imports import java.util.HashMap; +import java.util.Map; import java.awt.Graphics; import java.awt.Image; @@ -69,7 +70,8 @@ //}}} //{{{ Attributes - private final static HashMap iconCache = new HashMap(); + private final static Map<Icon,Icon[][][][]> iconCache = + new HashMap<Icon,Icon[][][][]>(); private final static Icon FILE_STATE_CHANGED_IMG = new ImageIcon(IconComposer.class.getResource("/projectviewer/images/file_state_changed.png")); Modified: plugins/ProjectViewer/trunk/projectviewer/vpt/ProjectTreePanel.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/vpt/ProjectTreePanel.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/vpt/ProjectTreePanel.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -101,7 +101,7 @@ super(new BorderLayout()); this.viewer = viewer; - trees = new ArrayList(); + trees = new ArrayList<PVTree>(); contextMenu = new VPTContextMenu(viewer); selectionListener = new VPTSelectionListener(viewer); @@ -600,7 +600,7 @@ //{{{ class _FileListTransferable_ /** A transferable for a file. */ private static class FileListTransferable - extends LinkedList + extends LinkedList<File> implements Transferable { Modified: plugins/ProjectViewer/trunk/projectviewer/vpt/VPTCompactModel.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/vpt/VPTCompactModel.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/vpt/VPTCompactModel.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -54,7 +54,8 @@ //{{{ Private members private static final String SEPARATOR = "/"; - private Map cache = new HashMap(); + private Map<VPTNode,List<VPTNode>> cache = + new HashMap<VPTNode,List<VPTNode>>(); //}}} //{{{ +VPTCompactModel(VPTNode) : <init> @@ -131,18 +132,23 @@ } //}}} //{{{ #getCompressedDirectories(VPTProject) : List - protected List getCompressedDirectories(VPTProject node) { - if (cache.get(node)!=null) - return (List)cache.get(node); + protected List<VPTNode> getCompressedDirectories(VPTProject node) + { + if (cache.containsKey(node)) { + return cache.get(node); + } Log.log(Log.DEBUG, this, "not cached: "+node); - List list=new ArrayList(); + List<VPTNode> list = new ArrayList<VPTNode>(); getCompressedDirectories(new StringBuffer(), node, list); cache.put(node, list); return list; } //}}} //{{{ #getCompressedDirectories(StringBuffer, VPTNode, List) : void - protected void getCompressedDirectories(StringBuffer leading, VPTNode node, List appendTo) { + protected void getCompressedDirectories(StringBuffer leading, + VPTNode node, + List<VPTNode> appendTo) + { int oldLenght = leading.length(); if (node.isDirectory() && hasFile(node)) { leading.append(node.getName()); @@ -175,8 +181,9 @@ } //}}} //{{{ #getProjectChildren(VPTProject) : List - protected List getProjectChildren(VPTProject project) { - List cd = getCompressedDirectories(project); + protected List<VPTNode> getProjectChildren(VPTProject project) + { + List<VPTNode> cd = getCompressedDirectories(project); for (int i = 0; i < project.getChildCount(); i++) { VPTNode child = (VPTNode) project.getChildAt(i); if (child.isFile()) { @@ -197,7 +204,7 @@ private VPTNode dir; private String name; - private List files = new ArrayList(); + private List<VPTNode> files = new ArrayList<VPTNode>(); //{{{ +CompactDirectoryNode(VPTNode, String) : <init> public CompactDirectoryNode(VPTNode dir, String name) { Modified: plugins/ProjectViewer/trunk/projectviewer/vpt/VPTContextMenu.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/vpt/VPTContextMenu.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/vpt/VPTContextMenu.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -158,7 +158,7 @@ */ public void userMenuChanged() { - updateExtensions(new ArrayList(extActions)); + updateExtensions(new ArrayList<Object>(extActions)); } /** Modified: plugins/ProjectViewer/trunk/projectviewer/vpt/VPTDirectory.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/vpt/VPTDirectory.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/vpt/VPTDirectory.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -131,13 +131,14 @@ } /** Directories have precedende over openable nodes... */ - public int compareToNode(VPTNode node) { + public int compareTo(VPTNode node) + { if (node.canOpen()) { return -1; } else if (node.isDirectory()) { return compareName(node); } else { - return -1 * node.compareToNode(this); + return -1 * node.compareTo(this); } } Modified: plugins/ProjectViewer/trunk/projectviewer/vpt/VPTFile.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/vpt/VPTFile.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/vpt/VPTFile.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -267,7 +267,7 @@ /** Files are at the same level of every leaf node. */ - public int compareToNode(VPTNode node) + public int compareTo(VPTNode node) { if (!node.getAllowsChildren()) { return compareName(node); Modified: plugins/ProjectViewer/trunk/projectviewer/vpt/VPTFileListModel.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/vpt/VPTFileListModel.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/vpt/VPTFileListModel.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.Collections; import java.util.WeakHashMap; @@ -49,11 +50,11 @@ public class VPTFileListModel extends ProjectTreeModel { //{{{ Private members - private WeakHashMap fileLists; + private Map<VPTProject,List<VPTNode>> fileLists; private Object lastParent; - private ArrayList lastList; - private List pathBuilder; + private List<VPTNode> lastList; + private List<TreeNode> pathBuilder; //}}} //{{{ +VPTFileListModel(VPTNode) : <init> @@ -64,8 +65,8 @@ */ public VPTFileListModel(VPTNode rootNode) { super(rootNode); - fileLists = new WeakHashMap(); - pathBuilder = new LinkedList(); + fileLists = new WeakHashMap<VPTProject,List<VPTNode>>(); + pathBuilder = new LinkedList<TreeNode>(); } //}}} //{{{ +getChildCount(Object) : int @@ -100,7 +101,7 @@ if (node.isGroup()) { return node.getChildAt(index); } else if (node.isProject()) { - ArrayList lst = getProjectFileList((VPTProject) node); + List<VPTNode> lst = getProjectFileList((VPTProject) node); if (index >= lst.size()) return null; return lst.get(index); } @@ -117,7 +118,7 @@ VPTNode n = (VPTNode) node; if (!n.isGroup()) { VPTProject p = VPTNode.findProjectFor(n); - ArrayList lst = new ArrayList(p.openableNodes.values()); + List<VPTNode> lst = new ArrayList<VPTNode>(p.openableNodes.values()); Collections.sort(lst); fileLists.put(p, lst); @@ -132,14 +133,15 @@ //{{{ +getIndexOfChild(Object, Object) : int public int getIndexOfChild(Object parent, Object child) { if (parent == lastParent) { - return Collections.binarySearch(lastList, child); + return Collections.binarySearch(lastList, (VPTNode) child); } VPTNode node = (VPTNode) child; if (node.isGroup()) { return super.getIndexOfChild(parent, child); } else if (node.isProject()) { - return Collections.binarySearch(getProjectFileList((VPTProject) node), child); + return Collections.binarySearch(getProjectFileList((VPTProject) node), + (VPTNode) child); } Log.log(Log.WARNING, this, "Reached the supposedly unreachable! parent = " + parent); return -1; // shouldn't reach here @@ -147,11 +149,11 @@ //{{{ -getProjectFileList(VPTProject) : ArrayList /** Returns a vector with all the files of the project. */ - private ArrayList getProjectFileList(VPTProject p) { + private List<VPTNode> getProjectFileList(VPTProject p) { lastParent = p; - ArrayList lst = (ArrayList) fileLists.get(p); + List<VPTNode> lst = fileLists.get(p); if (lst == null) { - lst = new ArrayList(p.openableNodes.values()); + lst = new ArrayList<VPTNode>(p.openableNodes.values()); Collections.sort(lst); fileLists.put(p, lst); } @@ -180,7 +182,7 @@ aNode = aNode.getParent(); } pathBuilder.add(0, aNode); - return (TreeNode[]) pathBuilder.toArray(new TreeNode[pathBuilder.size()]); + return pathBuilder.toArray(new TreeNode[pathBuilder.size()]); } //}}} //{{{ +nodeChanged(TreeNode) : void Modified: plugins/ProjectViewer/trunk/projectviewer/vpt/VPTFilteredModel.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/vpt/VPTFilteredModel.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/vpt/VPTFilteredModel.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -60,7 +60,8 @@ //{{{ Private members private static final String SEPARATOR = "/"; - private Map cache = new HashMap(); + private Map<VPTProject,List<VPTNode>> cache = + new HashMap<VPTProject,List<VPTNode>>(); //}}} //{{{ +VPTFilteredModel(VPTNode) : <init> @@ -143,19 +144,24 @@ } //}}} //{{{ #getFilteredNodes(VPTProject) : List - protected List getFilteredNodes(VPTProject node) { - if (cache.get(node)!=null) - return (List)cache.get(node); - Log.log(Log.DEBUG, this, "not cached: "+node); - List filteredNodesList=new ArrayList(); + protected List<VPTNode> getFilteredNodes(VPTProject node) + { + List<VPTNode> filteredNodesList = cache.get(node); + if (filteredNodesList != null) { + return filteredNodesList; + } - // openableNodes returns an unmodifiable Collection - // ==> copy it into a new list - List openableNodelist = new LinkedList(); - Iterator openableNodesIt = node.openableNodes.values().iterator(); - while (openableNodesIt.hasNext()) - openableNodelist.add(openableNodesIt.next()); + filteredNodesList = new ArrayList<VPTNode>(); + /* + * openableNodes returns an unmodifiable Collection, so + * copy it into a new list. + */ + List<VPTNode> openableNodelist = new LinkedList<VPTNode>(); + for (VPTNode n : node.openableNodes.values()) { + openableNodelist.add(n); + } + // check first project list, then global list boolean useProjectFilter = true; for (int i=0; i<2 ;i++) @@ -255,65 +261,67 @@ public class FilteredDirectoryNode extends VPTDirectory { private VPTFilterData filterData; - private List files = new ArrayList(); + private List<VPTNode> files = new ArrayList<VPTNode>(); - //{{{ +FilteredDirectoryNode(VPTFilterData, List) : <init> - public FilteredDirectoryNode(VPTFilterData filterData, List openableNodeList) + + public FilteredDirectoryNode(VPTFilterData filterData, + List<VPTNode> openableNodeList) { super(filterData.getName()); this.filterData = filterData; - Iterator it = openableNodeList.iterator(); - while (it.hasNext()) - { - VPTNode node = (VPTNode)it.next(); - if (filterData.getPattern().matcher(node.getName()).matches()) - { + for (VPTNode node : openableNodeList) { + if (filterData.getPattern().matcher(node.getName()).matches()) { add(node); } } sortFiles(); - // remove from openableNodeList - it = files.iterator(); - while (it.hasNext()) - openableNodeList.remove(it.next()); + for (VPTNode n : files) { + openableNodeList.remove(n); + } + } - } //}}} - //{{{ +getName() : String - public String getName() { + public String getName() + { return filterData.getName(); - } //}}} + } - //{{{ +getFiles() : List - public List getFiles() { + + public List getFiles() + { return files; - } //}}} + } - //{{{ -sortFiles() : void - private void sortFiles() { + + private void sortFiles() + { Collections.sort(files); - } //}}} + } - //{{{ +getChildCount() : int - public int getChildCount() { + + public int getChildCount() + { return files.size(); - } //}}} + } - //{{{ +remove(VPTNode) : void - public void remove(VPTNode node) { + + public void remove(VPTNode node) + { files.remove(node); - } //}}} + } - //{{{ +add(VPTNode) : void - public void add(VPTNode node) { + + public void add(VPTNode node) + { files.add(node); - } //}}} + } - //{{{ +getClipType() : int - public int getClipType() { + + public int getClipType() + { return VPTCellRenderer.CLIP_START; - } //}}} + } } //}}} Modified: plugins/ProjectViewer/trunk/projectviewer/vpt/VPTGroup.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/vpt/VPTGroup.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/vpt/VPTGroup.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -64,8 +64,9 @@ return getName() + File.separator; } //}}} - //{{{ +compareToNode(VPTNode) : int - public int compareToNode(VPTNode n) { + //{{{ +compareTo(VPTNode) : int + public int compareTo(VPTNode n) + { if (!n.isGroup()) { return -1; } else if (n.isRoot()) { Modified: plugins/ProjectViewer/trunk/projectviewer/vpt/VPTNode.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/vpt/VPTNode.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/vpt/VPTNode.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -43,7 +43,8 @@ * @version $Id$ */ public abstract class VPTNode extends DefaultMutableTreeNode - implements Comparable { + implements Comparable<VPTNode> +{ //{{{ Constants @@ -250,7 +251,7 @@ */ public abstract String getNodePath(); //}}} - //{{{ +compareToNode(VPTNode) : int + //{{{ +compareTo(VPTNode) : int /** * This method is used to sort the nodes in the trees. The rough hierarchy * is Root -> Groups -> Projects -> "allows children" -> leaves, so try @@ -261,27 +262,14 @@ * nodes of these kinds to take care of the comparison themselves. * There's danger of infinite recursion if you don't take this into * account.</p> + * + * @since PV 3.0.0 */ - public int compareToNode(VPTNode node) { + public int compareTo(VPTNode node) + { return 1; } //}}} - //{{{ +compareTo(Object) : int - /** - * Implementation of the Comparable interface. Returns -1 if "o" is - * not another VPTNode, otherwise calls - * {@link #compareToNode(VPTNode) compareToNode(VPTNode)}. - * - * @since PV 2.1.0 - */ - public int compareTo(Object o) { - if (o instanceof VPTNode) { - return compareToNode((VPTNode)o); - } else { - return -1; - } - } //}}} - //{{{ +findIndexForChild(VPTNode) : int /** * Do a binary search with the goal of finding in what index of the child @@ -300,7 +288,7 @@ while (e - b > 1) { n = (VPTNode) children.get(i); - int comp = child.compareToNode(n); + int comp = child.compareTo(n); if (comp < 0) { e = i; @@ -314,7 +302,7 @@ } if (b == children.size()) return b; n = (VPTNode) children.get(b); - return (child.compareToNode(n) < 0 ? b : b + 1); + return (child.compareTo(n) < 0 ? b : b + 1); } //}}} //{{{ +setParent(MutableTreeNode) : void Modified: plugins/ProjectViewer/trunk/projectviewer/vpt/VPTProject.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/vpt/VPTProject.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/vpt/VPTProject.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -58,8 +58,8 @@ //{{{ Attributes - private List openFiles; - private List filterList; + private List<String> openFiles; + private List<VPTFilterData> filterList; private String rootPath; private String url; private Properties properties; @@ -74,9 +74,9 @@ public VPTProject(String name) { super(name, true); openableNodes = new HashMap<String,VPTNode>(); - openFiles = new ArrayList(); + openFiles = new ArrayList<String>(); properties = new Properties(); - filterList = Collections.EMPTY_LIST; + filterList = Collections.emptyList(); lock = new AtomicBoolean(false); } @@ -259,9 +259,9 @@ return getRootPath(); } //}}} - //{{{ +compareToNode(VPTNode) : int + //{{{ +compareTo(VPTNode) : int /** Projects have precedence over everything but groups. */ - public int compareToNode(VPTNode node) { + public int compareTo(VPTNode node) { if (node.isGroup()){ return 1; } else if (node.isProject()) { @@ -286,7 +286,7 @@ * * @since PV 2.2.2.0 */ - public void setFilterList(List filterList) { + public void setFilterList(List<VPTFilterData> filterList) { this.filterList = filterList; ProjectViewer.nodeStructureChanged(this); } //}}} @@ -298,7 +298,7 @@ * * @since PV 2.2.2.0 */ - public List getFilterList() { + public List<VPTFilterData> getFilterList() { return filterList; } //}}} Modified: plugins/ProjectViewer/trunk/projectviewer/vpt/VPTRoot.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/vpt/VPTRoot.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/vpt/VPTRoot.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -58,9 +58,9 @@ return File.separator; } //}}} - //{{{ +compareToNode(VPTNode) : int + //{{{ +compareTo(VPTNode) : int /** The root is always the first node. Period. */ - public int compareToNode(VPTNode node) { + public int compareTo(VPTNode node) { return -1; } //}}} Modified: plugins/ProjectViewer/trunk/projectviewer/vpt/VPTWorkingFileListModel.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/vpt/VPTWorkingFileListModel.java 2008-08-30 16:51:06 UTC (rev 13456) +++ plugins/ProjectViewer/trunk/projectviewer/vpt/VPTWorkingFileListModel.java 2008-08-30 18:57:52 UTC (rev 13457) @@ -22,6 +22,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; +import java.util.List; +import java.util.Map; import java.util.WeakHashMap; import javax.swing.tree.TreeNode; @@ -40,11 +42,11 @@ public class VPTWorkingFileListModel extends ProjectTreeModel { //{{{ Private members - private WeakHashMap fileLists; + private Map<VPTProject,List<VPTNode>> fileLists; private Object lastParent; - private ArrayList lastList; - private ArrayList pathBuilder; + private List<VPTNode> lastList; + private List<TreeNode> pathBuilder; //}}} //{{{ +VPTWorkingFileListModel(VPTNode) : <init> @@ -55,8 +57,8 @@ */ public VPTWorkingFileListModel(VPTNode rootNode) { super(rootNode); - fileLists = new WeakHashMap(); - pathBuilder = new ArrayList(); + fileLists = new WeakHashMap<VPTProject,List<VPTNode>>(); + pathBuilder = new ArrayList<TreeNode>(); checkOpenFiles(); } //}}} @@ -76,7 +78,7 @@ return node.getChildCount(); } else if (node.isProject()) { lastParent = parent; - ArrayList lst = (ArrayList) fileLists.get(node); + List<VPTNode> lst = fileLists.get(node); lastList = lst; return (lst != null) ? lst.size() : 0; } @@ -101,10 +103,10 @@ } else if (node.isProject()) { lastParent = parent; VPTProject p = (VPTProject) node; - ArrayList lst = (ArrayList) fileLists.get(p); + List<VPTNode> lst = fileLists.get(p); if (lst == null) { - lst = new ArrayList(); - fileLists.put(node, lst); + lst = new ArrayList<VPTNode>(); + fileLists.put(p, lst); } lastList = lst; if (index >= lst.size()) return null; @@ -144,9 +146,9 @@ for (int j = 0; j < projs.length; j++) { VPTNode n = projs[j].getChildNode(path); if (n != null) { - ArrayList lst = (ArrayList) fileLists.get(projs[j]); + List<VPTNode> lst = fileLists.get(projs[j]); if (lst == null) { - lst = new ArrayList(); + lst = new ArrayList<VPTNode>(); fileLists.put(projs[j], lst); } lst.add(n); @@ -164,7 +166,7 @@ Buffer[] bufs = jEdit.getBuffers(); VPTNode root = (VPTNode) this.root; - ArrayList lst = new ArrayList(); + List<VPTNode> lst = new ArrayList<VPTNode>(); fileLists.put(p, lst); for (int i = 0; i < bufs.length; i++) { @@ -189,9 +191,9 @@ for (int j = 0; j < projs.length; j++) { VPTNode n = projs[j].getChildNode(path); if (n != null) { - ArrayList lst = (ArrayList) fileLists.get(projs[j]); + List<VPTNode> lst = fileLists.get(projs[j]); if (lst == null) { - lst = new ArrayList(); + lst = new ArrayList<VPTNode>(); fileLists.put(projs[j], lst); } if (!lst.contains(n)) { @@ -215,7 +217,7 @@ for (int j = 0; j < projs.length; j++) { VPTNode n = projs[j].getChildNode(path); if (n != null) { - ArrayList lst = (ArrayList) fileLists.get(projs[j]); + List<VPTNode> lst = fileLists.get(projs[j]); if (lst != null) { lst.remove(n); super.nodeStructureChanged(projs[j]); @@ -233,7 +235,7 @@ projs = new VPTProject[1]; projs[0] = (VPTProject) root; } else { - ArrayList lst = new ArrayList(); + List<VPTProject> lst = new ArrayList<VPTProject>(); findProjects((VPTGroup)root, lst); projs = (VPTProject[]) lst.toArray(new VPTProject[lst.size()]); } @@ -242,11 +244,13 @@ } //}}} //{{{ -findProjects(VPTGroup, ArrayList) : void - private void findProjects(VPTGroup grp, ArrayList projs) { + private void findProjects(VPTGroup grp, + List<VPTProject> projs) + { for (Enumeration e = grp.children(); e.hasMoreElements(); ) { VPTNode next = (VPTNode) e.nextElement(); if (next.isProject()) { - projs.add(next); + projs.add((VPTProject)next); } else { findProjects((VPTGroup)next, projs); } @@ -274,7 +278,7 @@ aNode = aNode.getParent(); } pathBuilder.add(0, aNode); - return (TreeNode[]) pathBuilder.toArray(new TreeNode[pathBuilder.size()]); + return pathBuilder.toArray(new TreeNode[pathBuilder.size()]); } //}}} //{{{ +nodeChanged(TreeNode) : void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |