8839eac403faeefc3e840ee924853866c036883e
[public/netxms.git] / webui / webapp / EventManager / src / org / netxms / ui / eclipse / eventmanager / views / SyslogMonitor.java
1 /**
2 * NetXMS - open source network management system
3 * Copyright (C) 2003-2013 Victor Kirhenshtein
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 package org.netxms.ui.eclipse.eventmanager.views;
20
21 import org.eclipse.core.runtime.IProgressMonitor;
22 import org.eclipse.jface.action.IMenuManager;
23 import org.eclipse.jface.action.Separator;
24 import org.eclipse.swt.SWT;
25 import org.eclipse.swt.widgets.Composite;
26 import org.eclipse.ui.IMemento;
27 import org.eclipse.ui.IViewSite;
28 import org.eclipse.ui.PartInitException;
29 import org.netxms.client.NXCSession;
30 import org.netxms.ui.eclipse.eventmanager.Activator;
31 import org.netxms.ui.eclipse.eventmanager.Messages;
32 import org.netxms.ui.eclipse.eventmanager.widgets.SyslogTraceWidget;
33 import org.netxms.ui.eclipse.jobs.ConsoleJob;
34 import org.netxms.ui.eclipse.shared.ConsoleSharedData;
35 import org.netxms.ui.eclipse.views.AbstractTraceView;
36 import org.netxms.ui.eclipse.widgets.AbstractTraceWidget;
37
38 /**
39 * Event monitor
40 */
41 public class SyslogMonitor extends AbstractTraceView
42 {
43 public static final String ID = "org.netxms.ui.eclipse.eventmanager.views.SyslogMonitor"; //$NON-NLS-1$
44
45 /* (non-Javadoc)
46 * @see org.eclipse.ui.part.ViewPart#init(org.eclipse.ui.IViewSite, org.eclipse.ui.IMemento)
47 */
48 @Override
49 public void init(IViewSite site, IMemento memento) throws PartInitException
50 {
51 super.init(site, memento);
52 if (memento != null)
53 {
54 final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
55 new ConsoleJob(Messages.get().SyslogMonitor_SubscribeJob_Title, null, Activator.PLUGIN_ID, null) {
56 @Override
57 protected void runInternal(IProgressMonitor monitor) throws Exception
58 {
59 session.subscribe(NXCSession.CHANNEL_SYSLOG);
60 }
61
62 @Override
63 protected String getErrorMessage()
64 {
65 return Messages.get().SyslogMonitor_SubscribeJob_Error;
66 }
67 }.start();
68 }
69 }
70
71 /* (non-Javadoc)
72 * @see org.netxms.ui.eclipse.views.AbstractTraceView#createTraceWidget(org.eclipse.swt.widgets.Composite)
73 */
74 @Override
75 protected AbstractTraceWidget createTraceWidget(Composite parent)
76 {
77 return new SyslogTraceWidget(parent, SWT.NONE, this);
78 }
79
80 /* (non-Javadoc)
81 * @see org.netxms.ui.eclipse.views.AbstractTraceView#fillLocalPullDown(org.eclipse.jface.action.IMenuManager)
82 */
83 @Override
84 protected void fillLocalPullDown(IMenuManager manager)
85 {
86 super.fillLocalPullDown(manager);
87 manager.add(new Separator());
88 manager.add(((SyslogTraceWidget)getTraceWidget()).getActionShowColor());
89 manager.add(((SyslogTraceWidget)getTraceWidget()).getActionShowIcons());
90 }
91
92 /* (non-Javadoc)
93 * @see org.eclipse.ui.part.WorkbenchPart#dispose()
94 */
95 @Override
96 public void dispose()
97 {
98 final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
99 new ConsoleJob(Messages.get().SyslogMonitor_UnsubscribeJob_Title, null, Activator.PLUGIN_ID, null) {
100 @Override
101 protected void runInternal(IProgressMonitor monitor) throws Exception
102 {
103 session.unsubscribe(NXCSession.CHANNEL_SYSLOG);
104 }
105
106 @Override
107 protected String getErrorMessage()
108 {
109 return Messages.get().SyslogMonitor_UnsubscribeJob_Error;
110 }
111 }.start();
112 super.dispose();
113 }
114 }