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 3 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
27 changes: 10 additions & 17 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 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 Down Expand Up @@ -172,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 );
Expand Down Expand Up @@ -308,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<SPMObjectInfo> addTo, String suffix )
{
SPMObjectInfo info;
boolean eligible;
Expand Down Expand Up @@ -442,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<SPMObjectInfo> addTo )
{

URL cgiUrl = null;
Expand Down Expand Up @@ -957,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<String> v;
private final URL from;


/**
Expand All @@ -967,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<String> v, URL from )
{
this.v = v;
this.from = from;
Expand Down
42 changes: 14 additions & 28 deletions SPManager/src/artofillusion/spmanager/InstallSplitPane.java
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -9,21 +10,16 @@
*/
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.util.List;
import java.net.*;
import java.text.*;


/**
Expand Down Expand Up @@ -197,19 +193,17 @@ 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<SPMObjectInfo> infos, List<SPMObjectInfo> managerInfoList )
{
DefaultMutableTreeNode tn;
SPMObjectInfo info;

SPMObjectInfo managerInfo;
boolean eligible;
TreeMap map = new TreeMap();
TreeMap<String, SPMObjectInfo> 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;

Expand All @@ -218,16 +212,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() );
Expand Down Expand Up @@ -266,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));
});

}


Expand Down
23 changes: 9 additions & 14 deletions SPManager/src/artofillusion/spmanager/LocalSPMFileSystem.java
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
{
Expand Down Expand Up @@ -58,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<SPMObjectInfo> 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));
}
}
}
}

Expand Down
54 changes: 20 additions & 34 deletions SPManager/src/artofillusion/spmanager/ManageSplitPane.java
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -13,10 +14,9 @@
import javax.swing.*;
import javax.swing.tree.*;
import buoy.widget.*;
import buoy.event.*;
import java.io.*;
import java.util.*;
import java.util.zip.*;
import java.util.List;

/**
* Description of the Class
Expand Down Expand Up @@ -106,41 +106,27 @@ 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<SPMObjectInfo> 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<String> 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++;
}
});
}
}

Expand Down
Loading