| 1 | // License: GPL. For details, see LICENSE file.
|
|---|
| 2 | package views;
|
|---|
| 3 |
|
|---|
| 4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
|---|
| 5 |
|
|---|
| 6 | import java.awt.BorderLayout;
|
|---|
| 7 | import java.awt.GridBagConstraints;
|
|---|
| 8 | import java.awt.GridBagLayout;
|
|---|
| 9 | import java.awt.Insets;
|
|---|
| 10 | import java.awt.event.FocusEvent;
|
|---|
| 11 | import java.awt.event.FocusListener;
|
|---|
| 12 |
|
|---|
| 13 | import javax.swing.DefaultComboBoxModel;
|
|---|
| 14 | import javax.swing.JButton;
|
|---|
| 15 | import javax.swing.JLabel;
|
|---|
| 16 | import javax.swing.JPanel;
|
|---|
| 17 | import javax.swing.JSeparator;
|
|---|
| 18 | import javax.swing.JToggleButton;
|
|---|
| 19 | import javax.swing.border.EmptyBorder;
|
|---|
| 20 |
|
|---|
| 21 | import org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField;
|
|---|
| 22 | import org.openstreetmap.josm.gui.widgets.JosmComboBox;
|
|---|
| 23 |
|
|---|
| 24 | import model.TagCatalog;
|
|---|
| 25 | import model.TagCatalog.IndoorObject;
|
|---|
| 26 |
|
|---|
| 27 | @SuppressWarnings("serial")
|
|---|
| 28 | public class DialogPanel extends JPanel {
|
|---|
| 29 | private JPanel contentPanel;
|
|---|
| 30 | private JToggleButton powerButton;
|
|---|
| 31 | private JLabel levelLabel;
|
|---|
| 32 | private JosmComboBox<String> levelBox;
|
|---|
| 33 | private JLabel levelTagLabel;
|
|---|
| 34 | private DisableShortcutsOnFocusGainedTextField levelTagField;
|
|---|
| 35 | private JLabel objectLabel;
|
|---|
| 36 | private JosmComboBox<TagCatalog.IndoorObject> objectBox;
|
|---|
| 37 | private JLabel nameLabel;
|
|---|
| 38 | private DisableShortcutsOnFocusGainedTextField nameField;
|
|---|
| 39 | private JLabel refLabel;
|
|---|
| 40 | private DisableShortcutsOnFocusGainedTextField refField;
|
|---|
| 41 | private JPanel buttonBar;
|
|---|
| 42 | private JButton applyButton;
|
|---|
| 43 | private JSeparator separator1;
|
|---|
| 44 | private JSeparator separator2;
|
|---|
| 45 |
|
|---|
| 46 | /**
|
|---|
| 47 | * Create the panel.
|
|---|
| 48 | */
|
|---|
| 49 | public DialogPanel() {
|
|---|
| 50 | contentPanel = new JPanel();
|
|---|
| 51 | powerButton = new JToggleButton();
|
|---|
| 52 | levelLabel = new JLabel();
|
|---|
| 53 | levelBox = new JosmComboBox<>();
|
|---|
| 54 | levelTagLabel = new JLabel();
|
|---|
| 55 | levelTagField = new DisableShortcutsOnFocusGainedTextField();
|
|---|
| 56 | objectLabel = new JLabel();
|
|---|
| 57 | objectBox = new JosmComboBox<>();
|
|---|
| 58 | objectBox.setModel(new DefaultComboBoxModel<>(TagCatalog.IndoorObject.values()));
|
|---|
| 59 | nameLabel = new JLabel();
|
|---|
| 60 | nameField = new DisableShortcutsOnFocusGainedTextField();
|
|---|
| 61 | refLabel = new JLabel();
|
|---|
| 62 | refField = new DisableShortcutsOnFocusGainedTextField();
|
|---|
| 63 | buttonBar = new JPanel();
|
|---|
| 64 | applyButton = new JButton();
|
|---|
| 65 | separator1 = new JSeparator();
|
|---|
| 66 | separator2 = new JSeparator();
|
|---|
| 67 |
|
|---|
| 68 | //======== this ========
|
|---|
| 69 | //Container contentPane = this.get;
|
|---|
| 70 | //contentPane.setLayout(new BorderLayout());
|
|---|
| 71 |
|
|---|
| 72 | //======== dialogPane ========
|
|---|
| 73 |
|
|---|
| 74 | this.setBorder(new EmptyBorder(12, 12, 12, 12));
|
|---|
| 75 | this.setLayout(new BorderLayout());
|
|---|
| 76 |
|
|---|
| 77 | //======== contentPanel ========
|
|---|
| 78 |
|
|---|
| 79 | contentPanel.setLayout(new GridBagLayout());
|
|---|
| 80 | ((GridBagLayout) contentPanel.getLayout()).columnWidths = new int[] {
|
|---|
| 81 | 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};
|
|---|
| 82 | ((GridBagLayout) contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0, 0, 0};
|
|---|
| 83 | ((GridBagLayout) contentPanel.getLayout()).columnWeights = new double[] {
|
|---|
| 84 | 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,
|
|---|
| 85 | 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};
|
|---|
| 86 | ((GridBagLayout) contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
|
|---|
| 87 |
|
|---|
| 88 | //---- powerButton ----
|
|---|
| 89 | powerButton.setText(tr("POWER"));
|
|---|
| 90 | powerButton.setToolTipText(tr("Activates the plug-in"));
|
|---|
| 91 | contentPanel.add(powerButton, new GridBagConstraints(8, 0, 4, 1, 0.0, 0.0,
|
|---|
| 92 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 93 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 94 | contentPanel.add(separator1, new GridBagConstraints(1, 1, 12, 1, 0.0, 0.0,
|
|---|
| 95 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 96 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 97 |
|
|---|
| 98 | //---- levelLabel ----
|
|---|
| 99 | levelLabel.setText(tr("Working Level"));
|
|---|
| 100 | contentPanel.add(levelLabel, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0,
|
|---|
| 101 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 102 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 103 |
|
|---|
| 104 | //---- levelBox ----
|
|---|
| 105 | levelBox.setEnabled(false);
|
|---|
| 106 | levelBox.setEditable(false);
|
|---|
| 107 | levelBox.setToolTipText(tr("Selects the working level."));
|
|---|
| 108 | contentPanel.add(levelBox, new GridBagConstraints(3, 2, 3, 1, 0.0, 0.0,
|
|---|
| 109 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 110 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 111 |
|
|---|
| 112 | //---- levelTagLabel ----
|
|---|
| 113 | levelTagLabel.setText(tr("Level Name"));
|
|---|
| 114 | contentPanel.add(levelTagLabel, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0,
|
|---|
| 115 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 116 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 117 |
|
|---|
| 118 | //---- levelTagField ----
|
|---|
| 119 | levelTagField.setEnabled(false);
|
|---|
| 120 | levelTagField.setColumns(6);
|
|---|
| 121 | levelTagField.setToolTipText(tr("Optional name-tag for a level."));
|
|---|
| 122 | contentPanel.add(levelTagField, new GridBagConstraints(8, 2, 5, 1, 0.0, 0.0,
|
|---|
| 123 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 124 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 125 | contentPanel.add(separator2, new GridBagConstraints(1, 3, 12, 1, 0.0, 0.0,
|
|---|
| 126 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 127 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 128 |
|
|---|
| 129 | //---- objectLabel ----
|
|---|
| 130 | objectLabel.setText(tr("Object"));
|
|---|
| 131 | contentPanel.add(objectLabel, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0,
|
|---|
| 132 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 133 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 134 |
|
|---|
| 135 | //---- objectBox ----
|
|---|
| 136 | objectBox.setEnabled(false);
|
|---|
| 137 | objectBox.setPrototypeDisplayValue(IndoorObject.CONCRETE_WALL);
|
|---|
| 138 | objectBox.setToolTipText(tr("The object preset you want to tag."));
|
|---|
| 139 | contentPanel.add(objectBox, new GridBagConstraints(3, 4, 3, 1, 0.0, 0.0,
|
|---|
| 140 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 141 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 142 |
|
|---|
| 143 | //---- nameLabel ----
|
|---|
| 144 | nameLabel.setText(tr("Name"));
|
|---|
| 145 | contentPanel.add(nameLabel, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0,
|
|---|
| 146 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 147 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 148 |
|
|---|
| 149 | //---- nameField ----
|
|---|
| 150 | nameField.setEnabled(false);
|
|---|
| 151 | nameField.addFocusListener(new FocusListener() {
|
|---|
| 152 |
|
|---|
| 153 | @Override
|
|---|
| 154 | public void focusLost(FocusEvent e) {}
|
|---|
| 155 |
|
|---|
| 156 | @Override
|
|---|
| 157 | public void focusGained(FocusEvent e) {
|
|---|
| 158 | nameField.selectAll();
|
|---|
| 159 | }
|
|---|
| 160 | });
|
|---|
| 161 | nameField.setToolTipText(tr("Sets the name tag when the room-object is selected."));
|
|---|
| 162 | contentPanel.add(nameField, new GridBagConstraints(3, 5, 3, 1, 0.0, 0.0,
|
|---|
| 163 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 164 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 165 |
|
|---|
| 166 | //---- refLabel ----
|
|---|
| 167 | refLabel.setText(tr("Reference"));
|
|---|
| 168 | contentPanel.add(refLabel, new GridBagConstraints(0, 6, 3, 1, 0.0, 0.0,
|
|---|
| 169 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 170 | new Insets(0, 0, 0, 5), 0, 0));
|
|---|
| 171 |
|
|---|
| 172 | //---- refField ----
|
|---|
| 173 | refField.setEnabled(false);
|
|---|
| 174 | refField.addFocusListener(new FocusListener() {
|
|---|
| 175 |
|
|---|
| 176 | @Override
|
|---|
| 177 | public void focusLost(FocusEvent e) {}
|
|---|
| 178 |
|
|---|
| 179 | @Override
|
|---|
| 180 | public void focusGained(FocusEvent e) {
|
|---|
| 181 | refField.selectAll();
|
|---|
| 182 | }
|
|---|
| 183 | });
|
|---|
| 184 | refField.setToolTipText(tr("Sets the ref tag when the room-object is selected."));
|
|---|
| 185 | contentPanel.add(refField, new GridBagConstraints(3, 6, 3, 1, 0.0, 0.0,
|
|---|
| 186 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 187 | new Insets(0, 0, 0, 5), 0, 0));
|
|---|
| 188 |
|
|---|
| 189 | this.add(contentPanel, BorderLayout.CENTER);
|
|---|
| 190 |
|
|---|
| 191 | //======== buttonBar ========
|
|---|
| 192 |
|
|---|
| 193 | buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
|
|---|
| 194 | buttonBar.setLayout(new GridBagLayout());
|
|---|
| 195 | ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 80};
|
|---|
| 196 | ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0};
|
|---|
| 197 |
|
|---|
| 198 | //---- applyButton ----
|
|---|
| 199 | applyButton.setText(tr("Apply Tags"));
|
|---|
| 200 | applyButton.setEnabled(false);
|
|---|
| 201 | buttonBar.add(applyButton, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
|
|---|
| 202 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 203 | new Insets(0, 0, 0, 0), 0, 0));
|
|---|
| 204 |
|
|---|
| 205 | this.add(buttonBar, BorderLayout.SOUTH);
|
|---|
| 206 | }
|
|---|
| 207 | }
|
|---|