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

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

save

File size: 4.3 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;
9import java.util.ArrayList;
10import java.util.Iterator;
11
12import javax.swing.*;
13
14import messages.Messages;
15
16import org.openstreetmap.josm.Main;
17
18import s57.S57att.Att;
19import s57.S57obj.Obj;
20import seamap.SeaMap.*;
21import smed2.Smed2Action;
22
23public class PanelMain extends JPanel {
24
25 public static JTextArea decode = null;
26 public static JTextField messageBar = null;
27 public JButton saveButton = null;
28 private ActionListener alSave = new ActionListener() {
29 public void actionPerformed(java.awt.event.ActionEvent e) {
30 }
31 };
32 private JButton importButton = null;
33 final JFileChooser ifc = new JFileChooser();
34 private ActionListener alImport = new ActionListener() {
35 public void actionPerformed(java.awt.event.ActionEvent e) {
36 if (e.getSource() == importButton) {
37 messageBar.setText("Select file");
38 int returnVal = ifc.showOpenDialog(Main.parent);
39 if (returnVal == JFileChooser.APPROVE_OPTION) {
40 Smed2Action.panelS57.startImport(ifc.getSelectedFile());
41 } else {
42 messageBar.setText("");
43 }
44 }
45 }
46 };
47
48 private JButton exportButton = null;
49 final JFileChooser efc = new JFileChooser();
50 private ActionListener alExport = new ActionListener() {
51 public void actionPerformed(java.awt.event.ActionEvent e) {
52 if (e.getSource() == exportButton) {
53 messageBar.setText("Select file");
54 int returnVal = efc.showOpenDialog(Main.parent);
55 if (returnVal == JFileChooser.APPROVE_OPTION) {
56 Smed2Action.panelS57.startExport(efc.getSelectedFile());
57 } else {
58 messageBar.setText("");
59 }
60 }
61 }
62 };
63
64 public PanelMain() {
65
66 setLayout(null);
67 setSize(new Dimension(480, 480));
68
69 messageBar = new JTextField();
70 messageBar.setBounds(70, 430, 290, 20);
71 messageBar.setEditable(false);
72 messageBar.setBackground(Color.WHITE);
73 add(messageBar);
74 importButton = new JButton(new ImageIcon(getClass().getResource("/images/importButton.png")));
75 importButton.setBounds(10, 430, 20, 20);
76 add(importButton);
77 importButton.addActionListener(alImport);
78 exportButton = new JButton(new ImageIcon(getClass().getResource("/images/exportButton.png")));
79 exportButton.setBounds(40, 430, 20, 20);
80 add(exportButton);
81 exportButton.addActionListener(alExport);
82 saveButton = new JButton();
83 saveButton.setBounds(370, 430, 100, 20);
84 saveButton.setText(tr("Save"));
85 add(saveButton);
86 saveButton.addActionListener(alSave);
87
88 decode = new JTextArea();
89 decode.setBounds(0, 0, 480, 420);
90 decode.setTabSize(1);
91 add(decode);
92 }
93
94 public void parseMark(Feature feature) {
95 decode.setText("Selected feature:\n");
96 decode.append("\t" + tr("Type") + ": " + Messages.getString(feature.type.name()) + "\n");
97 if (feature.atts.get(Att.OBJNAM) != null) {
98 decode.append("\t" + tr("Name") + ": " + feature.atts.get(Att.OBJNAM).val + "\n");
99 }
100 decode.append("\tObjects:\n");
101 for (Obj obj : feature.objs.keySet()) {
102 decode.append("\t\t" + Messages.getString(obj.name()) + "\n");
103 if (feature.objs.get(obj).size() != 0) {
104 for (AttMap atts : feature.objs.get(obj).values()) {
105 for (Att att : atts.keySet()) {
106 AttItem item = atts.get(att);
107 switch (item.conv) {
108 case E:
109 decode.append("\t\t\t" + Messages.getString(att.name()) + ": " + Messages.getString(((Enum)item.val).name()) + "\n");
110 break;
111 case L:
112 decode.append("\t\t\t" + Messages.getString(att.name()) + ": ");
113 Iterator it = ((ArrayList)item.val).iterator();
114 while (it.hasNext()) {
115 Object val = it.next();
116 decode.append(Messages.getString(((Enum)val).name()));
117 if (it.hasNext()) {
118 decode.append(", ");
119 }
120 }
121 decode.append("\n");
122 break;
123 default:
124 decode.append("\t\t\t" + Messages.getString(att.name()) + ": " + item.val + "\n");
125 }
126 }
127 }
128 }
129 }
130 }
131
132 public void clearMark() {
133 decode.setText(tr("No feature selected"));
134 }
135
136 private JRadioButton getButton(JRadioButton button, int x, int y, int w, int h, String title) {
137 button.setBounds(new Rectangle(x, y, w, h));
138 button.setBorder(BorderFactory.createLoweredBevelBorder());
139 button.setText(title);
140 return button;
141 }
142
143}
Note: See TracBrowser for help on using the repository browser.