Ignore:
Timestamp:
2012-02-18T15:10:01+01:00 (13 years ago)
Author:
bastik
Message:

update because of core api change (preferences - rev. 4968)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/customurl/UtilsPluginPreferences.java

    r27543 r27857  
    1 /*
    2  * To change this template, choose Tools | Templates
    3  * and open the template in the editor.
    4  */
     1// License: GPL. For details, see LICENSE file.
    52package utilsplugin2.customurl;
    63
     
    2219import javax.swing.event.TableModelListener;
    2320import javax.swing.table.DefaultTableModel;
    24 import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     21import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    2522import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    2623import org.openstreetmap.josm.tools.GBC;
     
    2825import static org.openstreetmap.josm.tools.I18n.*;
    2926
    30 public class UtilsPluginPreferences  implements PreferenceSetting {
     27public class UtilsPluginPreferences extends DefaultTabPreferenceSetting {
    3128    HistoryComboBox combo1=new HistoryComboBox();
    3229    JTable table;
     
    3532    JButton saveButton;
    3633
     34    public UtilsPluginPreferences() {
     35        super("utils", tr("Utilsplugin2 settings [TESTING]"), tr("Here you can change some preferences of Utilsplugin2 functions"));
     36    }
     37
    3738    @Override
    3839    public void addGui(PreferenceTabbedPane gui) {
    39         JPanel pp = gui.createPreferenceTab("utils", tr("Utilsplugin2 settings [TESTING]"),
    40                 tr("Here you can change some preferences of Utilsplugin2 functions"));
     40        JPanel pp = gui.createPreferenceTab(this);
    4141        JPanel all = new JPanel();
    4242        GridBagLayout layout = new GridBagLayout();
    4343        all.setLayout(layout);
    44        
     44
    4545        // FIXME: get rid of hardcoded URLS
    46        
     46
    4747        String addr =  URLList.getSelectedURL();
    4848        table=new JTable(new DefaultTableModel(null,new String[]{"Title","URL"}));
    49        
     49
    5050        List<String> items = URLList.getURLList();
    51         //System.out.println("pref:"+addr);
    52        
     51
    5352        resetButton = new JButton(tr("Reset"));
    5453        resetButton.addActionListener(new ActionListener() {
     
    5756            }
    5857        });
    59        
     58
    6059        saveButton = new JButton(tr("Save to file"));
    6160        saveButton.addActionListener(new ActionListener() {
     
    6463            }
    6564        });
    66        
     65
    6766        loadButton = new JButton(tr("Load from file"));
    6867        loadButton.addActionListener(new ActionListener() {
     
    7170            }
    7271        });
    73        
     72
    7473        fillRows(items);
    75        
     74
    7675        HtmlPanel help = new HtmlPanel(tr("Please edit custom URLs and select one row to use with the tool<br/>"
    7776                + " <b>&#123;key&#125;</b> is replaced with the tag value<br/>"
     
    8079                + " <b>&#123;#lat&#125; , &#123;#lon&#125;</b> is replaced with map center latitude/longitude <br/>"
    8180                + " Your can manually load settings from file <b>customurl.txt</b> in JOSM folder"));
    82        
     81
    8382        all.add(new JLabel(tr("Custom URL configuration")),GBC.std().insets(5,10,0,0));
    8483        all.add(resetButton,GBC.std().insets(25,10,0,0));
     
    8685        all.add(saveButton,GBC.eol().insets(25,10,0,0));
    8786        all.add(help,GBC.eop().insets(5,10,0,0));
    88        
     87
    8988        table.getColumnModel().getColumn(0).setPreferredWidth(150);
    9089        table.getColumnModel().getColumn(0).setMaxWidth(300);
     
    9998                if (row<0  || column<0) return;
    10099                String data = (String)model.getValueAt(row, column);
    101                 if (data!=null && data.length()>0 && row==model.getRowCount()-1) 
     100                if (data!=null && data.length()>0 && row==model.getRowCount()-1)
    102101                    model.addRow(new String[]{"",""});
    103102            }
    104103        });
    105104        all.add(table,GBC.eop().fill());
    106        
     105
    107106        pp.add(all, GBC.eol().fill(GridBagConstraints.BOTH));
    108107    }
     
    135134        List<String> lst = readItemsFromTable();
    136135        URLList.updateURLList(lst);
    137        
     136
    138137        return false;
    139138    }
    140 
    141    
    142    
    143139
    144140    private List<String> readItemsFromTable() {
Note: See TracChangeset for help on using the changeset viewer.