5 import java
.util
.jar
.*;
6 //import org.xml.sax.*;
7 //import org.w3c.dom.*;
8 //import javax.xml.parsers.*;
10 import java
.net
.JarURLConnection
;
11 //import javax.xml.parsers.*;
15 * The <code>XmlUpdater</code> pulls a META-INF/converter.xml
16 * file out of a jar file and parses it, providing access to this
17 * information in a <code>Vector</code> of <code>ConverterInfo</code>
20 * @author Aidan Butler
22 public class IdeUpdater
extends Thread
{
24 private String classesPath
= null;
25 private String jarfilename
;
26 private String installPath
;
28 private JLabel statusLabel
;
30 private Vector listeners
;
31 private Thread internalThread
;
32 private boolean threadSuspended
;
33 private JProgressBar progressBar
;
35 private boolean isNetbeansPath
= false;
38 public IdeUpdater(String installPath
, JLabel statusLabel
, JProgressBar pBar
) {
40 if (installPath
.endsWith(File
.separator
) == false)
41 installPath
+= File
.separator
;
43 //File jeditLauncher = new File( installPath + "jedit.jar" );
44 File netbeansLauncher
= new File( installPath
+ "bin" );
46 if( netbeansLauncher
.isDirectory() ) {
47 isNetbeansPath
= true;
48 installPath
= installPath
+"modules" + File
.separator
;
51 else if( jeditLauncher.isFile() ){
52 isNetbeansPath = false;
53 installPath = installPath + "jars" + File.separator;
57 System
.out
.println( "IdeUpdater installPath is " + installPath
+ " isNetbeansPath is " + isNetbeansPath
);
58 this.installPath
= installPath
;
59 this.statusLabel
= statusLabel
;
60 listeners
= new Vector();
61 threadSuspended
= false;
63 progressBar
.setStringPainted(true);
67 public boolean checkStop()
69 if (internalThread
== Thread
.currentThread())
75 public void checkSuspend()
81 while (threadSuspended
)
85 } catch (InterruptedException eInt
) {
94 public void setSuspend()
96 threadSuspended
= true;
100 public void setResume()
102 threadSuspended
= false;
107 public void setStop()
109 internalThread
= null;
115 //InputStream istream;
117 //String fileName = null;
119 internalThread
= Thread
.currentThread();
121 progressBar
.setString("Unzipping Required Files");
122 ZipData zd
= new ZipData("SFrameworkInstall.jar");
124 // Adding IDE support
125 if( isNetbeansPath
) {
126 if (!zd
.extractEntry("ide/office.jar",installPath
, statusLabel
))
133 if (!zd
.extractEntry("ide/idesupport.jar",installPath
, statusLabel
))
138 if (!zd
.extractEntry("ide/OfficeScripting.jar",installPath
, statusLabel
))
145 //System.out.println("About to call register");
146 //Register.register(installPath+File.separator, statusLabel, progressBar);
148 statusLabel
.setText("Installation Complete");
149 progressBar
.setString("Installation Complete");
150 progressBar
.setValue(10);
156 public void addInstallListener(InstallListener listener
)
158 listeners
.addElement(listener
);
159 }// addInstallListener
162 private void onInstallComplete()
164 Enumeration e
= listeners
.elements();
165 while (e
.hasMoreElements())
167 InstallListener listener
= (InstallListener
)e
.nextElement();
168 listener
.installationComplete(null);
170 }// onInstallComplete