204 lines
6.7 KiB
Java
204 lines
6.7 KiB
Java
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 javax.swing.event.ListSelectionEvent;
|
|
import javax.swing.event.ListSelectionListener;
|
|
|
|
import org.hwo.i18n.Messages;
|
|
import org.hwo.interactiveobjects.ObjectEditorUI;
|
|
import org.hwo.interactiveobjects.ObjectEditorUIHelper;
|
|
import org.hwo.models.TableMapper.TableMapper;
|
|
import org.hwo.pulscounter.ExportSetting;
|
|
import org.hwo.pulscounter.PulsCounterApplication;
|
|
|
|
import java.awt.GridBagLayout;
|
|
import javax.swing.JButton;
|
|
import javax.swing.JDialog;
|
|
|
|
import java.awt.GridBagConstraints;
|
|
import javax.swing.JScrollPane;
|
|
import java.awt.Insets;
|
|
import javax.swing.JTable;
|
|
import java.awt.event.ActionListener;
|
|
import java.awt.event.ActionEvent;
|
|
import javax.swing.JToolBar;
|
|
import javax.swing.ListSelectionModel;
|
|
import javax.swing.JSeparator;
|
|
import java.awt.Dialog.ModalExclusionType;
|
|
import java.awt.Dialog.ModalityType;
|
|
|
|
public class ExportFilesFrame extends JDialog {
|
|
|
|
private JPanel contentPane;
|
|
private JTable tExportSettings;
|
|
|
|
private TableMapper tmExportSettings;
|
|
private JButton bRemove;
|
|
private JButton bEdit;
|
|
private JButton bAdd;
|
|
|
|
|
|
private ExportSetting selectedExportSetting;
|
|
private JSeparator separator;
|
|
private JButton btnExec;
|
|
private JButton btnBatch;
|
|
|
|
/**
|
|
* Create the frame.
|
|
*/
|
|
public ExportFilesFrame() {
|
|
setModalityType(ModalityType.APPLICATION_MODAL);
|
|
|
|
setTitle(Messages.getString("Export Einstellungen..."));
|
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
|
setBounds(100, 100, 825, 433);
|
|
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, 0, 0};
|
|
gbl_contentPane.rowHeights = new int[]{0, 0, 0, 0};
|
|
gbl_contentPane.columnWeights = new double[]{1.0, 0.0, 0.0, Double.MIN_VALUE};
|
|
gbl_contentPane.rowWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
|
|
contentPane.setLayout(gbl_contentPane);
|
|
|
|
JToolBar toolBar = new JToolBar();
|
|
toolBar.setFloatable(false);
|
|
GridBagConstraints gbc_toolBar = new GridBagConstraints();
|
|
gbc_toolBar.fill = GridBagConstraints.BOTH;
|
|
gbc_toolBar.gridwidth = 3;
|
|
gbc_toolBar.insets = new Insets(0, 0, 5, 5);
|
|
gbc_toolBar.gridx = 0;
|
|
gbc_toolBar.gridy = 0;
|
|
contentPane.add(toolBar, gbc_toolBar);
|
|
|
|
bAdd = new JButton(Messages.getString("Export hinzufügen"));
|
|
bAdd.setToolTipText(Messages.getString("tooltip.export.add")); //"<html>\n<b>Neue Exportkonfiguration hinzufügen</b><br/>\n</html>");
|
|
bAdd.addActionListener(new ActionListener() {
|
|
public void actionPerformed(ActionEvent e) {
|
|
ExportSetting es = new ExportSetting();
|
|
tmExportSettings.addRow(es);
|
|
}
|
|
});
|
|
toolBar.add(bAdd);
|
|
|
|
bEdit = new JButton(Messages.getString("Einstellungen"));
|
|
bEdit.setToolTipText(Messages.getString("tooltip.export.configuration")); // "<html>\n<b>Ausgewählte Exportkonfiguration bearbeiten</b>\n</html>");
|
|
bEdit.addActionListener(new ActionListener() {
|
|
public void actionPerformed(ActionEvent e) {
|
|
ExportSetting es = (ExportSetting)tmExportSettings.getSelectedRow();
|
|
if (es != null){
|
|
if (ObjectEditorUIHelper.edit(es)){
|
|
tmExportSettings.fireTableDataChanged();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
bEdit.setEnabled(false);
|
|
toolBar.add(bEdit);
|
|
|
|
bRemove = new JButton(Messages.getString(Messages.getString("Export löschen")));
|
|
bRemove.setToolTipText(Messages.getString("tooltip.export.remove")); // "<html>\n<b>Ausgewählte Exportkonfiguration entfernen</b>\n</html>");
|
|
bRemove.addActionListener(new ActionListener() {
|
|
public void actionPerformed(ActionEvent e) {
|
|
if (selectedExportSetting != null){
|
|
ExportSetting es = selectedExportSetting;
|
|
tmExportSettings.removeRow(es);
|
|
}
|
|
}
|
|
});
|
|
bRemove.setEnabled(false);
|
|
toolBar.add(bRemove);
|
|
|
|
separator = new JSeparator();
|
|
toolBar.add(separator);
|
|
|
|
btnExec = new JButton(Messages.getString("Export ausführen"));
|
|
btnExec.setToolTipText(Messages.getString("tooltip.export.run")); //"<html>\n<b>Ausgewählte Exportkonfiguration jetzt ausführen</b><br/>\n</html>");
|
|
btnExec.setEnabled(false);
|
|
btnExec.addActionListener(new ActionListener() {
|
|
public void actionPerformed(ActionEvent e) {
|
|
doExport();
|
|
}
|
|
});
|
|
toolBar.add(btnExec);
|
|
|
|
btnBatch = new JButton(Messages.getString("Automatiklauf"));
|
|
btnBatch.addActionListener(new ActionListener() {
|
|
public void actionPerformed(ActionEvent e) {
|
|
doBatchExport();
|
|
}
|
|
});
|
|
toolBar.add(btnBatch);
|
|
|
|
JScrollPane scrollPane = new JScrollPane();
|
|
scrollPane.setToolTipText(Messages.getString("tooltip.export.list")); // "<html>\n<b>Exportkonfigurationen</b><br/>\nZeigt eine Übersicht über die aktuell vorhandenen Exportkonfigurationen\n</html>");
|
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
|
gbc_scrollPane.gridwidth = 3;
|
|
gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
|
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
|
gbc_scrollPane.gridx = 0;
|
|
gbc_scrollPane.gridy = 1;
|
|
contentPane.add(scrollPane, gbc_scrollPane);
|
|
|
|
tExportSettings = new JTable();
|
|
tExportSettings.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
|
tmExportSettings = new TableMapper(ExportSetting.class, tExportSettings);
|
|
tmExportSettings.addListSelectionListener(new ListSelectionListener() {
|
|
|
|
@Override
|
|
public void valueChanged(ListSelectionEvent e) {
|
|
ExportSetting es = (ExportSetting)tmExportSettings.getSelectedRow();
|
|
setSelectedExportSetting(es);
|
|
}
|
|
});
|
|
tmExportSettings.setRows(PulsCounterApplication.getApplication().getExportSettings());
|
|
scrollPane.setViewportView(tExportSettings);
|
|
|
|
JButton btnSchliessen = new JButton(Messages.getString("schliessen"));
|
|
btnSchliessen.addActionListener(new ActionListener() {
|
|
public void actionPerformed(ActionEvent e) {
|
|
setVisible(false);
|
|
}
|
|
});
|
|
GridBagConstraints gbc_btnSchliessen = new GridBagConstraints();
|
|
gbc_btnSchliessen.gridx = 2;
|
|
gbc_btnSchliessen.gridy = 2;
|
|
contentPane.add(btnSchliessen, gbc_btnSchliessen);
|
|
}
|
|
|
|
public ExportSetting getSelectedExportSetting() {
|
|
return selectedExportSetting;
|
|
}
|
|
public void setSelectedExportSetting(ExportSetting selectedExportSetting) {
|
|
this.selectedExportSetting = selectedExportSetting;
|
|
if (this.selectedExportSetting != null){
|
|
bEdit.setEnabled(true);
|
|
bRemove.setEnabled(true);
|
|
btnExec.setEnabled(true);
|
|
} else {
|
|
bEdit.setEnabled(false);
|
|
bRemove.setEnabled(false);
|
|
btnExec.setEnabled(false);
|
|
}
|
|
}
|
|
|
|
public void doExport(){
|
|
((ExportSetting)tmExportSettings.getSelectedRow()).export();
|
|
}
|
|
|
|
public void doBatchExport(){
|
|
for (ExportSetting es: PulsCounterApplication.getApplication().getExportSettings()){
|
|
if (es.getAutostart()){
|
|
es.export();
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|