Added option to hide unsupported DCIs from "Last Values" view; Added option to indica...
authorVictor Kirhenshtein <victor@netxms.org>
Wed, 11 Jul 2012 22:55:57 +0000 (22:55 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Wed, 11 Jul 2012 22:55:57 +0000 (22:55 +0000)
ChangeLog
include/netxms-version.h
src/install/windows/webui-x64.iss
src/java/netxms-client/src/main/java/org/netxms/client/NXCSession.java
src/java/netxms-client/src/main/java/org/netxms/client/datacollection/DciValue.java
src/java/netxms-eclipse/DataCollection/src/org/netxms/ui/eclipse/datacollection/widgets/LastValuesWidget.java
src/java/netxms-eclipse/DataCollection/src/org/netxms/ui/eclipse/datacollection/widgets/internal/LastValuesFilter.java
src/java/netxms-eclipse/DataCollection/src/org/netxms/ui/eclipse/datacollection/widgets/internal/LastValuesLabelProvider.java
src/java/netxms-eclipse/LogViewer/src/org/netxms/ui/eclipse/logviewer/views/LogViewer.java
src/server/core/dcitem.cpp
src/server/core/dctable.cpp

index 46f2155..117d580 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,8 @@
        - Interface IP shown in connection point search results
        - Interface IP and MAC shown in "Interfaces" tab
        - Added "Status Map" view
+       - Added option to hide unsupported DCIs from "Last Values" view
+       - Added option to indicate data collection errors in "Last Values" view
 - Android client:
        - Dashboards implemented
        - Node status/configuration/topology poll implemented
index 7a8b6fd..e47d236 100644 (file)
@@ -39,7 +39,7 @@
 // Current client-server protocol version
 //
 
-#define CLIENT_PROTOCOL_VERSION     33
+#define CLIENT_PROTOCOL_VERSION     34
 
 
 #endif
index c3f9e51..c27c7c4 100644 (file)
@@ -13,3 +13,4 @@ Source: nxmc\nxmc.war; DestDir: "{app}\WebUI\nxmc"; Flags: ignoreversion; Compon
 Source: files-x64\prunsrv.exe; DestDir: "{app}\WebUI"; Flags: ignoreversion; Components: webui
 
 #include "common-webui.iss"
+
index 890bd7d..e73a9d8 100644 (file)
@@ -151,7 +151,7 @@ public class NXCSession implements Session, ScriptLibraryManager, UserManager, S
 {\r
        // Various public constants\r
        public static final int DEFAULT_CONN_PORT = 4701;\r
-       public static final int CLIENT_PROTOCOL_VERSION = 33;\r
+       public static final int CLIENT_PROTOCOL_VERSION = 34;\r
 \r
        // Authentication types\r
        public static final int AUTH_TYPE_PASSWORD = 0;\r
index c8b3fe7..be5baf8 100644 (file)
@@ -35,6 +35,7 @@ public abstract class DciValue
        private int source;                             // data source (agent, SNMP, etc.)\r
        private int dataType;\r
        private int status;                             // status (active, disabled, etc.)\r
+       private int errorCount;\r
        private int dcObjectType;               // Data collection object type (item, table, etc.)\r
        private Date timestamp;\r
        private Threshold activeThreshold;\r
@@ -82,6 +83,7 @@ public abstract class DciValue
                timestamp = new Date(msg.getVariableAsInt64(var++) * 1000);\r
                status = msg.getVariableAsInteger(var++);\r
                dcObjectType = msg.getVariableAsInteger(var++);\r
+               errorCount = msg.getVariableAsInteger(var++);\r
                if (msg.getVariableAsBoolean(var++))\r
                        activeThreshold = new Threshold(msg, var);\r
                else\r
@@ -175,4 +177,12 @@ public abstract class DciValue
        {\r
                return dcObjectType;\r
        }\r
+\r
+       /**\r
+        * @return the errorCount\r
+        */\r
+       public int getErrorCount()\r
+       {\r
+               return errorCount;\r
+       }\r
 }\r
index 74e3f15..63d701f 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * NetXMS - open source network management system
- * Copyright (C) 2003-2011 Victor Kirhenshtein
+ * Copyright (C) 2003-2012 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
@@ -78,6 +78,8 @@ public class LastValuesWidget extends Composite
        private int autoRefreshInterval = 30000;        // in milliseconds
        private Runnable refreshTimer;
        private Action actionUseMultipliers;
+       private Action actionShowErrors;
+       private Action actionShowUnsupported;
        
        /**
         * Create "last values" widget
@@ -141,16 +143,6 @@ public class LastValuesWidget extends Composite
                dataViewer.addFilter(filter);
                WidgetHelper.restoreTableViewerSettings(dataViewer, ds, configPrefix);
                
-               actionUseMultipliers = new Action("Use &multipliers", Action.AS_CHECK_BOX) {
-                       @Override
-                       public void run()
-                       {
-                               setUseMultipliers(!areMultipliersUsed());
-                       }
-               };
-
-               createPopupMenu();
-
                dataViewer.getTable().addDisposeListener(new DisposeListener() {
                        @Override
                        public void widgetDisposed(DisposeEvent e)
@@ -159,6 +151,8 @@ public class LastValuesWidget extends Composite
                                ds.put(configPrefix + ".autoRefresh", autoRefreshEnabled);
                                ds.put(configPrefix + ".autoRefreshInterval", autoRefreshEnabled);
                                ds.put(configPrefix + ".useMultipliers", labelProvider.areMultipliersUsed());
+                               ds.put(configPrefix + ".showErrors", isShowErrors());
+                               ds.put(configPrefix + ".showUnsupported", isShowUnsupported());
                        }
                });
 
@@ -176,9 +170,6 @@ public class LastValuesWidget extends Composite
                fd.right = new FormAttachment(100, 0);
                filterText.setLayoutData(fd);
                
-               // Finalize widget creation
-               getDataFromServer();
-               
                try
                {
                        ds.getInt(configPrefix + ".autoRefreshInterval");
@@ -191,7 +182,16 @@ public class LastValuesWidget extends Composite
                        labelProvider.setUseMultipliers(ds.getBoolean(configPrefix + ".useMultipliers"));
                else
                        labelProvider.setUseMultipliers(true);
-               actionUseMultipliers.setChecked(areMultipliersUsed());
+               if (ds.get(configPrefix + ".showErrors") != null)
+                       labelProvider.setShowErrors(ds.getBoolean(configPrefix + ".showErrors"));
+               else
+                       labelProvider.setShowErrors(true);
+               filter.setShowUnsupported(ds.getBoolean(configPrefix + ".showUnsupported"));
+               
+               createActions();
+               createPopupMenu();
+
+               getDataFromServer();
                
                // Set initial focus to filter input line
                if (filterEnabled)
@@ -201,6 +201,39 @@ public class LastValuesWidget extends Composite
        }
        
        /**
+        * Create actions
+        */
+       private void createActions()
+       {
+               actionUseMultipliers = new Action("Use &multipliers", Action.AS_CHECK_BOX) {
+                       @Override
+                       public void run()
+                       {
+                               setUseMultipliers(actionUseMultipliers.isChecked());
+                       }
+               };
+               actionUseMultipliers.setChecked(areMultipliersUsed());
+
+               actionShowErrors = new Action("Show collection &errors", Action.AS_CHECK_BOX) {
+                       @Override
+                       public void run()
+                       {
+                               setShowErrors(actionShowErrors.isChecked());
+                       }
+               };
+               actionShowErrors.setChecked(isShowErrors());
+
+               actionShowUnsupported = new Action("Show &unsupported items", Action.AS_CHECK_BOX) {
+                       @Override
+                       public void run()
+                       {
+                               setShowUnsupported(actionShowUnsupported.isChecked());
+                       }
+               };
+               actionShowUnsupported.setChecked(isShowUnsupported());
+       }
+       
+       /**
         * Create pop-up menu
         */
        private void createPopupMenu()
@@ -234,6 +267,8 @@ public class LastValuesWidget extends Composite
                mgr.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
                mgr.add(new Separator());
                mgr.add(actionUseMultipliers);
+               mgr.add(actionShowErrors);
+               mgr.add(actionShowUnsupported);
        }
        
        /**
@@ -404,4 +439,44 @@ public class LastValuesWidget extends Composite
        {
                filterText.setCloseAction(action);
        }
+       
+       /**
+        * @return
+        */
+       public boolean isShowErrors()
+       {
+               return (labelProvider != null) ? labelProvider.isShowErrors() : false;
+       }
+
+       /**
+        * @param show
+        */
+       public void setShowErrors(boolean show)
+       {
+               labelProvider.setShowErrors(show);
+               if (dataViewer != null)
+               {
+                       dataViewer.refresh(true);
+               }
+       }
+       
+       /**
+        * @return
+        */
+       public boolean isShowUnsupported()
+       {
+               return (filter != null) ? filter.isShowUnsupported() : false;
+       }
+
+       /**
+        * @param show
+        */
+       public void setShowUnsupported(boolean show)
+       {
+               filter.setShowUnsupported(show);
+               if (dataViewer != null)
+               {
+                       dataViewer.refresh(true);
+               }
+       }
 }
index 4ba13ae..487e62b 100644 (file)
@@ -20,6 +20,7 @@ package org.netxms.ui.eclipse.datacollection.widgets.internal;
 
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerFilter;
+import org.netxms.client.datacollection.DataCollectionObject;
 import org.netxms.client.datacollection.DciValue;
 
 /**
@@ -28,6 +29,7 @@ import org.netxms.client.datacollection.DciValue;
 public class LastValuesFilter extends ViewerFilter
 {
        private String filterString = null;
+       private boolean showUnsupported = false;
 
        /* (non-Javadoc)
         * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
@@ -35,10 +37,14 @@ public class LastValuesFilter extends ViewerFilter
        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element)
        {
+               final DciValue value = (DciValue)element;
+               
+               if (!showUnsupported && (value.getStatus() == DataCollectionObject.NOT_SUPPORTED))
+                       return false;
+               
                if ((filterString == null) || (filterString.isEmpty()))
                        return true;
                
-               final DciValue value = (DciValue)element;
                return value.getDescription().toLowerCase().contains(filterString);
        }
 
@@ -57,4 +63,20 @@ public class LastValuesFilter extends ViewerFilter
        {
                this.filterString = filterString.toLowerCase();
        }
+
+       /**
+        * @return the showUnsupported
+        */
+       public boolean isShowUnsupported()
+       {
+               return showUnsupported;
+       }
+
+       /**
+        * @param showUnsupported the showUnsupported to set
+        */
+       public void setShowUnsupported(boolean showUnsupported)
+       {
+               this.showUnsupported = showUnsupported;
+       }
 }
index 472d51a..2f3c81f 100644 (file)
@@ -1,6 +1,6 @@
 /**\r
  * NetXMS - open source network management system\r
- * Copyright (C) 2003-2011 Victor Kirhenshtein\r
+ * Copyright (C) 2003-2012 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
@@ -44,6 +44,7 @@ public class LastValuesLabelProvider extends LabelProvider implements ITableLabe
 {\r
        private Image[] stateImages = new Image[3];\r
        private boolean useMultipliers = true;\r
+       private boolean showErrors = true;\r
        private ThresholdLabelProvider thresholdLabelProvider;\r
        \r
        /**\r
@@ -90,10 +91,14 @@ public class LastValuesLabelProvider extends LabelProvider implements ITableLabe
                        case LastValuesWidget.COLUMN_DESCRIPTION:\r
                                return ((DciValue)element).getDescription();\r
                        case LastValuesWidget.COLUMN_VALUE:\r
+                               if (showErrors && ((DciValue)element).getErrorCount() > 0)\r
+                                       return "<< ERROR >>";\r
                                if (((DciValue)element).getDcObjectType() == DataCollectionObject.DCO_TYPE_TABLE)\r
                                        return "<< TABLE >>";\r
                                return useMultipliers ? getValue((DciValue)element) : ((DciValue)element).getValue();\r
                        case LastValuesWidget.COLUMN_TIMESTAMP:\r
+                               if (((DciValue)element).getTimestamp().getTime() == 0)\r
+                                       return null;\r
                                return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(((DciValue)element).getTimestamp());\r
                        case LastValuesWidget.COLUMN_THRESHOLD:\r
                                return formatThreshold(((DciValue)element).getActiveThreshold());\r
@@ -208,8 +213,11 @@ public class LastValuesLabelProvider extends LabelProvider implements ITableLabe
        @Override\r
        public Color getForeground(Object element, int columnIndex)\r
        {\r
+               if (((DciValue)element).getStatus() == DataCollectionObject.DISABLED)\r
+                       return StatusDisplayInfo.getStatusColor(Severity.UNMANAGED);\r
+               if (showErrors && ((DciValue)element).getErrorCount() > 0)\r
+                       return StatusDisplayInfo.getStatusColor(Severity.CRITICAL);\r
                return null;\r
-               //return (((DciValue)element).getActiveThreshold() != null) ? StatusDisplayInfo.getStatusColor(Severity.MAJOR) : null;\r
        }\r
 \r
        /* (non-Javadoc)\r
@@ -220,4 +228,20 @@ public class LastValuesLabelProvider extends LabelProvider implements ITableLabe
        {\r
                return null;\r
        }\r
+\r
+       /**\r
+        * @return the showErrors\r
+        */\r
+       public boolean isShowErrors()\r
+       {\r
+               return showErrors;\r
+       }\r
+\r
+       /**\r
+        * @param showErrors the showErrors to set\r
+        */\r
+       public void setShowErrors(boolean showErrors)\r
+       {\r
+               this.showErrors = showErrors;\r
+       }\r
 }\r
index a08c846..0b210f1 100644 (file)
@@ -29,6 +29,7 @@ import org.eclipse.jface.action.Separator;
 import org.eclipse.jface.commands.ActionHandler;\r
 import org.eclipse.jface.resource.ImageDescriptor;\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.swt.SWT;\r
 import org.eclipse.swt.graphics.Image;\r
@@ -89,6 +90,7 @@ public class LogViewer extends ViewPart
        private Action actionGoLastPage;\r
        private Action actionGoNextPage;\r
        private Action actionGoPrevPage;\r
+       private Action actionCopyToClipboard;\r
        private Table resultSet;\r
        private long currentPosition;\r
        \r
@@ -367,6 +369,14 @@ public class LogViewer extends ViewPart
                actionShowFilter.setChecked(true);\r
       actionShowFilter.setActionDefinitionId("org.netxms.ui.eclipse.logviewer.commands.show_filter");\r
                handlerService.activateHandler(actionShowFilter.getActionDefinitionId(), new ActionHandler(actionShowFilter));\r
+               \r
+               actionCopyToClipboard = new Action("&Copy to clipboard", SharedIcons.COPY) {\r
+                       @Override\r
+                       public void run()\r
+                       {\r
+                               copySelectionToClipboard();\r
+                       }\r
+               };\r
        }\r
        \r
        /**\r
@@ -481,4 +491,17 @@ public class LogViewer extends ViewPart
                if (show)\r
                        filterBuilder.setFocus();\r
        }\r
+       \r
+       /**\r
+        * Copy selection in the list to clipboard\r
+        */\r
+       private void copySelectionToClipboard()\r
+       {\r
+               IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();\r
+               StringBuilder sb = new StringBuilder();\r
+               for(Object o : selection.toList())\r
+               {\r
+                       \r
+               }\r
+       }\r
 }\r
index 0e98dcb..c0e7bc9 100644 (file)
@@ -1348,6 +1348,7 @@ void DCItem::getLastValue(CSCPMessage *pMsg, DWORD dwId)
    }
    pMsg->SetVariable(dwId++, (WORD)m_status);
        pMsg->SetVariable(dwId++, (WORD)getType());
+       pMsg->SetVariable(dwId++, m_dwErrorCount);
 
        DWORD i;
    for(i = 0; i < m_dwNumThresholds; i++)
index 0028356..abe2d96 100644 (file)
@@ -319,6 +319,7 @@ void DCTable::processNewValue(time_t nTimeStamp, void *value)
 
 void DCTable::processNewError()
 {
+       m_dwErrorCount++;
 }
 
 
@@ -521,6 +522,7 @@ void DCTable::getLastValueSummary(CSCPMessage *pMsg, DWORD dwId)
    pMsg->SetVariable(dwId++, (DWORD)m_tLastPoll);
    pMsg->SetVariable(dwId++, (WORD)m_status);
        pMsg->SetVariable(dwId++, (WORD)getType());
+       pMsg->SetVariable(dwId++, m_dwErrorCount);
    pMsg->SetVariable(dwId++, (WORD)0);            // compatibility: number of thresholds
 
        unlock();