open.java 6.49 KB
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package GUI;

import LOGIC.Internacional;
import LOGIC.ObjectList;
import LOGIC.Serialize;
import javax.swing.table.DefaultTableModel;

/**
*
* @author Dalay
*/
public class open extends javax.swing.JFrame {

public open(Internacional inter, ObjectList listas) {
this.listas = listas;
initComponents();
mostrar();
remover.setText(inter.retornarMensagem("COD0021"));
abrir.setText(inter.retornarMensagem("COD0023"));
cancelar.setText(inter.retornarMensagem("COD0026"));
}
DefaultTableModel tabTipo = new DefaultTableModel(null, new String[]{"Nome"}) {
public boolean isCellEditable(int rowIndex, int mColIndex) {
return false;
}
};
ObjectList listas;
Serialize s = new Serialize();

/**
* 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() {

jScrollPane1 = new javax.swing.JScrollPane();
table = new javax.swing.JTable();
cancelar = new javax.swing.JButton();
abrir = new javax.swing.JButton();
remover = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setMinimumSize(new java.awt.Dimension(298, 237));

table.setModel(tabTipo);
jScrollPane1.setViewportView(table);

cancelar.setText("cancelar");
cancelar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelarActionPerformed(evt);
}
});

abrir.setText("abrir");
abrir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
abrirActionPerformed(evt);
}
});

remover.setText("Remover");
remover.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
removerActionPerformed(evt);
}
});

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.PREFERRED_SIZE, 274, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(remover)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(abrir)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cancelar)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cancelar)
.addComponent(abrir)
.addComponent(remover))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

pack();
}// </editor-fold>//GEN-END:initComponents

private void abrirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_abrirActionPerformed
listas.getChannelList().clear();
listas.getContractList().clear();
listas.getInstanceList().clear();
listas.getTypeList().clear();
listas.setChannelList(s.open(table.getSelectedRow()).getChannelList());
listas.setContractList(s.open(table.getSelectedRow()).getContractList());
listas.setInstanceList(s.open(table.getSelectedRow()).getInstanceList());
listas.setTypeList(s.open(table.getSelectedRow()).getTypeList());
listas.setDefaultrenameNumber(s.open(table.getSelectedRow()).getDefaultrenameNumber());
listas.setProcessosAuxiliares(s.open(table.getSelectedRow()).getProcessosAuxiliares());
this.dispose();
}//GEN-LAST:event_abrirActionPerformed

private void cancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelarActionPerformed
this.dispose();// TODO add your handling code here:
}//GEN-LAST:event_cancelarActionPerformed

private void removerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removerActionPerformed
if(table.getSelectedRow()>-1){
s.remove(table.getSelectedRow());
mostrar();
}
// TODO add your handling code here:
}//GEN-LAST:event_removerActionPerformed

/**
* @param args the command line arguments
*/
public void mostrar() {
while (tabTipo.getRowCount() > 0) {
tabTipo.removeRow(0);
}
if (s.getSaves().isEmpty()) {
System.out.println("saves eh vazio...");
} else {

String[] linha = new String[]{null, null};
for (int j = 0; j < s.getSaves().size(); j++) {
tabTipo.addRow(linha);
tabTipo.setValueAt(s.getSaves().get(j).getNome(), j, 0);

}
}
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton abrir;
private javax.swing.JButton cancelar;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JButton remover;
private javax.swing.JTable table;
// End of variables declaration//GEN-END:variables
}