public final class PluginHandler extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
PluginHandler.DeprecatedPlugin
Description of a deprecated plugin
|
private static class |
PluginHandler.UpdatePluginsMessagePanel |
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_TIME_BASED_UPDATE_INTERVAL
Default time-based update interval, in days (pluginmanager.time-based-update.interval)
|
static Collection<PluginHandler.DeprecatedPlugin> |
DEPRECATED_PLUGINS
Deprecated plugins that are removed on start
|
static Collection<PluginProxy> |
pluginList
All installed and loaded plugins (resp. their main classes)
|
private static List<ClassLoader> |
sources
Add here all ClassLoader whose resource should be searched.
|
static String[] |
UNMAINTAINED_PLUGINS
List of unmaintained plugins.
|
| Modifier | Constructor and Description |
|---|---|
private |
PluginHandler() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addDownloadSelection(List<DownloadSelection> downloadSelections) |
private static void |
alertFailedPluginUpdate(Component parent,
Collection<PluginInformation> plugins) |
private static void |
alertJOSMUpdateRequired(Component parent,
String plugin,
int requiredVersion) |
private static void |
alertMissingPluginInformation(Component parent,
Collection<String> plugins) |
private static void |
alertMissingRequiredPlugin(Component parent,
String plugin,
Set<String> missingRequiredPlugin)
Alerts the user if a plugin required by another plugin is missing
|
static List<PluginInformation> |
buildListOfPluginsToLoad(Component parent,
ProgressMonitor monitor)
Builds the set of plugins to load.
|
static boolean |
checkAndConfirmPluginUpdate(Component parent)
Checks whether the locally available plugins should be updated and
asks the user if running an update is OK.
|
static boolean |
checkLoadPreconditions(Component parent,
Collection<PluginInformation> plugins,
PluginInformation plugin)
Checks whether all preconditions for loading the plugin
plugin are met. |
static boolean |
checkRequiredPluginsPreconditions(Component parent,
Collection<PluginInformation> plugins,
PluginInformation plugin,
boolean local)
Checks if required plugins preconditions for loading the plugin
plugin are met. |
private static boolean |
confirmDeactivatingPluginAfterException(PluginProxy plugin) |
static boolean |
confirmDisablePlugin(Component parent,
String reason,
String name)
Ask the user for confirmation that a plugin shall be disabled.
|
static ClassLoader |
createClassLoader(Collection<PluginInformation> plugins)
Creates a class loader for loading plugin code.
|
static void |
disablePluginAfterException(Throwable e)
Checks whether the exception
e was thrown by a plugin. |
private static void |
filterDeprecatedPlugins(Component parent,
Collection<String> plugins)
Removes deprecated plugins from a collection of plugins.
|
private static void |
filterUnmaintainedPlugins(Component parent,
Collection<String> plugins)
Removes unmaintained plugins from a collection of plugins.
|
private static Set<PluginInformation> |
findRequiredPluginsToDownload(Collection<PluginInformation> pluginsToUpdate,
List<PluginInformation> allPlugins,
Set<PluginInformation> pluginsToDownload) |
static File |
findUpdatedJar(String name)
Replies the updated jar file for the given plugin name.
|
static String |
getBugReportText()
Returns the list of loaded plugins as a
String to be displayed in status report. |
static JPanel |
getInfoPanel()
Returns the list of loaded plugins as a
JPanel to be displayed in About dialog. |
static Object |
getPlugin(String name)
Returns the plugin of the specified name.
|
private static PluginProxy |
getPluginCausingException(Throwable ex)
Replies the plugin which most likely threw the exception
ex. |
static void |
getPreferenceSetting(Collection<PreferenceSettingFactory> settings) |
static Collection<ClassLoader> |
getResourceClassLoaders() |
static void |
installDownloadedPlugins(boolean dowarn)
Installs downloaded plugins.
|
static boolean |
isValidJar(File jar)
Determines if the specified file is a valid and accessible JAR file.
|
static void |
loadEarlyPlugins(Component parent,
Collection<PluginInformation> plugins,
ProgressMonitor monitor)
Loads plugins from
plugins which have the flag PluginInformation.early
set to true. |
static void |
loadLatePlugins(Component parent,
Collection<PluginInformation> plugins,
ProgressMonitor monitor)
Loads plugins from
plugins which have the flag PluginInformation.early
set to false. |
private static Map<String,PluginInformation> |
loadLocallyAvailablePluginInformation(ProgressMonitor monitor)
Loads locally available plugin information from local plugin jars and from cached
plugin lists.
|
static void |
loadPlugin(Component parent,
PluginInformation plugin,
ClassLoader pluginClassLoader)
Loads and instantiates the plugin described by
plugin using
the class loader pluginClassLoader. |
static void |
loadPlugins(Component parent,
Collection<PluginInformation> plugins,
ProgressMonitor monitor)
Loads the plugin in
plugins from locally available jar files into
memory. |
static void |
refreshLocalUpdatedPluginInfo(Collection<PluginInformation> updatedPlugins)
Refreshes the given PluginInformation objects with new contents read from their corresponding jar file.
|
static List<PluginInformation> |
updatePlugins(Component parent,
List<PluginInformation> plugins,
ProgressMonitor monitor)
Updates the plugins in
plugins. |
public static final Collection<PluginHandler.DeprecatedPlugin> DEPRECATED_PLUGINS
public static final String[] UNMAINTAINED_PLUGINS
public static final int DEFAULT_TIME_BASED_UPDATE_INTERVAL
public static final Collection<PluginProxy> pluginList
private static final List<ClassLoader> sources
private PluginHandler()
public static Collection<ClassLoader> getResourceClassLoaders()
private static void filterDeprecatedPlugins(Component parent, Collection<String> plugins)
plugins.
Also notifies the user about removed deprecated pluginsparent - The parent Component used to display warning popupplugins - the collection of pluginsprivate static void filterUnmaintainedPlugins(Component parent, Collection<String> plugins)
plugins. Also removes the plugin from the list
of plugins in the preferences, if necessary.
Asks the user for every unmaintained plugin whether it should be removed.plugins - the collection of pluginspublic static boolean checkAndConfirmPluginUpdate(Component parent)
parent - the parent component relative to which the confirmation dialog
is to be displayedprivate static void alertMissingRequiredPlugin(Component parent, String plugin, Set<String> missingRequiredPlugin)
parent - The parent Component used to display error popupplugin - the pluginmissingRequiredPlugin - the missing required pluginprivate static void alertJOSMUpdateRequired(Component parent, String plugin, int requiredVersion)
public static boolean checkLoadPreconditions(Component parent, Collection<PluginInformation> plugins, PluginInformation plugin)
plugin are met. The
current JOSM version must be compatible with the plugin and no other plugins this plugin
depends on should be missing.parent - The parent Component used to display error popupplugins - the collection of all loaded pluginsplugin - the plugin for which preconditions are checkedpublic static boolean checkRequiredPluginsPreconditions(Component parent, Collection<PluginInformation> plugins, PluginInformation plugin, boolean local)
plugin are met.
No other plugins this plugin depends on should be missing.parent - The parent Component used to display error popupplugins - the collection of all loaded pluginsplugin - the plugin for which preconditions are checkedlocal - Determines if the local or up-to-date plugin dependencies are to be checked.public static ClassLoader createClassLoader(Collection<PluginInformation> plugins)
plugins - the collection of plugins which are going to be loaded with this
class loaderpublic static void loadPlugin(Component parent, PluginInformation plugin, ClassLoader pluginClassLoader)
plugin using
the class loader pluginClassLoader.parent - The parent component to be used for the displayed dialogplugin - the pluginpluginClassLoader - the plugin class loaderpublic static void loadPlugins(Component parent, Collection<PluginInformation> plugins, ProgressMonitor monitor)
plugins from locally available jar files into
memory.parent - The parent component to be used for the displayed dialogplugins - the list of pluginsmonitor - the progress monitor. Defaults to NullProgressMonitor.INSTANCE if null.public static void loadEarlyPlugins(Component parent, Collection<PluginInformation> plugins, ProgressMonitor monitor)
plugins which have the flag PluginInformation.early
set to true.plugins - the collection of pluginsmonitor - the progress monitor. Defaults to NullProgressMonitor.INSTANCE if null.public static void loadLatePlugins(Component parent, Collection<PluginInformation> plugins, ProgressMonitor monitor)
plugins which have the flag PluginInformation.early
set to false.parent - The parent component to be used for the displayed dialogplugins - the collection of pluginsmonitor - the progress monitor. Defaults to NullProgressMonitor.INSTANCE if null.private static Map<String,PluginInformation> loadLocallyAvailablePluginInformation(ProgressMonitor monitor)
monitor - the progress monitor. Defaults to NullProgressMonitor.INSTANCE if null.private static void alertMissingPluginInformation(Component parent, Collection<String> plugins)
public static List<PluginInformation> buildListOfPluginsToLoad(Component parent, ProgressMonitor monitor)
parent - The parent component to be used for the displayed dialogmonitor - the progress monitor. Defaults to NullProgressMonitor.INSTANCE if null.private static void alertFailedPluginUpdate(Component parent, Collection<PluginInformation> plugins)
private static Set<PluginInformation> findRequiredPluginsToDownload(Collection<PluginInformation> pluginsToUpdate, List<PluginInformation> allPlugins, Set<PluginInformation> pluginsToDownload)
public static List<PluginInformation> updatePlugins(Component parent, List<PluginInformation> plugins, ProgressMonitor monitor) throws IllegalArgumentException
plugins.parent - the parent component for message boxesplugins - the collection of plugins to update. Must not be null.monitor - the progress monitor. Defaults to NullProgressMonitor.INSTANCE if null.IllegalArgumentException - thrown if plugins is nullpublic static boolean confirmDisablePlugin(Component parent, String reason, String name)
parent - The parent component to be used for the displayed dialogreason - the reason for disabling the pluginname - the plugin namepublic static Object getPlugin(String name)
name - The plugin namenull otherwise.public static void addDownloadSelection(List<DownloadSelection> downloadSelections)
public static void getPreferenceSetting(Collection<PreferenceSettingFactory> settings)
public static void installDownloadedPlugins(boolean dowarn)
dowarn is true, this methods emits warning messages on the console if a downloaded
but not yet installed plugin .jar can't be be installed. If dowarn is false, the
installation of the respective plugin is sillently skipped.dowarn - if true, warning messages are displayed; false otherwisepublic static boolean isValidJar(File jar)
jar - The fil to checkpublic static File findUpdatedJar(String name)
name - The plugin name to find.public static void refreshLocalUpdatedPluginInfo(Collection<PluginInformation> updatedPlugins)
updatedPlugins - The PluginInformation objects to update.private static boolean confirmDeactivatingPluginAfterException(PluginProxy plugin)
private static PluginProxy getPluginCausingException(Throwable ex)
ex.ex - the exceptionpublic static void disablePluginAfterException(Throwable e)
e was thrown by a plugin. If so,
conditionally deactivates the plugin, but asks the user first.e - the exceptionpublic static String getBugReportText()
String to be displayed in status report. Useful for bug reports.public static JPanel getInfoPanel()
JPanel to be displayed in About dialog.