Ignore:
Timestamp:
2011-09-04T08:59:08+02:00 (13 years ago)
Author:
akks
Message:

'Utilsplugin2: added setting tab'

Location:
applications/editors/josm/plugins/utilsplugin2
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/utilsplugin2/build.xml

    r26621 r26624  
    3030<project name="utilsplugin2" default="dist" basedir=".">
    3131    <!-- enter the SVN commit message -->
    32     <property name="commit.message" value="Utilsplugin2: Open custom URL in browser by Shift-\"/>
     32    <property name="commit.message" value="Utilsplugin2: added setting tab"/>
    3333    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    3434    <property name="plugin.main.version" value="4395"/>
  • applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/OpenPageAction.java

    r26603 r26624  
    5555            p=sel.iterator().next();
    5656        } else {
    57             showConfigDialog();
     57            JOptionPane.showMessageDialog(
     58                    Main.parent,
     59                    tr("Please select one element to open custom URL for it. You can choose the URL in Preferences, Utils tab."),
     60                    tr("Information"),
     61                    JOptionPane.INFORMATION_MESSAGE
     62            );
    5863            return;
    5964        }
     
    6772        try {
    6873        while (m.find()) {
    69                 System.out.println(m.group());
    7074                key=m.group(1);
    7175                if (key.equals("#id")) {
     
    9195            return;
    9296        }
    93         System.out.println(i);
    9497        for (int j=0;j<i;j++){
    9598            addr = addr.replace(keys[j],vals[j]);
    9699        }
    97         System.out.println(addr);
    98100        try {
    99101            OpenBrowser.displayUrl(addr);
     
    120122        setEnabled(selection != null );
    121123    }
    122 
    123     private void showConfigDialog() {
    124         JPanel all = new JPanel();
    125         GridBagLayout layout = new GridBagLayout();
    126         all.setLayout(layout);
    127        
    128         HistoryComboBox combo1=new HistoryComboBox();
    129        
    130         // FIXME: get rid of hardcoded URLS
    131         ArrayList<String> items=new ArrayList<String>();
    132         items.add(defaultURL);
    133         items.add("http://latlon.org/buildings?zoom=17&lat={#lat}&lon={#lon}&layers=B");
    134         items.add("http://addresses.amdmi3.ru/?zoom=11&lat={#lat}&lon={#lon}&layers=B00");
    135         items.add("http://www.openstreetmap.org/browse/{#type}/{#id}/history");
    136         items.add("http://www.openstreetmap.org/browse/{#type}/{#id}");
    137         String addr = Main.pref.get("utilsplugin2.customurl", defaultURL);
    138         System.out.println("pref:"+addr);
    139         combo1.setPossibleItems(items);
    140        
    141         HtmlPanel help = new HtmlPanel(tr("You can open custom URL for <b>one</b> selected object<br/>"
    142                 + " <b>&#123;key&#125;</b> is replaced with the tag walue<br/>"
    143                 + " <b>&#123;#id&#125;</b> is replaced with the element ID<br/>"
    144                 + " <b>&#123;#type&#125;</b> is replaced with \"node\",\"way\" or \"relation\" <br/>"
    145                 + " <b>&#123;#lat&#125; , &#123;#lon&#125;</b> is replaced with element latitude/longitude"));
    146         help.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
    147         all.add(help,GBC.eop().insets(5,10,0,0));
    148         all.add(combo1,GBC.eop().insets(5,10,0,0));
    149        
    150         ExtendedDialog dialog = new ExtendedDialog(Main.parent,
    151                 tr("Configure custom URL"),
    152                 new String[] {tr("OK"),tr("Cancel"),}
    153         );
    154         dialog.setContent(all, false);
    155         dialog.setButtonIcons(new String[] {"ok.png","cancel.png",});
    156         dialog.setDefaultButton(1);
    157         dialog.showDialog();
    158        
    159         addr=combo1.getText();
    160         if (dialog.getValue() ==1 && addr.length()>6) Main.pref.put("utilsplugin2.customurl",addr);
    161     }
    162124}
  • applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/UtilsPlugin2.java

    r26603 r26624  
    22package utilsplugin2;
    33
     4import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    45import java.awt.event.KeyEvent;
    56import javax.swing.JMenu;
     
    102103        undoSelection.setEnabled(enabled);
    103104    }
     105    @Override
     106    public PreferenceSetting getPreferenceSetting() {
     107        return new UtilsPluginPreferences();
     108    }
     109
    104110}
Note: See TracChangeset for help on using the changeset viewer.