Changeset 24243 in osm for applications


Ignore:
Timestamp:
2010-11-15T16:08:46+01:00 (14 years ago)
Author:
upliner
Message:

Add features requested by kryskow: make OK button in dialogs default and auto-accept address dialog when Alt is pressed

Location:
applications/editors/josm/plugins/buildings_tools
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/buildings_tools/.settings/org.eclipse.jdt.core.prefs

    r23330 r24243  
    1 #Fri Sep 24 19:30:08 MSD 2010
     1#Mon Nov 15 17:53:13 MSK 2010
    22eclipse.preferences.version=1
    33org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
  • applications/editors/josm/plugins/buildings_tools/.settings/org.eclipse.jdt.ui.prefs

    r21801 r24243  
    1 #Sat Jun 19 21:24:56 MSD 2010
     1#Mon Nov 15 17:59:59 MSK 2010
    22eclipse.preferences.version=1
    33editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
    4 formatter_profile=_BTProf
     4formatter_profile=_My Profile
    55formatter_settings_version=11
    66sp_cleanup.add_default_serial_version_id=true
     
    1111sp_cleanup.add_missing_nls_tags=false
    1212sp_cleanup.add_missing_override_annotations=true
     13sp_cleanup.add_missing_override_annotations_interface_methods=true
    1314sp_cleanup.add_serial_version_id=false
    1415sp_cleanup.always_use_blocks=true
     
    1920sp_cleanup.correct_indentation=false
    2021sp_cleanup.format_source_code=true
    21 sp_cleanup.format_source_code_changes_only=false
     22sp_cleanup.format_source_code_changes_only=true
    2223sp_cleanup.make_local_variable_final=false
    2324sp_cleanup.make_parameters_final=false
    2425sp_cleanup.make_private_fields_final=true
    2526sp_cleanup.make_type_abstract_if_missing_method=false
    26 sp_cleanup.make_variable_declarations_final=true
     27sp_cleanup.make_variable_declarations_final=false
    2728sp_cleanup.never_use_blocks=false
    2829sp_cleanup.never_use_parentheses_in_expressions=true
    29 sp_cleanup.on_save_use_additional_actions=false
     30sp_cleanup.on_save_use_additional_actions=true
    3031sp_cleanup.organize_imports=false
    3132sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
     
    3536sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
    3637sp_cleanup.remove_private_constructors=true
    37 sp_cleanup.remove_trailing_whitespaces=false
     38sp_cleanup.remove_trailing_whitespaces=true
    3839sp_cleanup.remove_trailing_whitespaces_all=true
    3940sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
  • applications/editors/josm/plugins/buildings_tools/src/buildings_tools/AddressDialog.java

    r23190 r24243  
    44
    55import java.awt.Choice;
    6 import java.awt.Component;
    7 import java.awt.GridBagLayout;
    8 import java.awt.Insets;
    96import java.text.NumberFormat;
    107import java.text.ParseException;
    118
    129import javax.swing.JTextField;
    13 import javax.swing.JLabel;
    14 import javax.swing.JPanel;
    15 
    16 import org.openstreetmap.josm.Main;
    17 import org.openstreetmap.josm.gui.ExtendedDialog;
    18 import org.openstreetmap.josm.tools.GBC;
    1910
    2011@SuppressWarnings("serial")
    21 public class AddressDialog extends ExtendedDialog {
    22     private static String lhousenum,lstreetname;
     12public class AddressDialog extends MyDialog {
     13    private static String lhousenum, lstreetname;
    2314    private static boolean inc = true;
    2415    private JTextField housenum = new JTextField();
     
    2617    private Choice cincdec = new Choice();
    2718
    28     private JPanel panel = new JPanel(new GridBagLayout());
    29     private void addLabelled(String str, Component c) {
    30         JLabel label = new JLabel(str);
    31         panel.add(label, GBC.std());
    32         label.setLabelFor(c);
    33         panel.add(c, GBC.eol().fill(GBC.HORIZONTAL));
    34     }
     19    public AddressDialog() {
     20        super(tr("Building address"));
    3521
    36     public AddressDialog() {
    37         super(Main.parent, tr("Building address"),
    38                 new String[] { tr("OK"), tr("Cancel") },
    39                 true);
    40 
    41         contentInsets = new Insets(15,15,5,15);
    42         setButtonIcons(new String[] {"ok.png", "cancel.png" });
    43 
    44         addLabelled(tr("House number:"),housenum);
    45         addLabelled(tr("Street Name:"),streetname);
     22        addLabelled(tr("House number:"), housenum);
     23        addLabelled(tr("Street Name:"), streetname);
    4624        housenum.setText(nextHouseNum());
    4725        streetname.setText(lstreetname);
     
    4927        cincdec.add(tr("Increment"));
    5028        cincdec.add(tr("Decrement"));
    51         cincdec.select(inc?0:1);
     29        cincdec.select(inc ? 0 : 1);
    5230        addLabelled(tr("Numbers:"), cincdec);
    5331
    5432        setContent(panel);
    5533        setupDialog();
    56         setVisible(true);
    5734    }
    5835
    5936    private static String nextHouseNum() {
    60         if (lhousenum==null) return "";
     37        if (lhousenum == null)
     38            return "";
    6139        try {
    6240            Integer num = NumberFormat.getInstance().parse(lhousenum).intValue();
    63             if (inc) num=num+2; else num = num-2;
     41            if (inc)
     42                num = num + 2;
     43            else
     44                num = num - 2;
    6445            return num.toString();
    6546        } catch (ParseException e) {
     
    6748        }
    6849    }
     50
    6951    public void saveValues() {
    7052        lhousenum = housenum.getText();
     
    7254        inc = cincdec.getSelectedIndex() == 0;
    7355    }
     56
    7457    public String getHouseNum() {
    7558        return housenum.getText();
    7659    }
     60
    7761    public String getStreetName() {
    7862        return streetname.getText();
  • applications/editors/josm/plugins/buildings_tools/src/buildings_tools/AdvancedSettingsDialog.java

    r23330 r24243  
    33import static org.openstreetmap.josm.tools.I18n.tr;
    44
    5 import java.awt.GridBagLayout;
    6 import java.awt.Insets;
    75import java.util.Map.Entry;
    86
    97import javax.swing.JCheckBox;
    108import javax.swing.JLabel;
    11 import javax.swing.JPanel;
    129
    13 import org.openstreetmap.josm.Main;
    14 import org.openstreetmap.josm.gui.ExtendedDialog;
    1510import org.openstreetmap.josm.gui.tagging.TagEditorModel;
    1611import org.openstreetmap.josm.gui.tagging.TagEditorPanel;
    1712import org.openstreetmap.josm.tools.GBC;
    1813
    19 public class AdvancedSettingsDialog extends ExtendedDialog {
    20     private TagEditorModel tagsModel = new TagEditorModel();
     14public class AdvancedSettingsDialog extends MyDialog {
     15    private final TagEditorModel tagsModel = new TagEditorModel();
    2116
    22     private JCheckBox cBigMode = new JCheckBox(tr("Big buildings mode"));
    23     private JCheckBox cSoftCur = new JCheckBox(tr("Rotate crosshair"));
     17    private final JCheckBox cBigMode = new JCheckBox(tr("Big buildings mode"));
     18    private final JCheckBox cSoftCur = new JCheckBox(tr("Rotate crosshair"));
    2419
    2520    public AdvancedSettingsDialog() {
    26         super(Main.parent, tr("Advanced settings"),
    27                 new String[] { tr("OK"), tr("Cancel") },
    28                 true);
    29         contentInsets = new Insets(15, 15, 5, 15);
    30         setButtonIcons(new String[] { "ok.png", "cancel.png" });
     21        super(tr("Advanced settings"));
    3122
    32         final JPanel panel = new JPanel(new GridBagLayout());
    3323        panel.add(new JLabel(tr("Buildings tags:")), GBC.eol().fill(GBC.HORIZONTAL));
    3424
     
    4434        cSoftCur.setSelected(ToolSettings.isSoftCursor());
    4535
    46         setContent(panel);
    47 
    4836        setupDialog();
    49         setVisible(true);
     37        showDialog();
    5038    }
    5139
  • applications/editors/josm/plugins/buildings_tools/src/buildings_tools/BuildingSizeDialog.java

    r23190 r24243  
    33import static org.openstreetmap.josm.tools.I18n.tr;
    44
    5 import java.awt.Component;
    6 import java.awt.GridBagLayout;
    7 import java.awt.Insets;
    85import java.awt.event.ActionEvent;
    96import java.awt.event.ActionListener;
     
    1411import javax.swing.JFormattedTextField;
    1512import javax.swing.JCheckBox;
    16 import javax.swing.JLabel;
    17 import javax.swing.JPanel;
    1813
    19 import org.openstreetmap.josm.Main;
    20 import org.openstreetmap.josm.gui.ExtendedDialog;
    2114import org.openstreetmap.josm.tools.GBC;
    2215
    2316@SuppressWarnings("serial")
    24 public class BuildingSizeDialog extends ExtendedDialog {
     17public class BuildingSizeDialog extends MyDialog {
    2518    private JFormattedTextField twidth = new JFormattedTextField(NumberFormat.getInstance());
    2619    private JFormattedTextField tlenstep = new JFormattedTextField(NumberFormat.getInstance());
     
    2821    private JCheckBox cAutoSelect = new JCheckBox(tr("Auto-select building"));
    2922
    30     static void addLabelled(JPanel panel, String str, Component c) {
    31         JLabel label = new JLabel(str);
    32         panel.add(label, GBC.std());
    33         label.setLabelFor(c);
    34         panel.add(c, GBC.eol().fill(GBC.HORIZONTAL));
    35     }
     23    public BuildingSizeDialog() {
     24        super(tr("Set buildings size"));
    3625
    37     public BuildingSizeDialog() {
    38         super(Main.parent, tr("Set buildings size"),
    39                 new String[] { tr("OK"), tr("Cancel") },
    40                 true);
    41         contentInsets = new Insets(15, 15, 5, 15);
    42         setButtonIcons(new String[] { "ok.png", "cancel.png" });
    43 
    44         final JPanel panel = new JPanel(new GridBagLayout());
    45         addLabelled(panel, tr("Buildings width:"), twidth);
    46         addLabelled(panel, tr("Length step:"), tlenstep);
     26        addLabelled(tr("Buildings width:"), twidth);
     27        addLabelled(tr("Length step:"), tlenstep);
    4728        panel.add(caddr, GBC.eol().fill(GBC.HORIZONTAL));
    4829        panel.add(cAutoSelect, GBC.eol().fill(GBC.HORIZONTAL));
     
    6546        panel.add(bAdv, GBC.eol().insets(0, 5, 0, 0).anchor(GBC.EAST));
    6647
    67         setContent(panel);
    6848        setupDialog();
    69         setVisible(true);
     49        showDialog();
    7050    }
    7151
  • applications/editors/josm/plugins/buildings_tools/src/buildings_tools/BuildingsToolsPlugin.java

    r23190 r24243  
    1717        return proj.latlon2eastNorth(p);
    1818    }
     19
    1920    public static LatLon eastNorth2latlon(EastNorth p) {
    2021        return proj.eastNorth2latlon(p);
     
    2627        MainMenu.add(Main.main.menu.editMenu, new BuildingSizeAction());
    2728    }
    28     @Override public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
    29         if (oldFrame==null && newFrame!=null) {
     29
     30    @Override
     31    public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
     32        if (oldFrame == null && newFrame != null) {
    3033            Main.map.addMapMode(new IconToggleButton(new DrawBuildingAction(Main.map)));
    3134        }
  • applications/editors/josm/plugins/buildings_tools/src/buildings_tools/DrawBuildingAction.java

    r23630 r24243  
    5454    private Mode nextMode = Mode.None;
    5555
    56     private Color selectedColor;
     56    private final Color selectedColor;
    5757    private Point drawStartPos;
    5858    private Point mousePos;
    5959    private boolean isCtrlDown;
    6060    private boolean isShiftDown;
     61    private boolean isAltDown;
    6162
    6263    Building building = new Building();
     
    9697            // We invoke this to prevent strange things from happening
    9798            EventQueue.invokeLater(new Runnable() {
     99                @Override
    98100                public void run() {
    99101                    // Don't change cursor when mode has changed already
     
    108110    }
    109111
    110     private static void showAddrDialog(Way w) {
     112    private void showAddrDialog(Way w) {
    111113        AddressDialog dlg = new AddressDialog();
    112         int answer = dlg.getValue();
    113         if (answer == 1) {
    114             dlg.saveValues();
    115             String tmp;
    116             tmp = dlg.getHouseNum();
    117             if (tmp != null && tmp != "")
    118                 w.put("addr:housenumber", tmp);
    119             tmp = dlg.getStreetName();
    120             if (tmp != null && tmp != "")
    121                 w.put("addr:street", tmp);
    122         }
     114        if (!isAltDown) {
     115            dlg.showDialog();
     116            if (dlg.getValue() != 1)
     117                return;
     118        }
     119        dlg.saveValues();
     120        String tmp;
     121        tmp = dlg.getHouseNum();
     122        if (tmp != null && tmp != "")
     123            w.put("addr:housenumber", tmp);
     124        tmp = dlg.getStreetName();
     125        if (tmp != null && tmp != "")
     126            w.put("addr:street", tmp);
    123127    }
    124128
     
    169173    }
    170174
     175    @Override
    171176    public void eventDispatched(AWTEvent arg0) {
    172177        if (!(arg0 instanceof KeyEvent))
     
    184189                Main.map.mapView.repaint();
    185190        }
     191        isAltDown = (modifiers & KeyEvent.ALT_DOWN_MASK) != 0;
    186192
    187193        if (ev.getKeyCode() == KeyEvent.VK_ESCAPE && ev.getID() == KeyEvent.KEY_PRESSED) {
     
    239245            isCtrlDown = e.isControlDown();
    240246            isShiftDown = e.isShiftDown();
     247            isAltDown = e.isAltDown();
    241248        }
    242249        if (mode == Mode.None) {
     
    255262    }
    256263
     264    @Override
    257265    public void paint(Graphics2D g, MapView mv, Bounds bbox) {
    258266        if (mode == Mode.None)
     
    453461    }
    454462
     463    @Override
    455464    public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
    456465        updateSnap(newSelection);
Note: See TracChangeset for help on using the changeset viewer.