@Override public void addNotifications( final NotificationChannel channel, Collection<NotificationItem> items) { channel.addNotifications(items); if (!channel.isVisible()) { boolean hasVisibleChannel = false; for (NotificationChannel ch : NotificationChannel.values()) { hasVisibleChannel |= ch.isVisible(); } SwingUtilities.invokeLater( new Runnable() { @Override public void run() { channel.saveNormalColor(); channel.getButton().setBackground(channel.getColor()); showNotification(channel); } }); if (!hasVisibleChannel) { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { showNotification(channel); } }); } } }
@Override public void showNotification(final NotificationChannel channel) { if (channel.getItems().isEmpty() && channel.getDefaultNotification() == null) { return; } if (!myAnimationView.isReady()) { if (myFirstChannel == null) { myFirstChannel = channel; } return; } if (myAnimationView.isVisible()) { return; } NotificationComponent nc = new NotificationComponent(channel, myAnimationView); channel.setVisible(true); nc.processItems(); myAnimationView.setComponent( nc.getComponent(), channel.getButton(), new Runnable() { @Override public void run() { channel.getButton().setBackground(channel.getNormalColor()); channel.setVisible(false); } }); }
/** * Function sends a "LISTEN channel" message to the database server for all specified channels in * the set. There is currently no way to subscribe to multiple channels in a single query. * * @param channelNames The channel names to listen to. */ private synchronized void sendListens(final Set<NotificationChannel> channelNames) { for (final NotificationChannel channel : channelNames) { try { m_connection.executeUpdate("LISTEN " + channel.name(), true); } catch (final SQLException exception) { NaviLogger.severe("Error: Could not send LISTEN command to database server: %s", exception); } } for (final PostgreSQLNotificationListener listener : m_listeners) { try { listener.listenedChannelsAdded(m_provider, channelNames); } catch (final Exception exception) { CUtilityFunctions.logException(exception); } } }