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.

LagDisplayPlugin.java 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (c) 2006-2014 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package com.dmdirc.addons.lagdisplay;
  23. import com.dmdirc.config.prefs.PluginPreferencesCategory;
  24. import com.dmdirc.config.prefs.PreferencesCategory;
  25. import com.dmdirc.config.prefs.PreferencesDialogModel;
  26. import com.dmdirc.config.prefs.PreferencesSetting;
  27. import com.dmdirc.config.prefs.PreferencesType;
  28. import com.dmdirc.plugins.PluginInfo;
  29. import com.dmdirc.plugins.implementations.BasePlugin;
  30. import dagger.ObjectGraph;
  31. /**
  32. * Displays the current server's lag in the status bar.
  33. */
  34. public final class LagDisplayPlugin extends BasePlugin {
  35. /** This plugin's plugin info. */
  36. private final PluginInfo pluginInfo;
  37. /** The manager currently in use. */
  38. private LagDisplayManager manager;
  39. /**
  40. * Creates a new LagDisplayPlugin.
  41. *
  42. * @param pluginInfo This plugin's plugin info
  43. */
  44. public LagDisplayPlugin(final PluginInfo pluginInfo) {
  45. this.pluginInfo = pluginInfo;
  46. }
  47. @Override
  48. public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
  49. super.load(pluginInfo, graph);
  50. setObjectGraph(graph.plus(new LagDisplayModule(pluginInfo.getDomain())));
  51. manager = getObjectGraph().get(LagDisplayManager.class);
  52. }
  53. /** {@inheritDoc} */
  54. @Override
  55. public void onLoad() {
  56. manager.load();
  57. }
  58. /** {@inheritDoc} */
  59. @Override
  60. public void onUnload() {
  61. manager.unload();
  62. }
  63. /** {@inheritDoc} */
  64. @Override
  65. public void showConfig(final PreferencesDialogModel manager) {
  66. final PreferencesCategory cat = new PluginPreferencesCategory(
  67. pluginInfo, "Lag display plugin", "");
  68. cat.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
  69. pluginInfo.getDomain(), "usealternate",
  70. "Alternate method", "Use an alternate method of determining "
  71. + "lag which bypasses bouncers or proxies that may reply?",
  72. manager.getConfigManager(), manager.getIdentity()));
  73. cat.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
  74. pluginInfo.getDomain(), "graph", "Show graph", "Show a graph of ping times "
  75. + "for the current server in the information popup?",
  76. manager.getConfigManager(), manager.getIdentity()));
  77. cat.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
  78. pluginInfo.getDomain(), "labels", "Show labels", "Show labels on selected "
  79. + "points on the ping graph?",
  80. manager.getConfigManager(), manager.getIdentity()));
  81. cat.addSetting(new PreferencesSetting(PreferencesType.INTEGER,
  82. pluginInfo.getDomain(), "history", "Graph points", "Number of data points "
  83. + "to plot on the graph, if enabled.",
  84. manager.getConfigManager(), manager.getIdentity()));
  85. manager.getCategory("Plugins").addSubCategory(cat);
  86. }
  87. }