Package pdfrobot.gui

Source Code of pdfrobot.gui.LogTab

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/*
* LogTab.java
*
* Created on 25-12-2010, 03:18:07
*/
package pdfrobot.gui;

import java.util.logging.LogRecord;
import javax.swing.DefaultComboBoxModel;
import pdfrobot.gui.inputverify.LogRecordBufferVerifyer;
import pdfrobot.logging.LogListener;
import pdfrobot.logging.LogRecordBuffer;
import pdfrobot.settings.ApplicationSettings;
import pdfrobot.settings.LogSettings;

/**
*
* @author hedsttor
*/
public class LogTab extends javax.swing.JPanel implements LogListener {
    private LogSettings logSettings;

    /** Creates new form LogTab */
    public LogTab() {
        initComponents();
        initCustom();
        LogRecordBuffer.getInstance().addLogListener(this);
    }

    /** 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() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jComboBox1 = new javax.swing.JComboBox();
        jTextField1 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();

        setPreferredSize(new java.awt.Dimension(560, 556));
        setVerifyInputWhenFocusTarget(false);

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });

        jTextField1.setText("1000");

        jLabel1.setText("Flush every ");

        jLabel2.setText("Records");

        jTextArea1.setColumns(20);
        jTextArea1.setEditable(false);
        jTextArea1.setFont(new java.awt.Font("Arial Black", 0, 10)); // NOI18N
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 540, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel2)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addContainerGap())
        );

        getAccessibleContext().setAccessibleName("");
    }// </editor-fold>//GEN-END:initComponents

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
        logSettings.setSelectedIndex(jComboBox1.getSelectedIndex());
    }//GEN-LAST:event_jComboBox1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration//GEN-END:variables

    /**
     * Custom initialization
     */
    private void initCustom() {
        logSettings = ApplicationSettings.getInstance().getLogSettings();
        jTextField1.setInputVerifier(new LogRecordBufferVerifyer());
        jTextField1.setText(Integer.toString(logSettings.getFlushLimit()));
        DefaultComboBoxModel logLevels = new DefaultComboBoxModel(logSettings.getLogLevels());
        logLevels.setSelectedItem(ApplicationSettings.getInstance().getLogSettings().getLogLevels()[ApplicationSettings.getInstance().getLogSettings().getSelectedIndex()]);
        jComboBox1.setModel(logLevels);
    }

    /**
     *LogListener inteface method. Called everytime something is logged, in order to update the UI.
     * @param record
     */
    public void logRecordAdded(LogRecord record) {
        jTextArea1.append(record.getMessage() + "\n");
    }

    /**
     *LogListener inteface method. Called everytime logs are flushed.
     */
    public void flush() {
        jTextArea1.setText("");
    }
}
TOP

Related Classes of pdfrobot.gui.LogTab

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.