Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spm typed members #9

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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, [email protected]
* $Id: Exp $
*
Expand Down Expand Up @@ -39,9 +40,10 @@

public class PostInstall implements Plugin
{
protected ArrayList ok, err;
protected List<String> ok, err;
protected static File tempDir = null;

@Override
public void processMessage(int msg, Object[] args)
{
int i, k;
Expand Down Expand Up @@ -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);
Expand All @@ -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<String> 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()) {
Expand Down Expand Up @@ -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<String> ok, List<String> err)
{
File from, to;
File plugin, update;
Expand Down
92 changes: 44 additions & 48 deletions SPManager/src/artofillusion/spmanager/HttpSPMFileSystem.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright 2004 Francois Guillet
* 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.
Expand All @@ -9,27 +10,19 @@
*/
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.*;
import java.util.*;
import java.util.List;
import java.util.zip.*;
import java.net.*;
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.*;
Expand All @@ -47,7 +40,7 @@ public class HttpSPMFileSystem extends SPMFileSystem
private URL repository;
private HttpStatusDialog statusDialog;
private boolean isDownloading;
private Vector callbacks;
private Vector<Runnable> callbacks;
private Document pluginsDoc, objectsDoc, startupDoc, toolsDoc;
private File file;

Expand Down Expand Up @@ -78,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;
Expand All @@ -97,6 +90,7 @@ public void setRepository( URL rep )
*
*@param cb Callback to call when done
*/
@Override
public void getRemoteInfo( Runnable cb )
{
if ( !initialized )
Expand All @@ -105,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();
Expand All @@ -123,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;
}
Expand Down Expand Up @@ -162,17 +156,17 @@ 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" ) );
pluginsInfo = new Vector();
pluginsInfo = new Vector<>();
if ( SPManagerFrame.getParameters().getUseCache() )
{
scanFiles( "Plugins", pluginsInfo );
Expand All @@ -199,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 );
Expand All @@ -236,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 );
Expand All @@ -273,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 );
Expand All @@ -308,15 +302,15 @@ 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<SPMObjectInfo> addTo, String suffix )
{
SPMObjectInfo info;
boolean eligible;

Vector v = null;
Vector<String> v = null;

try
{
Expand Down Expand Up @@ -344,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++ )
{
Expand Down Expand Up @@ -442,9 +436,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<SPMObjectInfo> addTo )
{

URL cgiUrl = null;
Expand Down Expand Up @@ -564,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--;
}
Expand All @@ -590,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<String> errors )
{
BufferedReader in = null;
BufferedWriter file = null;
Expand Down Expand Up @@ -699,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<String> errors )
{
System.out.println("download: size=" + size +
"; total=" + totalDownload +
Expand Down Expand Up @@ -833,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<String> htmlFindFiles( InputStream is )
{
Vector v = new Vector();
Vector<String> v = new Vector<>();

HtmlParserCallback callback = new HtmlParserCallback( v );
BufferedReader bufferedReader = null;
Expand All @@ -861,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<String> htmlFindFilesVersioning( InputStream is, URL from )
{
Vector v = new Vector();
Vector<String> v = new Vector<>();

HtmlVersioningParserCallback callback = new HtmlVersioningParserCallback( v, from );
BufferedReader bufferedReader = null;
Expand All @@ -889,15 +883,15 @@ private Vector htmlFindFilesVersioning( InputStream is, URL from )
*/
private class HtmlParserCallback extends HTMLEditorKit.ParserCallback
{
private Vector v;
private Vector<String> v;


/**
* Constructor for the HtmlParserCallback object
*
*@param v Description of the Parameter
*/
public HtmlParserCallback( Vector v )
public HtmlParserCallback( Vector<String> v )
{
this.v = v;
}
Expand Down Expand Up @@ -957,8 +951,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<String> v;
private final URL from;


/**
Expand All @@ -967,7 +961,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<String> v, URL from )
{
this.v = v;
this.from = from;
Expand All @@ -980,6 +974,7 @@ public HtmlVersioningParserCallback( Vector 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 );
Expand Down Expand Up @@ -1039,6 +1034,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 );
Expand Down
Loading