Changeset 12603 in osm for applications/editors/josm/plugins/osmarender/src
- Timestamp:
- 2008-12-27T13:23:39+01:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/osmarender/src/OsmarenderPlugin.java
r12588 r12603 7 7 import java.io.BufferedReader; 8 8 import java.io.FileReader; 9 import java.io.File; 9 10 import java.util.Collection; 10 11 import java.util.HashSet; … … 19 20 20 21 import org.openstreetmap.josm.Main; 22 import org.openstreetmap.josm.actions.JosmAction; 21 23 import org.openstreetmap.josm.data.Bounds; 22 24 import org.openstreetmap.josm.data.coor.LatLon; … … 27 29 import org.openstreetmap.josm.data.osm.visitor.CollectBackReferencesVisitor; 28 30 import org.openstreetmap.josm.gui.MapFrame; 31 import org.openstreetmap.josm.gui.MainMenu; 29 32 import org.openstreetmap.josm.gui.preferences.PreferenceDialog; 30 33 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; … … 35 38 public class OsmarenderPlugin extends Plugin { 36 39 37 private class Action extends AbstractAction {40 private class Action extends JosmAction { 38 41 39 42 public Action() { 40 super( "Osmarender");43 super(tr("Osmarender"), null, tr("Osmarender"), null, true); 41 44 } 42 45 … … 73 76 try { 74 77 // write to plugin dir 75 OsmWriter.output(new FileOutputStream(getPluginDir()+ "data.osm"), new OsmWriter.All(fromDataSet, true));78 OsmWriter.output(new FileOutputStream(getPluginDir()+File.separator+"data.osm"), new OsmWriter.All(fromDataSet, true)); 76 79 77 80 // get the exec line 78 81 String exec = firefox; 79 82 if (System.getProperty("os.name").startsWith("Windows")) 80 exec += " file:///"+getPluginDir().replace('\\','/').replace(" ","%20")+ "generated.xml\"";83 exec += " file:///"+getPluginDir().replace('\\','/').replace(" ","%20")+File.separator+"generated.xml\""; 81 84 else 82 exec += " "+getPluginDir()+ "generated.xml";85 exec += " "+getPluginDir()+File.separator+"generated.xml"; 83 86 84 87 // launch up the viewer … … 90 93 } 91 94 92 private JMenu view; 93 private JMenuItem osmarenderMenu = new JMenuItem(new Action()); 95 private JMenuItem osmarenderMenu; 94 96 95 97 public OsmarenderPlugin() throws IOException { 96 JMenuBar menu = Main.main.menu; 97 view = null; 98 for (int i = 0; i < menu.getMenuCount(); ++i) { 99 if (menu.getMenu(i) != null && tr("View").equals(menu.getMenu(i).getText())) { 100 view = menu.getMenu(i); 101 break; 102 } 103 } 104 if (view == null) { 105 view = new JMenu(tr("View")); 106 menu.add(view, 2); 107 view.setVisible(false); 108 } 109 view.add(osmarenderMenu); 98 osmarenderMenu = MainMenu.add(Main.main.menu.viewMenu, new Action()); 110 99 osmarenderMenu.setVisible(false); 111 100 … … 120 109 // disable 121 110 osmarenderMenu.setVisible(false); 122 if (view.getMenuComponentCount() == 1)123 view.setVisible(false);124 111 } else if (oldFrame == null && newFrame != null) { 125 112 // enable 126 113 osmarenderMenu.setVisible(true); 127 if (view.getMenuComponentCount() == 1)128 view.setVisible(true);129 114 } 130 115 } … … 154 139 155 140 BufferedReader reader = new BufferedReader( 156 new FileReader( getPluginDir() + "osm-map-features.xml") );157 PrintWriter writer = new PrintWriter( getPluginDir() + "generated.xml");141 new FileReader( getPluginDir() + File.separator + "osm-map-features.xml") ); 142 PrintWriter writer = new PrintWriter( getPluginDir() + File.separator + "generated.xml"); 158 143 159 144 // osm-map-fetaures.xml contain two placemark
Note:
See TracChangeset
for help on using the changeset viewer.