PageRenderTime 4ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 1ms

/src/mpv5/ui/dialogs/Notificator.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 78 lines | 49 code | 8 blank | 21 comment | 9 complexity | ae7b761bad5078a1234457c278c10f12 MD5 | raw file
Possible License(s): LGPL-3.0, Apache-2.0, GPL-3.0, GPL-2.0, AGPL-3.0, JSON, BSD-3-Clause
  1. package mpv5.ui.dialogs;
  2. import javax.swing.SwingUtilities;
  3. import mpv5.db.common.Context;
  4. import mpv5.db.common.DatabaseObject;
  5. import mpv5.db.common.QueryHandler;
  6. import mpv5.db.objects.HistoryItem;
  7. import mpv5.globals.Messages;
  8. import mpv5.ui.frames.MPView;
  9. /**
  10. *
  11. * Use this class to pass messages to the user
  12. * @author anti
  13. */
  14. public class Notificator {
  15. /**
  16. * Raise a notification to the user
  17. * @param message
  18. */
  19. public static void raiseNotification(final Object message) {
  20. Runnable runnable = new Runnable() {
  21. @Override
  22. public void run() {
  23. Popup.notice(message);
  24. }
  25. };
  26. SwingUtilities.invokeLater(runnable);
  27. }
  28. /**
  29. * Raise a notification to the user
  30. * @param message
  31. * @param popup
  32. */
  33. public static void raiseNotification(Object message, boolean popup) {
  34. if (popup) {
  35. raiseNotification(message);
  36. } else {
  37. if (message != null) {
  38. mpv5.YabsViewProxy.instance().addMessage(message.toString());
  39. }
  40. }
  41. }
  42. /**
  43. * Raise a notification to the user
  44. * @param message
  45. * @param popup
  46. * @param log write to log
  47. * @param source
  48. */
  49. public static void raiseNotification(final Object message, boolean popup, boolean log, DatabaseObject source) {
  50. if (popup) {
  51. raiseNotification(message);
  52. } else {
  53. if (message != null) {
  54. mpv5.YabsViewProxy.instance().addMessage(message.toString());
  55. }
  56. }
  57. if (log) {
  58. final String fdbid = Messages.NOTIFICATION.getValue();
  59. final int fids = source.__getIDS();
  60. final int fgids = source.__getGroupsids();
  61. Runnable runnable = new Runnable() {
  62. @Override
  63. public void run() {
  64. QueryHandler.instanceOf().clone(Context.getHistory()).insertHistoryItem(message.toString(), mpv5.db.objects.User.getCurrentUser().__getCname(), fdbid, fids, fgids);
  65. }
  66. };
  67. new Thread(runnable).start();
  68. }
  69. }
  70. }