001    /*
002     * LogPanel.java
003     *
004     * Created on May 22, 2003, 12:41 PM
005     *
006     * This file is part of the STAR Scheduler.
007     * Copyright (c) 2002-2006 STAR Collaboration - Brookhaven National Laboratory
008     *
009     * STAR Scheduler is free software; you can redistribute it and/or modify
010     * it under the terms of the GNU General Public License as published by
011     * the Free Software Foundation; either version 2 of the License, or
012     * (at your option) any later version.
013     *
014     * STAR Scheduler is distributed in the hope that it will be useful,
015     * but WITHOUT ANY WARRANTY; without even the implied warranty of
016     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017     * GNU General Public License for more details.
018     *
019     * You should have received a copy of the GNU General Public License
020     * along with STAR Scheduler; if not, write to the Free Software
021     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
022     */
023    
024    package gov.bnl.star.offline.scheduler.config;
025    
026    /**
027     *
028     * @author  Gabriele Carcassi
029     */
030    public class LogPanel extends javax.swing.JPanel implements WizardPanel {
031        
032        /** Creates new form LogPanel */
033        public LogPanel() {
034            initComponents();
035        }
036        
037        /** This method is called from within the constructor to
038         * initialize the form.
039         * WARNING: Do NOT modify this code. The content of this method is
040         * always regenerated by the Form Editor.
041         */
042        private void initComponents() {//GEN-BEGIN:initComponents
043            java.awt.GridBagConstraints gridBagConstraints;
044    
045            instructions = new javax.swing.JTextArea();
046            directoryLabel = new javax.swing.JLabel();
047            directory = new javax.swing.JTextField();
048            levelLabel = new javax.swing.JLabel();
049            level = new javax.swing.JComboBox();
050    
051            setLayout(new java.awt.GridBagLayout());
052    
053            instructions.setEditable(false);
054            instructions.setLineWrap(true);
055            instructions.setText("The scheduler keeps a log for each user. It is used during development for debugging and during production for user assistance.\nThe Directory is the directory in which the logs are stored. It must be accessible by all user.\nThe Level controls how verbose the log will be. CONFIG/WARNING is a level suitable for production.");
056            instructions.setWrapStyleWord(true);
057            instructions.setFocusable(false);
058            instructions.setOpaque(false);
059            gridBagConstraints = new java.awt.GridBagConstraints();
060            gridBagConstraints.gridwidth = 2;
061            gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
062            gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
063            gridBagConstraints.weightx = 1.0;
064            gridBagConstraints.insets = new java.awt.Insets(5, 5, 15, 5);
065            add(instructions, gridBagConstraints);
066    
067            directoryLabel.setText("Directory*");
068            gridBagConstraints = new java.awt.GridBagConstraints();
069            gridBagConstraints.gridx = 0;
070            gridBagConstraints.gridy = 1;
071            gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
072            add(directoryLabel, gridBagConstraints);
073    
074            directory.addKeyListener(new java.awt.event.KeyAdapter() {
075                public void keyTyped(java.awt.event.KeyEvent evt) {
076                    textChanged(evt);
077                }
078            });
079    
080            gridBagConstraints = new java.awt.GridBagConstraints();
081            gridBagConstraints.gridx = 1;
082            gridBagConstraints.gridy = 1;
083            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
084            gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
085            add(directory, gridBagConstraints);
086    
087            levelLabel.setText("Level*");
088            gridBagConstraints = new java.awt.GridBagConstraints();
089            gridBagConstraints.gridx = 0;
090            gridBagConstraints.gridy = 2;
091            gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
092            gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 0);
093            add(levelLabel, gridBagConstraints);
094    
095            level.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "", "ERROR", "WARNING", "INFO", "CONFIG", "FINE", "FINER", "FINEST" }));
096            level.addItemListener(new java.awt.event.ItemListener() {
097                public void itemStateChanged(java.awt.event.ItemEvent evt) {
098                    comboChange(evt);
099                }
100            });
101    
102            gridBagConstraints = new java.awt.GridBagConstraints();
103            gridBagConstraints.gridx = 1;
104            gridBagConstraints.gridy = 2;
105            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
106            gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
107            gridBagConstraints.weighty = 1.0;
108            gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
109            add(level, gridBagConstraints);
110    
111        }//GEN-END:initComponents
112    
113        private void comboChange(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_comboChange
114            firePropertyChange("ready", oldReady, isReady());
115            oldReady = isReady();
116        }//GEN-LAST:event_comboChange
117    
118        private void textChanged(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textChanged
119            firePropertyChange("ready", oldReady, isReady());
120            oldReady = isReady();
121        }//GEN-LAST:event_textChanged
122    
123        private boolean oldReady;
124        public String getTitle() {
125            return "Log";
126        }    
127        
128        public boolean isReady() {
129            if ("".equals(directory.getText())) return false;
130            if (level.getSelectedIndex() == 0) return false;
131            return true;
132        }    
133        
134        public void addProperties(java.util.Map schedulerProperties) {
135            schedulerProperties.put("Log.directory", directory.getText());
136            schedulerProperties.put("Log.level", level.getSelectedItem());
137        }
138        
139        // Variables declaration - do not modify//GEN-BEGIN:variables
140        private javax.swing.JTextField directory;
141        private javax.swing.JLabel directoryLabel;
142        private javax.swing.JTextArea instructions;
143        private javax.swing.JComboBox level;
144        private javax.swing.JLabel levelLabel;
145        // End of variables declaration//GEN-END:variables
146        
147    }