PageRenderTime 35ms CodeModel.GetById 1ms app.highlight 29ms RepoModel.GetById 1ms app.codeStats 0ms

/src/mpv5/ui/dialogs/subcomponents/ControlPanel_Localization.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 230 lines | 176 code | 39 blank | 15 comment | 4 complexity | c7eb3a52b6ba3715c9c7094114e75bfe MD5 | raw file
  1package mpv5.ui.dialogs.subcomponents;
  2
  3import java.awt.Component;
  4import java.io.File;
  5import java.util.ArrayList;
  6import javax.swing.DefaultListModel;
  7import javax.swing.JPanel;
  8import mpv5.data.PropertyStore;
  9import mpv5.db.common.Context;
 10import mpv5.db.common.DatabaseObject;
 11import mpv5.db.common.NodataFoundException;
 12import mpv5.logging.Log;
 13import mpv5.i18n.LanguageManager;
 14import mpv5.ui.dialogs.ControlApplet;
 15import mpv5.pluginhandling.UserPlugin;
 16
 17/**
 18 *
 19 * 
 20 */
 21public class ControlPanel_Localization extends javax.swing.JPanel implements ControlApplet {
 22
 23    private static final long serialVersionUID = 1L;
 24    /**
 25     * This unique name identifies this control applet
 26     */
 27    public final String UNAME = "plugins";
 28    private PropertyStore oldvalues;
 29    private static ControlPanel_Localization ident;
 30
 31    public ControlPanel_Localization() {
 32        initComponents();
 33        try {
 34            refresh();
 35        } catch (NodataFoundException ex) {
 36            Log.Debug(ex);
 37        }
 38        setVisible(true);
 39    }
 40
 41    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
 42    private void initComponents() {
 43
 44        jPanel1 = new javax.swing.JPanel();
 45        jButton1 = new javax.swing.JButton();
 46        jButton2 = new javax.swing.JButton();
 47        jPanel3 = new javax.swing.JPanel();
 48        jLabel3 = new javax.swing.JLabel();
 49        jLabel4 = new javax.swing.JLabel();
 50        jScrollPane1 = new javax.swing.JScrollPane();
 51        jList1 = new javax.swing.JList();
 52        jPanel5 = new javax.swing.JPanel();
 53        jLabel8 = new javax.swing.JLabel();
 54        jLabel9 = new javax.swing.JLabel();
 55        labeledTextChooser2 = new mpv5.ui.beans.LabeledTextChooser();
 56        jButton4 = new javax.swing.JButton();
 57
 58        setBackground(new java.awt.Color(255, 255, 255));
 59        setName("Form"); // NOI18N
 60        setLayout(new java.awt.BorderLayout());
 61
 62        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
 63        java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle(); // NOI18N
 64        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("ControlPanel_Localization.jPanel1.border.title"))); // NOI18N
 65        jPanel1.setName("jPanel1"); // NOI18N
 66
 67        jButton1.setText(bundle.getString("ControlPanel_Localization.jButton1.text")); // NOI18N
 68        jButton1.setName("jButton1"); // NOI18N
 69        jButton1.addActionListener(new java.awt.event.ActionListener() {
 70
 71            public void actionPerformed(java.awt.event.ActionEvent evt) {
 72                jButton1ActionPerformed(evt);
 73            }
 74        });
 75
 76        jButton2.setText(bundle.getString("ControlPanel_Localization.jButton2.text")); // NOI18N
 77        jButton2.setName("jButton2"); // NOI18N
 78        jButton2.addActionListener(new java.awt.event.ActionListener() {
 79
 80            public void actionPerformed(java.awt.event.ActionEvent evt) {
 81                jButton2ActionPerformed(evt);
 82            }
 83        });
 84
 85        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
 86        jPanel3.setName("jPanel3"); // NOI18N
 87
 88        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
 89        jLabel3.setText(bundle.getString("ControlPanel_Localization.jLabel3.text")); // NOI18N
 90        jLabel3.setName("jLabel3"); // NOI18N
 91
 92        jLabel4.setFont(new java.awt.Font("Dialog", 0, 11)); // NOI18N
 93        jLabel4.setText(bundle.getString("ControlPanel_Localization.jLabel4.text")); // NOI18N
 94        jLabel4.setName("jLabel4"); // NOI18N
 95
 96        jScrollPane1.setName("jScrollPane1"); // NOI18N
 97
 98        jList1.setName("jList1"); // NOI18N
 99        jScrollPane1.setViewportView(jList1);
100
101        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
102        jPanel3.setLayout(jPanel3Layout);
103        jPanel3Layout.setHorizontalGroup(
104                jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel3Layout.createSequentialGroup().addContainerGap().addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 357, Short.MAX_VALUE).addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false).addComponent(jLabel3).addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))).addContainerGap()));
105        jPanel3Layout.setVerticalGroup(
106                jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel3Layout.createSequentialGroup().addContainerGap().addComponent(jLabel3).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel4).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE).addContainerGap()));
107
108        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());
109        jPanel5.setName("jPanel5"); // NOI18N
110
111        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 12));
112        jLabel8.setText(bundle.getString("ControlPanel_Localization.jLabel8.text")); // NOI18N
113        jLabel8.setName("jLabel8"); // NOI18N
114
115        jLabel9.setFont(new java.awt.Font("Dialog", 0, 11)); // NOI18N
116        jLabel9.setText(bundle.getString("ControlPanel_Localization.jLabel9.text")); // NOI18N
117        jLabel9.setName("jLabel9"); // NOI18N
118
119        labeledTextChooser2.set_Label(bundle.getString("ControlPanel_Localization.labeledTextChooser2._Label")); // NOI18N
120        labeledTextChooser2.set_LabelFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N
121        labeledTextChooser2.setName("labeledTextChooser2"); // NOI18N
122
123        jButton4.setText(bundle.getString("ControlPanel_Localization.jButton4.text")); // NOI18N
124        jButton4.setName("jButton4"); // NOI18N
125        jButton4.addActionListener(new java.awt.event.ActionListener() {
126
127            public void actionPerformed(java.awt.event.ActionEvent evt) {
128                jButton4ActionPerformed(evt);
129            }
130        });
131
132        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
133        jPanel5.setLayout(jPanel5Layout);
134        jPanel5Layout.setHorizontalGroup(
135                jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel5Layout.createSequentialGroup().addContainerGap().addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel8).addGroup(jPanel5Layout.createSequentialGroup().addComponent(labeledTextChooser2, javax.swing.GroupLayout.PREFERRED_SIZE, 264, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jButton4)).addComponent(jLabel9)).addContainerGap(17, Short.MAX_VALUE)));
136        jPanel5Layout.setVerticalGroup(
137                jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup().addContainerGap().addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(jButton4).addGroup(jPanel5Layout.createSequentialGroup().addComponent(jLabel8).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(jLabel9).addGap(9, 9, 9).addComponent(labeledTextChooser2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))).addGap(16, 16, 16)));
138
139        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
140        jPanel1.setLayout(jPanel1Layout);
141        jPanel1Layout.setHorizontalGroup(
142                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(jPanel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addGroup(jPanel1Layout.createSequentialGroup().addComponent(jButton2).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jButton1))).addContainerGap()));
143        jPanel1Layout.setVerticalGroup(
144                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup().addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jButton1).addComponent(jButton2)).addContainerGap()));
145
146        add(jPanel1, java.awt.BorderLayout.CENTER);
147    }// </editor-fold>//GEN-END:initComponents
148
149    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
150    }//GEN-LAST:event_jButton2ActionPerformed
151
152    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
153    }//GEN-LAST:event_jButton1ActionPerformed
154
155    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
156        if (labeledTextChooser2.hasText()) {
157            LanguageManager.importCountries(new File(labeledTextChooser2.get_Text(true)));
158        }
159    }//GEN-LAST:event_jButton4ActionPerformed
160
161    public void setValues(PropertyStore values) {
162        oldvalues = values;
163    }
164
165    public String getUname() {
166        return UNAME;
167    }
168
169    public void reset() {
170        setValues(oldvalues);
171    }
172    // Variables declaration - do not modify//GEN-BEGIN:variables
173    private javax.swing.JButton jButton1;
174    private javax.swing.JButton jButton2;
175    private javax.swing.JButton jButton4;
176    private javax.swing.JLabel jLabel3;
177    private javax.swing.JLabel jLabel4;
178    private javax.swing.JLabel jLabel8;
179    private javax.swing.JLabel jLabel9;
180    private javax.swing.JList jList1;
181    private javax.swing.JPanel jPanel1;
182    private javax.swing.JPanel jPanel3;
183    private javax.swing.JPanel jPanel5;
184    private javax.swing.JScrollPane jScrollPane1;
185    private mpv5.ui.beans.LabeledTextChooser labeledTextChooser2;
186    // End of variables declaration//GEN-END:variables
187
188    public ControlApplet instanceOf() {
189        if (ident == null) {
190            ident = new ControlPanel_Localization();
191        }
192        return ident;
193    }
194
195    private void refresh() throws NodataFoundException {
196        DefaultListModel xl = new DefaultListModel();
197        ArrayList<UserPlugin> data = DatabaseObject.getObjects(Context.getPluginsToUsers());
198        for (int i = 0; i < data.size(); i++) {
199            UserPlugin userPlugin = data.get(i);
200            xl.addElement(userPlugin);
201        }
202
203        jList1.setModel(xl);
204    }
205//    public java.awt.Component getAndRemoveActionPanel() {
206//        jPanel1.remove(jPanel6);
207//        jPanel1.validate();
208//        return jPanel6;
209//    }
210
211    public Component getAndRemoveActionPanel() {
212        JPanel jPanel2 = new JPanel();
213        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
214        jPanel2.setName("jPanel2"); // NOI18N
215        jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
216
217        jPanel2.add(jButton1);
218        jPanel2.add(jButton2);
219        jPanel2.add(jButton4);
220        try {
221            jPanel1.remove(jButton1);
222            jPanel1.remove(jButton2);
223            jPanel1.remove(jButton4);
224        } catch (Exception e) {
225        }
226        validate();
227        return jPanel2;
228
229    }
230}