package cz.muni.fi.bronchus.gui; import java.awt.Color; import java.io.File; import javax.swing.SwingConstants; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; import java.awt.Dimension; import java.util.ArrayList; import cz.muni.fi.bronchus.questions.*; import java.util.List; import javax.swing.JOptionPane; import cz.muni.fi.bronchusio.loader.Loader; /* * ImportQuestionDialog.java * * Created on 15. duben 2005, 11:04 */ /** * * @author xudrzal */ public class ImportQuestionsDialog extends MyCentralizedJDialog { private static final Color Table_Selection_Background_COLOR_normal = new Color(153, 153, 203); private static final Color Table_Header_Background_COLOR = new Color(238, 238, 238); private static final Color Table_Selection_Background_COLOR_modify = new Color(255, 255, 0); private static int[] colwidthssource={30,30,150,120,160}; //jSourceTable private static int[] colwidthsimport={30,150,120,190}; //jImportTable public int IMPORT_OPTION=0; private int selected=-1; private MyUtilities myUtilities; private ArrayList questions; private ArrayList importquestions; private MyResources myResources; /** Creates new form ImportQuestionDialog */ public ImportQuestionsDialog(java.awt.Frame parent, boolean modal, MyResources res) { super(parent, modal); myResources = res; initComponents(); myInitComponents(); myUtilities=new MyUtilities(myResources); questions=new ArrayList(); importquestions=new ArrayList(); } /** 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. */ private void initComponents() {//GEN-BEGIN:initComponents jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jSourceTable = new javax.swing.JTable(); jLabel2 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); jImportTable = new javax.swing.JTable(); jImportButton = new javax.swing.JButton(); jCancelButton = new javax.swing.JButton(); jCheckAllButton = new javax.swing.JButton(); jUncheckAllButton = new javax.swing.JButton(); jAddButton = new javax.swing.JButton(); getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { closeDialog(evt); } }); jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); jLabel1.setFont(new java.awt.Font("Dialog", 1, 11)); jLabel1.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/ImportQuestionsDialogBundle", "Source_questions:")); jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 20, -1, -1)); jSourceTable.setFont(new java.awt.Font("Dialog", 0, 11)); jSourceTable.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null, null} }, new String [] { "", "#", "Title", "Format", "Question Wording" } ) { Class[] types = new Class [] { java.lang.Boolean.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class }; boolean[] canEdit = new boolean [] { true, false, false, false, false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); jSourceTable.setPreferredSize(new java.awt.Dimension(480, 16)); jScrollPane1.setViewportView(jSourceTable); jPanel1.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 40, 490, 120)); jLabel2.setFont(new java.awt.Font("Dialog", 1, 11)); jLabel2.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/ImportQuestionsDialogBundle", "Importing_questions:")); jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 180, -1, -1)); jImportTable.setFont(new java.awt.Font("Dialog", 0, 11)); jImportTable.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { }, new String [] { "#", "Title", "Format", "Question Wording" } ) { Class[] types = new Class [] { java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class }; boolean[] canEdit = new boolean [] { false, false, false, false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); jScrollPane2.setViewportView(jImportTable); jPanel1.add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 200, 490, 160)); jImportButton.setFont(new java.awt.Font("Dialog", 0, 11)); jImportButton.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/ImportQuestionsDialogBundle", "Import")); jImportButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jImportButtonActionPerformed(evt); } }); jPanel1.add(jImportButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 370, -1, -1)); jCancelButton.setFont(new java.awt.Font("Dialog", 0, 11)); jCancelButton.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/ImportQuestionsDialogBundle", "Cancel")); jCancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCancelButtonActionPerformed(evt); } }); jPanel1.add(jCancelButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 370, -1, -1)); jCheckAllButton.setFont(new java.awt.Font("Dialog", 0, 11)); jCheckAllButton.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/ImportQuestionsDialogBundle", "Check_all")); jCheckAllButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckAllButtonActionPerformed(evt); } }); jPanel1.add(jCheckAllButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 10, -1, -1)); jUncheckAllButton.setFont(new java.awt.Font("Dialog", 0, 11)); jUncheckAllButton.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/ImportQuestionsDialogBundle", "Uncheck_all")); jUncheckAllButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jUncheckAllButtonActionPerformed(evt); } }); jPanel1.add(jUncheckAllButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 10, -1, -1)); jAddButton.setFont(new java.awt.Font("Dialog", 0, 11)); jAddButton.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/ImportQuestionsDialogBundle", "Add")); jAddButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jAddButtonActionPerformed(evt); } }); jPanel1.add(jAddButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 170, -1, -1)); getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 510, 400)); pack(); }//GEN-END:initComponents private void jAddButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jAddButtonActionPerformed // TODO add your handling code here: int counter=0; while (counter0) jImportButton.setEnabled(true); }//GEN-LAST:event_jAddButtonActionPerformed private void jImportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jImportButtonActionPerformed // TODO add your handling code here: selected=0; setVisible(false); dispose(); }//GEN-LAST:event_jImportButtonActionPerformed private void jCancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCancelButtonActionPerformed // TODO add your handling code here: selected=-1; setVisible(false); dispose(); }//GEN-LAST:event_jCancelButtonActionPerformed private void jUncheckAllButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jUncheckAllButtonActionPerformed // TODO add your handling code here: for (int i=0; i