source: osm/applications/editors/josm/plugins/smed2/src/panels/PanelMain.java@ 29881

Last change on this file since 29881 was 29881, checked in by malcolmh, 11 years ago

save

File size: 5.7 KB
Line 
1package panels;
2
3import static org.openstreetmap.josm.tools.I18n.tr;
4
5import java.awt.Color;
6import java.awt.Dimension;
7import java.awt.Rectangle;
8import java.awt.event.ActionListener;
9
10import javax.swing.*;
11
12import org.openstreetmap.josm.Main;
13
14import smed2.Smed2Action;
15
16public 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 ButtonGroup sectionButtons = null;
57 public JRadioButton eButton = new JRadioButton();
58 public JRadioButton fButton = new JRadioButton();
59 public JRadioButton jButton = new JRadioButton();
60 public JRadioButton kButton = new JRadioButton();
61 public JRadioButton lButton = new JRadioButton();
62 public JRadioButton mButton = new JRadioButton();
63 public JRadioButton nButton = new JRadioButton();
64 public JRadioButton pButton = new JRadioButton();
65 public JRadioButton qButton = new JRadioButton();
66 public JRadioButton rButton = new JRadioButton();
67 public JRadioButton sButton = new JRadioButton();
68 public JRadioButton tButton = new JRadioButton();
69 public JRadioButton uButton = new JRadioButton();
70 private ActionListener alSection = new ActionListener() {
71 public void actionPerformed(java.awt.event.ActionEvent e) {
72 if (eButton.isSelected()) {
73 eButton.setBorderPainted(true);
74 } else {
75 eButton.setBorderPainted(false);
76 }
77 if (fButton.isSelected()) {
78 fButton.setBorderPainted(true);
79 } else {
80 fButton.setBorderPainted(false);
81 }
82 if (jButton.isSelected()) {
83 jButton.setBorderPainted(true);
84 } else {
85 jButton.setBorderPainted(false);
86 }
87 if (kButton.isSelected()) {
88 kButton.setBorderPainted(true);
89 } else {
90 kButton.setBorderPainted(false);
91 }
92 }
93 };
94
95 public PanelMain() {
96
97 setLayout(null);
98 setSize(new Dimension(480, 480));
99
100 messageBar = new JTextField();
101 messageBar.setBounds(70, 430, 290, 20);
102 messageBar.setEditable(false);
103 messageBar.setBackground(Color.WHITE);
104 add(messageBar);
105 importButton = new JButton(new ImageIcon(getClass().getResource("/images/importButton.png")));
106 importButton.setBounds(10, 430, 20, 20);
107 add(importButton);
108 importButton.addActionListener(alImport);
109 exportButton = new JButton(new ImageIcon(getClass().getResource("/images/exportButton.png")));
110 exportButton.setBounds(40, 430, 20, 20);
111 add(exportButton);
112 exportButton.addActionListener(alExport);
113 saveButton = new JButton();
114 saveButton.setBounds(370, 430, 100, 20);
115 saveButton.setText(tr("Save"));
116 add(saveButton);
117 saveButton.addActionListener(alSave);
118
119 add(getButton(eButton, 0, 0, 200, 20, "E Landmarks"), null);
120 add(getButton(fButton, 0, 20, 200, 20, "F Ports"), null);
121 add(getButton(jButton, 0, 40, 200, 20, "J Seabed"), null);
122 add(getButton(kButton, 0, 60, 200, 20, "K Obstructions"), null);
123 add(getButton(lButton, 0, 80, 200, 20, "L Obstructions"), null);
124 add(getButton(mButton, 0, 100, 200, 20, "M Offshore Installations"), null);
125 add(getButton(nButton, 0, 120, 200, 20, "N Areas & Limits"), null);
126 add(getButton(pButton, 0, 140, 200, 20, "P Lights"), null);
127 add(getButton(qButton, 0, 160, 200, 20, "Q Buoys & Beacons"), null);
128 add(getButton(rButton, 0, 180, 200, 20, "R Fog Sigals"), null);
129 add(getButton(sButton, 0, 200, 200, 20, "S Radio & Radar"), null);
130 add(getButton(tButton, 0, 220, 200, 20, "T Services"), null);
131 add(getButton(uButton, 0, 240, 200, 20, "U Small Craft Facilities"), null);
132 sectionButtons = new ButtonGroup();
133 sectionButtons.add(eButton);
134 sectionButtons.add(fButton);
135 sectionButtons.add(jButton);
136 sectionButtons.add(kButton);
137 sectionButtons.add(lButton);
138 sectionButtons.add(mButton);
139 sectionButtons.add(nButton);
140 sectionButtons.add(pButton);
141 sectionButtons.add(qButton);
142 sectionButtons.add(rButton);
143 sectionButtons.add(sButton);
144 sectionButtons.add(tButton);
145 sectionButtons.add(uButton);
146 eButton.addActionListener(alSection);
147 fButton.addActionListener(alSection);
148 jButton.addActionListener(alSection);
149 kButton.addActionListener(alSection);
150 lButton.addActionListener(alSection);
151 mButton.addActionListener(alSection);
152 nButton.addActionListener(alSection);
153 pButton.addActionListener(alSection);
154 qButton.addActionListener(alSection);
155 rButton.addActionListener(alSection);
156 sButton.addActionListener(alSection);
157 tButton.addActionListener(alSection);
158 uButton.addActionListener(alSection);
159 }
160
161 private JRadioButton getButton(JRadioButton button, int x, int y, int w, int h, String title) {
162 button.setBounds(new Rectangle(x, y, w, h));
163 button.setBorder(BorderFactory.createLoweredBevelBorder());
164 button.setText(title);
165 return button;
166 }
167
168}
Note: See TracBrowser for help on using the repository browser.