4277e1e17ff5488702f6549ae7681225b76d0b8e
[public/netxms.git] / webui / webapp / SNMP / src / org / netxms / ui / eclipse / snmp / actions / SnmpConfigrationAction.java
1 /**
2 * NetXMS - open source network management system
3 * Copyright (C) 2003-2010 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.snmp.actions;
20
21 import org.eclipse.jface.action.IAction;
22 import org.eclipse.jface.viewers.ISelection;
23 import org.eclipse.ui.IWorkbenchWindow;
24 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
25 import org.eclipse.ui.PartInitException;
26 import org.netxms.ui.eclipse.snmp.views.SnmpCredentials;
27 import org.netxms.ui.eclipse.tools.MessageDialogHelper;
28
29 /**
30 * Workbench action for opening SNMP trap configurator view.
31 *
32 */
33 public class SnmpConfigrationAction implements IWorkbenchWindowActionDelegate
34 {
35 private IWorkbenchWindow window;
36
37 /* (non-Javadoc)
38 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
39 */
40 @Override
41 public void dispose()
42 {
43 }
44
45 /* (non-Javadoc)
46 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
47 */
48 @Override
49 public void init(IWorkbenchWindow window)
50 {
51 this.window = window;
52 }
53
54 /* (non-Javadoc)
55 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
56 */
57 @Override
58 public void run(IAction action)
59 {
60 if(window != null)
61 {
62 try
63 {
64 window.getActivePage().showView(SnmpCredentials.ID);
65 }
66 catch (PartInitException e)
67 {
68 MessageDialogHelper.openError(window.getShell(), "Error opening view", "Error: " + e.getMessage());
69 }
70 }
71 }
72
73 /* (non-Javadoc)
74 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
75 */
76 @Override
77 public void selectionChanged(IAction action, ISelection selection)
78 {
79 }
80 }