PageRenderTime 394ms CodeModel.GetById 100ms app.highlight 181ms RepoModel.GetById 101ms app.codeStats 0ms

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

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 792 lines | 680 code | 100 blank | 12 comment | 44 complexity | 23effda5d38e52296438e6665c95a225 MD5 | raw file
  1package mpv5.ui.dialogs.subcomponents;
  2
  3import java.awt.Color;
  4import java.awt.Component;
  5import java.security.NoSuchAlgorithmException;
  6import java.util.Arrays;
  7import java.util.Date;
  8import java.util.Map;
  9import javax.swing.DefaultComboBoxModel;
 10import javax.swing.JComponent;
 11import javax.swing.JPasswordField;
 12import javax.swing.JTextField;
 13import javax.swing.UIManager;
 14import javax.swing.UIManager.LookAndFeelInfo;
 15import javax.swing.table.DefaultTableModel;
 16import mpv5.data.PropertyStore;
 17import mpv5.db.common.Context;
 18import mpv5.db.common.DatabaseObject;
 19import mpv5.db.common.DatabaseSearch;
 20import mpv5.db.common.NodataFoundException;
 21import mpv5.db.common.QueryHandler;
 22import mpv5.db.objects.Item;
 23import mpv5.globals.Headers;
 24import mpv5.globals.Messages;
 25import mpv5.logging.Log;
 26import mpv5.i18n.LanguageManager;
 27import mpv5.ui.dialogs.ControlApplet;
 28import mpv5.ui.dialogs.Popup;
 29import mpv5.ui.frames.MPView;
 30import mpv5.ui.panels.DataPanel;
 31import mpv5.usermanagement.MPSecurityManager;
 32import mpv5.db.objects.User;
 33
 34import mpv5.utils.arrays.ArrayUtilities;
 35import mpv5.utils.date.DateConverter;
 36import mpv5.utils.models.MPComboBoxModelItem;
 37import mpv5.utils.models.MPTableModel;
 38import mpv5.utils.tables.Selection;
 39import mpv5.utils.tables.TableFormat;
 40import mpv5.utils.text.MD5HashGenerator;
 41import mpv5.utils.ui.TextFieldUtils;
 42
 43/**
 44 *
 45 * 
 46 */
 47public class ControlPanel_Users extends javax.swing.JPanel implements ControlApplet, DataPanel {
 48
 49    private static final long serialVersionUID = 1L;
 50    /**
 51     * This unique name identifies this control applet
 52     */
 53    public final String UNAME = "users";
 54    private PropertyStore oldvalues;
 55    private User dataOwner;
 56    private static ControlPanel_Users ident;
 57
 58    public ControlPanel_Users() {
 59        if (MPSecurityManager.checkAdminAccess()) {
 60            initComponents();
 61            refresh();
 62            setVisible(true);
 63        }
 64    }
 65
 66    public ControlPanel_Users(User user) {
 67        if (MPSecurityManager.checkAdminAccess()) {
 68            initComponents();
 69            refresh();
 70            setDataOwner(user, true);
 71            setVisible(true);
 72        }
 73    }
 74
 75    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
 76    private void initComponents() {
 77
 78        jScrollPane1 = new javax.swing.JScrollPane();
 79        jTable1 = new javax.swing.JTable();
 80        jPanel2 = new javax.swing.JPanel();
 81        jPanel3 = new javax.swing.JPanel();
 82        language = new javax.swing.JComboBox();
 83        locale = new javax.swing.JComboBox();
 84        jLabel4 = new javax.swing.JLabel();
 85        jLabel5 = new javax.swing.JLabel();
 86        countrylist = new javax.swing.JComboBox();
 87        jLabel7 = new javax.swing.JLabel();
 88        jLabel8 = new javax.swing.JLabel();
 89        accountlist = new javax.swing.JComboBox();
 90        statuslist = new javax.swing.JComboBox();
 91        jLabel9 = new javax.swing.JLabel();
 92        laf = new javax.swing.JComboBox();
 93        jLabel11 = new javax.swing.JLabel();
 94        jPanel4 = new javax.swing.JPanel();
 95        fullname = new mpv5.ui.beans.LabeledTextField();
 96        mail = new mpv5.ui.beans.LabeledTextField();
 97        cname = new mpv5.ui.beans.LabeledTextField();
 98        password = new javax.swing.JPasswordField();
 99        jLabel2 = new javax.swing.JLabel();
100        enabled = new javax.swing.JCheckBox();
101        inthighestright = new javax.swing.JComboBox();
102        jLabel3 = new javax.swing.JLabel();
103        groupname = new javax.swing.JComboBox();
104        jLabel6 = new javax.swing.JLabel();
105        rgroups = new javax.swing.JCheckBox();
106        jLabel10 = new javax.swing.JLabel();
107        companyselect = new javax.swing.JComboBox();
108        jPanel5 = new javax.swing.JPanel();
109        jLabel1 = new javax.swing.JLabel();
110        datelastlog = new javax.swing.JTextField();
111        loggedin = new javax.swing.JCheckBox();
112        jPanel6 = new javax.swing.JPanel();
113        jButton4 = new javax.swing.JButton();
114        jButton3 = new javax.swing.JButton();
115        jButton2 = new javax.swing.JButton();
116        jButton1 = new javax.swing.JButton();
117
118        setBackground(new java.awt.Color(255, 255, 255));
119        java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle();
120        setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("ControlPanel_Users.border.title"))); // NOI18N
121        setName("Form"); // NOI18N
122        setLayout(new java.awt.BorderLayout());
123
124        jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("ControlPanel_Users.jScrollPane1.border.title"))); // NOI18N
125        jScrollPane1.setName("jScrollPane1"); // NOI18N
126
127        jTable1.setAutoCreateRowSorter(true);
128        jTable1.setModel(new javax.swing.table.DefaultTableModel(
129            new Object [][] {
130                {},
131                {},
132                {},
133                {}
134            },
135            new String [] {
136
137            }
138        ));
139        jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
140        jTable1.setDragEnabled(true);
141        jTable1.setFillsViewportHeight(true);
142        jTable1.setName("jTable1"); // NOI18N
143        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
144            public void mouseClicked(java.awt.event.MouseEvent evt) {
145                jTable1MouseClicked(evt);
146            }
147        });
148        jScrollPane1.setViewportView(jTable1);
149
150        add(jScrollPane1, java.awt.BorderLayout.CENTER);
151
152        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("ControlPanel_Users.jPanel2.border.title"))); // NOI18N
153        jPanel2.setName("jPanel2"); // NOI18N
154
155        jPanel3.setBackground(new java.awt.Color(255, 255, 255));
156        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("ControlPanel_Users.jPanel3.border.title"))); // NOI18N
157        jPanel3.setName("jPanel3"); // NOI18N
158
159        language.setName("language"); // NOI18N
160
161        locale.setName("locale"); // NOI18N
162
163        jLabel4.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
164        jLabel4.setText(bundle.getString("ControlPanel_Users.jLabel4.text")); // NOI18N
165        jLabel4.setName("jLabel4"); // NOI18N
166
167        jLabel5.setFont(new java.awt.Font("Dialog", 0, 12));
168        jLabel5.setText(bundle.getString("ControlPanel_Users.jLabel5.text")); // NOI18N
169        jLabel5.setName("jLabel5"); // NOI18N
170
171        countrylist.setName("countrylist"); // NOI18N
172
173        jLabel7.setFont(new java.awt.Font("Dialog", 0, 12));
174        jLabel7.setText(bundle.getString("ControlPanel_Users.jLabel7.text")); // NOI18N
175        jLabel7.setName("jLabel7"); // NOI18N
176
177        jLabel8.setFont(new java.awt.Font("Dialog", 0, 12));
178        jLabel8.setText(bundle.getString("ControlPanel_Users.jLabel8.text")); // NOI18N
179        jLabel8.setName("jLabel8"); // NOI18N
180
181        accountlist.setName("accountlist"); // NOI18N
182
183        statuslist.setName("statuslist"); // NOI18N
184
185        jLabel9.setFont(new java.awt.Font("Dialog", 0, 12));
186        jLabel9.setText(bundle.getString("ControlPanel_Users.jLabel9.text")); // NOI18N
187        jLabel9.setName("jLabel9"); // NOI18N
188
189        laf.setEditable(true);
190        laf.setName("laf"); // NOI18N
191
192        jLabel11.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
193        jLabel11.setText(bundle.getString("ControlPanel_Users.jLabel11.text")); // NOI18N
194        jLabel11.setName("jLabel11"); // NOI18N
195
196        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
197        jPanel3.setLayout(jPanel3Layout);
198        jPanel3Layout.setHorizontalGroup(
199            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
200            .addGroup(jPanel3Layout.createSequentialGroup()
201                .addContainerGap()
202                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
203                    .addGroup(jPanel3Layout.createSequentialGroup()
204                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
205                            .addComponent(jLabel8)
206                            .addComponent(jLabel9))
207                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
208                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
209                            .addComponent(statuslist, 0, 211, Short.MAX_VALUE)
210                            .addComponent(accountlist, 0, 211, Short.MAX_VALUE)))
211                    .addGroup(jPanel3Layout.createSequentialGroup()
212                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
213                            .addComponent(jLabel4)
214                            .addComponent(jLabel5)
215                            .addComponent(jLabel7)
216                            .addComponent(jLabel11))
217                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
218                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
219                            .addComponent(laf, 0, 212, Short.MAX_VALUE)
220                            .addComponent(countrylist, 0, 212, Short.MAX_VALUE)
221                            .addComponent(locale, javax.swing.GroupLayout.Alignment.TRAILING, 0, 212, Short.MAX_VALUE)
222                            .addComponent(language, 0, 212, Short.MAX_VALUE))))
223                .addContainerGap())
224        );
225        jPanel3Layout.setVerticalGroup(
226            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
227            .addGroup(jPanel3Layout.createSequentialGroup()
228                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
229                    .addComponent(laf, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
230                    .addComponent(jLabel11))
231                .addGap(7, 7, 7)
232                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
233                    .addComponent(language, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
234                    .addComponent(jLabel4))
235                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
236                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
237                    .addComponent(locale, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
238                    .addComponent(jLabel5))
239                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
240                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
241                    .addComponent(countrylist, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
242                    .addComponent(jLabel7))
243                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
244                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
245                    .addComponent(accountlist, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
246                    .addComponent(jLabel8))
247                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
248                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
249                    .addComponent(statuslist, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
250                    .addComponent(jLabel9))
251                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
252        );
253
254        jPanel4.setBackground(new java.awt.Color(255, 255, 255));
255        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("ControlPanel_Users.jPanel4.border.title"))); // NOI18N
256        jPanel4.setName("jPanel4"); // NOI18N
257
258        fullname.set_Label(bundle.getString("ControlPanel_Users.fullname._Label")); // NOI18N
259        fullname.setName("fullname"); // NOI18N
260
261        mail.set_Label(bundle.getString("ControlPanel_Users.mail._Label")); // NOI18N
262        mail.setName("mail"); // NOI18N
263
264        cname.set_Label(bundle.getString("ControlPanel_Users.cname._Label")); // NOI18N
265        cname.setName("cname"); // NOI18N
266
267        password.setText(bundle.getString("ControlPanel_Users.password.text")); // NOI18N
268        password.setName("password"); // NOI18N
269
270        jLabel2.setFont(jLabel2.getFont().deriveFont(jLabel2.getFont().getStyle() | java.awt.Font.BOLD));
271        jLabel2.setText(bundle.getString("ControlPanel_Users.jLabel2.text")); // NOI18N
272        jLabel2.setName("jLabel2"); // NOI18N
273
274        enabled.setBackground(new java.awt.Color(255, 255, 255));
275        enabled.setText(bundle.getString("ControlPanel_Users.enabled.text")); // NOI18N
276        enabled.setName("enabled"); // NOI18N
277
278        inthighestright.setName("inthighestright"); // NOI18N
279
280        jLabel3.setFont(new java.awt.Font("Dialog", 0, 12));
281        jLabel3.setText(bundle.getString("ControlPanel_Users.jLabel3.text")); // NOI18N
282        jLabel3.setName("jLabel3"); // NOI18N
283
284        groupname.setName("groupname"); // NOI18N
285
286        jLabel6.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
287        jLabel6.setText(bundle.getString("ControlPanel_Users.jLabel6.text")); // NOI18N
288        jLabel6.setName("jLabel6"); // NOI18N
289
290        rgroups.setBackground(new java.awt.Color(255, 255, 255));
291        rgroups.setText(bundle.getString("ControlPanel_Users.rgroups.text")); // NOI18N
292        rgroups.setName("rgroups"); // NOI18N
293
294        jLabel10.setFont(new java.awt.Font("Dialog", 0, 12));
295        jLabel10.setText(bundle.getString("ControlPanel_Users.jLabel10.text")); // NOI18N
296        jLabel10.setName("jLabel10"); // NOI18N
297
298        companyselect.setName("companyselect"); // NOI18N
299
300        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
301        jPanel4.setLayout(jPanel4Layout);
302        jPanel4Layout.setHorizontalGroup(
303            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
304            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
305                .addContainerGap()
306                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
307                    .addComponent(fullname, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE)
308                    .addComponent(mail, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE)
309                    .addComponent(cname, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE)
310                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createSequentialGroup()
311                        .addComponent(jLabel2)
312                        .addGap(24, 24, 24)
313                        .addComponent(password, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE))
314                    .addGroup(jPanel4Layout.createSequentialGroup()
315                        .addComponent(rgroups, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE)
316                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
317                        .addComponent(enabled))
318                    .addGroup(jPanel4Layout.createSequentialGroup()
319                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
320                            .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE)
321                            .addComponent(jLabel10, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE)
322                            .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE))
323                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
324                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
325                            .addComponent(groupname, 0, 203, Short.MAX_VALUE)
326                            .addComponent(companyselect, 0, 203, Short.MAX_VALUE)
327                            .addComponent(inthighestright, 0, 203, Short.MAX_VALUE))))
328                .addContainerGap())
329        );
330        jPanel4Layout.setVerticalGroup(
331            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
332            .addGroup(jPanel4Layout.createSequentialGroup()
333                .addComponent(fullname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
334                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
335                .addComponent(mail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
336                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
337                .addComponent(cname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
338                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
339                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
340                    .addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
341                    .addComponent(jLabel2))
342                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
343                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
344                    .addComponent(rgroups)
345                    .addComponent(enabled))
346                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
347                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
348                    .addComponent(jLabel6)
349                    .addComponent(groupname, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
350                .addGap(9, 9, 9)
351                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
352                    .addComponent(jLabel3)
353                    .addComponent(inthighestright, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
354                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
355                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
356                    .addComponent(companyselect, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
357                    .addComponent(jLabel10))
358                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
359        );
360
361        jPanel5.setBackground(new java.awt.Color(255, 255, 255));
362        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("ControlPanel_Users.jPanel5.border.title"))); // NOI18N
363        jPanel5.setName("jPanel5"); // NOI18N
364
365        jLabel1.setText(bundle.getString("ControlPanel_Users.jLabel1.text")); // NOI18N
366        jLabel1.setName("jLabel1"); // NOI18N
367
368        datelastlog.setEditable(false);
369        datelastlog.setText(bundle.getString("ControlPanel_Users.datelastlog.text")); // NOI18N
370        datelastlog.setName("datelastlog"); // NOI18N
371
372        loggedin.setBackground(new java.awt.Color(255, 255, 255));
373        loggedin.setText(bundle.getString("ControlPanel_Users.loggedin.text")); // NOI18N
374        loggedin.setEnabled(false);
375        loggedin.setName("loggedin"); // NOI18N
376
377        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
378        jPanel5.setLayout(jPanel5Layout);
379        jPanel5Layout.setHorizontalGroup(
380            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
381            .addGroup(jPanel5Layout.createSequentialGroup()
382                .addContainerGap(63, Short.MAX_VALUE)
383                .addComponent(jLabel1)
384                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
385                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
386                    .addComponent(loggedin)
387                    .addComponent(datelastlog, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)))
388        );
389        jPanel5Layout.setVerticalGroup(
390            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
391            .addGroup(jPanel5Layout.createSequentialGroup()
392                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
393                    .addComponent(jLabel1)
394                    .addComponent(datelastlog, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
395                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
396                .addComponent(loggedin, javax.swing.GroupLayout.PREFERRED_SIZE, 15, Short.MAX_VALUE)
397                .addContainerGap())
398        );
399
400        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
401        jPanel2.setLayout(jPanel2Layout);
402        jPanel2Layout.setHorizontalGroup(
403            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
404            .addComponent(jPanel5, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
405            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
406            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
407        );
408        jPanel2Layout.setVerticalGroup(
409            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
410            .addGroup(jPanel2Layout.createSequentialGroup()
411                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
412                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
413                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
414                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
415                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE))
416        );
417
418        add(jPanel2, java.awt.BorderLayout.EAST);
419
420        jPanel6.setBackground(new java.awt.Color(255, 255, 255));
421        jPanel6.setName("jPanel6"); // NOI18N
422        jPanel6.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
423
424        jButton4.setText(bundle.getString("ControlPanel_Users.jButton4.text")); // NOI18N
425        jButton4.setName("jButton4"); // NOI18N
426        jButton4.addActionListener(new java.awt.event.ActionListener() {
427            public void actionPerformed(java.awt.event.ActionEvent evt) {
428                jButton4ActionPerformed(evt);
429            }
430        });
431        jPanel6.add(jButton4);
432
433        jButton3.setText(bundle.getString("ControlPanel_Users.jButton3.text")); // NOI18N
434        jButton3.setName("jButton3"); // NOI18N
435        jButton3.addActionListener(new java.awt.event.ActionListener() {
436            public void actionPerformed(java.awt.event.ActionEvent evt) {
437                jButton3ActionPerformed(evt);
438            }
439        });
440        jPanel6.add(jButton3);
441
442        jButton2.setText(bundle.getString("ControlPanel_Users.jButton2.text")); // NOI18N
443        jButton2.setName("jButton2"); // NOI18N
444        jButton2.addActionListener(new java.awt.event.ActionListener() {
445            public void actionPerformed(java.awt.event.ActionEvent evt) {
446                jButton2ActionPerformed(evt);
447            }
448        });
449        jPanel6.add(jButton2);
450
451        jButton1.setText(bundle.getString("ControlPanel_Users.jButton1.text")); // NOI18N
452        jButton1.setName("jButton1"); // NOI18N
453        jButton1.addActionListener(new java.awt.event.ActionListener() {
454            public void actionPerformed(java.awt.event.ActionEvent evt) {
455                jButton1ActionPerformed(evt);
456            }
457        });
458        jPanel6.add(jButton1);
459
460        add(jPanel6, java.awt.BorderLayout.PAGE_END);
461    }// </editor-fold>//GEN-END:initComponents
462
463    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
464        reset();
465}//GEN-LAST:event_jButton3ActionPerformed
466
467    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
468
469        if (dataOwner != null) {
470            DatabaseObject dato = dataOwner;
471            dato.getPanelData(this);
472            if (dato.save()) {
473                if (mpv5.db.objects.User.getCurrentUser().equalTo((User) dato)) {
474                    mpv5.db.objects.User.getCurrentUser().reset();
475                }
476                Popup.notice(Messages.RESTART_REQUIRED);
477            } else {
478                showRequiredFields();
479            }
480        }
481}//GEN-LAST:event_jButton2ActionPerformed
482
483    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
484
485        if (dataOwner == null) {
486            dataOwner = new User();
487        }
488        DatabaseObject dato = dataOwner;
489        if (QueryHandler.instanceOf().clone(Context.getUser()).checkUniqueness(Context.getUser().getUniqueColumns(), new JTextField[]{cname.getTextField()})) {
490            dato.getPanelData(this);
491            dato.setIDS(-1);
492            if (dato.save()) {
493            } else {
494                showRequiredFields();
495            }
496        }
497
498        refresh();
499}//GEN-LAST:event_jButton1ActionPerformed
500
501    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
502        Selection s = new Selection(jTable1);
503        DatabaseObject obj;
504        if (s.checkID()) {
505            try {
506                obj = DatabaseObject.getObject(Context.getUser(), s.getId());
507                setDataOwner(obj, true);
508            } catch (NodataFoundException ex) {
509                Log.Debug(this, ex);
510            }
511        }
512    }//GEN-LAST:event_jTable1MouseClicked
513
514    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
515        if (Popup.Y_N_dialog(Messages.REALLY_DELETE)) {
516            if (dataOwner != null) {
517                DatabaseObject dato = dataOwner;
518                dato.getPanelData(this);
519                dato.delete();
520            }
521            refresh();
522        }
523    }//GEN-LAST:event_jButton4ActionPerformed
524
525    public void setValues(PropertyStore values) {
526    }
527
528    public String getUname() {
529        return UNAME;
530    }
531
532    public void reset() {
533        DatabaseObject dato = dataOwner;
534
535        dato.getPanelData(this);
536        dato.reset();
537        setDataOwner(dato, true);
538    }
539    // Variables declaration - do not modify//GEN-BEGIN:variables
540    private javax.swing.JComboBox accountlist;
541    private mpv5.ui.beans.LabeledTextField cname;
542    private javax.swing.JComboBox companyselect;
543    private javax.swing.JComboBox countrylist;
544    private javax.swing.JTextField datelastlog;
545    private javax.swing.JCheckBox enabled;
546    private mpv5.ui.beans.LabeledTextField fullname;
547    private javax.swing.JComboBox groupname;
548    private javax.swing.JComboBox inthighestright;
549    private javax.swing.JButton jButton1;
550    private javax.swing.JButton jButton2;
551    private javax.swing.JButton jButton3;
552    private javax.swing.JButton jButton4;
553    private javax.swing.JLabel jLabel1;
554    private javax.swing.JLabel jLabel10;
555    private javax.swing.JLabel jLabel11;
556    private javax.swing.JLabel jLabel2;
557    private javax.swing.JLabel jLabel3;
558    private javax.swing.JLabel jLabel4;
559    private javax.swing.JLabel jLabel5;
560    private javax.swing.JLabel jLabel6;
561    private javax.swing.JLabel jLabel7;
562    private javax.swing.JLabel jLabel8;
563    private javax.swing.JLabel jLabel9;
564    private javax.swing.JPanel jPanel2;
565    private javax.swing.JPanel jPanel3;
566    private javax.swing.JPanel jPanel4;
567    private javax.swing.JPanel jPanel5;
568    private javax.swing.JPanel jPanel6;
569    private javax.swing.JScrollPane jScrollPane1;
570    private javax.swing.JTable jTable1;
571    private javax.swing.JComboBox laf;
572    private javax.swing.JComboBox language;
573    private javax.swing.JComboBox locale;
574    private javax.swing.JCheckBox loggedin;
575    private mpv5.ui.beans.LabeledTextField mail;
576    private javax.swing.JPasswordField password;
577    private javax.swing.JCheckBox rgroups;
578    private javax.swing.JComboBox statuslist;
579    // End of variables declaration//GEN-END:variables
580    public String laf_;
581    public String language_ = "buildin_en";
582    public String locale_ = "en_US";
583    public String defcountry_ = "";
584    public String fullname_;
585    public String mail_;
586    public String cname_;
587    public String password_;
588    public boolean isenabled_;
589    public boolean isloggedin_;
590    public boolean isrgrouped_;
591    public int inthighestright_ = 9;
592    public int intdefaultaccount_ = 9;
593    public int intdefaultstatus_;
594    public int intaddedby_ = 4343;
595    public Date datelastlog_ = new Date();
596    public int ids_;
597    public int groupsids_;
598    public int compsids_;
599    public java.util.Date dateadded_ = new java.util.Date();
600
601    public boolean collectData() {
602        if (cname.getText().length() == 0) {
603            return false;
604        }
605        laf_ = String.valueOf(laf.getSelectedItem());
606
607        if (language.getSelectedItem() != null) {
608            language_ = String.valueOf(((MPComboBoxModelItem) language.getSelectedItem()).getId());
609        }
610        try {
611            defcountry_ = ((MPComboBoxModelItem) countrylist.getSelectedItem()).getId();
612        } catch (Exception e) {
613        }
614        if (locale.getSelectedItem() != null) {
615            locale_ = String.valueOf(((MPComboBoxModelItem) locale.getSelectedItem()).getId());
616        }
617
618        if (companyselect.getSelectedItem() != null) {
619            compsids_ = Integer.valueOf(((MPComboBoxModelItem) companyselect.getSelectedItem()).getId());
620        } else {
621            compsids_ = 0;
622        }
623
624        fullname_ = fullname.get_Text();
625        mail_ = mail.get_Text();
626        cname_ = cname.get_Text();
627
628        if (password.getPassword().length > 0 && !Arrays.equals(password.getPassword(), new JPasswordField().getPassword())) {
629            try {
630                password_ = MD5HashGenerator.getInstance().hashData(password.getPassword());
631            } catch (NoSuchAlgorithmException ex) {
632                Log.Debug(ex);
633            }
634        }
635        isenabled_ = enabled.isSelected();
636
637        if (inthighestright.getSelectedItem() != null) {
638            inthighestright_ = Integer.valueOf(((MPComboBoxModelItem) inthighestright.getSelectedItem()).getId());
639        }
640
641        if (groupname.getSelectedItem() != null) {
642            groupsids_ = Integer.valueOf(((MPComboBoxModelItem) groupname.getSelectedItem()).getId());
643        } else {
644            groupsids_ = 1;
645        }
646
647        if (accountlist.getSelectedItem() != null) {
648            intdefaultaccount_ = Integer.valueOf(((MPComboBoxModelItem) accountlist.getSelectedItem()).getId());
649        } else {
650            intdefaultaccount_ = 1;
651        }
652
653        if (statuslist.getSelectedItem() != null) {
654            intdefaultstatus_ = Integer.valueOf(((MPComboBoxModelItem) statuslist.getSelectedItem()).getId());
655        } else {
656            intdefaultstatus_ = 1;
657        }
658
659        isrgrouped_ = rgroups.isSelected();
660
661        return true;
662    }
663
664    public void exposeData() {
665
666        try {
667            laf.setSelectedItem(laf_);
668            language.setSelectedIndex(MPComboBoxModelItem.getItemID(language_, language.getModel()));
669            locale.setSelectedIndex(MPComboBoxModelItem.getItemID(locale_, locale.getModel()));
670            try {
671                countrylist.setSelectedIndex(MPComboBoxModelItem.getItemID(defcountry_, countrylist.getModel()));
672            } catch (Exception e) {
673                Log.Debug(this, e);
674            }
675            fullname.set_Text(fullname_);
676//        password.setText(password_);
677            mail.set_Text(mail_);
678            cname.set_Text(cname_);
679            enabled.setSelected(isenabled_);
680            rgroups.setSelected(isrgrouped_);
681            inthighestright.setSelectedIndex(MPComboBoxModelItem.getItemID(String.valueOf(inthighestright_), inthighestright.getModel()));
682            loggedin.setSelected(isloggedin_);
683            datelastlog.setText(DateConverter.getDefDateString(datelastlog_));
684            groupname.setSelectedIndex(MPComboBoxModelItem.getItemID(String.valueOf(groupsids_), groupname.getModel()));
685            accountlist.setSelectedIndex(MPComboBoxModelItem.getItemID(String.valueOf(intdefaultaccount_), accountlist.getModel()));
686            statuslist.setSelectedIndex(MPComboBoxModelItem.getItemIDfromValue(Item.getStatusString(intdefaultstatus_), statuslist.getModel()));
687            try {
688                companyselect.setSelectedIndex(MPComboBoxModelItem.getItemID(String.valueOf(compsids_), companyselect.getModel()));
689            } catch (Exception e) {
690                //No companies defined
691            }
692        } catch (Exception e) {
693            Log.Debug(this, e);
694        }
695    }
696
697    public DatabaseObject getDataOwner() {
698        return dataOwner;
699    }
700
701    public void setDataOwner(DatabaseObject object, boolean p) {
702        dataOwner = (User) object;
703        if (p) {
704            dataOwner.setPanelData(this);
705            this.exposeData();
706        }
707    }
708
709    public void refresh() {
710
711        try {
712            language.setModel(LanguageManager.getLanguagesAsComboBoxModel());
713            locale.setModel(LanguageManager.getLocalesAsComboBoxModel());
714            countrylist.setModel(LanguageManager.getCountriesAsComboBoxModel());
715        } catch (Exception e) {
716            Log.Debug(this, e);
717        }
718
719        inthighestright.setModel(MPSecurityManager.getRolesAsComboBoxModel());
720        jTable1.setModel(new MPTableModel(new Class[]{String.class, String.class, String.class, String.class, Boolean.class, Boolean.class}, TableFormat.changeToClassValue(QueryHandler.instanceOf().clone(Context.getUser()).select(Context.DETAILS_USERS, (String[]) null), Boolean.class, new int[]{4, 5}), Headers.USER_DETAILS.getValue()));
721
722        groupname.setModel(new DefaultComboBoxModel(
723                MPComboBoxModelItem.toItems(new DatabaseSearch(Context.getGroup()).getValuesFor(Context.getGroup().getSubID()))));
724        companyselect.setModel(new DefaultComboBoxModel(
725                MPComboBoxModelItem.toItems(new DatabaseSearch(Context.getCompany()).getValuesFor(Context.getCompany().getSubID()))));
726        accountlist.setModel(new DefaultComboBoxModel(
727                MPComboBoxModelItem.toItems(new DatabaseSearch(Context.getAccounts()).getValuesFor(Context.getAccounts().getSubID()))));
728        statuslist.setModel(MPComboBoxModelItem.toModel(Item.getStatusStrings()));
729
730        LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels();
731        String[] lnfs = new String[lfs.length];
732        for (int i = 0; i < lnfs.length; i++) {
733            lnfs[i] = lfs[i].getClassName();
734        }
735
736        laf.setModel(new DefaultComboBoxModel(lnfs));
737
738        TableFormat.stripFirstColumn(jTable1);
739        TableFormat.format(jTable1, 1, 120);
740        TableFormat.format(jTable1, 4, 80);
741        TableFormat.format(jTable1, 5, 80);
742    }
743
744    public void paste(DatabaseObject... dbos) {
745        for (DatabaseObject dbo : dbos) {
746            if (dbo.getDbIdentity().equals(Context.getUser().getDbIdentity())) {
747                setDataOwner(dbo, true);
748            } else {
749                mpv5.YabsViewProxy.instance().addMessage(Messages.NOT_POSSIBLE.toString() + Messages.ACTION_PASTE, Color.RED);
750            }
751        }
752    }
753
754    public void showRequiredFields() {
755        TextFieldUtils.blinkerRed(fullname);
756    }
757
758    public void showSearchBar(boolean show) {
759        throw new UnsupportedOperationException("Not supported yet.");
760    }
761
762    public Component getAndRemoveActionPanel() {
763        if (MPSecurityManager.checkAdminAccess()) {
764            this.remove(jPanel6);
765            validate();
766            return jPanel6;
767        }
768        return null;
769    }
770
771    @Override
772    public void actionAfterSave() {
773    }
774
775    @Override
776    public void actionAfterCreate() {
777    }
778
779    public void actionBeforeCreate() {
780    }
781
782    public void actionBeforeSave() {
783    }
784
785    public void mail() {
786        throw new UnsupportedOperationException("Not supported yet.");
787    }
788
789    public void print() {
790        mpv5.utils.export.Export.print(this);
791    }
792}