summaryrefslogtreecommitdiff
path: root/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java
blob: c3f42f46aa1bda2f1b16d9b119729f41f671f307 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
/*
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 */
package org.apache.qpid.management.ui.views;

import java.util.ArrayList;
import java.util.List;

import org.apache.qpid.management.ui.ApplicationRegistry;
import org.apache.qpid.management.ui.Constants;
import org.apache.qpid.management.ui.ManagedBean;
import org.apache.qpid.management.ui.ServerRegistry;
import org.apache.qpid.management.ui.jmx.MBeanUtility;
import org.apache.qpid.management.ui.model.NotificationInfoModel;
import org.apache.qpid.management.ui.model.NotificationObject;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.Form;
import org.eclipse.ui.forms.widgets.FormToolkit;

/**
 * 
 * @author Bhupendra Bhardwaj
 *
 */
public class NotificationsTabControl extends TabControl
{
    private FormToolkit  _toolkit;
    private Form _form;
    private Table table = null;
    private TableViewer _tableViewer  = null;
    
    private IStructuredContentProvider contentProvider = new ContentProviderImpl();
    private SelectionListener selectionListener = new SelectionListenerImpl();
    private SelectionListener comboListener = new ComboSelectionListener();
    
    private Thread worker = null;
    
    private List<NotificationObject> _notifications = null;
    private static final String COLUMN_SEQ  = "Sequence No";
    private static final String COLUMN_TIME = "TimeStamp";
    private static final String COLUMN_TYPE  = "Type";
    private static final String COLUMN_MSG  = "Notification Message";
    private static final String[] _tableTitles = new String [] {
            COLUMN_SEQ,
            COLUMN_TIME,
            COLUMN_TYPE,
            COLUMN_MSG
         };
    
    private Combo notificationNameCombo = null;
    private Combo typesCombo = null;
    private Label descriptionLabel = null;
    private Button _subscribeButton   = null;
    private Button _unsubscribeButton = null;
    private Button _clearButton       = null;
    private Button _refreshButton       = null;
    
    
    public NotificationsTabControl(TabFolder tabFolder)
    {
        super(tabFolder);
        _toolkit = new FormToolkit(_tabFolder.getDisplay());
        _form = _toolkit.createForm(_tabFolder);
        GridLayout gridLayout = new GridLayout();      
        gridLayout.marginWidth = 0;
        gridLayout.marginHeight = 0;       
        _form.getBody().setLayout(gridLayout);
        
        createWidgets();
        worker = new Thread(new Worker()); 
        worker.start();
    }
    
    private void createWidgets()
    {       
        createNotificationInfoComposite();
        //addFilterComposite();
        addButtons();  
        createTableViewer();
    }
    
    public Control getControl()
    {
        return _form;
    }
    
    private void createNotificationInfoComposite()
    {
        Composite composite = _toolkit.createComposite(_form.getBody(), SWT.NONE);
        composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
        composite.setLayout(new FormLayout());
        
        Label label = _toolkit.createLabel(composite, "Select the notification to subscribe or unsubscribe");
        label.setFont(ApplicationRegistry.getFont(Constants.FONT_BOLD));
        FormData formData = new FormData();
        formData.top = new FormAttachment(0, 10);
        formData.left = new FormAttachment(0, 10);
        label.setLayoutData(formData);
        
        notificationNameCombo = new Combo(composite, SWT.READ_ONLY | SWT.DROP_DOWN);
        formData = new FormData();
        formData.top = new FormAttachment(label, 10);
        formData.left = new FormAttachment(0, 10);
        formData.right = new FormAttachment(40);
        notificationNameCombo.setLayoutData(formData);
        notificationNameCombo.addSelectionListener(comboListener);
        
        typesCombo = new Combo(composite, SWT.READ_ONLY | SWT.DROP_DOWN);
        formData = new FormData();
        formData.top = new FormAttachment(label, 10);
        formData.left = new FormAttachment(notificationNameCombo, 5);
        formData.right = new FormAttachment(65);
        typesCombo.setLayoutData(formData);
        typesCombo.addSelectionListener(comboListener);
        
        _subscribeButton = new Button(composite, SWT.PUSH | SWT.CENTER);
        _subscribeButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON));
        _subscribeButton.setText(Constants.SUBSCRIBE_BUTTON);
        formData = new FormData();
        formData.top = new FormAttachment(label, 10);
        formData.left = new FormAttachment(65, 10);
        formData.width = 80;
        _subscribeButton.setLayoutData(formData);
        _subscribeButton.addSelectionListener(selectionListener);
        
        _unsubscribeButton = new Button(composite, SWT.PUSH | SWT.CENTER);
        _unsubscribeButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON));
        _unsubscribeButton.setText(Constants.UNSUBSCRIBE_BUTTON);
        formData = new FormData();
        formData.top = new FormAttachment(label, 10);
        formData.left = new FormAttachment(_subscribeButton, 10);
        formData.width = 80;
        _unsubscribeButton.setLayoutData(formData);
        _unsubscribeButton.addSelectionListener(selectionListener);
        
        Label fixedLabel = _toolkit.createLabel(composite, "");
        formData = new FormData();
        formData.top = new FormAttachment(notificationNameCombo, 5);
        formData.left = new FormAttachment(0, 10);
        fixedLabel.setLayoutData(formData);
        fixedLabel.setText(Constants.DESCRIPTION);
        fixedLabel.setFont(ApplicationRegistry.getFont(Constants.FONT_BOLD));
        
        descriptionLabel = _toolkit.createLabel(composite, "");
        formData = new FormData();
        formData.top = new FormAttachment(notificationNameCombo, 5);
        formData.left = new FormAttachment(fixedLabel, 10);
        formData.right = new FormAttachment(80);
        descriptionLabel.setLayoutData(formData);
        descriptionLabel.setText("      ");
        descriptionLabel.setFont(ApplicationRegistry.getFont(Constants.FONT_ITALIC));
    }
    
    private void addButtons()
    {    
        Composite composite = _toolkit.createComposite(_form.getBody(), SWT.NONE);
        composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
        composite.setLayout(new GridLayout(2, true));
        
        // Add Clear Button
        _clearButton = _toolkit.createButton(composite, Constants.BUTTON_CLEAR, SWT.PUSH | SWT.CENTER);
        _clearButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON));
        GridData gridData = new GridData(SWT.LEAD, SWT.TOP, true, false);
        gridData.widthHint = 80;
        _clearButton.setLayoutData(gridData);
        _clearButton.addSelectionListener(new SelectionAdapter()
            {
                public void widgetSelected(SelectionEvent e)
                {    
                    if (_mbean == null)
                        return;
                    
                    ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(_mbean);
                    serverRegistry.clearNotifications(_mbean);
                    refresh();
                }
            });
        
        // Add Refresh Button
        _refreshButton = _toolkit.createButton(composite, Constants.BUTTON_REFRESH, SWT.PUSH | SWT.CENTER);
        _refreshButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON));
        gridData = new GridData(SWT.TRAIL, SWT.TOP, true, false);
        gridData.widthHint = 80;
        _refreshButton.setLayoutData(gridData);
        _refreshButton.addSelectionListener(new SelectionAdapter()
            {
                public void widgetSelected(SelectionEvent e)
                {    
                    if (_mbean == null)
                        return;
                    
                    refresh();
                }
            });
    }
    
    private void createTable()
    {
        table = _toolkit.createTable(_form.getBody(),  SWT.FULL_SELECTION);
        table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        
        TableColumn column = new TableColumn(table, SWT.NONE);
        column.setText(_tableTitles[0]);
        column.pack();        //column.setWidth(200);

        column = new TableColumn(table, SWT.NONE);
        column.setText(_tableTitles[1]);
        column.setWidth(150);
        
        column = new TableColumn(table, SWT.NONE);
        column.setText(_tableTitles[2]);
        column.setWidth(100);
        
        column = new TableColumn(table, SWT.NONE);
        column.setText(_tableTitles[3]);
        column.setWidth(500);
        
        table.setHeaderVisible(true);
        table.setLinesVisible(true);
    }
    
    protected void createTableViewer()
    {
        createTable();
        _tableViewer = new TableViewer(table);
        //_tableViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        _tableViewer.setUseHashlookup(true);
        _tableViewer.setContentProvider(contentProvider);
        _tableViewer.setLabelProvider(new LabelProviderImpl());
        _tableViewer.setColumnProperties(_tableTitles);
        /*
        CellEditor[] cellEditors = new CellEditor[_tableTitles.length];
        TextCellEditor textEditor = new TextCellEditor(table);
        cellEditors[0] = textEditor;
        textEditor = new TextCellEditor(table);
        cellEditors[1] = textEditor;
        textEditor = new TextCellEditor(table);
        cellEditors[2] = textEditor;
        textEditor = new TextCellEditor(table);
        cellEditors[3] = textEditor;
        
        // Assign the cell editors to the viewer 
        _tableViewer.setCellEditors(cellEditors);
        _tableViewer.setCellModifier(new TableCellModifier());
        */
        
        addTableListeners();
        
        //_tableViewer.addSelectionChangedListener(new );
        
        //_notificationDetails = new Composite(_tabControl, SWT.BORDER);
        //_notificationDetails.setLayoutData(new GridData(GridData.FILL_BOTH));
        
        //_tabControl.layout();
        //viewerComposite.layout();
    }
    
    private void addTableListeners()
    {
        _tableViewer.addDoubleClickListener(new IDoubleClickListener()
            {
                Display display = null;
                Shell   shell = null;
                public void doubleClick(DoubleClickEvent event)
                {
                    System.out.println("DoubleClickEvent" + event);
                    display = Display.getCurrent();
                    shell = new Shell(display, SWT.BORDER | SWT.CLOSE | SWT.MIN |
                            SWT.MAX | SWT.RESIZE);
                    shell.setText("Notification");

                    int x = display.getBounds().width;
                    int y = display.getBounds().height;
                    shell.setBounds(x/4, y/4, x/2, y/3);
                    StructuredSelection selection = (StructuredSelection)event.getSelection();
                    createPopupContents((NotificationObject)selection.getFirstElement());
                    shell.open();
                    while (!shell.isDisposed()) {
                        if (!display.readAndDispatch()) {
                            display.sleep();
                        }
                    }
                    
                    //If you create it, you dispose it.
                    shell.dispose();
                }

                private void createPopupContents(NotificationObject obj)
                {                    
                    shell.setLayout(new GridLayout());
                    
                    Composite parent = new Composite(shell, SWT.NONE);
                    parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
                    GridLayout layout = new GridLayout(4, true);
                    parent.setLayout(layout);

                    Label key = new Label(parent, SWT.TRAIL);               
                    key.setText(COLUMN_SEQ);
                    GridData layoutData = new GridData(SWT.TRAIL, SWT.TOP, false, false,1,1);
                    key.setLayoutData(layoutData);
                    Text  value = new Text(parent, SWT.BEGINNING | SWT.BORDER |SWT.READ_ONLY);
                    value.setText(""+obj.getSequenceNo());
                    value.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false,3,1));

                    // Time row
                    key = new Label(parent, SWT.TRAIL);
                    key.setText(COLUMN_TIME);
                    key.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, true, false,1,1));
                    value = new Text(parent, SWT.BEGINNING | SWT.BORDER | SWT.READ_ONLY);
                    value.setText(""+obj.getTimeStamp());
                    value.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false,3,1));

                    key = new Label(parent, SWT.TRAIL);
                    key.setText(COLUMN_TYPE);
                    key.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, true, false,1,1));
                    value = new Text(parent, SWT.BEGINNING | SWT.BORDER | SWT.READ_ONLY);
                    value.setText(""+obj.getType());
                    value.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false,3,1));

                    key = new Label(parent, SWT.TRAIL);
                    key.setText(COLUMN_MSG);
                    key.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, true, false,1,1));
                    value = new Text(parent, SWT.MULTI | SWT.WRAP| SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY);
                    value.setText(""+obj.getMessage());
                    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
                    gridData.heightHint = 100;
                    value.setLayoutData(gridData);
                }
            });
    }
    
    @Override
    public void refresh(ManagedBean mbean)
    {
        _mbean = mbean;
        _notifications = null;
        _tableViewer.getTable().clearAll();
        
        if (_mbean == null)
        {            
            _tableViewer.getTable().clearAll();
            _subscribeButton.setEnabled(false);
            _unsubscribeButton.setEnabled(false);
            return;
        }        
        
        if (!doesMBeanSendsNotification())
        {
            Control[] children = _form.getBody().getChildren();        
            for (int i = 0; i < children.length; i++)
            {
                children[i].setVisible(false);
            }
            
            String name = (_mbean.getName() != null) ? _mbean.getName() : _mbean.getType();
            _form.setText(name + " does not send any notification");
            return;
        }
        
        Control[] children = _form.getBody().getChildren();        
        for (int i = 0; i < children.length; i++)
        {
            children[i].setVisible(true);
        }
        
        populateNotificationInfo();        
        /*
        ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(_mbean);        
        _notifications = serverRegistry.getNotifications(_mbean);
        if (_notifications != null)
        {
            _tableViewer.setInput(_notifications);
            
        }*/
        //_tableViewer.setInput(null);
        workerRunning = true;
        _form.layout();       
    }
    
    private void refresh()
    {
        _notifications = null;
        _tableViewer.getTable().clearAll();
    }
    
    private void populateNotificationInfo()
    {
        notificationNameCombo.removeAll();
        NotificationInfoModel[] items = MBeanUtility.getNotificationInfo(_mbean);
        notificationNameCombo.add("Select Notification");
        for (int i = 0; i < items.length; i++)
        {
            notificationNameCombo.add(items[i].getName());
            notificationNameCombo.setData(items[i].getName(), items[i]);
        } 
        notificationNameCombo.select(0);
        
        typesCombo.removeAll();
        typesCombo.add("Select Type", 0);
        typesCombo.select(0);
        typesCombo.setEnabled(false);
        
        checkForEnablingButtons();
    }
    
    private void checkForEnablingButtons()
    {
        int nameIndex = notificationNameCombo.getSelectionIndex();
        if (nameIndex == 0)
        {
            _subscribeButton.setEnabled(false);
            _unsubscribeButton.setEnabled(false);
            descriptionLabel.setText("");
            return;
        }
        
        int typeIndex = typesCombo.getSelectionIndex();
        if (typeIndex == 0)
        {
            _subscribeButton.setEnabled(false);
            _unsubscribeButton.setEnabled(false);
            return;
        }
        
        String type = typesCombo.getItem(typeIndex);
        String name = notificationNameCombo.getItem(nameIndex);
        ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(_mbean);
        
        if (serverRegistry.hasSubscribedForNotifications(_mbean, name, type))
        {
            _subscribeButton.setEnabled(false);
            _unsubscribeButton.setEnabled(true);
        }
        else
        {
            _subscribeButton.setEnabled(true);
            _unsubscribeButton.setEnabled(false);
        }
    }
    
    private boolean doesMBeanSendsNotification()
    {
        NotificationInfoModel[] items = MBeanUtility.getNotificationInfo(_mbean);
        if (items == null || items.length == 0)
            return false;
        else
            return true;
    }
    
    private class SelectionListenerImpl extends SelectionAdapter
    {
        public void widgetSelected(SelectionEvent e)
        {
            if (_mbean == null)
                return;
            
            Button source = (Button)e.getSource();
            String type = typesCombo.getItem(typesCombo.getSelectionIndex());
            String name = notificationNameCombo.getItem(notificationNameCombo.getSelectionIndex());
            if (source == _unsubscribeButton)
            {
                try
                {
                    MBeanUtility.removeNotificationListener(_mbean, name, type);
                }
                catch(Exception ex)
                {
                    MBeanUtility.handleException(ex);
                }
            }
            else if (source == _subscribeButton)
            {
                try
                {
                    MBeanUtility.createNotificationlistener(_mbean, name, type);
                }
                catch(Exception ex)
                {
                    MBeanUtility.handleException(ex);
                }
            }
            checkForEnablingButtons();
        }
    }
    
    
    private class ComboSelectionListener extends SelectionAdapter
    {
        public void widgetSelected(SelectionEvent e)
        {
            if (_mbean == null)
                return;
            
            Combo combo = (Combo)e.getSource();
            if (combo == notificationNameCombo)
            {
                if (combo.getSelectionIndex() == 0)
                {
                    descriptionLabel.setText("");
                    typesCombo.select(0);
                    typesCombo.setEnabled(false);
                    return;
                }
                String index = combo.getItem(combo.getSelectionIndex());                
                NotificationInfoModel data = (NotificationInfoModel)combo.getData(index);
                descriptionLabel.setText(data.getDescription());
                typesCombo.removeAll();       
                typesCombo.setItems(data.getTypes());
                typesCombo.add("Select Type", 0);
                typesCombo.select(0);
                typesCombo.setEnabled(true);
            }
            checkForEnablingButtons();
        }
    }
    
    private class ContentProviderImpl implements IStructuredContentProvider, INotificationViewer
    {
        public void inputChanged(Viewer v, Object oldInput, Object newInput)
        {
            
        }
        public void dispose()
        {
            
        }
        public Object[] getElements(Object parent) 
        {
            return _notifications.toArray(new NotificationObject[0]);
        }
        public void addNotification(NotificationObject notification)
        {
            _tableViewer.add(notification);
        }
        
        public void addNotification(List<NotificationObject> notificationList)
        {
            _tableViewer.add(notificationList.toArray(new NotificationObject[0]));
        }
    }
    
    private class LabelProviderImpl implements ITableLabelProvider
    {
        List<ILabelProviderListener> listeners = new ArrayList<ILabelProviderListener>();       
        public void addListener(ILabelProviderListener listener)
        {
            listeners.add(listener);
        }
        
        public void dispose(){
            
        }
        
        public Image getColumnImage(Object element, int columnIndex)
        {
            return null;
        }
        
        public String getColumnText(Object element, int columnIndex)
        {
            String result = null;
            NotificationObject t = (NotificationObject)element;
            switch(columnIndex)
            {
            case 0 : 
                result = String.valueOf(t.getSequenceNo());
                break;
            case 1 :
                result = String.valueOf(t.getTimeStamp());
                break;
            case 2 : 
                result = t.getType();
                break;
            case 3 : 
                result = t.getMessage();
                break;
            default : 
                result = "";
            }
            
            return result;
        }
        
        public boolean isLabelProperty(Object element, String property)
        {
            return false;
        }
        
        public void removeListener(ILabelProviderListener listener)
        {
            listeners.remove(listener);
        }
    } // end of LabelProviderImpl
    
    private boolean workerRunning = false;
    private void setWorkerRunning(boolean running)
    {
        workerRunning = running;
    }
    
    private class Worker implements Runnable
    {
        public void run()
        {
            Display display = _tabFolder.getDisplay();
            while(true)
            {
                if (!workerRunning || _mbean == null || display == null)
                {
                    sleep();
                    continue;
                }
                
                display.syncExec(new Runnable()
                {
                    public void run()
                    {
                        setWorkerRunning(_form.isVisible());
                        if (!workerRunning) return;
                        
                        updateTableViewer();
                    }
                });     
            
                sleep();
            }
        }
        
        private void sleep()
        {
            try
            {
                Thread.sleep(2000);
            }
            catch(Exception ex)
            {

            }  
        }
    }
    
    private void updateTableViewer()
    {
        ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(_mbean);        
        List<NotificationObject> newList = serverRegistry.getNotifications(_mbean);
        if (newList == null)
            return;
        
        /*
        int notificationCount = 0;
        if (_notifications != null)
            notificationCount = _notifications.size();
        
        for (int i = notificationCount; i < newList.size(); i++)
        {
            ((INotificationViewer)contentProvider).addNotification(newList.get(i));
        }*/
        
        _notifications = newList;
        _tableViewer.setInput(_notifications);
        _tableViewer.refresh();
    }
}