PageRenderTime 275ms CodeModel.GetById 201ms app.highlight 63ms RepoModel.GetById 2ms app.codeStats 0ms

/src/mpv5/ui/panels/RemindPanel.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 635 lines | 524 code | 77 blank | 34 comment | 34 complexity | 8b6f2deb0239fc3196bdb506c793766f 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 * GeneralListPanel.java
 19 *
 20 * Created on 03.04.2009, 15:26:37
 21 */
 22package mpv5.ui.panels;
 23
 24import enoa.handler.TemplateHandler;
 25import java.awt.event.ActionEvent;
 26import java.awt.event.ActionListener;
 27import java.io.File;
 28import java.util.HashMap;
 29import java.util.List;
 30import java.util.Vector;
 31import java.util.logging.Level;
 32import java.util.logging.Logger;
 33import javax.swing.DefaultListModel;
 34import mpv5.db.common.Context;
 35import mpv5.db.common.DatabaseObject;
 36import mpv5.db.common.NodataFoundException;
 37import mpv5.db.objects.Item;
 38import mpv5.db.objects.Reminder;
 39import mpv5.db.objects.Stage;
 40import mpv5.db.objects.Template;
 41import mpv5.globals.Constants;
 42import mpv5.globals.Messages;
 43import mpv5.handler.FormFieldsHandler;
 44import mpv5.logging.Log;
 45import mpv5.ui.dialogs.DialogForFile;
 46import mpv5.ui.dialogs.Popup;
 47import mpv5.ui.frames.MPView;
 48import mpv5.utils.export.Export;
 49import mpv5.utils.export.Exportable;
 50import mpv5.utils.files.FileDirectoryHandler;
 51import mpv5.utils.jobs.Job;
 52
 53/**
 54 *
 55 *  
 56 */
 57public class RemindPanel extends javax.swing.JPanel {
 58
 59    private static final long serialVersionUID = 1L;
 60    Reminder dataOwner = new Reminder();
 61    private java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle();
 62
 63    /** Creates new form GeneralListPanel */
 64    public RemindPanel() {
 65        initComponents();
 66        labeledTextField1.set_ValueClass(Double.class);
 67
 68        labeledCombobox1.setSearchEnabled(true);
 69        labeledCombobox1.setContext(Context.getItem());
 70
 71        labeledCombobox3.setSearchEnabled(true);
 72        labeledCombobox3.setContext(Context.getStage());
 73
 74        labeledCombobox1.getComboBox().addActionListener(new ActionListener() {
 75
 76            public void actionPerformed(ActionEvent e) {
 77                try {
 78                    refresh((Item) DatabaseObject.getObject(Context.getItem(), Integer.valueOf(labeledCombobox1.getSelectedItem().getId())));
 79                } catch (Exception ex) {
 80                    Log.Debug(this, ex.getMessage());
 81                }
 82            }
 83        });
 84
 85        labeledCombobox3.getComboBox().addActionListener(new ActionListener() {
 86
 87            public void actionPerformed(ActionEvent e) {
 88                try {
 89                    Stage s = (Stage) DatabaseObject.getObject(Context.getStage(), Integer.valueOf(labeledCombobox3.getSelectedItem().getId()));
 90                    jTextPane1.setText(s.__getDescription());
 91                    labeledTextField1.setText(s.__getExtravalue());
 92                } catch (Exception ex) {
 93                    Log.Debug(this, ex.getMessage());
 94                }
 95            }
 96        });
 97
 98
 99        labeledCombobox2.setContext(Context.getGroup());
100        labeledCombobox2.setSearchEnabled(true);
101        labeledCombobox2.setEditable(true);
102        labeledCombobox2.triggerSearch();
103    }
104
105    public RemindPanel(Item bill) {
106        initComponents();
107        labeledCombobox1.getComboBox().addActionListener(new ActionListener() {
108
109            public void actionPerformed(ActionEvent e) {
110                try {
111                    refresh((Item) DatabaseObject.getObject(Context.getItem(), Integer.valueOf(labeledCombobox1.getSelectedItem().getId())));
112                } catch (Exception ex) {
113                    Log.Debug(this, ex.getMessage());
114                }
115            }
116        });
117
118        labeledCombobox3.getComboBox().addActionListener(new ActionListener() {
119
120            public void actionPerformed(ActionEvent e) {
121                try {
122                    Stage s = (Stage) DatabaseObject.getObject(Context.getStage(), Integer.valueOf(labeledCombobox3.getSelectedItem().getId()));
123                    jTextPane1.setText(s.__getDescription());
124                    labeledTextField1.setText(s.__getExtravalue());
125                } catch (Exception ex) {
126                    Log.Debug(this, ex.getMessage());
127                }
128            }
129        });
130        labeledTextField1.set_ValueClass(Double.class);
131        labeledCombobox3.setSearchEnabled(true);
132        labeledCombobox3.setContext(Context.getStage());
133        labeledCombobox1.setModel(bill);
134        labeledCombobox3.triggerSearch();
135        refresh(bill);
136        labeledCombobox2.setContext(Context.getGroup());
137        labeledCombobox2.setSearchEnabled(true);
138        labeledCombobox2.setEditable(true);
139        labeledCombobox2.triggerSearch();
140    }
141
142    /** This method is called from within the constructor to
143     * initialize the form.
144     * WARNING: Do NOT modify this code. The content of this method is
145     * always regenerated by the Form Editor.
146     */
147    @SuppressWarnings("unchecked")
148    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
149    private void initComponents() {
150
151        jToolBar1 = new javax.swing.JToolBar();
152        jButton1 = new javax.swing.JButton();
153        jButton2 = new javax.swing.JButton();
154        jButton5 = new javax.swing.JButton();
155        jSeparator1 = new javax.swing.JToolBar.Separator();
156        jButton4 = new javax.swing.JButton();
157        jButton6 = new javax.swing.JButton();
158        jSeparator3 = new javax.swing.JToolBar.Separator();
159        jButton3 = new javax.swing.JButton();
160        jButton7 = new javax.swing.JButton();
161        jButton8 = new javax.swing.JButton();
162        jPanel1 = new javax.swing.JPanel();
163        labeledCombobox1 = new mpv5.ui.beans.LabeledCombobox();
164        labeledCombobox3 = new mpv5.ui.beans.LabeledCombobox();
165        jScrollPane1 = new javax.swing.JScrollPane();
166        jTextPane1 = new javax.swing.JTextPane();
167        labeledTextField1 = new mpv5.ui.beans.LabeledTextField();
168        labeledCombobox2 = new mpv5.ui.beans.LabeledCombobox();
169        jLabel1 = new javax.swing.JLabel();
170        jScrollPane2 = new javax.swing.JScrollPane();
171        jList1 = new javax.swing.JList();
172
173        mpv5.i18n.LanguageManager.getBundle();
174        setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("RemindPanel.border.title"))); // NOI18N
175        setName("Form"); // NOI18N
176
177        jToolBar1.setFloatable(false);
178        jToolBar1.setRollover(true);
179        jToolBar1.setName("jToolBar1"); // NOI18N
180
181        jButton1.setText(bundle.getString("RemindPanel.jButton1.text")); // NOI18N
182        jButton1.setName("jButton1"); // NOI18N
183        jButton1.addActionListener(new java.awt.event.ActionListener() {
184            public void actionPerformed(java.awt.event.ActionEvent evt) {
185                jButton1ActionPerformed(evt);
186            }
187        });
188        jToolBar1.add(jButton1);
189
190        jButton2.setText(bundle.getString("RemindPanel.jButton2.text")); // NOI18N
191        jButton2.setFocusable(false);
192        jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
193        jButton2.setName("jButton2"); // NOI18N
194        jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
195        jButton2.addActionListener(new java.awt.event.ActionListener() {
196            public void actionPerformed(java.awt.event.ActionEvent evt) {
197                jButton2ActionPerformed(evt);
198            }
199        });
200        jToolBar1.add(jButton2);
201
202        jButton5.setText(bundle.getString("RemindPanel.jButton5.text")); // NOI18N
203        jButton5.setFocusable(false);
204        jButton5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
205        jButton5.setName("jButton5"); // NOI18N
206        jButton5.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
207        jButton5.addActionListener(new java.awt.event.ActionListener() {
208            public void actionPerformed(java.awt.event.ActionEvent evt) {
209                jButton5ActionPerformed(evt);
210            }
211        });
212        jToolBar1.add(jButton5);
213
214        jSeparator1.setName("jSeparator1"); // NOI18N
215        jToolBar1.add(jSeparator1);
216
217        jButton4.setText(bundle.getString("RemindPanel.jButton4.text")); // NOI18N
218        jButton4.setName("jButton4"); // NOI18N
219        jButton4.addActionListener(new java.awt.event.ActionListener() {
220            public void actionPerformed(java.awt.event.ActionEvent evt) {
221                jButton4ActionPerformed(evt);
222            }
223        });
224        jToolBar1.add(jButton4);
225
226        jButton6.setText(bundle.getString("RemindPanel.jButton6.text")); // NOI18N
227        jButton6.setName("jButton6"); // NOI18N
228        jButton6.addActionListener(new java.awt.event.ActionListener() {
229            public void actionPerformed(java.awt.event.ActionEvent evt) {
230                jButton6ActionPerformed(evt);
231            }
232        });
233        jToolBar1.add(jButton6);
234
235        jSeparator3.setName("jSeparator3"); // NOI18N
236        jToolBar1.add(jSeparator3);
237
238        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/22/view_text.png"))); // NOI18N
239        jButton3.setText(bundle.getString("RemindPanel.jButton3.text")); // NOI18N
240        jButton3.setFocusable(false);
241        jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
242        jButton3.setName("jButton3"); // NOI18N
243        jButton3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
244        jButton3.addActionListener(new java.awt.event.ActionListener() {
245            public void actionPerformed(java.awt.event.ActionEvent evt) {
246                jButton3ActionPerformed(evt);
247            }
248        });
249        jToolBar1.add(jButton3);
250
251        jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/22/mimetypes/pdf.png"))); // NOI18N
252        jButton7.setText(bundle.getString("RemindPanel.jButton7.text")); // NOI18N
253        jButton7.setFocusable(false);
254        jButton7.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
255        jButton7.setName("jButton7"); // NOI18N
256        jButton7.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
257        jButton7.addActionListener(new java.awt.event.ActionListener() {
258            public void actionPerformed(java.awt.event.ActionEvent evt) {
259                jButton7ActionPerformed(evt);
260            }
261        });
262        jToolBar1.add(jButton7);
263
264        jButton8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/22/mimetypes/odt.png"))); // NOI18N
265        jButton8.setText(bundle.getString("RemindPanel.jButton8.text")); // NOI18N
266        jButton8.setFocusable(false);
267        jButton8.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
268        jButton8.setName("jButton8"); // NOI18N
269        jButton8.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
270        jButton8.addActionListener(new java.awt.event.ActionListener() {
271            public void actionPerformed(java.awt.event.ActionEvent evt) {
272                jButton8ActionPerformed(evt);
273            }
274        });
275        jToolBar1.add(jButton8);
276
277        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
278        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("RemindPanel.jPanel1.border.title"))); // NOI18N
279        jPanel1.setName("jPanel1"); // NOI18N
280
281        labeledCombobox1.set_Label(bundle.getString("RemindPanel.labeledCombobox1._Label")); // NOI18N
282        labeledCombobox1.setName("labeledCombobox1"); // NOI18N
283
284        labeledCombobox3.set_Label(bundle.getString("RemindPanel.labeledCombobox3._Label")); // NOI18N
285        labeledCombobox3.setName("labeledCombobox3"); // NOI18N
286
287        jScrollPane1.setName("jScrollPane1"); // NOI18N
288
289        jTextPane1.setName("jTextPane1"); // NOI18N
290        jScrollPane1.setViewportView(jTextPane1);
291
292        labeledTextField1.set_Label(bundle.getString("RemindPanel.labeledTextField1._Label")); // NOI18N
293        labeledTextField1.setName("labeledTextField1"); // NOI18N
294
295        labeledCombobox2.set_Label(bundle.getString("RemindPanel.labeledCombobox2._Label")); // NOI18N
296        labeledCombobox2.setName("labeledCombobox2"); // NOI18N
297
298        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
299        jPanel1.setLayout(jPanel1Layout);
300        jPanel1Layout.setHorizontalGroup(
301            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
302            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
303                .addContainerGap()
304                .addComponent(labeledTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
305            .addGroup(jPanel1Layout.createSequentialGroup()
306                .addGap(2, 2, 2)
307                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
308                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 554, Short.MAX_VALUE)
309                    .addGroup(jPanel1Layout.createSequentialGroup()
310                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
311                            .addComponent(labeledCombobox3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
312                            .addComponent(labeledCombobox1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE))
313                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
314                        .addComponent(labeledCombobox2, javax.swing.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE))))
315        );
316        jPanel1Layout.setVerticalGroup(
317            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
318            .addGroup(jPanel1Layout.createSequentialGroup()
319                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
320                    .addGroup(jPanel1Layout.createSequentialGroup()
321                        .addComponent(labeledCombobox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
322                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
323                        .addComponent(labeledCombobox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
324                    .addComponent(labeledCombobox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
325                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
326                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 138, Short.MAX_VALUE)
327                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
328                .addComponent(labeledTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
329        );
330
331        jLabel1.setText(bundle.getString("RemindPanel.jLabel1.text")); // NOI18N
332        jLabel1.setName("jLabel1"); // NOI18N
333
334        jScrollPane2.setName("jScrollPane2"); // NOI18N
335
336        jList1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
337        jList1.setName("jList1"); // NOI18N
338        jList1.addMouseListener(new java.awt.event.MouseAdapter() {
339            public void mouseClicked(java.awt.event.MouseEvent evt) {
340                jList1MouseClicked(evt);
341            }
342        });
343        jScrollPane2.setViewportView(jList1);
344
345        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
346        this.setLayout(layout);
347        layout.setHorizontalGroup(
348            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
349            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE)
350            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE)
351            .addGroup(layout.createSequentialGroup()
352                .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 558, Short.MAX_VALUE)
353                .addContainerGap())
354            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
355        );
356        layout.setVerticalGroup(
357            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
358            .addGroup(layout.createSequentialGroup()
359                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
360                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
361                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
362                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
363                .addComponent(jLabel1)
364                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
365                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE))
366        );
367    }// </editor-fold>//GEN-END:initComponents
368
369    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
370        if (dataOwner == null) {
371            dataOwner = new Reminder();
372
373        }
374        dataOwner.setIDS(-1);
375        save();
376    }//GEN-LAST:event_jButton2ActionPerformed
377
378    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
379        dataOwner.delete();
380        try {
381            refresh((Item) Item.getObject(Context.getItem(), dataOwner.__getItemsids()));
382        } catch (NodataFoundException ex) {
383            refresh(null);
384        }
385    }//GEN-LAST:event_jButton5ActionPerformed
386
387    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
388        String msg = Popup.Enter_Value(Messages.ENTER_A_DESCRIPTION);
389        if (msg != null) {
390            Stage s = new Stage();
391            s.setCname(msg);
392            s.setGroupsids(mpv5.db.objects.User.getCurrentUser().__getGroupsids());
393            s.setDescription(jTextPane1.getText());
394            try {
395                s.setExtravalue(Double.valueOf(labeledTextField1.getText()));
396            } catch (NumberFormatException e) {
397                s.setExtravalue(0d);
398            }
399            s.save();
400            labeledCombobox3.triggerSearch();
401        }
402    }//GEN-LAST:event_jButton4ActionPerformed
403
404    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
405        try {
406            Stage s = (Stage) DatabaseObject.getObject(Context.getStage(), Integer.valueOf(labeledCombobox3.getSelectedItem().getId()));
407            s.delete();
408            labeledCombobox3.triggerSearch();
409        } catch (NodataFoundException ex) {
410            Log.Debug(this, ex.getMessage());
411        }
412
413    }//GEN-LAST:event_jButton6ActionPerformed
414
415    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
416
417        int group = 1;
418
419        PreviewPanel pr;
420        if (dataOwner != null && dataOwner.isExisting()) {
421
422            if (labeledCombobox2.getSelectedItem() != null) {
423                group = Integer.valueOf(labeledCombobox2.getSelectedItem().getId());
424            }
425
426            Template t = TemplateHandler.loadTemplate(group, Constants.TYPE_REMINDER);
427            if (t != null) {
428                Exportable te = TemplateHandler.loadTemplate(group, Constants.TYPE_REMINDER).getExFile();
429                HashMap<String, Object> hm1 = new FormFieldsHandler(dataOwner).getFormattedFormFields(null);
430                File f2 = FileDirectoryHandler.getTempFile("pdf");
431                Export ex = new Export(t);
432                ex.putAll(hm1);
433                ex.setTemplate(te);
434                ex.setTargetFile(f2);
435                try {
436                    Stage g = (Stage) DatabaseObject.getObject(Context.getStage(), dataOwner.__getStagesids());
437                    ex.put("reminder.stage", g.__getCname());
438                } catch (NodataFoundException ex1) {
439                    Log.Debug(ex1);
440                }
441                try {
442                    Item i = (Item) DatabaseObject.getObject(Context.getItem(), dataOwner.__getItemsids());
443                    ex.put("reminder.count", Reminder.getRemindersOf(i).size());
444                } catch (NodataFoundException nodataFoundException) {
445                    Log.Debug(nodataFoundException);
446                }
447
448                pr = new PreviewPanel();
449                pr.setDataOwner(dataOwner);
450                new Job(ex, pr).execute();
451            } else {
452                Popup.notice(Messages.NO_TEMPLATE_DEFINDED);
453            }
454        }
455    }//GEN-LAST:event_jButton3ActionPerformed
456
457    private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked
458        try {
459            expose((Reminder) jList1.getSelectedValue());
460        } catch (Exception e) {
461        }
462    }//GEN-LAST:event_jList1MouseClicked
463
464    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
465
466        save();
467    }//GEN-LAST:event_jButton1ActionPerformed
468
469    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
470        int group = 1;
471
472        if (dataOwner != null && dataOwner.isExisting()) {
473
474            if (labeledCombobox2.getSelectedItem() != null) {
475                group = Integer.valueOf(labeledCombobox2.getSelectedItem().getId());
476            }
477
478            Template t = TemplateHandler.loadTemplate(group, Constants.TYPE_REMINDER);
479            if (t != null) {
480                Exportable te = TemplateHandler.loadTemplate(group, Constants.TYPE_REMINDER).getExFile();
481                HashMap<String, Object> hm1 = new HashMap<String, Object>();
482                File f2 = FileDirectoryHandler.getTempFile("pdf");
483
484                try {
485                    Stage g = (Stage) DatabaseObject.getObject(Context.getStage(), dataOwner.__getStagesids());
486                    hm1.put("reminder.stage", g.__getCname());
487                } catch (NodataFoundException ex1) {
488                    Log.Debug(ex1);
489                }
490                try {
491                    Item i = (Item) DatabaseObject.getObject(Context.getItem(), dataOwner.__getItemsids());
492                    hm1.put("reminder.count", Reminder.getRemindersOf(i).size());
493                } catch (NodataFoundException nodataFoundException) {
494                    Log.Debug(nodataFoundException);
495                }
496
497                new Job(Export.createFile(dataOwner.__getCname(), t, dataOwner, hm1), new DialogForFile(DialogForFile.FILES_ONLY, dataOwner.__getCname())).execute();
498            } else {
499                Popup.notice(Messages.NO_TEMPLATE_DEFINDED);
500            }
501        }
502    }//GEN-LAST:event_jButton7ActionPerformed
503
504    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
505
506        int group = 1;
507
508        PreviewPanel pr;
509        if (dataOwner != null && dataOwner.isExisting()) {
510
511            if (labeledCombobox2.getSelectedItem() != null) {
512                group = Integer.valueOf(labeledCombobox2.getSelectedItem().getId());
513            }
514
515            Template t = TemplateHandler.loadTemplate(group, Constants.TYPE_REMINDER);
516            if (t != null) {
517                Exportable te = TemplateHandler.loadTemplate(group, Constants.TYPE_REMINDER).getExFile();
518                HashMap<String, Object> hm1 = new HashMap<String, Object>();
519                File f2 = FileDirectoryHandler.getTempFile("odt");
520
521                try {
522                    Stage g = (Stage) DatabaseObject.getObject(Context.getStage(), dataOwner.__getStagesids());
523                    hm1.put("reminder.stage", g.__getCname());
524                } catch (NodataFoundException ex1) {
525                    Log.Debug(ex1);
526                }
527                try {
528                    Item i = (Item) DatabaseObject.getObject(Context.getItem(), dataOwner.__getItemsids());
529                    hm1.put("reminder.count", Reminder.getRemindersOf(i).size());
530                } catch (NodataFoundException nodataFoundException) {
531                    Log.Debug(nodataFoundException);
532                }
533
534                new Job(Export.sourceFile(dataOwner.__getCname(), t, dataOwner, hm1), new DialogForFile(DialogForFile.FILES_ONLY, dataOwner.__getCname())).execute();
535            } else {
536                Popup.notice(Messages.NO_TEMPLATE_DEFINDED);
537            }
538        }
539    }//GEN-LAST:event_jButton8ActionPerformed
540    // Variables declaration - do not modify//GEN-BEGIN:variables
541    private javax.swing.JButton jButton1;
542    private javax.swing.JButton jButton2;
543    private javax.swing.JButton jButton3;
544    private javax.swing.JButton jButton4;
545    private javax.swing.JButton jButton5;
546    private javax.swing.JButton jButton6;
547    private javax.swing.JButton jButton7;
548    private javax.swing.JButton jButton8;
549    private javax.swing.JLabel jLabel1;
550    private javax.swing.JList jList1;
551    private javax.swing.JPanel jPanel1;
552    private javax.swing.JScrollPane jScrollPane1;
553    private javax.swing.JScrollPane jScrollPane2;
554    private javax.swing.JToolBar.Separator jSeparator1;
555    private javax.swing.JToolBar.Separator jSeparator3;
556    private javax.swing.JTextPane jTextPane1;
557    private javax.swing.JToolBar jToolBar1;
558    private mpv5.ui.beans.LabeledCombobox labeledCombobox1;
559    private mpv5.ui.beans.LabeledCombobox labeledCombobox2;
560    private mpv5.ui.beans.LabeledCombobox labeledCombobox3;
561    private mpv5.ui.beans.LabeledTextField labeledTextField1;
562    // End of variables declaration//GEN-END:variables
563
564    private void save() {
565        try {
566            Item i = (Item) DatabaseObject.getObject(Context.getItem(), Integer.valueOf(labeledCombobox1.getSelectedItem().getId()));
567            Stage s = null;
568            try {
569                s = (Stage) DatabaseObject.getObject(Context.getStage(), Integer.valueOf(labeledCombobox3.getSelectedItem().getId()));
570            } catch (Exception nodataFoundException) {
571                String msg = Popup.Enter_Value(Messages.ENTER_A_DESCRIPTION);
572                if (msg == null) {
573                    msg = "autogenerated stage";
574                }
575                s = new Stage();
576                s.setCname(msg);
577                s.setGroupsids(mpv5.db.objects.User.getCurrentUser().__getGroupsids());
578                s.setTemplategroup(mpv5.db.objects.User.getCurrentUser().__getGroupsids());
579                s.setDescription(jTextPane1.getText());
580                try {
581                    s.setExtravalue(labeledTextField1.getValue(0d));
582                } catch (NumberFormatException numberFormatException) {
583                    s.setExtravalue(0d);
584                }
585                s.save();
586                labeledCombobox3.triggerSearch();
587
588            }
589            dataOwner.setDescription(jTextPane1.getText());
590            try {
591                dataOwner.setExtravalue(Double.valueOf(labeledTextField1.getText()));
592            } catch (NumberFormatException numberFormatException) {
593                dataOwner.setExtravalue(0d);
594            }
595            dataOwner.setItemsids(i.__getIDS());
596            dataOwner.setStagesids(s.__getIDS());
597            dataOwner.setCname(s + "@" + i);
598            dataOwner.save();
599            refresh(i);
600        } catch (Exception ex) {
601            Log.Debug(this, ex);
602        }
603    }
604
605    private void refresh(Item bill) {
606        if (bill != null) {
607            DefaultListModel d = new DefaultListModel();
608            List<Reminder> data = Reminder.getRemindersOf(bill);
609            for (int i = 0; i < data.size(); i++) {
610                Reminder reminder = data.get(i);
611                d.addElement(reminder);
612            }
613            jList1.setModel(d);
614        } else {
615            jList1.setModel(new DefaultListModel());
616        }
617    }
618
619    private void expose(Reminder r) {
620        dataOwner = r;
621        try {
622            labeledCombobox1.setModel(Item.getObject(Context.getItem(), r.__getItemsids()));
623
624        } catch (NodataFoundException ex) {
625        }
626        try {
627            labeledCombobox2.setModel(Item.getObject(Context.getGroup(), r.__getGroupsids()));
628        } catch (NodataFoundException ex) {
629        }
630
631
632        labeledTextField1.setText(r.__getExtravalue());
633        jTextPane1.setText(r.__getDescription());
634    }
635}