update dev300-m58
[ooovba.git] / scripting / workben / installer / IdeUpdater.java
blobaff23fd92d393d35c875eaaf57be060501e1c8e7
1 package installer;
3 import java.io.*;
4 import java.util.*;
5 import java.util.jar.*;
6 //import org.xml.sax.*;
7 //import org.w3c.dom.*;
8 //import javax.xml.parsers.*;
9 import java.net.URL;
10 import java.net.JarURLConnection;
11 //import javax.xml.parsers.*;
12 import javax.swing.*;
14 /**
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>
18 * objects.
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;
62 progressBar=pBar;
63 progressBar.setStringPainted(true);
64 }// XmlUpdater
67 public boolean checkStop()
69 if (internalThread == Thread.currentThread())
70 return false;
71 return true;
72 }// checkStop
75 public void checkSuspend()
77 if (threadSuspended)
79 synchronized(this)
81 while (threadSuspended)
83 try {
84 wait();
85 } catch (InterruptedException eInt) {
86 //...
91 }// checkSuspend
94 public void setSuspend()
96 threadSuspended = true;
97 }// setSuspend
100 public void setResume()
102 threadSuspended = false;
103 notify();
104 }// setResume
107 public void setStop()
109 internalThread = null;
110 }// setStop
113 public void run() {
115 //InputStream istream;
116 //URL url;
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))
128 onInstallComplete();
129 return;
132 else {
133 if (!zd.extractEntry("ide/idesupport.jar",installPath, statusLabel))
135 onInstallComplete();
136 return;
138 if (!zd.extractEntry("ide/OfficeScripting.jar",installPath, statusLabel))
140 onInstallComplete();
141 return;
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);
151 onInstallComplete();
153 }// run
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
172 }// XmlUpdater class