package reportbuilder;
import java.util.Locale;
import javax.swing.text.DefaultCaret;
public class MainFrame extends javax.swing.JFrame {
private MultiThreadedServer server;
private Thread thread;
private ConnectionIndex conIndex;
private AlwayDeleteFile alwayDelete;
public MainFrame() {
initComponents();
this.setLocale(new Locale("en", "US"));
DefaultCaret caret = (DefaultCaret) textArea1.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
ReportBuilder.textArea1 = textArea1;
try {
ReportBuilder.writeMessage("ConIndex XML : " + ReportBuilder.xmlConnectionString);
conIndex = new ConnectionIndex();
} catch (Exception ex) {
ex.printStackTrace();
ReportBuilder.writeMessage("ConIndex XML err: " + ex.getMessage());
}
server = new MultiThreadedServer(conIndex, ReportBuilder.portNumber);
thread = new Thread(server);
thread.start();
try {
alwayDelete = new AlwayDeleteFile();
} catch (Exception ex) {
ReportBuilder.writeMessage("Alway delete err: " + ex.getMessage());
}
this.setTitle("iReport Builder, " + ReportBuilder.prefix + ", Port " + ReportBuilder.portNumber);
}
/**
* 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")
// //GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
textArea1 = new javax.swing.JTextArea();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("iReport Builder");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});
textArea1.setEditable(false);
textArea1.setBackground(new java.awt.Color(51, 51, 51));
textArea1.setColumns(20);
textArea1.setForeground(new java.awt.Color(0, 153, 51));
textArea1.setLineWrap(true);
textArea1.setRows(5);
textArea1.setDisabledTextColor(new java.awt.Color(0, 153, 51));
textArea1.setSelectedTextColor(new java.awt.Color(204, 204, 204));
jScrollPane1.setViewportView(textArea1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 748, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// //GEN-END:initComponents
private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
System.out.println("Closing all connection ...");
try {
conIndex.CloseAll();
} catch (Exception ex) {
System.out.println("Exception:Closing: " + ex.getMessage());
}
System.out.println("Stopping thread ...");
try {
thread = null;
} catch (Exception ex) {
System.out.println("Error stop thread :: " + ex.getMessage());
}
System.out.println("Stopping thread ...");
try {
server.stop();
} catch (Exception ex) {
System.out.println("Error stop server :: " + ex.getMessage());
}
System.out.println("Stopping alway delete ...");
try {
alwayDelete.close();
} catch (Exception ex) {
System.out.println("Error stop alway delete :: " + ex.getMessage());
}
System.out.println("Stop all ...");
}//GEN-LAST:event_formWindowClosing
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MainFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea textArea1;
// End of variables declaration//GEN-END:variables
}