Changeset 12321 in osm for applications


Ignore:
Timestamp:
2008-12-13T18:11:39+01:00 (16 years ago)
Author:
stoecker
Message:

updated default entry handling

Location:
applications/editors/josm/plugins/wmsplugin
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPlugin.java

    r12187 r12321  
    1010import java.util.Map;
    1111import java.util.TreeSet;
     12import java.util.TreeMap;
    1213import java.io.*;
    1314
     
    4041
    4142        static ArrayList<WMSInfo> wmsList = new ArrayList<WMSInfo>();
     43        static TreeMap<String,String> wmsListDefault = new TreeMap<String,String>();
    4244
    4345        // remember state of menu item to restore on changed preferences
     
    102104                                wmsList.add(new WMSInfo(name, url, prefid));
    103105                }
    104                 setDefault(tr("Landsat"), "http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&"+
     106                setDefault(true, tr("Landsat"), "http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&"+
    105107                "layers=global_mosaic&styles=&srs=EPSG:4326&format=image/jpeg");
    106                 setDefault(tr("NPE Maps"), "http://nick.dev.openstreetmap.org/openpaths/freemap.php?layers=npe&");
    107                 setDefault(tr("YAHOO (GNOME)"), "yahoo://gnome-web-photo --mode=photo --format=png {0} /dev/stdout");
    108                 setDefault(tr("YAHOO (GNOME Fix)"), "yahoo://gnome-web-photo-fixed {0}");
    109                 setDefault(tr("YAHOO (WebKit)"), "yahoo://webkit-image {0}");
     108                setDefault(true, tr("NPE Maps"), "http://nick.dev.openstreetmap.org/openpaths/freemap.php?layers=npe&");
     109                setDefault(false, tr("YAHOO (GNOME)"), "yahoo://gnome-web-photo --mode=photo --format=png {0} /dev/stdout");
     110                setDefault(false, tr("YAHOO (GNOME Fix)"), "yahoo://gnome-web-photo-fixed {0}");
     111                setDefault(true, tr("YAHOO (WebKit)"), "yahoo://webkit-image {0}");
     112                setDefault(false, tr("YAHOO (WebKit GTK)"), "yahoo://webkit-image-gtk {0}");
    110113
    111114                Collections.sort(wmsList);
     
    140143
    141144        /* add a default entry in case the URL does not yet exist */
    142         private static void setDefault(String name, String url)
     145        private static void setDefault(Boolean force, String name, String url)
    143146        {
    144147                String testurl = url.replaceAll("=", "_");
    145                 if(!Main.pref.getBoolean("wmsplugin.default."+testurl))
     148                wmsListDefault.put(name, url);
     149
     150                if(force && !Main.pref.getBoolean("wmsplugin.default."+testurl))
    146151                {
    147152                        Main.pref.put("wmsplugin.default."+testurl, true);
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPreferenceEditor.java

    r10767 r12321  
    3131        private DefaultTableModel model;
    3232        private HashMap<Integer, WMSInfo> oldValues = new HashMap<Integer, WMSInfo>();
    33        
     33
    3434        public void addGui(final PreferenceDialog gui) {
    3535                JPanel p = gui.createPreferenceTab("wms", tr("WMS Plugin Preferences"), tr("Modify list of WMS servers displayed in the WMS plugin menu"));
     
    3939                JScrollPane scroll = new JScrollPane(list);
    4040                p.add(scroll, GBC.eol().fill(GBC.BOTH));
    41                 scroll.setPreferredSize(new Dimension(400,200));
     41                scroll.setPreferredSize(new Dimension(200,200));
    4242               
    4343                for (WMSInfo i : WMSPlugin.wmsList) {
     
    4545                        model.addRow(new String[]{i.name, i.url});
    4646                }
    47                
     47
     48                final DefaultTableModel modeldef = new DefaultTableModel(
     49                new String[]{tr("Menu Name (Default)"), tr("WMS URL (Default)")}, 0);
     50                final JTable listdef = new JTable(modeldef){
     51                        public boolean isCellEditable(int row,int column){return false;}
     52                };;
     53                JScrollPane scrolldef = new JScrollPane(listdef);
     54                p.add(scrolldef, GBC.eol().insets(0,5,0,0).fill(GBC.BOTH));
     55                scrolldef.setPreferredSize(new Dimension(200,200));
     56
     57                for (Map.Entry<String,String> i : WMSPlugin.wmsListDefault.entrySet()) {
     58                        modeldef.addRow(new String[]{i.getKey(), i.getValue()});
     59                }
     60
    4861                JButton add = new JButton(tr("Add"));
    4962                p.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL));
     
    7689                                        while ((i = list.getSelectedRow()) != -1)
    7790                                                model.removeRow(i);
     91                                }
     92                        }
     93                });
     94               
     95                JButton copy = new JButton(tr("Copy Default"));
     96                p.add(copy, GBC.std().insets(0,5,0,0));
     97                copy.addActionListener(new ActionListener(){
     98                        public void actionPerformed(ActionEvent e) {
     99                                Integer line = listdef.getSelectedRow();
     100                                if (line == -1)
     101                                        JOptionPane.showMessageDialog(gui, tr("Please select the row to copy."));
     102                                else
     103                                {
     104                                        model.addRow(new String[]{modeldef.getValueAt(line, 0).toString(),
     105                                        modeldef.getValueAt(line, 1).toString()});
    78106                                }
    79107                        }
Note: See TracChangeset for help on using the changeset viewer.