/* * OffenePflege * Copyright (C) 2006-2012 Torsten Löhr * This program is free software; you can redistribute it and/or modify it under the terms of the * GNU General Public License V2 as published by the Free Software Foundation * * 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, write to * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA * www.offene-pflege.de * ------------------------ * Auf deutsch (freie Übersetzung. Rechtlich gilt die englische Version) * Dieses Programm ist freie Software. Sie können es unter den Bedingungen der GNU General Public License, * wie von der Free Software Foundation veröffentlicht, weitergeben und/oder modifizieren, gemäß Version 2 der Lizenz. * * Die Veröffentlichung dieses Programms erfolgt in der Hoffnung, daß es Ihnen von Nutzen sein wird, aber * OHNE IRGENDEINE GARANTIE, sogar ohne die implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT FÜR EINEN * BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License. * * Sie sollten ein Exemplar der GNU General Public License zusammen mit diesem Programm erhalten haben. Falls nicht, * schreiben Sie an die Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA. * */ package op.care.supervisor; import java.awt.event.*; import com.jgoodies.forms.factories.CC; import com.jgoodies.forms.layout.FormLayout; import entity.reports.Handovers; import op.OPDE; import op.tools.MyJDialog; import op.tools.PnlPIT; import op.tools.SYSTools; import org.apache.commons.collections.Closure; import org.joda.time.DateMidnight; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Date; /** * @author root */ public class DlgHOReport extends MyJDialog { private Handovers handover; private Closure actionBlock; private PnlPIT pnlPIT; /** * Creates new form DlgReport */ public DlgHOReport(Handovers handover, Closure actionBlock) { super(false); this.handover = handover; this.actionBlock = actionBlock; initComponents(); initDialog(); // setVisible(true); } private void thisWindowClosing(WindowEvent e) { btnCancelActionPerformed(null); } private void initDialog() { txtReport.setText(SYSTools.catchNull(handover.getText())); pnlPIT = new PnlPIT(handover.getPit(), new Date(), new DateMidnight().minusWeeks(1).toDate()); add(pnlPIT, CC.xywh(3, 3, 1, 1, CC.DEFAULT, CC.FILL)); // cmbHomes.setFont(SYSConst.ARIAL14); // HomesTools.setComboBox(cmbHomes); } /** * 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 PrinterForm Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jScrollPane1 = new JScrollPane(); txtReport = new JTextPane(); panel1 = new JPanel(); btnCancel = new JButton(); btnSave = new JButton(); //======== this ======== setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { thisWindowClosing(e); } }); Container contentPane = getContentPane(); contentPane.setLayout(new FormLayout( "default, $lcgap, default:grow, $lcgap, default", "2*(default, $lgap), fill:default:grow, $lgap, fill:default, $lgap, default")); //======== jScrollPane1 ======== { jScrollPane1.setViewportView(txtReport); } contentPane.add(jScrollPane1, CC.xy(3, 5)); //======== panel1 ======== { panel1.setLayout(new BoxLayout(panel1, BoxLayout.X_AXIS)); //---- btnCancel ---- btnCancel.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png"))); btnCancel.setText(null); btnCancel.addActionListener(e -> btnCancelActionPerformed(e)); panel1.add(btnCancel); //---- btnSave ---- btnSave.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png"))); btnSave.setText(null); btnSave.addActionListener(e -> btnSaveActionPerformed(e)); panel1.add(btnSave); } contentPane.add(panel1, CC.xy(3, 7, CC.RIGHT, CC.DEFAULT)); setSize(462, 379); setLocationRelativeTo(null); }// </editor-fold>//GEN-END:initComponents private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed handover = null; dispose(); }//GEN-LAST:event_btnCancelActionPerformed private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed if (!txtReport.getText().trim().isEmpty()) { handover.setUser(OPDE.getLogin().getUser()); handover.setPit(pnlPIT.getPIT()); handover.setText(txtReport.getText().trim()); } else { handover = null; } this.dispose(); }//GEN-LAST:event_btnSaveActionPerformed @Override public void dispose() { actionBlock.execute(handover); super.dispose(); } // private void txtTBUhrzeittxtUhrzeitHandler(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtTBUhrzeittxtUhrzeitHandler // JTextField txt = (JTextField) evt.getComponent(); // String t = txt.getText(); // try { // GregorianCalendar gc = SYSCalendar.parseTime(t); // txt.setText(SYSCalendar.toGermanTime(gc)); // } catch (NumberFormatException nfe) { // txt.setText(SYSCalendar.toGermanTime(new GregorianCalendar())); // txt.requestFocusInWindow(); // } // }//GEN-LAST:event_txtTBUhrzeittxtUhrzeitHandler // private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing // }//GEN-LAST:event_formWindowClosing // Variables declaration - do not modify//GEN-BEGIN:variables private JScrollPane jScrollPane1; private JTextPane txtReport; private JPanel panel1; private JButton btnCancel; private JButton btnSave; // End of variables declaration//GEN-END:variables }