Changeset 212 in josm for src/org/openstreetmap


Ignore:
Timestamp:
2007-04-04T16:44:02+02:00 (18 years ago)
Author:
imi
Message:
  • added focus-attribute to Annotation Presets
  • fixed Incomplete Download Dialog not displaying a correct message.
  • fixed csv-Reader to correctly detect the first line (format string)
Location:
src/org/openstreetmap/josm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/gui/annotation/AnnotationPreset.java

    r202 r212  
    4848public class AnnotationPreset extends AbstractAction {
    4949
    50         private static interface Item {
    51                 void addToPanel(JPanel p);
    52                 void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds);
     50        public static abstract class Item {
     51                public boolean focus = false;
     52                abstract void addToPanel(JPanel p);
     53                abstract void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds);
     54                boolean requestFocusInWindow() {return false;}
    5355        }
    5456       
    55         public static class Text implements Item {
     57        public static class Text extends Item {
    5658                public String key;
    5759                public String text;
     
    6163                private JTextField value = new JTextField();
    6264
    63                 public void addToPanel(JPanel p) {
     65                @Override public void addToPanel(JPanel p) {
    6466                        value.setText(default_ == null ? "" : default_);
    6567                        p.add(new JLabel(text), GBC.std().insets(0,0,10,0));
    6668                        p.add(value, GBC.eol().fill(GBC.HORIZONTAL));
    6769                }
    68                 public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) {
     70                @Override public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) {
    6971                        String v = value.getText();
    7072                        if (delete_if_empty && v.length() == 0)
     
    7274                        cmds.add(new ChangePropertyCommand(sel, key, v));
    7375                }
    74         }
    75 
    76         public static class Check implements Item {
     76                @Override boolean requestFocusInWindow() {return value.requestFocusInWindow();}
     77        }
     78
     79        public static class Check extends Item {
    7780                public String key;
    7881                public String text;
     
    8184                private JCheckBox check = new JCheckBox();
    8285
    83                 public void addToPanel(JPanel p) {
     86                @Override public void addToPanel(JPanel p) {
    8487                        check.setSelected(default_);
    8588                        check.setText(text);
    8689                        p.add(check, GBC.eol().fill(GBC.HORIZONTAL));
    8790                }
    88                 public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) {
     91                @Override public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) {
    8992                        cmds.add(new ChangePropertyCommand(sel, key, check.isSelected() ? "true" : null));
    9093                }
    91         }
    92 
    93         public static class Combo implements Item {
     94                @Override boolean requestFocusInWindow() {return check.requestFocusInWindow();}
     95        }
     96
     97        public static class Combo extends Item {
    9498                public String key;
    9599                public String text;
     
    102106                private JComboBox combo;
    103107
    104                 public void addToPanel(JPanel p) {
     108                @Override public void addToPanel(JPanel p) {
    105109                        combo = new JComboBox((display_values != null ? display_values : values).split(","));
    106110                        combo.setEditable(editable);
     
    109113                        p.add(combo, GBC.eol().fill(GBC.HORIZONTAL));
    110114                }
    111                 public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) {
     115                @Override public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) {
    112116                        String v = combo.getSelectedIndex() == -1 ? null : values.split(",")[combo.getSelectedIndex()];
    113117                        String str = combo.isEditable()?combo.getEditor().getItem().toString() : v;
     
    116120                        cmds.add(new ChangePropertyCommand(sel, key, str));
    117121                }
    118         }
    119 
    120         public static class Label implements Item {
     122                @Override boolean requestFocusInWindow() {return combo.requestFocusInWindow();}
     123        }
     124
     125        public static class Label extends Item {
    121126                public String text;
    122127
    123                 public void addToPanel(JPanel p) {
     128                @Override public void addToPanel(JPanel p) {
    124129                        p.add(new JLabel(text), GBC.eol());
    125130                }
    126                 public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) {}
    127         }
    128 
    129         public static class Key implements Item {
     131                @Override public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) {}
     132        }
     133
     134        public static class Key extends Item {
    130135                public String key;
    131136                public String value;
    132137
    133                 public void addToPanel(JPanel p) {}
    134                 public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) {
     138                @Override public void addToPanel(JPanel p) {}
     139                @Override public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) {
    135140                        cmds.add(new ChangePropertyCommand(sel, key, value != null && !value.equals("") ? value : null));
    136141                }
     
    252257                if (p == null)
    253258                        return;
    254                 int answer;
    255                 if (p.getComponentCount() == 0)
    256                         answer = JOptionPane.OK_OPTION;
    257                 else
    258                         answer = JOptionPane.showConfirmDialog(Main.parent, p, trn("Change {0} object", "Change {0} objects", sel.size(), sel.size()), JOptionPane.OK_CANCEL_OPTION);
     259                int answer = JOptionPane.OK_OPTION;
     260                if (p.getComponentCount() != 0) {
     261                        final JOptionPane optionPane = new JOptionPane(p, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION){
     262                                @Override public void selectInitialValue() {
     263                                        for (Item i : data) {
     264                                                if (i.focus) {
     265                                                        System.out.println(i.requestFocusInWindow());
     266                                                        return;
     267                                                }
     268                                        }
     269                                }
     270                        };
     271                        optionPane.createDialog(Main.parent, trn("Change {0} object", "Change {0} objects", sel.size(), sel.size())).setVisible(true);
     272                        Object answerObj = optionPane.getValue();
     273                        if (answerObj == null || answerObj == JOptionPane.UNINITIALIZED_VALUE ||
     274                                        (answerObj instanceof Integer && (Integer)answerObj != JOptionPane.OK_OPTION))
     275                                answer = JOptionPane.CANCEL_OPTION;
     276                }
    259277                if (answer == JOptionPane.OK_OPTION) {
    260278                        Command cmd = createCommand(Main.ds.getSelected());
  • src/org/openstreetmap/josm/io/IncompleteDownloader.java

    r175 r212  
    4545
    4646        public void parse() throws SAXException, IOException {
     47                Main.pleaseWaitDlg.currentAction.setText(tr("Downloading incomplete ways..."));
    4748                Main.pleaseWaitDlg.progress.setMaximum(toDownload.size());
    4849                Main.pleaseWaitDlg.progress.setValue(0);
  • src/org/openstreetmap/josm/io/RawCsvReader.java

    r113 r212  
    3434                Collection<GpsPoint> data = new LinkedList<GpsPoint>();
    3535                String formatStr = Main.pref.get("csv.importstring");
    36                 if (formatStr == null)
     36                if (formatStr == null || formatStr.equals(""))
    3737                        formatStr = in.readLine();
    38                 if (formatStr == null)
     38                if (formatStr == null || formatStr.equals(""))
    3939                        throw new SAXException(tr("Could not detect data format string."));
    4040
  • src/org/openstreetmap/josm/tools/XmlObjectParser.java

    r195 r212  
    115115                                }
    116116                        } catch (Exception e) {
     117                                e.printStackTrace(); // !"§%$!"§ SAXException does not dump inner exceptions.
    117118                                throw new SAXException(e);
    118119                        }
Note: See TracChangeset for help on using the changeset viewer.