From 3da5a4bf817bbb9ee740c58e8de57ecd23effc3f Mon Sep 17 00:00:00 2001 From: Sailsman63 Date: Mon, 28 Feb 2022 01:17:56 -0600 Subject: [PATCH 1/5] strip unused imports --- .../src/artofillusion/spmanager/HttpSPMFileSystem.java | 10 +--------- .../src/artofillusion/spmanager/InstallSplitPane.java | 7 +------ .../artofillusion/spmanager/LocalSPMFileSystem.java | 8 +------- .../src/artofillusion/spmanager/ManageSplitPane.java | 3 +-- .../src/artofillusion/spmanager/SPMFileSystem.java | 3 +-- .../src/artofillusion/spmanager/SPMSplitPane.java | 3 +-- .../src/artofillusion/spmanager/SPManagerFrame.java | 6 +----- .../src/artofillusion/spmanager/SPManagerPlugin.java | 3 +-- 8 files changed, 8 insertions(+), 35 deletions(-) diff --git a/SPManager/src/artofillusion/spmanager/HttpSPMFileSystem.java b/SPManager/src/artofillusion/spmanager/HttpSPMFileSystem.java index d72c94b..3b24d5a 100644 --- a/SPManager/src/artofillusion/spmanager/HttpSPMFileSystem.java +++ b/SPManager/src/artofillusion/spmanager/HttpSPMFileSystem.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Francois Guillet + * Changes copyright 2022 by Maksim Khramov * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later version. @@ -9,12 +10,9 @@ */ package artofillusion.spmanager; -import artofillusion.*; import artofillusion.ui.*; import java.awt.*; -import java.awt.event.*; import javax.swing.*; -import javax.swing.tree.*; import buoy.widget.*; import buoy.event.*; import java.io.*; @@ -24,12 +22,6 @@ import javax.swing.text.*; import javax.swing.text.html.*; import javax.swing.text.html.parser.*; -import java.util.regex.*; -import javax.xml.parsers.*; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; import org.xml.sax.*; import org.w3c.dom.*; diff --git a/SPManager/src/artofillusion/spmanager/InstallSplitPane.java b/SPManager/src/artofillusion/spmanager/InstallSplitPane.java index 1e0dbd6..793febe 100644 --- a/SPManager/src/artofillusion/spmanager/InstallSplitPane.java +++ b/SPManager/src/artofillusion/spmanager/InstallSplitPane.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Francois Guillet + * Changes copyright 2022 by Maksim Khramov * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later version. @@ -9,21 +10,15 @@ */ package artofillusion.spmanager; -import artofillusion.*; -import artofillusion.ui.Translate; import artofillusion.ui.UIUtilities; import java.awt.*; -import java.awt.event.*; import javax.swing.*; -import javax.swing.event.*; import javax.swing.tree.*; import buoy.widget.*; import buoy.event.*; import java.io.*; import java.util.*; -import java.util.zip.*; import java.net.*; -import java.text.*; /** diff --git a/SPManager/src/artofillusion/spmanager/LocalSPMFileSystem.java b/SPManager/src/artofillusion/spmanager/LocalSPMFileSystem.java index 9b53cec..2908920 100644 --- a/SPManager/src/artofillusion/spmanager/LocalSPMFileSystem.java +++ b/SPManager/src/artofillusion/spmanager/LocalSPMFileSystem.java @@ -1,5 +1,5 @@ /* Copyright 2004 Francois Guillet - + * Changes copyright 2022 by Maksim Khramov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -11,14 +11,8 @@ package artofillusion.spmanager; -import java.awt.*; -import javax.swing.*; -import javax.swing.tree.*; -import buoy.widget.*; -import buoy.event.*; import java.io.*; import java.util.*; -import java.util.zip.*; public class LocalSPMFileSystem extends SPMFileSystem { diff --git a/SPManager/src/artofillusion/spmanager/ManageSplitPane.java b/SPManager/src/artofillusion/spmanager/ManageSplitPane.java index bdb1bae..af2e1b1 100644 --- a/SPManager/src/artofillusion/spmanager/ManageSplitPane.java +++ b/SPManager/src/artofillusion/spmanager/ManageSplitPane.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Francois Guillet + * Changes copyright 2022 by Maksim Khramov * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later version. @@ -13,10 +14,8 @@ import javax.swing.*; import javax.swing.tree.*; import buoy.widget.*; -import buoy.event.*; import java.io.*; import java.util.*; -import java.util.zip.*; /** * Description of the Class diff --git a/SPManager/src/artofillusion/spmanager/SPMFileSystem.java b/SPManager/src/artofillusion/spmanager/SPMFileSystem.java index 6ec4020..40d7ae4 100644 --- a/SPManager/src/artofillusion/spmanager/SPMFileSystem.java +++ b/SPManager/src/artofillusion/spmanager/SPMFileSystem.java @@ -1,5 +1,5 @@ /* Copyright 2004 Francois Guillet - + * Changes copyright 2022 by Maksim Khramov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -12,7 +12,6 @@ package artofillusion.spmanager; import java.util.Vector; -import artofillusion.*; public class SPMFileSystem { diff --git a/SPManager/src/artofillusion/spmanager/SPMSplitPane.java b/SPManager/src/artofillusion/spmanager/SPMSplitPane.java index 917d97f..23a8671 100644 --- a/SPManager/src/artofillusion/spmanager/SPMSplitPane.java +++ b/SPManager/src/artofillusion/spmanager/SPMSplitPane.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Francois Guillet + * Changes copyright 2022 by Maksim Khramov * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later version. @@ -14,8 +15,6 @@ import javax.swing.*; import javax.swing.tree.*; import java.awt.event.*; -import javax.swing.event.*; -import javax.swing.plaf.*; import buoy.widget.*; import buoy.event.*; diff --git a/SPManager/src/artofillusion/spmanager/SPManagerFrame.java b/SPManager/src/artofillusion/spmanager/SPManagerFrame.java index 9a7963a..249ecde 100644 --- a/SPManager/src/artofillusion/spmanager/SPManagerFrame.java +++ b/SPManager/src/artofillusion/spmanager/SPManagerFrame.java @@ -1,6 +1,6 @@ - /* * Copyright 2004 Francois Guillet + * Changes copyright 2022 by Maksim Khramov * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later version. @@ -15,12 +15,8 @@ import java.awt.*; import javax.swing.*; -import javax.swing.Timer.*; import javax.swing.border.*; import java.awt.event.ActionEvent; -import java.io.File; -import java.util.Vector; - import buoy.widget.*; import buoy.event.*; diff --git a/SPManager/src/artofillusion/spmanager/SPManagerPlugin.java b/SPManager/src/artofillusion/spmanager/SPManagerPlugin.java index 100f9b5..d3e3d0b 100644 --- a/SPManager/src/artofillusion/spmanager/SPManagerPlugin.java +++ b/SPManager/src/artofillusion/spmanager/SPManagerPlugin.java @@ -1,6 +1,6 @@ - /* * Copyright 2004 Francois Guillet + * Changes copyright 2022 by Maksim Khramov * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later version. @@ -15,7 +15,6 @@ import artofillusion.ui.*; import java.awt.*; -import java.awt.event.*; import buoy.event.*; import buoy.widget.*; From 2dcfb4a9ba1e42c75fea9965f3346948c5a96fe6 Mon Sep 17 00:00:00 2001 From: Sailsman63 Date: Mon, 28 Feb 2022 01:28:34 -0600 Subject: [PATCH 2/5] Convert to modern, type-annotated Collections calls --- .../spmanager/HttpSPMFileSystem.java | 17 ++++---- .../spmanager/InstallSplitPane.java | 13 ++++--- .../spmanager/ManageSplitPane.java | 3 +- .../spmanager/SPMFileSystem.java | 27 ++++++------- .../spmanager/SPMObjectInfo.java | 39 ++++++++++--------- .../artofillusion/spmanager/SPMSplitPane.java | 5 ++- 6 files changed, 55 insertions(+), 49 deletions(-) diff --git a/SPManager/src/artofillusion/spmanager/HttpSPMFileSystem.java b/SPManager/src/artofillusion/spmanager/HttpSPMFileSystem.java index 3b24d5a..89a8ffe 100644 --- a/SPManager/src/artofillusion/spmanager/HttpSPMFileSystem.java +++ b/SPManager/src/artofillusion/spmanager/HttpSPMFileSystem.java @@ -17,6 +17,7 @@ import buoy.event.*; import java.io.*; import java.util.*; +import java.util.List; import java.util.zip.*; import java.net.*; import javax.swing.text.*; @@ -164,7 +165,7 @@ private void scanPlugins() } if ( statusDialog != null ) statusDialog.setText( SPMTranslate.text( "scanningPlugins" ) ); - pluginsInfo = new Vector(); + pluginsInfo = new Vector<>(); if ( SPManagerFrame.getParameters().getUseCache() ) { scanFiles( "Plugins", pluginsInfo ); @@ -300,10 +301,10 @@ private void scanStartupScripts() * Scans file on a general basis * *@param from URL to scan files from - *@param addTo Which vector to add info to + *@param addTo Which list to add info to *@param suffix Scanned files suffix */ - private void scanFiles( URL from, Vector addTo, String suffix ) + private void scanFiles( URL from, List addTo, String suffix ) { SPMObjectInfo info; boolean eligible; @@ -434,9 +435,9 @@ else if ( e instanceof FileNotFoundException ) * Scans file using server cgi * *@param dir directory to fetch scripts from - *@param addTo Which vector to add info to + *@param addTo Which list to add info to */ - private void scanFiles( String dir, Vector addTo ) + private void scanFiles( String dir, List addTo ) { URL cgiUrl = null; @@ -949,8 +950,8 @@ public void handleEndTag( HTML.Tag t, MutableAttributeSet a, int pos ) */ private class HtmlVersioningParserCallback extends HTMLEditorKit.ParserCallback { - private Vector v; - private URL from; + private final List v; + private final URL from; /** @@ -959,7 +960,7 @@ private class HtmlVersioningParserCallback extends HTMLEditorKit.ParserCallback *@param v Description of the Parameter *@param from Description of the Parameter */ - public HtmlVersioningParserCallback( Vector v, URL from ) + public HtmlVersioningParserCallback( List v, URL from ) { this.v = v; this.from = from; diff --git a/SPManager/src/artofillusion/spmanager/InstallSplitPane.java b/SPManager/src/artofillusion/spmanager/InstallSplitPane.java index 793febe..f470cc6 100644 --- a/SPManager/src/artofillusion/spmanager/InstallSplitPane.java +++ b/SPManager/src/artofillusion/spmanager/InstallSplitPane.java @@ -18,6 +18,7 @@ import buoy.event.*; import java.io.*; import java.util.*; +import java.util.List; import java.net.*; @@ -192,15 +193,15 @@ private void getStartupScripts() * *@param addTo Description of the Parameter *@param infos Description of the Parameter - *@param managerInfoVector Description of the Parameter + *@param managerInfoList Description of the Parameter */ - private void getFiles( TreePath addTo, Vector infos, Vector managerInfoVector ) + private void getFiles( TreePath addTo, List infos, List managerInfoList ) { DefaultMutableTreeNode tn; SPMObjectInfo info; SPMObjectInfo managerInfo; boolean eligible; - TreeMap map = new TreeMap(); + TreeMap map = new TreeMap<>(); for ( int i = 0; i < infos.size(); i++ ) { @@ -213,16 +214,16 @@ private void getFiles( TreePath addTo, Vector infos, Vector managerInfoVector ) eligible = ( workMode == INSTALL ); managerInfo = null; String name = info.getName(); - for ( int j = 0; j < managerInfoVector.size(); ++j ) + for ( int j = 0; j < managerInfoList.size(); ++j ) { - if ( ( (SPMObjectInfo) managerInfoVector.elementAt( j ) ).getName().equals( name ) ) + if ( (managerInfoList.get( j ) ).getName().equals( name ) ) { eligible = ( workMode == UPDATE ); if ( eligible ) { //check if valid update - managerInfo = (SPMObjectInfo) managerInfoVector.elementAt( j ); + managerInfo = managerInfoList.get( j ); System.out.println( info.getName() ); System.out.println( "major distant local :" + info.getMajor() + " " + managerInfo.getMajor() ); System.out.println( "minor distant local :" + info.getMinor() + " " + managerInfo.getMinor() ); diff --git a/SPManager/src/artofillusion/spmanager/ManageSplitPane.java b/SPManager/src/artofillusion/spmanager/ManageSplitPane.java index af2e1b1..6ff79df 100644 --- a/SPManager/src/artofillusion/spmanager/ManageSplitPane.java +++ b/SPManager/src/artofillusion/spmanager/ManageSplitPane.java @@ -16,6 +16,7 @@ import buoy.widget.*; import java.io.*; import java.util.*; +import java.util.List; /** * Description of the Class @@ -105,7 +106,7 @@ private void getStartupScripts() *@param addTo Description of the Parameter *@param infos Description of the Parameter */ - private void getFiles( TreePath addTo, Vector infos ) + private void getFiles( TreePath addTo, List infos ) { DefaultMutableTreeNode tn; SPMObjectInfo info; diff --git a/SPManager/src/artofillusion/spmanager/SPMFileSystem.java b/SPManager/src/artofillusion/spmanager/SPMFileSystem.java index 40d7ae4..68b5d53 100644 --- a/SPManager/src/artofillusion/spmanager/SPMFileSystem.java +++ b/SPManager/src/artofillusion/spmanager/SPMFileSystem.java @@ -11,11 +11,12 @@ package artofillusion.spmanager; +import java.util.List; import java.util.Vector; public class SPMFileSystem { - protected Vector pluginsInfo, toolInfo, objectInfo, startupInfo; + protected List pluginsInfo, toolInfo, objectInfo, startupInfo; protected boolean initialized; public final static short PLUGIN_TYPE = 0; @@ -25,23 +26,23 @@ public class SPMFileSystem public SPMFileSystem() { - pluginsInfo = new Vector(); - toolInfo = new Vector(); - objectInfo = new Vector(); - startupInfo = new Vector(); + pluginsInfo = new Vector<>(); + toolInfo = new Vector<>(); + objectInfo = new Vector<>(); + startupInfo = new Vector<>(); initialized = false; } public short getInfoType(SPMObjectInfo info) { for (int i = 0; i < pluginsInfo.size(); ++i) - if (info == pluginsInfo.elementAt(i)) return PLUGIN_TYPE; + if (info == pluginsInfo.get(i)) return PLUGIN_TYPE; for (int i = 0; i < toolInfo.size(); ++i) - if (info == toolInfo.elementAt(i)) return TOOL_SCRIPT_TYPE; + if (info == toolInfo.get(i)) return TOOL_SCRIPT_TYPE; for (int i = 0; i < objectInfo.size(); ++i) - if (info == objectInfo.elementAt(i)) return OBJECT_SCRIPT_TYPE; + if (info == objectInfo.get(i)) return OBJECT_SCRIPT_TYPE; for (int i = 0; i < startupInfo.size(); ++i) - if (info == startupInfo.elementAt(i)) return STARTUP_SCRIPT_TYPE; + if (info == startupInfo.get(i)) return STARTUP_SCRIPT_TYPE; return PLUGIN_TYPE; } @@ -66,25 +67,25 @@ public void initialize() startupInfo.clear(); } - public Vector getPlugins() + public List getPlugins() { if (!initialized) initialize(); return pluginsInfo; } - public Vector getToolScripts() + public List getToolScripts() { if (!initialized) initialize(); return toolInfo; } - public Vector getObjectScripts() + public List getObjectScripts() { if (!initialized) initialize(); return objectInfo; } - public Vector getStartupScripts() + public List getStartupScripts() { if (!initialized) initialize(); return startupInfo; diff --git a/SPManager/src/artofillusion/spmanager/SPMObjectInfo.java b/SPManager/src/artofillusion/spmanager/SPMObjectInfo.java index 3c47e9d..c0dc103 100644 --- a/SPManager/src/artofillusion/spmanager/SPMObjectInfo.java +++ b/SPManager/src/artofillusion/spmanager/SPMObjectInfo.java @@ -1,5 +1,6 @@ /* * Copyright 2004 Francois Guillet + * Changes copyright 2022 by Maksim Khramov * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later version. @@ -13,7 +14,7 @@ import java.util.*; import org.w3c.dom.*; import java.net.*; - +import java.util.List; /** * Description of the Class @@ -63,12 +64,12 @@ public class SPMObjectInfo private String description = null; private String comments = null; - private HashMap externals; - private Vector changeLog; - private Vector details; + private Map externals; + private List changeLog; + private List details; - protected HashMap exports; - public HashMap actions; + protected Map exports; + public Map actions; /** * Script file name @@ -699,12 +700,12 @@ private void readInfoFromDocumentNode(Node script) SPMParameters params = SPManagerFrame.getParameters(); if (changeLog == null) { - changeLog = new Vector(16); - details = new Vector(16); - externals = new HashMap(16); + changeLog = new Vector<>(16); + details = new Vector<>(16); + externals = new HashMap<>(16); destination = new ArrayList(16); - actions = new HashMap(16); - exports = new HashMap(32); + actions = new HashMap<>(16); + exports = new HashMap<>(32); } else { changeLog.clear(); @@ -1097,18 +1098,18 @@ public String getComments() return comments; } - /** - * get the list of external dependencies. + /**. + * @return the list of external dependencies */ - public Collection getExternals() - { return (externals != null ? externals.values() : null); } + public Collection getExternals() + { return externals == null ? null: externals.values(); } /** * get the change log */ - public Vector getChangeLog() + public List getChangeLog() { - return changeLog; + return changeLog; } /** @@ -1116,9 +1117,9 @@ public Vector getChangeLog() * *@return The details vector */ - public Vector getDetails() + public List getDetails() { - return details; + return details; } /** diff --git a/SPManager/src/artofillusion/spmanager/SPMSplitPane.java b/SPManager/src/artofillusion/spmanager/SPMSplitPane.java index 23a8671..327cbc3 100644 --- a/SPManager/src/artofillusion/spmanager/SPMSplitPane.java +++ b/SPManager/src/artofillusion/spmanager/SPMSplitPane.java @@ -11,6 +11,7 @@ package artofillusion.spmanager; import java.util.*; +import java.util.List; import java.awt.*; import javax.swing.*; import javax.swing.tree.*; @@ -94,7 +95,7 @@ public class SPMSplitPane extends BSplitPane private BScrollPane nameSP, descriptionSP; private BComboBox descSelect; - private Vector descText; + private List descText; /** * Description of the Field @@ -434,7 +435,7 @@ private void displayObjectInfo( SPMObjectInfo info ) objectDescription.setText( (String) descText.get(0) ); else objectDescription.setText(""); - Vector changeLog = info.getChangeLog(); + List changeLog = info.getChangeLog(); if (changeLog != null) descSelect.setContents(changeLog); else { descSelect.removeAll(); From 925a40d02d2c91c9df8fb6c8afcdb25101102c6e Mon Sep 17 00:00:00 2001 From: Sailsman63 Date: Mon, 28 Feb 2022 01:36:03 -0600 Subject: [PATCH 3/5] Modern iteration through Collections --- .../spmanager/InstallSplitPane.java | 22 +++------ .../spmanager/LocalSPMFileSystem.java | 15 +++--- .../spmanager/ManageSplitPane.java | 48 +++++++------------ .../spmanager/SPManagerFrame.java | 34 +++++-------- .../spmanager/SPManagerPlugin.java | 8 ++-- 5 files changed, 45 insertions(+), 82 deletions(-) diff --git a/SPManager/src/artofillusion/spmanager/InstallSplitPane.java b/SPManager/src/artofillusion/spmanager/InstallSplitPane.java index f470cc6..383f4c1 100644 --- a/SPManager/src/artofillusion/spmanager/InstallSplitPane.java +++ b/SPManager/src/artofillusion/spmanager/InstallSplitPane.java @@ -197,15 +197,13 @@ private void getStartupScripts() */ private void getFiles( TreePath addTo, List infos, List managerInfoList ) { - DefaultMutableTreeNode tn; - SPMObjectInfo info; + SPMObjectInfo managerInfo; boolean eligible; TreeMap map = new TreeMap<>(); - for ( int i = 0; i < infos.size(); i++ ) + for (SPMObjectInfo info: infos ) { - info = (SPMObjectInfo) infos.elementAt( i ); if (info.restriction >= SPMParameters.HIDE) continue; @@ -262,18 +260,10 @@ else if ( info.getMinor() == managerInfo.getMinor() ) } } } - Collection col = map.values(); - if ( ! col.isEmpty() ) - { - for( Iterator iter = col.iterator(); iter.hasNext(); ) - { - info = (SPMObjectInfo) iter.next(); - tn = new DefaultMutableTreeNode( info.getName() ); - tn.setAllowsChildren( false ); - tn.setUserObject( info ); - tree.addNode( addTo, tn ); - } - } + map.values().forEach(info -> { + tree.addNode(addTo, new DefaultMutableTreeNode(info, false)); + }); + } diff --git a/SPManager/src/artofillusion/spmanager/LocalSPMFileSystem.java b/SPManager/src/artofillusion/spmanager/LocalSPMFileSystem.java index 2908920..3e75319 100644 --- a/SPManager/src/artofillusion/spmanager/LocalSPMFileSystem.java +++ b/SPManager/src/artofillusion/spmanager/LocalSPMFileSystem.java @@ -52,20 +52,21 @@ private void scanStartupScripts() scanFiles(SPManagerPlugin.STARTUP_SCRIPT_DIRECTORY, startupInfo, ".bsh"); } - private void scanFiles(String directory, Vector infoVector, String suffix) + private void scanFiles(String directory, List infoVector, String suffix) { - SPMObjectInfo info; File dir = new File(directory); if (dir.exists()) { String[] files = dir.list(); if (files.length > 0) Arrays.sort(files); - for (int i = 0; i < files.length; i++) - if (files[i].endsWith(suffix)) - { info = new SPMObjectInfo(directory+File.separatorChar+files[i]); - infoVector.add(info); - } + for (String file : files) + { + if (file.endsWith(suffix)) + { + infoVector.add(new SPMObjectInfo(directory + File.separatorChar + file)); + } + } } } diff --git a/SPManager/src/artofillusion/spmanager/ManageSplitPane.java b/SPManager/src/artofillusion/spmanager/ManageSplitPane.java index 6ff79df..6d04e6b 100644 --- a/SPManager/src/artofillusion/spmanager/ManageSplitPane.java +++ b/SPManager/src/artofillusion/spmanager/ManageSplitPane.java @@ -108,39 +108,25 @@ private void getStartupScripts() */ private void getFiles( TreePath addTo, List infos ) { - DefaultMutableTreeNode tn; - SPMObjectInfo info; - - for ( int i = 0; i < infos.size(); i++ ) - { - info = (SPMObjectInfo) infos.elementAt( i ); - tn = new DefaultMutableTreeNode( info.getName() ); - tn.setAllowsChildren( false ); - tn.setUserObject( info ); - tree.addNode( addTo, tn ); - } + infos.forEach(info -> { + tree.addNode(addTo, new DefaultMutableTreeNode(info, false)); + }); // NTJ: set reference counts - for (int i = 0; i < infos.size(); i++) { - info = (SPMObjectInfo) infos.elementAt( i ); - - Collection externals = info.getExternals(); - String extName, extType; - SPMObjectInfo ext; - if (externals != null) { - for (Iterator iter = externals.iterator(); iter.hasNext(); ) { - extName = (String) iter.next(); - - if (extName.endsWith("= required")) { - extType = extName.substring(extName.indexOf(':')+1, - extName.indexOf('=')).trim(); - extName = extName.substring(0, extName.indexOf(':')); - - ext = getInfo(extName, (TreePath)pathMap.get(extType)); - if (ext != null) ext.refcount++; - } - } - } + for (SPMObjectInfo info: infos) { + Collection externals = info.getExternals(); + if(externals == null) continue; + + externals.forEach((String item) -> { + String extName = item; + if (extName.endsWith("= required")) + { + String extType = extName.substring(extName.indexOf(':') + 1, extName.indexOf('=')).trim(); + extName = extName.substring(0, extName.indexOf(':')); + SPMObjectInfo ext = getInfo(extName, (TreePath) pathMap.get(extType)); + if (ext != null) ext.refcount++; + } + }); } } diff --git a/SPManager/src/artofillusion/spmanager/SPManagerFrame.java b/SPManager/src/artofillusion/spmanager/SPManagerFrame.java index 249ecde..16473dc 100644 --- a/SPManager/src/artofillusion/spmanager/SPManagerFrame.java +++ b/SPManager/src/artofillusion/spmanager/SPManagerFrame.java @@ -19,6 +19,7 @@ import java.awt.event.ActionEvent; import buoy.widget.*; import buoy.event.*; +import java.util.function.Predicate; /** * Main frame of the scripts and plugins manager. @@ -141,17 +142,13 @@ public void actionPerformed( ActionEvent e ) */ public void printBounds( WidgetContainer wc ) { - java.util.Iterator childEnum = wc.getChildren().iterator(); - while ( childEnum.hasNext() ) - { - Widget w = (Widget) childEnum.next(); - System.out.println( "Widget: " + w ); - System.out.println( "Bounds: " + w.getBounds() ); - System.out.println( "Min size: " + w.getMinimumSize() ); - System.out.println( "Pref size: " + w.getPreferredSize() ); - if ( w instanceof WidgetContainer ) - printBounds( (WidgetContainer) w ); - } + wc.getChildren().forEach(w ->{ + System.out.println("Widget: " + w); + System.out.println("Bounds: " + w.getBounds()); + System.out.println("Min size: " + w.getMinimumSize()); + System.out.println("Pref size: " + w.getPreferredSize()); + if(w instanceof WidgetContainer) printBounds((WidgetContainer)w); + }); } @@ -192,19 +189,10 @@ private void doTabbedPaneSelection() */ protected void checkForUpdatedMe() { - Vector localList = manageSplitPane.getFileSystem().getPlugins(); - Vector remoteList = updateSplitPane.getFileSystem().getPlugins(); - SPMObjectInfo localinfo=null, remoteinfo=null; - for (int i = 0; i < localList.size(); i++) { - localinfo= (SPMObjectInfo) localList.get(i); - if ("SPManager".equals(localinfo.getName())) break; - } - - for (int i = 0; i < remoteList.size(); i++) { - remoteinfo = (SPMObjectInfo) remoteList.get(i); - if ("SPManager".equals(remoteinfo.getName())) break; - } + Predicate self = (SPMObjectInfo t) -> t.getName().equals("SPManager"); + SPMObjectInfo localinfo = manageSplitPane.getFileSystem().getPlugins().stream().filter(self).findFirst().orElse(null); + SPMObjectInfo remoteinfo = updateSplitPane.getFileSystem().getPlugins().stream().filter(self).findFirst().orElse(null); boolean update = true; diff --git a/SPManager/src/artofillusion/spmanager/SPManagerPlugin.java b/SPManager/src/artofillusion/spmanager/SPManagerPlugin.java index d3e3d0b..11d2a20 100644 --- a/SPManager/src/artofillusion/spmanager/SPManagerPlugin.java +++ b/SPManager/src/artofillusion/spmanager/SPManagerPlugin.java @@ -156,11 +156,9 @@ public void processMessage( int message, Object args[] ) } // ok, now perform the actions - for (Iterator iter = info.actions.entrySet().iterator(); - iter.hasNext(); ) { - - entry = (Map.Entry) iter.next(); - key = entry.getKey().toString().split(":"); + for (Map.Entry entry: info.actions.entrySet()) { + String value = entry.getValue(); + String key[] = entry.getKey().split(":"); try { if (key[0].startsWith("/")) From d69da2319cd7baf09cca3b6278051b5b9517d936 Mon Sep 17 00:00:00 2001 From: Sailsman63 Date: Mon, 28 Feb 2022 01:39:37 -0600 Subject: [PATCH 4/5] Formatting cleanup Added @Overrides Converted to shorter lambda-style calls for functional interfaces --- .../spmanager/HttpSPMFileSystem.java | 2 ++ .../spmanager/LocalSPMFileSystem.java | 1 + .../spmanager/ManageSplitPane.java | 1 + .../spmanager/SPMObjectInfo.java | 2 +- .../artofillusion/spmanager/SPMSplitPane.java | 1 + .../spmanager/SPManagerFrame.java | 14 ++++++-------- .../spmanager/SPManagerPlugin.java | 19 ++++++------------- 7 files changed, 18 insertions(+), 22 deletions(-) diff --git a/SPManager/src/artofillusion/spmanager/HttpSPMFileSystem.java b/SPManager/src/artofillusion/spmanager/HttpSPMFileSystem.java index 89a8ffe..6442256 100644 --- a/SPManager/src/artofillusion/spmanager/HttpSPMFileSystem.java +++ b/SPManager/src/artofillusion/spmanager/HttpSPMFileSystem.java @@ -973,6 +973,7 @@ public HtmlVersioningParserCallback( List v, URL from ) *@param data Description of the Parameter *@param pos Description of the Parameter */ + @Override public void handleText( char[] data, int pos ) { System.out.println( "handleText " + new String( data ) + " " + pos ); @@ -1032,6 +1033,7 @@ private String findCorrectVersion( String AoIversion, String[] versions ) *@param a Description of the Parameter *@param pos Description of the Parameter */ + @Override public void handleStartTag( HTML.Tag t, MutableAttributeSet a, int pos ) { System.out.println( "StartTag :" + t + ":" + a + ":" + pos ); diff --git a/SPManager/src/artofillusion/spmanager/LocalSPMFileSystem.java b/SPManager/src/artofillusion/spmanager/LocalSPMFileSystem.java index 3e75319..27c059a 100644 --- a/SPManager/src/artofillusion/spmanager/LocalSPMFileSystem.java +++ b/SPManager/src/artofillusion/spmanager/LocalSPMFileSystem.java @@ -21,6 +21,7 @@ public LocalSPMFileSystem() super(); } + @Override public void initialize() { super.initialize(); diff --git a/SPManager/src/artofillusion/spmanager/ManageSplitPane.java b/SPManager/src/artofillusion/spmanager/ManageSplitPane.java index 6d04e6b..ffc04dc 100644 --- a/SPManager/src/artofillusion/spmanager/ManageSplitPane.java +++ b/SPManager/src/artofillusion/spmanager/ManageSplitPane.java @@ -51,6 +51,7 @@ public ManageSplitPane() /** * Description of the Method */ + @Override protected void updateTree() { //update the file system diff --git a/SPManager/src/artofillusion/spmanager/SPMObjectInfo.java b/SPManager/src/artofillusion/spmanager/SPMObjectInfo.java index c0dc103..a75beb2 100644 --- a/SPManager/src/artofillusion/spmanager/SPMObjectInfo.java +++ b/SPManager/src/artofillusion/spmanager/SPMObjectInfo.java @@ -784,7 +784,7 @@ private void readInfoFromDocumentNode(Node script) extType = SPManagerUtils.getAttribute(node, "type"); extAssoc = SPManagerUtils.getAttribute(node, "association"); - externals.put(extName, extName + ":"+extType+"= " + extAssoc); + externals.put(extName, extName + ":" + extType + "= " + extAssoc); extAction = SPManagerUtils.getAttribute(node, "action"); if (extAction != null && extAction.length() > 0) { diff --git a/SPManager/src/artofillusion/spmanager/SPMSplitPane.java b/SPManager/src/artofillusion/spmanager/SPMSplitPane.java index 327cbc3..02a4f25 100644 --- a/SPManager/src/artofillusion/spmanager/SPMSplitPane.java +++ b/SPManager/src/artofillusion/spmanager/SPMSplitPane.java @@ -722,6 +722,7 @@ public SPMTreeRenderer() *@param hasFocus Description of the Parameter *@return The treeCellRendererComponent value */ + @Override public Component getTreeCellRendererComponent( JTree tree, Object value, diff --git a/SPManager/src/artofillusion/spmanager/SPManagerFrame.java b/SPManager/src/artofillusion/spmanager/SPManagerFrame.java index 16473dc..a2dba54 100644 --- a/SPManager/src/artofillusion/spmanager/SPManagerFrame.java +++ b/SPManager/src/artofillusion/spmanager/SPManagerFrame.java @@ -189,7 +189,6 @@ private void doTabbedPaneSelection() */ protected void checkForUpdatedMe() { - Predicate self = (SPMObjectInfo t) -> t.getName().equals("SPManager"); SPMObjectInfo localinfo = manageSplitPane.getFileSystem().getPlugins().stream().filter(self).findFirst().orElse(null); SPMObjectInfo remoteinfo = updateSplitPane.getFileSystem().getPlugins().stream().filter(self).findFirst().orElse(null); @@ -230,18 +229,17 @@ else if ( remoteinfo.getMinor() == localinfo.getMinor() ) { final SPMObjectInfo info = remoteinfo; (new Thread() { + @Override public void run() { updateSplitPane.installFile(info); updateSplitPane.showErrors(); - SwingUtilities.invokeLater(new Runnable() { - public void run() - { - status.dispose(); - hideSPManager(); - } - }); + SwingUtilities.invokeLater(() -> + { + status.dispose(); + hideSPManager(); + }); } }).start(); diff --git a/SPManager/src/artofillusion/spmanager/SPManagerPlugin.java b/SPManager/src/artofillusion/spmanager/SPManagerPlugin.java index 11d2a20..ac40454 100644 --- a/SPManager/src/artofillusion/spmanager/SPManagerPlugin.java +++ b/SPManager/src/artofillusion/spmanager/SPManagerPlugin.java @@ -52,6 +52,7 @@ public class SPManagerPlugin implements Plugin *@param message Description of the Parameter *@param args Description of the Parameter */ + @Override public void processMessage( int message, Object args[] ) { // NTJ: get the AOI run-time (*not* compile-time) version @@ -100,8 +101,7 @@ public void processMessage( int message, Object args[] ) Method addUrl = null; try { - addUrl = - URLClassLoader.class.getDeclaredMethod("addURL", sig); + addUrl = URLClassLoader.class.getDeclaredMethod("addURL", sig); addUrl.setAccessible(true); } catch (Exception e) { System.out.println("Error getting addURL method: " + e); @@ -113,8 +113,7 @@ public void processMessage( int message, Object args[] ) Class plugType; File files[], urlfile; URL url; - Map.Entry entry; - String key[], value; + File plugdir = new File(PLUGIN_DIRECTORY); if (plugdir.exists()) { files = plugdir.listFiles(); @@ -174,9 +173,6 @@ public void processMessage( int message, Object args[] ) System.out.println("SPM: adding path: " + url); - value = entry.getValue().toString(); - - if ("classpath".equalsIgnoreCase(value)) { if (searchldr != null) searchldr.add(url); @@ -184,20 +180,17 @@ else if (addUrl != null) { try { addUrl.invoke(urlldr, url); } catch (Exception e) { - System.out.println("Error invoking: " - + e); + System.out.println("Error invoking: " + e); } } - else System.out.println("Could not add path" + - url); + else System.out.println("Could not add path" + url); } else if ("import".equalsIgnoreCase(value)) { ldr = (ClassLoader) loaders.get(url); if (key.length == 1) { if (obj != null) searchldr.add(ldr); - else System.out.println("SPM: could not find" - + " loader for: " + url); + else System.out.println("SPM: could not find" + " loader for: " + url); } } From b94995058f1b778a6a28d8bf898b99c5e6b3b8e3 Mon Sep 17 00:00:00 2001 From: Maksim Khramov Date: Thu, 26 Jan 2023 17:05:23 +0300 Subject: [PATCH 5/5] More compiler warnings cleanup --- .../spmanager/postinstall/PostInstall.java | 16 ++-- .../spmanager/HttpSPMFileSystem.java | 65 +++++++------- .../spmanager/InstallSplitPane.java | 60 +++++-------- .../spmanager/ManageSplitPane.java | 26 +++--- .../spmanager/SPMObjectInfo.java | 20 ++--- .../spmanager/SPMParameters.java | 6 +- .../spmanager/SPMSetupFrame.java | 12 +-- .../artofillusion/spmanager/SPMSplitPane.java | 84 ++++++++----------- .../artofillusion/spmanager/SPMTranslate.java | 10 +-- .../spmanager/SPManagerPlugin.java | 33 ++++---- 10 files changed, 146 insertions(+), 186 deletions(-) diff --git a/PostInstall/src/artofillusion/spmanager/postinstall/PostInstall.java b/PostInstall/src/artofillusion/spmanager/postinstall/PostInstall.java index 1735508..b5d06a1 100644 --- a/PostInstall/src/artofillusion/spmanager/postinstall/PostInstall.java +++ b/PostInstall/src/artofillusion/spmanager/postinstall/PostInstall.java @@ -6,7 +6,8 @@ * PostInstall: perform post-install cleanup * * Copyright (C) 2006 Nik Trevallyn-Jones, Sydney Australia - * + * Changes copyright 2023 by Maksim Khramov + * * Author: Nik Trevallyn-Jones, nik777@users.sourceforge.net * $Id: Exp $ * @@ -39,9 +40,10 @@ public class PostInstall implements Plugin { - protected ArrayList ok, err; + protected List ok, err; protected static File tempDir = null; + @Override public void processMessage(int msg, Object[] args) { int i, k; @@ -95,8 +97,8 @@ public void processMessage(int msg, Object[] args) System.out.println("PostInstall: tempDir is " + tempDir.getAbsolutePath()); - ok = new ArrayList(128); - err = new ArrayList(128); + ok = new ArrayList<>(128); + err = new ArrayList<>(128); cleanup(ArtOfIllusion.PLUGIN_DIRECTORY, ok, err); cleanup(ArtOfIllusion.TOOL_SCRIPT_DIRECTORY, ok, err); @@ -116,12 +118,12 @@ public void processMessage(int msg, Object[] args) try { File tmp; String[] sub = tempDir.list(); - ArrayList list = new ArrayList(sub.length); + List list = new ArrayList<>(sub.length); for (i = 0; i < sub.length; i++) list.add(tempDir + File.separator + sub[i]); for (i = 0; i < list.size(); i++) { - tmp = new File((String) list.get(i)); + tmp = new File(list.get(i)); // make sure we empty all sub-directories first if (tmp.isDirectory()) { @@ -216,7 +218,7 @@ public void processMessage(int msg, Object[] args) * * @param path - the String representation of the pathname */ - public static void cleanup(String path, ArrayList ok, ArrayList err) + public static void cleanup(String path, List ok, List err) { File from, to; File plugin, update; diff --git a/SPManager/src/artofillusion/spmanager/HttpSPMFileSystem.java b/SPManager/src/artofillusion/spmanager/HttpSPMFileSystem.java index 6442256..b4fb6ee 100644 --- a/SPManager/src/artofillusion/spmanager/HttpSPMFileSystem.java +++ b/SPManager/src/artofillusion/spmanager/HttpSPMFileSystem.java @@ -1,6 +1,6 @@ /* * Copyright 2004 Francois Guillet - * Changes copyright 2022 by Maksim Khramov + * Changes copyright 2022-2023 by Maksim Khramov * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later version. @@ -40,7 +40,7 @@ public class HttpSPMFileSystem extends SPMFileSystem private URL repository; private HttpStatusDialog statusDialog; private boolean isDownloading; - private Vector callbacks; + private Vector callbacks; private Document pluginsDoc, objectsDoc, startupDoc, toolsDoc; private File file; @@ -71,10 +71,10 @@ public HttpSPMFileSystem( URL rep ) */ public void setRepository( URL rep ) { - pluginsInfo = new Vector(); - toolInfo = new Vector(); - objectInfo = new Vector(); - startupInfo = new Vector(); + pluginsInfo = new Vector<>(); + toolInfo = new Vector<>(); + objectInfo = new Vector<>(); + startupInfo = new Vector<>(); initialized = false; unknownHost = false; repository = rep; @@ -90,6 +90,7 @@ public void setRepository( URL rep ) * *@param cb Callback to call when done */ + @Override public void getRemoteInfo( Runnable cb ) { if ( !initialized ) @@ -98,13 +99,14 @@ public void getRemoteInfo( Runnable cb ) unknownHost = false; if ( !isDownloading ) { - callbacks = new Vector(); + callbacks = new Vector<>(); callbacks.add( cb ); isDownloading = true; statusDialog = new HttpStatusDialog(); ( new Thread() { + @Override public void run() { scanPlugins(); @@ -116,8 +118,7 @@ public void run() scanStartupScripts(); isDownloading = false; initialized = true; - for ( int i = 0; i < callbacks.size(); ++i ) - ( (Runnable) callbacks.elementAt( i ) ).run(); + callbacks.forEach(cb -> cb.run()); statusDialog.dispose(); statusDialog = null; } @@ -155,13 +156,13 @@ public void initialize() private void scanPlugins() { if (! SPManagerFrame.getParameters().getUseCache() ) - SPManagerFrame.getInstance().setRemoteStatusText( SPMTranslate.text( "scanningPluginsFrom", new String[]{repository.toString()} ), 5000 ); + SPManagerFrame.getInstance().setRemoteStatusText( SPMTranslate.text( "scanningPluginsFrom", repository ), 5000 ); else { String s = repository.toString(); s = s.substring(0, s.lastIndexOf('/')); s = s + "/cgi-bin/scripts.cgi?Plugins%20" + SPManagerPlugin.AOI_VERSION; - SPManagerFrame.getInstance().setRemoteStatusText( SPMTranslate.text( "scanningPluginsFrom", new String[]{s} ), 5000 ); + SPManagerFrame.getInstance().setRemoteStatusText( SPMTranslate.text( "scanningPluginsFrom", s), 5000 ); } if ( statusDialog != null ) statusDialog.setText( SPMTranslate.text( "scanningPlugins" ) ); @@ -192,17 +193,17 @@ private void scanPlugins() private void scanToolScripts() { if ( ! SPManagerFrame.getParameters().getUseCache() ) - SPManagerFrame.getInstance().setRemoteStatusText( SPMTranslate.text( "scanningToolScriptsFrom", new String[]{repository.toString()} ), 5000 ); + SPManagerFrame.getInstance().setRemoteStatusText( SPMTranslate.text( "scanningToolScriptsFrom", repository), 5000 ); else { String s = repository.toString(); s = s.substring(0, s.lastIndexOf('/')); s = s + "/cgi-bin/scripts.cgi?Scripts/Tools%20" + SPManagerPlugin.AOI_VERSION; - SPManagerFrame.getInstance().setRemoteStatusText( SPMTranslate.text( "scanningToolScriptsFrom", new String[]{s} ), 5000 ); + SPManagerFrame.getInstance().setRemoteStatusText( SPMTranslate.text( "scanningToolScriptsFrom", s ), 5000 ); } if ( statusDialog != null ) statusDialog.setText( SPMTranslate.text( "scanningToolScripts" ) ); - toolInfo = new Vector(); + toolInfo = new Vector<>(); if ( SPManagerFrame.getParameters().getUseCache() ) { scanFiles( "Scripts/Tools", toolInfo ); @@ -229,17 +230,17 @@ private void scanToolScripts() private void scanObjectScripts() { if ( ! SPManagerFrame.getParameters().getUseCache() ) - SPManagerFrame.getInstance().setRemoteStatusText( SPMTranslate.text( "scanningObjectScriptsFrom", new String[]{repository.toString()} ), 5000 ); + SPManagerFrame.getInstance().setRemoteStatusText( SPMTranslate.text( "scanningObjectScriptsFrom", repository ), 5000 ); else { String s = repository.toString(); s = s.substring(0, s.lastIndexOf('/')); s = s + "/cgi-bin/scripts.cgi?Scripts/Objects%20" + SPManagerPlugin.AOI_VERSION; - SPManagerFrame.getInstance().setRemoteStatusText( SPMTranslate.text( "scanningObjectScriptsFrom", new String[]{s} ), 5000 ); + SPManagerFrame.getInstance().setRemoteStatusText( SPMTranslate.text( "scanningObjectScriptsFrom", s ), 5000 ); } if ( statusDialog != null ) statusDialog.setText( SPMTranslate.text( "scanningObjectScripts" ) ); - objectInfo = new Vector(); + objectInfo = new Vector<>(); if ( SPManagerFrame.getParameters().getUseCache() ) { scanFiles( "Scripts/Objects", objectInfo ); @@ -266,17 +267,17 @@ private void scanObjectScripts() private void scanStartupScripts() { if ( ! SPManagerFrame.getParameters().getUseCache() ) - SPManagerFrame.getInstance().setRemoteStatusText( SPMTranslate.text( "scanningStartupScriptsFrom", new String[]{repository.toString()} ), 5000 ); + SPManagerFrame.getInstance().setRemoteStatusText( SPMTranslate.text( "scanningStartupScriptsFrom", repository ), 5000 ); else { String s = repository.toString(); s = s.substring(0, s.lastIndexOf('/')); s = s + "/cgi-bin/scripts.cgi?Scripts/Startup%20" + SPManagerPlugin.AOI_VERSION; - SPManagerFrame.getInstance().setRemoteStatusText( SPMTranslate.text( "scanningStartupScriptsFrom", new String[]{s} ), 5000 ); + SPManagerFrame.getInstance().setRemoteStatusText( SPMTranslate.text( "scanningStartupScriptsFrom", s ), 5000 ); } if ( statusDialog != null ) statusDialog.setText( SPMTranslate.text( "scanningStartupScripts" ) ); - startupInfo = new Vector(); + startupInfo = new Vector<>(); if ( SPManagerFrame.getParameters().getUseCache() ) { scanFiles( "Scripts/Startup", startupInfo ); @@ -309,7 +310,7 @@ private void scanFiles( URL from, List addTo, String suffix ) SPMObjectInfo info; boolean eligible; - Vector v = null; + Vector v = null; try { @@ -337,7 +338,7 @@ else if ( e instanceof FileNotFoundException ) } if ( v != null ) { // sort the list - String[] sarray = (String[]) v.toArray(EMPTY_STRING_ARRAY); + String[] sarray = v.toArray(EMPTY_STRING_ARRAY); Arrays.sort(sarray); for ( int i = 0; i < sarray.length; i++ ) { @@ -557,10 +558,10 @@ else if ( e instanceof FileNotFoundException ) int i, j; for (i = addTo.size()-1; i > 0; i--) { j = i; - right = (SPMObjectInfo) addTo.get(i); + right = addTo.get(i); while (j > 0) { - left = (SPMObjectInfo) addTo.get(j-1); + left = addTo.get(j-1); if (right.getName().compareTo(left.getName()) >= 0) break; j--; } @@ -583,7 +584,7 @@ else if ( e instanceof FileNotFoundException ) *@param lengthToDownload Description of the Parameter *@return Description of the Return Value */ - public static long downloadRemoteTextFile( URL from, String fileName, long size, StatusDialog status, long totalDownload, long downloadedLength, ArrayList errors ) + public static long downloadRemoteTextFile( URL from, String fileName, long size, StatusDialog status, long totalDownload, long downloadedLength, List errors ) { BufferedReader in = null; BufferedWriter file = null; @@ -692,7 +693,7 @@ public static long downloadRemoteTextFile( URL from, String fileName, long size, *@param downloadedLength Description of the Parameter *@return Description of the Return Value */ - public static long downloadRemoteBinaryFile( URL from, String fileName, long size, StatusDialog status, long totalDownload, long downloadedLength, ArrayList errors ) + public static long downloadRemoteBinaryFile( URL from, String fileName, long size, StatusDialog status, long totalDownload, long downloadedLength, List errors ) { System.out.println("download: size=" + size + "; total=" + totalDownload + @@ -826,9 +827,9 @@ public static long downloadRemoteBinaryFile( URL from, String fileName, long siz *@param is Description of the Parameter *@return Description of the Return Value */ - private Vector htmlFindFiles( InputStream is ) + private Vector htmlFindFiles( InputStream is ) { - Vector v = new Vector(); + Vector v = new Vector<>(); HtmlParserCallback callback = new HtmlParserCallback( v ); BufferedReader bufferedReader = null; @@ -854,9 +855,9 @@ private Vector htmlFindFiles( InputStream is ) *@param from Description of the Parameter *@return Description of the Return Value */ - private Vector htmlFindFilesVersioning( InputStream is, URL from ) + private Vector htmlFindFilesVersioning( InputStream is, URL from ) { - Vector v = new Vector(); + Vector v = new Vector<>(); HtmlVersioningParserCallback callback = new HtmlVersioningParserCallback( v, from ); BufferedReader bufferedReader = null; @@ -882,7 +883,7 @@ private Vector htmlFindFilesVersioning( InputStream is, URL from ) */ private class HtmlParserCallback extends HTMLEditorKit.ParserCallback { - private Vector v; + private Vector v; /** @@ -890,7 +891,7 @@ private class HtmlParserCallback extends HTMLEditorKit.ParserCallback * *@param v Description of the Parameter */ - public HtmlParserCallback( Vector v ) + public HtmlParserCallback( Vector v ) { this.v = v; } diff --git a/SPManager/src/artofillusion/spmanager/InstallSplitPane.java b/SPManager/src/artofillusion/spmanager/InstallSplitPane.java index 383f4c1..cf40d49 100644 --- a/SPManager/src/artofillusion/spmanager/InstallSplitPane.java +++ b/SPManager/src/artofillusion/spmanager/InstallSplitPane.java @@ -1,6 +1,6 @@ /* * Copyright 2004 Francois Guillet - * Changes copyright 2022 by Maksim Khramov + * Changes copyright 2022-2023 by Maksim Khramov * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later version. @@ -42,7 +42,7 @@ public class InstallSplitPane extends SPMSplitPane private boolean isDownloading; private SPMObjectInfo installNodeInfo; - protected ArrayList errors=null; + protected List errors=null; /** * Constructor for the InstallSplitPane object @@ -99,19 +99,13 @@ private void initialize() /** * Description of the Method */ + @Override protected void updateTree() { if ( setup ) { //get the scripts - fs.getRemoteInfo( - new Runnable() - { - public void run() - { - doCallbackUpdate(); - } - } ); + fs.getRemoteInfo(this::doCallbackUpdate); } } @@ -135,19 +129,13 @@ public void doCallbackUpdate() /** * Pane setup */ + @Override public void doSetup() { if ( !setup ) { //get the scripts - fs.getRemoteInfo( - new Runnable() - { - public void run() - { - doCallbackUpdate(); - } - } ); + fs.getRemoteInfo(this::doCallbackUpdate); } } @@ -287,6 +275,7 @@ public void doInstallAll() ( new Thread() { + @Override public void run() { installAllSelected( pluginsPath ); @@ -296,6 +285,7 @@ public void run() try { SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { voidSelection(); @@ -352,7 +342,7 @@ private void installAllSelected( TreePath path ) int count = tree.getChildNodeCount( path ); if ( count > 0 ) { - if (errors == null) errors = new ArrayList(128); + if (errors == null) errors = new ArrayList<>(128); else errors.clear(); boolean ignoreErrs = false; @@ -425,7 +415,7 @@ private void installAllSelected( TreePath path ) */ public void doInstallSingle() { - if (errors == null) errors = new ArrayList(128); + if (errors == null) errors = new ArrayList<>(128); else errors.clear(); installNodeInfo = getSelectedNodeInfo(); @@ -469,13 +459,14 @@ public void doInstallSingle() downloadedLength = 0; if ( lengthToDownload > 0 ) { - if (errors == null) errors = new ArrayList(128); + if (errors == null) errors = new ArrayList<>(128); else errors.clear(); status = new StatusDialog(SPManagerPlugin.getFrame()); ( new Thread() { + @Override public void run() { installFile( installNodeInfo ); @@ -484,6 +475,7 @@ public void run() try { SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { /* NTJ - replaced by restart() */ @@ -515,9 +507,9 @@ public void run() */ public void installFile( SPMObjectInfo nodeInfo ) { - HashMap transaction = new HashMap(32); + Map transaction = new HashMap<>(32); - if (errors == null) errors = new ArrayList(16); + if (errors == null) errors = new ArrayList<>(16); int errCount = errors.size(); File file = null; @@ -577,7 +569,7 @@ public void installFile( SPMObjectInfo nodeInfo ) int sep; for ( int j = 0; j < nodeInfo.files.length; ++j ) { - dest = (String) nodeInfo.destination.get(j); + dest = nodeInfo.destination.get(j); sep = dest.indexOf('/'); // build the destination path @@ -618,16 +610,11 @@ else if (dest.startsWith("$")) { } } - File orig; - Map.Entry entry; - Iterator iter = transaction.entrySet().iterator(); - while (iter.hasNext()) { + for(Map.Entry entry: transaction.entrySet()) { try { - entry = (Map.Entry) iter.next(); - - orig = (File) entry.getKey(); - update = (File) entry.getValue(); + File orig = entry.getKey(); + update = entry.getValue(); // if there are errors, just clean up... if (errors.size() > errCount) { @@ -797,7 +784,7 @@ public void scriptSelection( boolean deletable ) if (nodeInfo.refcount > 0) selectCB.setEnabled(false); // disable install single if script has dependents - Collection externals = nodeInfo.getExternals(); + Collection externals = nodeInfo.getExternals(); } super.scriptSelection( deletable ); } @@ -825,7 +812,7 @@ public void pluginSelection( boolean deletable ) if (nodeInfo.refcount > 0) selectCB.setEnabled(false); // disable install single if plugin has dependents - Collection externals = nodeInfo.getExternals(); + Collection externals = nodeInfo.getExternals(); } super.pluginSelection( deletable ); } @@ -859,14 +846,13 @@ public void showErrors() /** * show errors in a panel */ - public static void showErrors(ArrayList errs) + public static void showErrors(List errs) { BTextArea txt = new BTextArea(5, 45); txt.setEditable(false); txt.setWrapStyle(BTextArea.WRAP_WORD); - for (int i = 0; i < errs.size(); i++) - txt.append(errs.get(i) + "\n"); + errs.forEach(err -> txt.append(err + "\n")); BScrollPane detail = new BScrollPane(txt, BScrollPane.SCROLLBAR_NEVER, diff --git a/SPManager/src/artofillusion/spmanager/ManageSplitPane.java b/SPManager/src/artofillusion/spmanager/ManageSplitPane.java index ffc04dc..f6173f1 100644 --- a/SPManager/src/artofillusion/spmanager/ManageSplitPane.java +++ b/SPManager/src/artofillusion/spmanager/ManageSplitPane.java @@ -1,6 +1,6 @@ /* * Copyright 2004 Francois Guillet - * Changes copyright 2022 by Maksim Khramov + * Changes copyright 2022-2023 by Maksim Khramov * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later version. @@ -124,7 +124,7 @@ private void getFiles( TreePath addTo, List infos ) { String extType = extName.substring(extName.indexOf(':') + 1, extName.indexOf('=')).trim(); extName = extName.substring(0, extName.indexOf(':')); - SPMObjectInfo ext = getInfo(extName, (TreePath) pathMap.get(extType)); + SPMObjectInfo ext = getInfo(extName, pathMap.get(extType)); if (ext != null) ext.refcount++; } }); @@ -140,12 +140,12 @@ private void doDelete() SPMObjectInfo info = getSelectedNodeInfo(); if (info.refcount > 0) { - JOptionPane.showMessageDialog( (JFrame) SPManagerFrame.getInstance().getComponent(), SPMTranslate.text("cannotDeleteRequired"), SPMTranslate.text("Delete", info.fileName), JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(SPManagerFrame.getInstance().getComponent(), SPMTranslate.text("cannotDeleteRequired"), SPMTranslate.text("Delete", info.fileName), JOptionPane.ERROR_MESSAGE); return; } - int r = JOptionPane.showConfirmDialog( (JFrame) SPManagerFrame.getInstance().getComponent(), SPMTranslate.text( "permanentlyDelete", info.fileName ), + int r = JOptionPane.showConfirmDialog(SPManagerFrame.getInstance().getComponent(), SPMTranslate.text( "permanentlyDelete", info.fileName ), SPMTranslate.text( "warning" ), JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION ); if ( r == JOptionPane.YES_OPTION ) deleteFile( info ); @@ -195,12 +195,12 @@ private void deleteFile( SPMObjectInfo info ) } } - Collection externals = info.getExternals(); + Collection externals = info.getExternals(); String extName, extType; SPMObjectInfo ext; if (externals != null) { - for (Iterator iter = externals.iterator(); iter.hasNext(); ) { - extName = (String) iter.next(); + for (Iterator iter = externals.iterator(); iter.hasNext(); ) { + extName = iter.next(); if (extName.endsWith("= required")) { extType = extName.substring(extName.indexOf(':')+1, @@ -208,7 +208,7 @@ private void deleteFile( SPMObjectInfo info ) extName = extName.substring(0, extName.indexOf(':')); - ext = getInfo(extName, (TreePath)pathMap.get(extType)); + ext = getInfo(extName, pathMap.get(extType)); if (ext != null) ext.refcount--; } } @@ -219,11 +219,9 @@ private void deleteFile( SPMObjectInfo info ) voidSelection(); } - for ( int i = 0; i < splitPaneList.size(); ++i ) - { - if ( splitPaneList.elementAt( i ) != this ) - { - ( (SPMSplitPane) splitPaneList.elementAt( i ) ).doUpdate(); + for (SPMSplitPane pane : splitPaneList) { + if (pane != this) { + pane.doUpdate(); } } @@ -235,7 +233,7 @@ private void deleteFile( SPMObjectInfo info ) */ public void doDeleteAll() { - int r = JOptionPane.showConfirmDialog( (JFrame) SPManagerFrame.getInstance().getComponent(), SPMTranslate.text( "permanentlyDeleteAll" ), + int r = JOptionPane.showConfirmDialog(SPManagerFrame.getInstance().getComponent(), SPMTranslate.text( "permanentlyDeleteAll" ), SPMTranslate.text( "warning" ), JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION ); if ( r == JOptionPane.YES_OPTION ) { diff --git a/SPManager/src/artofillusion/spmanager/SPMObjectInfo.java b/SPManager/src/artofillusion/spmanager/SPMObjectInfo.java index a75beb2..2e029d9 100644 --- a/SPManager/src/artofillusion/spmanager/SPMObjectInfo.java +++ b/SPManager/src/artofillusion/spmanager/SPMObjectInfo.java @@ -1,6 +1,6 @@ /* * Copyright 2004 Francois Guillet - * Changes copyright 2022 by Maksim Khramov + * Changes copyright 2022-2023 by Maksim Khramov * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later version. @@ -92,7 +92,7 @@ public class SPMObjectInfo /** * local destination to copy to */ - public ArrayList destination; + public List destination; /** * sizes of the fileset files */ @@ -695,15 +695,14 @@ private void readInfoFromDocumentNode(Node script) { int i, j, filtType; String val, filtName, filtVal; - Iterator iter; - Map.Entry entry; + SPMParameters params = SPManagerFrame.getParameters(); if (changeLog == null) { changeLog = new Vector<>(16); details = new Vector<>(16); externals = new HashMap<>(16); - destination = new ArrayList(16); + destination = new ArrayList<>(16); actions = new HashMap<>(16); exports = new HashMap<>(32); } @@ -834,12 +833,7 @@ private void readInfoFromDocumentNode(Node script) if (val != null) setComments(val); // create the display lists - String extList = ""; - iter = externals.entrySet().iterator(); - while (iter.hasNext()) { - extList += (extList.length() > 0 ? "\n" : "") + - ((Map.Entry) iter.next()).getValue().toString(); - } + String extList = String.join("\n", externals.values()); setLog(SPMTranslate.text("flags"), flags, 1); setLog(SPMTranslate.text("otherFiles"), extList, 2); @@ -943,7 +937,7 @@ private void readInfoFromDocumentNode(Node script) if (fileSet != null) { NodeList filesList = fileSet.getChildNodes(); - Vector fileNames = new Vector(); + Vector fileNames = new Vector<>(); for (i = 0; i < filesList.getLength(); ++i ) { if( ! "file".equals( filesList.item(i).getNodeName() ) ) @@ -965,7 +959,7 @@ private void readInfoFromDocumentNode(Node script) { files = new String[ fileNames.size() ]; for (i = 0; i < files.length; ++i ) - files[i] = (String) fileNames.elementAt(i); + files[i] = fileNames.elementAt(i); httpFiles = new String[files.length]; fileSizes = new long[files.length]; for (i = 0; i < files.length; ++i ) diff --git a/SPManager/src/artofillusion/spmanager/SPMParameters.java b/SPManager/src/artofillusion/spmanager/SPMParameters.java index beb3804..e7a0fc4 100644 --- a/SPManager/src/artofillusion/spmanager/SPMParameters.java +++ b/SPManager/src/artofillusion/spmanager/SPMParameters.java @@ -1,6 +1,6 @@ /* * Copyright 2004 Francois Guillet - * Changes copyright 2022 by Maksim Khramov + * Changes copyright 2022-2023 by Maksim Khramov * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later version. @@ -471,10 +471,10 @@ public Map getFilters() * get a filter value */ public int getFilter(String name) - { return getFilterType((String) filters.get(name)); } + { return getFilterType(filters.get(name)); } public String getFilterString(String name) - { return (String) filters.get(name); } + { return filters.get(name); } /** * return the filter type corresponding to this filter value diff --git a/SPManager/src/artofillusion/spmanager/SPMSetupFrame.java b/SPManager/src/artofillusion/spmanager/SPMSetupFrame.java index 519bf99..36df8d5 100644 --- a/SPManager/src/artofillusion/spmanager/SPMSetupFrame.java +++ b/SPManager/src/artofillusion/spmanager/SPMSetupFrame.java @@ -1,6 +1,6 @@ /* * Copyright 2004 Francois Guillet - * Changes copyright 2022 by Maksim Khramov + * Changes copyright 2022-2023 by Maksim Khramov * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later version. @@ -69,7 +69,7 @@ public SPMSetupFrame( SPManagerFrame fr ) Map filters = parameters.getFilters(); if (filters.size() > 0) { - String[] keys = (String[]) filters.keySet().toArray(EMPTY_STRING_ARRAY); + String[] keys = filters.keySet().toArray(EMPTY_STRING_ARRAY); Arrays.sort(keys); String filtName, filtVal, filtType; @@ -80,7 +80,7 @@ public SPMSetupFrame( SPManagerFrame fr ) LayoutInfo left = new LayoutInfo(LayoutInfo.WEST,LayoutInfo.NONE); for (i = 0; i < keys.length; i++) { filtName = keys[i]; - filtVal = (String) filters.get(filtName); + filtVal = filters.get(filtName); System.out.println("filter: " + filtName + "=" + filtVal); @@ -164,7 +164,7 @@ public SPMSetupFrame( SPManagerFrame fr ) setContent( cc ); addEventLink( WindowClosingEvent.class, this, "doCancel" ); pack(); - ( (JDialog) getComponent() ).setLocationRelativeTo( frame.getComponent() ); + getComponent().setLocationRelativeTo( frame.getComponent() ); parameters.setChanged( false ); setVisible( true ); } @@ -328,7 +328,7 @@ private void doRepEntryChanged() { String text = repEntry.getText(); new URL( text ); - ( (JTextField) repEntry.getComponent() ).setForeground( Color.black ); + repEntry.getComponent().setForeground( Color.black ); String s[] = parameters.getRepositories(); addButton.setEnabled( true ); removeButton.setEnabled( false ); @@ -343,7 +343,7 @@ private void doRepEntryChanged() } catch ( MalformedURLException e ) { - ( (JTextField) repEntry.getComponent() ).setForeground( Color.red ); + repEntry.getComponent().setForeground( Color.red ); addButton.setEnabled( false ); removeButton.setEnabled( false ); } diff --git a/SPManager/src/artofillusion/spmanager/SPMSplitPane.java b/SPManager/src/artofillusion/spmanager/SPMSplitPane.java index 02a4f25..8da755d 100644 --- a/SPManager/src/artofillusion/spmanager/SPMSplitPane.java +++ b/SPManager/src/artofillusion/spmanager/SPMSplitPane.java @@ -1,6 +1,6 @@ /* * Copyright 2004 Francois Guillet - * Changes copyright 2022 by Maksim Khramov + * Changes copyright 2022-2023 by Maksim Khramov * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later version. @@ -77,7 +77,7 @@ public class SPMSplitPane extends BSplitPane /** * Description of the Field */ - protected static Vector splitPaneList; + protected static Vector splitPaneList; /** * Description of the Field @@ -90,7 +90,8 @@ public class SPMSplitPane extends BSplitPane protected boolean acceptsFileSelection = true; /** map of externals being processed - for loop detection */ - protected Hashtable extMap, pathMap; + protected Hashtable extMap; + protected Hashtable pathMap; private BScrollPane nameSP, descriptionSP; private BComboBox descSelect; @@ -173,7 +174,7 @@ private void initialize( String s ) if ( splitPaneList == null ) { - splitPaneList = new Vector(); + splitPaneList = new Vector<>(); } splitPaneList.add( this ); @@ -200,15 +201,12 @@ private void initialize( String s ) void processEvent() { int index = descSelect.getSelectedIndex(); if (descText != null && index < descText.size()) { - objectDescription.setText((String)descText.get(index)); + objectDescription.setText(descText.get(index)); - SwingUtilities.invokeLater(new Runnable() { - public void run() { - BScrollBar bar = - descriptionSP.getVerticalScrollBar(); - bar.setValue( bar.getMinimum() ); - } - } ); + SwingUtilities.invokeLater(() -> { + BScrollBar bar = descriptionSP.getVerticalScrollBar(); + bar.setValue( bar.getMinimum() ); + }); } } }); @@ -247,7 +245,7 @@ public void run() { objectName.setEditable( false ); objectDescription.setEditable( false ); - ( (JTree) tree.getComponent() ).putClientProperty( "JTree.lineStyle", "Angled" ); + tree.getComponent().putClientProperty( "JTree.lineStyle", "Angled" ); tree.setCellRenderer( new SPMTreeRenderer() ); tree.addEventLink( SelectionChangedEvent.class, this, "doTreeNodeSelection" ); tree.setMultipleSelectionEnabled( false ); @@ -265,8 +263,8 @@ public void run() { { public void mousePressed( MouseEvent e ) { - int selRow = ( (JTree) tree.getComponent() ).getRowForLocation( e.getX(), e.getY() ); - TreePath selPath = ( (JTree) tree.getComponent() ).getPathForLocation( e.getX(), e.getY() ); + int selRow = tree.getComponent() .getRowForLocation( e.getX(), e.getY() ); + TreePath selPath = tree.getComponent().getPathForLocation( e.getX(), e.getY() ); if ( selRow != -1 ) { if ( e.getClickCount() == 2 ) @@ -276,9 +274,9 @@ public void mousePressed( MouseEvent e ) } } }; - ( (JTree) tree.getComponent() ).addMouseListener( ml ); + tree.getComponent().addMouseListener( ml ); - pathMap = new Hashtable(8); + pathMap = new Hashtable<>(8); pathMap.put("plugin", pluginsPath); pathMap.put("library", pluginsPath); pathMap.put("script", scriptsPath); @@ -298,8 +296,8 @@ protected void updateTree() */ public void doTreeNodeSelection() { - TreePath[] tp = tree.getSelectedNodes(); - DefaultMutableTreeNode node = (DefaultMutableTreeNode) ( (JTree) tree.getComponent() ).getLastSelectedPathComponent(); + + DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getComponent().getLastSelectedPathComponent(); if ( node != null ) { if ( node.isLeaf() && ( !node.getAllowsChildren() ) ) @@ -334,8 +332,7 @@ public void doTreeNodeSelection() */ public SPMObjectInfo getSelectedNodeInfo() { - TreePath[] tp = tree.getSelectedNodes(); - DefaultMutableTreeNode node = (DefaultMutableTreeNode) ( (JTree) tree.getComponent() ).getLastSelectedPathComponent(); + DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getComponent().getLastSelectedPathComponent(); if ( node != null ) { if ( node.isLeaf() && ( !node.getAllowsChildren() ) ) @@ -378,17 +375,17 @@ private void displayObjectInfo( SPMObjectInfo info ) String extName, extType; String extList = "\n"; boolean missing = false; - Collection externals = info.getExternals(); + Collection externals = info.getExternals(); if (externals != null) { - for (Iterator iter = externals.iterator(); iter.hasNext(); ) { - ext = (String) iter.next(); + for (Iterator iter = externals.iterator(); iter.hasNext(); ) { + ext = iter.next(); if (ext.endsWith("= required")) { extName = ext.substring(0, ext.indexOf(':')); extType = ext.substring(ext.indexOf(':')+1, ext.indexOf('=')).trim(); - if (getInfo(extName, (TreePath) pathMap.get(extType)) == null) { + if (getInfo(extName, pathMap.get(extType)) == null) { //TODO check for externals with pathnames @@ -432,7 +429,7 @@ private void displayObjectInfo( SPMObjectInfo info ) objectName.setText( name ); if (descText != null && descText.size() > 0) - objectDescription.setText( (String) descText.get(0) ); + objectDescription.setText( descText.get(0) ); else objectDescription.setText(""); List changeLog = info.getChangeLog(); @@ -454,15 +451,10 @@ private void displayObjectInfo( SPMObjectInfo info ) descriptionSP.layoutChildren(); - SwingUtilities.invokeLater( - new Runnable() - { - public void run() - { - BScrollBar bar = descriptionSP.getVerticalScrollBar(); - bar.setValue( bar.getMinimum() ); - } - } ); + SwingUtilities.invokeLater(() -> { + BScrollBar bar = descriptionSP.getVerticalScrollBar(); + bar.setValue( bar.getMinimum() ); + }); } /** @@ -470,8 +462,7 @@ public void run() */ public SPMObjectInfo getInfo(String name, String type) { - TreePath path = (TreePath) pathMap.get(type); - return getInfo(name, path); + return getInfo(name, pathMap.get(type)); } /** @@ -557,14 +548,7 @@ public void doUpdate() */ public SPMSplitPane getManager() { - for ( int i = 0; i < splitPaneList.size(); ++i ) - { - if ( ( (SPMSplitPane) splitPaneList.elementAt( i ) ).workMode == BROWSE ) - { - return (SPMSplitPane) splitPaneList.elementAt( i ); - } - } - return null; + return splitPaneList.stream().filter(pane -> pane.workMode == BROWSE).findFirst().orElse(null); } @@ -658,7 +642,7 @@ protected void notifyObjectInfoSelection( SPMObjectInfo info ) */ protected void selectExternals( SPMObjectInfo info) { - if (extMap == null) extMap = new Hashtable(32); + if (extMap == null) extMap = new Hashtable<>(32); if (extMap.containsKey(info)) { System.out.println("SPMSplitPane: dependency loop detected: " + @@ -668,20 +652,20 @@ protected void selectExternals( SPMObjectInfo info) extMap.put(info, info); - Collection externals = info.getExternals(); + Collection externals = info.getExternals(); if (externals == null || externals.size() == 0) return; String extName, extType; SPMObjectInfo ext; - for (Iterator iter = externals.iterator(); iter.hasNext(); ) { - extName = (String) iter.next(); + for (Iterator iter = externals.iterator(); iter.hasNext(); ) { + extName = iter.next(); if (extName.endsWith("= required")) { extType = extName.substring(extName.indexOf(':')+1, extName.indexOf('=')).trim(); extName = extName.substring(0, extName.indexOf(':')); - ext = getInfo(extName, (TreePath) pathMap.get(extType)); + ext = getInfo(extName, pathMap.get(extType)); if (ext != null) { if (info.isSelected()) ext.refcount++; diff --git a/SPManager/src/artofillusion/spmanager/SPMTranslate.java b/SPManager/src/artofillusion/spmanager/SPMTranslate.java index f920ef3..6b60f00 100644 --- a/SPManager/src/artofillusion/spmanager/SPMTranslate.java +++ b/SPManager/src/artofillusion/spmanager/SPMTranslate.java @@ -1,6 +1,7 @@ /* * Copyright (C) 2003 by Francois Guillet * Copyright (C) 2003 by Peter Eastman for original Translate.java code + * 2023 by Maksim Khramov * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later version. @@ -12,15 +13,10 @@ import java.awt.*; import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.*; import java.text.*; import java.util.*; -import java.util.zip.*; import buoy.event.*; import buoy.widget.*; -import artofillusion.*; -import java.io.*; /** * This class extends AoI Translate Class so that i) the spmanager properties @@ -119,7 +115,7 @@ public static BMenuItem bMenuItem( String name, java.lang.Object target, String *@param method Description of the Parameter *@return Description of the Return Value */ - public static BMenuItem bMenuItem( String name, java.lang.Class eventType, java.lang.Object target, String method ) + public static BMenuItem bMenuItem( String name, Class eventType, java.lang.Object target, String method ) { String command = name; BMenuItem item = null; @@ -202,7 +198,7 @@ public static BButton bButton( String name, java.lang.Object target, String meth *@param method Description of the Parameter *@return Description of the Return Value */ - public static BButton bButton( String name, java.lang.Class eventType, Object target, String method ) + public static BButton bButton( String name, Class eventType, Object target, String method ) { String command = name; try diff --git a/SPManager/src/artofillusion/spmanager/SPManagerPlugin.java b/SPManager/src/artofillusion/spmanager/SPManagerPlugin.java index ac40454..43f46a3 100644 --- a/SPManager/src/artofillusion/spmanager/SPManagerPlugin.java +++ b/SPManager/src/artofillusion/spmanager/SPManagerPlugin.java @@ -1,6 +1,6 @@ /* * Copyright 2004 Francois Guillet - * Changes copyright 2022 by Maksim Khramov + * Changes copyright 2022-2023 by Maksim Khramov * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later version. @@ -22,6 +22,7 @@ import java.io.*; import java.net.*; import java.lang.reflect.*; +import java.util.List; /** * The Plugin corresponding to the SPManager @@ -43,8 +44,6 @@ public class SPManagerPlugin implements Plugin public static final int DOWNLOAD = -1; private static SPManagerFrame spmFrame; - - protected static HashMap plugins; /** * Description of the Method @@ -75,33 +74,32 @@ public void processMessage( int message, Object args[] ) System.out.println("SPManager starting..."); // get details of plugin classloaders - int i, j, idx; + int i, j; URL urlList[]; - ArrayList aoiloaders; + ClassLoader ldr = null; URLClassLoader urlldr = null; SearchlistClassLoader searchldr = null; Object obj; - java.util.List list = PluginRegistry.getPluginClassLoaders(); - HashMap loaders = new HashMap(list.size()); - for (i = 0; i < list.size(); i++) { - obj = list.get(i); + + Map loaders = new HashMap<>(); + for (ClassLoader loader: PluginRegistry.getPluginClassLoaders()) { + obj = loader; if (obj instanceof URLClassLoader) urlList = ((URLClassLoader) obj).getURLs(); else urlList = ((SearchlistClassLoader) obj).getURLs(); if (urlList.length > 0) - loaders.put(urlList[0], obj); + loaders.put(urlList[0], (ClassLoader)obj); } - URL[] urlarg = new URL[1]; - Class[] sig = new Class[] { URL.class }; + Method addUrl = null; try { - addUrl = URLClassLoader.class.getDeclaredMethod("addURL", sig); + addUrl = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); addUrl.setAccessible(true); } catch (Exception e) { System.out.println("Error getting addURL method: " + e); @@ -110,7 +108,7 @@ public void processMessage( int message, Object args[] ) // get details of all local plugins SPMObjectInfo info; StringBuffer errs = null; - Class plugType; + File files[], urlfile; URL url; @@ -186,7 +184,7 @@ else if (addUrl != null) { else System.out.println("Could not add path" + url); } else if ("import".equalsIgnoreCase(value)) { - ldr = (ClassLoader) loaders.get(url); + ldr = loaders.get(url); if (key.length == 1) { if (obj != null) searchldr.add(ldr); @@ -262,7 +260,7 @@ else if ("import".equalsIgnoreCase(value)) { public void init() { - ArrayList err = new ArrayList(8); + List err = new ArrayList<>(8); System.out.println("SPManager: java temp dir is " + System.getProperty("java.io.tmpdir")); @@ -613,8 +611,9 @@ else if (cmd.equals("install")) { setText(SPMTranslate.text("downloading", info.getName())); pack(); - final ArrayList errs = new ArrayList(); + final List errs = new ArrayList<>(); worker = new Thread() { + @Override public void run() { long total = info.getTotalLength();