1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
package installer;
import java.io.*;
import java.util.*;
import java.util.jar.*;
//import org.xml.sax.*;
//import org.w3c.dom.*;
//import javax.xml.parsers.*;
import java.net.URL;
import java.net.JarURLConnection;
//import javax.xml.parsers.*;
import javax.swing.*;
/**
* The <code>XmlUpdater</code> pulls a META-INF/converter.xml
* file out of a jar file and parses it, providing access to this
* information in a <code>Vector</code> of <code>ConverterInfo</code>
* objects.
*
* @author Aidan Butler
*/
public class IdeUpdater extends Thread {
private String classesPath = null;
private String jarfilename;
private String installPath;
private JLabel statusLabel;
private Vector listeners;
private Thread internalThread;
private boolean threadSuspended;
private JProgressBar progressBar;
private boolean isNetbeansPath = false;
public IdeUpdater(String installPath, JLabel statusLabel, JProgressBar pBar) {
if (installPath.endsWith(File.separator) == false)
installPath += File.separator;
//File jeditLauncher = new File( installPath + "jedit.jar" );
File netbeansLauncher = new File( installPath + "bin" );
if( netbeansLauncher.isDirectory() ) {
isNetbeansPath = true;
installPath = installPath +"modules" + File.separator;
}
/*
else if( jeditLauncher.isFile() ){
isNetbeansPath = false;
installPath = installPath + "jars" + File.separator;
}
*/
System.out.println( "IdeUpdater installPath is " + installPath + " isNetbeansPath is " + isNetbeansPath );
this.installPath = installPath;
this.statusLabel = statusLabel;
listeners = new Vector();
threadSuspended = false;
progressBar=pBar;
progressBar.setStringPainted(true);
}// XmlUpdater
public boolean checkStop()
{
if (internalThread == Thread.currentThread())
return false;
return true;
}// checkStop
public void checkSuspend()
{
if (threadSuspended)
{
synchronized(this)
{
while (threadSuspended)
{
try {
wait();
} catch (InterruptedException eInt) {
//...
}
}
}
}
}// checkSuspend
public void setSuspend()
{
threadSuspended = true;
}// setSuspend
public void setResume()
{
threadSuspended = false;
notify();
}// setResume
public void setStop()
{
internalThread = null;
}// setStop
public void run() {
//InputStream istream;
//URL url;
//String fileName = null;
internalThread = Thread.currentThread();
progressBar.setString("Unzipping Required Files");
ZipData zd = new ZipData("SFrameworkInstall.jar");
// Adding IDE support
if( isNetbeansPath ) {
if (!zd.extractEntry("ide/office.jar",installPath, statusLabel))
{
onInstallComplete();
return;
}
}
else {
if (!zd.extractEntry("ide/idesupport.jar",installPath, statusLabel))
{
onInstallComplete();
return;
}
if (!zd.extractEntry("ide/OfficeScripting.jar",installPath, statusLabel))
{
onInstallComplete();
return;
}
}
//System.out.println("About to call register");
//Register.register(installPath+File.separator, statusLabel, progressBar);
statusLabel.setText("Installation Complete");
progressBar.setString("Installation Complete");
progressBar.setValue(10);
onInstallComplete();
}// run
public void addInstallListener(InstallListener listener)
{
listeners.addElement(listener);
}// addInstallListener
private void onInstallComplete()
{
Enumeration e = listeners.elements();
while (e.hasMoreElements())
{
InstallListener listener = (InstallListener)e.nextElement();
listener.installationComplete(null);
}
}// onInstallComplete
}// XmlUpdater class
|