java/abc-drupal-gui/src/cz/frantovo/abcDrupal/gui/HlavniOkno.java
author František Kučera <franta-hg@frantovo.cz>
Thu Dec 31 18:41:04 2009 +0100 (2009-12-31)
changeset 3 d40099dbbdd1
parent 2 2f02db6cd698
child 4 5816c7f61a2a
permissions -rw-r--r--
Načítání připojovacích řetězců z proměnných prostředí.
     1 /*
     2  * HlavniOkno.java
     3  *
     4  * Created on 30.12.2009, 2:22:41
     5  */
     6 package cz.frantovo.abcDrupal.gui;
     7 
     8 import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel;
     9 import cz.frantovo.abcDrupal.Konvertor;
    10 import cz.frantovo.abcDrupal.PosluchacLogu;
    11 import cz.frantovo.abcDrupal.PromenneProstredi;
    12 import java.util.logging.Level;
    13 import java.util.logging.Logger;
    14 import javax.swing.UIManager;
    15 import javax.swing.UnsupportedLookAndFeelException;
    16 
    17 /**
    18  *
    19  * @author fiki
    20  */
    21 public class HlavniOkno extends javax.swing.JFrame implements PosluchacLogu {
    22 
    23     private static final Logger log = Logger.getLogger(HlavniOkno.class.getName());
    24 
    25     /** Creates new form HlavniOkno */
    26     public HlavniOkno() {
    27 	initComponents();
    28 	nactiPromenneProstredi();
    29     }
    30 
    31     private void nactiPromenneProstredi() {
    32 	String zdroj = System.getenv(PromenneProstredi.MIGRACE_ZDROJ.toString());
    33 	if (zdroj != null) {
    34 	    jdbcZdroj.setText(zdroj);
    35 	}
    36 	String cil = System.getenv(PromenneProstredi.MIGRACE_CIL.toString());
    37 	if (cil != null) {
    38 	    jdbcCil.setText(cil);
    39 	}
    40     }
    41 
    42     /** This method is called from within the constructor to
    43      * initialize the form.
    44      * WARNING: Do NOT modify this code. The content of this method is
    45      * always regenerated by the Form Editor.
    46      */
    47     @SuppressWarnings("unchecked")
    48     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    49     private void initComponents() {
    50 
    51         jLabel1 = new javax.swing.JLabel();
    52         jLabel2 = new javax.swing.JLabel();
    53         jdbcZdroj = new javax.swing.JTextField();
    54         jdbcCil = new javax.swing.JTextField();
    55         jScrollPane1 = new javax.swing.JScrollPane();
    56         vystup = new javax.swing.JTextArea();
    57         jButton1 = new javax.swing.JButton();
    58 
    59         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    60         setTitle("ABC-Drupal");
    61 
    62         jLabel1.setText("Zdroj");
    63 
    64         jLabel2.setText("Cíl");
    65 
    66         jdbcZdroj.setText("jdbcZdroj");
    67 
    68         jdbcCil.setText("jdbcCil");
    69 
    70         vystup.setColumns(20);
    71         vystup.setEditable(false);
    72         vystup.setRows(5);
    73         vystup.setEnabled(false);
    74         jScrollPane1.setViewportView(vystup);
    75 
    76         jButton1.setText("Nahrát data");
    77         jButton1.addActionListener(new java.awt.event.ActionListener() {
    78             public void actionPerformed(java.awt.event.ActionEvent evt) {
    79                 jButton1ActionPerformed(evt);
    80             }
    81         });
    82 
    83         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    84         getContentPane().setLayout(layout);
    85         layout.setHorizontalGroup(
    86             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    87             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
    88                 .addContainerGap()
    89                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
    90                     .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 599, Short.MAX_VALUE)
    91                     .addGroup(layout.createSequentialGroup()
    92                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    93                             .addComponent(jLabel1)
    94                             .addComponent(jLabel2))
    95                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    96                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    97                             .addComponent(jdbcCil, javax.swing.GroupLayout.DEFAULT_SIZE, 560, Short.MAX_VALUE)
    98                             .addComponent(jdbcZdroj, javax.swing.GroupLayout.DEFAULT_SIZE, 560, Short.MAX_VALUE)))
    99                     .addComponent(jButton1))
   100                 .addContainerGap())
   101         );
   102         layout.setVerticalGroup(
   103             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
   104             .addGroup(layout.createSequentialGroup()
   105                 .addContainerGap()
   106                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
   107                     .addComponent(jLabel1)
   108                     .addComponent(jdbcZdroj, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
   109                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
   110                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
   111                     .addComponent(jdbcCil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
   112                     .addComponent(jLabel2))
   113                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
   114                 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
   115                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
   116                 .addComponent(jButton1)
   117                 .addContainerGap())
   118         );
   119 
   120         pack();
   121     }// </editor-fold>//GEN-END:initComponents
   122 
   123     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
   124 	Konvertor k = new Konvertor(jdbcZdroj.getText(), jdbcCil.getText(), this);
   125 	k.konvertuj();
   126     }//GEN-LAST:event_jButton1ActionPerformed
   127 
   128     /**
   129      * @param args the command line arguments
   130      */
   131     public static void main(String args[]) {
   132 	nastavLaF();
   133 
   134 	java.awt.EventQueue.invokeLater(new Runnable() {
   135 
   136 	    public void run() {
   137 		new HlavniOkno().setVisible(true);
   138 	    }
   139 	});
   140     }
   141 
   142     private static void nastavLaF() {
   143 	try {
   144 	    UIManager.setLookAndFeel(new NimbusLookAndFeel());
   145 	} catch (UnsupportedLookAndFeelException e) {
   146 	    log.log(Level.FINE, "Nepodařilo se načíst LaF. Nevadí.");
   147 	}
   148     }
   149     // Variables declaration - do not modify//GEN-BEGIN:variables
   150     private javax.swing.JButton jButton1;
   151     private javax.swing.JLabel jLabel1;
   152     private javax.swing.JLabel jLabel2;
   153     private javax.swing.JScrollPane jScrollPane1;
   154     private javax.swing.JTextField jdbcCil;
   155     private javax.swing.JTextField jdbcZdroj;
   156     private javax.swing.JTextArea vystup;
   157     // End of variables declaration//GEN-END:variables
   158 
   159     public void vypis(String zprava) {
   160 	vystup.append(zprava + "\n");
   161     }
   162 }