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

Last change on this file since 32122 was 32122, checked in by erigrus, 9 years ago

initial commit

File size: 8.3 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[] {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};
98 ((GridBagLayout)contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0, 0, 0};
99 ((GridBagLayout)contentPanel.getLayout()).columnWeights = new double[] {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};
100 ((GridBagLayout)contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
101
102 //---- powerButton ----
103 powerButton.setText(tr("POWER"));
104 powerButton.setToolTipText(tr("Activates the plug-in"));
105 contentPanel.add(powerButton, new GridBagConstraints(8, 0, 4, 1, 0.0, 0.0,
106 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
107 new Insets(0, 0, 5, 5), 0, 0));
108 contentPanel.add(separator1, new GridBagConstraints(1, 1, 12, 1, 0.0, 0.0,
109 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
110 new Insets(0, 0, 5, 5), 0, 0));
111
112 //---- levelLabel ----
113 levelLabel.setText(tr("Working Level"));
114 contentPanel.add(levelLabel, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0,
115 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
116 new Insets(0, 0, 5, 5), 0, 0));
117
118 //---- levelBox ----
119 levelBox.setEnabled(false);
120 levelBox.setEditable(false);
121 levelBox.setToolTipText(tr("Selects the working level."));
122 contentPanel.add(levelBox, new GridBagConstraints(3, 2, 3, 1, 0.0, 0.0,
123 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
124 new Insets(0, 0, 5, 5), 0, 0));
125
126 //---- levelTagLabel ----
127 levelTagLabel.setText(tr("Level Name"));
128 contentPanel.add(levelTagLabel, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0,
129 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
130 new Insets(0, 0, 5, 5), 0, 0));
131
132 //---- levelTagField ----
133 levelTagField.setEnabled(false);
134 levelTagField.setColumns(6);
135 levelTagField.setToolTipText(tr("Optional name-tag for a level."));
136 contentPanel.add(levelTagField, new GridBagConstraints(8, 2, 5, 1, 0.0, 0.0,
137 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
138 new Insets(0, 0, 5, 5), 0, 0));
139 contentPanel.add(separator2, new GridBagConstraints(1, 3, 12, 1, 0.0, 0.0,
140 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
141 new Insets(0, 0, 5, 5), 0, 0));
142
143 //---- objectLabel ----
144 objectLabel.setText(tr("Object"));
145 contentPanel.add(objectLabel, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0,
146 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
147 new Insets(0, 0, 5, 5), 0, 0));
148
149 //---- objectBox ----
150 objectBox.setEnabled(false);
151 objectBox.setPrototypeDisplayValue(IndoorObject.CONCRETE_WALL);
152 objectBox.setToolTipText(tr("The object preset you want to tag."));
153 contentPanel.add(objectBox, new GridBagConstraints(3, 4, 3, 1, 0.0, 0.0,
154 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
155 new Insets(0, 0, 5, 5), 0, 0));
156
157 //---- nameLabel ----
158 nameLabel.setText(tr("Name"));
159 contentPanel.add(nameLabel, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0,
160 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
161 new Insets(0, 0, 5, 5), 0, 0));
162
163 //---- nameField ----
164 nameField.setEnabled(false);
165 nameField.addFocusListener(new FocusListener() {
166
167 @Override
168 public void focusLost(FocusEvent e) {}
169
170 @Override
171 public void focusGained(FocusEvent e) {
172 nameField.selectAll();
173 }
174 });
175 nameField.setToolTipText(tr("Sets the name tag when the room-object is selected."));
176 contentPanel.add(nameField, new GridBagConstraints(3, 5, 3, 1, 0.0, 0.0,
177 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
178 new Insets(0, 0, 5, 5), 0, 0));
179
180 //---- refLabel ----
181 refLabel.setText(tr("Reference"));
182 contentPanel.add(refLabel, new GridBagConstraints(0, 6, 3, 1, 0.0, 0.0,
183 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
184 new Insets(0, 0, 0, 5), 0, 0));
185
186 //---- refField ----
187 refField.setEnabled(false);
188 refField.addFocusListener(new FocusListener() {
189
190 @Override
191 public void focusLost(FocusEvent e) {}
192
193 @Override
194 public void focusGained(FocusEvent e) {
195 refField.selectAll();
196 }
197 });
198 refField.setToolTipText(tr("Sets the ref tag when the room-object is selected."));
199 contentPanel.add(refField, new GridBagConstraints(3, 6, 3, 1, 0.0, 0.0,
200 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
201 new Insets(0, 0, 0, 5), 0, 0));
202 }
203 this.add(contentPanel, BorderLayout.CENTER);
204
205 //======== buttonBar ========
206 {
207 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
208 buttonBar.setLayout(new GridBagLayout());
209 ((GridBagLayout)buttonBar.getLayout()).columnWidths = new int[] {0, 80};
210 ((GridBagLayout)buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0};
211
212 //---- applyButton ----
213 applyButton.setText(tr("Apply Tags"));
214 applyButton.setEnabled(false);
215 buttonBar.add(applyButton, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
216 GridBagConstraints.CENTER, GridBagConstraints.BOTH,
217 new Insets(0, 0, 0, 0), 0, 0));
218 }
219 this.add(buttonBar, BorderLayout.SOUTH);
220 }
221 }
222
223}
Note: See TracBrowser for help on using the repository browser.