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 ProgramLocation extends javax.swing.JPanel implements WizardPanel {
031        
032        /** Creates new form LogPanel */
033        public ProgramLocation() {
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            lsLabel = new javax.swing.JLabel();
047            lsPath = new javax.swing.JTextField();
048            cshLabel = new javax.swing.JLabel();
049            cshPath = new javax.swing.JTextField();
050    
051            setLayout(new java.awt.GridBagLayout());
052    
053            instructions.setEditable(false);
054            instructions.setLineWrap(true);
055            instructions.setText("The scheduler needs to know the full path of the programs it relies on. This makes it tolerant to user-dependent configurations.\nOne can always decide to enter just the command, to rely on the PATH environment variable. You do that at your own risk.");
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.weightx = 1.0;
063            gridBagConstraints.insets = new java.awt.Insets(5, 5, 15, 5);
064            add(instructions, gridBagConstraints);
065    
066            lsLabel.setText("ls*");
067            gridBagConstraints = new java.awt.GridBagConstraints();
068            gridBagConstraints.gridx = 0;
069            gridBagConstraints.gridy = 1;
070            gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
071            gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
072            add(lsLabel, gridBagConstraints);
073    
074            lsPath.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(lsPath, gridBagConstraints);
086    
087            cshLabel.setText("csh*");
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(cshLabel, gridBagConstraints);
094    
095            cshPath.addKeyListener(new java.awt.event.KeyAdapter() {
096                public void keyTyped(java.awt.event.KeyEvent evt) {
097                    textChanged(evt);
098                }
099            });
100    
101            gridBagConstraints = new java.awt.GridBagConstraints();
102            gridBagConstraints.gridx = 1;
103            gridBagConstraints.gridy = 2;
104            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
105            gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
106            gridBagConstraints.weighty = 1.0;
107            gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
108            add(cshPath, gridBagConstraints);
109    
110        }//GEN-END:initComponents
111    
112        private void textChanged(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textChanged
113            firePropertyChange("ready", oldReady, isReady());
114            oldReady = isReady();
115        }//GEN-LAST:event_textChanged
116    
117        private boolean oldReady;
118        public String getTitle() {
119            return "Program location";
120        }    
121        
122        public boolean isReady() {
123            if ("".equals(cshPath.getText())) return false;
124            if ("".equals(lsPath.getText())) return false;
125            return true;
126        }    
127        
128        public void addProperties(java.util.Map schedulerProperties) {
129            schedulerProperties.put("ProgramLocation.ls", lsPath.getText());
130            schedulerProperties.put("ProgramLocation.csh", cshPath.getText());
131        }
132        
133        // Variables declaration - do not modify//GEN-BEGIN:variables
134        private javax.swing.JLabel cshLabel;
135        private javax.swing.JTextField cshPath;
136        private javax.swing.JTextArea instructions;
137        private javax.swing.JLabel lsLabel;
138        private javax.swing.JTextField lsPath;
139        // End of variables declaration//GEN-END:variables
140        
141    }