/*
* MainFrame.java
*
* Created on 29.03.2011, 22:54:20
*/
package com.google.code.ftspc.LectorInstaller;
import com.google.code.ftspc.LectorInstaller.UnPack.UnZip;
import com.google.code.ftspc.LectorInstaller.Downloads.DownloadApacheTomcat;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import org.jdesktop.application.Action;
/**
*
* @author KAN
*/
public class MainFrame extends javax.swing.JFrame {
JFileChooser c = new JFileChooser();
public static String destinationFolder;
/** Creates new form MainFrame */
public MainFrame() {
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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel2 = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jPB1 = new javax.swing.JProgressBar();
jLabel3 = new javax.swing.JLabel();
InstallationDirectory = new javax.swing.JTextField();
jButton4 = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
LuceneRepoPath = new javax.swing.JTextField();
MaterLectorPath = new javax.swing.JTextField();
jButton2 = new javax.swing.JButton();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
LectorRepositoryPath = new javax.swing.JTextField();
jButton6 = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jCheckBox1 = new javax.swing.JCheckBox();
jCheckBox2 = new javax.swing.JCheckBox();
downloadTomcatFlag = new javax.swing.JCheckBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(com.google.code.ftspc.LectorInstaller.LectorInstallerApp.class).getContext().getResourceMap(MainFrame.class);
setTitle(resourceMap.getString("Form.title")); // NOI18N
setName("Form"); // NOI18N
jTabbedPane1.setMaximumSize(new java.awt.Dimension(198, 44));
jTabbedPane1.setName("jTabbedPane1"); // NOI18N
jPanel2.setName("jPanel2"); // NOI18N
jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
jLabel6.setName("jLabel6"); // NOI18N
jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
jLabel4.setName("jLabel4"); // NOI18N
jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
jLabel5.setName("jLabel5"); // NOI18N
jPB1.setMaximumSize(new java.awt.Dimension(10, 14));
jPB1.setName("jPB1"); // NOI18N
jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
jLabel3.setName("jLabel3"); // NOI18N
InstallationDirectory.setText(resourceMap.getString("InstallationDirectory.text")); // NOI18N
InstallationDirectory.setName("InstallationDirectory"); // NOI18N
javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(com.google.code.ftspc.LectorInstaller.LectorInstallerApp.class).getContext().getActionMap(MainFrame.class, this);
jButton4.setAction(actionMap.get("InstallProgramm")); // NOI18N
jButton4.setText(resourceMap.getString("jButton4.text")); // NOI18N
jButton4.setName("jButton4"); // NOI18N
jButton1.setAction(actionMap.get("PathToMaterLector")); // NOI18N
jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
jButton1.setName("jButton1"); // NOI18N
jButton3.setAction(actionMap.get("SelectInstallationDirectory")); // NOI18N
jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N
jButton3.setName("jButton3"); // NOI18N
LuceneRepoPath.setText(resourceMap.getString("LuceneRepoPath.text")); // NOI18N
LuceneRepoPath.setName("LuceneRepoPath"); // NOI18N
MaterLectorPath.setText(resourceMap.getString("MaterLectorPath.text")); // NOI18N
MaterLectorPath.setName("MaterLectorPath"); // NOI18N
jButton2.setAction(actionMap.get("SelectLuceneRepoPath")); // NOI18N
jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
jButton2.setName("jButton2"); // NOI18N
jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
jLabel7.setName("jLabel7"); // NOI18N
jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
jLabel8.setName("jLabel8"); // NOI18N
LectorRepositoryPath.setText(resourceMap.getString("LectorRepositoryPath.text")); // NOI18N
LectorRepositoryPath.setName("LectorRepositoryPath"); // NOI18N
jButton6.setAction(actionMap.get("SelectLectorRepositoryPath")); // NOI18N
jButton6.setText(resourceMap.getString("jButton6.text")); // NOI18N
jButton6.setName("jButton6"); // NOI18N
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 312, Short.MAX_VALUE))
.addComponent(jPB1, javax.swing.GroupLayout.DEFAULT_SIZE, 464, Short.MAX_VALUE)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(10, 10, 10)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel8))
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(LuceneRepoPath)
.addComponent(LectorRepositoryPath)
.addComponent(MaterLectorPath)
.addComponent(InstallationDirectory, javax.swing.GroupLayout.DEFAULT_SIZE, 406, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton6, javax.swing.GroupLayout.Alignment.LEADING))
.addComponent(jButton2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)))
.addGap(41, 41, 41))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(27, 27, 27)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(InstallationDirectory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5)
.addComponent(jButton3))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(MaterLectorPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(LectorRepositoryPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton6))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(LuceneRepoPath, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(jButton2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(jLabel7))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPB1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
jTabbedPane1.addTab(resourceMap.getString("jPanel2.TabConstraints.tabTitle"), jPanel2); // NOI18N
jPanel1.setName("jPanel1"); // NOI18N
jCheckBox1.setSelected(true);
jCheckBox1.setText(resourceMap.getString("jCheckBox1.text")); // NOI18N
jCheckBox1.setName("jCheckBox1"); // NOI18N
jCheckBox2.setSelected(true);
jCheckBox2.setText(resourceMap.getString("jCheckBox2.text")); // NOI18N
jCheckBox2.setName("jCheckBox2"); // NOI18N
downloadTomcatFlag.setText(resourceMap.getString("downloadTomcatFlag.text")); // NOI18N
downloadTomcatFlag.setName("downloadTomcatFlag"); // NOI18N
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jCheckBox1)
.addComponent(jCheckBox2)
.addComponent(downloadTomcatFlag))
.addContainerGap(204, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jCheckBox1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jCheckBox2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(downloadTomcatFlag)
.addContainerGap(154, Short.MAX_VALUE))
);
jTabbedPane1.addTab(resourceMap.getString("jPanel1.TabConstraints.tabTitle"), jPanel1); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 690, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 670, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 290, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
);
pack();
}// </editor-fold>//GEN-END:initComponents
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MainFrame().setVisible(true);
}
});
}
@org.jdesktop.application.Action
public void PathToMaterLector() {
c.setCurrentDirectory(new java.io.File("."));
c.setDialogTitle("Select folder for MaterLector");
c.setAcceptAllFileFilterUsed(false);
c.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int ret = c.showDialog(null, "Select");
if (ret == JFileChooser.APPROVE_OPTION) {
MaterLectorPath.setText(c.getSelectedFile().getAbsolutePath());
}
}
@org.jdesktop.application.Action
public void SelectLuceneRepoPath() {
c.setCurrentDirectory(new java.io.File("."));
c.setDialogTitle("Select folder for LuceneRepo");
c.setAcceptAllFileFilterUsed(false);
c.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int ret = c.showDialog(null, "Select");
if (ret == JFileChooser.APPROVE_OPTION) {
LuceneRepoPath.setText(c.getSelectedFile().getAbsolutePath());
}
}
@org.jdesktop.application.Action
public void SelectInstallationDirectory() {
c.setCurrentDirectory(new java.io.File("."));
c.setDialogTitle("Select folder for Installation Directory");
c.setAcceptAllFileFilterUsed(false);
c.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int ret = c.showDialog(null, "Select");
if (ret == JFileChooser.APPROVE_OPTION) {
InstallationDirectory.setText(c.getSelectedFile().getAbsolutePath());
}
}
@org.jdesktop.application.Action
public void InstallProgramm() {
jLabel7.setText("Validating data entered by the user.");
Boolean incorrectUserValues = false;
File fileForDirectoryTesting;
if (InstallationDirectory.getText().equals("")) {
incorrectUserValues = true;
JOptionPane.showMessageDialog(null, "You did not specify the "
+ "installation folder for the program.", "LectorInstaller", 1);
}
if (MaterLectorPath.getText().equals("")) {
incorrectUserValues = true;
JOptionPane.showMessageDialog(null, "You did not specify the "
+ "installation folder for the MaterLector.", "LectorInstaller", 1);
}
if (LuceneRepoPath.getText().equals("")) {
incorrectUserValues = true;
JOptionPane.showMessageDialog(null, "You did not specify the "
+ "nstallation folder for the LuceneRepo.", "LectorInstaller", 1);
}
if (LectorRepositoryPath.getText().equals("")) {
incorrectUserValues = true;
JOptionPane.showMessageDialog(null, "You did not specify the "
+ "installation folder for the Lector Repository.", "LectorInstaller", 1);
}
fileForDirectoryTesting = new File(InstallationDirectory.getText());
if (!fileForDirectoryTesting.exists()) {
incorrectUserValues = true;
JOptionPane.showMessageDialog(null, "The installation folder you "
+ "specified does not exist.", "LectorInstaller", 1);
}
fileForDirectoryTesting = new File(MaterLectorPath.getText());
if (!fileForDirectoryTesting.exists()) {
incorrectUserValues = true;
JOptionPane.showMessageDialog(null, "The directory MaterLector you "
+ "specified does not exist.", "LectorInstaller", 1);
}
fileForDirectoryTesting = new File(LuceneRepoPath.getText());
if (!fileForDirectoryTesting.exists()) {
incorrectUserValues = true;
JOptionPane.showMessageDialog(null, "The directory LuceneRepo you "
+ "specified does not exist.", "LectorInstaller", 1);
}
fileForDirectoryTesting = new File(LectorRepositoryPath.getText());
if (!fileForDirectoryTesting.exists()) {
incorrectUserValues = true;
JOptionPane.showMessageDialog(null, "The directory Lector Repository"
+ " you specified does not exist.", "LectorInstaller", 1);
}
if (!incorrectUserValues) {
OutputStream out = null;
jLabel7.setText("Unpacking files.");
try {
jButton4.setEnabled(false);
File tmpDir = new File("");
tmpDir = new File(tmpDir.getAbsolutePath() + "/temp");
tmpDir.mkdirs();
File f = new File(tmpDir.getAbsolutePath() + "/bins.zip");
InputStream inputStream =
MainFrame.class.getResourceAsStream(
"bins.zip");
out = new FileOutputStream(f);
byte[] buf = new byte[1024];
int len;
while ((len = inputStream.read(buf)) > 0) {
out.write(buf, 0, len);
}
out.close();
inputStream.close();
out.close();
UnZip UnZip = new UnZip(tmpDir);
UnZip.start_th();
DownloadApacheTomcat DownloadApacheTomcat = new DownloadApacheTomcat(this);
tmpDir = null;
} catch (Exception ex) {
LectorInstallerApp.logger.fatal(ex.getMessage(), ex);
}
} else {
jLabel7.setText("Check the settings specified by you.");
}
incorrectUserValues = false;
}
@Action
public void SelectLectorRepositoryPath() {
c.setCurrentDirectory(new java.io.File("."));
c.setDialogTitle("Select folder for Lector Repository");
c.setAcceptAllFileFilterUsed(false);
c.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int ret = c.showDialog(null, "Select");
if (ret == JFileChooser.APPROVE_OPTION) {
LectorRepositoryPath.setText(c.getSelectedFile().getAbsolutePath());
}
}
/*
//http://download.oracle.com/javase/tutorial/uiswing/components/dialog.html
//JOptionPane.showMessageDialog(null, "This is the simple message dialog box.", "Roseindia.net", 1);
//JOptionPane.showConfirmDialog(null, "This is the \"Yes/No/Cancel\" message dialog box.");
/*int n = JOptionPane.showConfirmDialog(null,
"Would you like green eggs and ham?",
"An Inane Question",
JOptionPane.YES_NO_OPTION);
System.out.println(n);
Object[] options = {"Yes, please",
"No way!"};
n = JOptionPane.showOptionDialog(null,
"Would you like green eggs and ham?",
"A Silly Question",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, //do not use a custom Icon
options, //the titles of buttons
options[0]); //default button title
System.out.println(n);
//Custom button text
Object[] options1 = {"Yes, please",
"No, thanks",
"No eggs, no ham!"};
n = JOptionPane.showOptionDialog(null,
"Would you like some green eggs to go "
+ "with that ham?",
"A Silly Question",
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options1,
options1[2]);
System.out.println(n);
*/
// Variables declaration - do not modify//GEN-BEGIN:variables
public static javax.swing.JTextField InstallationDirectory;
public static javax.swing.JTextField LectorRepositoryPath;
public static javax.swing.JTextField LuceneRepoPath;
public static javax.swing.JTextField MaterLectorPath;
public static javax.swing.JCheckBox downloadTomcatFlag;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton6;
public static javax.swing.JCheckBox jCheckBox1;
public static javax.swing.JCheckBox jCheckBox2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
public static javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
public static javax.swing.JProgressBar jPB1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JTabbedPane jTabbedPane1;
// End of variables declaration//GEN-END:variables
}