001/*
002 * To change this license header, choose License Headers in Project Properties.
003 * To change this template file, choose Tools | Templates
004 * and open the template in the editor.
005 */
006package jmri.jmrit.ctc.editor.gui;
007
008import jmri.jmrit.ctc.editor.code.AwtWindowProperties;
009import jmri.jmrit.ctc.editor.code.Columns;
010import jmri.jmrit.ctc.editor.code.CommonSubs;
011
012/**
013 *
014 * @author Gregory J. Bedlek Copyright (C) 2018, 2019
015 */
016public class FrmFixErrors extends javax.swing.JFrame {
017
018    private static final String FORM_PROPERTIES = "DlgFixErrors";   // NOI18N
019    private final AwtWindowProperties _mAwtWindowProperties;
020    private final Columns _mColumns;
021
022    public FrmFixErrors(AwtWindowProperties awtWindowProperties, Columns columns) {
023        super();
024        initComponents();
025        CommonSubs.addHelpMenu(this, "package.jmri.jmrit.ctc.CTC_menuEditFix", true);  // NOI18N
026        _mAwtWindowProperties = awtWindowProperties;
027        _mColumns = columns;
028        _mAwtWindowProperties.setWindowState(this, FORM_PROPERTIES);
029        this.getRootPane().setDefaultButton(_mCancel);
030    }
031
032    /**
033     * This method is called from within the constructor to initialize the form.
034     * WARNING: Do NOT modify this code. The content of this method is always
035     * regenerated by the Form Editor.
036     */
037    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
038    private void initComponents() {
039
040        _mInfo = new javax.swing.JLabel();
041        jButton1 = new javax.swing.JButton();
042        _mCancel = new javax.swing.JButton();
043
044        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
045        setTitle(Bundle.getMessage("TitleDlgFix"));
046        addWindowListener(new java.awt.event.WindowAdapter() {
047            @Override
048            public void windowClosing(java.awt.event.WindowEvent evt) {
049                formWindowClosing(evt);
050            }
051        });
052
053        _mInfo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
054        _mInfo.setText(Bundle.getMessage("InfoDlgFix"));
055        _mInfo.setVerticalAlignment(javax.swing.SwingConstants.TOP);
056        _mInfo.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
057        _mInfo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
058
059        jButton1.setText(Bundle.getMessage("ButtonProceed"));
060        jButton1.addActionListener(new java.awt.event.ActionListener() {
061            @Override
062            public void actionPerformed(java.awt.event.ActionEvent evt) {
063                jButton1ActionPerformed(evt);
064            }
065        });
066
067        _mCancel.setText(Bundle.getMessage("ButtonCancel"));
068        _mCancel.addActionListener(new java.awt.event.ActionListener() {
069            @Override
070            public void actionPerformed(java.awt.event.ActionEvent evt) {
071                _mCancelActionPerformed(evt);
072            }
073        });
074
075        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
076        getContentPane().setLayout(layout);
077        layout.setHorizontalGroup(
078            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
079            .addGroup(layout.createSequentialGroup()
080                .addContainerGap()
081                .addComponent(_mInfo, javax.swing.GroupLayout.DEFAULT_SIZE, 390, Short.MAX_VALUE)
082                .addContainerGap())
083            .addGroup(layout.createSequentialGroup()
084                .addGap(74, 74, 74)
085                .addComponent(jButton1)
086                .addGap(54, 54, 54)
087                .addComponent(_mCancel)
088                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
089        );
090        layout.setVerticalGroup(
091            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
092            .addGroup(layout.createSequentialGroup()
093                .addContainerGap()
094                .addComponent(_mInfo, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)
095                .addGap(18, 18, 18)
096                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
097                    .addComponent(jButton1)
098                    .addComponent(_mCancel))
099                .addGap(34, 34, 34))
100        );
101
102        pack();
103    }// </editor-fold>//GEN-END:initComponents
104
105    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
106        exitDialog();
107    }//GEN-LAST:event_formWindowClosing
108
109    private void _mCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event__mCancelActionPerformed
110        exitDialog();
111    }//GEN-LAST:event__mCancelActionPerformed
112
113    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
114        _mColumns.fixAllErrors();
115        exitDialog();
116    }//GEN-LAST:event_jButton1ActionPerformed
117
118    private void exitDialog() {
119        _mAwtWindowProperties.saveWindowState(this, FORM_PROPERTIES);
120        dispose();
121    }
122
123    // Variables declaration - do not modify//GEN-BEGIN:variables
124    private javax.swing.JButton _mCancel;
125    private javax.swing.JLabel _mInfo;
126    private javax.swing.JButton jButton1;
127    // End of variables declaration//GEN-END:variables
128}