fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / scripting / workben / installer / Welcome.java
blob9a5cf4790acda1a486e49e15f6a07068c936058c
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.awt.event.*;
22 import javax.swing.*;
23 import java.io.*;
24 import java.util.Properties;
26 public class Welcome extends javax.swing.JPanel implements ActionListener {
28 /** Creates new form Welcome */
29 public Welcome(InstallWizard wizard) {
30 this.wizard = wizard;
31 setBorder(new javax.swing.border.EtchedBorder(javax.swing.border.EtchedBorder.RAISED));
32 initComponents();
35 /** This method is called from within the constructor to
36 * initialize the form.
37 * WARNING: Do NOT modify this code. The content of this method is
38 * always regenerated by the Form Editor.
40 private void initComponents() {//GEN-BEGIN:initComponents
41 welcomePanel = new javax.swing.JPanel();
42 area = new javax.swing.JTextArea();
43 nextButtonEnable = true;
45 setLayout(new java.awt.BorderLayout());
47 welcomePanel.setLayout(new java.awt.BorderLayout());
48 area.setEditable(false);
49 area.setLineWrap(true);
51 String message = "\n\tOffice Scripting Framework Version 0.3" +
52 "\n\n\n\tPlease ensure that you have exited from Office";
54 /* String userDir = (String) System.getProperty( "user.dir" );
55 boolean isValid = validateCurrentUserDir(userDir);
56 if( !isValid ) {
57 nextButtonEnable = false;
58 message = "Please run Installer from the program directory in a valid Office installation";
59 setUpWelcomePanel(message);
60 return;
63 int programPosition = userDir.lastIndexOf("program");
64 String offInstallPth = null;
65 offInstallPth = userDir.substring( 0, programPosition );
67 wizard.storeLocation(offInstallPth); */
68 setUpWelcomePanel(message);
70 }//GEN-END:initComponents
72 private void setUpWelcomePanel(String message){
73 area.setText( message );
74 welcomePanel.add(area, java.awt.BorderLayout.CENTER);
75 add(welcomePanel, java.awt.BorderLayout.CENTER);
76 NavPanel nav = new NavPanel(wizard, false, nextButtonEnable, true, "", InstallWizard.VERSIONS);
77 nav.setNextListener(this);
78 add(nav, java.awt.BorderLayout.SOUTH);
80 //Banner br = new Banner();
81 //add(br, java.awt.BorderLayout.WEST);
85 private boolean validateCurrentUserDir(String userDir){
89 Properties props = null;
91 File fileVersions = null;
92 try
94 fileVersions = InstUtil.buildSversionLocation();
96 catch(IOException eFnF)
98 System.err.println("Cannot find sversion.ini/.sversionrc");
99 JOptionPane.showMessageDialog(this, eFnF.getMessage(), "File not Found", JOptionPane.ERROR_MESSAGE);
100 wizard.exitForm(null);
103 try {
104 props = InstUtil.getOfficeVersions(fileVersions);
106 catch (IOException eIO) {
107 //Message about no installed versions found
108 System.err.println("Failed to parse SVERSION");
109 JOptionPane.showMessageDialog(this, "There was a problem reading from the Office settings file.", "Parse Error", JOptionPane.ERROR_MESSAGE);
110 wizard.exitForm(null);
114 boolean versionMatch = false;
116 for( int i = 0; i < versions.length; i++ ) {
117 String key = versions[i];
118 String progPath = props.getProperty( key );
119 if ( progPath != null ){
120 progPath = progPath + File.separator + "program";
122 File tmpFile = new File(progPath + File.separator + "oostubversion.txt");
123 try{
124 tmpFile.createNewFile();
126 if( new File(userDir + File.separator + "oostubversion.txt").exists())
128 versionMatch = true;
129 break;
132 catch( IOException e)
134 // Fail silently
136 tmpFile.delete();
139 return versionMatch;
144 public java.awt.Dimension getPreferredSize() {
145 return new java.awt.Dimension(InstallWizard.DEFWIDTH, InstallWizard.DEFHEIGHT);
148 public void actionPerformed(ActionEvent ev)
150 //Perform next actions here...
154 // Variables declaration - do not modify//GEN-BEGIN:variables
155 private javax.swing.JPanel welcomePanel;
156 private javax.swing.JTextArea area;
157 private InstallWizard wizard;
158 //private static final String [] versions = {"OpenOffice.org 643", "StarOffice 6.1"};
159 private static final String [] versions = { "StarOffice 6.1" };
160 private boolean nextButtonEnable = true;
162 // End of variables declaration//GEN-END:variables