bump product version to 4.1.6.2
[LibreOffice.git] / scripting / workben / installer / IdeUpdater.java
blob63cb0c2d389ba5b3cf11c8e050c040345dc1afa9
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package installer;
21 import java.io.*;
22 import java.util.*;
23 import javax.swing.*;
25 /**
26 * The <code>XmlUpdater</code> pulls a META-INF/converter.xml
27 * file out of a jar file and parses it, providing access to this
28 * information in a <code>Vector</code> of <code>ConverterInfo</code>
29 * objects.
31 public class IdeUpdater extends Thread {
33 private String classesPath = null;
34 private String jarfilename;
35 private String installPath;
37 private JLabel statusLabel;
39 private ArrayList<InstallListener> listeners;
40 private Thread internalThread;
41 private boolean threadSuspended;
42 private JProgressBar progressBar;
44 private boolean isNetbeansPath = false;
47 public IdeUpdater(String installPath, JLabel statusLabel, JProgressBar pBar) {
49 if (installPath.endsWith(File.separator) == false)
50 installPath += File.separator;
52 File netbeansLauncher = new File( installPath + "bin" );
54 if( netbeansLauncher.isDirectory() ) {
55 isNetbeansPath = true;
56 installPath = installPath +"modules" + File.separator;
59 System.out.println( "IdeUpdater installPath is " + installPath + " isNetbeansPath is " + isNetbeansPath );
60 this.installPath = installPath;
61 this.statusLabel = statusLabel;
62 listeners = new ArrayList<InstallListener>();
63 threadSuspended = false;
64 progressBar=pBar;
65 progressBar.setStringPainted(true);
66 }// XmlUpdater
69 public boolean checkStop()
71 if (internalThread == Thread.currentThread())
72 return false;
73 return true;
74 }// checkStop
77 public void checkSuspend()
79 if (threadSuspended)
81 synchronized(this)
83 while (threadSuspended)
85 try {
86 wait();
87 } catch (InterruptedException eInt) {
88 //...
93 }// checkSuspend
96 public void setSuspend()
98 threadSuspended = true;
99 }// setSuspend
102 public void setResume()
104 threadSuspended = false;
105 notify();
106 }// setResume
109 public void setStop()
111 internalThread = null;
112 }// setStop
115 public void run() {
117 internalThread = Thread.currentThread();
119 progressBar.setString("Unzipping Required Files");
120 ZipData zd = new ZipData("SFrameworkInstall.jar");
122 // Adding IDE support
123 if( isNetbeansPath ) {
124 if (!zd.extractEntry("ide/office.jar",installPath, statusLabel))
126 onInstallComplete();
127 return;
130 else {
131 if (!zd.extractEntry("ide/idesupport.jar",installPath, statusLabel))
133 onInstallComplete();
134 return;
136 if (!zd.extractEntry("ide/OfficeScripting.jar",installPath, statusLabel))
138 onInstallComplete();
139 return;
143 statusLabel.setText("Installation Complete");
144 progressBar.setString("Installation Complete");
145 progressBar.setValue(10);
146 onInstallComplete();
148 }// run
151 public void addInstallListener(InstallListener listener)
153 listeners.add(listener);
154 }// addInstallListener
157 private void onInstallComplete()
159 for( InstallListener l : listeners)
161 l.installationComplete(null);
163 }// onInstallComplete
165 }// XmlUpdater class