Changeset 171 in josm


Ignore:
Timestamp:
Nov 29, 2006 12:32:42 PM (6 years ago)
Author:
imi
Message:
  • fixed bug that properties in advanced preferences could not be deleted
  • added "selected" and "property:key=value" as search criteria
Location:
src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/data/Preferences.java

    r149 r171  
    102102        protected void save() { 
    103103                try { 
    104                         final PrintWriter out = new PrintWriter(new FileWriter( 
    105                                         getPreferencesDir() + "preferences")); 
     104                        final PrintWriter out = new PrintWriter(new FileWriter(getPreferencesDir() + "preferences"), false); 
    106105                        for (final Entry<String, String> e : properties.entrySet()) 
    107106                                if (!e.getValue().equals("")) 
  • src/org/openstreetmap/josm/gui/preferences/AdvancedPreference.java

    r168 r171  
    4949                for (String s : new TreeSet<String>(orig.keySet())) 
    5050                        model.addRow(new String[]{s, Main.pref.get(s)}); 
    51                  
     51 
    5252                JButton add = new JButton(tr("Add")); 
    5353                p.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL)); 
     
    6565                                if (answer == JOptionPane.OK_OPTION) 
    6666                                        model.addRow(new String[]{key.getText(), value.getText()}); 
    67             } 
     67                        } 
    6868                }); 
    69                  
     69 
    7070                JButton edit = new JButton(tr("Edit")); 
    7171                p.add(edit, GBC.std().insets(5,5,5,0)); 
     
    7373                        public void actionPerformed(ActionEvent e) { 
    7474                                edit(gui, list); 
    75             } 
     75                        } 
    7676                }); 
    77                  
     77 
    7878                JButton delete = new JButton(tr("Delete")); 
    7979                p.add(delete, GBC.std().insets(0,5,0,0)); 
     
    8686                                while (list.getSelectedRow() != -1) 
    8787                                        model.removeRow(list.getSelectedRow()); 
    88             } 
     88                        } 
    8989                }); 
    90                  
     90 
    9191                list.addMouseListener(new MouseAdapter(){ 
    9292                        @Override public void mouseClicked(MouseEvent e) { 
    9393                                if (e.getClickCount() == 2) 
    9494                                        edit(gui, list); 
    95             } 
     95                        } 
    9696                }); 
    9797        } 
     
    107107                } 
    108108                for (Entry<String, String> e : orig.entrySet()) 
    109                         Main.pref.put(e.getKey(), e.getValue()); 
     109                        Main.pref.put(e.getKey(), null); 
    110110        } 
    111111 
    112112 
    113113        private void edit(final PreferenceDialog gui, final JTable list) { 
    114             if (list.getSelectedRowCount() != 1) { 
    115                 JOptionPane.showMessageDialog(gui, tr("Please select the row to edit.")); 
    116                 return; 
    117             } 
    118             String v = JOptionPane.showInputDialog(tr("New value for {0}", model.getValueAt(list.getSelectedRow(), 0)), model.getValueAt(list.getSelectedRow(), 1)); 
    119             if (v != null) 
    120                 model.setValueAt(v, list.getSelectedRow(), 1); 
    121     } 
     114                if (list.getSelectedRowCount() != 1) { 
     115                        JOptionPane.showMessageDialog(gui, tr("Please select the row to edit.")); 
     116                        return; 
     117                } 
     118                String v = JOptionPane.showInputDialog(tr("New value for {0}", model.getValueAt(list.getSelectedRow(), 0)), model.getValueAt(list.getSelectedRow(), 1)); 
     119                if (v != null) 
     120                        model.setValueAt(v, list.getSelectedRow(), 1); 
     121        } 
    122122} 
  • src/org/openstreetmap/josm/tools/SearchCompiler.java

    r160 r171  
    119119                @Override public String toString() {return "modified";} 
    120120        } 
     121         
     122        private static class Selected extends Match { 
     123                @Override public boolean match(OsmPrimitive osm) { 
     124                        return osm.selected; 
     125                } 
     126                @Override public String toString() {return "selected";} 
     127        } 
    121128 
    122129        private static class Incomplete extends Match { 
     
    124131                        return osm instanceof Way && ((Way)osm).isIncomplete(); 
    125132                } 
    126                 @Override public String toString() {return "modified";} 
     133                @Override public String toString() {return "incomplete";} 
    127134        } 
    128135         
     
    204211                        else if (value.equals("incomplete")) 
    205212                                c = new Incomplete(); 
     213                        else if (value.equals("selected")) 
     214                                c = new Selected(); 
    206215                        else 
    207216                                c = new Any(value); 
     
    211220                if (key.equals("type")) 
    212221                        c = new ExactType(value); 
    213                 else if (key.equals("id")) { 
     222                else if (key.equals("property")) { 
     223                        String realKey = "", realValue = value; 
     224                        int eqPos = value.indexOf("="); 
     225                        if (eqPos != -1) { 
     226                                realKey = value.substring(0,eqPos); 
     227                                realValue = value.substring(eqPos+1); 
     228                        } 
     229                        c = new KeyValue(realKey, realValue, notValue); 
     230                } else if (key.equals("id")) { 
    214231                        try { 
    215232                                c = new Id(Long.parseLong(value)); 
Note: See TracChangeset for help on using the changeset viewer.