/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package algoD;
import algoD.interpreter.CODE;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.text.BadLocationException;
/**
*
* @author dusakus
*/
public class interGUI extends javax.swing.JFrame {
/**
* Creates new form interGUI
*/
public interGUI() {
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() {
TABS = new javax.swing.JTabbedPane();
TAB_HALU = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
TAB_CODE = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
CODE_AREA = new javax.swing.JTextArea();
doRUN = new javax.swing.JButton();
jScrollPane2 = new javax.swing.JScrollPane();
INPUT_AREA = new javax.swing.JTextArea();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
SelectCodeFile = new javax.swing.JButton();
LoadCode = new javax.swing.JToggleButton();
codeFileArea = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
jButton3 = new javax.swing.JButton();
CodeName = new javax.swing.JTextField();
TAB_RUN = new javax.swing.JPanel();
jLabel7 = new javax.swing.JLabel();
ExecTimeField = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jScrollPane3 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
TAB_SETUP = new javax.swing.JPanel();
jToolBar1 = new javax.swing.JToolBar();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
TABS.setTabLayoutPolicy(javax.swing.JTabbedPane.SCROLL_TAB_LAYOUT);
TABS.setTabPlacement(javax.swing.JTabbedPane.BOTTOM);
jButton1.setText("LEAVE ME ALLONE !");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("D-CODE HOMEPAGE");
jLabel1.setText("First of all, this program is a part of D-CODE project by Dusakus");
jLabel2.setText("You can use it in any way that isn't disallowed in licence /\\ /\\ /\\ /\\ /\\");
jLabel3.setText("If you don't know how to use it just don't use it(or read about it on the website linked above)");
javax.swing.GroupLayout TAB_HALULayout = new javax.swing.GroupLayout(TAB_HALU);
TAB_HALU.setLayout(TAB_HALULayout);
TAB_HALULayout.setHorizontalGroup(
TAB_HALULayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TAB_HALULayout.createSequentialGroup()
.addContainerGap()
.addGroup(TAB_HALULayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(TAB_HALULayout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2))
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
TAB_HALULayout.setVerticalGroup(
TAB_HALULayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, TAB_HALULayout.createSequentialGroup()
.addContainerGap()
.addGroup(TAB_HALULayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 350, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
TABS.addTab("HALU!", TAB_HALU);
CODE_AREA.setColumns(20);
CODE_AREA.setRows(5);
jScrollPane1.setViewportView(CODE_AREA);
doRUN.setText("RUN");
doRUN.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
doRUNActionPerformed(evt);
}
});
INPUT_AREA.setColumns(20);
INPUT_AREA.setRows(5);
jScrollPane2.setViewportView(INPUT_AREA);
jLabel4.setText("Write your code there ----------->");
jLabel5.setText("Or load it from file ...");
SelectCodeFile.setText("Select");
SelectCodeFile.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
SelectCodeFileActionPerformed(evt);
}
});
LoadCode.setText("Load Code");
codeFileArea.setText("Select File ...");
codeFileArea.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
codeFileAreaActionPerformed(evt);
}
});
jLabel6.setText("And set your input there:");
jButton3.setText("Save Code");
CodeName.setText("UNNAMED");
javax.swing.GroupLayout TAB_CODELayout = new javax.swing.GroupLayout(TAB_CODE);
TAB_CODE.setLayout(TAB_CODELayout);
TAB_CODELayout.setHorizontalGroup(
TAB_CODELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, TAB_CODELayout.createSequentialGroup()
.addGroup(TAB_CODELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jScrollPane2)
.addComponent(doRUN, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.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(javax.swing.GroupLayout.Alignment.TRAILING, TAB_CODELayout.createSequentialGroup()
.addComponent(codeFileArea)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(SelectCodeFile))
.addComponent(LoadCode, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(CodeName))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 449, Short.MAX_VALUE))
);
TAB_CODELayout.setVerticalGroup(
TAB_CODELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1)
.addGroup(TAB_CODELayout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(TAB_CODELayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(SelectCodeFile)
.addComponent(codeFileArea, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(LoadCode)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton3)
.addGap(18, 18, 18)
.addComponent(CodeName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 165, Short.MAX_VALUE)
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(doRUN, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
);
TABS.addTab("CODE", TAB_CODE);
jLabel7.setText("Execution Time: ");
ExecTimeField.setText("00000");
jLabel8.setText("Output:");
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane3.setViewportView(jTextArea1);
javax.swing.GroupLayout TAB_RUNLayout = new javax.swing.GroupLayout(TAB_RUN);
TAB_RUN.setLayout(TAB_RUNLayout);
TAB_RUNLayout.setHorizontalGroup(
TAB_RUNLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TAB_RUNLayout.createSequentialGroup()
.addContainerGap()
.addGroup(TAB_RUNLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TAB_RUNLayout.createSequentialGroup()
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(ExecTimeField))
.addComponent(jLabel8)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(274, Short.MAX_VALUE))
);
TAB_RUNLayout.setVerticalGroup(
TAB_RUNLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(TAB_RUNLayout.createSequentialGroup()
.addContainerGap()
.addGroup(TAB_RUNLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(ExecTimeField))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE)
.addContainerGap())
);
TABS.addTab("RUNNING", TAB_RUN);
javax.swing.GroupLayout TAB_SETUPLayout = new javax.swing.GroupLayout(TAB_SETUP);
TAB_SETUP.setLayout(TAB_SETUPLayout);
TAB_SETUPLayout.setHorizontalGroup(
TAB_SETUPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 686, Short.MAX_VALUE)
);
TAB_SETUPLayout.setVerticalGroup(
TAB_SETUPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 492, Short.MAX_VALUE)
);
TABS.addTab("SETUP", TAB_SETUP);
jToolBar1.setFloatable(false);
jToolBar1.setRollover(true);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(TABS)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(TABS, javax.swing.GroupLayout.DEFAULT_SIZE, 519, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
TABS.remove(TAB_HALU);
}//GEN-LAST:event_jButton1ActionPerformed
private void SelectCodeFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SelectCodeFileActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_SelectCodeFileActionPerformed
private void codeFileAreaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_codeFileAreaActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_codeFileAreaActionPerformed
private void doRUNActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_doRUNActionPerformed
StData.currentCode = new CODE(CodeName.getText());
String line = "START";
int S = 0, E = 0, L = 0;
String[] lines = CODE_AREA.getText().split("\\n");
for(String s : lines){
StData.currentCode.addLine(s);
StData.log.println("[Reading code]==> read line >>>"+ s, "D");
}
String[] params = INPUT_AREA.getText().split("\\n");
for(String s : params){
StData.currentCode.addArg(s);
StData.log.println("[Reading code]==> read argument >>>"+ s, "D");
}
StData.currentCode.PRINT(StData.log);
}//GEN-LAST:event_doRUNActionPerformed
/**
* @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(interGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(interGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(interGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(interGUI.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() {
new interGUI().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextArea CODE_AREA;
private javax.swing.JTextField CodeName;
private javax.swing.JLabel ExecTimeField;
private javax.swing.JTextArea INPUT_AREA;
private javax.swing.JToggleButton LoadCode;
private javax.swing.JButton SelectCodeFile;
private javax.swing.JTabbedPane TABS;
private javax.swing.JPanel TAB_CODE;
private javax.swing.JPanel TAB_HALU;
private javax.swing.JPanel TAB_RUN;
private javax.swing.JPanel TAB_SETUP;
private javax.swing.JTextField codeFileArea;
private javax.swing.JButton doRUN;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JToolBar jToolBar1;
// End of variables declaration//GEN-END:variables
}