1*cd519653SAndrew Rist /**************************************************************
2*cd519653SAndrew Rist  *
3*cd519653SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*cd519653SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*cd519653SAndrew Rist  * distributed with this work for additional information
6*cd519653SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*cd519653SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*cd519653SAndrew Rist  * "License"); you may not use this file except in compliance
9*cd519653SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*cd519653SAndrew Rist  *
11*cd519653SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*cd519653SAndrew Rist  *
13*cd519653SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*cd519653SAndrew Rist  * software distributed under the License is distributed on an
15*cd519653SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cd519653SAndrew Rist  * KIND, either express or implied.  See the License for the
17*cd519653SAndrew Rist  * specific language governing permissions and limitations
18*cd519653SAndrew Rist  * under the License.
19*cd519653SAndrew Rist  *
20*cd519653SAndrew Rist  *************************************************************/
21*cd519653SAndrew Rist 
22cdf0e10cSrcweir package installer;
23cdf0e10cSrcweir 
24cdf0e10cSrcweir import java.io.*;
25cdf0e10cSrcweir import java.util.*;
26cdf0e10cSrcweir import java.util.jar.*;
27cdf0e10cSrcweir import java.net.URL;
28cdf0e10cSrcweir import java.net.JarURLConnection;
29cdf0e10cSrcweir import javax.swing.*;
30cdf0e10cSrcweir 
31cdf0e10cSrcweir /**
32cdf0e10cSrcweir  *
33cdf0e10cSrcweir  *
34cdf0e10cSrcweir  *  @author  Aidan Butler
35cdf0e10cSrcweir  */
36cdf0e10cSrcweir public class XmlUpdater extends Thread {
37cdf0e10cSrcweir 
38cdf0e10cSrcweir     private String classesPath = null;
39cdf0e10cSrcweir     private String jarfilename;
40cdf0e10cSrcweir     private String installPath;
41cdf0e10cSrcweir     private boolean netInstall;
42cdf0e10cSrcweir     private boolean bindingsInstall;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir     private JLabel statusLabel;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir     private Vector listeners;
47cdf0e10cSrcweir     private Thread internalThread;
48cdf0e10cSrcweir     private boolean threadSuspended;
49cdf0e10cSrcweir     private JProgressBar progressBar;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir     private final String[] bakFiles =
52cdf0e10cSrcweir     {
53cdf0e10cSrcweir         "writermenubar.xml",
54cdf0e10cSrcweir         "writerkeybinding.xml",
55cdf0e10cSrcweir         "calcmenubar.xml",
56cdf0e10cSrcweir         "calckeybinding.xml",
57cdf0e10cSrcweir         "impressmenubar.xml",
58cdf0e10cSrcweir         "impresskeybinding.xml",
59cdf0e10cSrcweir         "drawmenubar.xml",
60cdf0e10cSrcweir         "drawkeybinding.xml",
61cdf0e10cSrcweir         "eventbindings.xml",
62cdf0e10cSrcweir         "META-INF" + File.separator + "manifest.xml"
63cdf0e10cSrcweir     };
64cdf0e10cSrcweir 
65cdf0e10cSrcweir     private final String[] dirs =
66cdf0e10cSrcweir     {
67cdf0e10cSrcweir         "java" + File.separator + "Highlight",
68cdf0e10cSrcweir         "java" + File.separator + "MemoryUsage",
69cdf0e10cSrcweir         "java" + File.separator + "ScriptFrmwrkHelper",
70cdf0e10cSrcweir         "java" + File.separator + "debugger",
71cdf0e10cSrcweir         "java" + File.separator + "debugger" + File.separator + "rhino",
72cdf0e10cSrcweir         "beanshell" + File.separator + "InteractiveBeanShell",
73cdf0e10cSrcweir         "beanshell" + File.separator + "Highlight",
74cdf0e10cSrcweir         "beanshell" + File.separator + "MemoryUsage",
75cdf0e10cSrcweir         "javascript" + File.separator + "ExportSheetsToHTML"
76cdf0e10cSrcweir     };
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     private final String[] names =
79cdf0e10cSrcweir     {
80cdf0e10cSrcweir         "java/Highlight/HighlightUtil.java",
81cdf0e10cSrcweir         "java/Highlight/HighlightText.java",
82cdf0e10cSrcweir         "java/Highlight/Highlight.jar",
83cdf0e10cSrcweir         "java/Highlight/parcel-descriptor.xml",
84cdf0e10cSrcweir         "java/MemoryUsage/MemoryUsage.java",
85cdf0e10cSrcweir         "java/MemoryUsage/MemoryUsage.class",
86cdf0e10cSrcweir         "java/MemoryUsage/parcel-descriptor.xml",
87cdf0e10cSrcweir         "java/MemoryUsage/ExampleSpreadSheet.sxc",
88cdf0e10cSrcweir         "java/ScriptFrmwrkHelper/parcel-descriptor.xml",
89cdf0e10cSrcweir         "java/ScriptFrmwrkHelper/ScriptFrmwrkHelper.java",
90cdf0e10cSrcweir         "java/ScriptFrmwrkHelper/ScriptFrmwrkHelper.class",
91cdf0e10cSrcweir         "java/ScriptFrmwrkHelper/ScriptFrmwrkHelper.jar",
92cdf0e10cSrcweir         "java/debugger/debugger.jar",
93cdf0e10cSrcweir         "java/debugger/OOBeanShellDebugger.java",
94cdf0e10cSrcweir         "java/debugger/OOScriptDebugger.java",
95cdf0e10cSrcweir         "java/debugger/DebugRunner.java",
96cdf0e10cSrcweir         "java/debugger/OORhinoDebugger.java",
97cdf0e10cSrcweir         "java/debugger/parcel-descriptor.xml",
98cdf0e10cSrcweir         "java/debugger/rhino/Main.java",
99cdf0e10cSrcweir         "beanshell/InteractiveBeanShell/parcel-descriptor.xml",
100cdf0e10cSrcweir         "beanshell/InteractiveBeanShell/interactive.bsh",
101cdf0e10cSrcweir         "beanshell/Highlight/parcel-descriptor.xml",
102cdf0e10cSrcweir         "beanshell/Highlight/highlighter.bsh",
103cdf0e10cSrcweir         "beanshell/MemoryUsage/parcel-descriptor.xml",
104cdf0e10cSrcweir         "beanshell/MemoryUsage/memusage.bsh",
105cdf0e10cSrcweir         "javascript/ExportSheetsToHTML/parcel-descriptor.xml",
106cdf0e10cSrcweir         "javascript/ExportSheetsToHTML/exportsheetstohtml.js"
107cdf0e10cSrcweir     };
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 
XmlUpdater(String installPath, JLabel statusLabel,JProgressBar pBar, boolean netInstall, boolean bindingsInstall)110cdf0e10cSrcweir     public XmlUpdater(String installPath, JLabel statusLabel,JProgressBar pBar, boolean netInstall, boolean bindingsInstall) {
111cdf0e10cSrcweir         this.installPath = installPath;
112cdf0e10cSrcweir         this.statusLabel = statusLabel;
113cdf0e10cSrcweir         this.netInstall = netInstall;
114cdf0e10cSrcweir         this.bindingsInstall = bindingsInstall;
115cdf0e10cSrcweir         listeners = new Vector();
116cdf0e10cSrcweir         threadSuspended = false;
117cdf0e10cSrcweir         progressBar=pBar;
118cdf0e10cSrcweir         progressBar.setStringPainted(true);
119cdf0e10cSrcweir     }// XmlUpdater
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 
checkStop()122cdf0e10cSrcweir 	public boolean checkStop()
123cdf0e10cSrcweir 	{
124cdf0e10cSrcweir         if (internalThread == Thread.currentThread())
125cdf0e10cSrcweir             return false;
126cdf0e10cSrcweir         return true;
127cdf0e10cSrcweir 	}// checkStop
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 
checkSuspend()130cdf0e10cSrcweir 	public void checkSuspend()
131cdf0e10cSrcweir 	{
132cdf0e10cSrcweir         if (threadSuspended) {
133cdf0e10cSrcweir             synchronized(this) {
134cdf0e10cSrcweir                 while (threadSuspended) {
135cdf0e10cSrcweir                     try	{
136cdf0e10cSrcweir                         wait();
137cdf0e10cSrcweir                     } catch (InterruptedException eInt) {
138cdf0e10cSrcweir                         //...
139cdf0e10cSrcweir                     }
140cdf0e10cSrcweir                 }
141cdf0e10cSrcweir             }
142cdf0e10cSrcweir         }
143cdf0e10cSrcweir 	}// checkSuspend
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 
setSuspend()146cdf0e10cSrcweir 	public void setSuspend()
147cdf0e10cSrcweir 	{
148cdf0e10cSrcweir         threadSuspended = true;
149cdf0e10cSrcweir 	}// setSuspend
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 
setResume()152cdf0e10cSrcweir 	public void setResume()
153cdf0e10cSrcweir 	{
154cdf0e10cSrcweir         threadSuspended = false;
155cdf0e10cSrcweir         notify();
156cdf0e10cSrcweir 	}// setResume
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 
setStop()159cdf0e10cSrcweir 	public void setStop()
160cdf0e10cSrcweir 	{
161cdf0e10cSrcweir         internalThread = null;
162cdf0e10cSrcweir 	}// setStop
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 
run()165cdf0e10cSrcweir     public void run() {
166cdf0e10cSrcweir 
167cdf0e10cSrcweir         InputStream            istream;
168cdf0e10cSrcweir         //InputSource            isource;
169cdf0e10cSrcweir         //DocumentBuilderFactory builderFactory;
170cdf0e10cSrcweir         //DocumentBuilder        builder = null;
171cdf0e10cSrcweir         URL                    url;
172cdf0e10cSrcweir         String                 fileName = null;
173cdf0e10cSrcweir 
174cdf0e10cSrcweir         internalThread = Thread.currentThread();
175cdf0e10cSrcweir 
176cdf0e10cSrcweir         //System.out.println("\n\n\n\nFileName: "+installPath);
177cdf0e10cSrcweir         classesPath= installPath.concat(File.separator+"program"+File.separator+"classes"+File.separator);
178cdf0e10cSrcweir         String opSys =System.getProperty("os.name");
179cdf0e10cSrcweir         //System.out.println("\n System "+opSys);
180cdf0e10cSrcweir 
181cdf0e10cSrcweir         String progpath=installPath;
182cdf0e10cSrcweir         progpath= progpath.concat(File.separator+"program"+File.separator);
183cdf0e10cSrcweir         //System.out.println("Office progpath" + progpath );
184cdf0e10cSrcweir         //System.out.println("\nModifying Installation "+installPath);
185cdf0e10cSrcweir 
186cdf0e10cSrcweir         String starBasicPath=installPath;
187cdf0e10cSrcweir         starBasicPath= starBasicPath.concat(File.separator+"share"+File.separator+"basic"+File.separator+"ScriptBindingLibrary"+File.separator);
188cdf0e10cSrcweir         //System.out.println( "Office StarBasic path: " + starBasicPath );
189cdf0e10cSrcweir 
190cdf0e10cSrcweir         String regSchemaOfficePath=installPath;
191cdf0e10cSrcweir         regSchemaOfficePath= regSchemaOfficePath.concat(File.separator+"share"+File.separator+"registry"+File.separator+"schema"+File.separator+"org"+File.separator+"openoffice"+File.separator+"Office"+File.separator);
192cdf0e10cSrcweir         //System.out.println( "Office schema path: " + regSchemaOfficePath );
193cdf0e10cSrcweir 
194cdf0e10cSrcweir         // Get the NetBeans installation
195cdf0e10cSrcweir         //String netbeansPath=
196cdf0e10cSrcweir 
197cdf0e10cSrcweir         progressBar.setString("Unzipping Required Files");
198cdf0e10cSrcweir         ZipData zd = new ZipData("SFrameworkInstall.jar");
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 
201cdf0e10cSrcweir         if( (!netInstall) || bindingsInstall) {
202cdf0e10cSrcweir             String configPath=installPath;
203cdf0e10cSrcweir             configPath= configPath.concat(File.separator+"user"+File.separator+"config"+File.separator+"soffice.cfg"+File.separator);
204cdf0e10cSrcweir             //System.out.println( "Office configuration path: " + configPath );
205cdf0e10cSrcweir             String manifestPath=configPath + "META-INF" + File.separator;
206cdf0e10cSrcweir 
207cdf0e10cSrcweir             //Adding <Office>/user/config/soffice.cfg/
208cdf0e10cSrcweir             File configDir = new File( configPath );
209cdf0e10cSrcweir             if( !configDir.isDirectory() ) {
210cdf0e10cSrcweir                 if( !configDir.mkdir() ) {
211cdf0e10cSrcweir                     System.out.println( "creating  " + configDir + "directory failed");
212cdf0e10cSrcweir                 }
213cdf0e10cSrcweir                 else {
214cdf0e10cSrcweir                     System.out.println( configDir + "directory created");
215cdf0e10cSrcweir                 }
216cdf0e10cSrcweir             }
217cdf0e10cSrcweir             else
218cdf0e10cSrcweir                 System.out.println( "soffice.cfg exists" );
219cdf0e10cSrcweir 
220cdf0e10cSrcweir             File manifestDir = new File( manifestPath );
221cdf0e10cSrcweir             if( !manifestDir.isDirectory() ) {
222cdf0e10cSrcweir                 if( !manifestDir.mkdir() ) {
223cdf0e10cSrcweir                     System.out.println( "creating " + manifestPath + "directory failed");
224cdf0e10cSrcweir                 }
225cdf0e10cSrcweir                 else {
226cdf0e10cSrcweir                     System.out.println( manifestPath + " directory created");
227cdf0e10cSrcweir                 }
228cdf0e10cSrcweir             }
229cdf0e10cSrcweir             else
230cdf0e10cSrcweir                 System.out.println( manifestPath + " exists" );
231cdf0e10cSrcweir 
232cdf0e10cSrcweir             // Backup the confguration files in
233cdf0e10cSrcweir             // <office>/user/config/soffice.cfg/
234cdf0e10cSrcweir             // If they already exist.
235cdf0e10cSrcweir 
236cdf0e10cSrcweir             for( int i=0; i < bakFiles.length; i++ )
237cdf0e10cSrcweir             {
238cdf0e10cSrcweir                 String pathNameBak = configPath + bakFiles[i];
239cdf0e10cSrcweir                 File origFile = new File( pathNameBak );
240cdf0e10cSrcweir                 if( origFile.exists() )
241cdf0e10cSrcweir                 {
242cdf0e10cSrcweir                     System.out.println( "Attempting to backup " + pathNameBak + " to " + pathNameBak + ".bak" );
243cdf0e10cSrcweir                     if(! origFile.renameTo( new File( pathNameBak + ".bak" ) ) )
244cdf0e10cSrcweir                     {
245cdf0e10cSrcweir                         System.out.println( "Failed to backup " + pathNameBak + " to " + pathNameBak + ".bak" );
246cdf0e10cSrcweir                     }
247cdf0e10cSrcweir                 }
248cdf0e10cSrcweir             }
249cdf0e10cSrcweir 
250cdf0e10cSrcweir             // Adding Office configuration files
251cdf0e10cSrcweir             if (!zd.extractEntry("bindingdialog/writermenubar.xml",configPath, statusLabel))
252cdf0e10cSrcweir             {
253cdf0e10cSrcweir                 onInstallComplete();
254cdf0e10cSrcweir                 return;
255cdf0e10cSrcweir             }
256cdf0e10cSrcweir             if (!zd.extractEntry("bindingdialog/writerkeybinding.xml",configPath, statusLabel))
257cdf0e10cSrcweir             {
258cdf0e10cSrcweir                 onInstallComplete();
259cdf0e10cSrcweir                 return;
260cdf0e10cSrcweir             }
261cdf0e10cSrcweir             if (!zd.extractEntry("bindingdialog/calcmenubar.xml",configPath, statusLabel))
262cdf0e10cSrcweir             {
263cdf0e10cSrcweir                 onInstallComplete();
264cdf0e10cSrcweir                 return;
265cdf0e10cSrcweir             }
266cdf0e10cSrcweir             if (!zd.extractEntry("bindingdialog/calckeybinding.xml",configPath, statusLabel))
267cdf0e10cSrcweir             {
268cdf0e10cSrcweir                 onInstallComplete();
269cdf0e10cSrcweir                 return;
270cdf0e10cSrcweir             }
271cdf0e10cSrcweir             if (!zd.extractEntry("bindingdialog/impressmenubar.xml",configPath, statusLabel))
272cdf0e10cSrcweir             {
273cdf0e10cSrcweir                 onInstallComplete();
274cdf0e10cSrcweir                 return;
275cdf0e10cSrcweir             }
276cdf0e10cSrcweir             if (!zd.extractEntry("bindingdialog/impresskeybinding.xml",configPath, statusLabel))
277cdf0e10cSrcweir             {
278cdf0e10cSrcweir                 onInstallComplete();
279cdf0e10cSrcweir                 return;
280cdf0e10cSrcweir             }
281cdf0e10cSrcweir             if (!zd.extractEntry("bindingdialog/drawmenubar.xml",configPath, statusLabel))
282cdf0e10cSrcweir             {
283cdf0e10cSrcweir                 onInstallComplete();
284cdf0e10cSrcweir                 return;
285cdf0e10cSrcweir             }
286cdf0e10cSrcweir             if (!zd.extractEntry("bindingdialog/drawkeybinding.xml",configPath, statusLabel))
287cdf0e10cSrcweir             {
288cdf0e10cSrcweir                 onInstallComplete();
289cdf0e10cSrcweir                 return;
290cdf0e10cSrcweir             }
291cdf0e10cSrcweir             if (!zd.extractEntry("bindingdialog/eventbindings.xml",configPath, statusLabel))
292cdf0e10cSrcweir             {
293cdf0e10cSrcweir                 onInstallComplete();
294cdf0e10cSrcweir                 return;
295cdf0e10cSrcweir             }
296cdf0e10cSrcweir             if (!zd.extractEntry("bindingdialog/manifest.xml",manifestPath, statusLabel))
297cdf0e10cSrcweir             {
298cdf0e10cSrcweir                 onInstallComplete();
299cdf0e10cSrcweir                 return;
300cdf0e10cSrcweir             }
301cdf0e10cSrcweir         }
302cdf0e10cSrcweir 
303cdf0e10cSrcweir         if(!bindingsInstall) {
304cdf0e10cSrcweir             // Adding new directories to Office
305cdf0e10cSrcweir             // Adding <Office>/user/basic/ScriptBindingLibrary/
306cdf0e10cSrcweir             File scriptBindingLib = new File( starBasicPath );
307cdf0e10cSrcweir             if( !scriptBindingLib.isDirectory() ) {
308cdf0e10cSrcweir                 if( !scriptBindingLib.mkdir() ) {
309cdf0e10cSrcweir                     System.out.println( "ScriptBindingLibrary failed");
310cdf0e10cSrcweir                 }
311cdf0e10cSrcweir                 else {
312cdf0e10cSrcweir                     System.out.println( "ScriptBindingLibrary directory created");
313cdf0e10cSrcweir                 }
314cdf0e10cSrcweir             }
315cdf0e10cSrcweir             else
316cdf0e10cSrcweir                 System.out.println( "ScriptBindingLibrary exists" );
317cdf0e10cSrcweir 
318cdf0e10cSrcweir             // Adding Scripting Framework and tools
319cdf0e10cSrcweir             if (!zd.extractEntry("sframework/ooscriptframe.zip",progpath, statusLabel))
320cdf0e10cSrcweir             {
321cdf0e10cSrcweir                 onInstallComplete();
322cdf0e10cSrcweir                 return;
323cdf0e10cSrcweir             }
324cdf0e10cSrcweir 
325cdf0e10cSrcweir             if (!zd.extractEntry("sframework/bshruntime.zip",progpath, statusLabel))
326cdf0e10cSrcweir             {
327cdf0e10cSrcweir                 onInstallComplete();
328cdf0e10cSrcweir                 return;
329cdf0e10cSrcweir             }
330cdf0e10cSrcweir 
331cdf0e10cSrcweir             if (!zd.extractEntry("sframework/jsruntime.zip",progpath, statusLabel))
332cdf0e10cSrcweir             {
333cdf0e10cSrcweir                 onInstallComplete();
334cdf0e10cSrcweir                 return;
335cdf0e10cSrcweir             }
336cdf0e10cSrcweir 
337cdf0e10cSrcweir             if (!zd.extractEntry("schema/Scripting.xcs",regSchemaOfficePath, statusLabel))
338cdf0e10cSrcweir             {
339cdf0e10cSrcweir                 onInstallComplete();
340cdf0e10cSrcweir                 return;
341cdf0e10cSrcweir             }
342cdf0e10cSrcweir 
343cdf0e10cSrcweir     //--------------------------------
344cdf0e10cSrcweir 
345cdf0e10cSrcweir             progressBar.setString("Registering Scripting Framework");
346cdf0e10cSrcweir             progressBar.setValue(3);
347cdf0e10cSrcweir             if(!Register.register(installPath+File.separator, statusLabel) ) {
348cdf0e10cSrcweir                onInstallComplete();
349cdf0e10cSrcweir                return;
350cdf0e10cSrcweir             }
351cdf0e10cSrcweir             progressBar.setValue(5);
352cdf0e10cSrcweir 
353cdf0e10cSrcweir             String path = installPath + File.separator +
354cdf0e10cSrcweir                 "share" + File.separator + "Scripts" + File.separator;
355cdf0e10cSrcweir 
356cdf0e10cSrcweir             for (int i = 0; i < dirs.length; i++) {
357cdf0e10cSrcweir                 File dir = new File(path + dirs[i]);
358cdf0e10cSrcweir 
359cdf0e10cSrcweir                 if (!dir.exists()) {
360cdf0e10cSrcweir                     if (!dir.mkdirs()) {
361cdf0e10cSrcweir                         System.err.println("Error making dir: " +
362cdf0e10cSrcweir                             dir.getAbsolutePath());
363cdf0e10cSrcweir                         onInstallComplete();
364cdf0e10cSrcweir                         return;
365cdf0e10cSrcweir                     }
366cdf0e10cSrcweir                 }
367cdf0e10cSrcweir             }
368cdf0e10cSrcweir 
369cdf0e10cSrcweir             for (int i = 0; i < names.length; i++) {
370cdf0e10cSrcweir                 String source = "/examples/" + names[i];
371cdf0e10cSrcweir                 String dest = path + names[i].replace('/', File.separatorChar);
372cdf0e10cSrcweir 
373cdf0e10cSrcweir                 if (!zd.extractEntry(source, dest, statusLabel)) {
374cdf0e10cSrcweir                     onInstallComplete();
375cdf0e10cSrcweir                     return;
376cdf0e10cSrcweir                 }
377cdf0e10cSrcweir             }
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 
380cdf0e10cSrcweir             // Adding binding dialog
381cdf0e10cSrcweir             if (!zd.extractEntry("bindingdialog/ScriptBinding.xba",starBasicPath, statusLabel))
382cdf0e10cSrcweir             {
383cdf0e10cSrcweir                 onInstallComplete();
384cdf0e10cSrcweir                 return;
385cdf0e10cSrcweir             }
386cdf0e10cSrcweir             if (!zd.extractEntry("bindingdialog/MenuBinding.xdl",starBasicPath, statusLabel))
387cdf0e10cSrcweir             {
388cdf0e10cSrcweir                 onInstallComplete();
389cdf0e10cSrcweir                 return;
390cdf0e10cSrcweir             }
391cdf0e10cSrcweir             if (!zd.extractEntry("bindingdialog/KeyBinding.xdl",starBasicPath, statusLabel))
392cdf0e10cSrcweir             {
393cdf0e10cSrcweir                 onInstallComplete();
394cdf0e10cSrcweir                 return;
395cdf0e10cSrcweir             }
396cdf0e10cSrcweir             if (!zd.extractEntry("bindingdialog/EventsBinding.xdl",starBasicPath, statusLabel))
397cdf0e10cSrcweir             {
398cdf0e10cSrcweir                 onInstallComplete();
399cdf0e10cSrcweir                 return;
400cdf0e10cSrcweir             }
401cdf0e10cSrcweir             if (!zd.extractEntry("bindingdialog/HelpBinding.xdl",starBasicPath, statusLabel))
402cdf0e10cSrcweir             {
403cdf0e10cSrcweir                 onInstallComplete();
404cdf0e10cSrcweir                 return;
405cdf0e10cSrcweir             }
406cdf0e10cSrcweir             if (!zd.extractEntry("bindingdialog/EditDebug.xdl",starBasicPath, statusLabel))
407cdf0e10cSrcweir             {
408cdf0e10cSrcweir                 onInstallComplete();
409cdf0e10cSrcweir                 return;
410cdf0e10cSrcweir             }
411cdf0e10cSrcweir             if (!zd.extractEntry("bindingdialog/dialog.xlb",starBasicPath, statusLabel))
412cdf0e10cSrcweir             {
413cdf0e10cSrcweir                 onInstallComplete();
414cdf0e10cSrcweir                 return;
415cdf0e10cSrcweir             }
416cdf0e10cSrcweir             if (!zd.extractEntry("bindingdialog/script.xlb",starBasicPath, statusLabel))
417cdf0e10cSrcweir             {
418cdf0e10cSrcweir                 onInstallComplete();
419cdf0e10cSrcweir                 return;
420cdf0e10cSrcweir             }
421cdf0e10cSrcweir         }
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 
424cdf0e10cSrcweir         statusLabel.setText("Installation Complete");
425cdf0e10cSrcweir         progressBar.setString("Installation Complete");
426cdf0e10cSrcweir         progressBar.setValue(10);
427cdf0e10cSrcweir         onInstallComplete();
428cdf0e10cSrcweir 
429cdf0e10cSrcweir     }// run
430cdf0e10cSrcweir 
431cdf0e10cSrcweir 
addInstallListener(InstallListener listener)432cdf0e10cSrcweir     public void addInstallListener(InstallListener listener)
433cdf0e10cSrcweir     {
434cdf0e10cSrcweir         listeners.addElement(listener);
435cdf0e10cSrcweir     }// addInstallListener
436cdf0e10cSrcweir 
437cdf0e10cSrcweir 
onInstallComplete()438cdf0e10cSrcweir     private void onInstallComplete()
439cdf0e10cSrcweir     {
440cdf0e10cSrcweir         Enumeration e = listeners.elements();
441cdf0e10cSrcweir         while (e.hasMoreElements())
442cdf0e10cSrcweir         {
443cdf0e10cSrcweir             InstallListener listener = (InstallListener)e.nextElement();
444cdf0e10cSrcweir             listener.installationComplete(null);
445cdf0e10cSrcweir         }
446cdf0e10cSrcweir     }// onInstallComplete
447cdf0e10cSrcweir 
448cdf0e10cSrcweir }// XmlUpdater class
449