source: osm/applications/editors/josm/plugins/indoorhelper/src/views/DialogPanel.java@ 32637

Last change on this file since 32637 was 32637, checked in by donvip, 10 years ago

checkstyle

File size: 9.9 KB
Line 
1/*
2 * Indoorhelper is a JOSM plug-in to support users when creating their own indoor maps.
3 * Copyright (C) 2016 Erik Gruschka
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package views;
20
21import static org.openstreetmap.josm.tools.I18n.tr;
22
23import java.awt.BorderLayout;
24import java.awt.GridBagConstraints;
25import java.awt.GridBagLayout;
26import java.awt.Insets;
27import java.awt.event.FocusEvent;
28import java.awt.event.FocusListener;
29
30import javax.swing.DefaultComboBoxModel;
31import javax.swing.JButton;
32import javax.swing.JLabel;
33import javax.swing.JPanel;
34import javax.swing.JSeparator;
35import javax.swing.JToggleButton;
36import javax.swing.border.EmptyBorder;
37
38import org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField;
39import org.openstreetmap.josm.gui.widgets.JosmComboBox;
40
41import model.TagCatalog;
42import model.TagCatalog.IndoorObject;
43
44@SuppressWarnings("serial")
45public class DialogPanel extends JPanel {
46 private JPanel contentPanel;
47 private JToggleButton powerButton;
48 private JLabel levelLabel;
49 private JosmComboBox<String> levelBox;
50 private JLabel levelTagLabel;
51 private DisableShortcutsOnFocusGainedTextField levelTagField;
52 private JLabel objectLabel;
53 private JosmComboBox<TagCatalog.IndoorObject> objectBox;
54 private JLabel nameLabel;
55 private DisableShortcutsOnFocusGainedTextField nameField;
56 private JLabel refLabel;
57 private DisableShortcutsOnFocusGainedTextField refField;
58 private JPanel buttonBar;
59 private JButton applyButton;
60 private JSeparator separator1;
61 private JSeparator separator2;
62
63 /**
64 * Create the panel.
65 */
66 public DialogPanel() {
67 contentPanel = new JPanel();
68 powerButton = new JToggleButton();
69 levelLabel = new JLabel();
70 levelBox = new JosmComboBox<String>();
71 levelTagLabel = new JLabel();
72 levelTagField = new DisableShortcutsOnFocusGainedTextField();
73 objectLabel = new JLabel();
74 objectBox = new JosmComboBox<>();
75 objectBox.setModel(new DefaultComboBoxModel<>(TagCatalog.IndoorObject.values()));
76 nameLabel = new JLabel();
77 nameField = new DisableShortcutsOnFocusGainedTextField();
78 refLabel = new JLabel();
79 refField = new DisableShortcutsOnFocusGainedTextField();
80 buttonBar = new JPanel();
81 applyButton = new JButton();
82 separator1 = new JSeparator();
83 separator2 = new JSeparator();
84
85 //======== this ========
86 //Container contentPane = this.get;
87 //contentPane.setLayout(new BorderLayout());
88
89 //======== dialogPane ========
90 {
91 this.setBorder(new EmptyBorder(12, 12, 12, 12));
92 this.setLayout(new BorderLayout());
93
94 //======== contentPanel ========
95 {
96 contentPanel.setLayout(new GridBagLayout());
97 ((GridBagLayout) contentPanel.getLayout()).columnWidths = new int[] {
98 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
99 ((GridBagLayout) contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0, 0, 0};
100 ((GridBagLayout) contentPanel.getLayout()).columnWeights = new double[] {
101 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
102 ((GridBagLayout) contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
103
104 //---- powerButton ----
105 powerButton.setText(tr("POWER"));
106 powerButton.setToolTipText(tr("Activates the plug-in"));
107 contentPanel.add(powerButton, new GridBagConstraints(8, 0, 4, 1, 0.0, 0.0,
108 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
109 new Insets(0, 0, 5, 5), 0, 0));
110 contentPanel.add(separator1, new GridBagConstraints(1, 1, 12, 1, 0.0, 0.0,
111 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
112 new Insets(0, 0, 5, 5), 0, 0));
113
114 //---- levelLabel ----
115 levelLabel.setText(tr("Working Level"));
116 contentPanel.add(levelLabel, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0,
117 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
118 new Insets(0, 0, 5, 5), 0, 0));
119
120 //---- levelBox ----
121 levelBox.setEnabled(false);
122 levelBox.setEditable(false);
123 levelBox.setToolTipText(tr("Selects the working level."));
124 contentPanel.add(levelBox, new GridBagConstraints(3, 2, 3, 1, 0.0, 0.0,
125 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
126 new Insets(0, 0, 5, 5), 0, 0));
127
128 //---- levelTagLabel ----
129 levelTagLabel.setText(tr("Level Name"));
130 contentPanel.add(levelTagLabel, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0,
131 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
132 new Insets(0, 0, 5, 5), 0, 0));
133
134 //---- levelTagField ----
135 levelTagField.setEnabled(false);
136 levelTagField.setColumns(6);
137 levelTagField.setToolTipText(tr("Optional name-tag for a level."));
138 contentPanel.add(levelTagField, new GridBagConstraints(8, 2, 5, 1, 0.0, 0.0,
139 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
140 new Insets(0, 0, 5, 5), 0, 0));
141 contentPanel.add(separator2, new GridBagConstraints(1, 3, 12, 1, 0.0, 0.0,
142 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
143 new Insets(0, 0, 5, 5), 0, 0));
144
145 //---- objectLabel ----
146 objectLabel.setText(tr("Object"));
147 contentPanel.add(objectLabel, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0,
148 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
149 new Insets(0, 0, 5, 5), 0, 0));
150
151 //---- objectBox ----
152 objectBox.setEnabled(false);
153 objectBox.setPrototypeDisplayValue(IndoorObject.CONCRETE_WALL);
154 objectBox.setToolTipText(tr("The object preset you want to tag."));
155 contentPanel.add(objectBox, new GridBagConstraints(3, 4, 3, 1, 0.0, 0.0,
156 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
157 new Insets(0, 0, 5, 5), 0, 0));
158
159 //---- nameLabel ----
160 nameLabel.setText(tr("Name"));
161 contentPanel.add(nameLabel, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0,
162 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
163 new Insets(0, 0, 5, 5), 0, 0));
164
165 //---- nameField ----
166 nameField.setEnabled(false);
167 nameField.addFocusListener(new FocusListener() {
168
169 @Override
170 public void focusLost(FocusEvent e) {}
171
172 @Override
173 public void focusGained(FocusEvent e) {
174 nameField.selectAll();
175 }
176 });
177 nameField.setToolTipText(tr("Sets the name tag when the room-object is selected."));
178 contentPanel.add(nameField, new GridBagConstraints(3, 5, 3, 1, 0.0, 0.0,
179 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
180 new Insets(0, 0, 5, 5), 0, 0));
181
182 //---- refLabel ----
183 refLabel.setText(tr("Reference"));
184 contentPanel.add(refLabel, new GridBagConstraints(0, 6, 3, 1, 0.0, 0.0,
185 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
186 new Insets(0, 0, 0, 5), 0, 0));
187
188 //---- refField ----
189 refField.setEnabled(false);
190 refField.addFocusListener(new FocusListener() {
191
192 @Override
193 public void focusLost(FocusEvent e) {}
194
195 @Override
196 public void focusGained(FocusEvent e) {
197 refField.selectAll();
198 }
199 });
200 refField.setToolTipText(tr("Sets the ref tag when the room-object is selected."));
201 contentPanel.add(refField, new GridBagConstraints(3, 6, 3, 1, 0.0, 0.0,
202 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
203 new Insets(0, 0, 0, 5), 0, 0));
204 }
205 this.add(contentPanel, BorderLayout.CENTER);
206
207 //======== buttonBar ========
208 {
209 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
210 buttonBar.setLayout(new GridBagLayout());
211 ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 80};
212 ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0};
213
214 //---- applyButton ----
215 applyButton.setText(tr("Apply Tags"));
216 applyButton.setEnabled(false);
217 buttonBar.add(applyButton, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
218 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
219 new Insets(0, 0, 0, 0), 0, 0));
220 }
221 this.add(buttonBar, BorderLayout.SOUTH);
222 }
223 }
224
225}
Note: See TracBrowser for help on using the repository browser.