PageRenderTime 2195ms CodeModel.GetById 284ms app.highlight 1620ms RepoModel.GetById 93ms app.codeStats 0ms

/src/mpv5/ui/toolbars/DataPanelTB.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 657 lines | 512 code | 72 blank | 73 comment | 72 complexity | f71333c6d9ce73c1bd20aef96b1c5127 MD5 | raw file
  1/*
  2 *  This file is part of YaBS.
  3 *
  4 *      YaBS is free software: you can redistribute it and/or modify
  5 *      it under the terms of the GNU General Public License as published by
  6 *      the Free Software Foundation, either version 3 of the License, or
  7 *      (at your option) any later version.
  8 *
  9 *      YaBS is distributed in the hope that it will be useful,
 10 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12 *      GNU General Public License for more details.
 13 *
 14 *      You should have received a copy of the GNU General Public License
 15 *      along with YaBS.  If not, see <http://www.gnu.org/licenses/>.
 16 */
 17/*
 18 * ContactsTB.java
 19 *
 20 * Created on 25.01.2009, 16:54:29
 21 */
 22package mpv5.ui.toolbars;
 23
 24import java.awt.Color;
 25import java.awt.Component;
 26import java.awt.event.ActionListener;
 27import java.awt.event.ItemListener;
 28import mpv5.db.common.Context;
 29import mpv5.db.common.DatabaseObject;
 30import mpv5.db.common.QueryHandler;
 31import mpv5.globals.Messages;
 32import mpv5.db.objects.Favourite;
 33import mpv5.logging.Log;
 34import mpv5.ui.dialogs.Popup;
 35import mpv5.ui.frames.MPView;
 36import mpv5.ui.panels.ChangeNotApprovedException;
 37import mpv5.ui.panels.DataPanel;
 38import mpv5.ui.panels.ExportablePanel;
 39
 40/**
 41 *
 42 * 
 43 */
 44public class DataPanelTB extends javax.swing.JPanel implements ActionListener, ItemListener {
 45
 46    private static final long serialVersionUID = -8215471082724735228L;
 47    private DataPanel parents;
 48    private final ActionListener action1 = new java.awt.event.ActionListener() {
 49
 50        public void actionPerformed(java.awt.event.ActionEvent evt) {
 51            favAdd(evt);
 52        }
 53    };
 54    private final ActionListener action2 = new java.awt.event.ActionListener() {
 55
 56        public void actionPerformed(java.awt.event.ActionEvent evt) {
 57            favRemover(evt);
 58        }
 59    };
 60
 61    /**
 62     * 
 63     * @param panel
 64     */
 65    public DataPanelTB(DataPanel panel) {
 66        initComponents();
 67        parents = panel;
 68        parents.showSearchBar(mpv5.db.objects.User.getCurrentUser().getProperties().getProperty(this, "jToggleButton1"));
 69        but1.setSelected(mpv5.db.objects.User.getCurrentUser().getProperties().getProperty(this, "jToggleButton1"));
 70        but6.setEnabled(!DatabaseObject.isAutoLockEnabled());
 71
 72        if (!(parents instanceof ExportablePanel)) {
 73            commonActionsToolbar.remove(odtButton);
 74            commonActionsToolbar.remove(pdfButton);
 75            commonActionsToolbar.validate();
 76        }
 77    }
 78
 79    /**
 80     * Disable the button with the given number (from left to right)
 81     * @param button
 82     */
 83    public void disableButton(int button) {
 84        Component[] c = commonActionsToolbar.getComponents();
 85        for (int i = 0; i < c.length; i++) {
 86            Component component = c[i];
 87            if (component.getName().equals("but" + button)) {
 88                (component).setEnabled(false);
 89            }
 90        }
 91    }
 92
 93    /**
 94     *
 95     * @param on
 96     */
 97    public void setEditable(boolean on) {
 98        but3.setEnabled(on);
 99        but5.setEnabled(on);
100        but6.setEnabled(on);
101    }
102
103    /**
104     *
105     * @param favourite
106     */
107    public void setFavourite(boolean favourite) {
108        if (!favourite) {
109            but7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bookmark_add.png"))); // NOI18N
110            but7.setFocusable(false);
111            but7.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
112            but7.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
113            but7.removeActionListener(action2);
114            but7.removeActionListener(action1);
115            but7.addActionListener(action1);
116        } else {
117            but7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bookmark.png"))); // NOI18N
118            but7.setFocusable(false);
119            but7.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
120            but7.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
121            but7.removeActionListener(action1);
122            but7.removeActionListener(action2);
123            but7.addActionListener(action2);
124        }
125        this.validate();
126    }
127
128    /** This method is called from within the constructor to
129     * initialize the form.
130     * WARNING: Do NOT modify this code. The content of this method is
131     * always regenerated by the Form Editor.
132     */
133    @SuppressWarnings("unchecked")
134    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
135    private void initComponents() {
136
137        commonActionsToolbar = new javax.swing.JToolBar();
138        but1 = new javax.swing.JToggleButton();
139        jSeparator4 = new javax.swing.JToolBar.Separator();
140        but2 = new javax.swing.JButton();
141        but3 = new javax.swing.JButton();
142        but4 = new javax.swing.JButton();
143        jSeparator1 = new javax.swing.JToolBar.Separator();
144        but5 = new javax.swing.JButton();
145        jSeparator3 = new javax.swing.JToolBar.Separator();
146        but6 = new javax.swing.JButton();
147        but7 = new javax.swing.JButton();
148        but10 = new javax.swing.JButton();
149        jSeparator2 = new javax.swing.JToolBar.Separator();
150        printButton = new javax.swing.JButton();
151        mailButton = new javax.swing.JButton();
152        pdfButton = new javax.swing.JButton();
153        odtButton = new javax.swing.JButton();
154
155        setName("Form"); // NOI18N
156
157        commonActionsToolbar.setFloatable(false);
158        commonActionsToolbar.setRollover(true);
159        commonActionsToolbar.setName("commonActionsToolbar"); // NOI18N
160        commonActionsToolbar.setPreferredSize(new java.awt.Dimension(342, 41));
161
162        but1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/viewmag.png"))); // NOI18N
163        java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle(); // NOI18N
164        but1.setText(bundle.getString("DataPanelTB.but1.text")); // NOI18N
165        but1.setToolTipText(bundle.getString("DataPanelTB.but1.toolTipText")); // NOI18N
166        but1.setContentAreaFilled(false);
167        but1.setFocusable(false);
168        but1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
169        but1.setName("but1"); // NOI18N
170        but1.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_viewmag.png"))); // NOI18N
171        but1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
172        but1.addItemListener(this);
173        but1.addActionListener(this);
174        commonActionsToolbar.add(but1);
175
176        jSeparator4.setName("jSeparator4"); // NOI18N
177        commonActionsToolbar.add(jSeparator4);
178
179        but2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/revert.png"))); // NOI18N
180        but2.setText(bundle.getString("MPV5View.jButton22.text")); // NOI18N
181        but2.setToolTipText(bundle.getString("MPV5View.jButton22.toolTipText")); // NOI18N
182        but2.setContentAreaFilled(false);
183        but2.setFocusable(false);
184        but2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
185        but2.setName("but2"); // NOI18N
186        but2.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
187        but2.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_revert.png"))); // NOI18N
188        but2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
189        but2.addActionListener(this);
190        commonActionsToolbar.add(but2);
191
192        but3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/3floppy_unmount.png"))); // NOI18N
193        but3.setText(bundle.getString("MPV5View.jButton25.text")); // NOI18N
194        but3.setToolTipText(bundle.getString("MPV5View.jButton25.toolTipText")); // NOI18N
195        but3.setContentAreaFilled(false);
196        but3.setFocusable(false);
197        but3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
198        but3.setName("but3"); // NOI18N
199        but3.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
200        but3.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_3floppy_unmount.png"))); // NOI18N
201        but3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
202        but3.addActionListener(this);
203        commonActionsToolbar.add(but3);
204
205        but4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/filenew.png"))); // NOI18N
206        but4.setText(bundle.getString("MPV5View.jButton4.text")); // NOI18N
207        but4.setToolTipText(bundle.getString("MPV5View.jButton4.toolTipText")); // NOI18N
208        but4.setContentAreaFilled(false);
209        but4.setFocusable(false);
210        but4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
211        but4.setName("but4"); // NOI18N
212        but4.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
213        but4.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_filenew.png"))); // NOI18N
214        but4.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
215        but4.addActionListener(this);
216        commonActionsToolbar.add(but4);
217
218        jSeparator1.setName("jSeparator1"); // NOI18N
219        commonActionsToolbar.add(jSeparator1);
220
221        but5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/edittrash.png"))); // NOI18N
222        but5.setText(bundle.getString("MPV5View.jButton26.text")); // NOI18N
223        but5.setToolTipText(bundle.getString("MPV5View.jButton26.toolTipText")); // NOI18N
224        but5.setContentAreaFilled(false);
225        but5.setFocusable(false);
226        but5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
227        but5.setName("but5"); // NOI18N
228        but5.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
229        but5.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_edittrash.png"))); // NOI18N
230        but5.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
231        but5.addActionListener(this);
232        commonActionsToolbar.add(but5);
233
234        jSeparator3.setName("jSeparator3"); // NOI18N
235        commonActionsToolbar.add(jSeparator3);
236
237        but6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/password.png"))); // NOI18N
238        but6.setText(bundle.getString("MPV5View.jButton21.text")); // NOI18N
239        but6.setToolTipText(bundle.getString("MPV5View.jButton21.toolTipText")); // NOI18N
240        but6.setContentAreaFilled(false);
241        but6.setFocusable(false);
242        but6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
243        but6.setName("but6"); // NOI18N
244        but6.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
245        but6.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_password.png"))); // NOI18N
246        but6.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
247        but6.addActionListener(this);
248        commonActionsToolbar.add(but6);
249
250        but7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bookmark_add.png"))); // NOI18N
251        but7.setText(bundle.getString("MPV5View.jButton24.text")); // NOI18N
252        but7.setToolTipText(bundle.getString("MPV5View.jButton24.toolTipText")); // NOI18N
253        but7.setContentAreaFilled(false);
254        but7.setFocusable(false);
255        but7.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
256        but7.setName("but7"); // NOI18N
257        but7.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
258        but7.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_bookmark_add.png"))); // NOI18N
259        but7.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
260        but7.addActionListener(this);
261        commonActionsToolbar.add(but7);
262
263        but10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/add.png"))); // NOI18N
264        but10.setText(bundle.getString("DataPanelTB.but10.text")); // NOI18N
265        but10.setToolTipText(bundle.getString("DataPanelTB.but10.toolTipText")); // NOI18N
266        but10.setContentAreaFilled(false);
267        but10.setFocusable(false);
268        but10.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
269        but10.setName("but10"); // NOI18N
270        but10.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
271        but10.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
272        but10.addActionListener(this);
273        commonActionsToolbar.add(but10);
274
275        jSeparator2.setName("jSeparator2"); // NOI18N
276        commonActionsToolbar.add(jSeparator2);
277
278        printButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/printer.png"))); // NOI18N
279        printButton.setText(bundle.getString("MPV5View.jButton23.text")); // NOI18N
280        printButton.setToolTipText(bundle.getString("MPV5View.jButton23.toolTipText")); // NOI18N
281        printButton.setContentAreaFilled(false);
282        printButton.setFocusable(false);
283        printButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
284        printButton.setName("printButton"); // NOI18N
285        printButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
286        printButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_printer.png"))); // NOI18N
287        printButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
288        printButton.addActionListener(this);
289        commonActionsToolbar.add(printButton);
290
291        mailButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/mail_reply.png"))); // NOI18N
292        mailButton.setText(bundle.getString("DataPanelTB.mailButton.text")); // NOI18N
293        mailButton.setToolTipText(bundle.getString("DataPanelTB.mailButton.toolTipText")); // NOI18N
294        mailButton.setContentAreaFilled(false);
295        mailButton.setFocusable(false);
296        mailButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
297        mailButton.setName("mailButton"); // NOI18N
298        mailButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
299        mailButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_mail_reply.png"))); // NOI18N
300        mailButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
301        mailButton.addActionListener(this);
302        commonActionsToolbar.add(mailButton);
303
304        pdfButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/pdf.png"))); // NOI18N
305        pdfButton.setText(bundle.getString("DataPanelTB.pdfButton.text")); // NOI18N
306        pdfButton.setToolTipText(bundle.getString("DataPanelTB.pdfButton.toolTipText")); // NOI18N
307        pdfButton.setContentAreaFilled(false);
308        pdfButton.setFocusable(false);
309        pdfButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
310        pdfButton.setName("pdfButton"); // NOI18N
311        pdfButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
312        pdfButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
313        pdfButton.addActionListener(this);
314        commonActionsToolbar.add(pdfButton);
315
316        odtButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/openofficeorg-20-writer.png"))); // NOI18N
317        odtButton.setText(bundle.getString("DataPanelTB.odtButton.text")); // NOI18N
318        odtButton.setToolTipText(bundle.getString("DataPanelTB.odtButton.toolTipText")); // NOI18N
319        odtButton.setContentAreaFilled(false);
320        odtButton.setFocusable(false);
321        odtButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
322        odtButton.setName("odtButton"); // NOI18N
323        odtButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
324        odtButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
325        odtButton.addActionListener(this);
326        commonActionsToolbar.add(odtButton);
327
328        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
329        this.setLayout(layout);
330        layout.setHorizontalGroup(
331            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
332            .addComponent(commonActionsToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, 583, Short.MAX_VALUE)
333        );
334        layout.setVerticalGroup(
335            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
336            .addComponent(commonActionsToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
337        );
338    }
339
340    // Code for dispatching events from components to event handlers.
341
342    public void actionPerformed(java.awt.event.ActionEvent evt) {
343        if (evt.getSource() == but1) {
344            DataPanelTB.this.but1ActionPerformed(evt);
345        }
346        else if (evt.getSource() == but2) {
347            DataPanelTB.this.but2ActionPerformed(evt);
348        }
349        else if (evt.getSource() == but3) {
350            DataPanelTB.this.but3ActionPerformed(evt);
351        }
352        else if (evt.getSource() == but4) {
353            DataPanelTB.this.but4ActionPerformed(evt);
354        }
355        else if (evt.getSource() == but5) {
356            DataPanelTB.this.but5ActionPerformed(evt);
357        }
358        else if (evt.getSource() == but6) {
359            DataPanelTB.this.but6ActionPerformed(evt);
360        }
361        else if (evt.getSource() == but7) {
362            DataPanelTB.this.but7ActionPerformed(evt);
363        }
364        else if (evt.getSource() == but10) {
365            DataPanelTB.this.but10ActionPerformed(evt);
366        }
367        else if (evt.getSource() == printButton) {
368            DataPanelTB.this.printButtonActionPerformed(evt);
369        }
370        else if (evt.getSource() == mailButton) {
371            DataPanelTB.this.mailButtonActionPerformed(evt);
372        }
373        else if (evt.getSource() == pdfButton) {
374            DataPanelTB.this.pdfButtonActionPerformed(evt);
375        }
376        else if (evt.getSource() == odtButton) {
377            DataPanelTB.this.odtButtonActionPerformed(evt);
378        }
379    }
380
381    public void itemStateChanged(java.awt.event.ItemEvent evt) {
382        if (evt.getSource() == but1) {
383            DataPanelTB.this.but1ItemStateChanged(evt);
384        }
385    }// </editor-fold>//GEN-END:initComponents
386
387    private void but2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but2ActionPerformed
388        DatabaseObject dato = parents.getDataOwner();
389
390        if (dato.isExisting()) {
391            dato.getPanelData((parents));
392            dato.reset();
393            parents.setDataOwner(dato, true);
394        }
395}//GEN-LAST:event_but2ActionPerformed
396
397    private void but3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but3ActionPerformed
398        try {
399            DatabaseObject dato = parents.getDataOwner();
400            parents.actionBeforeSave();
401            if (dato.getPanelData(parents) && dato.save()) {
402                try {
403                    parents.actionAfterSave();
404                    parents.setDataOwner(dato, true);
405                } catch (Exception e) {
406                    Log.Debug(this, e);
407                }
408            } else {
409                parents.showRequiredFields();
410            }
411        } catch (ChangeNotApprovedException ex) {
412            Log.Debug(this, ex.getMessage());
413        }
414    }//GEN-LAST:event_but3ActionPerformed
415
416    private void but4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but4ActionPerformed
417        DatabaseObject dato = parents.getDataOwner();
418
419        boolean d = dato.getPanelData(parents);
420        dato.setIDS(-1);
421        parents.actionBeforeCreate();
422
423        if (d && dato.save()) {
424            try {
425                parents.actionAfterCreate();
426                parents.setDataOwner(dato, true);
427            } catch (Exception e) {
428                Log.Debug(this, e);
429            }
430        } else {
431            parents.showRequiredFields();
432        }
433}//GEN-LAST:event_but4ActionPerformed
434
435    private void but6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but6ActionPerformed
436        DatabaseObject dato = parents.getDataOwner();
437        if (mpv5.db.objects.User.getCurrentUser().isDefault()) {
438            Popup.notice(Messages.DEFAULT_USER);
439        } else if (dato.isExisting()) {
440            if (dato.lock()) {
441                Popup.notice(dato.toString() + Messages.LOCKED);
442                but6.setEnabled(false);
443            } else {
444                Popup.notice(Messages.LOCK_FAILED);
445            }
446        } else {
447            Popup.notice(Messages.NOT_SAVED_YET);
448        }
449}//GEN-LAST:event_but6ActionPerformed
450
451    private void printButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_printButtonActionPerformed
452
453        DatabaseObject dato = parents.getDataOwner();
454        if (dato.isExisting()) {
455            parents.print();
456
457            final String fmessage = Messages.PRINTED + dato.__getCname();
458            final String fdbid = dato.getDbIdentity();
459            final int fids = dato.__getIDS();
460            final int fgids = dato.__getGroupsids();
461            Runnable runnable = new Runnable() {
462
463                @Override
464                public void run() {
465                    QueryHandler.instanceOf().clone(Context.getHistory()).insertHistoryItem(fmessage, mpv5.db.objects.User.getCurrentUser().__getCname(), fdbid, fids, fgids);
466                }
467            };
468            new Thread(runnable).start();
469        }
470}//GEN-LAST:event_printButtonActionPerformed
471
472    private void but5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but5ActionPerformed
473
474        DatabaseObject dato = parents.getDataOwner();
475        if (dato.isExisting() && Popup.Y_N_dialog(Messages.REALLY_DELETE)) {
476            dato.getPanelData(parents);
477            dato.delete();
478            parents.refresh();
479            parents.setDataOwner(dato.getObject(dato.getContext()), true);
480        }
481    }//GEN-LAST:event_but5ActionPerformed
482
483    private void but7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but7ActionPerformed
484    }//GEN-LAST:event_but7ActionPerformed
485
486    private void but1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but1ActionPerformed
487
488        parents.showSearchBar(but1.isSelected());
489    }//GEN-LAST:event_but1ActionPerformed
490
491    private void but1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_but1ItemStateChanged
492        mpv5.db.objects.User.getCurrentUser().getProperties().changeProperty(this, "jToggleButton1", but1.isSelected());
493    }//GEN-LAST:event_but1ItemStateChanged
494
495    private void mailButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mailButtonActionPerformed
496
497        DatabaseObject dato = parents.getDataOwner();
498        if (dato.isExisting()) {
499            parents.mail();
500        }
501    }//GEN-LAST:event_mailButtonActionPerformed
502
503    private void but10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but10ActionPerformed
504
505        DatabaseObject dato = parents.getDataOwner();
506        if (dato.isExisting()) {
507            mpv5.YabsViewProxy.instance().addToClipBoard(dato);
508//            mpv5.YabsViewProxy.instance().setClipBoardVisible(true);
509        } 
510    }//GEN-LAST:event_but10ActionPerformed
511
512    private void pdfButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pdfButtonActionPerformed
513
514        DatabaseObject dato = parents.getDataOwner();
515        if (dato.isExisting() && parents instanceof ExportablePanel) {
516            ((ExportablePanel) parents).pdf();
517            final String fmessage = Messages.PDF + dato.__getCname();
518            final String fdbid = dato.getDbIdentity();
519            final int fids = dato.__getIDS();
520            final int fgids = dato.__getGroupsids();
521            Runnable runnable = new Runnable() {
522
523                @Override
524                public void run() {
525                    QueryHandler.instanceOf().clone(Context.getHistory()).insertHistoryItem(fmessage, mpv5.db.objects.User.getCurrentUser().__getCname(), fdbid, fids, fgids);
526                }
527            };
528            new Thread(runnable).start();
529        }
530
531    }//GEN-LAST:event_pdfButtonActionPerformed
532
533    private void odtButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_odtButtonActionPerformed
534        DatabaseObject dato = parents.getDataOwner();
535        if (dato.isExisting()) {
536            ((ExportablePanel) parents).odt();
537            final String fmessage = Messages.ODT + dato.__getCname();
538            final String fdbid = dato.getDbIdentity();
539            final int fids = dato.__getIDS();
540            final int fgids = dato.__getGroupsids();
541            Runnable runnable = new Runnable() {
542
543                @Override
544                public void run() {
545                    QueryHandler.instanceOf().clone(Context.getHistory()).insertHistoryItem(fmessage, mpv5.db.objects.User.getCurrentUser().__getCname(), fdbid, fids, fgids);
546                }
547            };
548            new Thread(runnable).start();
549        }
550
551    }//GEN-LAST:event_odtButtonActionPerformed
552    // Variables declaration - do not modify//GEN-BEGIN:variables
553    private javax.swing.JToggleButton but1;
554    private javax.swing.JButton but10;
555    private javax.swing.JButton but2;
556    private javax.swing.JButton but3;
557    private javax.swing.JButton but4;
558    private javax.swing.JButton but5;
559    private javax.swing.JButton but6;
560    private javax.swing.JButton but7;
561    private javax.swing.JToolBar commonActionsToolbar;
562    private javax.swing.JToolBar.Separator jSeparator1;
563    private javax.swing.JToolBar.Separator jSeparator2;
564    private javax.swing.JToolBar.Separator jSeparator3;
565    private javax.swing.JToolBar.Separator jSeparator4;
566    private javax.swing.JButton mailButton;
567    private javax.swing.JButton odtButton;
568    private javax.swing.JButton pdfButton;
569    private javax.swing.JButton printButton;
570    // End of variables declaration//GEN-END:variables
571
572    private void favRemover(java.awt.event.ActionEvent evt) {
573
574        DatabaseObject dato = parents.getDataOwner();
575        if (!mpv5.db.objects.User.getCurrentUser().isDefault() && dato.isExisting()) {
576            dato.getPanelData(parents);
577            if (dato.save()) {
578                Favourite.removeFavourite(dato);
579                mpv5.YabsViewProxy.instance().reloadFavorites();
580                parents.setDataOwner(dato, true);
581            } else {
582                parents.showRequiredFields();
583            }
584        }
585    }
586
587    private void favAdd(java.awt.event.ActionEvent evt) {
588        DatabaseObject dato = parents.getDataOwner();
589        Favourite fav = null;
590        if (!mpv5.db.objects.User.getCurrentUser().isDefault()) {
591            if (dato.isExisting()) {
592                dato.getPanelData(parents);
593                if (dato.save()) {
594                    fav = new Favourite(dato);
595                    fav.save();
596                    mpv5.YabsViewProxy.instance().reloadFavorites();
597                    mpv5.YabsViewProxy.instance().addMessage(Messages.ADDED_TO_FAVOURITES + dato.__getCname(), Color.GREEN);
598                    parents.setDataOwner(dato, true);
599                } else {
600                    parents.showRequiredFields();
601                }
602            }
603        } else {
604            Popup.notice(Messages.DEFAULT_USER);
605        }
606    }
607
608    /**
609     *
610     * @param enable
611     */
612    public void setExportButtonsEnabled(boolean enable) {
613        getMailButton().setEnabled(enable);
614    }
615
616    /**
617     * @return the mailButton
618     */
619    public javax.swing.JButton getMailButton() {
620        return mailButton;
621    }
622
623    /**
624     * @return the odtButton
625     */
626    public javax.swing.JButton getOdtButton() {
627        return odtButton;
628    }
629
630    /**
631     * @return the pdfButton
632     */
633    public javax.swing.JButton getPdfButton() {
634        return pdfButton;
635    }
636
637    /**
638     * @return the printButton
639     */
640    public javax.swing.JButton getPrintButton() {
641        return printButton;
642    }
643
644    /**
645     * @return the pdfButton
646     */
647    public javax.swing.JButton getSaveButton() {
648        return but3;
649    }
650
651    /**
652     * @return the printButton
653     */
654    public javax.swing.JButton getCreateButton() {
655        return but4;
656    }
657}