network discovery configuration form partially working
authorVictor Kirhenshtein <victor@netxms.org>
Thu, 13 Oct 2011 09:00:26 +0000 (09:00 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Thu, 13 Oct 2011 09:00:26 +0000 (09:00 +0000)
.gitattributes
include/ieee8021x.h [new file with mode: 0644]
src/java/netxms-client/src/main/java/org/netxms/client/constants/NetworkDiscovery.java [copied from src/java/netxms-client/src/main/java/org/netxms/client/constants/NodePoller.java with 68% similarity]
src/java/netxms-client/src/main/java/org/netxms/client/constants/NodePoller.java
src/java/netxms-client/src/main/java/org/netxms/client/constants/Severity.java
src/java/netxms-eclipse/ServerConfig/src/org/netxms/ui/eclipse/serverconfig/views/NetworkDiscoveryConfigurator.java
src/java/netxms-eclipse/ServerConfig/src/org/netxms/ui/eclipse/serverconfig/widgets/ScriptSelector.java
src/java/netxms-eclipse/library/src/org/netxms/ui/eclipse/tools/StringComparator.java

index 9636746..35504ae 100644 (file)
@@ -483,6 +483,7 @@ src/java/netxms-client/src/main/java/org/netxms/client/ServerAction.java -text
 src/java/netxms-client/src/main/java/org/netxms/client/ServerConsoleListener.java -text
 src/java/netxms-client/src/main/java/org/netxms/client/ServerFile.java -text
 src/java/netxms-client/src/main/java/org/netxms/client/Table.java -text
+src/java/netxms-client/src/main/java/org/netxms/client/constants/NetworkDiscovery.java -text
 src/java/netxms-client/src/main/java/org/netxms/client/constants/NodePoller.java -text
 src/java/netxms-client/src/main/java/org/netxms/client/constants/RCC.java -text
 src/java/netxms-client/src/main/java/org/netxms/client/constants/Severity.java -text
diff --git a/include/ieee8021x.h b/include/ieee8021x.h
new file mode 100644 (file)
index 0000000..86c96e2
--- /dev/null
@@ -0,0 +1,53 @@
+/* 
+** NetXMS - Network Management System
+** Copyright (C) 2003-2011 Victor Kirhenshtein
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation; either version 3 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**
+** File: ieee8021x.h
+**
+**/
+
+#ifndef _ieee8021x_h
+#define _ieee8021x_h
+
+
+/**
+ * States of PAE state machine
+ */
+#define PAE_STATE_INITIALIZE     1
+#define PAE_STATE_DISCONNECTED   2
+#define PAE_STATE_CONNECTING     3
+#define PAE_STATE_AUTHENTICATING 4
+#define PAE_STATE_AUTHENTICATED  5
+#define PAE_STATE_ABORTING       6
+#define PAE_STATE_HELD           7
+#define PAE_STATE_FORCE_AUTH     8
+#define PAE_STATE_FORCE_UNAUTH   9
+#define PAE_STATE_RESTART        10
+
+/**
+ * States of backend authentication state machine
+ */
+#define BACKEND_STATE_REQUEST    1
+#define BACKEND_STATE_RESPONSE   2
+#define BACKEND_STATE_SUCCESS    3
+#define BACKEND_STATE_FAIL       4
+#define BACKEND_STATE_TIMEOUT    5
+#define BACKEND_STATE_IDLE       6
+#define BACKEND_STATE_INITIALIZE 7
+#define BACKEND_STATE_IGNORE     8
+
+#endif
 package org.netxms.client.constants;\r
 \r
 /**\r
- * Constants for node poller\r
- *\r
+ * This class holds constants related to network discovery\r
  */\r
-public final class NodePoller\r
+public final class NetworkDiscovery\r
 {\r
-       public static final int STATUS_POLL = 1;\r
-       public static final int CONFIGURATION_POLL = 2;\r
-       public static final int INTERFACE_POLL = 3;\r
-       public static final int TOPOLOGY_POLL = 4;\r
+       public static final String FILTER_NONE = "none";\r
+       public static final String FILTER_AUTO = "auto";\r
+       \r
+       public static final int FILTER_ALLOW_AGENT = 0x0001;\r
+       public static final int FILTER_ALLOW_SNMP = 0x0002;\r
+       public static final int FILTER_LIMIT_BY_RANGE = 0x0004;\r
 }\r
index 0413783..7aeb1f5 100644 (file)
@@ -1,6 +1,6 @@
 /**\r
  * NetXMS - open source network management system\r
- * Copyright (C) 2003-2009 Victor Kirhenshtein\r
+ * Copyright (C) 2003-2011 Victor Kirhenshtein\r
  *\r
  * This program is free software; you can redistribute it and/or modify\r
  * it under the terms of the GNU General Public License as published by\r
@@ -20,9 +20,6 @@ package org.netxms.client.constants;
 \r
 /**\r
  * This class holds severity constants.\r
- * \r
- * @author Victor Kirhenshtein\r
- *\r
  */\r
 public final class Severity\r
 {\r
index 0536cba..aede781 100644 (file)
  */\r
 package org.netxms.ui.eclipse.serverconfig.views;\r
 \r
+import java.util.List;\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.jface.action.Action;\r
+import org.eclipse.jface.action.IMenuManager;\r
+import org.eclipse.jface.action.IToolBarManager;\r
+import org.eclipse.jface.action.Separator;\r
+import org.eclipse.jface.dialogs.InputDialog;\r
+import org.eclipse.jface.dialogs.MessageDialog;\r
+import org.eclipse.jface.viewers.ArrayContentProvider;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
 import org.eclipse.jface.viewers.TableViewer;\r
+import org.eclipse.jface.window.Window;\r
 import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.ModifyEvent;\r
+import org.eclipse.swt.events.ModifyListener;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.events.SelectionListener;\r
 import org.eclipse.swt.layout.GridData;\r
 import org.eclipse.swt.layout.GridLayout;\r
 import org.eclipse.swt.widgets.Button;\r
 import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IActionBars;\r
+import org.eclipse.ui.ISaveablePart;\r
 import org.eclipse.ui.forms.events.HyperlinkAdapter;\r
 import org.eclipse.ui.forms.events.HyperlinkEvent;\r
 import org.eclipse.ui.forms.widgets.FormToolkit;\r
@@ -33,19 +50,24 @@ import org.eclipse.ui.forms.widgets.Section;
 import org.eclipse.ui.forms.widgets.TableWrapData;\r
 import org.eclipse.ui.forms.widgets.TableWrapLayout;\r
 import org.eclipse.ui.part.ViewPart;\r
+import org.netxms.client.constants.NetworkDiscovery;\r
+import org.netxms.ui.eclipse.jobs.ConsoleJob;\r
+import org.netxms.ui.eclipse.serverconfig.Activator;\r
 import org.netxms.ui.eclipse.serverconfig.views.helpers.DiscoveryConfig;\r
 import org.netxms.ui.eclipse.serverconfig.widgets.ScriptSelector;\r
 import org.netxms.ui.eclipse.shared.SharedIcons;\r
+import org.netxms.ui.eclipse.tools.StringComparator;\r
 import org.netxms.ui.eclipse.widgets.LabeledText;\r
 \r
 /**\r
  * Configurator for network discovery\r
  */\r
-public class NetworkDiscoveryConfigurator extends ViewPart\r
+public class NetworkDiscoveryConfigurator extends ViewPart implements ISaveablePart\r
 {\r
        public static final String ID = "org.netxms.ui.eclipse.serverconfig.views.NetworkDiscoveryConfigurator";\r
 \r
        private DiscoveryConfig config;\r
+       private boolean modified = false;\r
        private FormToolkit toolkit;\r
        private ScrolledForm form;\r
        private Button radioDiscoveryOff;\r
@@ -63,6 +85,7 @@ public class NetworkDiscoveryConfigurator extends ViewPart
        private TableViewer activeDiscoveryAddressList;\r
        private TableViewer snmpCommunityList;\r
        private TableViewer snmpUsmCredList;\r
+       private Action actionSave;\r
 \r
        /* (non-Javadoc)\r
         * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)\r
@@ -84,8 +107,58 @@ public class NetworkDiscoveryConfigurator extends ViewPart
                createSubnetFilterSection();\r
                createSnmpCommunitySection();\r
                createSnmpUsmCredSection();\r
+               \r
+               createActions();\r
+               contributeToActionBars();\r
+       }\r
+       \r
+       /**\r
+        * Create actions\r
+        */\r
+       private void createActions()\r
+       {\r
+               actionSave = new Action("&Save") {\r
+                       @Override\r
+                       public void run()\r
+                       {\r
+                               save();\r
+                       }\r
+               };\r
+               actionSave.setImageDescriptor(SharedIcons.SAVE);\r
        }\r
        \r
+       /**\r
+        * Contribute actions to action bar\r
+        */\r
+       private void contributeToActionBars()\r
+       {\r
+               IActionBars bars = getViewSite().getActionBars();\r
+               fillLocalPullDown(bars.getMenuManager());\r
+               fillLocalToolBar(bars.getToolBarManager());\r
+       }\r
+\r
+       /**\r
+        * Fill local pull-down menu\r
+        * \r
+        * @param manager\r
+        *           Menu manager for pull-down menu\r
+        */\r
+       private void fillLocalPullDown(IMenuManager manager)\r
+       {\r
+               manager.add(actionSave);\r
+       }\r
+\r
+       /**\r
+        * Fill local tool bar\r
+        * \r
+        * @param manager\r
+        *           Menu manager for local toolbar\r
+        */\r
+       private void fillLocalToolBar(IToolBarManager manager)\r
+       {\r
+               manager.add(actionSave);\r
+       }\r
+\r
        /**\r
         * Create "General" section\r
         */\r
@@ -104,9 +177,35 @@ public class NetworkDiscoveryConfigurator extends ViewPart
                clientArea.setLayout(layout);\r
                section.setClient(clientArea);\r
                \r
+               final SelectionListener listener = new SelectionListener() {\r
+                       @Override\r
+                       public void widgetSelected(SelectionEvent e)\r
+                       {\r
+                               setModified();\r
+                               if (radioDiscoveryOff.getSelection())\r
+                               {\r
+                                       config.setEnabled(false);\r
+                               }\r
+                               else\r
+                               {\r
+                                       config.setEnabled(true);\r
+                                       config.setActive(radioDiscoveryActive.getSelection());\r
+                               }\r
+                       }\r
+                       \r
+                       @Override\r
+                       public void widgetDefaultSelected(SelectionEvent e)\r
+                       {\r
+                               widgetSelected(e);\r
+                       }\r
+               };\r
+               \r
                radioDiscoveryOff = toolkit.createButton(clientArea, "&Disabled", SWT.RADIO);\r
+               radioDiscoveryOff.addSelectionListener(listener);\r
                radioDiscoveryPassive = toolkit.createButton(clientArea, "&Passive only (using ARP and routing information)", SWT.RADIO);\r
+               radioDiscoveryPassive.addSelectionListener(listener);\r
                radioDiscoveryActive = toolkit.createButton(clientArea, "&Active and passive", SWT.RADIO);\r
+               radioDiscoveryActive.addSelectionListener(listener);\r
                \r
                defaultSnmpCommunity = new LabeledText(clientArea, SWT.NONE);\r
                toolkit.adapt(defaultSnmpCommunity);\r
@@ -116,6 +215,14 @@ public class NetworkDiscoveryConfigurator extends ViewPart
                gd.grabExcessHorizontalSpace = true;\r
                gd.verticalIndent = 10;\r
                defaultSnmpCommunity.setLayoutData(gd);\r
+               defaultSnmpCommunity.getTextControl().addModifyListener(new ModifyListener() {\r
+                       @Override\r
+                       public void modifyText(ModifyEvent e)\r
+                       {\r
+                               setModified();\r
+                               config.setDefaultCommunity(defaultSnmpCommunity.getText());\r
+                       }\r
+               });\r
        }\r
        \r
        /**\r
@@ -136,27 +243,94 @@ public class NetworkDiscoveryConfigurator extends ViewPart
                clientArea.setLayout(layout);\r
                section.setClient(clientArea);\r
 \r
+               final SelectionListener radioButtonListener = new SelectionListener() {\r
+                       @Override\r
+                       public void widgetSelected(SelectionEvent e)\r
+                       {\r
+                               updateElementEnablement();\r
+                               setModified();\r
+                               if (radioFilterOff.getSelection())\r
+                               {\r
+                                       config.setFilter(NetworkDiscovery.FILTER_NONE);\r
+                               }\r
+                               else if (radioFilterAuto.getSelection())\r
+                               {\r
+                                       config.setFilter(NetworkDiscovery.FILTER_AUTO);\r
+                               }\r
+                               else\r
+                               {\r
+                                       config.setFilter(filterScript.getScriptName());\r
+                               }\r
+                       }\r
+                       \r
+                       @Override\r
+                       public void widgetDefaultSelected(SelectionEvent e)\r
+                       {\r
+                               widgetSelected(e);\r
+                       }\r
+               };\r
+               \r
+               final SelectionListener checkBoxListener = new SelectionListener() {\r
+                       @Override\r
+                       public void widgetSelected(SelectionEvent e)\r
+                       {\r
+                               setModified();\r
+                               int flags = 0;\r
+                               if (checkAgentOnly.getSelection())\r
+                                       flags |= NetworkDiscovery.FILTER_ALLOW_AGENT;\r
+                               if (checkSnmpOnly.getSelection())\r
+                                       flags |= NetworkDiscovery.FILTER_ALLOW_SNMP;\r
+                               if (checkRangeOnly.getSelection())\r
+                                       flags |= NetworkDiscovery.FILTER_LIMIT_BY_RANGE;\r
+                               config.setFilterFlags(flags);\r
+                       }\r
+                       \r
+                       @Override\r
+                       public void widgetDefaultSelected(SelectionEvent e)\r
+                       {\r
+                               widgetSelected(e);\r
+                       }\r
+               };\r
+               \r
                radioFilterOff = toolkit.createButton(clientArea, "&No filtering", SWT.RADIO);\r
+               radioFilterOff.addSelectionListener(radioButtonListener);\r
                radioFilterCustom = toolkit.createButton(clientArea, "&Custom script)", SWT.RADIO);\r
+               radioFilterCustom.addSelectionListener(radioButtonListener);\r
                filterScript = new ScriptSelector(toolkit, clientArea, "");\r
                GridData gd = new GridData();\r
                gd.horizontalAlignment = SWT.FILL;\r
                gd.grabExcessHorizontalSpace = true;\r
                gd.horizontalIndent = 20;\r
                filterScript.setLayoutData(gd);\r
+               filterScript.addModifyListener(new ModifyListener() {\r
+                       @Override\r
+                       public void modifyText(ModifyEvent e)\r
+                       {\r
+                               if (radioFilterCustom.getSelection())\r
+                               {\r
+                                       setModified();\r
+                                       config.setFilter(filterScript.getScriptName());\r
+                               }\r
+                       }\r
+               });\r
+               \r
                radioFilterAuto = toolkit.createButton(clientArea, "A&utomatically generated script with following rules", SWT.RADIO);\r
+               radioFilterAuto.addSelectionListener(radioButtonListener);\r
                \r
                checkAgentOnly = toolkit.createButton(clientArea, "Accept node if it has &NetXMS agent", SWT.CHECK);\r
+               checkAgentOnly.addSelectionListener(checkBoxListener);\r
                gd = new GridData();\r
                gd.horizontalIndent = 20;\r
                checkAgentOnly.setLayoutData(gd);\r
                \r
                checkSnmpOnly = toolkit.createButton(clientArea, "Accept node if it has &SNMP agent", SWT.CHECK);\r
+               checkSnmpOnly.addSelectionListener(checkBoxListener);\r
                gd = new GridData();\r
                gd.horizontalIndent = 20;\r
                checkSnmpOnly.setLayoutData(gd);\r
                \r
                checkRangeOnly = toolkit.createButton(clientArea, "Accept node if it is within given &range or subnet", SWT.CHECK);\r
+               checkRangeOnly.addSelectionListener(checkBoxListener);\r
                gd = new GridData();\r
                gd.horizontalIndent = 20;\r
                checkRangeOnly.setLayoutData(gd);\r
@@ -306,6 +480,9 @@ public class NetworkDiscoveryConfigurator extends ViewPart
                gd.verticalSpan = 2;\r
                gd.heightHint = 100;\r
                snmpCommunityList.getTable().setLayoutData(gd);\r
+               snmpCommunityList.getTable().setSortDirection(SWT.UP);\r
+               snmpCommunityList.setContentProvider(new ArrayContentProvider());\r
+               snmpCommunityList.setComparator(new StringComparator());\r
                \r
                final ImageHyperlink linkAdd = toolkit.createImageHyperlink(clientArea, SWT.NONE);\r
                linkAdd.setText("Add...");\r
@@ -317,6 +494,7 @@ public class NetworkDiscoveryConfigurator extends ViewPart
                        @Override\r
                        public void linkActivated(HyperlinkEvent e)\r
                        {\r
+                               addCommunity();\r
                        }\r
                });\r
                \r
@@ -330,6 +508,7 @@ public class NetworkDiscoveryConfigurator extends ViewPart
                        @Override\r
                        public void linkActivated(HyperlinkEvent e)\r
                        {\r
+                               removeCommunity();\r
                        }\r
                });\r
        }\r
@@ -406,5 +585,193 @@ public class NetworkDiscoveryConfigurator extends ViewPart
        public void setConfig(DiscoveryConfig config)\r
        {\r
                this.config = config;\r
+               \r
+               radioDiscoveryOff.setSelection(!config.isEnabled());\r
+               radioDiscoveryPassive.setSelection(config.isEnabled() && !config.isActive());\r
+               radioDiscoveryActive.setSelection(config.isEnabled() && config.isActive());\r
+               \r
+               defaultSnmpCommunity.setText(config.getDefaultCommunity());\r
+               \r
+               if (config.getFilter().equalsIgnoreCase(NetworkDiscovery.FILTER_NONE) || config.getFilter().isEmpty())\r
+               {\r
+                       radioFilterOff.setSelection(true);\r
+               }\r
+               else if (config.getFilter().equalsIgnoreCase(NetworkDiscovery.FILTER_AUTO))\r
+               {\r
+                       radioFilterAuto.setSelection(true);\r
+               }\r
+               else\r
+               {\r
+                       radioFilterCustom.setSelection(true);\r
+                       filterScript.setScriptName(config.getFilter());\r
+               }\r
+               \r
+               checkAgentOnly.setSelection((config.getFilterFlags() & NetworkDiscovery.FILTER_ALLOW_AGENT) != 0);\r
+               checkSnmpOnly.setSelection((config.getFilterFlags() & NetworkDiscovery.FILTER_ALLOW_SNMP) != 0);\r
+               checkRangeOnly.setSelection((config.getFilterFlags() & NetworkDiscovery.FILTER_LIMIT_BY_RANGE) != 0);\r
+               \r
+               snmpCommunityList.setInput(config.getCommunities().toArray());\r
+\r
+               updateElementEnablement();\r
+               modified = false;\r
+               firePropertyChange(PROP_DIRTY);\r
+       }\r
+       \r
+       /**\r
+        * Update enabled state of elements\r
+        */\r
+       private void updateElementEnablement()\r
+       {\r
+               // Filter section\r
+               if (radioFilterOff.getSelection())\r
+               {\r
+                       filterScript.setEnabled(false);\r
+                       checkAgentOnly.setEnabled(false);\r
+                       checkSnmpOnly.setEnabled(false);\r
+                       checkRangeOnly.setEnabled(false);\r
+               }\r
+               else if (radioFilterAuto.getSelection())\r
+               {\r
+                       filterScript.setEnabled(false);\r
+                       checkAgentOnly.setEnabled(true);\r
+                       checkSnmpOnly.setEnabled(true);\r
+                       checkRangeOnly.setEnabled(true);\r
+               }\r
+               if (radioFilterCustom.getSelection())\r
+               {\r
+                       filterScript.setEnabled(true);\r
+                       checkAgentOnly.setEnabled(false);\r
+                       checkSnmpOnly.setEnabled(false);\r
+                       checkRangeOnly.setEnabled(false);\r
+               }\r
+       }\r
+       \r
+       /**\r
+        * Mark view as modified\r
+        */\r
+       private void setModified()\r
+       {\r
+               if (!modified)\r
+               {\r
+                       modified = true;\r
+                       firePropertyChange(PROP_DIRTY);\r
+               }\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor)\r
+        */\r
+       @Override\r
+       public void doSave(IProgressMonitor monitor)\r
+       {\r
+               try\r
+               {\r
+                       config.save();\r
+               }\r
+               catch(Exception e)\r
+               {\r
+                       MessageDialog.openError(getSite().getShell(), "Error", "Cannot save network discovery configuration: " + e.getLocalizedMessage());\r
+               }\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.ui.ISaveablePart#doSaveAs()\r
+        */\r
+       @Override\r
+       public void doSaveAs()\r
+       {\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.ui.ISaveablePart#isDirty()\r
+        */\r
+       @Override\r
+       public boolean isDirty()\r
+       {\r
+               return modified;\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed()\r
+        */\r
+       @Override\r
+       public boolean isSaveAsAllowed()\r
+       {\r
+               return false;\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.ui.ISaveablePart#isSaveOnCloseNeeded()\r
+        */\r
+       @Override\r
+       public boolean isSaveOnCloseNeeded()\r
+       {\r
+               return modified;\r
+       }\r
+       \r
+       /**\r
+        * Save settings\r
+        */\r
+       private void save()\r
+       {\r
+               new ConsoleJob("Saving network discovery configuration", this, Activator.PLUGIN_ID, null) {\r
+                       @Override\r
+                       protected void runInternal(IProgressMonitor monitor) throws Exception\r
+                       {\r
+                               config.save();\r
+                               getSite().getShell().getDisplay().asyncExec(new Runnable() {\r
+                                       @Override\r
+                                       public void run()\r
+                                       {\r
+                                               modified = false;\r
+                                               firePropertyChange(PROP_DIRTY);\r
+                                       }\r
+                               });\r
+                       }\r
+                       \r
+                       @Override\r
+                       protected String getErrorMessage()\r
+                       {\r
+                               return "Cannot save network discovery configuration";\r
+                       }\r
+               }.start();\r
+       }\r
+       \r
+       /**\r
+        * Add SNMP community to the list\r
+        */\r
+       private void addCommunity()\r
+       {\r
+               InputDialog dlg = new InputDialog(getSite().getShell(), "Add SNMP Community", \r
+                               "Please enter SNMP community string", "", null);\r
+               if (dlg.open() == Window.OK)\r
+               {\r
+                       String s = dlg.getValue();\r
+                       final List<String> list = config.getCommunities();\r
+                       if (!list.contains(s))\r
+                       {\r
+                               list.add(s);\r
+                               snmpCommunityList.setInput(list.toArray());\r
+                               setModified();\r
+                       }\r
+               }\r
+       }\r
+       \r
+       /**\r
+        * Remove selected SNMP communities\r
+        */\r
+       private void removeCommunity()\r
+       {\r
+               final List<String> list = config.getCommunities();\r
+               IStructuredSelection selection = (IStructuredSelection)snmpCommunityList.getSelection();\r
+               if (selection.size() > 0)\r
+               {\r
+                       for(Object o : selection.toList())\r
+                       {\r
+                               list.remove(o);\r
+                       }\r
+                       snmpCommunityList.setInput(list.toArray());\r
+                       setModified();\r
+               }\r
        }\r
 }\r
index cd0c6cf..c8172b4 100644 (file)
@@ -19,6 +19,7 @@
 package org.netxms.ui.eclipse.serverconfig.widgets;\r
 \r
 import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.ModifyListener;\r
 import org.eclipse.swt.layout.GridData;\r
 import org.eclipse.swt.layout.GridLayout;\r
 import org.eclipse.swt.widgets.Composite;\r
@@ -36,6 +37,7 @@ import org.netxms.ui.eclipse.tools.WidgetHelper;
 public class ScriptSelector extends Composite\r
 {\r
        private Text text;\r
+       private ImageHyperlink selectionLink;\r
        \r
        /**\r
         * @param toolkit\r
@@ -61,7 +63,7 @@ public class ScriptSelector extends Composite
                text.setLayoutData(gd);\r
                text.setText(initialValue);\r
                \r
-               final ImageHyperlink selectionLink = toolkit.createImageHyperlink(this, SWT.NONE);\r
+               selectionLink = toolkit.createImageHyperlink(this, SWT.NONE);\r
                selectionLink.setImage(SharedIcons.IMG_FIND);\r
                selectionLink.addHyperlinkListener(new HyperlinkAdapter() {\r
                        /* (non-Javadoc)\r
@@ -81,6 +83,16 @@ public class ScriptSelector extends Composite
        private void selectScript()\r
        {\r
        }\r
+       \r
+       /**\r
+        * Set currently selected script name\r
+        * \r
+        * @param name\r
+        */\r
+       public void setScriptName(String name)\r
+       {\r
+               text.setText(name);\r
+       }\r
 \r
        /**\r
         * @return\r
@@ -89,4 +101,25 @@ public class ScriptSelector extends Composite
        {\r
                return text.getText();\r
        }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.swt.widgets.Control#setEnabled(boolean)\r
+        */\r
+       @Override\r
+       public void setEnabled(boolean enabled)\r
+       {\r
+               super.setEnabled(enabled);\r
+               text.setEnabled(enabled);\r
+               selectionLink.setEnabled(enabled);\r
+       }\r
+       \r
+       /**\r
+        * Add modify listener\r
+        * \r
+        * @param listener\r
+        */\r
+       public void addModifyListener(ModifyListener listener)\r
+       {\r
+               text.addModifyListener(listener);\r
+       }\r
 }\r
index 8883e5e..f7deaa3 100644 (file)
@@ -25,9 +25,6 @@ import org.eclipse.swt.SWT;
 \r
 /**\r
  * Viewer comparator for case when model elements are just strings.\r
- * \r
- * @author Victor Kirhenshtein\r
- *\r
  */\r
 public class StringComparator extends ViewerComparator\r
 {\r