You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PluginPreferencesCategory.java 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright (c) 2006-2017 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  5. * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
  6. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
  7. * permit persons to whom the Software is furnished to do so, subject to the following conditions:
  8. *
  9. * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
  10. * Software.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  13. * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
  14. * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  15. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16. */
  17. package com.dmdirc.config.prefs;
  18. import com.dmdirc.plugins.PluginInfo;
  19. /**
  20. * A specialised {@link PreferencesCategory} which warns the user if an associated plugin is not
  21. * loaded
  22. *
  23. * @since 0.6.3
  24. */
  25. public class PluginPreferencesCategory extends PreferencesCategory {
  26. /**
  27. * Creates a new preferences category that contains an object.
  28. *
  29. * @param plugin The plugin which owns this category
  30. * @param title The title of this preferences category
  31. * @param description The description of this category
  32. * @param icon The icon to use for this category
  33. * @param object The replacement object for this category
  34. */
  35. public PluginPreferencesCategory(final PluginInfo plugin, final String title,
  36. final String description, final String icon, final PreferencesInterface object) {
  37. super(title, description, icon, object);
  38. setPlugin(plugin);
  39. }
  40. /**
  41. * Creates a new preferences category that contains an object.
  42. *
  43. * @param plugin The plugin which owns this category
  44. * @param title The title of this preferences category
  45. * @param description The description of this category
  46. * @param object The replacement object for this category
  47. */
  48. public PluginPreferencesCategory(final PluginInfo plugin, final String title,
  49. final String description, final PreferencesInterface object) {
  50. super(title, description, object);
  51. setPlugin(plugin);
  52. }
  53. /**
  54. * Creates a new preferences category that contains settings.
  55. *
  56. * @param plugin The plugin which owns this category
  57. * @param title The title of this preferences category
  58. * @param description The description of this category
  59. * @param icon The icon to use for this category
  60. */
  61. public PluginPreferencesCategory(final PluginInfo plugin, final String title,
  62. final String description, final String icon) {
  63. super(title, description, icon);
  64. setPlugin(plugin);
  65. }
  66. /**
  67. * Creates a new preferences category that contains settings.
  68. *
  69. * @param plugin The plugin which owns this category
  70. * @param title The title of this preferences category
  71. * @param description The description of this category
  72. */
  73. public PluginPreferencesCategory(final PluginInfo plugin, final String title,
  74. final String description) {
  75. super(title, description);
  76. setPlugin(plugin);
  77. }
  78. /**
  79. * Declares that this category has been created by the specified plugin. If the plugin is not
  80. * loaded, then the category's warning field is set to a message reflecting the fact.
  81. *
  82. * @param plugin The plugin that owns this category
  83. */
  84. private void setPlugin(final PluginInfo plugin) {
  85. if (!plugin.isLoaded()) {
  86. setWarning("These are settings for the '" + plugin.getMetaData()
  87. .getFriendlyName() + "' plugin, " + "which is not currently"
  88. + " loaded. You must enable the plugin in the main 'Plugins'"
  89. + " category for these settings to have any effect.");
  90. }
  91. }
  92. }