Changeset 32637 in osm for applications/editors/josm/plugins/indoorhelper/src/views
- Timestamp:
- 2016-07-11T22:48:15+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/indoorhelper/src/views
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/indoorhelper/src/views/DialogPanel.java
r32122 r32637 44 44 @SuppressWarnings("serial") 45 45 public 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 } 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 } 222 224 223 225 } -
applications/editors/josm/plugins/indoorhelper/src/views/FittingView.java
r32122 r32637 21 21 import static org.openstreetmap.josm.tools.I18n.tr; 22 22 23 import java.awt.*; 23 import java.awt.BorderLayout; 24 import java.awt.Container; 25 import java.awt.FlowLayout; 26 import java.awt.GridBagConstraints; 27 import java.awt.GridBagLayout; 28 import java.awt.Insets; 24 29 import java.awt.event.ActionListener; 25 30 26 import javax.swing.*; 27 import javax.swing.border.*; 31 import javax.swing.JButton; 32 import javax.swing.JFrame; 33 import javax.swing.JLabel; 34 import javax.swing.JPanel; 35 import javax.swing.border.EmptyBorder; 28 36 29 37 … … 31 39 * The view for the pop-up hint that tells the user, that he has to start the fitting 32 40 * of his indoor building plans. 33 * 41 * 34 42 * @author egru 35 43 */ 36 44 @SuppressWarnings("serial") 37 45 public class FittingView extends JFrame { 38 39 private JPanel dialogPane;40 private JPanel contentPanel;41 private JLabel label1;42 private JPanel buttonBar;43 private JButton okButton;44 45 public FittingView() {46 initComponents();47 }48 46 49 private void initComponents() { 50 dialogPane = new JPanel(); 51 contentPanel = new JPanel(); 52 label1 = new JLabel(); 53 buttonBar = new JPanel(); 54 okButton = new JButton(); 47 private JPanel dialogPane; 48 private JPanel contentPanel; 49 private JLabel label1; 50 private JPanel buttonBar; 51 private JButton okButton; 55 52 56 //======== this ======== 57 setTitle(tr("Fitting")); 58 Container contentPane = getContentPane(); 59 contentPane.setLayout(new BorderLayout()); 53 public FittingView() { 54 initComponents(); 55 } 60 56 61 //======== dialogPane ======== 62 { 63 dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12)); 64 dialogPane.setLayout(new BorderLayout()); 57 private void initComponents() { 58 dialogPane = new JPanel(); 59 contentPanel = new JPanel(); 60 label1 = new JLabel(); 61 buttonBar = new JPanel(); 62 okButton = new JButton(); 65 63 66 //======== contentPanel ======== 67 { 68 contentPanel.setLayout(new FlowLayout()); 64 //======== this ======== 65 setTitle(tr("Fitting")); 66 Container contentPane = getContentPane(); 67 contentPane.setLayout(new BorderLayout()); 69 68 70 //---- label1 ---- 71 label1.setText(tr("<html>Please mind to start fitting your building-plans now.<br>" + 72 "To do so, use the PicLayer plug-in, which you can install<br>" + 73 "using the JOSM plug-in management.</html>")); 74 contentPanel.add(label1); 75 } 76 dialogPane.add(contentPanel, BorderLayout.CENTER); 69 //======== dialogPane ======== 70 { 71 dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12)); 72 dialogPane.setLayout(new BorderLayout()); 77 73 78 //======== buttonBar ======== 79 { 80 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); 81 buttonBar.setLayout(new GridBagLayout()); 82 ((GridBagLayout)buttonBar.getLayout()).columnWidths = new int[] {0, 80}; 83 ((GridBagLayout)buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0}; 74 //======== contentPanel ======== 75 { 76 contentPanel.setLayout(new FlowLayout()); 84 77 85 //---- okButton ---- 86 okButton.setText(tr("OK")); 87 buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, 88 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 89 new Insets(0, 0, 0, 0), 0, 0)); 90 } 91 dialogPane.add(buttonBar, BorderLayout.SOUTH); 92 } 93 contentPane.add(dialogPane, BorderLayout.CENTER); 94 pack(); 95 setLocationRelativeTo(getOwner()); 96 } 97 98 /** 99 * Set the given {@link ActionListener} to the OK-Button of the {@link FittingView}. 100 * 101 * @param l the listener which should be set 102 */ 103 public void setOkButtonListener(ActionListener l){ 104 this.okButton.addActionListener(l); 105 } 78 //---- label1 ---- 79 label1.setText(tr("<html>Please mind to start fitting your building-plans now.<br>" + 80 "To do so, use the PicLayer plug-in, which you can install<br>" + 81 "using the JOSM plug-in management.</html>")); 82 contentPanel.add(label1); 83 } 84 dialogPane.add(contentPanel, BorderLayout.CENTER); 85 86 //======== buttonBar ======== 87 { 88 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); 89 buttonBar.setLayout(new GridBagLayout()); 90 ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 80}; 91 ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0}; 92 93 //---- okButton ---- 94 okButton.setText(tr("OK")); 95 buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, 96 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 97 new Insets(0, 0, 0, 0), 0, 0)); 98 } 99 dialogPane.add(buttonBar, BorderLayout.SOUTH); 100 } 101 contentPane.add(dialogPane, BorderLayout.CENTER); 102 pack(); 103 setLocationRelativeTo(getOwner()); 104 } 105 106 /** 107 * Set the given {@link ActionListener} to the OK-Button of the {@link FittingView}. 108 * 109 * @param l the listener which should be set 110 */ 111 public void setOkButtonListener(ActionListener l) { 112 this.okButton.addActionListener(l); 113 } 106 114 } -
applications/editors/josm/plugins/indoorhelper/src/views/LevelSelectorView.java
r32122 r32637 21 21 import static org.openstreetmap.josm.tools.I18n.tr; 22 22 23 import java.awt.*; 23 import java.awt.BorderLayout; 24 import java.awt.Container; 25 import java.awt.GridBagConstraints; 26 import java.awt.GridBagLayout; 27 import java.awt.Insets; 24 28 import java.awt.event.ActionListener; 25 29 26 import javax.swing.*; 30 import javax.swing.JButton; 31 import javax.swing.JFrame; 32 import javax.swing.JLabel; 33 import javax.swing.JPanel; 34 import javax.swing.JSpinner; 27 35 import javax.swing.JSpinner.DefaultEditor; 28 import javax.swing.border. *;36 import javax.swing.border.EmptyBorder; 29 37 30 38 /** 31 39 * Class for the pop-up window which provides an level selector to get a user input. 32 40 * In this window the user declares the lowest and the highest level of the building he wants to map. 33 * 41 * 34 42 * @author egru 35 43 * … … 38 46 @SuppressWarnings("serial") 39 47 public class LevelSelectorView extends JFrame { 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 * 161 162 163 164 165 166 167 168 169 * 170 171 172 173 174 175 176 177 178 * 179 180 181 182 183 184 185 186 187 * 188 189 190 191 192 48 49 private JPanel dialogPane; 50 private JPanel contentPanel; 51 private JLabel minLabel; 52 private JSpinner minSpinner; 53 private JLabel maxLabel; 54 private JSpinner maxSpinner; 55 private JPanel buttonBar; 56 private JButton okButton; 57 private JButton cancelButton; 58 59 public LevelSelectorView() { 60 initComponents(); 61 } 62 63 private void initComponents() { 64 dialogPane = new JPanel(); 65 contentPanel = new JPanel(); 66 minLabel = new JLabel(); 67 minSpinner = new JSpinner(); 68 maxLabel = new JLabel(); 69 maxSpinner = new JSpinner(); 70 buttonBar = new JPanel(); 71 okButton = new JButton(); 72 cancelButton = new JButton(); 73 74 //======== this ======== 75 setTitle(tr("Level Selection")); 76 Container contentPane = getContentPane(); 77 contentPane.setLayout(new BorderLayout()); 78 79 //======== dialogPane ======== 80 { 81 dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12)); 82 dialogPane.setLayout(new BorderLayout()); 83 84 //======== contentPanel ======== 85 { 86 contentPanel.setLayout(new GridBagLayout()); 87 ((GridBagLayout) contentPanel.getLayout()).columnWidths = new int[] {0, 0, 0, 0, 0}; 88 ((GridBagLayout) contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0}; 89 ((GridBagLayout) contentPanel.getLayout()).columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 1.0E-4}; 90 ((GridBagLayout) contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4}; 91 92 //---- minLabel ---- 93 minLabel.setText(tr("Lowest Level")); 94 contentPanel.add(maxLabel, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, 95 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 96 new Insets(0, 0, 5, 5), 0, 0)); 97 JSpinner.DefaultEditor minEditor = (DefaultEditor) maxSpinner.getEditor(); 98 minEditor.getTextField().setColumns(2); 99 maxSpinner.setToolTipText(tr("The lowest level of your building.")); 100 contentPanel.add(maxSpinner, new GridBagConstraints(2, 0, 2, 1, 0.0, 0.0, 101 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 102 new Insets(0, 0, 5, 0), 0, 0)); 103 104 //---- maxLabel ---- 105 maxLabel.setText(tr("Highest Level")); 106 contentPanel.add(minLabel, new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0, 107 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 108 new Insets(0, 0, 5, 5), 0, 0)); 109 JSpinner.DefaultEditor maxEditor = (DefaultEditor) minSpinner.getEditor(); 110 maxEditor.getTextField().setColumns(2); 111 minSpinner.setToolTipText(tr("The highest level of your building.")); 112 contentPanel.add(minSpinner, new GridBagConstraints(2, 2, 2, 1, 0.0, 0.0, 113 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 114 new Insets(0, 0, 5, 0), 0, 0)); 115 } 116 dialogPane.add(contentPanel, BorderLayout.CENTER); 117 118 //======== buttonBar ======== 119 { 120 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); 121 buttonBar.setLayout(new GridBagLayout()); 122 ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 85, 80}; 123 ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0, 0.0}; 124 125 //---- okButton ---- 126 okButton.setText(tr("OK")); 127 buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, 128 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 129 new Insets(0, 0, 0, 5), 0, 0)); 130 131 //---- cancelButton ---- 132 cancelButton.setText(tr("Cancel")); 133 buttonBar.add(cancelButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, 134 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 135 new Insets(0, 0, 0, 0), 0, 0)); 136 } 137 dialogPane.add(contentPanel, BorderLayout.CENTER); 138 139 //======== buttonBar ======== 140 { 141 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); 142 buttonBar.setLayout(new GridBagLayout()); 143 ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 85, 80}; 144 ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0, 0.0}; 145 146 //---- okButton ---- 147 okButton.setText(tr("OK")); 148 buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, 149 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 150 new Insets(0, 0, 0, 5), 0, 0)); 151 152 //---- cancelButton ---- 153 cancelButton.setText(tr("Cancel")); 154 buttonBar.add(cancelButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, 155 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 156 new Insets(0, 0, 0, 0), 0, 0)); 157 } 158 dialogPane.add(buttonBar, BorderLayout.SOUTH); 159 } 160 contentPane.add(dialogPane, BorderLayout.CENTER); 161 pack(); 162 setLocationRelativeTo(getOwner()); 163 164 } 165 166 /** 167 * Set the listener for the OK button. 168 * 169 * @param l the listener to set 170 */ 171 public void setOkButtonListener(ActionListener l) { 172 this.okButton.addActionListener(l); 173 } 174 175 /** 176 * Set the listener for the cancel button. 177 * 178 * @param l the listener to set 179 */ 180 public void setCancelButtonListener(ActionListener l) { 181 this.cancelButton.addActionListener(l); 182 } 183 184 /** 185 * Getter for the lowest level. 186 * 187 * @return Integer which represents the lowest level of the building. 188 */ 189 public int getMin() { 190 return (int) this.minSpinner.getValue(); 191 } 192 193 /** 194 * Getter for the highest level. 195 * 196 * @return Integer which represents the highest level of the building. 197 */ 198 public int getMax() { 199 return (int) this.maxSpinner.getValue(); 200 } 193 201 } -
applications/editors/josm/plugins/indoorhelper/src/views/PresetButton.java
r32122 r32637 20 20 21 21 import javax.swing.JButton; 22 22 23 import model.TagCatalog.IndoorObject; 23 24 … … 30 31 @SuppressWarnings("serial") 31 32 class PresetButton extends JButton { 32 33 34 35 publicPresetButton(IndoorObject object){36 37 38 39 40 41 42 43 44 45 46 47 33 34 private IndoorObject indoorObject; 35 36 PresetButton(IndoorObject object) { 37 this.setIndoorObject(object); 38 } 39 40 public IndoorObject getIndoorObject() { 41 return this.indoorObject; 42 } 43 44 public void setIndoorObject(IndoorObject object) { 45 this.indoorObject = object; 46 this.setText(indoorObject.toString()); 47 this.setToolTipText(indoorObject.toString()); 48 } 48 49 49 50 } -
applications/editors/josm/plugins/indoorhelper/src/views/ToolBoxView.java
r32122 r32637 21 21 import static org.openstreetmap.josm.tools.I18n.tr; 22 22 23 import java.awt.*; 23 import java.awt.BorderLayout; 24 import java.awt.GridBagConstraints; 25 import java.awt.GridBagLayout; 26 import java.awt.Insets; 27 import java.awt.TextField; 24 28 import java.awt.event.ActionListener; 25 29 import java.awt.event.FocusEvent; … … 29 33 import java.util.ListIterator; 30 34 31 import javax.swing.*; 32 import javax.swing.border.*; 35 import javax.swing.JButton; 36 import javax.swing.JLabel; 37 import javax.swing.JPanel; 38 import javax.swing.JSeparator; 39 import javax.swing.JToggleButton; 40 import javax.swing.border.EmptyBorder; 41 33 42 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; 34 43 import org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField; … … 40 49 41 50 /** 42 * 51 * 43 52 * This is the main toolbox of the indoorhelper plug-in. 44 * 53 * 45 54 * @author egru 46 55 * 47 56 */ 48 57 @SuppressWarnings("serial") 49 public class ToolBoxView extends ToggleDialog{ 50 private JPanel dialogPane; 51 private JPanel contentPanel; 52 private JToggleButton powerButton; 53 private JLabel levelLabel; 54 private JosmComboBox<String> levelBox; 55 private JLabel levelTagLabel; 56 private DisableShortcutsOnFocusGainedTextField levelTagField; 57 private JLabel objectLabel; 58 private JosmComboBox<TagCatalog.IndoorObject> objectBox; 59 private JLabel nameLabel; 60 private DisableShortcutsOnFocusGainedTextField nameField; 61 private JLabel refLabel; 62 private DisableShortcutsOnFocusGainedTextField refField; 63 private JPanel buttonBar; 64 private JButton applyButton; 65 private JSeparator separator1; 66 private JSeparator separator2; 67 private PresetButton preset1; 68 private PresetButton preset2; 69 private PresetButton preset3; 70 private PresetButton preset4; 71 72 public ToolBoxView(){ 73 super(tr("Indoor Mapping Helper"), "indoorhelper", 74 tr("Toolbox for indoor mapping assistance"), null, 300, true); 75 76 initComponents(); 77 } 78 79 /** 80 * Creates the layout of the plug-in. 81 */ 82 private void initComponents() { 83 dialogPane = new JPanel(); 84 contentPanel = new JPanel(); 85 powerButton = new JToggleButton(); 86 levelLabel = new JLabel(); 87 levelBox = new JosmComboBox<String>(); 88 levelTagLabel = new JLabel(); 89 levelTagField = new DisableShortcutsOnFocusGainedTextField(); 90 objectLabel = new JLabel(); 91 objectBox = new JosmComboBox<>(TagCatalog.IndoorObject.values()); 92 nameLabel = new JLabel(); 93 nameField = new DisableShortcutsOnFocusGainedTextField(); 94 refLabel = new JLabel(); 95 refField = new DisableShortcutsOnFocusGainedTextField(); 96 buttonBar = new JPanel(); 97 applyButton = new JButton(); 98 separator1 = new JSeparator(); 99 separator2 = new JSeparator(); 100 preset1 = new PresetButton(IndoorObject.ROOM); 101 preset2 = new PresetButton(IndoorObject.SHELL); 102 preset3 = new PresetButton(IndoorObject.CONCRETE_WALL); 103 preset4 = new PresetButton(IndoorObject.GLASS_WALL); 104 105 //======== this ======== 106 //Container contentPane = this.get; 107 //contentPane.setLayout(new BorderLayout()); 108 109 //======== dialogPane ======== 110 { 111 dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12)); 112 dialogPane.setLayout(new BorderLayout()); 113 114 //======== contentPanel ======== 115 { 116 contentPanel.setLayout(new GridBagLayout()); 117 ((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}; 118 ((GridBagLayout)contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0, 0, 0}; 119 ((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}; 120 ((GridBagLayout)contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4}; 121 122 //---- powerButton ---- 123 powerButton.setText(tr("POWER")); 124 powerButton.setToolTipText(tr("Activates the plug-in")); 125 contentPanel.add(powerButton, new GridBagConstraints(8, 0, 4, 1, 0.0, 0.0, 126 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 127 new Insets(0, 0, 5, 5), 0, 0)); 128 contentPanel.add(separator1, new GridBagConstraints(1, 1, 12, 1, 0.0, 0.0, 129 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 130 new Insets(0, 0, 5, 5), 0, 0)); 131 132 //---- levelLabel ---- 133 levelLabel.setText(tr("Working Level")); 134 contentPanel.add(levelLabel, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0, 135 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 136 new Insets(0, 0, 5, 5), 0, 0)); 137 138 //---- levelBox ---- 139 levelBox.setEnabled(false); 140 levelBox.setEditable(false); 141 levelBox.setToolTipText(tr("Selects the working level.")); 142 contentPanel.add(levelBox, new GridBagConstraints(3, 2, 3, 1, 0.0, 0.0, 143 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 144 new Insets(0, 0, 5, 5), 0, 0)); 145 146 //---- levelTagLabel ---- 147 levelTagLabel.setText(tr("Level Name")); 148 contentPanel.add(levelTagLabel, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0, 149 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 150 new Insets(0, 0, 5, 5), 0, 0)); 151 152 //---- levelTagField ---- 153 levelTagField.setEnabled(false); 154 levelTagField.setColumns(6); 155 levelTagField.setToolTipText(tr("Optional name-tag for a level.")); 156 contentPanel.add(levelTagField, new GridBagConstraints(8, 2, 5, 1, 0.0, 0.0, 157 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 158 new Insets(0, 0, 5, 5), 0, 0)); 159 contentPanel.add(separator2, new GridBagConstraints(1, 3, 12, 1, 0.0, 0.0, 160 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 161 new Insets(0, 0, 5, 5), 0, 0)); 162 163 //---- objectLabel ---- 164 objectLabel.setText(tr("Object")); 165 contentPanel.add(objectLabel, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0, 166 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 167 new Insets(0, 0, 5, 5), 0, 0)); 168 169 //---- objectBox ---- 170 objectBox.setEnabled(false); 171 objectBox.setPrototypeDisplayValue(IndoorObject.CONCRETE_WALL); 172 objectBox.setToolTipText(tr("The object preset you want to tag.")); 173 contentPanel.add(objectBox, new GridBagConstraints(3, 4, 3, 1, 0.0, 0.0, 174 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 175 new Insets(0, 0, 5, 5), 0, 0)); 176 177 //---- nameLabel ---- 178 nameLabel.setText(tr("Name")); 179 contentPanel.add(nameLabel, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0, 180 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 181 new Insets(0, 0, 5, 5), 0, 0)); 182 183 //---- nameField ---- 184 nameField.setEnabled(false); 185 nameField.addFocusListener(new FocusListener() { 186 187 @Override 188 public void focusLost(FocusEvent e) {} 189 190 @Override 191 public void focusGained(FocusEvent e) { 192 nameField.selectAll(); 193 } 194 }); 195 nameField.setToolTipText(tr("Sets the name tag when the room-object is selected.")); 196 contentPanel.add(nameField, new GridBagConstraints(3, 5, 3, 1, 0.0, 0.0, 197 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 198 new Insets(0, 0, 5, 5), 0, 0)); 199 200 //---- refLabel ---- 201 refLabel.setText(tr("Reference")); 202 contentPanel.add(refLabel, new GridBagConstraints(0, 6, 3, 1, 0.0, 0.0, 203 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 204 new Insets(0, 0, 0, 5), 0, 0)); 205 206 //---- refField ---- 207 refField.setEnabled(false); 208 refField.addFocusListener(new FocusListener() { 209 210 @Override 211 public void focusLost(FocusEvent e) {} 212 213 @Override 214 public void focusGained(FocusEvent e) { 215 refField.selectAll(); 216 } 217 }); 218 refField.setToolTipText(tr("Sets the ref tag when the room-object is selected.")); 219 contentPanel.add(refField, new GridBagConstraints(3, 6, 3, 1, 0.0, 0.0, 220 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 221 new Insets(0, 0, 0, 5), 0, 0)); 222 223 //---- preset1 ---- 224 preset1.setEnabled(false); 225 contentPanel.add(preset1, new GridBagConstraints(16, 2, 1, 1, 0.0, 0.0, 226 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 227 new Insets(0, 0, 5, 5), 0, 0)); 228 contentPanel.add(separator2, new GridBagConstraints(1, 3, 13, 1, 0.0, 0.0, 229 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 230 new Insets(0, 0, 5, 5), 0, 0)); 231 232 //---- preset2 ---- 233 preset2.setEnabled(false); 234 contentPanel.add(preset2, new GridBagConstraints(16, 3, 1, 1, 0.0, 0.0, 235 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 236 new Insets(0, 0, 5, 5), 0, 0)); 237 238 //---- preset3 ---- 239 preset3.setEnabled(false); 240 contentPanel.add(preset3, new GridBagConstraints(16, 4, 1, 1, 0.0, 0.0, 241 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 242 new Insets(0, 0, 5, 5), 0, 0)); 243 244 //---- preset4 ---- 245 preset4.setEnabled(false); 246 contentPanel.add(preset4, new GridBagConstraints(16, 5, 1, 1, 0.0, 0.0, 247 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 248 new Insets(0, 0, 5, 5), 0, 0)); 249 } 250 dialogPane.add(contentPanel, BorderLayout.CENTER); 251 252 //======== buttonBar ======== 253 { 254 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); 255 buttonBar.setLayout(new GridBagLayout()); 256 ((GridBagLayout)buttonBar.getLayout()).columnWidths = new int[] {0, 80}; 257 ((GridBagLayout)buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0}; 258 259 //---- applyButton ---- 260 applyButton.setText(tr("Apply Tags")); 261 applyButton.setEnabled(false); 262 buttonBar.add(applyButton, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, 263 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 264 new Insets(0, 0, 0, 0), 0, 0)); 265 } 266 dialogPane.add(buttonBar, BorderLayout.SOUTH); 267 } 268 //contentPane.add(dialogPane, BorderLayout.CENTER); 269 270 271 this.createLayout(dialogPane, false, null); 272 } 273 274 /** 275 * Returns the state of the power button. 276 * 277 * @return boolean which is true when the button is selected 278 */ 279 public boolean getPowerButtonState(){ 280 return this.powerButton.isSelected(); 281 } 282 283 /** 284 * Enables or disables the interactive UI elements of the toolbox. 285 * 286 * @param enabled set this true for enabled elements 287 */ 288 public void setAllUiElementsEnabled(boolean enabled){ 289 this.applyButton.setEnabled(enabled); 290 this.levelBox.setEnabled(enabled); 291 this.objectBox.setEnabled(enabled); 292 this.nameField.setEnabled(enabled); 293 this.refField.setEnabled(enabled); 294 this.levelTagField.setEnabled(enabled); 295 this.preset1.setEnabled(enabled); 296 this.preset2.setEnabled(enabled); 297 this.preset3.setEnabled(enabled); 298 this.preset4.setEnabled(enabled); 299 300 301 if(enabled==false) { 302 resetUiElements(); 303 this.levelTagField.setText(""); 304 } 305 } 306 307 /** 308 * Enables or disables the interactive text box elements name and ref. 309 * 310 * @param enabled set this true for enabled elements 311 */ 312 public void setTagUiElementsEnabled(boolean enabled){ 313 this.nameField.setEnabled(enabled); 314 this.refField.setEnabled(enabled); 315 316 if(enabled==false) resetUiElements(); 317 } 318 319 /** 320 * Disables the power-button of the plug-in. 321 */ 322 public void setPowerButtonDisabled(){ 323 this.powerButton.setSelected(false); 324 } 325 326 /** 327 * Getter for the selected {@link IndoorObject} in the objectBox. 328 * 329 * @return the selected indoor object in the object ComboBox. 330 */ 331 public IndoorObject getSelectedObject(){ 332 return (IndoorObject) this.objectBox.getSelectedItem(); 333 } 334 335 336 /** 337 * Sets the level list for the level selection comboBox. 338 * 339 * @param levelList the list of levels which you want to set 340 */ 341 public void setLevelList(List<IndoorLevel> levelList){ 342 this.levelBox.removeAllItems(); 343 344 ListIterator<IndoorLevel> listIterator = levelList.listIterator(); 345 346 while(listIterator.hasNext()){ 347 IndoorLevel level = listIterator.next(); 348 if(level.hasEmptyName()){ 349 this.levelBox.addItem(Integer.toString(level.getLevelNumber())); 350 } else{ 351 this.levelBox.addItem(level.getName()); 352 } 353 } 354 } 355 356 /** 357 * Getter for the selected working level. 358 * 359 * @return the index of the selected item in the level-box 360 */ 361 public int getSelectedLevelIndex(){ 362 return this.levelBox.getSelectedIndex(); 363 } 364 365 /** 366 * Checks if the level list is empty. 367 * 368 * @return boolean which is true if the level-list is empty 369 */ 370 public boolean levelListIsEmpty(){ 371 if(this.levelBox.getItemCount()==0){ 372 return true; 373 } else{ 374 return false; 375 } 376 } 377 378 /** 379 * Getter for the level-name-field. 380 * 381 * @return the {@link String} of the levelTagField 382 */ 383 public String getLevelName(){ 384 return this.levelTagField.getText(); 385 } 386 387 /** 388 * Setter for the level name field. 389 * 390 * @param name the String for the levelTagField 391 */ 392 public void setLevelName(String name){ 393 this.levelTagField.setText(name); 394 } 395 396 /** 397 * Getter for the name {@link TextField}. 398 * 399 * @return {@link String} of the name text field 400 */ 401 public String getNameText(){ 402 return this.nameField.getText(); 403 } 404 405 /** 406 * Getter for the ref {@link TextField}. 407 * 408 * @return {@link String} of the ref text field 409 */ 410 public String getRefText(){ 411 return this.refField.getText(); 412 } 413 414 /** 415 * Resets the view by making the UI elements disabled and deleting the level list. 416 */ 417 public void reset(){ 418 this.setAllUiElementsEnabled(false); 419 this.levelBox.removeAllItems(); 420 } 421 422 /** 423 * Clears the text boxes and sets an empty {@link String}. 424 */ 425 public void resetUiElements(){ 426 this.nameField.setText(""); 427 this.refField.setText(""); 428 } 429 430 /* 431 * ******************************** 432 * SETTERS FOR THE BUTTON LISTENERS 433 * ******************************** 434 */ 435 436 /** 437 * Set the listener for the power button. 438 * 439 * @param l the listener to set 440 */ 441 public void setPowerButtonListener(ActionListener l){ 442 this.powerButton.addActionListener(l); 443 } 444 445 /** 446 * Set the listener for the apply button. 447 * 448 * @param l the listener to set 449 */ 450 public void setApplyButtonListener(ActionListener l){ 451 this.applyButton.addActionListener(l); 452 } 453 454 /** 455 * Set the listener which is called when a new item in the level list is selected. 456 * 457 * @param l the listener to set 458 */ 459 public void setLevelItemListener(ItemListener l){ 460 this.levelBox.addItemListener(l); 461 } 462 463 464 /** 465 * Set the listener which is called when a new item in the object list is selected. 466 * 467 * @param l the listener to set 468 */ 469 public void setObjectItemListener(ItemListener l){ 470 this.objectBox.addItemListener(l); 471 } 472 473 // Preset Button Functions 474 475 public void setPresetButtons(List<IndoorObject> objects){ 476 this.preset1.setIndoorObject(objects.get(0)); 477 this.preset2.setIndoorObject(objects.get(1)); 478 this.preset3.setIndoorObject(objects.get(2)); 479 this.preset4.setIndoorObject(objects.get(3)); 480 } 481 482 public void setPreset1Listener(ActionListener l){ 483 this.preset1.addActionListener(l); 484 } 485 486 public void setPreset2Listener(ActionListener l){ 487 this.preset2.addActionListener(l); 488 } 489 490 public void setPreset3Listener(ActionListener l){ 491 this.preset3.addActionListener(l); 492 } 493 494 public void setPreset4Listener(ActionListener l){ 495 this.preset4.addActionListener(l); 496 } 497 498 public IndoorObject getPreset1(){ 499 return preset1.getIndoorObject(); 500 } 501 502 public IndoorObject getPreset2(){ 503 return preset2.getIndoorObject(); 504 } 505 506 public IndoorObject getPreset3(){ 507 return preset3.getIndoorObject(); 508 } 509 510 public IndoorObject getPreset4(){ 511 return preset4.getIndoorObject(); 512 } 58 public class ToolBoxView extends ToggleDialog { 59 private JPanel dialogPane; 60 private JPanel contentPanel; 61 private JToggleButton powerButton; 62 private JLabel levelLabel; 63 private JosmComboBox<String> levelBox; 64 private JLabel levelTagLabel; 65 private DisableShortcutsOnFocusGainedTextField levelTagField; 66 private JLabel objectLabel; 67 private JosmComboBox<TagCatalog.IndoorObject> objectBox; 68 private JLabel nameLabel; 69 private DisableShortcutsOnFocusGainedTextField nameField; 70 private JLabel refLabel; 71 private DisableShortcutsOnFocusGainedTextField refField; 72 private JPanel buttonBar; 73 private JButton applyButton; 74 private JSeparator separator1; 75 private JSeparator separator2; 76 private PresetButton preset1; 77 private PresetButton preset2; 78 private PresetButton preset3; 79 private PresetButton preset4; 80 81 public ToolBoxView() { 82 super(tr("Indoor Mapping Helper"), "indoorhelper", 83 tr("Toolbox for indoor mapping assistance"), null, 300, true); 84 85 initComponents(); 86 } 87 88 /** 89 * Creates the layout of the plug-in. 90 */ 91 private void initComponents() { 92 dialogPane = new JPanel(); 93 contentPanel = new JPanel(); 94 powerButton = new JToggleButton(); 95 levelLabel = new JLabel(); 96 levelBox = new JosmComboBox<String>(); 97 levelTagLabel = new JLabel(); 98 levelTagField = new DisableShortcutsOnFocusGainedTextField(); 99 objectLabel = new JLabel(); 100 objectBox = new JosmComboBox<>(TagCatalog.IndoorObject.values()); 101 nameLabel = new JLabel(); 102 nameField = new DisableShortcutsOnFocusGainedTextField(); 103 refLabel = new JLabel(); 104 refField = new DisableShortcutsOnFocusGainedTextField(); 105 buttonBar = new JPanel(); 106 applyButton = new JButton(); 107 separator1 = new JSeparator(); 108 separator2 = new JSeparator(); 109 preset1 = new PresetButton(IndoorObject.ROOM); 110 preset2 = new PresetButton(IndoorObject.SHELL); 111 preset3 = new PresetButton(IndoorObject.CONCRETE_WALL); 112 preset4 = new PresetButton(IndoorObject.GLASS_WALL); 113 114 //======== this ======== 115 //Container contentPane = this.get; 116 //contentPane.setLayout(new BorderLayout()); 117 118 //======== dialogPane ======== 119 { 120 dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12)); 121 dialogPane.setLayout(new BorderLayout()); 122 123 //======== contentPanel ======== 124 { 125 contentPanel.setLayout(new GridBagLayout()); 126 ((GridBagLayout) contentPanel.getLayout()).columnWidths = new int[] { 127 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}; 128 ((GridBagLayout) contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0, 0, 0}; 129 ((GridBagLayout) contentPanel.getLayout()).columnWeights = new double[] { 130 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}; 131 ((GridBagLayout) contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4}; 132 133 //---- powerButton ---- 134 powerButton.setText(tr("POWER")); 135 powerButton.setToolTipText(tr("Activates the plug-in")); 136 contentPanel.add(powerButton, new GridBagConstraints(8, 0, 4, 1, 0.0, 0.0, 137 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 138 new Insets(0, 0, 5, 5), 0, 0)); 139 contentPanel.add(separator1, new GridBagConstraints(1, 1, 12, 1, 0.0, 0.0, 140 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 141 new Insets(0, 0, 5, 5), 0, 0)); 142 143 //---- levelLabel ---- 144 levelLabel.setText(tr("Working Level")); 145 contentPanel.add(levelLabel, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0, 146 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 147 new Insets(0, 0, 5, 5), 0, 0)); 148 149 //---- levelBox ---- 150 levelBox.setEnabled(false); 151 levelBox.setEditable(false); 152 levelBox.setToolTipText(tr("Selects the working level.")); 153 contentPanel.add(levelBox, new GridBagConstraints(3, 2, 3, 1, 0.0, 0.0, 154 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 155 new Insets(0, 0, 5, 5), 0, 0)); 156 157 //---- levelTagLabel ---- 158 levelTagLabel.setText(tr("Level Name")); 159 contentPanel.add(levelTagLabel, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0, 160 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 161 new Insets(0, 0, 5, 5), 0, 0)); 162 163 //---- levelTagField ---- 164 levelTagField.setEnabled(false); 165 levelTagField.setColumns(6); 166 levelTagField.setToolTipText(tr("Optional name-tag for a level.")); 167 contentPanel.add(levelTagField, new GridBagConstraints(8, 2, 5, 1, 0.0, 0.0, 168 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 169 new Insets(0, 0, 5, 5), 0, 0)); 170 contentPanel.add(separator2, new GridBagConstraints(1, 3, 12, 1, 0.0, 0.0, 171 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 172 new Insets(0, 0, 5, 5), 0, 0)); 173 174 //---- objectLabel ---- 175 objectLabel.setText(tr("Object")); 176 contentPanel.add(objectLabel, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0, 177 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 178 new Insets(0, 0, 5, 5), 0, 0)); 179 180 //---- objectBox ---- 181 objectBox.setEnabled(false); 182 objectBox.setPrototypeDisplayValue(IndoorObject.CONCRETE_WALL); 183 objectBox.setToolTipText(tr("The object preset you want to tag.")); 184 contentPanel.add(objectBox, new GridBagConstraints(3, 4, 3, 1, 0.0, 0.0, 185 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 186 new Insets(0, 0, 5, 5), 0, 0)); 187 188 //---- nameLabel ---- 189 nameLabel.setText(tr("Name")); 190 contentPanel.add(nameLabel, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0, 191 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 192 new Insets(0, 0, 5, 5), 0, 0)); 193 194 //---- nameField ---- 195 nameField.setEnabled(false); 196 nameField.addFocusListener(new FocusListener() { 197 198 @Override 199 public void focusLost(FocusEvent e) {} 200 201 @Override 202 public void focusGained(FocusEvent e) { 203 nameField.selectAll(); 204 } 205 }); 206 nameField.setToolTipText(tr("Sets the name tag when the room-object is selected.")); 207 contentPanel.add(nameField, new GridBagConstraints(3, 5, 3, 1, 0.0, 0.0, 208 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 209 new Insets(0, 0, 5, 5), 0, 0)); 210 211 //---- refLabel ---- 212 refLabel.setText(tr("Reference")); 213 contentPanel.add(refLabel, new GridBagConstraints(0, 6, 3, 1, 0.0, 0.0, 214 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 215 new Insets(0, 0, 0, 5), 0, 0)); 216 217 //---- refField ---- 218 refField.setEnabled(false); 219 refField.addFocusListener(new FocusListener() { 220 221 @Override 222 public void focusLost(FocusEvent e) {} 223 224 @Override 225 public void focusGained(FocusEvent e) { 226 refField.selectAll(); 227 } 228 }); 229 refField.setToolTipText(tr("Sets the ref tag when the room-object is selected.")); 230 contentPanel.add(refField, new GridBagConstraints(3, 6, 3, 1, 0.0, 0.0, 231 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 232 new Insets(0, 0, 0, 5), 0, 0)); 233 234 //---- preset1 ---- 235 preset1.setEnabled(false); 236 contentPanel.add(preset1, new GridBagConstraints(16, 2, 1, 1, 0.0, 0.0, 237 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 238 new Insets(0, 0, 5, 5), 0, 0)); 239 contentPanel.add(separator2, new GridBagConstraints(1, 3, 13, 1, 0.0, 0.0, 240 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 241 new Insets(0, 0, 5, 5), 0, 0)); 242 243 //---- preset2 ---- 244 preset2.setEnabled(false); 245 contentPanel.add(preset2, new GridBagConstraints(16, 3, 1, 1, 0.0, 0.0, 246 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 247 new Insets(0, 0, 5, 5), 0, 0)); 248 249 //---- preset3 ---- 250 preset3.setEnabled(false); 251 contentPanel.add(preset3, new GridBagConstraints(16, 4, 1, 1, 0.0, 0.0, 252 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 253 new Insets(0, 0, 5, 5), 0, 0)); 254 255 //---- preset4 ---- 256 preset4.setEnabled(false); 257 contentPanel.add(preset4, new GridBagConstraints(16, 5, 1, 1, 0.0, 0.0, 258 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 259 new Insets(0, 0, 5, 5), 0, 0)); 260 } 261 dialogPane.add(contentPanel, BorderLayout.CENTER); 262 263 //======== buttonBar ======== 264 { 265 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); 266 buttonBar.setLayout(new GridBagLayout()); 267 ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 80}; 268 ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0}; 269 270 //---- applyButton ---- 271 applyButton.setText(tr("Apply Tags")); 272 applyButton.setEnabled(false); 273 buttonBar.add(applyButton, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, 274 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 275 new Insets(0, 0, 0, 0), 0, 0)); 276 } 277 dialogPane.add(buttonBar, BorderLayout.SOUTH); 278 } 279 //contentPane.add(dialogPane, BorderLayout.CENTER); 280 281 282 this.createLayout(dialogPane, false, null); 283 } 284 285 /** 286 * Returns the state of the power button. 287 * 288 * @return boolean which is true when the button is selected 289 */ 290 public boolean getPowerButtonState() { 291 return this.powerButton.isSelected(); 292 } 293 294 /** 295 * Enables or disables the interactive UI elements of the toolbox. 296 * 297 * @param enabled set this true for enabled elements 298 */ 299 public void setAllUiElementsEnabled(boolean enabled) { 300 this.applyButton.setEnabled(enabled); 301 this.levelBox.setEnabled(enabled); 302 this.objectBox.setEnabled(enabled); 303 this.nameField.setEnabled(enabled); 304 this.refField.setEnabled(enabled); 305 this.levelTagField.setEnabled(enabled); 306 this.preset1.setEnabled(enabled); 307 this.preset2.setEnabled(enabled); 308 this.preset3.setEnabled(enabled); 309 this.preset4.setEnabled(enabled); 310 311 312 if (enabled == false) { 313 resetUiElements(); 314 this.levelTagField.setText(""); 315 } 316 } 317 318 /** 319 * Enables or disables the interactive text box elements name and ref. 320 * 321 * @param enabled set this true for enabled elements 322 */ 323 public void setTagUiElementsEnabled(boolean enabled) { 324 this.nameField.setEnabled(enabled); 325 this.refField.setEnabled(enabled); 326 327 if (enabled == false) resetUiElements(); 328 } 329 330 /** 331 * Disables the power-button of the plug-in. 332 */ 333 public void setPowerButtonDisabled() { 334 this.powerButton.setSelected(false); 335 } 336 337 /** 338 * Getter for the selected {@link IndoorObject} in the objectBox. 339 * 340 * @return the selected indoor object in the object ComboBox. 341 */ 342 public IndoorObject getSelectedObject() { 343 return (IndoorObject) this.objectBox.getSelectedItem(); 344 } 345 346 347 /** 348 * Sets the level list for the level selection comboBox. 349 * 350 * @param levelList the list of levels which you want to set 351 */ 352 public void setLevelList(List<IndoorLevel> levelList) { 353 this.levelBox.removeAllItems(); 354 355 ListIterator<IndoorLevel> listIterator = levelList.listIterator(); 356 357 while (listIterator.hasNext()) { 358 IndoorLevel level = listIterator.next(); 359 if (level.hasEmptyName()) { 360 this.levelBox.addItem(Integer.toString(level.getLevelNumber())); 361 } else { 362 this.levelBox.addItem(level.getName()); 363 } 364 } 365 } 366 367 /** 368 * Getter for the selected working level. 369 * 370 * @return the index of the selected item in the level-box 371 */ 372 public int getSelectedLevelIndex() { 373 return this.levelBox.getSelectedIndex(); 374 } 375 376 /** 377 * Checks if the level list is empty. 378 * 379 * @return boolean which is true if the level-list is empty 380 */ 381 public boolean levelListIsEmpty() { 382 if (this.levelBox.getItemCount() == 0) { 383 return true; 384 } else { 385 return false; 386 } 387 } 388 389 /** 390 * Getter for the level-name-field. 391 * 392 * @return the {@link String} of the levelTagField 393 */ 394 public String getLevelName() { 395 return this.levelTagField.getText(); 396 } 397 398 /** 399 * Setter for the level name field. 400 * 401 * @param name the String for the levelTagField 402 */ 403 public void setLevelName(String name) { 404 this.levelTagField.setText(name); 405 } 406 407 /** 408 * Getter for the name {@link TextField}. 409 * 410 * @return {@link String} of the name text field 411 */ 412 public String getNameText() { 413 return this.nameField.getText(); 414 } 415 416 /** 417 * Getter for the ref {@link TextField}. 418 * 419 * @return {@link String} of the ref text field 420 */ 421 public String getRefText() { 422 return this.refField.getText(); 423 } 424 425 /** 426 * Resets the view by making the UI elements disabled and deleting the level list. 427 */ 428 public void reset() { 429 this.setAllUiElementsEnabled(false); 430 this.levelBox.removeAllItems(); 431 } 432 433 /** 434 * Clears the text boxes and sets an empty {@link String}. 435 */ 436 public void resetUiElements() { 437 this.nameField.setText(""); 438 this.refField.setText(""); 439 } 440 441 /* 442 * ******************************** 443 * SETTERS FOR THE BUTTON LISTENERS 444 * ******************************** 445 */ 446 447 /** 448 * Set the listener for the power button. 449 * 450 * @param l the listener to set 451 */ 452 public void setPowerButtonListener(ActionListener l) { 453 this.powerButton.addActionListener(l); 454 } 455 456 /** 457 * Set the listener for the apply button. 458 * 459 * @param l the listener to set 460 */ 461 public void setApplyButtonListener(ActionListener l) { 462 this.applyButton.addActionListener(l); 463 } 464 465 /** 466 * Set the listener which is called when a new item in the level list is selected. 467 * 468 * @param l the listener to set 469 */ 470 public void setLevelItemListener(ItemListener l) { 471 this.levelBox.addItemListener(l); 472 } 473 474 475 /** 476 * Set the listener which is called when a new item in the object list is selected. 477 * 478 * @param l the listener to set 479 */ 480 public void setObjectItemListener(ItemListener l) { 481 this.objectBox.addItemListener(l); 482 } 483 484 // Preset Button Functions 485 486 public void setPresetButtons(List<IndoorObject> objects) { 487 this.preset1.setIndoorObject(objects.get(0)); 488 this.preset2.setIndoorObject(objects.get(1)); 489 this.preset3.setIndoorObject(objects.get(2)); 490 this.preset4.setIndoorObject(objects.get(3)); 491 } 492 493 public void setPreset1Listener(ActionListener l) { 494 this.preset1.addActionListener(l); 495 } 496 497 public void setPreset2Listener(ActionListener l) { 498 this.preset2.addActionListener(l); 499 } 500 501 public void setPreset3Listener(ActionListener l) { 502 this.preset3.addActionListener(l); 503 } 504 505 public void setPreset4Listener(ActionListener l) { 506 this.preset4.addActionListener(l); 507 } 508 509 public IndoorObject getPreset1() { 510 return preset1.getIndoorObject(); 511 } 512 513 public IndoorObject getPreset2() { 514 return preset2.getIndoorObject(); 515 } 516 517 public IndoorObject getPreset3() { 518 return preset3.getIndoorObject(); 519 } 520 521 public IndoorObject getPreset4() { 522 return preset4.getIndoorObject(); 523 } 513 524 }
Note:
See TracChangeset
for help on using the changeset viewer.