Ignore:
Timestamp:
2016-02-24T02:08:53+01:00 (8 years ago)
Author:
Don-vip
Message:

PluginHandler: deprecate kendzi3d-jogl plugin, remove unused code, fix findbugs warning, add unit tests

File:
1 edited

Legend:

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

    r9616 r9870  
    130130            new DeprecatedPlugin("missingRoads", tr("replaced by new {0} plugin", "ImproveOsm")),
    131131            new DeprecatedPlugin("trafficFlowDirection", tr("replaced by new {0} plugin", "ImproveOsm")),
     132            new DeprecatedPlugin("kendzi3d-jogl", tr("replaced by new {0} plugin", "jogl")),
    132133        });
    133134    }
     
    145146        /** Short explanation about deprecation, can be {@code null} */
    146147        public final String reason;
    147         /** Code to run to perform migration, can be {@code null} */
    148         private final Runnable migration;
    149 
    150         /**
    151          * Constructs a new {@code DeprecatedPlugin}.
    152          * @param name The plugin name
    153          */
    154         public DeprecatedPlugin(String name) {
    155             this(name, null, null);
    156         }
    157148
    158149        /**
     
    162153         */
    163154        public DeprecatedPlugin(String name, String reason) {
    164             this(name, reason, null);
    165         }
    166 
    167         /**
    168          * Constructs a new {@code DeprecatedPlugin}.
    169          * @param name The plugin name
    170          * @param reason The reason about deprecation
    171          * @param migration The code to run to perform migration
    172          */
    173         public DeprecatedPlugin(String name, String reason, Runnable migration) {
    174155            this.name = name;
    175156            this.reason = reason;
    176             this.migration = migration;
    177         }
    178 
    179         /**
    180          * Performs migration.
    181          */
    182         public void migrate() {
    183             if (migration != null) {
    184                 migration.run();
    185             }
     157        }
     158
     159        @Override
     160        public int hashCode() {
     161            final int prime = 31;
     162            int result = prime + ((name == null) ? 0 : name.hashCode());
     163            return prime * result + ((reason == null) ? 0 : reason.hashCode());
     164        }
     165
     166        @Override
     167        public boolean equals(Object obj) {
     168            if (this == obj)
     169                return true;
     170            if (obj == null)
     171                return false;
     172            if (getClass() != obj.getClass())
     173                return false;
     174            DeprecatedPlugin other = (DeprecatedPlugin) obj;
     175            if (name == null) {
     176                if (other.name != null)
     177                    return false;
     178            } else if (!name.equals(other.name))
     179                return false;
     180            if (reason == null) {
     181                if (other.reason != null)
     182                    return false;
     183            } else if (!reason.equals(other.reason))
     184                return false;
     185            return true;
    186186        }
    187187
    188188        @Override
    189189        public int compareTo(DeprecatedPlugin o) {
    190             return name.compareTo(o.name);
     190            int d = name.compareTo(o.name);
     191            if (d == 0)
     192                d = reason.compareTo(o.reason);
     193            return d;
    191194        }
    192195    }
     
    217220     * List of unmaintained plugins. Not really up-to-date as the vast majority of plugins are not maintained after a few months, sadly...
    218221     */
    219     private static final String[] UNMAINTAINED_PLUGINS = new String[] {
     222    static final String[] UNMAINTAINED_PLUGINS = new String[] {
    220223        "gpsbabelgui",
    221224        "Intersect_way",
     
    282285                Main.pref.removeFromCollection("plugins", depr.name);
    283286                removedPlugins.add(depr);
    284                 depr.migrate();
    285287            }
    286288        }
     
    661663        if (pluginClassLoader == null) {
    662664            pluginClassLoader = AccessController.doPrivileged(new PrivilegedAction<DynamicURLClassLoader>() {
     665                @Override
    663666                public DynamicURLClassLoader run() {
    664667                    return new DynamicURLClassLoader(new URL[0], Main.class.getClassLoader());
     
    853856                plugins.size()))
    854857          .append("</html>");
    855         HelpAwareOptionPane.showOptionDialog(
    856                 parent,
    857                 sb.toString(),
    858                 tr("Warning"),
    859                 JOptionPane.WARNING_MESSAGE,
    860                 HelpUtil.ht("/Plugin/Loading#MissingPluginInfos")
    861         );
     858        if (!GraphicsEnvironment.isHeadless()) {
     859            HelpAwareOptionPane.showOptionDialog(
     860                    parent,
     861                    sb.toString(),
     862                    tr("Warning"),
     863                    JOptionPane.WARNING_MESSAGE,
     864                    HelpUtil.ht("/Plugin/Loading#MissingPluginInfos")
     865            );
     866        }
    862867    }
    863868
     
    878883            monitor.beginTask(tr("Determine plugins to load..."));
    879884            Set<String> plugins = new HashSet<>();
    880             plugins.addAll(Main.pref.getCollection("plugins",  new LinkedList<String>()));
     885            plugins.addAll(Main.pref.getCollection("plugins", new LinkedList<String>()));
    881886            if (System.getProperty("josm.plugins") != null) {
    882887                plugins.addAll(Arrays.asList(System.getProperty("josm.plugins").split(",")));
Note: See TracChangeset for help on using the changeset viewer.