PageRenderTime 392ms CodeModel.GetById 120ms app.highlight 190ms RepoModel.GetById 72ms app.codeStats 1ms

/src/mpv5/ui/dialogs/ScheduleEvents.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 840 lines | 748 code | 68 blank | 24 comment | 46 complexity | d06ce256644a3b920ac4dd4e22ff72e0 MD5 | raw file
  1/*
  2 * To change this template, choose Tools | Templates
  3 * and open the template in the editor.
  4 */
  5
  6/*
  7 * SplashScreen.java
  8 *
  9 * Created on 30.03.2009, 21:55:52
 10 */
 11package mpv5.ui.dialogs;
 12
 13import java.awt.Component;
 14import java.awt.event.ActionEvent;
 15import java.awt.event.ActionListener;
 16import java.util.ArrayList;
 17import java.util.Calendar;
 18import java.util.Date;
 19
 20import javax.swing.JComboBox;
 21import mpv5.db.common.Context;
 22import mpv5.db.common.DatabaseObject;
 23import mpv5.db.common.DatabaseSearch;
 24import mpv5.db.common.NodataFoundException;
 25import mpv5.db.common.QueryCriteria;
 26import mpv5.db.objects.Contact;
 27import mpv5.db.objects.Item;
 28import mpv5.db.objects.Schedule;
 29import mpv5.db.objects.ScheduleTypes;
 30import mpv5.db.objects.User;
 31import mpv5.globals.Headers;
 32import mpv5.globals.Messages;
 33import mpv5.logging.Log;
 34import mpv5.ui.misc.Position;
 35import mpv5.ui.panels.HomeScreen;
 36import mpv5.ui.panels.calendar.ScheduleCalendarDayChooser;
 37import mpv5.utils.date.DateConverter;
 38import mpv5.utils.models.MPComboBoxModelItem;
 39import mpv5.utils.models.MPComboboxModel;
 40import mpv5.utils.models.MPTableModel;
 41import mpv5.utils.tables.TableFormat;
 42
 43/**
 44 *
 45 *  
 46 */
 47public class ScheduleEvents extends javax.swing.JFrame {
 48
 49    private static final long serialVersionUID = 1L;
 50    private static ScheduleEvents icke;
 51    private Schedule dataOwner;
 52
 53    public static ScheduleEvents instanceOf() {
 54        if (icke == null) {
 55            icke = new ScheduleEvents();
 56        }
 57        icke.setVisible(true);
 58        icke.clearViews();
 59        Log.Debug(ScheduleEvents.class, "Anzeige erfolgt ...");
 60        return icke;
 61    }
 62
 63    private ScheduleEvents() {
 64        initComponents();
 65        labeledCombobox1.setSearchEnabled(true);
 66        labeledCombobox1.setContext(Context.getInvoice());
 67        labeledCombobox1.getComboBox().addActionListener(new ActionListener() {
 68
 69            public void actionPerformed(ActionEvent e) {
 70                JComboBox cb = (JComboBox) e.getSource();
 71                Integer id;
 72                try {
 73                    if (Integer.valueOf(cb.getSelectedIndex()) >= 0) {
 74                        Log.Debug(this, "Item-ID: " + Integer.valueOf(labeledCombobox1.getSelectedItem().getId()));
 75                        Item i = (Item) DatabaseObject.getObject(Context.getItem(),
 76                                Integer.valueOf(labeledCombobox1.getSelectedItem().getId()));
 77                        icke.refreshFromItem(i);
 78                    }
 79                } catch (NodataFoundException ex) {
 80                    Log.Debug(this, ex);
 81                }
 82            }
 83        });
 84        initSchedTyps();
 85        labeledCombobox3.setSearchEnabled(true);
 86        labeledCombobox3.setContext(Context.getContact());
 87        labeledCombobox3.getComboBox().addActionListener(new ActionListener() {
 88
 89            public void actionPerformed(ActionEvent e) {
 90                JComboBox cb = (JComboBox) e.getSource();
 91                String s;
 92                Integer id;
 93                try {
 94                    if (Integer.valueOf(cb.getSelectedIndex()) >= 0) {
 95                        id = Integer.valueOf(labeledCombobox3.getSelectedItem().getId());
 96                        Log.Debug(this, "Contact-ID: " + id);
 97                        Contact c = (Contact) DatabaseObject.getObject(Context.getContact(),
 98                                id);
 99                        icke.refreshFromContact(c);
100                        Context i = Context.getItem();
101                        s = Context.DEFAULT_ITEM_SEARCH + ", inttype";
102                        Object[][] data = new DatabaseSearch(i).getValuesFor(s, "contactsids", c.__getIDS());
103                        Log.Debug(this, "gefundene Items: " + data.length);
104                        MPComboBoxModelItem[] items = new MPComboBoxModelItem[data.length];
105                        for (int a = 0; a < data.length; a++) {
106                            items[a] = new MPComboBoxModelItem(data[a][0],
107                                    Item.getTypeString((Integer) data[a][4]) + ": " + data[a][1]);
108                        }
109                        labeledCombobox4.setModel(new MPComboboxModel(items));
110                    }
111                } catch (NodataFoundException ex) {
112                    Log.Debug(this, ex);
113                }
114            }
115        });
116        labeledCombobox4.setSearchEnabled(false);
117        setAlwaysOnTop(true);
118        new Position(this);
119    }
120
121    @Override
122    public void dispose() {
123        setVisible(false);
124    }
125
126    public void setDate(Date tday) {
127        labeledDateChooser1.setDate(DateConverter.addDays(tday, 0));
128        labeledDateChooser2.setDate(DateConverter.addYear(tday));
129        labeledDateChooser3.getDateChooser().setDate(tday);
130    }
131
132    /** This method is called from within the constructor to
133     * initialize the form.
134     * WARNING: Do NOT modify this code. The content of this method is
135     * always regenerated by the Form Editor.
136     */
137    @SuppressWarnings("unchecked")
138    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
139    private void initComponents() {
140
141        jPanel1 = new javax.swing.JPanel();
142        jPanel2 = new javax.swing.JPanel();
143        jSeparator1 = new javax.swing.JSeparator();
144        but4 = new javax.swing.JButton();
145        jSeparator3 = new javax.swing.JSeparator();
146        jSeparator2 = new javax.swing.JSeparator();
147        but6 = new javax.swing.JButton();
148        but5 = new javax.swing.JButton();
149        but7 = new javax.swing.JButton();
150        but8 = new javax.swing.JButton();
151        jTabbedPane1 = new javax.swing.JTabbedPane();
152        jPanel3 = new javax.swing.JPanel();
153        jScrollPane1 = new javax.swing.JScrollPane();
154        jTable1 = new javax.swing.JTable();
155        jLabel3 = new javax.swing.JLabel();
156        labeledDateChooser2 = new mpv5.ui.beans.LabeledDateChooser();
157        labeledDateChooser1 = new mpv5.ui.beans.LabeledDateChooser();
158        labeledSpinner1 = new mpv5.ui.beans.LabeledSpinner();
159        jLabel1 = new javax.swing.JLabel();
160        labeledCombobox1 = new mpv5.ui.beans.LabeledCombobox();
161        jButton5 = new javax.swing.JButton();
162        jPanel4 = new javax.swing.JPanel();
163        labeledDateChooser3 = new mpv5.ui.beans.LabeledDateChooser();
164        jLabel4 = new javax.swing.JLabel();
165        jScrollPane2 = new javax.swing.JScrollPane();
166        jTable2 = new javax.swing.JTable();
167        labeledCombobox2 = new mpv5.ui.beans.LabeledCombobox();
168        labeledCombobox3 = new mpv5.ui.beans.LabeledCombobox();
169        labeledCombobox4 = new mpv5.ui.beans.LabeledCombobox();
170
171        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
172        java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle(); // NOI18N // NOI18N
173        setTitle(bundle.getString("ScheduleEvents.title")); // NOI18N
174        setAlwaysOnTop(true);
175        setName("Form"); // NOI18N
176
177        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("ScheduleEvents.jPanel1.border.title"))); // NOI18N
178        jPanel1.setName("jPanel1"); // NOI18N
179
180        jPanel2.setName("jPanel2"); // NOI18N
181
182        jSeparator1.setName("jSeparator1"); // NOI18N
183
184        but4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/save_all.png"))); // NOI18N
185        but4.setText(bundle.getString("ScheduleEvents.but4.text")); // NOI18N
186        but4.setToolTipText(bundle.getString("ScheduleEvents.but4.toolTipText")); // NOI18N
187        but4.setContentAreaFilled(false);
188        but4.setFocusable(false);
189        but4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
190        but4.setName("but4"); // NOI18N
191        but4.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
192        but4.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/save_all.png"))); // NOI18N
193        but4.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
194        but4.addActionListener(new java.awt.event.ActionListener() {
195            public void actionPerformed(java.awt.event.ActionEvent evt) {
196                but4ActionPerformed(evt);
197            }
198        });
199
200        jSeparator3.setName("jSeparator3"); // NOI18N
201
202        jSeparator2.setName("jSeparator2"); // NOI18N
203
204        but6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/kate.png"))); // NOI18N
205        but6.setText(bundle.getString("ScheduleEvents.but6.text")); // NOI18N
206        but6.setToolTipText(bundle.getString("ScheduleEvents.but6.toolTipText")); // NOI18N
207        but6.setContentAreaFilled(false);
208        but6.setFocusable(false);
209        but6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
210        but6.setName("but6"); // NOI18N
211        but6.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
212        but6.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/kate.png"))); // NOI18N
213        but6.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
214        but6.addActionListener(new java.awt.event.ActionListener() {
215            public void actionPerformed(java.awt.event.ActionEvent evt) {
216                but6ActionPerformed(evt);
217            }
218        });
219
220        but5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/edittrash.png"))); // NOI18N
221        but5.setText(bundle.getString("ScheduleEvents.but5.text")); // NOI18N
222        but5.setToolTipText(bundle.getString("ScheduleEvents.but5.toolTipText")); // NOI18N
223        but5.setContentAreaFilled(false);
224        but5.setFocusable(false);
225        but5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
226        but5.setName("but5"); // NOI18N
227        but5.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
228        but5.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_edittrash.png"))); // NOI18N
229        but5.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
230        but5.addActionListener(new java.awt.event.ActionListener() {
231            public void actionPerformed(java.awt.event.ActionEvent evt) {
232                but5ActionPerformed(evt);
233            }
234        });
235
236        but7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/All software is current.png"))); // NOI18N
237        but7.setText(bundle.getString("ScheduleEvents.but7.text")); // NOI18N
238        but7.setToolTipText(bundle.getString("ScheduleEvents.but7.toolTipText")); // NOI18N
239        but7.setContentAreaFilled(false);
240        but7.setFocusable(false);
241        but7.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
242        but7.setName("but7"); // NOI18N
243        but7.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
244        but7.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/All software is current.png"))); // NOI18N
245        but7.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
246        but7.addActionListener(new java.awt.event.ActionListener() {
247            public void actionPerformed(java.awt.event.ActionEvent evt) {
248                but7ActionPerformed(evt);
249            }
250        });
251
252        but8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/tab_remove.png"))); // NOI18N
253        but8.setText(bundle.getString("ScheduleEvents.but8.text")); // NOI18N
254        but8.setToolTipText(bundle.getString("ScheduleEvents.but8.toolTipText")); // NOI18N
255        but8.setContentAreaFilled(false);
256        but8.setFocusable(false);
257        but8.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
258        but8.setName("but8"); // NOI18N
259        but8.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
260        but8.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/tab_remove.png"))); // NOI18N
261        but8.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
262        but8.addActionListener(new java.awt.event.ActionListener() {
263            public void actionPerformed(java.awt.event.ActionEvent evt) {
264                but8ActionPerformed(evt);
265            }
266        });
267
268        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
269        jPanel2.setLayout(jPanel2Layout);
270        jPanel2Layout.setHorizontalGroup(
271            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
272            .addGroup(jPanel2Layout.createSequentialGroup()
273                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
274                    .addGroup(jPanel2Layout.createSequentialGroup()
275                        .addGap(50, 50, 50)
276                        .addComponent(but6))
277                    .addGroup(jPanel2Layout.createSequentialGroup()
278                        .addGap(143, 143, 143)
279                        .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
280                    .addGroup(jPanel2Layout.createSequentialGroup()
281                        .addGap(138, 138, 138)
282                        .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
283                    .addGroup(jPanel2Layout.createSequentialGroup()
284                        .addGap(110, 110, 110)
285                        .addComponent(but5))
286                    .addComponent(but4)
287                    .addGroup(jPanel2Layout.createSequentialGroup()
288                        .addGap(63, 63, 63)
289                        .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
290                .addGap(105, 105, 105)
291                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
292                    .addComponent(but8)
293                    .addGroup(jPanel2Layout.createSequentialGroup()
294                        .addGap(60, 60, 60)
295                        .addComponent(but7))))
296        );
297        jPanel2Layout.setVerticalGroup(
298            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
299            .addComponent(but6, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
300            .addGroup(jPanel2Layout.createSequentialGroup()
301                .addGap(24, 24, 24)
302                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
303            .addGroup(jPanel2Layout.createSequentialGroup()
304                .addGap(24, 24, 24)
305                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
306            .addComponent(but5, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
307            .addGroup(jPanel2Layout.createSequentialGroup()
308                .addGap(3, 3, 3)
309                .addComponent(but4, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
310            .addGroup(jPanel2Layout.createSequentialGroup()
311                .addGap(24, 24, 24)
312                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
313            .addComponent(but8, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
314            .addComponent(but7)
315        );
316
317        jTabbedPane1.setTabPlacement(javax.swing.JTabbedPane.BOTTOM);
318        jTabbedPane1.setName("jTabbedPane1"); // NOI18N
319
320        jPanel3.setName("jPanel3"); // NOI18N
321
322        jScrollPane1.setName("jScrollPane1"); // NOI18N
323
324        jTable1.setModel(new javax.swing.table.DefaultTableModel(
325            new Object [][] {
326                {},
327                {},
328                {},
329                {}
330            },
331            new String [] {
332
333            }
334        ));
335        jTable1.setName("jTable1"); // NOI18N
336        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
337            public void mouseClicked(java.awt.event.MouseEvent evt) {
338                jTable1MouseClicked(evt);
339            }
340        });
341        jScrollPane1.setViewportView(jTable1);
342
343        jLabel3.setText(bundle.getString("ScheduleEvents.jLabel3.text")); // NOI18N
344        jLabel3.setName("jLabel3"); // NOI18N
345
346        labeledDateChooser2.set_Label(bundle.getString("ScheduleEvents.labeledDateChooser2._Label")); // NOI18N
347        labeledDateChooser2.setName("labeledDateChooser2"); // NOI18N
348
349        labeledDateChooser1.setToolTipText(bundle.getString("ScheduleEvents.labeledDateChooser1.toolTipText")); // NOI18N
350        labeledDateChooser1.set_Label(bundle.getString("ScheduleEvents.labeledDateChooser1._Label")); // NOI18N
351        labeledDateChooser1.setName("labeledDateChooser1"); // NOI18N
352
353        labeledSpinner1.set_Label(bundle.getString("ScheduleEvents.labeledSpinner1._Label")); // NOI18N
354        labeledSpinner1.setName("labeledSpinner1"); // NOI18N
355
356        jLabel1.setText(bundle.getString("ScheduleEvents.jLabel1.text")); // NOI18N
357        jLabel1.setName("jLabel1"); // NOI18N
358
359        labeledCombobox1.set_Label(bundle.getString("ScheduleEvents.labeledCombobox1._Label")); // NOI18N
360        labeledCombobox1.setName("labeledCombobox1"); // NOI18N
361
362        jButton5.setText(bundle.getString("ScheduleEvents.jButton5.text")); // NOI18N
363        jButton5.setName("jButton5"); // NOI18N
364        jButton5.addActionListener(new java.awt.event.ActionListener() {
365            public void actionPerformed(java.awt.event.ActionEvent evt) {
366                jButton5ActionPerformed(evt);
367            }
368        });
369
370        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
371        jPanel3.setLayout(jPanel3Layout);
372        jPanel3Layout.setHorizontalGroup(
373            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
374            .addGroup(jPanel3Layout.createSequentialGroup()
375                .addContainerGap()
376                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
377                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 449, Short.MAX_VALUE)
378                    .addComponent(labeledCombobox1, javax.swing.GroupLayout.DEFAULT_SIZE, 449, Short.MAX_VALUE)
379                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
380                    .addGroup(jPanel3Layout.createSequentialGroup()
381                        .addComponent(labeledSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
382                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
383                        .addComponent(jLabel1)
384                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 156, Short.MAX_VALUE)
385                        .addComponent(jButton5))
386                    .addComponent(labeledDateChooser1, javax.swing.GroupLayout.DEFAULT_SIZE, 449, Short.MAX_VALUE)
387                    .addComponent(labeledDateChooser2, javax.swing.GroupLayout.DEFAULT_SIZE, 449, Short.MAX_VALUE))
388                .addContainerGap())
389        );
390        jPanel3Layout.setVerticalGroup(
391            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
392            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
393                .addContainerGap()
394                .addComponent(labeledCombobox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
395                .addGap(14, 14, 14)
396                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
397                    .addComponent(labeledSpinner1, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)
398                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
399                        .addComponent(jButton5)
400                        .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)))
401                .addGap(18, 18, 18)
402                .addComponent(labeledDateChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
403                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
404                .addComponent(labeledDateChooser2, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
405                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
406                .addComponent(jLabel3)
407                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
408                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 251, javax.swing.GroupLayout.PREFERRED_SIZE)
409                .addGap(52, 52, 52))
410        );
411
412        jTabbedPane1.addTab(bundle.getString("ScheduleEvents.jPanel3.TabConstraints.tabTitle"), jPanel3); // NOI18N
413
414        jPanel4.setName("jPanel4"); // NOI18N
415
416        labeledDateChooser3.set_Label(bundle.getString("ScheduleEvents.labeledDateChooser3._Label")); // NOI18N
417        labeledDateChooser3.setName("labeledDateChooser3"); // NOI18N
418
419        jLabel4.setText(bundle.getString("ScheduleEvents.jLabel4.text")); // NOI18N
420        jLabel4.setName("jLabel4"); // NOI18N
421
422        jScrollPane2.setName("jScrollPane2"); // NOI18N
423
424        jTable2.setModel(new javax.swing.table.DefaultTableModel(
425            new Object [][] {
426                {},
427                {},
428                {},
429                {}
430            },
431            new String [] {
432
433            }
434        ));
435        jTable2.setName("jTable2"); // NOI18N
436        jTable2.addMouseListener(new java.awt.event.MouseAdapter() {
437            public void mouseClicked(java.awt.event.MouseEvent evt) {
438                jTable2MouseClicked(evt);
439            }
440        });
441        jScrollPane2.setViewportView(jTable2);
442
443        labeledCombobox2.set_Label(bundle.getString("ScheduleEvents.labeledCombobox2._Label")); // NOI18N
444        labeledCombobox2.setName("labeledCombobox2"); // NOI18N
445
446        labeledCombobox3.set_Label(bundle.getString("ScheduleEvents.labeledCombobox3._Label")); // NOI18N
447        labeledCombobox3.setName("labeledCombobox3"); // NOI18N
448
449        labeledCombobox4.set_Label(bundle.getString("ScheduleEvents.labeledCombobox4._Label")); // NOI18N
450        labeledCombobox4.setName("labeledCombobox4"); // NOI18N
451
452        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
453        jPanel4.setLayout(jPanel4Layout);
454        jPanel4Layout.setHorizontalGroup(
455            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
456            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
457                .addContainerGap()
458                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
459                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 449, Short.MAX_VALUE)
460                    .addComponent(labeledDateChooser3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 449, Short.MAX_VALUE)
461                    .addComponent(labeledCombobox3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 449, Short.MAX_VALUE)
462                    .addComponent(labeledCombobox4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 449, Short.MAX_VALUE)
463                    .addComponent(labeledCombobox2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 449, Short.MAX_VALUE)
464                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE))
465                .addContainerGap())
466        );
467        jPanel4Layout.setVerticalGroup(
468            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
469            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
470                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
471                .addComponent(labeledCombobox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
472                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
473                .addComponent(labeledCombobox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
474                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
475                .addComponent(labeledDateChooser3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
476                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
477                .addComponent(labeledCombobox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
478                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
479                .addComponent(jLabel4)
480                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
481                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 318, javax.swing.GroupLayout.PREFERRED_SIZE)
482                .addGap(59, 59, 59))
483        );
484
485        jTabbedPane1.addTab(bundle.getString("ScheduleEvents.jPanel4.TabConstraints.tabTitle"), jPanel4); // NOI18N
486
487        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
488        jPanel1.setLayout(jPanel1Layout);
489        jPanel1Layout.setHorizontalGroup(
490            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
491            .addGroup(jPanel1Layout.createSequentialGroup()
492                .addContainerGap()
493                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
494                .addContainerGap())
495            .addGroup(jPanel1Layout.createSequentialGroup()
496                .addGap(34, 34, 34)
497                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 411, Short.MAX_VALUE)
498                .addGap(49, 49, 49))
499        );
500        jPanel1Layout.setVerticalGroup(
501            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
502            .addGroup(jPanel1Layout.createSequentialGroup()
503                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 505, javax.swing.GroupLayout.PREFERRED_SIZE)
504                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
505                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
506                .addContainerGap(45, Short.MAX_VALUE))
507        );
508
509        getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_START);
510
511        pack();
512    }// </editor-fold>//GEN-END:initComponents
513
514    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
515        try {
516            mpv5.YabsViewProxy.instance().getIdentifierView().addTab(DatabaseObject.getObject(Context.getItem(), Integer.valueOf(labeledCombobox1.getSelectedItem().getId())));
517        } catch (Exception ex) {
518            Log.Debug(this, ex.getMessage());
519        }
520    }//GEN-LAST:event_jButton5ActionPerformed
521
522    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
523        Log.Debug(this, "CYCLIC-Event geklicked...");
524        Schedule d = (Schedule) jTable1.getModel().getValueAt(jTable1.convertRowIndexToModel(jTable1.getSelectedRow()), 0);
525        Log.Debug(this, "CYCLIC-Event geklicked...0");
526        if (d != null) {
527            Log.Debug(this, "CYCLIC-Event geklicked...1");
528            try {
529                labeledCombobox1.setModel(d.getItem());
530                Log.Debug(this, "CYCLIC-Event geklicked...2");
531            } catch (NodataFoundException ex) {
532                Log.Debug(ex);
533            }
534            Log.Debug(this, "CYCLIC-Event geklicked...3");
535            labeledDateChooser1.setDate(d.__getStartdate());
536            Log.Debug(this, "CYCLIC-Event geklicked...4");
537            labeledDateChooser2.setDate(d.__getStopdate());
538            Log.Debug(this, "CYCLIC-Event geklicked...5");
539            labeledSpinner1.setValue(d.__getIntervalmonth());
540            Log.Debug(this, "CYCLIC-Event geklicked...6");
541            dataOwner = d;
542            but5.setEnabled(true);
543            but6.setEnabled(true);
544            Log.Debug(this, "CYCLIC-Event geklicked...fertig");
545        }
546    }//GEN-LAST:event_jTable1MouseClicked
547
548    private void jTable2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable2MouseClicked
549        Log.Debug(this, "Single-Event geklicked...");
550        Schedule d = (Schedule) jTable2.getModel().getValueAt(jTable2.convertRowIndexToModel(jTable2.getSelectedRow()), 0);
551        Log.Debug(this, "Single-Event geklicked...0");
552        if (d != null) {
553            Log.Debug(this, "Single-Event geklicked...1");
554            try {
555                labeledCombobox3.setModel(d.getContact());
556                Log.Debug(this, "Single-Event geklicked...2");
557            } catch (NodataFoundException ex) {
558                Log.Debug(ex);
559            }
560            Log.Debug(this, "Single-Event geklicked...3");
561            labeledCombobox2.setSelectedItem(d.__getEventtype());
562            Log.Debug(this, "Single-Event geklicked...4");
563            labeledDateChooser3.setDate(d.__getStartdate());
564            Log.Debug(this, "Single-Event geklicked...5");
565            dataOwner = d;
566            but5.setEnabled(true);
567            but6.setEnabled(true);
568            Log.Debug(this, "Single-Event geklicked...fertig");
569        }
570    }//GEN-LAST:event_jTable2MouseClicked
571
572    private void but6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but6ActionPerformed
573        Log.Debug(this, "ändern ... geklickt");
574        Calendar cal = Calendar.getInstance();
575        cal.setTime(dataOwner.__getStartdate());
576        Date oldDate = cal.getTime();
577        Log.Debug(this, "ändern ... 1");
578        save(dataOwner);
579        Log.Debug(this, "ändern ... 2");
580        try {
581            if (jTabbedPane1.getSelectedIndex() == 0) {
582                Log.Debug(this, "ändern ... 2a");
583                refreshFromItem(dataOwner.getItem());
584            } else if (jTabbedPane1.getSelectedIndex() == 1) {
585                Log.Debug(this, "ändern ... 2b");
586                refreshFromContact(dataOwner.getContact());
587                Log.Debug(this, "ändern ... 2b.");
588                ScheduleCalendarDayChooser.instanceOf().refreshDayPanels(oldDate,
589                        dataOwner, Boolean.FALSE);
590                Log.Debug(this, "ändern ... 2b..");
591                ScheduleCalendarDayChooser.instanceOf().refreshDayPanels(dataOwner.__getStartdate(),
592                        dataOwner, Boolean.TRUE);
593                Log.Debug(this, oldDate + " / " + dataOwner.__getStartdate());
594                Log.Debug(this, "ändern ... 2b...");
595            }
596        } catch (Exception ex) {
597            Log.Debug(this,
598                    ex);
599        }
600        Log.Debug(this, "ändern ... fertig");
601    }//GEN-LAST:event_but6ActionPerformed
602
603    private void but4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but4ActionPerformed
604        Log.Debug(this, "neu Anlage ... geklickt");
605        save(dataOwner = new Schedule());
606        Log.Debug(this, "neu Anlage ... 1");
607        if (dataOwner != null) {
608            try {
609                if (jTabbedPane1.getSelectedIndex() == 0) {
610                    Log.Debug(this, "neu Anlage ... 1a");
611                    refreshFromItem(dataOwner.getItem());
612                } else if (jTabbedPane1.getSelectedIndex() == 1) {
613                    Log.Debug(this, "neu Anlage ... 1b");
614                    refreshFromContact(dataOwner.getContact());
615                    ScheduleCalendarDayChooser.instanceOf().refreshDayPanels(dataOwner.__getStartdate(),
616                            dataOwner, Boolean.TRUE);
617                }
618                Log.Debug(this, "neu Anlage ... 2");
619            } catch (NodataFoundException ex) {
620                Log.Debug(this,
621                        ex);
622            }
623            Log.Debug(this, "neu Anlage ... 3");
624            ScheduleCalendarDayChooser.instanceOf();
625            Log.Debug(this, "neu Anlage ... fertig");
626        } else {
627            Popup.error(this, Messages.ENTER_VALUE.toString());
628        }
629    }//GEN-LAST:event_but4ActionPerformed
630
631    private void but5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but5ActionPerformed
632        Log.Debug(this, "löschen ... geklicked");
633        if (dataOwner != null && dataOwner.isExisting()) {
634            Log.Debug(this, "löschen ... 1");
635            dataOwner.delete();
636            Log.Debug(this, "löschen ... 2");
637            try {
638                if (jTabbedPane1.getSelectedIndex() == 0) {
639                    Log.Debug(this, "löschen ... 3a");
640                    refreshFromItem(dataOwner.getItem());
641                } else if (jTabbedPane1.getSelectedIndex() == 1) {
642                    Log.Debug(this, "löschen ... 3b");
643                    refreshFromContact(dataOwner.getContact());
644                    Log.Debug(this, "löschen ... 3b.");
645                    Calendar cal = Calendar.getInstance();
646                    cal.setTime(dataOwner.__getStartdate());
647                    Date oldDate = cal.getTime();
648                    ScheduleCalendarDayChooser.instanceOf().refreshDayPanels(oldDate,
649                            dataOwner, Boolean.FALSE);
650                }
651            } catch (NodataFoundException ex) {
652                Log.Debug(ex);
653            }
654        }
655        Log.Debug(this, "löschen ... fertig");
656    }//GEN-LAST:event_but5ActionPerformed
657
658    private void but7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but7ActionPerformed
659        this.setVisible(false);
660        HomeScreen.getInstance();
661    }//GEN-LAST:event_but7ActionPerformed
662
663    private void but8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but8ActionPerformed
664        but5.setEnabled(false);
665        but6.setEnabled(false);
666        clearViews();
667    }//GEN-LAST:event_but8ActionPerformed
668    // Variables declaration - do not modify//GEN-BEGIN:variables
669    private javax.swing.JButton but4;
670    private javax.swing.JButton but5;
671    private javax.swing.JButton but6;
672    private javax.swing.JButton but7;
673    private javax.swing.JButton but8;
674    private javax.swing.JButton jButton5;
675    private javax.swing.JLabel jLabel1;
676    private javax.swing.JLabel jLabel3;
677    private javax.swing.JLabel jLabel4;
678    private javax.swing.JPanel jPanel1;
679    private javax.swing.JPanel jPanel2;
680    private javax.swing.JPanel jPanel3;
681    private javax.swing.JPanel jPanel4;
682    private javax.swing.JScrollPane jScrollPane1;
683    private javax.swing.JScrollPane jScrollPane2;
684    private javax.swing.JSeparator jSeparator1;
685    private javax.swing.JSeparator jSeparator2;
686    private javax.swing.JSeparator jSeparator3;
687    private javax.swing.JTabbedPane jTabbedPane1;
688    private javax.swing.JTable jTable1;
689    private javax.swing.JTable jTable2;
690    private mpv5.ui.beans.LabeledCombobox labeledCombobox1;
691    private mpv5.ui.beans.LabeledCombobox labeledCombobox2;
692    private mpv5.ui.beans.LabeledCombobox labeledCombobox3;
693    private mpv5.ui.beans.LabeledCombobox labeledCombobox4;
694    private mpv5.ui.beans.LabeledDateChooser labeledDateChooser1;
695    private mpv5.ui.beans.LabeledDateChooser labeledDateChooser2;
696    private mpv5.ui.beans.LabeledDateChooser labeledDateChooser3;
697    private mpv5.ui.beans.LabeledSpinner labeledSpinner1;
698    // End of variables declaration//GEN-END:variables
699
700    private void refreshFromItem(Item dao) {
701        Log.Debug(this, "Anzeige der zyklischen Eventtabelle aktualisiert!");
702        ArrayList<Schedule> data = Schedule.getEvents2(dao);
703        Object[][] d = new Object[data.size()][];
704        for (int i = 0; i < data.size(); i++) {
705            Schedule schedule = data.get(i);
706            d[i] = schedule.toArray();
707        }
708        jTable1.setModel(new MPTableModel(d, Headers.SCHEDULE_LIST));
709        TableFormat.resizeCols(jTable1, new Integer[]{150}, false);
710    }
711
712    private void refreshFromContact(Contact dao) {
713        Log.Debug(this, "Anzeige der einmaligen Eventtabelle aktualisiert!");
714        ArrayList<Schedule> data = Schedule.getEvents2(dao);
715        Object[][] d = new Object[data.size()][4];
716        QueryCriteria qc;
717        for (int i = 0; i < data.size(); i++) {
718            try {
719                Schedule schedule = data.get(i);
720                d[i][0] = schedule;
721                d[i][1] = schedule.__getCname();
722                d[i][2] = schedule.__getStartdate();
723                qc = new QueryCriteria("USERSIDS", User.getCurrentUser().getID());
724                qc.addAndCondition("IDS", schedule.__getEventtype());
725                Log.Debug(this, "Eventtype: " + schedule.__getEventtype());
726                ArrayList<DatabaseObject> SType = DatabaseObject.getObjects(Context.getScheduleTypes(),
727                        qc);
728                d[i][3] = SType.get(0).__getCname();
729            } catch (NodataFoundException ex) {
730                Log.Debug(this, ex);
731            }
732        }
733        jTable2.setModel(new MPTableModel(d, Headers.SCHEDULE_PANEL));
734        TableFormat.stripColumn(jTable2, 0);
735        TableFormat.resizeCols(jTable2, new Integer[]{150}, false);
736    }
737
738    private void save(Schedule s) {
739        Component tmp;
740        if (s != null) {
741            try {
742                if (jTabbedPane1.getSelectedIndex() == 0) {
743
744                    Item i = (Item) DatabaseObject.getObject(Context.getItem(),
745                            Integer.valueOf(labeledCombobox1.getSelectedItem().getId()));
746                    s.setCname("(" + Messages.SCHEDULE + ") " + i.toString());
747                    s.setItemsids(i.__getIDS());
748                    s.setContactsids(i.__getContactsids());
749                    s.setEventtype(0);
750                    s.setGroupsids(i.__getGroupsids());
751                    s.setIntervalmonth(Integer.valueOf(labeledSpinner1.getSpinner().getValue().toString()));
752                    s.setStartdate(labeledDateChooser1.getDate());
753                    s.setStopdate(labeledDateChooser2.getDate());
754                    s.setUsersids(mpv5.db.objects.User.getCurrentUser().__getIDS());
755                    s.setNextdate(DateConverter.addMonths(labeledDateChooser1.getDate(),
756                            s.__getIntervalmonth()));
757                    s.save();
758                    dataOwner = s;
759                    /*
760                     * Hack um das POPUP ganz nach oben zu bringen ...
761                     */
762                    tmp = Popup.identifier;
763                    Popup.identifier = this;
764                    Popup.notice(Messages.SCHEDULE_NEXT
765                            + DateConverter.getDefDateString(DateConverter.addMonths(labeledDateChooser1.getDate(),
766                            s.__getIntervalmonth())));
767                    Popup.identifier = tmp;
768                } else if (jTabbedPane1.getSelectedIndex() == 1) {
769                    if (labeledCombobox3.getSelectedItem() == null) {
770                        Popup.error(this, Messages.SELECT_A_CONTACT.toString());
771                        dataOwner = null;
772                        return;
773                    }
774                    if (labeledCombobox4.getSelectedItem() == null) {
775                        Popup.error(this, Messages.SELECT_AN_INVOICE.toString());
776                        dataOwner = null;
777                        return;
778                    }
779                    if (labeledCombobox2.getSelectedItem() == null) {
780                        Popup.error(this, Messages.SELECT_A_TYPE.toString());
781                        dataOwner = null;
782                        return;
783                    }
784                    Contact c = (Contact) DatabaseObject.getObject(Context.getContact(),
785                            Integer.valueOf(labeledCombobox3.getSelectedItem().getId()));
786                    s.setCname("(" + Messages.SCHEDULE + ") " + c.toString());
787                        s.setItemsids(Integer.parseInt(labeledCombobox4.getSelectedItem().getId()));
788                    s.setContactsids(c.__getIDS());
789                        s.setEventtype(Integer.valueOf(labeledCombobox2.getSelectedItem().getId()));
790                    s.setGroupsids(c.__getGroupsids());
791                    s.setIntervalmonth(0);
792                    s.setStartdate(labeledDateChooser3.getDate());
793                    s.setStopdate(labeledDateChooser3.getDate());
794                    s.setUsersids(mpv5.db.objects.User.getCurrentUser().__getIDS());
795                    s.setNextdate(labeledDateChooser3.getDate());
796                    s.save();
797                    dataOwner = s;
798                }
799            } catch (NodataFoundException ex) {
800                Log.Debug(this, ex.getMessage());
801            }
802        }
803    }
804
805    private void initSchedTyps() {
806        try {
807            final ArrayList<DatabaseObject> STypes = DatabaseObject.getObjects(Context.getScheduleTypes(),
808                    new QueryCriteria("USERSIDS", User.getCurrentUser().getID()));
809            MPComboBoxModelItem[] SchedTyps = new MPComboBoxModelItem[STypes.size()];
810
811            for (int i = 0; i < STypes.size(); i++) {
812                ScheduleTypes st = (ScheduleTypes) STypes.get(i);
813                SchedTyps[i] = new MPComboBoxModelItem(st.__getIDS(),
814                        st.__getCname());
815            }
816            labeledCombobox2.setModel(new MPComboboxModel(SchedTyps));
817        } catch (NodataFoundException ex) {
818            Log.Debug(this, ex);
819        }
820    }
821
822    private void clearViews() {
823        dataOwner = null;
824        refreshFromContact(null);
825        refreshFromItem(null);
826        Log.Debug(this, "Views zurückgesetzt ...1");
827        labeledCombobox1.setSelectedIndex(-1);
828        Log.Debug(this, "Views zurückgesetzt ...2");
829        labeledCombobox2.setSelectedIndex(-1);
830        Log.Debug(this, "Views zurückgesetzt ...3");
831        labeledCombobox3.setSelectedIndex(-1);
832        Log.Debug(this, "Views zurückgesetzt ...4");
833        labeledCombobox4.setSelectedIndex(-1);
834        Log.Debug(this, "Views zurückgesetzt ...5");
835        setDate(new Date());
836        Log.Debug(this, "Views zurückgesetzt ...6");
837        labeledSpinner1.setValue(1);
838        Log.Debug(this, "Views zurückgesetzt ...7");
839    }
840}