Ignore:
Timestamp:
2010-08-31T12:29:48+02:00 (14 years ago)
Author:
upliner
Message:

buildings_tools: implemented tag editor

Location:
applications/editors/josm/plugins/buildings_tools/src/buildings_tools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/buildings_tools/src/buildings_tools/AdvancedSettingsDialog.java

    r22529 r22904  
    22
    33import static org.openstreetmap.josm.tools.I18n.tr;
    4 import static buildings_tools.BuildingSizeDialog.addLabelled;
    54
    65import java.awt.GridBagLayout;
    76import java.awt.Insets;
     7import java.util.Map.Entry;
    88
    99import javax.swing.JCheckBox;
     10import javax.swing.JLabel;
    1011import javax.swing.JPanel;
    11 import javax.swing.JTextField;
    1212
    1313import org.openstreetmap.josm.Main;
    1414import org.openstreetmap.josm.gui.ExtendedDialog;
     15import org.openstreetmap.josm.gui.tagging.TagEditorModel;
     16import org.openstreetmap.josm.gui.tagging.TagEditorPanel;
    1517import org.openstreetmap.josm.tools.GBC;
    1618
    1719public class AdvancedSettingsDialog extends ExtendedDialog {
    18         // TODO: Replace tag textbox to full-fledged tag editor
    19         JTextField tBTag = new JTextField();
    20         JCheckBox cBigMode = new JCheckBox(tr("Big buildings mode"));
    21         JCheckBox cSoftCur = new JCheckBox(tr("Rotate crosshair"));
     20        private TagEditorModel tagsModel = new TagEditorModel();
     21
     22        private JCheckBox cBigMode = new JCheckBox(tr("Big buildings mode"));
     23        private JCheckBox cSoftCur = new JCheckBox(tr("Rotate crosshair"));
    2224
    2325        public AdvancedSettingsDialog() {
     
    2931
    3032                final JPanel panel = new JPanel(new GridBagLayout());
    31                 addLabelled(panel, tr("Building tag:"), tBTag);
     33                panel.add(new JLabel(tr("Buildings tags:")), GBC.eol().fill(GBC.HORIZONTAL));
     34
     35                for (Entry<String, String> entry : ToolSettings.getTags().entrySet()) {
     36                        tagsModel.add(entry.getKey(), entry.getValue());
     37                }
     38                panel.add(new TagEditorPanel(tagsModel), GBC.eop().fill(GBC.BOTH));
     39
    3240                panel.add(cBigMode, GBC.eol().fill(GBC.HORIZONTAL));
    3341                panel.add(cSoftCur, GBC.eol().fill(GBC.HORIZONTAL));
    3442
    35                 tBTag.setText(ToolSettings.getTag());
    3643                cBigMode.setSelected(ToolSettings.isBBMode());
    3744                cSoftCur.setSelected(ToolSettings.isSoftCursor());
    3845
    3946                setContent(panel);
     47
    4048                setupDialog();
    4149                setVisible(true);
    42         }
    43 
    44         public String getTag() {
    45                 return tBTag.getText();
    4650        }
    4751
     
    5559
    5660        public void saveSettings() {
    57                 ToolSettings.setTag(getTag());
     61                tagsModel.applyToTags(ToolSettings.getTags());
    5862                ToolSettings.setBBMode(isBBMode());
    5963                ToolSettings.setSoftCursor(isSoftCursor());
  • applications/editors/josm/plugins/buildings_tools/src/buildings_tools/Building.java

    r21876 r22904  
    248248                }
    249249                w.addNode(nodes[0]);
    250                 w.put("building", ToolSettings.getTag());
     250                w.setKeys(ToolSettings.getTags());
    251251                Collection<Command> cmds = new LinkedList<Command>();
    252252                for (int i = 0; i < 4; i++) {
  • applications/editors/josm/plugins/buildings_tools/src/buildings_tools/DrawBuildingAction.java

    r21875 r22904  
    4242@SuppressWarnings("serial")
    4343public class DrawBuildingAction extends MapMode implements MapViewPaintable, AWTEventListener, SelectionChangedListener {
    44         enum Mode {
     44        private enum Mode {
    4545                None, Drawing, DrawingWidth, DrawingAngFix
    4646        }
     
    6565                super(tr("Draw buildings"), "building", tr("Draw buildings"),
    6666                                Shortcut.registerShortcut("mapmode:buildings",
    67                                 tr("Mode: {0}", tr("Draw buildings")),
    68                                 KeyEvent.VK_W, Shortcut.GROUP_EDIT),
     67                                                tr("Mode: {0}", tr("Draw buildings")),
     68                                                KeyEvent.VK_W, Shortcut.GROUP_EDIT),
    6969                                mapFrame, getCursor());
    7070
     
    134134                Main.map.mapView.addMouseMotionListener(this);
    135135                Main.map.mapView.addTemporaryLayer(this);
    136                 DataSet.selListeners.add(this);
     136                DataSet.addSelectionListener(this);
    137137                updateSnap(getCurrentDataSet().getSelected());
    138138                try {
     
    148148                Main.map.mapView.removeMouseMotionListener(this);
    149149                Main.map.mapView.removeTemporaryLayer(this);
    150                 DataSet.selListeners.remove(this);
     150                DataSet.removeSelectionListener(this);
    151151                try {
    152152                        Toolkit.getDefaultToolkit().removeAWTEventListener(this);
  • applications/editors/josm/plugins/buildings_tools/src/buildings_tools/ToolSettings.java

    r21875 r22904  
    11package buildings_tools;
     2
     3import java.util.HashMap;
     4import java.util.Map;
    25
    36import org.openstreetmap.josm.Main;
     
    710        private static double lenstep = 0;
    811        private static boolean useAddr;
    9         private static String tag = "yes";
     12        private static final Map<String, String> tags = new HashMap<String, String>();
    1013        private static boolean autoSelect;
     14
     15        static {
     16                tags.put("building", "yes");
     17        }
    1118
    1219        public static void setAddrDialog(boolean _useAddr) {
     
    3138        }
    3239
    33         public static void setTag(String newtag) {
    34                 tag = newtag;
    35         }
    36 
    37         public static String getTag() {
    38                 return tag;
     40        public static Map<String, String> getTags() {
     41                return tags;
    3942        }
    4043
Note: See TracChangeset for help on using the changeset viewer.