1 | package mirrored_download;
|
---|
2 |
|
---|
3 | import static org.openstreetmap.josm.tools.I18n.marktr;
|
---|
4 |
|
---|
5 | import java.awt.event.KeyEvent;
|
---|
6 |
|
---|
7 | import javax.swing.JMenu;
|
---|
8 | import javax.swing.JMenuItem;
|
---|
9 |
|
---|
10 | import org.openstreetmap.josm.Main;
|
---|
11 | import org.openstreetmap.josm.actions.JosmAction;
|
---|
12 | import org.openstreetmap.josm.data.ProjectionBounds;
|
---|
13 | import org.openstreetmap.josm.gui.IconToggleButton;
|
---|
14 | import org.openstreetmap.josm.gui.MainMenu;
|
---|
15 | import org.openstreetmap.josm.gui.MapFrame;
|
---|
16 | import org.openstreetmap.josm.gui.MapView;
|
---|
17 | import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
|
---|
18 | import org.openstreetmap.josm.io.CacheFiles;
|
---|
19 | import org.openstreetmap.josm.io.MirroredInputStream;
|
---|
20 | import org.openstreetmap.josm.plugins.Plugin;
|
---|
21 | import org.openstreetmap.josm.plugins.PluginInformation;
|
---|
22 |
|
---|
23 | public class MirroredDownloadPlugin extends Plugin {
|
---|
24 |
|
---|
25 | static JMenu jMenu;
|
---|
26 |
|
---|
27 | public MirroredDownloadPlugin(PluginInformation info)
|
---|
28 | {
|
---|
29 | super(info);
|
---|
30 | refreshMenu();
|
---|
31 | }
|
---|
32 |
|
---|
33 | public static void refreshMenu()
|
---|
34 | {
|
---|
35 | MainMenu menu = Main.main.menu;
|
---|
36 |
|
---|
37 | if (jMenu == null)
|
---|
38 | jMenu = menu.addMenu(marktr("Mirrored Download"), KeyEvent.VK_P, menu.defaultMenuPos, "help");
|
---|
39 | else
|
---|
40 | jMenu.removeAll();
|
---|
41 |
|
---|
42 | jMenu.addSeparator();
|
---|
43 | jMenu.add(new JMenuItem(new DownloadAction2()));
|
---|
44 | jMenu.add(new JMenuItem(new UrlSelectionAction()));
|
---|
45 | setEnabledAll(true);
|
---|
46 | }
|
---|
47 |
|
---|
48 | private static void setEnabledAll(boolean isEnabled)
|
---|
49 | {
|
---|
50 | for(int i=0; i < jMenu.getItemCount(); i++) {
|
---|
51 | JMenuItem item = jMenu.getItem(i);
|
---|
52 |
|
---|
53 | if(item != null) item.setEnabled(isEnabled);
|
---|
54 | }
|
---|
55 | }
|
---|
56 |
|
---|
57 | private static String downloadUrl = "http://overpass.osm.rambler.ru/cgi/xapi?";//"http://overpass-api.de/api/xapi?";
|
---|
58 |
|
---|
59 | public static String getDownloadUrl() {
|
---|
60 | return downloadUrl;
|
---|
61 | }
|
---|
62 | public static void setDownloadUrl(String downloadUrl_) {
|
---|
63 | downloadUrl = downloadUrl_;
|
---|
64 | }
|
---|
65 | }
|
---|