/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package gui.performer_main;
/**
*
* @author Dragan
*
* There is only one instance of this class,
* it represents the main window of Perfomer
* application.
* It's instantiated in main method of this
* class and there is reference to that
* instance:
* public static MainWindow appMainWindow;
*
*/
import core.engine.GlobalOperationEngine;
import java.awt.*;
public class MainWindow extends javax.swing.JFrame {
/**
* Creates new form MainWindow
*/
public MainWindow() {
super("Performer");
initComponents();
setLayout(new GridLayout());
setSize(550,420);
// project
jMenuItem3.setEnabled(false);
jMenuItem4.setEnabled(false);
jMenuItem5.setEnabled(false);
jMenuItem6.setEnabled(false);
jMenuItem13.setEnabled(false);
// test
jMenuItem9.setEnabled(false);
jMenuItem10.setEnabled(false);
jMenuItem11.setEnabled(false);
}
/**
* 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() {
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem();
jMenuItem5 = new javax.swing.JMenuItem();
jSeparator1 = new javax.swing.JPopupMenu.Separator();
jMenuItem13 = new javax.swing.JMenuItem();
jMenuItem6 = new javax.swing.JMenuItem();
jSeparator2 = new javax.swing.JPopupMenu.Separator();
jMenuItem4 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
jMenuItem7 = new javax.swing.JMenuItem();
jMenuItem8 = new javax.swing.JMenuItem();
jMenuItem9 = new javax.swing.JMenuItem();
jMenuItem10 = new javax.swing.JMenuItem();
jMenuItem11 = new javax.swing.JMenuItem();
jMenu3 = new javax.swing.JMenu();
jMenu4 = new javax.swing.JMenu();
jMenu5 = new javax.swing.JMenu();
jMenuItem12 = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jMenu1.setText("Project");
jMenuItem1.setLabel("New Project");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem1);
jMenuItem2.setText("Open Project");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem2);
jMenuItem3.setText("Save Project");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem3);
jMenuItem5.setText("Save Project as");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem5);
jMenu1.add(jSeparator1);
jMenuItem13.setText("Project Properties");
jMenuItem13.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem13ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem13);
jMenuItem6.setText("Add Test");
jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem6ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem6);
jMenu1.add(jSeparator2);
jMenuItem4.setText("Close Project");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem4);
jMenuBar1.add(jMenu1);
jMenu2.setText("Test");
jMenuItem7.setText("New Test");
jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem7ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem7);
jMenuItem8.setText("Open Test");
jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem8ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem8);
jMenuItem9.setText("Save Test");
jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem9ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem9);
jMenuItem10.setText("Save Test as");
jMenu2.add(jMenuItem10);
jMenuItem11.setText("Close Test");
jMenu2.add(jMenuItem11);
jMenuBar1.add(jMenu2);
jMenu3.setText("Options");
jMenu4.setText("Project Quick Bar");
jMenu3.add(jMenu4);
jMenu5.setText("Test Quick Bar");
jMenu3.add(jMenu5);
jMenuItem12.setText("Settings");
jMenuItem12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem12ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem12);
jMenuBar1.add(jMenu3);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 279, Short.MAX_VALUE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
/*
* Enables the necessary buttons for project
*/
public void unlockProjectFeatures ()
{
jMenuItem3.setEnabled(true);
jMenuItem4.setEnabled(true);
jMenuItem5.setEnabled(true);
jMenuItem6.setEnabled(true);
jMenuItem13.setEnabled(true);
}
public void unlockTestFeatures ()
{
jMenuItem9.setEnabled(true);
jMenuItem10.setEnabled(true);
jMenuItem11.setEnabled(true);
}
/*
* Project -> New Project from menu bar
* Opens a dialog for new project
*/
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
(new NewProjectDialog(this, true)).setVisible(true);
}//GEN-LAST:event_jMenuItem1ActionPerformed
/*
* Project -> Project Properties from menu bar
* Gives a look to propeties of current Project
*
* REMARK: STILL SOME WORK
*/
private void jMenuItem13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem13ActionPerformed
projectSettings();
}//GEN-LAST:event_jMenuItem13ActionPerformed
/*
* Project -> Open Project from menu bar
* Opens a dialog which is used to browse to exsisted project
*
* REMARK: NOT DONE YET
*/
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
projectFileChooser1.showDialog(this);
}//GEN-LAST:event_jMenuItem2ActionPerformed
/*
* Project -> Save Project from menu bar
* Save changes to previously saved project.
* In case of first saving, same effect as Save Project as
*
* REMARK: NOT DONE YET
*/
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
projectFileChooser2.showDialog(this);
}//GEN-LAST:event_jMenuItem3ActionPerformed
/*
* Project -> Save Project as from menu bar
* User chooses a location for saving the project
*
* REMARK: NOT DONE YET
*/
private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
projectFileChooser2.showDialog(this);
}//GEN-LAST:event_jMenuItem5ActionPerformed
/*
* Projet -> Add Test from menu bar
* Add a existing test to current project
*
* REMARK: NOT DONE YET
*/
private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
testFileChooser1.showDialog(this);
}//GEN-LAST:event_jMenuItem6ActionPerformed
/*
* Project -> Close Project from menu bar
* Close current project
*
* REMARK: NOT DONE YET
*/
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
MainWindow.runningProject = null;
//MainWindow.panel = null;
jMenuItem3.setEnabled(false);
jMenuItem4.setEnabled(false);
jMenuItem5.setEnabled(false);
jMenuItem6.setEnabled(false);
jMenuItem13.setEnabled(false);
//MainWindow.appMainWindow.repaint();
}//GEN-LAST:event_jMenuItem4ActionPerformed
private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
testFileChooser2.showDialog(this);
}//GEN-LAST:event_jMenuItem8ActionPerformed
private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
testFileChooser3.showDialog(this);
}//GEN-LAST:event_jMenuItem9ActionPerformed
/*
* Options -> Setting
* Application Settings
*/
private void jMenuItem12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem12ActionPerformed
(new SettingsDialog(this,true)).setVisible(true);
}//GEN-LAST:event_jMenuItem12ActionPerformed
private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
(new NewTestDialog(this,true)).setVisible(true);
}//GEN-LAST:event_jMenuItem7ActionPerformed
void projectSettings ()
{
(new ProjectSettingsDialog(this,true)).setVisible(true);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/*
* Set the Nimbus look and feel
*/
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/*
* 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(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/*
* Create and display the form
*/
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
(appMainWindow = new MainWindow()).setVisible(true);
(new Thread(appMainWindow.GOEngine = new GlobalOperationEngine(35))).start();
}
});
}
static public MainWindow appMainWindow; // only instance of this class
static public Project runningProject; // reference to opened project
static public Component panel = new javax.swing.JPanel();
public GlobalOperationEngine GOEngine;
private MyFileChooser projectFileChooser1 = new MyFileChooser("Open");
private MyFileChooser projectFileChooser2 = new MyFileChooser("Save");
private MyFileChooser testFileChooser1 = new MyFileChooser("Add");
private MyFileChooser testFileChooser2 = new MyFileChooser("Open");
private MyFileChooser testFileChooser3 = new MyFileChooser("Save");
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenu jMenu4;
private javax.swing.JMenu jMenu5;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem10;
private javax.swing.JMenuItem jMenuItem11;
private javax.swing.JMenuItem jMenuItem12;
private javax.swing.JMenuItem jMenuItem13;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JMenuItem jMenuItem6;
private javax.swing.JMenuItem jMenuItem7;
private javax.swing.JMenuItem jMenuItem8;
private javax.swing.JMenuItem jMenuItem9;
private javax.swing.JPopupMenu.Separator jSeparator1;
private javax.swing.JPopupMenu.Separator jSeparator2;
// End of variables declaration//GEN-END:variables
}