diff --git a/src/org/hwo/pulscounter/elements/WorkShiftRecord.java b/src/org/hwo/pulscounter/elements/WorkShiftRecord.java index 49123dc..29d0ddd 100644 --- a/src/org/hwo/pulscounter/elements/WorkShiftRecord.java +++ b/src/org/hwo/pulscounter/elements/WorkShiftRecord.java @@ -10,6 +10,10 @@ import java.util.List; import org.hwo.datetime.Date; import org.hwo.datetime.DateTime; +<<<<<<< HEAD +======= +import org.hwo.pulscounter.PulsCounter; +>>>>>>> a886cb917c05a82eb85921d7d9c387835aa3f888 public class WorkShiftRecord { @@ -85,7 +89,11 @@ public class WorkShiftRecord { } void loadRecords(){ +<<<<<<< HEAD /* try { +======= + try { +>>>>>>> a886cb917c05a82eb85921d7d9c387835aa3f888 PreparedStatement stat = PulsCounter.getInspectorApplication().getConnection().prepareStatement("SELECT tstamp,channel,chvalue FROM rawvalues WHERE tstamp >= ? AND tstamp < ? ORDER BY channel,tstamp"); stat.setTimestamp(1, workShift.getShiftBegins(date).getTimeStamp()); @@ -118,7 +126,10 @@ public class WorkShiftRecord { } catch (SQLException e) { e.printStackTrace(); } +<<<<<<< HEAD */ +======= +>>>>>>> a886cb917c05a82eb85921d7d9c387835aa3f888 } public Integer[] getChannels(){ diff --git a/src/org/hwo/pulscounter/ui/CheckWorkshiftRecords.java b/src/org/hwo/pulscounter/ui/CheckWorkshiftRecords.java new file mode 100644 index 0000000..4aff814 --- /dev/null +++ b/src/org/hwo/pulscounter/ui/CheckWorkshiftRecords.java @@ -0,0 +1,302 @@ +package org.hwo.pulscounter.ui; + +import java.awt.BorderLayout; +import java.awt.EventQueue; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; + +import java.awt.GridBagLayout; +import java.awt.GridBagConstraints; + +import javax.swing.border.TitledBorder; + +import java.awt.Insets; + +import javax.swing.JLabel; +import javax.swing.JTextField; +import javax.swing.JButton; + +import org.hwo.datetime.Date; +import org.hwo.pulscounter.PulsCounter; +import org.hwo.pulscounter.elements.WorkShift; +import org.hwo.pulscounter.elements.WorkShiftRecord; + +import javax.swing.JComboBox; + +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.util.LinkedList; + +import javax.swing.JTable; + +import org.hwo.ui.FlexibleJTable; +import org.hwo.ui.JComboBoxEx; + +import javax.swing.JScrollPane; + +public class CheckWorkshiftRecords extends JFrame { + + private Date selectedDate; + private WorkShiftRecord selectedWorkShift; + + + private JPanel contentPane; + private JTextField tfDatum; + private JComboBox cbWorkShift; + private JTextField tfBegins; + private JTextField tfEnds; + private FlexibleJTable flexibleJTable; + private JComboBoxEx cbChannel; + + /** + * Launch the application. + */ + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + CheckWorkshiftRecords frame = new CheckWorkshiftRecords(); + frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + /** + * Create the frame. + */ + public CheckWorkshiftRecords() { + setTitle("Schichtdaten prüfen"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setBounds(100, 100, 938, 686); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + GridBagLayout gbl_contentPane = new GridBagLayout(); + gbl_contentPane.columnWidths = new int[]{0, 0}; + gbl_contentPane.rowHeights = new int[]{0, 0, 0, 0}; + gbl_contentPane.columnWeights = new double[]{1.0, Double.MIN_VALUE}; + gbl_contentPane.rowWeights = new double[]{0.0, 0.0, 1.0, Double.MIN_VALUE}; + contentPane.setLayout(gbl_contentPane); + + JPanel panel = new JPanel(); + panel.setBorder(new TitledBorder(null, "Auswahl", TitledBorder.LEADING, TitledBorder.TOP, null, null)); + GridBagConstraints gbc_panel = new GridBagConstraints(); + gbc_panel.insets = new Insets(0, 0, 5, 0); + gbc_panel.fill = GridBagConstraints.BOTH; + gbc_panel.gridx = 0; + gbc_panel.gridy = 0; + contentPane.add(panel, gbc_panel); + GridBagLayout gbl_panel = new GridBagLayout(); + gbl_panel.columnWidths = new int[]{0, 0, 0, 0, 0, 0}; + gbl_panel.rowHeights = new int[]{0, 0, 0, 0}; + gbl_panel.columnWeights = new double[]{0.0, 1.0, 1.0, 0.0, 0.0, Double.MIN_VALUE}; + gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE}; + panel.setLayout(gbl_panel); + + JLabel lblDatum = new JLabel("Datum:"); + GridBagConstraints gbc_lblDatum = new GridBagConstraints(); + gbc_lblDatum.insets = new Insets(0, 0, 5, 5); + gbc_lblDatum.anchor = GridBagConstraints.EAST; + gbc_lblDatum.gridx = 0; + gbc_lblDatum.gridy = 0; + panel.add(lblDatum, gbc_lblDatum); + + tfDatum = new JTextField(); + tfDatum.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Date d = new Date(); + d.fromSQLDate(tfDatum.getText()); + selectDatum(d); + } + }); + GridBagConstraints gbc_tfDatum = new GridBagConstraints(); + gbc_tfDatum.gridwidth = 2; + gbc_tfDatum.insets = new Insets(0, 0, 5, 5); + gbc_tfDatum.fill = GridBagConstraints.HORIZONTAL; + gbc_tfDatum.gridx = 1; + gbc_tfDatum.gridy = 0; + panel.add(tfDatum, gbc_tfDatum); + tfDatum.setColumns(10); + + JButton btnGestern = new JButton("GESTERN"); + btnGestern.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Date d = new Date(); + d.addDays(-1); + selectDatum(d); + } + }); + + JButton btnHeute = new JButton("HEUTE"); + btnHeute.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + selectDatum(new Date()); + } + }); + GridBagConstraints gbc_btnHeute = new GridBagConstraints(); + gbc_btnHeute.insets = new Insets(0, 0, 5, 5); + gbc_btnHeute.gridx = 3; + gbc_btnHeute.gridy = 0; + panel.add(btnHeute, gbc_btnHeute); + GridBagConstraints gbc_btnGestern = new GridBagConstraints(); + gbc_btnGestern.insets = new Insets(0, 0, 5, 0); + gbc_btnGestern.gridx = 4; + gbc_btnGestern.gridy = 0; + panel.add(btnGestern, gbc_btnGestern); + + JLabel lblSchicht = new JLabel("Schicht:"); + GridBagConstraints gbc_lblSchicht = new GridBagConstraints(); + gbc_lblSchicht.insets = new Insets(0, 0, 5, 5); + gbc_lblSchicht.gridx = 0; + gbc_lblSchicht.gridy = 1; + panel.add(lblSchicht, gbc_lblSchicht); + + cbWorkShift = new JComboBox(); + cbWorkShift.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + selectionChanged(); + } + }); + GridBagConstraints gbc_cbWorkShift = new GridBagConstraints(); + gbc_cbWorkShift.gridwidth = 2; + gbc_cbWorkShift.insets = new Insets(0, 0, 5, 5); + gbc_cbWorkShift.fill = GridBagConstraints.HORIZONTAL; + gbc_cbWorkShift.gridx = 1; + gbc_cbWorkShift.gridy = 1; + panel.add(cbWorkShift, gbc_cbWorkShift); + + JLabel lblSchichtgrenzen = new JLabel("Schichtgrenzen:"); + GridBagConstraints gbc_lblSchichtgrenzen = new GridBagConstraints(); + gbc_lblSchichtgrenzen.anchor = GridBagConstraints.EAST; + gbc_lblSchichtgrenzen.insets = new Insets(0, 0, 0, 5); + gbc_lblSchichtgrenzen.gridx = 0; + gbc_lblSchichtgrenzen.gridy = 2; + panel.add(lblSchichtgrenzen, gbc_lblSchichtgrenzen); + + tfBegins = new JTextField(); + GridBagConstraints gbc_tfBegins = new GridBagConstraints(); + gbc_tfBegins.insets = new Insets(0, 0, 0, 5); + gbc_tfBegins.fill = GridBagConstraints.HORIZONTAL; + gbc_tfBegins.gridx = 1; + gbc_tfBegins.gridy = 2; + panel.add(tfBegins, gbc_tfBegins); + tfBegins.setColumns(10); + + tfEnds = new JTextField(); + tfEnds.setColumns(10); + GridBagConstraints gbc_tfEnds = new GridBagConstraints(); + gbc_tfEnds.insets = new Insets(0, 0, 0, 5); + gbc_tfEnds.fill = GridBagConstraints.HORIZONTAL; + gbc_tfEnds.gridx = 2; + gbc_tfEnds.gridy = 2; + panel.add(tfEnds, gbc_tfEnds); + + JPanel panel_2 = new JPanel(); + panel_2.setBorder(new TitledBorder(null, "Kanal", TitledBorder.LEADING, TitledBorder.TOP, null, null)); + GridBagConstraints gbc_panel_2 = new GridBagConstraints(); + gbc_panel_2.insets = new Insets(0, 0, 5, 0); + gbc_panel_2.fill = GridBagConstraints.BOTH; + gbc_panel_2.gridx = 0; + gbc_panel_2.gridy = 1; + contentPane.add(panel_2, gbc_panel_2); + GridBagLayout gbl_panel_2 = new GridBagLayout(); + gbl_panel_2.columnWidths = new int[]{0, 0}; + gbl_panel_2.rowHeights = new int[]{0, 0}; + gbl_panel_2.columnWeights = new double[]{1.0, Double.MIN_VALUE}; + gbl_panel_2.rowWeights = new double[]{0.0, Double.MIN_VALUE}; + panel_2.setLayout(gbl_panel_2); + + cbChannel = new JComboBoxEx(); + cbChannel.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + selectChannel(); + } + } + ); + GridBagConstraints gbc_cbChannel = new GridBagConstraints(); + gbc_cbChannel.fill = GridBagConstraints.HORIZONTAL; + gbc_cbChannel.gridx = 0; + gbc_cbChannel.gridy = 0; + panel_2.add(cbChannel, gbc_cbChannel); + + JPanel panel_1 = new JPanel(); + GridBagConstraints gbc_panel_1 = new GridBagConstraints(); + gbc_panel_1.fill = GridBagConstraints.BOTH; + gbc_panel_1.gridx = 0; + gbc_panel_1.gridy = 2; + contentPane.add(panel_1, gbc_panel_1); + GridBagLayout gbl_panel_1 = new GridBagLayout(); + gbl_panel_1.columnWidths = new int[]{0, 0}; + gbl_panel_1.rowHeights = new int[]{0, 0}; + gbl_panel_1.columnWeights = new double[]{1.0, Double.MIN_VALUE}; + gbl_panel_1.rowWeights = new double[]{1.0, Double.MIN_VALUE}; + panel_1.setLayout(gbl_panel_1); + + JScrollPane scrollPane = new JScrollPane(); + GridBagConstraints gbc_scrollPane = new GridBagConstraints(); + gbc_scrollPane.fill = GridBagConstraints.BOTH; + gbc_scrollPane.gridx = 0; + gbc_scrollPane.gridy = 0; + panel_1.add(scrollPane, gbc_scrollPane); + + flexibleJTable = new FlexibleJTable(WorkShiftRecord.ChannelRecords.ChannelRecord.class); + scrollPane.setViewportView(flexibleJTable); + + this.initialize(); + } + + void initialize(){ + for (WorkShift shift: PulsCounter.getInspectorApplication().getWorkShifts()){ + cbWorkShift.addItem(shift); + } + + flexibleJTable.addColumn("timestamp"); + flexibleJTable.addColumn("value"); + + + + selectDatum(new Date()); + } + + void selectDatum(Date date){ + tfDatum.setText(date.getSQLDate()); + selectedDate = date; + + selectionChanged(); + } + + void selectionChanged(){ + if (cbWorkShift.getSelectedItem()==null) + return; + if (selectedDate == null) + return; + + WorkShift shift = (WorkShift)cbWorkShift.getSelectedItem(); + + tfBegins.setText(shift.getShiftBegins(selectedDate).getSQLDateTime()); + tfEnds.setText(shift.getShiftEnds(selectedDate).getSQLDateTime()); + + WorkShiftRecord workShiftRecord = new WorkShiftRecord(shift, selectedDate); + + selectedWorkShift = null; + + flexibleJTable.setRows(new LinkedList()); + cbChannel.setItems(workShiftRecord.getChannels()); + + selectedWorkShift = workShiftRecord; + } + + void selectChannel(){ + if (selectedWorkShift != null){ + Integer ch = (Integer)cbChannel.getSelectedItem(); + flexibleJTable.setRows(selectedWorkShift.getChannelRecords(ch).getRecords()); + } + } + +} diff --git a/src/org/hwo/pulscounter/ui/InspectionMainFrame.java b/src/org/hwo/pulscounter/ui/InspectionMainFrame.java new file mode 100644 index 0000000..4f21695 --- /dev/null +++ b/src/org/hwo/pulscounter/ui/InspectionMainFrame.java @@ -0,0 +1,122 @@ +package org.hwo.pulscounter.ui; + +import java.awt.BorderLayout; +import java.awt.EventQueue; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; + +import java.awt.GridBagLayout; + +import javax.swing.JButton; + +import java.awt.GridBagConstraints; +import java.awt.Insets; + +import javax.swing.border.TitledBorder; + +import org.hwo.datetime.Date; +import org.hwo.pulscounter.PulsCounter; +import org.hwo.pulscounter.elements.WorkShift; + +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; + +public class InspectionMainFrame extends JFrame { + + private JPanel contentPane; + + /** + * Launch the application. + */ + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + InspectionMainFrame frame = new InspectionMainFrame(); + frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + /** + * Create the frame. + */ + public InspectionMainFrame() { + setTitle("Inspektor"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setBounds(100, 100, 841, 607); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + GridBagLayout gbl_contentPane = new GridBagLayout(); + gbl_contentPane.columnWidths = new int[]{0, 0}; + gbl_contentPane.rowHeights = new int[]{0, 0, 0}; + gbl_contentPane.columnWeights = new double[]{1.0, Double.MIN_VALUE}; + gbl_contentPane.rowWeights = new double[]{1.0, 1.0, Double.MIN_VALUE}; + contentPane.setLayout(gbl_contentPane); + + JPanel panel = new JPanel(); + GridBagConstraints gbc_panel = new GridBagConstraints(); + gbc_panel.insets = new Insets(0, 0, 5, 0); + gbc_panel.fill = GridBagConstraints.BOTH; + gbc_panel.gridx = 0; + gbc_panel.gridy = 0; + contentPane.add(panel, gbc_panel); + GridBagLayout gbl_panel = new GridBagLayout(); + gbl_panel.columnWidths = new int[]{0, 0}; + gbl_panel.rowHeights = new int[]{0, 0}; + gbl_panel.columnWeights = new double[]{0.0, Double.MIN_VALUE}; + gbl_panel.rowWeights = new double[]{0.0, Double.MIN_VALUE}; + panel.setLayout(gbl_panel); + + JButton btnNewButton = new JButton("Schichtdaten prüfen..."); + btnNewButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + WorkShift[] shifts = PulsCounter.getInspectorApplication().getWorkShifts(); + Date d = new Date(); + d.addDays(10); + for (int i=0;i<40;i++){ + + for (int s = 0;s