rack information added to "Nodes" tab (issue #1210)
authorVictor Kirhenshtein <victor@netxms.org>
Thu, 26 May 2016 08:25:00 +0000 (11:25 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Thu, 26 May 2016 08:25:00 +0000 (11:25 +0300)
22 files changed:
src/java/netxms-eclipse/ObjectView/src/org/netxms/ui/eclipse/objectview/Messages.java
src/java/netxms-eclipse/ObjectView/src/org/netxms/ui/eclipse/objectview/messages.properties
src/java/netxms-eclipse/ObjectView/src/org/netxms/ui/eclipse/objectview/messages_cs.properties
src/java/netxms-eclipse/ObjectView/src/org/netxms/ui/eclipse/objectview/messages_de.properties
src/java/netxms-eclipse/ObjectView/src/org/netxms/ui/eclipse/objectview/messages_es.properties
src/java/netxms-eclipse/ObjectView/src/org/netxms/ui/eclipse/objectview/messages_fr.properties
src/java/netxms-eclipse/ObjectView/src/org/netxms/ui/eclipse/objectview/messages_ru.properties
src/java/netxms-eclipse/ObjectView/src/org/netxms/ui/eclipse/objectview/messages_zh_CN.properties
src/java/netxms-eclipse/ObjectView/src/org/netxms/ui/eclipse/objectview/objecttabs/NodesTab.java
src/java/netxms-eclipse/ObjectView/src/org/netxms/ui/eclipse/objectview/objecttabs/helpers/NodeListComparator.java
src/java/netxms-eclipse/ObjectView/src/org/netxms/ui/eclipse/objectview/objecttabs/helpers/NodeListLabelProvider.java
webui/webapp/ObjectView/src/org/netxms/ui/eclipse/objectview/Messages.java
webui/webapp/ObjectView/src/org/netxms/ui/eclipse/objectview/messages.properties
webui/webapp/ObjectView/src/org/netxms/ui/eclipse/objectview/messages_cs.properties
webui/webapp/ObjectView/src/org/netxms/ui/eclipse/objectview/messages_de.properties
webui/webapp/ObjectView/src/org/netxms/ui/eclipse/objectview/messages_es.properties
webui/webapp/ObjectView/src/org/netxms/ui/eclipse/objectview/messages_fr.properties
webui/webapp/ObjectView/src/org/netxms/ui/eclipse/objectview/messages_ru.properties
webui/webapp/ObjectView/src/org/netxms/ui/eclipse/objectview/messages_zh_CN.properties
webui/webapp/ObjectView/src/org/netxms/ui/eclipse/objectview/objecttabs/NodesTab.java
webui/webapp/ObjectView/src/org/netxms/ui/eclipse/objectview/objecttabs/helpers/NodeListComparator.java
webui/webapp/ObjectView/src/org/netxms/ui/eclipse/objectview/objecttabs/helpers/NodeListLabelProvider.java

index a97bded..f469285 100644 (file)
@@ -187,6 +187,7 @@ public class Messages extends NLS
    public static String NodesTab_ColName;
    public static String NodesTab_ColPlatform;
    public static String NodesTab_ColPrimaryIP;
+   public static String NodesTab_ColRack;
    public static String NodesTab_ColStatus;
    public static String NodesTab_ColSysDescr;
    public static String ObjectStatusMapView_ActionGroupNodes;
index ed3dcf7..7c5a402 100644 (file)
@@ -180,6 +180,7 @@ NodesTab_ColId=ID
 NodesTab_ColName=Name
 NodesTab_ColPlatform=Platform
 NodesTab_ColPrimaryIP=Primary IP
+NodesTab_ColRack=Rack
 NodesTab_ColStatus=Status
 NodesTab_ColSysDescr=Sys Description
 ObjectStatusMapView_ActionGroupNodes=&Group nodes
index 44b3569..eaba320 100644 (file)
@@ -180,6 +180,7 @@ NodesTab_ColId=ID
 NodesTab_ColName=Name
 NodesTab_ColPlatform=Platform
 NodesTab_ColPrimaryIP=Primary IP
+NodesTab_ColRack=Rack
 NodesTab_ColStatus=Status
 NodesTab_ColSysDescr=Sys Description
 ObjectStatusMapView_ActionGroupNodes=&Skupina prvk\u016f
index 5c5746a..a755193 100644 (file)
@@ -180,6 +180,7 @@ NodesTab_ColId=ID
 NodesTab_ColName=Name
 NodesTab_ColPlatform=Platform
 NodesTab_ColPrimaryIP=Primary IP
+NodesTab_ColRack=Rack
 NodesTab_ColStatus=Status
 NodesTab_ColSysDescr=Sys Description
 ObjectStatusMapView_ActionGroupNodes=&Group nodes
index 5c5746a..a755193 100644 (file)
@@ -180,6 +180,7 @@ NodesTab_ColId=ID
 NodesTab_ColName=Name
 NodesTab_ColPlatform=Platform
 NodesTab_ColPrimaryIP=Primary IP
+NodesTab_ColRack=Rack
 NodesTab_ColStatus=Status
 NodesTab_ColSysDescr=Sys Description
 ObjectStatusMapView_ActionGroupNodes=&Group nodes
index 5c5746a..a755193 100644 (file)
@@ -180,6 +180,7 @@ NodesTab_ColId=ID
 NodesTab_ColName=Name
 NodesTab_ColPlatform=Platform
 NodesTab_ColPrimaryIP=Primary IP
+NodesTab_ColRack=Rack
 NodesTab_ColStatus=Status
 NodesTab_ColSysDescr=Sys Description
 ObjectStatusMapView_ActionGroupNodes=&Group nodes
index b069681..587db7b 100644 (file)
@@ -180,6 +180,7 @@ NodesTab_ColId=ID
 NodesTab_ColName=\u0418\u043c\u044f
 NodesTab_ColPlatform=\u041f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430
 NodesTab_ColPrimaryIP=\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 IP
+NodesTab_ColRack=Rack
 NodesTab_ColStatus=\u0421\u0442\u0430\u0442\u0443\u0441
 NodesTab_ColSysDescr=\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435
 ObjectStatusMapView_ActionGroupNodes=&\u0413\u0440\u0443\u043f\u043f\u0430 \u0443\u0437\u043b\u043e\u0432
index 5c5746a..a755193 100644 (file)
@@ -180,6 +180,7 @@ NodesTab_ColId=ID
 NodesTab_ColName=Name
 NodesTab_ColPlatform=Platform
 NodesTab_ColPrimaryIP=Primary IP
+NodesTab_ColRack=Rack
 NodesTab_ColStatus=Status
 NodesTab_ColSysDescr=Sys Description
 ObjectStatusMapView_ActionGroupNodes=&Group nodes
index 26c268c..bee730f 100644 (file)
@@ -55,10 +55,11 @@ public class NodesTab extends ObjectTab
        public static final int COLUMN_ID = 0;
        public static final int COLUMN_NAME = 1;
        public static final int COLUMN_IP_ADDRESS = 2;
-   public static final int COLUMN_PLATFORM = 3;
-   public static final int COLUMN_AGENT_VERSION = 4;
-   public static final int COLUMN_SYS_DESCRIPTION = 5;
-   public static final int COLUMN_STATUS = 6;
+   public static final int COLUMN_RACK = 3;
+   public static final int COLUMN_PLATFORM = 4;
+   public static final int COLUMN_AGENT_VERSION = 5;
+   public static final int COLUMN_SYS_DESCRIPTION = 6;
+   public static final int COLUMN_STATUS = 7;
        
        private SortableTableViewer viewer;
        private Action actionExportToCsv;
@@ -73,24 +74,25 @@ public class NodesTab extends ObjectTab
                      Messages.get().NodesTab_ColId,
                      Messages.get().NodesTab_ColName,
                      Messages.get().NodesTab_ColPrimaryIP,
+            Messages.get().NodesTab_ColRack,
                      Messages.get().NodesTab_ColPlatform,
                      Messages.get().NodesTab_ColAgentVersion,
                      Messages.get().NodesTab_ColSysDescr,
                      Messages.get().NodesTab_ColStatus
                };
-               final int[] widths = { 60, 150, 100, 150, 100, 300, 100 };
+               final int[] widths = { 60, 150, 100, 150, 150, 100, 300, 100 };
                viewer = new SortableTableViewer(parent, names, widths, COLUMN_NAME, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
                viewer.setLabelProvider(new NodeListLabelProvider());
                viewer.setContentProvider(new ArrayContentProvider());
                viewer.setComparator(new NodeListComparator());
                viewer.getTable().setHeaderVisible(true);
                viewer.getTable().setLinesVisible(true);
-               WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), "NodeTable"); //$NON-NLS-1$
+               WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), "NodeTable.V2"); //$NON-NLS-1$
                viewer.getTable().addDisposeListener(new DisposeListener() {
                        @Override
                        public void widgetDisposed(DisposeEvent e)
                        {
-                               WidgetHelper.saveColumnSettings(viewer.getTable(), Activator.getDefault().getDialogSettings(), "NodeTable"); //$NON-NLS-1$
+                               WidgetHelper.saveColumnSettings(viewer.getTable(), Activator.getDefault().getDialogSettings(), "NodeTable.V2"); //$NON-NLS-1$
                        }
                });
                createActions();
index e209b43..15f5328 100644 (file)
@@ -21,8 +21,11 @@ package org.netxms.ui.eclipse.objectview.objecttabs.helpers;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerComparator;
 import org.eclipse.swt.SWT;
+import org.netxms.client.NXCSession;
 import org.netxms.client.objects.AbstractNode;
+import org.netxms.client.objects.Rack;
 import org.netxms.ui.eclipse.objectview.objecttabs.NodesTab;
+import org.netxms.ui.eclipse.shared.ConsoleSharedData;
 import org.netxms.ui.eclipse.tools.ComparatorHelper;
 import org.netxms.ui.eclipse.widgets.SortableTableViewer;
 
@@ -31,6 +34,8 @@ import org.netxms.ui.eclipse.widgets.SortableTableViewer;
  */
 public class NodeListComparator extends ViewerComparator
 {
+   private NXCSession session = ConsoleSharedData.getSession();
+   
        /* (non-Javadoc)
         * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
         */
@@ -65,6 +70,22 @@ public class NodeListComparator extends ViewerComparator
                        case NodesTab.COLUMN_IP_ADDRESS:
                                result = ComparatorHelper.compareInetAddresses(node1.getPrimaryIP(), node2.getPrimaryIP());
                                break;
+         case NodesTab.COLUMN_RACK:
+            Rack rack1 = session.findObjectById(node1.getRackId(), Rack.class);
+            Rack rack2 = session.findObjectById(node2.getRackId(), Rack.class);
+            if ((rack1 != null) && (rack2 != null))
+            {
+               result = rack1.getObjectName().compareToIgnoreCase(rack2.getObjectName());
+               if (result == 0)
+               {
+                  result = node1.getRackPosition() - node2.getRackPosition();
+               }
+            }
+            else
+            {
+               result = Long.signum(node1.getRackId() - node2.getRackId());
+            }
+            break;
                        default:
                                result = 0;
                                break;
index 7f4d14c..c085482 100644 (file)
@@ -23,15 +23,21 @@ import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Image;
+import org.netxms.client.NXCSession;
 import org.netxms.client.objects.AbstractNode;
+import org.netxms.client.objects.Rack;
 import org.netxms.ui.eclipse.console.resources.StatusDisplayInfo;
+import org.netxms.ui.eclipse.objectview.Messages;
 import org.netxms.ui.eclipse.objectview.objecttabs.NodesTab;
+import org.netxms.ui.eclipse.shared.ConsoleSharedData;
 
 /**
  * Label provider for node list
  */
 public class NodeListLabelProvider extends LabelProvider implements ITableLabelProvider, ITableColorProvider
 {
+   private NXCSession session = ConsoleSharedData.getSession();
+   
        /* (non-Javadoc)
         * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
         */
@@ -64,6 +70,18 @@ public class NodeListLabelProvider extends LabelProvider implements ITableLabelP
             return node.getPlatformName();
          case NodesTab.COLUMN_AGENT_VERSION:
             return node.getAgentVersion();
+         case NodesTab.COLUMN_RACK:
+            if (node.getRackId() != 0)
+            {
+               Rack rack = session.findObjectById(node.getRackId(), Rack.class);
+               if (rack != null)
+               {
+                  return String.format(Messages.get().GeneralInfo_Units, rack.getObjectName(),
+                          rack.isTopBottomNumbering() ? node.getRackPosition() : node.getRackPosition() - node.getRackHeight() + 1,
+                          rack.isTopBottomNumbering() ? node.getRackPosition() + node.getRackHeight() - 1 : node.getRackPosition());
+               }
+            }
+            return "";
                }
                return null;
        }
index 223d669..fc65c02 100644 (file)
@@ -190,6 +190,7 @@ public class Messages extends NLS
    public String NodesTab_ColName;
    public String NodesTab_ColPlatform;
    public String NodesTab_ColPrimaryIP;
+   public String NodesTab_ColRack;
    public String NodesTab_ColStatus;
    public String NodesTab_ColSysDescr;
    public String ObjectStatusMapView_ActionGroupNodes;
index ed3dcf7..7c5a402 100644 (file)
@@ -180,6 +180,7 @@ NodesTab_ColId=ID
 NodesTab_ColName=Name
 NodesTab_ColPlatform=Platform
 NodesTab_ColPrimaryIP=Primary IP
+NodesTab_ColRack=Rack
 NodesTab_ColStatus=Status
 NodesTab_ColSysDescr=Sys Description
 ObjectStatusMapView_ActionGroupNodes=&Group nodes
index 44b3569..eaba320 100644 (file)
@@ -180,6 +180,7 @@ NodesTab_ColId=ID
 NodesTab_ColName=Name
 NodesTab_ColPlatform=Platform
 NodesTab_ColPrimaryIP=Primary IP
+NodesTab_ColRack=Rack
 NodesTab_ColStatus=Status
 NodesTab_ColSysDescr=Sys Description
 ObjectStatusMapView_ActionGroupNodes=&Skupina prvk\u016f
index 5c5746a..a755193 100644 (file)
@@ -180,6 +180,7 @@ NodesTab_ColId=ID
 NodesTab_ColName=Name
 NodesTab_ColPlatform=Platform
 NodesTab_ColPrimaryIP=Primary IP
+NodesTab_ColRack=Rack
 NodesTab_ColStatus=Status
 NodesTab_ColSysDescr=Sys Description
 ObjectStatusMapView_ActionGroupNodes=&Group nodes
index 5c5746a..a755193 100644 (file)
@@ -180,6 +180,7 @@ NodesTab_ColId=ID
 NodesTab_ColName=Name
 NodesTab_ColPlatform=Platform
 NodesTab_ColPrimaryIP=Primary IP
+NodesTab_ColRack=Rack
 NodesTab_ColStatus=Status
 NodesTab_ColSysDescr=Sys Description
 ObjectStatusMapView_ActionGroupNodes=&Group nodes
index 5c5746a..a755193 100644 (file)
@@ -180,6 +180,7 @@ NodesTab_ColId=ID
 NodesTab_ColName=Name
 NodesTab_ColPlatform=Platform
 NodesTab_ColPrimaryIP=Primary IP
+NodesTab_ColRack=Rack
 NodesTab_ColStatus=Status
 NodesTab_ColSysDescr=Sys Description
 ObjectStatusMapView_ActionGroupNodes=&Group nodes
index b069681..587db7b 100644 (file)
@@ -180,6 +180,7 @@ NodesTab_ColId=ID
 NodesTab_ColName=\u0418\u043c\u044f
 NodesTab_ColPlatform=\u041f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430
 NodesTab_ColPrimaryIP=\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 IP
+NodesTab_ColRack=Rack
 NodesTab_ColStatus=\u0421\u0442\u0430\u0442\u0443\u0441
 NodesTab_ColSysDescr=\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435
 ObjectStatusMapView_ActionGroupNodes=&\u0413\u0440\u0443\u043f\u043f\u0430 \u0443\u0437\u043b\u043e\u0432
index 5c5746a..a755193 100644 (file)
@@ -180,6 +180,7 @@ NodesTab_ColId=ID
 NodesTab_ColName=Name
 NodesTab_ColPlatform=Platform
 NodesTab_ColPrimaryIP=Primary IP
+NodesTab_ColRack=Rack
 NodesTab_ColStatus=Status
 NodesTab_ColSysDescr=Sys Description
 ObjectStatusMapView_ActionGroupNodes=&Group nodes
index 26c268c..bee730f 100644 (file)
@@ -55,10 +55,11 @@ public class NodesTab extends ObjectTab
        public static final int COLUMN_ID = 0;
        public static final int COLUMN_NAME = 1;
        public static final int COLUMN_IP_ADDRESS = 2;
-   public static final int COLUMN_PLATFORM = 3;
-   public static final int COLUMN_AGENT_VERSION = 4;
-   public static final int COLUMN_SYS_DESCRIPTION = 5;
-   public static final int COLUMN_STATUS = 6;
+   public static final int COLUMN_RACK = 3;
+   public static final int COLUMN_PLATFORM = 4;
+   public static final int COLUMN_AGENT_VERSION = 5;
+   public static final int COLUMN_SYS_DESCRIPTION = 6;
+   public static final int COLUMN_STATUS = 7;
        
        private SortableTableViewer viewer;
        private Action actionExportToCsv;
@@ -73,24 +74,25 @@ public class NodesTab extends ObjectTab
                      Messages.get().NodesTab_ColId,
                      Messages.get().NodesTab_ColName,
                      Messages.get().NodesTab_ColPrimaryIP,
+            Messages.get().NodesTab_ColRack,
                      Messages.get().NodesTab_ColPlatform,
                      Messages.get().NodesTab_ColAgentVersion,
                      Messages.get().NodesTab_ColSysDescr,
                      Messages.get().NodesTab_ColStatus
                };
-               final int[] widths = { 60, 150, 100, 150, 100, 300, 100 };
+               final int[] widths = { 60, 150, 100, 150, 150, 100, 300, 100 };
                viewer = new SortableTableViewer(parent, names, widths, COLUMN_NAME, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
                viewer.setLabelProvider(new NodeListLabelProvider());
                viewer.setContentProvider(new ArrayContentProvider());
                viewer.setComparator(new NodeListComparator());
                viewer.getTable().setHeaderVisible(true);
                viewer.getTable().setLinesVisible(true);
-               WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), "NodeTable"); //$NON-NLS-1$
+               WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), "NodeTable.V2"); //$NON-NLS-1$
                viewer.getTable().addDisposeListener(new DisposeListener() {
                        @Override
                        public void widgetDisposed(DisposeEvent e)
                        {
-                               WidgetHelper.saveColumnSettings(viewer.getTable(), Activator.getDefault().getDialogSettings(), "NodeTable"); //$NON-NLS-1$
+                               WidgetHelper.saveColumnSettings(viewer.getTable(), Activator.getDefault().getDialogSettings(), "NodeTable.V2"); //$NON-NLS-1$
                        }
                });
                createActions();
index e209b43..15f5328 100644 (file)
@@ -21,8 +21,11 @@ package org.netxms.ui.eclipse.objectview.objecttabs.helpers;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerComparator;
 import org.eclipse.swt.SWT;
+import org.netxms.client.NXCSession;
 import org.netxms.client.objects.AbstractNode;
+import org.netxms.client.objects.Rack;
 import org.netxms.ui.eclipse.objectview.objecttabs.NodesTab;
+import org.netxms.ui.eclipse.shared.ConsoleSharedData;
 import org.netxms.ui.eclipse.tools.ComparatorHelper;
 import org.netxms.ui.eclipse.widgets.SortableTableViewer;
 
@@ -31,6 +34,8 @@ import org.netxms.ui.eclipse.widgets.SortableTableViewer;
  */
 public class NodeListComparator extends ViewerComparator
 {
+   private NXCSession session = ConsoleSharedData.getSession();
+   
        /* (non-Javadoc)
         * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
         */
@@ -65,6 +70,22 @@ public class NodeListComparator extends ViewerComparator
                        case NodesTab.COLUMN_IP_ADDRESS:
                                result = ComparatorHelper.compareInetAddresses(node1.getPrimaryIP(), node2.getPrimaryIP());
                                break;
+         case NodesTab.COLUMN_RACK:
+            Rack rack1 = session.findObjectById(node1.getRackId(), Rack.class);
+            Rack rack2 = session.findObjectById(node2.getRackId(), Rack.class);
+            if ((rack1 != null) && (rack2 != null))
+            {
+               result = rack1.getObjectName().compareToIgnoreCase(rack2.getObjectName());
+               if (result == 0)
+               {
+                  result = node1.getRackPosition() - node2.getRackPosition();
+               }
+            }
+            else
+            {
+               result = Long.signum(node1.getRackId() - node2.getRackId());
+            }
+            break;
                        default:
                                result = 0;
                                break;
index 7f4d14c..c085482 100644 (file)
@@ -23,15 +23,21 @@ import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Image;
+import org.netxms.client.NXCSession;
 import org.netxms.client.objects.AbstractNode;
+import org.netxms.client.objects.Rack;
 import org.netxms.ui.eclipse.console.resources.StatusDisplayInfo;
+import org.netxms.ui.eclipse.objectview.Messages;
 import org.netxms.ui.eclipse.objectview.objecttabs.NodesTab;
+import org.netxms.ui.eclipse.shared.ConsoleSharedData;
 
 /**
  * Label provider for node list
  */
 public class NodeListLabelProvider extends LabelProvider implements ITableLabelProvider, ITableColorProvider
 {
+   private NXCSession session = ConsoleSharedData.getSession();
+   
        /* (non-Javadoc)
         * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
         */
@@ -64,6 +70,18 @@ public class NodeListLabelProvider extends LabelProvider implements ITableLabelP
             return node.getPlatformName();
          case NodesTab.COLUMN_AGENT_VERSION:
             return node.getAgentVersion();
+         case NodesTab.COLUMN_RACK:
+            if (node.getRackId() != 0)
+            {
+               Rack rack = session.findObjectById(node.getRackId(), Rack.class);
+               if (rack != null)
+               {
+                  return String.format(Messages.get().GeneralInfo_Units, rack.getObjectName(),
+                          rack.isTopBottomNumbering() ? node.getRackPosition() : node.getRackPosition() - node.getRackHeight() + 1,
+                          rack.isTopBottomNumbering() ? node.getRackPosition() + node.getRackHeight() - 1 : node.getRackPosition());
+               }
+            }
+            return "";
                }
                return null;
        }