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 .
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>
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;
65 progressBar
.setStringPainted(true);
69 public boolean checkStop()
71 if (internalThread
== Thread
.currentThread())
77 public void checkSuspend()
83 while (threadSuspended
)
87 } catch (InterruptedException eInt
) {
96 public void setSuspend()
98 threadSuspended
= true;
102 public void setResume()
104 threadSuspended
= false;
109 public void setStop()
111 internalThread
= null;
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
))
131 if (!zd
.extractEntry("ide/idesupport.jar",installPath
, statusLabel
))
136 if (!zd
.extractEntry("ide/OfficeScripting.jar",installPath
, statusLabel
))
143 statusLabel
.setText("Installation Complete");
144 progressBar
.setString("Installation Complete");
145 progressBar
.setValue(10);
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