Initial Import of support for Netbeans and jEdit installation
This commit is contained in:
125
scripting/workben/installer/IdeFinal.java
Normal file
125
scripting/workben/installer/IdeFinal.java
Normal file
@@ -0,0 +1,125 @@
|
||||
package installer;
|
||||
|
||||
/*
|
||||
* Welcome.java
|
||||
*
|
||||
* Created on 04 July 2002, 15:43
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @author mike
|
||||
*/
|
||||
|
||||
import java.awt.event.*;
|
||||
import java.util.*;
|
||||
import java.net.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class IdeFinal extends javax.swing.JPanel implements ActionListener, InstallListener {
|
||||
|
||||
/** Creates new form Welcome */
|
||||
public IdeFinal(InstallWizard wizard) {
|
||||
this.wizard = wizard;
|
||||
setBackground(java.awt.Color.white);
|
||||
ideupdater = null;
|
||||
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() {//GEN-BEGIN:initComponents
|
||||
statusPanel = new javax.swing.JPanel();
|
||||
statusPanel.setBackground(java.awt.Color.white);
|
||||
statusLine = new javax.swing.JLabel("Ready", javax.swing.JLabel.CENTER);
|
||||
|
||||
setLayout(new java.awt.BorderLayout());
|
||||
|
||||
statusPanel.setLayout(new java.awt.BorderLayout());
|
||||
|
||||
statusLine.setText("Waiting to install IDE support.");
|
||||
statusPanel.add(statusLine, java.awt.BorderLayout.CENTER);
|
||||
|
||||
add(statusPanel, java.awt.BorderLayout.CENTER);
|
||||
nav = new NavPanel(wizard, true, true, true, InstallWizard.IDEVERSIONS, "");
|
||||
nav.setNextListener(this);
|
||||
nav.removeCancelListener(nav);
|
||||
nav.setCancelListener(this);
|
||||
nav.navNext.setText("Install");
|
||||
add(nav, java.awt.BorderLayout.SOUTH);
|
||||
}//GEN-END:initComponents
|
||||
|
||||
public java.awt.Dimension getPreferredSize() {
|
||||
return new java.awt.Dimension(InstallWizard.DEFWIDTH, InstallWizard.DEFHEIGHT);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// navNext is "Install"
|
||||
if (e.getSource() == nav.navNext)
|
||||
{
|
||||
JProgressBar progressBar=new JProgressBar();
|
||||
progressBar.setMaximum(10);
|
||||
progressBar.setValue(0);
|
||||
statusPanel.add(progressBar, java.awt.BorderLayout.SOUTH);
|
||||
nav.enableNext(false);
|
||||
nav.enableBack(false);
|
||||
nav.enableCancel(false);
|
||||
ArrayList locations = wizard.getLocations();
|
||||
//System.out.println("here "+locations.size());
|
||||
// Returned 1
|
||||
String progpath=null;
|
||||
String path=null;
|
||||
String classespath=null;
|
||||
for (int i =0;i<locations.size();i++){
|
||||
path= (String)locations.get(i);
|
||||
|
||||
//InstallWizard.currentPath = path;
|
||||
ideupdater = new IdeUpdater( path, statusLine, progressBar );
|
||||
ideupdater.addInstallListener(this);
|
||||
InstallWizard.setInstallStarted(true);
|
||||
//InstallWizard.setPatchedTypes(false);
|
||||
//InstallWizard.setPatchedJava(false);
|
||||
//InstallWizard.setPatchedRDB(false);
|
||||
ideupdater.start();
|
||||
}
|
||||
}
|
||||
|
||||
// set to "Exit" at end of installation process
|
||||
if (e.getSource() == nav.navCancel) {
|
||||
int answer = JOptionPane.showConfirmDialog(wizard, "Are you sure you want to exit?");
|
||||
if (answer == JOptionPane.YES_OPTION)
|
||||
{
|
||||
wizard.exitForm(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}// actionPerformed
|
||||
|
||||
|
||||
public void installationComplete(InstallationEvent ev) {
|
||||
//System.out.println("Detected installation complete");
|
||||
//if( InstUtil.hasNetbeansInstallation() || InstUtil.hasJeditInstallation() ) {
|
||||
//System.out.println("Detected installation complete (IDE(s) detected)");
|
||||
nav.removeCancelListener(this);
|
||||
nav.setCancelListener(nav);
|
||||
nav.navCancel.setText("Finish");
|
||||
nav.enableCancel(true);
|
||||
ideupdater = null;
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JPanel statusPanel;
|
||||
private javax.swing.JLabel statusLine;
|
||||
private InstallWizard wizard;
|
||||
private NavPanel nav;
|
||||
//private XmlUpdater xud;
|
||||
private IdeUpdater ideupdater;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
176
scripting/workben/installer/IdeUpdater.java
Normal file
176
scripting/workben/installer/IdeUpdater.java
Normal file
@@ -0,0 +1,176 @@
|
||||
package installer;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.jar.*;
|
||||
//import org.xml.sax.*;
|
||||
//import org.w3c.dom.*;
|
||||
//import javax.xml.parsers.*;
|
||||
import java.net.URL;
|
||||
import java.net.JarURLConnection;
|
||||
//import javax.xml.parsers.*;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* The <code>XmlUpdater</code> pulls a META-INF/converter.xml
|
||||
* file out of a jar file and parses it, providing access to this
|
||||
* information in a <code>Vector</code> of <code>ConverterInfo</code>
|
||||
* objects.
|
||||
*
|
||||
* @author Aidan Butler
|
||||
*/
|
||||
public class IdeUpdater extends Thread {
|
||||
|
||||
private String classesPath = null;
|
||||
private String jarfilename;
|
||||
private String installPath;
|
||||
|
||||
private JLabel statusLabel;
|
||||
|
||||
private Vector listeners;
|
||||
private Thread internalThread;
|
||||
private boolean threadSuspended;
|
||||
private JProgressBar progressBar;
|
||||
|
||||
private boolean isNetbeansPath = false;
|
||||
|
||||
|
||||
public IdeUpdater(String installPath, JLabel statusLabel,JProgressBar pBar) {
|
||||
|
||||
File jeditLauncher = new File( installPath + File.separator + "jedit.jar" );
|
||||
File netbeansLauncher = null;
|
||||
|
||||
String opSys =System.getProperty("os.name");
|
||||
if (opSys.indexOf("Windows") != -1) {
|
||||
netbeansLauncher = new File( installPath + "bin" + File.separator + "runide.exe" );
|
||||
}
|
||||
else {
|
||||
netbeansLauncher = new File( installPath + "bin" + File.separator + "runide.sh" );
|
||||
}
|
||||
|
||||
if( netbeansLauncher.isFile() ) {
|
||||
isNetbeansPath = true;
|
||||
installPath = installPath +"modules" + File.separator;
|
||||
}
|
||||
else if( jeditLauncher.isFile() ){
|
||||
isNetbeansPath = false;
|
||||
installPath = installPath + "jars" + File.separator;
|
||||
}
|
||||
|
||||
|
||||
System.out.println( "IdeUpdater installPath is " + installPath + " isNetbeansPath is " + isNetbeansPath );
|
||||
this.installPath = installPath;
|
||||
this.statusLabel = statusLabel;
|
||||
listeners = new Vector();
|
||||
threadSuspended = false;
|
||||
progressBar=pBar;
|
||||
progressBar.setStringPainted(true);
|
||||
}// XmlUpdater
|
||||
|
||||
|
||||
public boolean checkStop()
|
||||
{
|
||||
if (internalThread == Thread.currentThread())
|
||||
return false;
|
||||
return true;
|
||||
}// checkStop
|
||||
|
||||
|
||||
public void checkSuspend()
|
||||
{
|
||||
if (threadSuspended)
|
||||
{
|
||||
synchronized(this)
|
||||
{
|
||||
while (threadSuspended)
|
||||
{
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException eInt) {
|
||||
//...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}// checkSuspend
|
||||
|
||||
|
||||
public void setSuspend()
|
||||
{
|
||||
threadSuspended = true;
|
||||
}// setSuspend
|
||||
|
||||
|
||||
public void setResume()
|
||||
{
|
||||
threadSuspended = false;
|
||||
notify();
|
||||
}// setResume
|
||||
|
||||
|
||||
public void setStop()
|
||||
{
|
||||
internalThread = null;
|
||||
}// setStop
|
||||
|
||||
|
||||
public void run() {
|
||||
|
||||
//InputStream istream;
|
||||
//URL url;
|
||||
//String fileName = null;
|
||||
|
||||
internalThread = Thread.currentThread();
|
||||
|
||||
progressBar.setString("Unzipping Required Files");
|
||||
ZipData zd = new ZipData("SFrameworkInstall.jar");
|
||||
|
||||
// Adding IDE support
|
||||
if( isNetbeansPath ) {
|
||||
if (!zd.extractEntry("ide/office.jar",installPath, statusLabel))
|
||||
{
|
||||
onInstallComplete();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!zd.extractEntry("ide/idesupport.jar",installPath, statusLabel))
|
||||
{
|
||||
onInstallComplete();
|
||||
return;
|
||||
}
|
||||
if (!zd.extractEntry("ide/OfficeScripting.jar",installPath, statusLabel))
|
||||
{
|
||||
onInstallComplete();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//System.out.println("About to call register");
|
||||
//Register.register(installPath+File.separator, statusLabel, progressBar);
|
||||
|
||||
statusLabel.setText("Installation Complete");
|
||||
progressBar.setString("Installation Complete");
|
||||
progressBar.setValue(10);
|
||||
onInstallComplete();
|
||||
|
||||
}// run
|
||||
|
||||
|
||||
public void addInstallListener(InstallListener listener)
|
||||
{
|
||||
listeners.addElement(listener);
|
||||
}// addInstallListener
|
||||
|
||||
|
||||
private void onInstallComplete()
|
||||
{
|
||||
Enumeration e = listeners.elements();
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
InstallListener listener = (InstallListener)e.nextElement();
|
||||
listener.installationComplete(null);
|
||||
}
|
||||
}// onInstallComplete
|
||||
|
||||
}// XmlUpdater class
|
||||
239
scripting/workben/installer/IdeVersion.java
Normal file
239
scripting/workben/installer/IdeVersion.java
Normal file
@@ -0,0 +1,239 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
79
scripting/workben/installer/IdeWelcome.java
Normal file
79
scripting/workben/installer/IdeWelcome.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package installer;
|
||||
|
||||
/*
|
||||
* Welcome.java
|
||||
*
|
||||
* Created on 04 July 2002, 15:43
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @author mike
|
||||
*/
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class IdeWelcome extends javax.swing.JPanel implements ActionListener {
|
||||
|
||||
/** Creates new form Welcome */
|
||||
public IdeWelcome(InstallWizard wizard) {
|
||||
this.wizard = wizard;
|
||||
setBorder(new javax.swing.border.EtchedBorder(javax.swing.border.EtchedBorder.RAISED));
|
||||
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() {//GEN-BEGIN:initComponents
|
||||
welcomePanel = new javax.swing.JPanel();
|
||||
area = new javax.swing.JTextArea();
|
||||
|
||||
setLayout(new java.awt.BorderLayout());
|
||||
|
||||
welcomePanel.setLayout(new java.awt.BorderLayout());
|
||||
//area.setHorizontalAlignment(javax.swing.JTextField.CENTER);
|
||||
area.setEditable(false);
|
||||
area.setLineWrap(true);
|
||||
area.setText("\n Click Next to include Scripting Framework support for IDEs.");
|
||||
area.append("\n Click Cancel exit the Installation process. \n");
|
||||
if( InstUtil.hasNetbeansInstallation() ) {
|
||||
area.append("\n \tA version of Netbeans has been detected. \n");
|
||||
}
|
||||
if( InstUtil.hasJeditInstallation() ) {
|
||||
area.append("\n \tA version of jEdit has been detected.");
|
||||
}
|
||||
|
||||
welcomePanel.add(area, java.awt.BorderLayout.CENTER);
|
||||
add(welcomePanel, java.awt.BorderLayout.CENTER);
|
||||
NavPanel nav = new NavPanel(wizard, false, true, true, "", InstallWizard.IDEVERSIONS);
|
||||
nav.setNextListener(this);
|
||||
add(nav, java.awt.BorderLayout.SOUTH);
|
||||
|
||||
//Banner br = new Banner();
|
||||
//add(br, java.awt.BorderLayout.WEST);
|
||||
|
||||
}//GEN-END:initComponents
|
||||
|
||||
public java.awt.Dimension getPreferredSize() {
|
||||
return new java.awt.Dimension(InstallWizard.DEFWIDTH, InstallWizard.DEFHEIGHT);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent ev)
|
||||
{
|
||||
//Perform next actions here...
|
||||
}
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JPanel welcomePanel;
|
||||
private javax.swing.JTextArea area;
|
||||
private InstallWizard wizard;
|
||||
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
Reference in New Issue
Block a user