/* * Copyright (C) 2014 GG-Net GmbH - Oliver Günther * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package eu.ggnet.dwoss.misc; import java.awt.Dimension; import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Date; import javax.swing.*; import javax.swing.GroupLayout.Alignment; import javax.swing.LayoutStyle.ComponentPlacement; import org.jdesktop.beansbinding.*; import org.jdesktop.beansbinding.AutoBinding.UpdateStrategy; import com.toedter.calendar.JDateChooser; /** * * @author development */ public class AuditReportDialog extends javax.swing.JDialog { /** Creates new form ReportAuditDialog */ public AuditReportDialog(Window parent) { super(parent); setModalityType(ModalityType.APPLICATION_MODAL); initComponents(); setLocationRelativeTo(parent); } /** @return the return status of this dialog - one of RET_OK or RET_CANCEL */ public boolean isOk() { return ok; } public Date getEnd() { return end; } public void setEnd(Date end) { this.end = end; } public boolean isRoolIn() { return roolIn; } public void setRoolIn(boolean roolIn) { this.roolIn = roolIn; } public Date getStart() { return start; } public void setStart(Date start) { this.start = start; } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { bindingGroup = new BindingGroup(); group = new ButtonGroup(); jPanel1 = new JPanel(); labelBeginDate = new JLabel(); labelEndDate = new JLabel(); buttonOK = new JButton(); ButtonCancel = new JButton(); jLabel1 = new JLabel(); dateReportButton = new JRadioButton(); rollInReportButton = new JRadioButton(); jDateChooser1 = new JDateChooser(); jDateChooser2 = new JDateChooser(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); labelBeginDate.setText("Start Datum:"); labelBeginDate.setMaximumSize(new Dimension(75, 14)); labelBeginDate.setMinimumSize(new Dimension(75, 14)); labelBeginDate.setPreferredSize(new Dimension(100, 14)); labelEndDate.setText("End Datum:"); labelEndDate.setMaximumSize(new Dimension(75, 14)); labelEndDate.setMinimumSize(new Dimension(75, 14)); labelEndDate.setPreferredSize(new Dimension(100, 14)); buttonOK.setText("OK"); buttonOK.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { buttonOKActionPerformed(evt); } }); ButtonCancel.setText("Cancel"); ButtonCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { ButtonCancelActionPerformed(evt); } }); jLabel1.setText("Audit-Report"); group.add(dateReportButton); dateReportButton.setSelected(true); group.add(rollInReportButton); rollInReportButton.setText("Alle neu erfassten Geräte"); Binding binding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, this, ELProperty.create("${roolIn}"), rollInReportButton, BeanProperty.create("selected")); bindingGroup.addBinding(binding); binding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, this, ELProperty.create("${start}"), jDateChooser1, BeanProperty.create("date")); bindingGroup.addBinding(binding); binding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, this, ELProperty.create("${end}"), jDateChooser2, BeanProperty.create("date")); bindingGroup.addBinding(binding); GroupLayout jPanel1Layout = new GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(Alignment.LEADING) .addGroup(Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(buttonOK) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(ButtonCancel)) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(Alignment.LEADING) .addComponent(jLabel1) .addComponent(rollInReportButton) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(dateReportButton) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(Alignment.LEADING, false) .addComponent(labelBeginDate, GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE) .addComponent(labelEndDate, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(Alignment.LEADING, false) .addComponent(jDateChooser2, GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE) .addComponent(jDateChooser1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) ); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(Alignment.BASELINE) .addComponent(ButtonCancel) .addComponent(buttonOK))) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel1) .addGroup(jPanel1Layout.createParallelGroup(Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(24, 24, 24) .addComponent(dateReportButton)) .addGroup(jPanel1Layout.createSequentialGroup() .addPreferredGap(ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(Alignment.TRAILING) .addComponent(jDateChooser1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(labelBeginDate, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(Alignment.TRAILING) .addComponent(labelEndDate, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE) .addComponent(jDateChooser2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(rollInReportButton) .addGap(0, 36, Short.MAX_VALUE))) .addContainerGap()) ); GroupLayout layout = new GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING) .addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING) .addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); bindingGroup.bind(); pack(); }// </editor-fold>//GEN-END:initComponents private void ButtonCancelActionPerformed(ActionEvent evt) {//GEN-FIRST:event_ButtonCancelActionPerformed setVisible(false); }//GEN-LAST:event_ButtonCancelActionPerformed private void buttonOKActionPerformed(ActionEvent evt) {//GEN-FIRST:event_buttonOKActionPerformed ok = true; setVisible(false); }//GEN-LAST:event_buttonOKActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private JButton ButtonCancel; private JButton buttonOK; private JRadioButton dateReportButton; private ButtonGroup group; private JDateChooser jDateChooser1; private JDateChooser jDateChooser2; private JLabel jLabel1; private JPanel jPanel1; private JLabel labelBeginDate; private JLabel labelEndDate; private JRadioButton rollInReportButton; private BindingGroup bindingGroup; // End of variables declaration//GEN-END:variables private boolean ok = false; private boolean roolIn = false; private Date start; private Date end; public static void main(String[] args) { AuditReportDialog d = new AuditReportDialog(null); d.setVisible(true); System.out.println(d.getStart() + " | " + d.getEnd() + " | " + d.isRoolIn()); System.exit(0); } }