Ignore:
Timestamp:
2015-06-20T23:42:21+02:00 (9 years ago)
Author:
Don-vip
Message:

checkstyle: enable relevant whitespace checks and fix them

Location:
trunk/src/org/openstreetmap/josm/plugins
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/plugins/Plugin.java

    r8506 r8510  
    121121            }
    122122            byte[] buffer = new byte[8192];
    123             for(int len = in.read(buffer); len > 0; len = in.read(buffer)) {
     123            for (int len = in.read(buffer); len > 0; len = in.read(buffer)) {
    124124                out.write(buffer, 0, len);
    125125            }
  • trunk/src/org/openstreetmap/josm/plugins/PluginDownloadTask.java

    r8443 r8510  
    7171     */
    7272    public PluginDownloadTask(ProgressMonitor monitor, Collection<PluginInformation> toUpdate, String title) {
    73         super(title, monitor == null? NullProgressMonitor.INSTANCE: monitor, false /* don't ignore exceptions */);
     73        super(title, monitor == null ? NullProgressMonitor.INSTANCE : monitor, false /* don't ignore exceptions */);
    7474        CheckParameterUtil.ensureParameterNotNull(toUpdate, "toUpdate");
    7575        this.toUpdate.addAll(toUpdate);
     
    9191    protected void cancel() {
    9292        this.canceled = true;
    93         synchronized(this) {
     93        synchronized (this) {
    9494            if (downloadConnection != null) {
    9595                downloadConnection.disconnect();
     
    101101    protected void finish() {}
    102102
    103     protected void download(PluginInformation pi, File file) throws PluginDownloadException{
     103    protected void download(PluginInformation pi, File file) throws PluginDownloadException {
    104104        if (pi.mainversion > Version.getInstance().getVersion()) {
    105105            ExtendedDialog dialog = new ExtendedDialog(
     
    124124            }
    125125            URL url = new URL(pi.downloadlink);
    126             synchronized(this) {
     126            synchronized (this) {
    127127                downloadConnection = CachedFile.connectFollowingRedirect(url, PLUGIN_MIME_TYPES, null);
    128128            }
     
    146146            throw new PluginDownloadException(e);
    147147        } finally {
    148             synchronized(this) {
     148            synchronized (this) {
    149149                downloadConnection = null;
    150150            }
     
    168168            try {
    169169                download(d, pluginFile);
    170             } catch(PluginDownloadException e) {
     170            } catch (PluginDownloadException e) {
    171171                Main.error(e);
    172172                failed.add(d);
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r8509 r8510  
    100100            new DeprecatedPlugin("tways-0.2", IN_CORE),
    101101            new DeprecatedPlugin("geotagged", IN_CORE),
    102             new DeprecatedPlugin("landsat", tr("replaced by new {0} plugin","lakewalker")),
     102            new DeprecatedPlugin("landsat", tr("replaced by new {0} plugin", "lakewalker")),
    103103            new DeprecatedPlugin("namefinder", IN_CORE),
    104104            new DeprecatedPlugin("waypoints", IN_CORE),
    105105            new DeprecatedPlugin("slippy_map_chooser", IN_CORE),
    106             new DeprecatedPlugin("tcx-support", tr("replaced by new {0} plugin","dataimport")),
     106            new DeprecatedPlugin("tcx-support", tr("replaced by new {0} plugin", "dataimport")),
    107107            new DeprecatedPlugin("usertools", IN_CORE),
    108108            new DeprecatedPlugin("AgPifoJ", IN_CORE),
     
    117117            new DeprecatedPlugin("wmsplugin", IN_CORE),
    118118            new DeprecatedPlugin("ParallelWay", IN_CORE),
    119             new DeprecatedPlugin("dumbutils", tr("replaced by new {0} plugin","utilsplugin2")),
     119            new DeprecatedPlugin("dumbutils", tr("replaced by new {0} plugin", "utilsplugin2")),
    120120            new DeprecatedPlugin("ImproveWayAccuracy", IN_CORE),
    121             new DeprecatedPlugin("Curves", tr("replaced by new {0} plugin","utilsplugin2")),
     121            new DeprecatedPlugin("Curves", tr("replaced by new {0} plugin", "utilsplugin2")),
    122122            new DeprecatedPlugin("epsg31287", tr("replaced by new {0} plugin", "proj4j")),
    123123            new DeprecatedPlugin("licensechange", tr("no longer required")),
     
    241241     */
    242242    private static final List<ClassLoader> sources = new LinkedList<>();
    243 
    244243    static {
    245244        try {
     
    321320                    + "<br>This plugin is no longer developed and very likely will produce errors."
    322321                    +"<br>It should be disabled.<br>Delete from preferences?</html>", unmaintained);
    323             if (confirmDisablePlugin(parent, msg,unmaintained)) {
     322            if (confirmDisablePlugin(parent, msg, unmaintained)) {
    324323                Main.pref.removeFromCollection("plugins", unmaintained);
    325324                plugins.remove(unmaintained);
     
    818817            try {
    819818                future.get();
    820             } catch(ExecutionException e) {
     819            } catch (ExecutionException e) {
    821820                Main.error(e);
    822821                return null;
    823             } catch(InterruptedException e) {
     822            } catch (InterruptedException e) {
    824823                Main.warn("InterruptedException in "+PluginHandler.class.getSimpleName()+" while loading locally available plugin information");
    825824                return null;
     
    879878            monitor.subTask(tr("Removing unmaintained plugins..."));
    880879            filterUnmaintainedPlugins(parent, plugins);
    881             Map<String, PluginInformation> infos = loadLocallyAvailablePluginInformation(monitor.createSubTaskMonitor(1,false));
     880            Map<String, PluginInformation> infos = loadLocallyAvailablePluginInformation(monitor.createSubTaskMonitor(1, false));
    882881            List<PluginInformation> ret = new LinkedList<>();
    883882            for (Iterator<String> it = plugins.iterator(); it.hasNext();) {
     
    10421041                //
    10431042                pluginDownloadTask = new PluginDownloadTask(
    1044                         monitor.createSubTaskMonitor(1,false),
     1043                        monitor.createSubTaskMonitor(1, false),
    10451044                        pluginsToDownload,
    10461045                        tr("Update plugins")
     
    10501049                try {
    10511050                    future.get();
    1052                 } catch(ExecutionException e) {
     1051                } catch (ExecutionException e) {
    10531052                    Main.error(e);
    10541053                    alertFailedPluginUpdate(parent, pluginsToUpdate);
    10551054                    return plugins;
    1056                 } catch(InterruptedException e) {
     1055                } catch (InterruptedException e) {
    10571056                    Main.warn("InterruptedException in "+PluginHandler.class.getSimpleName()+" while updating plugins");
    10581057                    alertFailedPluginUpdate(parent, pluginsToUpdate);
     
    11741173            if (plugin.exists() && !plugin.delete() && dowarn) {
    11751174                Main.warn(tr("Failed to delete outdated plugin ''{0}''.", plugin.toString()));
    1176                 Main.warn(tr("Failed to install already downloaded plugin ''{0}''. Skipping installation. JOSM is still going to load the old plugin version.",
     1175                Main.warn(tr("Failed to install already downloaded plugin ''{0}''. " +
     1176                        "Skipping installation. JOSM is still going to load the old plugin version.",
    11771177                        pluginName));
    11781178                continue;
     
    11921192                Main.warn(tr("Failed to install plugin ''{0}'' from temporary download file ''{1}''. Renaming failed.",
    11931193                        plugin.toString(), updatedPlugin.toString()));
    1194                 Main.warn(tr("Failed to install already downloaded plugin ''{0}''. Skipping installation. JOSM is still going to load the old plugin version.",
     1194                Main.warn(tr("Failed to install already downloaded plugin ''{0}''. " +
     1195                        "Skipping installation. JOSM is still going to load the old plugin version.",
    11951196                        pluginName));
    11961197            }
     
    12501251            try {
    12511252                pi.updateFromJar(new PluginInformation(downloadedPluginFile, pi.name));
    1252             } catch(PluginException e) {
     1253            } catch (PluginException e) {
    12531254                Main.error(e);
    12541255            }
     
    12731274                        tr("Keep plugin"),
    12741275                        ImageProvider.get("cancel"),
    1275                         tr("Click to keep the plugin ''{0}''",plugin.getPluginInformation().name),
     1276                        tr("Click to keep the plugin ''{0}''", plugin.getPluginInformation().name),
    12761277                        null /* no specific help context */
    12771278                )
     
    13581359
    13591360        Set<String> plugins = new HashSet<>(
    1360                 Main.pref.getCollection("plugins",Collections.<String>emptySet())
     1361                Main.pref.getCollection("plugins", Collections.<String>emptySet())
    13611362        );
    13621363        final PluginInformation pluginInfo = plugin.getPluginInformation();
     
    14731474            gc.weightx = 1.0;
    14741475            gc.weighty = 1.0;
    1475             gc.insets = new Insets(5,5,5,5);
     1476            gc.insets = new Insets(5, 5, 5, 5);
    14761477            add(lblMessage = new JMultilineLabel(""), gc);
    14771478            lblMessage.setFont(lblMessage.getFont().deriveFont(Font.PLAIN));
  • trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java

    r8470 r8510  
    9797     * @throws PluginException if reading the manifest fails
    9898     */
    99     public PluginInformation(File file) throws PluginException{
     99    public PluginInformation(File file) throws PluginException {
    100100        this(file, file.getName().substring(0, file.getName().length()-4));
    101101    }
     
    143143            Manifest manifest = new Manifest();
    144144            manifest.read(manifestStream);
    145             if(url != null) {
     145            if (url != null) {
    146146                downloadlink = url;
    147147            }
     
    238238            try {
    239239                mainversion = Integer.parseInt(s);
    240             } catch(NumberFormatException e) {
     240            } catch (NumberFormatException e) {
    241241                Main.warn(tr("Invalid plugin main version ''{0}'' in plugin {1}", s, name));
    242242            }
     
    259259            for (Map.Entry<Object, Object> entry : attr.entrySet()) {
    260260                try {
    261                     String key = ((Attributes.Name)entry.getKey()).toString();
     261                    String key = ((Attributes.Name) entry.getKey()).toString();
    262262                    if (key.endsWith("_Plugin-Url")) {
    263                         int mv = Integer.parseInt(key.substring(0,key.length()-11));
     263                        int mv = Integer.parseInt(key.substring(0, key.length()-11));
    264264                        if (mv <= myv && (mv > mainversion || mainversion > myv)) {
    265                             String v = (String)entry.getValue();
     265                            String v = (String) entry.getValue();
    266266                            int i = v.indexOf(';');
    267267                            if (i > 0) {
    268268                                downloadlink = v.substring(i+1);
    269269                                mainversion = mv;
    270                                 version = v.substring(0,i);
     270                                version = v.substring(0, i);
    271271                                oldmode = true;
    272272                            }
    273273                        }
    274274                    }
    275                 } catch(Exception e) {
     275                } catch (Exception e) {
    276276                    Main.error(e);
    277277                }
     
    333333            Object plugin = c.newInstance(this);
    334334            return new PluginProxy(plugin, this);
    335         } catch(NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
     335        } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
    336336            throw new PluginException(name, e);
    337337        }
     
    436436    public boolean isUpdateRequired(String referenceVersion) {
    437437        if (this.downloadlink == null) return false;
    438         if (this.version == null && referenceVersion!= null)
     438        if (this.version == null && referenceVersion != null)
    439439            return true;
    440440        if (this.version != null && !this.version.equals(referenceVersion))
  • trunk/src/org/openstreetmap/josm/plugins/PluginListParser.java

    r8470 r8510  
    3434     * @throws PluginListParseException if plugin manifest cannot be parsed
    3535     */
    36     protected static PluginInformation createInfo(String name, String url, String manifest) throws PluginListParseException{
     36    protected static PluginInformation createInfo(String name, String url, String manifest) throws PluginListParseException {
    3737        try {
    3838            return new PluginInformation(
     
    5757     * @throws PluginListParseException if something goes wrong while parsing
    5858     */
    59     public List<PluginInformation> parse(InputStream in) throws PluginListParseException{
     59    public List<PluginInformation> parse(InputStream in) throws PluginListParseException {
    6060        List<PluginInformation> ret = new LinkedList<>();
    6161        BufferedReader r = null;
     
    7777                addPluginInformation(ret, name, url, manifest.toString());
    7878                String[] x = line.split(";");
    79                 if(x.length != 2)
     79                if (x.length != 2)
    8080                    throw new IOException(tr("Illegal entry in plugin list."));
    8181                name = x[0];
  • trunk/src/org/openstreetmap/josm/plugins/PluginProxy.java

    r6380 r8510  
    3838    @Override public PreferenceSetting getPreferenceSetting() {
    3939        try {
    40             return (PreferenceSetting)plugin.getClass().getMethod("getPreferenceSetting").invoke(plugin);
     40            return (PreferenceSetting) plugin.getClass().getMethod("getPreferenceSetting").invoke(plugin);
    4141        } catch (NoSuchMethodException e) {
    4242            Main.debug("Plugin "+plugin+" does not define getPreferenceSetting");
  • trunk/src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java

    r8030 r8510  
    4747
    4848    public ReadLocalPluginInformationTask(ProgressMonitor monitor) {
    49         super(tr("Reading local plugin information.."),monitor, false);
     49        super(tr("Reading local plugin information.."), monitor, false);
    5050        availablePlugins = new HashMap<>();
    5151    }
     
    5959    protected void finish() {}
    6060
    61     protected void processJarFile(File f, String pluginName) throws PluginException{
     61    protected void processJarFile(File f, String pluginName) throws PluginException {
    6262        PluginInformation info = new PluginInformation(
    6363                f,
     
    9595            try {
    9696                processLocalPluginInformationFile(f);
    97             } catch(PluginListParseException e) {
     97            } catch (PluginListParseException e) {
    9898                Main.warn(tr("Failed to scan file ''{0}'' for plugin information. Skipping.", fname));
    9999                Main.error(e);
     
    127127                    processJarFile(f, pluginName);
    128128                }
    129             } catch (PluginException e){
     129            } catch (PluginException e) {
    130130                Main.warn("PluginException: "+e.getMessage());
    131131                Main.warn(tr("Failed to scan file ''{0}'' for plugin information. Skipping.", fname));
     
    147147    }
    148148
    149     protected void processLocalPluginInformationFile(File file) throws PluginListParseException{
     149    protected void processLocalPluginInformationFile(File file) throws PluginListParseException {
    150150        try (FileInputStream fin = new FileInputStream(file)) {
    151151            List<PluginInformation> pis = new PluginListParser().parse(fin);
     
    157157                availablePlugins.put(pi.name, pi);
    158158            }
    159         } catch(IOException e) {
     159        } catch (IOException e) {
    160160            throw new PluginListParseException(e);
    161161        }
     
    165165        for (PluginProxy proxy : PluginHandler.pluginList) {
    166166            PluginInformation info = proxy.getPluginInformation();
    167             if (canceled)return;
     167            if (canceled) return;
    168168            if (!availablePlugins.containsKey(info.name)) {
    169169                availablePlugins.put(info.name, info);
     
    176176    protected void filterOldPlugins() {
    177177        for (PluginHandler.DeprecatedPlugin p : PluginHandler.DEPRECATED_PLUGINS) {
    178             if (canceled)return;
     178            if (canceled) return;
    179179            if (availablePlugins.containsKey(p.name)) {
    180180                availablePlugins.remove(p.name);
     
    194194            );
    195195            getProgressMonitor().worked(1);
    196             if (canceled)return;
     196            if (canceled) return;
    197197        }
    198198        analyseInProcessPlugins();
    199199        getProgressMonitor().worked(1);
    200         if (canceled)return;
     200        if (canceled) return;
    201201        filterOldPlugins();
    202202        getProgressMonitor().worked(1);
  • trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java

    r8509 r8510  
    8484     */
    8585    public ReadRemotePluginInformationTask(ProgressMonitor monitor, Collection<String> sites, boolean displayErrMsg) {
    86         super(tr("Download plugin list..."), monitor == null ? NullProgressMonitor.INSTANCE: monitor, false /* don't ignore exceptions */);
     86        super(tr("Download plugin list..."), monitor == null ? NullProgressMonitor.INSTANCE : monitor, false /* don't ignore exceptions */);
    8787        init(sites, displayErrMsg);
    8888    }
     
    9191    protected void cancel() {
    9292        canceled = true;
    93         synchronized(this) {
     93        synchronized (this) {
    9494            if (connection != null) {
    9595                connection.disconnect();
     
    120120            }
    121121            String path = url.getPath();
    122             for (int i =0;i<path.length(); i++) {
     122            for (int i = 0; i < path.length(); i++) {
    123123                char c = path.charAt(i);
    124124                if (Character.isLetterOrDigit(c)) {
     
    130130            sb.append(".txt");
    131131            name = sb.toString();
    132         } catch(MalformedURLException e) {
     132        } catch (MalformedURLException e) {
    133133            name = "site-unknown.txt";
    134134        }
     
    158158
    159159            URL url = new URL(site);
    160             synchronized(this) {
     160            synchronized (this) {
    161161                connection = Utils.openHttpConnection(url);
    162162                connection.setRequestProperty("Cache-Control", "no-cache");
     
    181181            return null;
    182182        } finally {
    183             synchronized(this) {
     183            synchronized (this) {
    184184                if (connection != null) {
    185185                    connection.disconnect();
     
    264264            writer.write(list);
    265265            writer.flush();
    266         } catch(IOException e) {
     266        } catch (IOException e) {
    267267            // just failed to write the cache file. No big deal, but log the exception anyway
    268268            Main.error(e);
     
    328328                    }
    329329            );
    330             if(f != null && f.length > 0) {
     330            if (f != null && f.length > 0) {
    331331                siteCacheFiles.addAll(Arrays.asList(f));
    332332            }
Note: See TracChangeset for help on using the changeset viewer.