- Timestamp:
- 2007-04-03T17:46:00+02:00 (18 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/Main.java
r203 r207 14 14 import java.util.LinkedList; 15 15 import java.util.Map; 16 import java.util.SortedMap; 16 17 import java.util.StringTokenizer; 18 import java.util.TreeMap; 17 19 import java.util.concurrent.Executor; 18 20 import java.util.concurrent.Executors; … … 190 192 191 193 /** 192 * Load all plugins specified in preferences. Has to be called after the complete 193 * GUI has been set up. (post-constructor) 194 */ 195 public void loadPlugins() { 196 if (Main.pref.hasKey("plugins")) { 197 for (String pluginName : Main.pref.get("plugins").split(",")) { 194 * Load all plugins specified in preferences. If the parameter is <code>true</code>, all 195 * early plugins are loaded (before constructor). 196 */ 197 public static void loadPlugins(boolean early) { 198 if (!Main.pref.hasKey("plugins")) 199 return; 200 SortedMap<Integer, Collection<PluginInformation>> p = new TreeMap<Integer, Collection<PluginInformation>>(); 201 for (String pluginName : Main.pref.get("plugins").split(",")) { 202 File pluginFile = new File(pref.getPreferencesDir()+"plugins/"+pluginName+".jar"); 203 if (pluginFile.exists()) { 204 PluginInformation info = new PluginInformation(pluginFile); 205 if (info.early != early) 206 continue; 207 if (!p.containsKey(info.stage)) 208 p.put(info.stage, new LinkedList<PluginInformation>()); 209 p.get(info.stage).add(info); 210 } else { 211 if (early) 212 System.out.println("Plugin not found: "+pluginName); // do not translate 213 else 214 JOptionPane.showMessageDialog(Main.parent, tr("Plugin not found: {0}.", pluginName)); 215 } 216 } 217 for (Collection<PluginInformation> c : p.values()) { 218 for (PluginInformation info : c) { 198 219 try { 199 File pluginFile = new File(pref.getPreferencesDir()+"plugins/"+pluginName+".jar"); 200 if (pluginFile.exists()) { 201 PluginInformation info = new PluginInformation(pluginFile); 202 Class<?> klass = info.loadClass(); 203 ImageProvider.sources.add(0, klass); 204 plugins.add(info.load(klass)); 205 } else 206 JOptionPane.showMessageDialog(Main.parent, tr("Plugin not found: {0}.", pluginName)); 220 Class<?> klass = info.loadClass(); 221 ImageProvider.sources.add(0, klass); 222 System.out.println("loading "+info.name); 223 plugins.add(info.load(klass)); 207 224 } catch (PluginException e) { 208 225 e.printStackTrace(); 209 JOptionPane.showMessageDialog(Main.parent, tr("Could not load plugin {0}.", pluginName)); 226 if (early) 227 System.out.println("Could not load plugin: "+info.name); // do not translate 228 else 229 JOptionPane.showMessageDialog(Main.parent, tr("Could not load plugin {0}.", info.name)); 210 230 } 211 231 } … … 307 327 bounds = !args.containsKey("no-fullscreen") ? new Rectangle(0,0,screenDimension.width,screenDimension.height) : new Rectangle(1000,740); 308 328 309 pleaseWaitDlg = new PleaseWaitDialog(); 329 pleaseWaitDlg = new PleaseWaitDialog(); 310 330 } 311 331 … … 319 339 if (args.containsKey("selection")) 320 340 for (String s : args.get("selection")) 321 SearchAction.search(s, SearchAction.SearchMode.add); 341 SearchAction.search(s, SearchAction.SearchMode.add, false); 322 342 } 323 343 -
src/org/openstreetmap/josm/actions/search/SearchAction.java
r191 r207 9 9 10 10 import javax.swing.ButtonGroup; 11 import javax.swing.JCheckBox; 11 12 import javax.swing.JLabel; 12 13 import javax.swing.JOptionPane; … … 51 52 bg.add(add); 52 53 bg.add(remove); 54 55 JCheckBox caseSensitive = new JCheckBox(tr("case sensitive"), false); 53 56 54 57 JPanel p = new JPanel(new GridBagLayout()); … … 57 60 p.add(replace, GBC.eol()); 58 61 p.add(add, GBC.eol()); 59 p.add(remove, GBC.eol()); 62 p.add(remove, GBC.eop()); 63 p.add(caseSensitive, GBC.eol()); 60 64 JOptionPane pane = new JOptionPane(p, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null){ 61 65 @Override public void selectInitialValue() { … … 69 73 lastSearch = input.getText(); 70 74 SearchAction.SearchMode mode = replace.isSelected() ? SearchAction.SearchMode.replace : (add.isSelected() ? SearchAction.SearchMode.add : SearchAction.SearchMode.remove); 71 search(lastSearch, mode); 75 search(lastSearch, mode, caseSensitive.isSelected()); 72 76 } 73 77 74 public static void search(String search, SearchMode mode) { 78 public static void search(String search, SearchMode mode, boolean caseSensitive) { 75 79 if (search.startsWith("http://") || search.startsWith("ftp://") || search.startsWith("https://") || search.startsWith("file:/")) { 76 80 SelectionWebsiteLoader loader = new SelectionWebsiteLoader(search, mode); … … 81 85 } 82 86 Collection<OsmPrimitive> sel = Main.ds.getSelected(); 83 SearchCompiler.Match matcher = SearchCompiler.compile(search); 87 SearchCompiler.Match matcher = SearchCompiler.compile(search, caseSensitive); 84 88 for (OsmPrimitive osm : Main.ds.allNonDeletedPrimitives()) { 85 89 if (mode == SearchMode.replace) { -
src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r191 r207 17 17 public class SearchCompiler { 18 18 19 boolean caseSensitive = false; 20 19 21 abstract public static class Match { 20 22 abstract public boolean match(OsmPrimitive osm); … … 65 67 } 66 68 67 private staticclass KeyValue extends Match {69 private class KeyValue extends Match { 68 70 private String key; 69 71 private String value; … … 78 80 if (value == null) 79 81 return notValue; 80 return (value.toLowerCase().indexOf(this.value.toLowerCase()) != -1) != notValue; 82 String v1 = caseSensitive ? value : value.toLowerCase(); 83 String v2 = caseSensitive ? this.value : this.value.toLowerCase(); 84 return (v1.indexOf(v2) != -1) != notValue; 81 85 } 82 86 @Override public String toString() {return key+"="+(notValue?"!":"")+value;} 83 87 } 84 88 85 private staticclass Any extends Match {89 private class Any extends Match { 86 90 private String s; 87 91 public Any(String s) {this.s = s;} … … 89 93 if (osm.keys == null) 90 94 return s.equals(""); 91 for (Entry<String, String> e : osm.keys.entrySet()) 92 if (e.getKey().toLowerCase().indexOf(s.toLowerCase()) != -1 93 || e.getValue().toLowerCase().indexOf(s.toLowerCase()) != -1) 95 for (Entry<String, String> e : osm.keys.entrySet()) { 96 String key = caseSensitive ? e.getKey() : e.getKey().toLowerCase(); 97 String value = caseSensitive ? e.getValue() : e.getValue().toLowerCase(); 98 String search = caseSensitive ? s : s.toLowerCase(); 99 if (key.indexOf(search) != -1 || value.indexOf(search) != -1) 94 100 return true; 101 } 95 102 return false; 96 103 } … … 134 141 } 135 142 136 public static Match compile(String searchStr) { 137 return new SearchCompiler().parse(new PushbackReader(new StringReader(searchStr))); 143 public static Match compile(String searchStr, boolean caseSensitive) { 144 SearchCompiler searchCompiler = new SearchCompiler(); 145 searchCompiler.caseSensitive = caseSensitive; 146 return searchCompiler.parse(new PushbackReader(new StringReader(searchStr))); 138 147 } 139 148 -
src/org/openstreetmap/josm/gui/MainApplication.java
r205 r207 21 21 22 22 import org.openstreetmap.josm.Main; 23 import org.openstreetmap.josm.plugins.PluginException;24 23 import org.openstreetmap.josm.plugins.PluginInformation; 25 24 import org.openstreetmap.josm.tools.BugReportExceptionHandler; 26 import org.openstreetmap.josm.tools.ImageProvider;27 25 /** 28 26 * Main window class application. … … 119 117 120 118 // load the early plugins 121 if (Main.pref.hasKey("plugins")) { 122 for (String pluginName : Main.pref.get("plugins").split(",")) { 123 try { 124 File pluginFile = new File(pref.getPreferencesDir()+"plugins/"+pluginName+".jar"); 125 if (pluginFile.exists()) { 126 PluginInformation info = new PluginInformation(pluginFile); 127 if (!info.early) 128 continue; 129 Class<?> klass = info.loadClass(); 130 ImageProvider.sources.add(0, klass); 131 Main.plugins.add(info.load(klass)); 132 } else 133 System.out.println("Plugin not found: "+pluginName); 134 } catch (PluginException e) { 135 System.out.println("Could not load plugin "+pluginName); 136 e.printStackTrace(); 137 } 138 } 139 } 119 Main.loadPlugins(true); 140 120 141 121 if (argList.contains("--help") || argList.contains("-?") || argList.contains("-h")) { … … 171 151 Main.parent = mainFrame; 172 152 final Main main = new MainApplication(mainFrame); 173 main.loadPlugins();153 Main.loadPlugins(false); 174 154 175 155 mainFrame.setVisible(true); -
src/org/openstreetmap/josm/plugins/PluginInformation.java
r192 r207 40 40 public final boolean early; 41 41 public final String author; 42 public final int stage; 42 43 public final List<URL> libraries = new ArrayList<URL>(); 43 44 … … 57 58 description = attr.getValue("Plugin-Description"); 58 59 early = Boolean.parseBoolean(attr.getValue("Plugin-Early")); 60 String stageStr = attr.getValue("Plugin-Stage"); 61 stage = stageStr == null ? 50 : Integer.parseInt(stageStr); 59 62 author = attr.getValue("Author"); 60 63 libraries.add(new URL(getURLString(file.getAbsolutePath())));
Note:
See TracChangeset
for help on using the changeset viewer.