/*
* 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("