| 1 | package panels;
|
|---|
| 2 |
|
|---|
| 3 | import static org.openstreetmap.josm.tools.I18n.tr;
|
|---|
| 4 |
|
|---|
| 5 | import java.awt.Color;
|
|---|
| 6 | import java.awt.Dimension;
|
|---|
| 7 | import java.awt.Rectangle;
|
|---|
| 8 | import java.awt.event.ActionListener;
|
|---|
| 9 |
|
|---|
| 10 | import javax.swing.*;
|
|---|
| 11 |
|
|---|
| 12 | import org.openstreetmap.josm.Main;
|
|---|
| 13 |
|
|---|
| 14 | import smed2.Smed2Action;
|
|---|
| 15 |
|
|---|
| 16 | public class PanelMain extends JPanel {
|
|---|
| 17 |
|
|---|
| 18 | public static JTextField messageBar = null;
|
|---|
| 19 | public JButton saveButton = null;
|
|---|
| 20 | private ActionListener alSave = new ActionListener() {
|
|---|
| 21 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
|---|
| 22 | }
|
|---|
| 23 | };
|
|---|
| 24 | private JButton importButton = null;
|
|---|
| 25 | final JFileChooser ifc = new JFileChooser();
|
|---|
| 26 | private ActionListener alImport = new ActionListener() {
|
|---|
| 27 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
|---|
| 28 | if (e.getSource() == importButton) {
|
|---|
| 29 | messageBar.setText("Select file");
|
|---|
| 30 | int returnVal = ifc.showOpenDialog(Main.parent);
|
|---|
| 31 | if (returnVal == JFileChooser.APPROVE_OPTION) {
|
|---|
| 32 | Smed2Action.panelS57.startImport(ifc.getSelectedFile());
|
|---|
| 33 | } else {
|
|---|
| 34 | messageBar.setText("");
|
|---|
| 35 | }
|
|---|
| 36 | }
|
|---|
| 37 | }
|
|---|
| 38 | };
|
|---|
| 39 |
|
|---|
| 40 | private JButton exportButton = null;
|
|---|
| 41 | final JFileChooser efc = new JFileChooser();
|
|---|
| 42 | private ActionListener alExport = new ActionListener() {
|
|---|
| 43 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
|---|
| 44 | if (e.getSource() == exportButton) {
|
|---|
| 45 | messageBar.setText("Select file");
|
|---|
| 46 | int returnVal = efc.showOpenDialog(Main.parent);
|
|---|
| 47 | if (returnVal == JFileChooser.APPROVE_OPTION) {
|
|---|
| 48 | Smed2Action.panelS57.startExport(efc.getSelectedFile());
|
|---|
| 49 | } else {
|
|---|
| 50 | messageBar.setText("");
|
|---|
| 51 | }
|
|---|
| 52 | }
|
|---|
| 53 | }
|
|---|
| 54 | };
|
|---|
| 55 |
|
|---|
| 56 | public PanelMain() {
|
|---|
| 57 |
|
|---|
| 58 | setLayout(null);
|
|---|
| 59 | setSize(new Dimension(480, 480));
|
|---|
| 60 |
|
|---|
| 61 | messageBar = new JTextField();
|
|---|
| 62 | messageBar.setBounds(70, 430, 290, 20);
|
|---|
| 63 | messageBar.setEditable(false);
|
|---|
| 64 | messageBar.setBackground(Color.WHITE);
|
|---|
| 65 | add(messageBar);
|
|---|
| 66 | importButton = new JButton(new ImageIcon(getClass().getResource("/images/importButton.png")));
|
|---|
| 67 | importButton.setBounds(10, 430, 20, 20);
|
|---|
| 68 | add(importButton);
|
|---|
| 69 | importButton.addActionListener(alImport);
|
|---|
| 70 | exportButton = new JButton(new ImageIcon(getClass().getResource("/images/exportButton.png")));
|
|---|
| 71 | exportButton.setBounds(40, 430, 20, 20);
|
|---|
| 72 | add(exportButton);
|
|---|
| 73 | exportButton.addActionListener(alExport);
|
|---|
| 74 | saveButton = new JButton();
|
|---|
| 75 | saveButton.setBounds(370, 430, 100, 20);
|
|---|
| 76 | saveButton.setText(tr("Save"));
|
|---|
| 77 | add(saveButton);
|
|---|
| 78 | saveButton.addActionListener(alSave);
|
|---|
| 79 |
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | private JRadioButton getButton(JRadioButton button, int x, int y, int w, int h, String title) {
|
|---|
| 83 | button.setBounds(new Rectangle(x, y, w, h));
|
|---|
| 84 | button.setBorder(BorderFactory.createLoweredBevelBorder());
|
|---|
| 85 | button.setText(title);
|
|---|
| 86 | return button;
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | }
|
|---|