/* * AdvancedOptionsDialog.java * * Created on June 10, 2004, 1:02 PM */ package cz.muni.fi.bronchus.gui; import cz.muni.fi.bronchus.questions.*; import cz.muni.fi.bronchus.antlrparsers.*; import java.awt.*; import javax.swing.table.*; import javax.swing.*; import java.util.*; import java.io.StringReader; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import javax.swing.text.html.*; /** * * @author xudrzal */ public class AdvancedOptionsDialog extends MyCentralizedJDialog { public int FINISH_OPTION=0; private int selected=-1; private int activeCard; private Question question; private MyUtilities myUtilities; private SelectionListener selectionListener; private MyUneditableTableModel uneditableTableModel; private boolean feedbacks=false; private boolean hints=false; private boolean solutions=false; private int algorithm=-1; private FIBWizard fibWizard; private boolean addingrow=false; private MyResources myResources; /** Creates new form AdvancedOptionsDialog */ public AdvancedOptionsDialog(java.awt.Frame parent, boolean modal, Question q, MyResources res) { super(parent, modal); myResources = res; initComponents(); myInitComponents(); activeCard=1; myUtilities=new MyUtilities(myResources); fibWizard=new FIBWizard(this,true, myResources); setAlgorithm(algorithm); } /** 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(); jSeparator1 = new javax.swing.JSeparator(); jBackButton = new javax.swing.JButton(); jNextButton = new javax.swing.JButton(); jCancelButton = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jSeparator2 = new javax.swing.JSeparator(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); jSummarizePanel = new javax.swing.JPanel(); jLabel5 = new javax.swing.JLabel(); jSeparator3 = new javax.swing.JSeparator(); jLabel8 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jTextPane1 = new javax.swing.JTextPane(); jLabel6 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); jResprocessingTable1 = new javax.swing.JTable(); jLabel10 = new javax.swing.JLabel(); jResprocessingPanel = new javax.swing.JPanel(); jLabel7 = new javax.swing.JLabel(); jSeparator5 = new javax.swing.JSeparator(); jScrollPane3 = new javax.swing.JScrollPane(); jResprocessingTable2 = new javax.swing.JTable(); jConditionTF = new javax.swing.JTextField(); jLabel9 = new javax.swing.JLabel(); jHelpGrammarButton = new javax.swing.JButton(); jValidateButton = new javax.swing.JButton(); jAddConditionButton = new javax.swing.JButton(); jConditionLabel = new javax.swing.JLabel(); jFIBButton = new javax.swing.JButton(); jLabel11 = new javax.swing.JLabel(); jHintScrollPane = new javax.swing.JScrollPane(); jHintTextArea = new javax.swing.JTextArea(); jSolutionScrollPane = new javax.swing.JScrollPane(); jSolutionTextArea = new javax.swing.JTextArea(); jHintLabel = new javax.swing.JLabel(); jSolutionLabel = new javax.swing.JLabel(); jFinishButton = new javax.swing.JButton(); jButton1 = new javax.swing.JButton(); getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); setTitle(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "Advanced_Options_for_")); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { closeDialog(evt); } }); jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); jPanel1.setPreferredSize(new java.awt.Dimension(600, 400)); jSeparator1.setBorder(new javax.swing.border.EtchedBorder()); jSeparator1.setPreferredSize(new java.awt.Dimension(600, 2)); jPanel1.add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 360, -1, -1)); jBackButton.setFont(new java.awt.Font("Dialog", 0, 11)); jBackButton.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "<_Back")); jBackButton.setEnabled(false); jBackButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBackButtonActionPerformed(evt); } }); jPanel1.add(jBackButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 370, -1, -1)); jNextButton.setFont(new java.awt.Font("Dialog", 0, 11)); jNextButton.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "Next_>")); jNextButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jNextButtonActionPerformed(evt); } }); jPanel1.add(jNextButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 370, -1, -1)); jCancelButton.setFont(new java.awt.Font("Dialog", 0, 11)); jCancelButton.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "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(520, 370, -1, -1)); jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); jPanel2.setBackground(javax.swing.UIManager.getDefaults().getColor("Button.focus")); jPanel2.setPreferredSize(new java.awt.Dimension(150, 360)); jLabel1.setFont(new java.awt.Font("Dialog", 1, 11)); jLabel1.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "Steps:")); jPanel2.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, -1)); jSeparator2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0))); jSeparator2.setPreferredSize(new java.awt.Dimension(130, 1)); jPanel2.add(jSeparator2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 25, -1, -1)); jLabel2.setFont(new java.awt.Font("Dialog", 0, 11)); jLabel2.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "1._Summarize")); jPanel2.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 30, -1, -1)); jLabel3.setFont(new java.awt.Font("Dialog", 0, 11)); jLabel3.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "2._Resprocessing")); jPanel2.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 50, -1, -1)); jLabel4.setFont(new java.awt.Font("Dialog", 0, 11)); jPanel2.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 70, -1, -1)); jPanel1.add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1)); jPanel3.setLayout(new java.awt.CardLayout()); jPanel3.setPreferredSize(new java.awt.Dimension(450, 360)); jSummarizePanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); jLabel5.setFont(new java.awt.Font("Dialog", 1, 11)); jLabel5.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "Summarize")); jSummarizePanel.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, -1)); jSeparator3.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0))); jSeparator3.setPreferredSize(new java.awt.Dimension(430, 1)); jSummarizePanel.add(jSeparator3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 25, -1, -1)); jLabel8.setFont(new java.awt.Font("Dialog", 1, 11)); jLabel8.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "True/False")); jSummarizePanel.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 40, -1, -1)); jScrollPane1.setPreferredSize(new java.awt.Dimension(400, 200)); jTextPane1.setEnabled(false); jScrollPane1.setViewportView(jTextPane1); jSummarizePanel.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 60, 410, 160)); jLabel6.setFont(new java.awt.Font("Dialog", 1, 11)); jLabel6.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "Resprocessing")); jSummarizePanel.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 230, -1, -1)); jScrollPane2.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); jResprocessingTable1.setFont(new java.awt.Font("Dialog", 0, 11)); jResprocessingTable1.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { }, new String [] { myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "RespTableCol1"), myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "RespTableCol2"), myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "RespTableCol3") } ) { Class[] types = new Class [] { java.lang.String.class, java.lang.String.class, java.lang.Integer.class }; boolean[] canEdit = new boolean [] { false, false, false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); jResprocessingTable1.setPreferredSize(new java.awt.Dimension(410, 0)); jScrollPane2.setViewportView(jResprocessingTable1); jSummarizePanel.add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 250, 410, 100)); jLabel10.setFont(new java.awt.Font("Dialog", 0, 11)); jLabel10.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "Sorry,_there_is_no_support_for_computer_made_resprocessing")); jSummarizePanel.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 290, -1, -1)); jPanel3.add(jSummarizePanel, "SummarizeCard"); jResprocessingPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); jLabel7.setFont(new java.awt.Font("Dialog", 1, 11)); jLabel7.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "Resprocessing")); jResprocessingPanel.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, -1)); jSeparator5.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0))); jSeparator5.setPreferredSize(new java.awt.Dimension(430, 1)); jResprocessingPanel.add(jSeparator5, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 25, -1, -1)); jScrollPane3.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); jResprocessingTable2.setFont(new java.awt.Font("Dialog", 0, 11)); jResprocessingTable2.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { }, new String [] { myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "RespTableCol1"), myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "RespTableCol2"), myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "RespTableCol3") } ) { Class[] types = new Class [] { java.lang.Object.class, java.lang.String.class, java.lang.Integer.class }; boolean[] canEdit = new boolean [] { false, true, true }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); jResprocessingTable2.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { jResprocessingTable2KeyPressed(evt); } }); jResprocessingTable2.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jResprocessingTable2MouseClicked(evt); } }); jScrollPane3.setViewportView(jResprocessingTable2); jResprocessingPanel.add(jScrollPane3, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 40, 410, 140)); jConditionTF.setFont(new java.awt.Font("Dialog", 0, 11)); jConditionTF.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { jConditionTFKeyTyped(evt); } }); jResprocessingPanel.add(jConditionTF, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 220, 350, -1)); jLabel9.setFont(new java.awt.Font("Dialog", 0, 11)); jLabel9.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "Here_you_can_add_your_Conditions:")); jResprocessingPanel.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 195, -1, -1)); jHelpGrammarButton.setFont(new java.awt.Font("Dialog", 0, 11)); jHelpGrammarButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cz/muni/fi/bronchus/resources/otaznik.gif"))); jHelpGrammarButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); jHelpGrammarButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jHelpGrammarButtonActionPerformed(evt); } }); jResprocessingPanel.add(jHelpGrammarButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(405, 190, -1, -1)); jValidateButton.setFont(new java.awt.Font("Dialog", 0, 11)); jValidateButton.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "Validate")); jValidateButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jValidateButtonActionPerformed(evt); } }); jResprocessingPanel.add(jValidateButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 190, -1, -1)); jAddConditionButton.setFont(new java.awt.Font("Dialog", 0, 11)); jAddConditionButton.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "Add")); jAddConditionButton.setEnabled(false); jAddConditionButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jAddConditionButtonActionPerformed(evt); } }); jResprocessingPanel.add(jAddConditionButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 190, -1, -1)); jConditionLabel.setFont(new java.awt.Font("Dialog", 0, 11)); jConditionLabel.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "not_valid")); jResprocessingPanel.add(jConditionLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(378, 221, -1, -1)); jFIBButton.setFont(new java.awt.Font("Dialog", 0, 11)); jFIBButton.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "FIB_Wizard")); jFIBButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); jFIBButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jFIBButtonActionPerformed(evt); } }); jResprocessingPanel.add(jFIBButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 240, -1, -1)); jLabel11.setFont(new java.awt.Font("Dialog", 0, 11)); jLabel11.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "You_can_use_a_wizard_to_make_a_Fill-In-Blank_Condition")); jResprocessingPanel.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 247, -1, -1)); jHintScrollPane.setPreferredSize(new java.awt.Dimension(170, 60)); jHintTextArea.setFont(new java.awt.Font("Dialog", 0, 11)); jHintTextArea.setLineWrap(true); jHintTextArea.setWrapStyleWord(true); jHintScrollPane.setViewportView(jHintTextArea); jResprocessingPanel.add(jHintScrollPane, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 290, -1, -1)); jSolutionScrollPane.setPreferredSize(new java.awt.Dimension(230, 60)); jSolutionTextArea.setFont(new java.awt.Font("Dialog", 0, 11)); jSolutionTextArea.setLineWrap(true); jSolutionTextArea.setWrapStyleWord(true); jSolutionScrollPane.setViewportView(jSolutionTextArea); jResprocessingPanel.add(jSolutionScrollPane, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 290, -1, -1)); jHintLabel.setFont(new java.awt.Font("Dialog", 1, 11)); jHintLabel.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "Hint:")); jResprocessingPanel.add(jHintLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 270, -1, -1)); jSolutionLabel.setFont(new java.awt.Font("Dialog", 1, 11)); jSolutionLabel.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "Solution:")); jResprocessingPanel.add(jSolutionLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 270, -1, -1)); jPanel3.add(jResprocessingPanel, "ResprocessingCard"); jPanel1.add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 0, -1, -1)); jFinishButton.setFont(new java.awt.Font("Dialog", 0, 11)); jFinishButton.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "Finish")); jFinishButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jFinishButtonActionPerformed(evt); } }); jPanel1.add(jFinishButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 370, -1, -1)); jButton1.setFont(new java.awt.Font("Dialog", 0, 11)); jButton1.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle", "Help")); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jPanel1.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 370, -1, -1)); getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1)); pack(); }//GEN-END:initComponents private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: InfoDialog infoDialog = new InfoDialog(this,true, myResources); infoDialog.setBorderTitle(myResources.getBundle("cz/muni/fi/bronchus/bundles/TestsBundle","Help")); java.net.URL url = Tests.class.getResource("/dokumentace/out/ch06.html"); infoDialog.setInnerHTML(url); infoDialog.centerInParent(); infoDialog.setVisible(true); }//GEN-LAST:event_jButton1ActionPerformed private void jFinishButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFinishButtonActionPerformed // TODO add your handling code here: stopTableEditing(jResprocessingTable2); if (!(question instanceof ShortAnswerQuestion) && validateForm()) { //ulozi resprocessing, hints, feedbacks a solutions // stopTableEditing(jResprocessingTable2); /* if (!(question instanceof ShortAnswerQuestion)) { // question.getRespConditions().clear(); ColoredRespCondition s; if (!(question instanceof FillInBlankQuestion)) { //nutne aktualizovat hodnoty, pokud byly zmeneny s=question.getRespCondition(0); //defaultni vygenerovany respprocsesing s.setFeedback((String)jResprocessingTable2.getModel().getValueAt(0, 1)); Integer a = (Integer)jResprocessingTable2.getModel().getValueAt(0, 2); int points = (emptyInteger(a)) ? 0 : a.intValue(); s.setPoints(points); } int from = (question instanceof FillInBlankQuestion) ? 0 : 1; for (int i=from; iCondition:
")); s.append(((ResProcessingItem)jResprocessingTable2.getValueAt(i,0)).getCondition()); s.append(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle","

Feedback:
")); if (feedbacks==true) { s.append((String)jResprocessingTable2.getValueAt(i,1)); } else { s.append(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle","disabled")); } s.append(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle","

Points:_")); s.append(String.valueOf(jResprocessingTable2.getValueAt(i,2))); s.append("
"); InfoDialog infoDialog = new InfoDialog(this,true, myResources); infoDialog.setBorderTitle(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle","Resprocessing")); infoDialog.setInnerHTML(s.toString()); infoDialog.centerInParent(); infoDialog.setVisible(true); } }//GEN-LAST:event_jResprocessingTable2MouseClicked private void jResprocessingTable2KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jResprocessingTable2KeyPressed // TODO add your handling code here: if (evt.getKeyCode()==evt.VK_DELETE && jResprocessingTable2.getSelectedRowCount()>0) { int[] rows=jResprocessingTable2.getSelectedRows(); String s=""; for (int i=0; i=0; i--) { ((DefaultTableModel)jResprocessingTable1.getModel()).removeRow(rows[i]); ((DefaultTableModel)jResprocessingTable2.getModel()).removeRow(rows[i]); conditions.remove(rows[i]); } jResprocessingTable1.clearSelection(); jResprocessingTable1.setPreferredSize( new Dimension(560, jResprocessingTable1.getRowCount()*16)); jResprocessingTable2.clearSelection(); jResprocessingTable2.setPreferredSize( new Dimension(560, jResprocessingTable2.getRowCount()*16)); } } }//GEN-LAST:event_jResprocessingTable2KeyPressed private void jAddConditionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jAddConditionButtonActionPerformed // TODO add your handling code here: addingrow=true; ResProcessingItem c=new ResProcessingItem(jConditionTF.getText(), 0, false); question.addRespCondition(c); Vector row=new Vector(); row.add(c); row.add(""); row.add(new Integer(c.getPoints())); int i=((DefaultTableModel)jResprocessingTable1.getModel()).getRowCount(); jResprocessingTable1.setPreferredSize(new Dimension(410, 16*(i+1))); ((DefaultTableModel)jResprocessingTable1.getModel()).addRow(row); jResprocessingTable2.setPreferredSize(new Dimension(410, 16*(i+1))); ((DefaultTableModel)jResprocessingTable2.getModel()).addRow(row); addingrow=false; }//GEN-LAST:event_jAddConditionButtonActionPerformed private void jConditionTFKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jConditionTFKeyTyped // TODO add your handling code here: jConditionLabel.setText(""); jAddConditionButton.setEnabled(false); }//GEN-LAST:event_jConditionTFKeyTyped private void jValidateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jValidateButtonActionPerformed // TODO add your handling code here: boolean valid=false; String err=""; try { TestsLexer lexer = new TestsLexer(new StringReader(jConditionTF.getText()+";")); TestsParser parser = new TestsParser(lexer); parser.expr(); valid=true; } catch (Exception ex) { valid=false; err=ex.getMessage(); } if (!valid) { myUtilities.showMessageDialog(this, myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle","Not_Valid_Expression"), err , JOptionPane.ERROR_MESSAGE); jConditionLabel.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle","not_valid")); jAddConditionButton.setEnabled(false); } else { jConditionLabel.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle","is_valid")); jAddConditionButton.setEnabled(true); } }//GEN-LAST:event_jValidateButtonActionPerformed private void jHelpGrammarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jHelpGrammarButtonActionPerformed // TODO add your handling code here: InfoDialog infoDialog = new InfoDialog(this, true, myResources); infoDialog.setBorderTitle(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle","Grammar help")); java.net.URL url = Tests.class.getResource("/dokumentace/out/ch08.html"); infoDialog.setInnerHTML(url); infoDialog.centerInParent(); infoDialog.setVisible(true); }//GEN-LAST:event_jHelpGrammarButtonActionPerformed private void setHTMLKit(JTextPane textpane, String begin, boolean wholecontent) { HTMLDocument doc; HTMLEditorKit htmlKit; StyleSheet styleSheet = new StyleSheet(); styleSheet.addRule("body {font-family: Dialog; font-size: 11pt; font-style: normal; font-weight: normal;}"); htmlKit = new HTMLEditorKit(); htmlKit.setDefaultCursor(new Cursor(Cursor.TEXT_CURSOR)); htmlKit.setStyleSheet(styleSheet); doc = (HTMLDocument) htmlKit.createDefaultDocument(); textpane.setEditorKit(htmlKit); textpane.setDocument(doc); textpane.setMargin(new Insets(0, 0, 0, 0)); textpane.setContentType("text/html"); if (wholecontent) textpane.setText(begin); else textpane.setText("
"+begin+"
"); textpane.setCaretPosition(doc.getLength()); } private boolean emptyString(String s) { if ((s==null)||(s.trim().compareTo("")==0)||(s.length()==0)) { return true; } else { return false; } } public void loadQuestion(Question q) { setHTMLKit(jTextPane1, myUtilities.getQuestionBaseInfo(q), false); if (q instanceof ShortAnswerQuestion) { jLabel3.setVisible(false); jNextButton.setEnabled(false); jScrollPane2.setVisible(false); } else { jLabel3.setVisible(true); jNextButton.setEnabled(true); jScrollPane2.setVisible(true); } boolean showfib=true; if (!(q instanceof FillInBlankQuestion)) showfib=false; if (q instanceof CombinedQuestion) { if (((CombinedQuestion)q).getCorrectAnswer().compareTo("Z")!=0) showfib=false; else showfib=true; } if (!showfib) { jFIBButton.setVisible(false); jLabel11.setVisible(false); } else { jFIBButton.setVisible(true); jLabel11.setVisible(true); uneditableTableModel.setPoints(true); } /* if (conditions.size()>0) { ((DefaultTableModel)jResprocessingTable1.getModel()).setRowCount(conditions.size()); ((DefaultTableModel)jResprocessingTable2.getModel()).setRowCount(conditions.size()); for (int i=0; i1._Summarize")); jLabel3.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle","2._Resprocessing")); activeCard=1; } if (i==1) { jBackButton.setEnabled(true); jNextButton.setEnabled(false); cl.show(jPanel3,"ResprocessingCard"); jLabel2.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle","1._Summarize")); jLabel3.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle","2._Resprocessing")); activeCard=2; } } private void jBackButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBackButtonActionPerformed // TODO add your handling code here: stopTableEditing(jResprocessingTable2); setActiveCard(activeCard); }//GEN-LAST:event_jBackButtonActionPerformed private boolean showError(String msg) { myUtilities.showMessageDialog(this, myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle","Error"), msg, JOptionPane.ERROR_MESSAGE); return false; } private boolean emptyInteger(Integer s) { if ((s==null)||(s.intValue()==0)) { return true; } else { return false; } } private boolean validateForm() { /* if (question instanceof ShortAnswerQuestion) { if (hints && jHintTextArea.getText().compareTo("")==0) return showError("Hint is empty"); if (hints && solutions && jSolutionTextArea.getText().compareTo("")==0) return showError("Solution is empty"); if (hints==false && solutions && jHintTextArea.getText().compareTo("")==0) return showError("Solution is empty"); return true; }*/ if (((DefaultTableModel)jResprocessingTable1.getModel()).getRowCount()==0) return showError(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle","There_must_be_at_least_one_condition_in_Resprocessing_table")); /* if (hints && jHintTextArea.getText().compareTo("")==0) return showError("Hint is empty"); if (hints && solutions && jSolutionTextArea.getText().compareTo("")==0) return showError("Solution is empty"); if (hints==false && solutions && jHintTextArea.getText().compareTo("")==0) return showError("Solution is empty");*/ //kontrola bodu if (algorithm==5 || algorithm==6 || algorithm==7 || algorithm==8) { //nesmi byt prazdne hodnoty for (int i=0; i1) { java.util.List tmpList = new ArrayList(conditions); Collections.sort(tmpList); ResProcessingItem crc1 = (ResProcessingItem)tmpList.get(0); ResProcessingItem crc2 = (ResProcessingItem)tmpList.get(1); if (! crc1.isGenerated() && crc1.getPoints()==crc2.getPoints()) return showError(myResources.getBundle("cz/muni/fi/bronchus/bundles/AdvancedOptionsDialogBundle","There_must_be_only_one_condition_with_greatest_value_of_points")); /* if (!( (question instanceof FillInBlankQuestion) || ( (question instanceof CombinedQuestion) && (((CombinedQuestion)question).getCorrectAnswer().compareTo("Z")==0) ) ) ) { if (! crc1.isGenerated()) return showError("Generated condition must have the greatest value of points"); }*/ } /* if (!( (question instanceof FillInBlankQuestion) || ( (question instanceof CombinedQuestion) && (((CombinedQuestion)question).getCorrectAnswer().compareTo("Z")==0) ) ) ) { //nejvetsi hodnota bodu musi byt u vygenerovane condition Integer int1=(Integer)jResprocessingTable1.getValueAt(0, 2); int i1 = (emptyInteger(int1)) ? 0 : int1.intValue(); for (int i=1; i=i1) return showError("Generated condition must have the greatest value of points"); } }*/ return true; } private void jNextButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNextButtonActionPerformed // Add your handling code here: stopTableEditing(jResprocessingTable2); setActiveCard(activeCard); }//GEN-LAST:event_jNextButtonActionPerformed private void jCancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCancelButtonActionPerformed // Add your handling code here: selected=-1; setVisible(false); dispose(); }//GEN-LAST:event_jCancelButtonActionPerformed /** Closes the dialog */ private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog selected=-1; setVisible(false); dispose(); }//GEN-LAST:event_closeDialog public void setFHS(boolean feedbacks, boolean hints, boolean solutions) { this.feedbacks=feedbacks; this.hints=hints; this.solutions=solutions; } public void setAlgorithm(int type) { algorithm=type; if (algorithm==5 || algorithm==6 || algorithm==7 || algorithm==8) { //umoznim zadavani bodu v tabulkach uneditableTableModel.setPoints(true); } else { //znemoznim zadavani bodu v tabulkach uneditableTableModel.setPoints(false); } } public void showResprocessing() { /* Vector conditions = question.getRespConditions(); if (conditions.size()>0) { ((DefaultTableModel)jResprocessingTable1.getModel()).setRowCount(conditions.size()); ((DefaultTableModel)jResprocessingTable2.getModel()).setRowCount(conditions.size()); for (int i=0; i