Files
loongoffice/scripting/workben/installer/IdeVersion.java
Duncan Foster 49212de9d3 Some fixes to installer, including extra diagnostics, and exception handling.
Also added StarOffice build to supported Office installations
2002-11-18 17:23:19 +00:00

246 lines
7.7 KiB
Java

package installer;
/*
* Welcome.java
*
* Created on 04 July 2002, 15:43
*/
/**
*
* @author mike
*/
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import javax.swing.SwingUtilities.*;
public class IdeVersion extends javax.swing.JPanel implements ActionListener, TableModelListener {
/** Creates new form Welcome */
public IdeVersion(InstallWizard wizard) {
this.wizard=wizard;
setBackground(Color.white);
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {
Properties props = null;
JPanel versionPanel = new JPanel();
setLayout(new BorderLayout());
try {
//props = InstUtil.getNetbeansLocation();
Properties netbeansProps = InstUtil.getNetbeansLocation();
Properties jeditProps = InstUtil.getJeditLocation();
Properties ideProps = new Properties();
for( int n = 0; n < netbeansProps.size(); n++ ) {
for( int v = 0; v < versions.length; v++ ) {
String key = versions[v];
String path = null;
if ( (path = netbeansProps.getProperty(key) ) != null ) {
//System.out.println( "n="+n+" v="+v + " Netbeans " + " key=" + key + " path=" + path );
ideProps.put(key, path);
}
}
}
if(jeditProps!=null)
{
for( int j = 0; j < jeditProps.size(); j++ ) {
for( int v = 0; v < versions.length; v++ ) {
String key = versions[v];
String path = null;
if ((path = jeditProps.getProperty(key)) != null) {
//System.out.println( "j="+j+" v="+v + " jEdit " + " key=" + key + " path=" + path );
ideProps.put(key, path);
}
}
}
}
props = ideProps;
/*
int len = versions.length;
for (int i = 0; i < len; i++) {
System.out.println( i + "start for" );
String key = versions[i];
String path = null;
if ((path = netbeansProps.getProperty(key)) != null) {
System.out.println( i + " Netbeans " + " key=" + key + " path=" + path );
//props.put(key, path);
}
else if ((path = jeditProps.getProperty(key)) != null) {
System.out.println( i + " jEdit " + " key=" + key + " path=" + path );
//props.put(key, path);
}
System.out.println( i + "end for" );
}
*/
}
catch (IOException eIO) {
//Message about no installed versions found
System.err.println("Failed to parse .netbeans/ide.log");
//JOptionPane.showMessageDialog(this, "There was a problem reading from the NetBeans ide.log file.", "Parse Error", JOptionPane.ERROR_MESSAGE);
//wizard.exitForm(null);
}
catch (Exception e) {
System.err.println("Exception thrown in initComponents");
}
tableModel = new MyTableModelIDE (props, versions);
if (tableModel.getRowCount() == 0)
{
JOptionPane.showMessageDialog(this, "No compatible IDEs were found.", "Invalid versions", JOptionPane.ERROR_MESSAGE);
//wizard.exitForm(null);
}
tableModel.addTableModelListener(this);
JTable tableVersions = new JTable(tableModel);
tableVersions.setPreferredSize(new Dimension(InstallWizard.DEFWIDTH,InstallWizard.DEFHEIGHT));
tableVersions.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
tableVersions.doLayout();
setBorder(new javax.swing.border.EtchedBorder(javax.swing.border.EtchedBorder.RAISED));
//JScrollPane scroll = new JScrollPane(tableVersions);
//versionPanel.add(scroll);
versionPanel.add(tableVersions);
JTextArea area = new JTextArea("Please select IDEs below that you wish to add Scripting support to");
area.setLineWrap(true);
area.setEditable(false);
add(area, BorderLayout.NORTH);
add(versionPanel, BorderLayout.CENTER);
nav = new NavPanel(wizard, true, false, true, InstallWizard.IDEWELCOME, InstallWizard.IDEFINAL);
nav.setNextListener(this);
add(nav, BorderLayout.SOUTH);
}// initComponents
public java.awt.Dimension getPreferredSize() {
return new java.awt.Dimension(320, 280);
}
public void actionPerformed(ActionEvent ev) {
wizard.clearLocations();
int len = tableModel.data.size();
for (int i = 0; i < len; i++) {
ArrayList list = (ArrayList)tableModel.data.get(i);
if (((Boolean)list.get(0)).booleanValue() == true)
wizard.storeLocation((String)list.get(2));
}
//System.out.println(wizard.getLocations());
}
public void tableChanged(TableModelEvent e) {
if (tableModel.isAnySelected()) {
nav.enableNext(true);
}
else {
nav.enableNext(false);
}
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField jTextField2;
private InstallWizard wizard;
private MyTableModelIDE tableModel;
private NavPanel nav;
//private static final String [] versions = {"StarOffice 6.0", "OpenOffice.org 1.0","OpenOffice.org 1.0.1","OpenOffice.org 642","OpenOffice.org 643","StarOffice 6.1"};
//private static final String [] versions = {"OpenOffice.org 643"};
private static final String [] versions = {"NetBeans 3.4", "jEdit 4.0.3"};
// End of variables declaration//GEN-END:variables
}
class MyTableModelIDE extends AbstractTableModel {
ArrayList data;
String colNames[] = {"Install", "Name", "Location"};
MyTableModelIDE (Properties properties, String [] validVersions) {
data = new ArrayList();
//System.out.println(properties);
int len = validVersions.length;
for (int i = 0; i < len; i++) {
String key = validVersions[i];
String path = null;
if ((path = properties.getProperty(key)) != null) {
ArrayList row = new ArrayList();
row.add(0, new Boolean(false));
row.add(1, key);
row.add(2, properties.getProperty(key));
data.add(row);
}
}
}// MyTableModel
public int getColumnCount() {
return 3;
}
public int getRowCount() {
return data.size();
}
public String getColumnName(int col) {
return colNames[col];
}
public Object getValueAt(int row, int col) {
ArrayList aRow = (ArrayList)data.get(row);
return aRow.get(col);
}
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
}
public boolean isCellEditable(int row, int col) {
if (col == 0) {
return true;
} else {
return false;
}
}
public void setValueAt(Object value, int row, int col) {
ArrayList aRow = (ArrayList)data.get(row);
aRow.set(col, value);
fireTableCellUpdated(row, col);
}
String [] getSelected() {
return null;
}
public boolean isAnySelected() {
Iterator iter = data.iterator();
while (iter.hasNext()) {
ArrayList row = (ArrayList)iter.next();
if (((Boolean)row.get(0)).booleanValue() == true) {
return true;
}
}
return false;
}
}