| 1 | package event.editor; |
|---|
| 2 | |
|---|
| 3 | import java.awt.event.*; |
|---|
| 4 | import java.util.Observable; |
|---|
| 5 | import scriptbuilder.structures.events.CADEvent; |
|---|
| 6 | import scriptbuilder.structures.events.I_ScriptEvent; |
|---|
| 7 | |
|---|
| 8 | /** |
|---|
| 9 | * |
|---|
| 10 | * @author nathaniellehrer |
|---|
| 11 | */ |
|---|
| 12 | public class CADLogPanel extends javax.swing.JPanel implements RemoveablePanel, ScriptEventEditorPanel |
|---|
| 13 | { |
|---|
| 14 | |
|---|
| 15 | private ActionListener removeListener; |
|---|
| 16 | private CADEvent event; |
|---|
| 17 | |
|---|
| 18 | /** |
|---|
| 19 | * Creates new form DetailPanel |
|---|
| 20 | */ |
|---|
| 21 | public CADLogPanel() |
|---|
| 22 | { |
|---|
| 23 | initComponents(); |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | public void setRemoveListener(ActionListener listener) |
|---|
| 27 | { |
|---|
| 28 | removeListener = listener; |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | public void getEventObject(I_ScriptEvent sei) |
|---|
| 32 | { |
|---|
| 33 | event = (CADEvent) sei; |
|---|
| 34 | CadTextField.setText(event.detail); |
|---|
| 35 | CadTextField.addKeyListener(new KeyListener() |
|---|
| 36 | { |
|---|
| 37 | |
|---|
| 38 | public void keyTyped(KeyEvent e) |
|---|
| 39 | { |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | public void keyPressed(KeyEvent e) |
|---|
| 43 | { |
|---|
| 44 | if(e.getKeyCode() == KeyEvent.VK_ENTER) |
|---|
| 45 | { |
|---|
| 46 | event.detail = CadTextField.getText(); |
|---|
| 47 | } |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | public void keyReleased(KeyEvent e) |
|---|
| 51 | { |
|---|
| 52 | } |
|---|
| 53 | }); |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | public void update(Observable o, Object arg) |
|---|
| 57 | { |
|---|
| 58 | throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | /** |
|---|
| 62 | * This method is called from within the constructor to initialize the form. |
|---|
| 63 | * WARNING: Do NOT modify this code. The content of this method is always |
|---|
| 64 | * regenerated by the Form Editor. |
|---|
| 65 | */ |
|---|
| 66 | @SuppressWarnings("unchecked") |
|---|
| 67 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
|---|
| 68 | private void initComponents() |
|---|
| 69 | { |
|---|
| 70 | |
|---|
| 71 | removeButton = new javax.swing.JButton(); |
|---|
| 72 | jLabel1 = new javax.swing.JLabel(); |
|---|
| 73 | jScrollPane1 = new javax.swing.JScrollPane(); |
|---|
| 74 | CadTextField = new javax.swing.JTextArea(); |
|---|
| 75 | |
|---|
| 76 | removeButton.setText("Remove"); |
|---|
| 77 | removeButton.addMouseListener(new java.awt.event.MouseAdapter() |
|---|
| 78 | { |
|---|
| 79 | public void mouseClicked(java.awt.event.MouseEvent evt) |
|---|
| 80 | { |
|---|
| 81 | removeButtonremoveThisProperty(evt); |
|---|
| 82 | } |
|---|
| 83 | }); |
|---|
| 84 | |
|---|
| 85 | jLabel1.setText("Cad Log Text"); |
|---|
| 86 | |
|---|
| 87 | CadTextField.setColumns(20); |
|---|
| 88 | CadTextField.setRows(5); |
|---|
| 89 | jScrollPane1.setViewportView(CadTextField); |
|---|
| 90 | |
|---|
| 91 | org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); |
|---|
| 92 | this.setLayout(layout); |
|---|
| 93 | layout.setHorizontalGroup( |
|---|
| 94 | layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 95 | .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() |
|---|
| 96 | .addContainerGap() |
|---|
| 97 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) |
|---|
| 98 | .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 506, Short.MAX_VALUE) |
|---|
| 99 | .add(layout.createSequentialGroup() |
|---|
| 100 | .add(jLabel1) |
|---|
| 101 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 330, Short.MAX_VALUE) |
|---|
| 102 | .add(removeButton))) |
|---|
| 103 | .addContainerGap()) |
|---|
| 104 | ); |
|---|
| 105 | layout.setVerticalGroup( |
|---|
| 106 | layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
|---|
| 107 | .add(layout.createSequentialGroup() |
|---|
| 108 | .addContainerGap() |
|---|
| 109 | .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) |
|---|
| 110 | .add(removeButton) |
|---|
| 111 | .add(jLabel1)) |
|---|
| 112 | .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
|---|
| 113 | .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE) |
|---|
| 114 | .addContainerGap()) |
|---|
| 115 | ); |
|---|
| 116 | }// </editor-fold>//GEN-END:initComponents |
|---|
| 117 | |
|---|
| 118 | private void removeButtonremoveThisProperty(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_removeButtonremoveThisProperty |
|---|
| 119 | if (removeListener != null) |
|---|
| 120 | { |
|---|
| 121 | removeListener.actionPerformed(new ActionEvent(this, 0, "")); |
|---|
| 122 | } |
|---|
| 123 | }//GEN-LAST:event_removeButtonremoveThisProperty |
|---|
| 124 | |
|---|
| 125 | |
|---|
| 126 | // Variables declaration - do not modify//GEN-BEGIN:variables |
|---|
| 127 | private javax.swing.JTextArea CadTextField; |
|---|
| 128 | private javax.swing.JLabel jLabel1; |
|---|
| 129 | private javax.swing.JScrollPane jScrollPane1; |
|---|
| 130 | private javax.swing.JButton removeButton; |
|---|
| 131 | // End of variables declaration//GEN-END:variables |
|---|
| 132 | |
|---|
| 133 | } |
|---|