PageRenderTime 83ms CodeModel.GetById 40ms app.highlight 9ms RepoModel.GetById 32ms app.codeStats 0ms

/src/mpv5/ui/beans/TimeframeChooser.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 107 lines | 55 code | 12 blank | 40 comment | 2 complexity | cd054d663b344a175a728abcdd3c8274 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 * TimeframeChooser.java
 19 *
 20 * Created on 25.05.2009, 14:20:08
 21 */
 22package mpv5.ui.beans;
 23
 24import java.util.Date;
 25import mpv5.utils.date.DateConverter;
 26import mpv5.utils.date.vTimeframe;
 27
 28/**
 29 *
 30 *  
 31 */
 32public class TimeframeChooser extends javax.swing.JPanel {
 33
 34    private static final long serialVersionUID = 1L;
 35
 36    /** Creates new form TimeframeChooser */
 37    public TimeframeChooser() {
 38        initComponents();
 39        setTime(new vTimeframe(new Date(), new Date()))
 40               ;
 41    }
 42    private vTimeframe time;
 43
 44    /** This method is called from within the constructor to
 45     * initialize the form.
 46     * WARNING: Do NOT modify this code. The content of this method is
 47     * always regenerated by the Form Editor.
 48     */
 49    @SuppressWarnings("unchecked")
 50    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
 51    private void initComponents() {
 52
 53        dateChooser1 = new mpv5.ui.beans.DateChooser();
 54        dateChooser2 = new mpv5.ui.beans.DateChooser();
 55        jLabel1 = new javax.swing.JLabel();
 56
 57        setName("Form"); // NOI18N
 58        setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.LINE_AXIS));
 59
 60        dateChooser1.setMaximumSize(new java.awt.Dimension(32767, 333));
 61        dateChooser1.setMinimumSize(new java.awt.Dimension(33, 18));
 62        dateChooser1.setName("dateChooser1"); // NOI18N
 63        dateChooser1.setPreferredSize(new java.awt.Dimension(150, 20));
 64        add(dateChooser1);
 65
 66        dateChooser2.setMaximumSize(new java.awt.Dimension(32767, 333));
 67        dateChooser2.setMinimumSize(new java.awt.Dimension(33, 18));
 68        dateChooser2.setName("dateChooser2"); // NOI18N
 69        dateChooser2.setPreferredSize(new java.awt.Dimension(150, 20));
 70        add(dateChooser2);
 71
 72        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
 73        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/2rightarrow.png"))); // NOI18N
 74        java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle(); // NOI18N
 75        jLabel1.setText(bundle.getString("TimeframeChooser.jLabel1.text")); // NOI18N
 76        jLabel1.setIconTextGap(0);
 77        jLabel1.setMaximumSize(new java.awt.Dimension(33, 333));
 78        jLabel1.setMinimumSize(new java.awt.Dimension(18, 18));
 79        jLabel1.setName("jLabel1"); // NOI18N
 80        jLabel1.setPreferredSize(new java.awt.Dimension(32, 20));
 81        add(jLabel1);
 82    }// </editor-fold>//GEN-END:initComponents
 83    // Variables declaration - do not modify//GEN-BEGIN:variables
 84    private mpv5.ui.beans.DateChooser dateChooser1;
 85    private mpv5.ui.beans.DateChooser dateChooser2;
 86    private javax.swing.JLabel jLabel1;
 87    // End of variables declaration//GEN-END:variables
 88
 89    /**
 90     * @return the time
 91     */
 92    public vTimeframe getTime() {
 93        if (dateChooser1.hasDate() && dateChooser2.hasDate()) {
 94            time = new vTimeframe(dateChooser1.getDate(), DateConverter.getEndOfDay(dateChooser2.getDate()));
 95        }
 96        return time;
 97    }
 98
 99    /**
100     * @param time the time to set
101     */
102    public void setTime(vTimeframe time) {
103        this.time = time;
104        dateChooser1.setDate(time.getStart());
105        dateChooser2.setDate(DateConverter.getEndOfDay(time.getEnd()));
106    }
107}