Changeset 299 in josm
- Timestamp:
- 2007-08-08T02:59:36+02:00 (17 years ago)
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
.settings/org.eclipse.jdt.core.prefs
r86 r299 1 # Fri Apr 21 12:51:47 CEST 20061 #Tue Aug 07 22:54:52 GMT+01:00 2007 2 2 eclipse.preferences.version=1 3 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning 4 org.eclipse.jdt.core.compiler.problem.autoboxing=ignore 5 org.eclipse.jdt.core.compiler.problem.deprecation=warning 6 org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled 7 org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled 8 org.eclipse.jdt.core.compiler.problem.discouragedReference=warning 9 org.eclipse.jdt.core.compiler.problem.emptyStatement=warning 10 org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore 11 org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled 12 org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore 13 org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning 14 org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning 15 org.eclipse.jdt.core.compiler.problem.forbiddenReference=error 16 org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning 17 org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning 18 org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore 19 org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore 20 org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore 21 org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning 22 org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning 23 org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error 24 org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore 25 org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error 26 org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning 27 org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore 28 org.eclipse.jdt.core.compiler.problem.nullReference=ignore 29 org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning 30 org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore 31 org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error 32 org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore 33 org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning 34 org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore 35 org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled 36 org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning 37 org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled 38 org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore 39 org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning 40 org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning 41 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore 42 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning 43 org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning 44 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning 45 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore 46 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning 47 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled 48 org.eclipse.jdt.core.compiler.problem.unusedImport=warning 49 org.eclipse.jdt.core.compiler.problem.unusedLabel=warning 50 org.eclipse.jdt.core.compiler.problem.unusedLocal=warning 51 org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore 52 org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled 53 org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled 54 org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled 55 org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning 56 org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning 3 57 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false 4 58 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -
src/org/openstreetmap/josm/actions/SaveActionBase.java
r298 r299 104 104 return; 105 105 } 106 ((OsmDataLayer)layer).cleanData(null, false);106 layer.cleanData(null, false); 107 107 } catch (IOException e) { 108 108 e.printStackTrace(); -
src/org/openstreetmap/josm/gui/preferences/PluginPreference.java
r298 r299 1 // 1 //License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 package org.openstreetmap.josm.gui.preferences; 3 3 … … 14 14 import java.util.Comparator; 15 15 import java.util.HashMap; 16 import java.util.HashSet; 16 17 import java.util.LinkedList; 17 18 import java.util.Map; 19 import java.util.Set; 18 20 import java.util.SortedMap; 19 21 import java.util.TreeMap; … … 50 52 public String description; 51 53 public String resource; 52 public PluginDescription(String name, String description, String resource) { 54 public String version; 55 public PluginDescription(String name, String description, String resource, String version) { 53 56 this.name = name; 54 57 this.description = description; 55 58 this.resource = resource; 56 } 59 this.version = version; 60 } 57 61 public PluginDescription() { 58 59 } 60 62 } 63 } 64 61 65 private Map<PluginDescription, Boolean> pluginMap; 62 66 private Box pluginPanel = Box.createVerticalBox(); … … 75 79 public void actionPerformed(ActionEvent e) { 76 80 int count = PluginDownloader.downloadDescription(); 77 78 79 80 81 82 83 84 81 if (count > 0) 82 JOptionPane.showMessageDialog(Main.parent, 83 trn("Downloaded plugin information from {0} site", 84 "Downloaded plugin information from {0} sites", count, count)); 85 else 86 JOptionPane.showMessageDialog(Main.parent, tr("No plugin information found.")); 87 refreshPluginPanel(gui); 88 } 85 89 }); 86 90 plugin.add(morePlugins, GBC.std().insets(0,0,10,0)); 87 91 88 92 JButton update = new JButton(tr("Update current")); 89 93 update.addActionListener(new ActionListener(){ 90 94 public void actionPerformed(ActionEvent e) { 91 JOptionPane.showMessageDialog(Main.parent, tr("Not implemented yet.")); 92 } 93 }); 94 //TODO: plugin.add(update, GBC.std().insets(0,0,10,0)); 95 update(); 96 } 97 98 }); 99 plugin.add(update, GBC.std().insets(0,0,10,0)); 95 100 96 101 JButton configureSites = new JButton(tr("Configure Plugin Sites")); … … 98 103 public void actionPerformed(ActionEvent e) { 99 104 JOptionPane.showMessageDialog(Main.parent, tr("Not implemented yet.")); 100 105 } 101 106 }); 102 107 //TODO: plugin.add(configureSites, GBC.std()); … … 105 110 } 106 111 112 private void update() { 113 Set<PluginDescription> toUpdate = new HashSet<PluginDescription>(); 114 StringBuilder toUpdateStr = new StringBuilder(); 115 for (PluginProxy proxy : Main.plugins) { 116 PluginDescription description = findDescription(proxy.info.name); 117 if (description != null && (description.version == null || description.version.equals("")) ? (proxy.info.version != null && proxy.info.version.equals("")) : !description.version.equals(proxy.info.version)) { 118 toUpdate.add(description); 119 toUpdateStr.append(description.name+"\n"); 120 } 121 } 122 if (toUpdate.isEmpty()) { 123 JOptionPane.showMessageDialog(Main.parent, tr("All installed plugins are up to date.")); 124 return; 125 } 126 int answer = JOptionPane.showConfirmDialog(Main.parent, tr("Update the following plugins:\n\n{0}", toUpdateStr.toString()), tr("Update"), JOptionPane.OK_CANCEL_OPTION); 127 if (answer != JOptionPane.OK_OPTION) 128 return; 129 PluginDownloader.update(toUpdate); 130 } 131 132 private PluginDescription findDescription(String name) { 133 for (PluginDescription d : pluginMap.keySet()) 134 if (d.name.equals(name)) 135 return d; 136 return null; 137 } 138 107 139 private void refreshPluginPanel(final PreferenceDialog gui) { 108 109 110 140 Collection<PluginDescription> availablePlugins = getAvailablePlugins(); 141 pluginMap = new HashMap<PluginDescription, Boolean>(); 142 pluginPanel.removeAll(); 111 143 Collection<String> enabledPlugins = Arrays.asList(Main.pref.get("plugins").split(",")); 112 144 for (final PluginDescription plugin : availablePlugins) { 113 145 boolean enabled = enabledPlugins.contains(plugin.name); 114 final JCheckBox pluginCheck = new JCheckBox(plugin.name , enabled);146 final JCheckBox pluginCheck = new JCheckBox(plugin.name+(plugin.version != null && !plugin.version.equals("") ? " Version: "+plugin.version : ""), enabled); 115 147 pluginPanel.add(pluginCheck); 116 148 … … 130 162 } 131 163 plugin.updateUI(); 132 164 } 133 165 134 166 private Collection<PluginDescription> getAvailablePlugins() { 135 167 SortedMap<String, PluginDescription> availablePlugins = new TreeMap<String, PluginDescription>(new Comparator<String>(){ 136 168 public int compare(String o1, String o2) { 137 138 169 return o1.compareToIgnoreCase(o2); 170 } 139 171 }); 140 172 for (String location : PluginInformation.getPluginLocations()) { … … 148 180 try { 149 181 PluginInformation info = new PluginInformation(f); 150 availablePlugins.put(info.name, new PluginDescription(info.name, info.description, PluginInformation.getURLString(f.getPath()))); 151 } catch (PluginException x) { 152 } 182 if (!availablePlugins.containsKey(info.name)) 183 availablePlugins.put(info.name, new PluginDescription(info.name, info.description, PluginInformation.getURLString(f.getPath()), info.version)); 184 } catch (PluginException x) { 185 } 153 186 } else if (f.getName().matches("^[0-9]+-site.*\\.xml$")) { 154 187 try { 155 156 157 158 159 160 161 162 188 Uniform<PluginDescription> parser = new Uniform<PluginDescription>(new FileReader(f), "plugin", PluginDescription.class); 189 for (PluginDescription pd : parser) 190 if (!availablePlugins.containsKey(pd.name)) 191 availablePlugins.put(pd.name, pd); 192 } catch (Exception e) { 193 e.printStackTrace(); 194 JOptionPane.showMessageDialog(Main.parent, tr("Error reading plugin information file: {0}", f.getName())); 195 } 163 196 } 164 197 } … … 170 203 proxy.info.name, 171 204 proxy.info.description, 172 proxy.info.file == null ? null : PluginInformation.getURLString(proxy.info.file.getPath()))); 173 return availablePlugins.values(); 174 } 205 proxy.info.file == null ? null : PluginInformation.getURLString(proxy.info.file.getPath()), 206 proxy.info.version)); 207 return availablePlugins.values(); 208 } 175 209 176 210 public void ok() { … … 195 229 if (!PluginDownloader.downloadPlugin(pd)) 196 230 pluginMap.put(pd, false); 197 231 198 232 } 199 233 … … 204 238 if (plugins.endsWith(",")) 205 239 plugins = plugins.substring(0, plugins.length()-1); 206 240 207 241 String oldPlugins = Main.pref.get("plugins"); 208 242 if (!plugins.equals(oldPlugins)) { -
src/org/openstreetmap/josm/plugins/PluginDownloader.java
r298 r299 1 // 1 //License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 /** 3 3 * … … 6 6 7 7 import static org.openstreetmap.josm.tools.I18n.tr; 8 import static org.openstreetmap.josm.tools.I18n.trn; 8 9 9 10 import java.io.BufferedReader; 10 11 import java.io.File; 12 import java.io.FileNotFoundException; 11 13 import java.io.FileOutputStream; 12 14 import java.io.FileWriter; … … 15 17 import java.io.InputStreamReader; 16 18 import java.io.OutputStream; 19 import java.net.MalformedURLException; 17 20 import java.net.URL; 21 import java.util.Collection; 18 22 import java.util.regex.Matcher; 19 23 import java.util.regex.Pattern; … … 22 26 23 27 import org.openstreetmap.josm.Main; 28 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 24 29 import org.openstreetmap.josm.gui.preferences.PluginPreference.PluginDescription; 30 import org.xml.sax.SAXException; 25 31 26 32 public class PluginDownloader { 27 private static final Pattern wiki = Pattern.compile("^</td></tr><tr><td><a class=\"ext-link\" href=\"([^\"]*)\"><span class=\"icon\">([^<]*)</span></a></td><td>[^<]*</td><td>(.*)"); 33 34 private static final class UpdateTask extends PleaseWaitRunnable { 35 private final Collection<PluginDescription> toUpdate; 36 private String errors = ""; 37 private int count = 0; 38 39 private UpdateTask(Collection<PluginDescription> toUpdate) { 40 super(tr("Update Plugins")); 41 this.toUpdate = toUpdate; 42 } 43 44 @Override protected void cancel() { 45 finish(); 46 } 47 48 @Override protected void finish() { 49 if (errors.length() > 0) 50 JOptionPane.showMessageDialog(Main.parent, tr("There were problems with the following plugins:\n\n {0}",errors)); 51 else 52 JOptionPane.showMessageDialog(Main.parent, trn("{0} Plugin successfully updated. Please restart JOSM.", "{0} Plugins successfully updated. Please restart JOSM.", count, count)); 53 } 54 55 @Override protected void realRun() throws SAXException, IOException { 56 for (PluginDescription d : toUpdate) { 57 File tempFile = new File(Main.pref.getPreferencesDir()+"temp.jar"); 58 if (download(d.resource, tempFile)) { 59 tempFile.renameTo(new File(Main.pref.getPreferencesDir()+"plugins/"+d.name+".jar")); 60 count++; 61 } else 62 errors += d.name + "\n"; 63 } 64 } 65 } 66 67 private static final Pattern wiki = Pattern.compile("^</td></tr><tr><td><a class=\"ext-link\" href=\"([^\"]*)\"><span class=\"icon\">([^<]*)</span></a></td><td>[^<]*</td><td>([^<]*)</td><td>(.*)"); 28 68 29 69 public static int downloadDescription() { … … 66 106 b.append(" <resource>"+escape(m.group(1))+"</resource>\n"); 67 107 b.append(" <description>"+escape(m.group(3))+"</description>\n"); 108 b.append(" <version>"+escape(m.group(4))+"</version>\n"); 68 109 b.append(" </plugin>\n"); 69 110 } … … 73 114 74 115 private static String escape(String s) { 75 76 116 return s.replaceAll("<", "<").replaceAll(">", ">"); 117 } 77 118 78 119 public static boolean downloadPlugin(PluginDescription pd) { 79 120 File file = new File(Main.pref.getPreferencesDir()+"plugins/"+pd.name+".jar"); 80 try { 81 InputStream in = new URL(pd.resource).openStream(); 121 if (!download(pd.resource, file)) { 122 JOptionPane.showMessageDialog(Main.parent, tr("Could not download plugin: {0} from {1}", pd.name, pd.resource)); 123 } else { 124 try { 125 PluginInformation.findPlugin(pd.name); 126 return true; 127 } catch (Exception e) { 128 e.printStackTrace(); 129 JOptionPane.showMessageDialog(Main.parent, tr("The plugin {0} seem to be broken or could not be downloaded automatically.", pd.name)); 130 } 131 } 132 if (file.exists()) 133 file.delete(); 134 return false; 135 } 136 137 private static boolean download(String url, File file) { 138 try { 139 InputStream in = new URL(url).openStream(); 82 140 OutputStream out = new FileOutputStream(file); 83 84 85 86 87 88 try {89 PluginInformation.findPlugin(pd.name);90 return true;91 } catch (Exception e) {92 93 JOptionPane.showMessageDialog(Main.parent, tr("The plugin {0} seem to be broken or could not be downloaded automatically.", pd.name));94 } 95 } catch (Exception e) { 96 JOptionPane.showMessageDialog(Main.parent, tr("Could not download plugin: {0} from {1}", pd.name, pd.resource));97 98 if (file.exists()) 99 file.delete(); 100 return false;101 141 byte[] buffer = new byte[8192]; 142 for (int read = in.read(buffer); read != -1; read = in.read(buffer)) 143 out.write(buffer, 0, read); 144 out.close(); 145 in.close(); 146 return true; 147 } catch (MalformedURLException e) { 148 e.printStackTrace(); 149 } catch (FileNotFoundException e) { 150 e.printStackTrace(); 151 } catch (IOException e) { 152 e.printStackTrace(); 153 } 154 return false; 155 } 156 157 public static void update(Collection<PluginDescription> update) { 158 Main.worker.execute(new UpdateTask(update)); 159 } 102 160 } -
src/org/openstreetmap/josm/tools/OpenBrowser.java
r298 r299 52 52 } 53 53 54 private static void linux(String url) throws IOException{54 private static void linux(String url) { 55 55 String[] programs = {"gnome-open", "kfmclient openURL", "firefox"}; 56 56 for (String program : programs) { -
test/unit/org/openstreetmap/josm/testframework/MainMock.java
r298 r299 3 3 4 4 import java.awt.AWTEvent; 5 import java.awt.AWTException;6 5 import java.awt.Toolkit; 7 6 import java.awt.event.AWTEventListener; … … 44 43 } 45 44 46 @BeforeClass public static void startPopupKiller() throws AWTException{45 @BeforeClass public static void startPopupKiller() { 47 46 Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener(){ 48 47 public void eventDispatched(AWTEvent event) {
Note:
See TracChangeset
for help on using the changeset viewer.