intermediate commit
authorVictor Kirhenshtein <victor@netxms.org>
Sun, 16 Oct 2011 23:10:43 +0000 (23:10 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Sun, 16 Oct 2011 23:10:43 +0000 (23:10 +0000)
doc/manuals/netxms_user_manual.odt
src/java/netxms-client/src/main/java/org/netxms/client/IpAddressListElement.java
src/java/netxms-eclipse/ServerConfig/src/org/netxms/ui/eclipse/serverconfig/dialogs/AddAddressListElementDialog.java [new file with mode: 0644]
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/views/helpers/AddressListElementComparator.java [new file with mode: 0644]

index 9b41bed..394eafc 100644 (file)
Binary files a/doc/manuals/netxms_user_manual.odt and b/doc/manuals/netxms_user_manual.odt differ
index 3f614fd..93c6693 100644 (file)
@@ -72,4 +72,17 @@ public class IpAddressListElement
        {\r
                return addr2;\r
        }\r
+\r
+       /* (non-Javadoc)\r
+        * @see java.lang.Object#toString()\r
+        */\r
+       @Override\r
+       public String toString()\r
+       {\r
+               StringBuilder sb = new StringBuilder();\r
+               sb.append(addr1.getHostAddress());\r
+               sb.append((type == SUBNET) ? '/' : '-');\r
+               sb.append(addr2.getHostAddress());\r
+               return sb.toString();\r
+       }\r
 }\r
diff --git a/src/java/netxms-eclipse/ServerConfig/src/org/netxms/ui/eclipse/serverconfig/dialogs/AddAddressListElementDialog.java b/src/java/netxms-eclipse/ServerConfig/src/org/netxms/ui/eclipse/serverconfig/dialogs/AddAddressListElementDialog.java
new file mode 100644 (file)
index 0000000..645f778
--- /dev/null
@@ -0,0 +1,48 @@
+/**
+ * NetXMS - open source 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 General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.netxms.ui.eclipse.serverconfig.dialogs;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Dialog for adding address list element
+ */
+public class AddAddressListElementDialog extends Dialog
+{
+       /**
+        * @param parentShell
+        */
+       public AddAddressListElementDialog(Shell parentShell)
+       {
+               super(parentShell);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createDialogArea(Composite parent)
+       {
+               // TODO Auto-generated method stub
+               return super.createDialogArea(parent);
+       }
+}
index aede781..62a83f2 100644 (file)
@@ -53,6 +53,7 @@ import org.eclipse.ui.part.ViewPart;
 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.AddressListElementComparator;\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
@@ -365,6 +366,8 @@ public class NetworkDiscoveryConfigurator extends ViewPart implements ISaveableP
                gd.verticalSpan = 2;\r
                gd.heightHint = 100;\r
                activeDiscoveryAddressList.getTable().setLayoutData(gd);\r
+               activeDiscoveryAddressList.setContentProvider(new ArrayContentProvider());\r
+               activeDiscoveryAddressList.setComparator(new AddressListElementComparator());\r
                \r
                final ImageHyperlink linkAdd = toolkit.createImageHyperlink(clientArea, SWT.NONE);\r
                linkAdd.setText("Add...");\r
@@ -422,6 +425,8 @@ public class NetworkDiscoveryConfigurator extends ViewPart implements ISaveableP
                gd.verticalSpan = 2;\r
                gd.heightHint = 100;\r
                filterAddressList.getTable().setLayoutData(gd);\r
+               filterAddressList.setContentProvider(new ArrayContentProvider());\r
+               filterAddressList.setComparator(new AddressListElementComparator());\r
                \r
                final ImageHyperlink linkAdd = toolkit.createImageHyperlink(clientArea, SWT.NONE);\r
                linkAdd.setText("Add...");\r
@@ -611,6 +616,8 @@ public class NetworkDiscoveryConfigurator extends ViewPart implements ISaveableP
                checkRangeOnly.setSelection((config.getFilterFlags() & NetworkDiscovery.FILTER_LIMIT_BY_RANGE) != 0);\r
                \r
                snmpCommunityList.setInput(config.getCommunities().toArray());\r
+               activeDiscoveryAddressList.setInput(config.getTargets().toArray());\r
+               filterAddressList.setInput(config.getAddressFilter().toArray());\r
 \r
                updateElementEnablement();\r
                modified = false;\r
diff --git a/src/java/netxms-eclipse/ServerConfig/src/org/netxms/ui/eclipse/serverconfig/views/helpers/AddressListElementComparator.java b/src/java/netxms-eclipse/ServerConfig/src/org/netxms/ui/eclipse/serverconfig/views/helpers/AddressListElementComparator.java
new file mode 100644 (file)
index 0000000..43531dd
--- /dev/null
@@ -0,0 +1,58 @@
+/**
+ * 
+ */
+package org.netxms.ui.eclipse.serverconfig.views.helpers;
+
+import java.net.InetAddress;
+
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.swt.SWT;
+import org.netxms.client.IpAddressListElement;
+
+/**
+ * Comparator for address list elements
+ */
+public class AddressListElementComparator extends ViewerComparator
+{
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+        */
+       @Override
+       public int compare(Viewer viewer, Object e1, Object e2)
+       {
+               IpAddressListElement a1 = (IpAddressListElement)e1;
+               IpAddressListElement a2 = (IpAddressListElement)e2;
+               
+               int rc = compareIpAddresses(a1.getAddr1(), a2.getAddr1());
+               if (rc == 0)
+               {
+                       rc = compareIpAddresses(a1.getAddr2(), a2.getAddr2());
+               }
+               
+               int dir = ((TableViewer)viewer).getTable().getSortDirection();
+               return (dir == SWT.UP) ? rc : -rc;
+       }
+       
+       /**
+        * Compare two IP addresses
+        * 
+        * @param a1
+        * @param a2
+        * @return
+        */
+       private int compareIpAddresses(InetAddress a1, InetAddress a2)
+       {
+               byte[] b1 = a1.getAddress();
+               byte[] b2 = a2.getAddress();
+               
+               for(int i = 0; i < b1.length; i++)
+               {
+                       int rc = b1[i] - b2[i];
+                       if (rc != 0)
+                               return Integer.signum(rc);
+               }
+               return 0;
+       }
+}