Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

PopupCommand.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.addons.systray;
  18. import com.dmdirc.commandparser.BaseCommandInfo;
  19. import com.dmdirc.commandparser.CommandArguments;
  20. import com.dmdirc.commandparser.CommandType;
  21. import com.dmdirc.commandparser.commands.BaseCommand;
  22. import com.dmdirc.commandparser.commands.context.CommandContext;
  23. import com.dmdirc.interfaces.CommandController;
  24. import com.dmdirc.interfaces.WindowModel;
  25. import javax.annotation.Nonnull;
  26. import javax.inject.Inject;
  27. /**
  28. * The /popup command allows the user to show a popup message from the system tray icon.
  29. */
  30. public class PopupCommand extends BaseCommand {
  31. /** A command info object for this command. */
  32. public static final BaseCommandInfo INFO = new BaseCommandInfo("popup",
  33. "popup <message> - shows the message as a system tray popup",
  34. CommandType.TYPE_GLOBAL);
  35. /** Systray manager, used to show notifications. */
  36. private final SystrayManager manager;
  37. /**
  38. * Creates a new instance of PopupCommand.
  39. *
  40. * @param manager Systray manager, used to show notifications
  41. * @param commandController The controller to use for command information.
  42. */
  43. @Inject
  44. public PopupCommand(final SystrayManager manager, final CommandController commandController) {
  45. super(commandController);
  46. this.manager = manager;
  47. }
  48. /**
  49. * Used to show a notification using this plugin.
  50. *
  51. * @param title Title of dialog if applicable
  52. * @param message Message to show
  53. *
  54. * @return True if the notification was shown.
  55. */
  56. public boolean showPopup(final String title, final String message) {
  57. manager.notify(title, message);
  58. return true;
  59. }
  60. @Override
  61. public void execute(@Nonnull final WindowModel origin,
  62. final CommandArguments args, final CommandContext context) {
  63. showPopup("DMDirc", args.getArgumentsAsString());
  64. }
  65. }