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