diff options
author | neilm <neilm@openoffice.org> | 2002-11-15 12:26:54 +0000 |
---|---|---|
committer | neilm <neilm@openoffice.org> | 2002-11-15 12:26:54 +0000 |
commit | 4701a503d0bb1fc51e686e1990050edfdb014ebc (patch) | |
tree | 1a27af2c9eb718b9bfa6aa771815db96ac2b289b /scripting/workben/installer/IdeUpdater.java | |
parent | 4fa9cce70a2d353353d4b392a280cad67fb84430 (diff) |
Initial Import of support for Netbeans and jEdit installation
Diffstat (limited to 'scripting/workben/installer/IdeUpdater.java')
-rw-r--r-- | scripting/workben/installer/IdeUpdater.java | 176 |
1 files changed, 176 insertions, 0 deletions
diff --git a/scripting/workben/installer/IdeUpdater.java b/scripting/workben/installer/IdeUpdater.java new file mode 100644 index 000000000000..def08e6d7a63 --- /dev/null +++ b/scripting/workben/installer/IdeUpdater.java @@ -0,0 +1,176 @@ +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) { + + File jeditLauncher = new File( installPath + File.separator + "jedit.jar" ); + File netbeansLauncher = null; + + String opSys =System.getProperty("os.name"); + if (opSys.indexOf("Windows") != -1) { + netbeansLauncher = new File( installPath + "bin" + File.separator + "runide.exe" ); + } + else { + netbeansLauncher = new File( installPath + "bin" + File.separator + "runide.sh" ); + } + + if( netbeansLauncher.isFile() ) { + 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 |