| 1 | //  Copyright 2004-2007 Jean-Francois Poilpret | 
| 2 | // | 
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
| 4 | // you may not use this file except in compliance with the License. | 
| 5 | // You may obtain a copy of the License at | 
| 6 | // | 
| 7 | //     http://www.apache.org/licenses/LICENSE-2.0 | 
| 8 | // | 
| 9 | // Unless required by applicable law or agreed to in writing, software | 
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, | 
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
| 12 | // See the License for the specific language governing permissions and | 
| 13 | // limitations under the License. | 
| 14 |   | 
| 15 | package net.sourceforge.hiveboard.view; | 
| 16 |   | 
| 17 | import java.awt.BorderLayout; | 
| 18 |   | 
| 19 | import javax.swing.JPanel; | 
| 20 | import javax.swing.JScrollPane; | 
| 21 | import javax.swing.ListSelectionModel; | 
| 22 |   | 
| 23 | import net.sourceforge.hiveboard.Event; | 
| 24 | import net.sourceforge.hiveboard.docking.Views; | 
| 25 | import net.sourceforge.hiveboard.event.EventsPriorities; | 
| 26 | import net.sourceforge.hiveevents.Channel; | 
| 27 | import net.sourceforge.hiveevents.PersistentConsumer; | 
| 28 | import net.sourceforge.hivegui.table.BeanTable; | 
| 29 | import net.sourceforge.hivegui.table.DataListModel; | 
| 30 |   | 
| 31 | public class NotificationListPanel extends JPanel | 
| 32 | { | 
| 33 |         public NotificationListPanel(        Channel<Object>                clearNotificationsChannel, | 
| 34 |                                                                         BeanTable<Event>        tblNotifications) | 
| 35 |         { | 
| 36 |                 setLayout(new BorderLayout()); | 
| 37 |                 _tblNotifications = tblNotifications; | 
| 38 |                 _tblNotifications.setName(Views.NOTIFICATIONS_LIST.id() + "-table"); | 
| 39 |                 _model = _tblNotifications.getDataListModel(); | 
| 40 |                 _tblNotifications.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); | 
| 41 |                 JScrollPane scroller = new JScrollPane(_tblNotifications); | 
| 42 |                 scroller.setName(Views.NOTIFICATIONS_LIST.id() + "-scroller"); | 
| 43 |             add(scroller, BorderLayout.CENTER); | 
| 44 |   | 
| 45 |             int priority = EventsPriorities.NOTIFICATIONS_LIST_CLEARED; | 
| 46 |                 clearNotificationsChannel.registerPushConsumer( | 
| 47 |                                                         priority, new PersistentConsumer<Object>() | 
| 48 |                 { | 
| 49 |                         public void        push(Object event) | 
| 50 |                         { | 
| 51 |                                 _model.clear(); | 
| 52 |                         } | 
| 53 |                 }); | 
| 54 |         } | 
| 55 |   | 
| 56 |         final private BeanTable<Event>                _tblNotifications; | 
| 57 |         final private DataListModel<Event>        _model; | 
| 58 | } |