
package ex1;



/**
 *
 * @author maxerdwien
 */
public class SavePanelSingle extends javax.swing.JPanel {
    private static final long serialVersionUID = 1L;
    
    Boolean allowSave = true;

    /** Creates new form savePanel */
    public SavePanelSingle(WepsTableModel wt, WEPSDBViewer wdv) {
        initComponents();
        
        String message;
        int row = wdv.getCurrentRow();
        if(!wt.checkData) message = "Data checking is turned off.\n"
                + "This data may produce incorrect results or crash the program.";
        else
        {
            switch (wt.getTableStatus(row)) {
                case WARNSAVE:
                    message = "Some data (highlighted in yellow) is outside the recommended limits. "
                            + "You can still save, but may get strange results from the simulation.";
                    wdv.scrollToCell(wt.getFirstYellowRow(), wt.getFirstYellowColumn());
                    break;
                case NOSAVE:
                    message = "Some data (highlighted in red) is outside the absolute limits. "
                            + "You cannot save until the infringing data has been fixed. "
                            + "If you are sure that you want to save with the current data, turn off data checking.";
                    wdv.scrollToCell(wt.getFirstRedRow(), wt.getFirstRedColumn());
                    allowSave = false;
                    break;
                case OKAY:
                        message = "All data is within bounds.";
                    break;
                default:
                    message = "error";
                    break;
            }
        }
        messageArea.setText(message);
        
        
    }

    /** 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();
        messageArea = new javax.swing.JTextArea();
        jScrollPane2 = new javax.swing.JScrollPane();

        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        messageArea.setEditable(false);
        messageArea.setColumns(20);
        messageArea.setLineWrap(true);
        messageArea.setRows(5);
        messageArea.setText(org.openide.util.NbBundle.getMessage(SavePanel.class, "SavePanel.messageArea.text")); // NOI18N
        messageArea.setWrapStyleWord(true);
        jScrollPane1.setViewportView(messageArea);

        


        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 385, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 385, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addGap(0, 0, 0))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextArea messageArea;
    // End of variables declaration//GEN-END:variables
}
