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