PageRenderTime 272ms CodeModel.GetById 81ms app.highlight 16ms RepoModel.GetById 135ms app.codeStats 0ms

/src/mpv5/ui/dialogs/ScheduleDayEvents.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 195 lines | 142 code | 24 blank | 29 comment | 4 complexity | 8ebb3b188077155df287c01cb14a4b6d 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.util.ArrayList;
 14
 15import java.util.Date;
 16import mpv5.db.common.Context;
 17import mpv5.db.common.DatabaseObject;
 18import mpv5.db.common.NodataFoundException;
 19import mpv5.db.objects.Schedule;
 20import mpv5.globals.Headers;
 21import mpv5.logging.Log;
 22import mpv5.ui.frames.MPView;
 23import mpv5.ui.misc.Position;
 24import mpv5.utils.date.DateConverter;
 25import mpv5.utils.models.MPTableModel;
 26import mpv5.utils.tables.TableFormat;
 27
 28/**
 29 *
 30 *  
 31 */
 32public class ScheduleDayEvents extends javax.swing.JFrame {
 33
 34    private static final long serialVersionUID = 1L;
 35    private final Date day;
 36
 37    /**
 38     *
 39     * @param day
 40     */
 41    public ScheduleDayEvents(Date day) {
 42        initComponents();
 43        this.day = day;
 44        refresh(Schedule.getEvents(day));
 45        setTitle(getTitle() + " " + DateConverter.getDefDateString(day));
 46        new Position(this);
 47        setVisible(rootPaneCheckingEnabled);
 48    }
 49
 50    /** Creates new form SplashScreen
 51     * @param list
 52     */
 53    public ScheduleDayEvents(ArrayList<Schedule> list) {
 54        initComponents();
 55        refresh(list);
 56        day = new Date();
 57        new Position(this);
 58        setVisible(rootPaneCheckingEnabled);
 59    }
 60
 61    /** This method is called from within the constructor to
 62     * initialize the form.
 63     * WARNING: Do NOT modify this code. The content of this method is
 64     * always regenerated by the Form Editor.
 65     */
 66    @SuppressWarnings("unchecked")
 67    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
 68    private void initComponents() {
 69
 70        jPanel1 = new javax.swing.JPanel();
 71        jButton2 = new javax.swing.JButton();
 72        jScrollPane1 = new javax.swing.JScrollPane();
 73        jTable1 = new javax.swing.JTable();
 74        jButton1 = new javax.swing.JButton();
 75
 76        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
 77        java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle();
 78        setTitle(bundle.getString("ScheduleDayEvents.title")); // NOI18N
 79        setName("Form"); // NOI18N
 80
 81        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("ScheduleDayEvents.jPanel1.border.title"))); // NOI18N
 82        jPanel1.setName("jPanel1"); // NOI18N
 83
 84        jButton2.setText(bundle.getString("ScheduleDayEvents.jButton2.text")); // NOI18N
 85        jButton2.setName("jButton2"); // NOI18N
 86        jButton2.addActionListener(new java.awt.event.ActionListener() {
 87            public void actionPerformed(java.awt.event.ActionEvent evt) {
 88                jButton2ActionPerformed(evt);
 89            }
 90        });
 91
 92        jScrollPane1.setName("jScrollPane1"); // NOI18N
 93
 94        jTable1.setModel(new javax.swing.table.DefaultTableModel(
 95            new Object [][] {
 96                {},
 97                {},
 98                {},
 99                {}
100            },
101            new String [] {
102
103            }
104        ));
105        jTable1.setName("jTable1"); // NOI18N
106        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
107            public void mouseClicked(java.awt.event.MouseEvent evt) {
108                jTable1MouseClicked(evt);
109            }
110        });
111        jScrollPane1.setViewportView(jTable1);
112
113        jButton1.setText(bundle.getString("ScheduleDayEvents.jButton1.text")); // NOI18N
114        jButton1.setName("jButton1"); // NOI18N
115        jButton1.addActionListener(new java.awt.event.ActionListener() {
116            public void actionPerformed(java.awt.event.ActionEvent evt) {
117                jButton1ActionPerformed(evt);
118            }
119        });
120
121        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
122        jPanel1.setLayout(jPanel1Layout);
123        jPanel1Layout.setHorizontalGroup(
124            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
125            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
126                .addGap(200, 200, 200)
127                .addComponent(jButton1)
128                .addGap(18, 18, 18)
129                .addComponent(jButton2))
130            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE)
131        );
132        jPanel1Layout.setVerticalGroup(
133            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
134            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
135                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE)
136                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
137                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
138                    .addComponent(jButton2)
139                    .addComponent(jButton1)))
140        );
141
142        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
143
144        pack();
145    }// </editor-fold>//GEN-END:initComponents
146
147    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
148        dispose();
149    }//GEN-LAST:event_jButton2ActionPerformed
150
151    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
152        if (evt.getClickCount() > 1) {
153            DatabaseObject d = (DatabaseObject) jTable1.getValueAt(jTable1.getSelectedRow(), 0);
154            if (d != null) {
155                mpv5.YabsViewProxy.instance().getIdentifierView().addTab(d);
156                this.dispose();
157            }
158        }
159    }//GEN-LAST:event_jTable1MouseClicked
160
161    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
162        ScheduleDayEvent.instanceOf().setDate(day);
163        ScheduleDayEvent.instanceOf().setVisible(rootPaneCheckingEnabled);
164        dispose();
165    }//GEN-LAST:event_jButton1ActionPerformed
166    // Variables declaration - do not modify//GEN-BEGIN:variables
167    private javax.swing.JButton jButton1;
168    private javax.swing.JButton jButton2;
169    private javax.swing.JPanel jPanel1;
170    private javax.swing.JScrollPane jScrollPane1;
171    private javax.swing.JTable jTable1;
172    // End of variables declaration//GEN-END:variables
173
174    private void refresh(ArrayList<Schedule> list) {
175        Object[][] data = new Object[list.size()][4];
176
177        for (int i = 0; i < list.size(); i++) {
178            try {
179                Schedule schedule = list.get(i);
180                data[i][0] = schedule.getItem();
181                data[i][1] = schedule.__getIntervalmonth();
182                data[i][2] = DateConverter.getDefDateString(schedule.__getStopdate());
183                try {
184                    data[i][3] = DatabaseObject.getObject(Context.getUser(), schedule.__getIntaddedby());
185                } catch (NodataFoundException nodataFoundException) {
186                }
187            } catch (NodataFoundException ex) {
188                Log.Debug(this, ex);
189            }
190        }
191        jTable1.setModel(new MPTableModel(data, Headers.SCHEDULE_LIST));
192//        TableFormat.stripFirstColumn(jTable1);
193        TableFormat.format(jTable1, 1, 100);
194    }
195}