implemented gauge text color change based on active threshold
authorVictor Kirhenshtein <victor@netxms.org>
Fri, 22 Apr 2016 18:40:51 +0000 (21:40 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Fri, 22 Apr 2016 18:40:51 +0000 (21:40 +0300)
src/java/netxms-eclipse/Charts/src/org/netxms/ui/eclipse/charts/widgets/CurrentValueWidget.java
src/java/netxms-eclipse/Charts/src/org/netxms/ui/eclipse/charts/widgets/internal/DataComparisonElement.java
webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/widgets/CurrentValueWidget.java
webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/widgets/internal/DataComparisonElement.java

index a54e3ce..b55a7bc 100644 (file)
@@ -26,6 +26,7 @@ import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.widgets.Composite;
 import org.netxms.ui.eclipse.charts.widgets.internal.DataComparisonElement;
+import org.netxms.ui.eclipse.console.resources.StatusDisplayInfo;
 import org.netxms.ui.eclipse.tools.WidgetHelper;
 
 /**
@@ -113,6 +114,9 @@ public class CurrentValueWidget extends GaugeWidget
                   case CUSTOM:
                   gc.setForeground(colors.create(customColor));
                   break;
+                  case THRESHOLD:
+                     gc.setForeground(StatusDisplayInfo.getStatusColor(dci.getActiveThresholdSeverity()));
+                     break;
          default:
             gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
             break;
index 6bf5fad..1bf1f0f 100644 (file)
@@ -19,6 +19,7 @@
 package org.netxms.ui.eclipse.charts.widgets.internal;
 
 import org.eclipse.birt.chart.model.component.Series;
+import org.netxms.client.constants.Severity;
 import org.netxms.client.datacollection.GraphItem;
 import org.netxms.client.datacollection.Threshold;
 
@@ -182,4 +183,23 @@ public class DataComparisonElement
                }
                return (value < Double.MAX_VALUE) ? value : defval;
        }
+       
+       /**
+        * Get severity of most critical active threshold
+        * 
+        * @return severity of most critical active threshold (NORMAL if no active thresholds) 
+        */
+       public Severity getActiveThresholdSeverity()
+       {
+          Severity s = Severity.NORMAL;
+      for(Threshold t : thresholds)
+      {
+         if (!t.isActive())
+            continue;
+         
+         if (s.getValue() < t.getCurrentSeverity().getValue())
+            s = t.getCurrentSeverity();
+      }
+      return s;
+       }
 }
index c8fbfa4..67eca51 100644 (file)
@@ -25,6 +25,7 @@ import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.widgets.Composite;
 import org.netxms.ui.eclipse.charts.widgets.internal.DataComparisonElement;
+import org.netxms.ui.eclipse.console.resources.StatusDisplayInfo;
 import org.netxms.ui.eclipse.tools.WidgetHelper;
 
 /**
@@ -112,6 +113,9 @@ public class CurrentValueWidget extends GaugeWidget
                   case CUSTOM:
                   gc.setForeground(colors.create(customColor));
                   break;
+                  case THRESHOLD:
+                     gc.setForeground(StatusDisplayInfo.getStatusColor(dci.getActiveThresholdSeverity()));
+                     break;
          default:
             gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
             break;
index 6bf5fad..1bf1f0f 100644 (file)
@@ -19,6 +19,7 @@
 package org.netxms.ui.eclipse.charts.widgets.internal;
 
 import org.eclipse.birt.chart.model.component.Series;
+import org.netxms.client.constants.Severity;
 import org.netxms.client.datacollection.GraphItem;
 import org.netxms.client.datacollection.Threshold;
 
@@ -182,4 +183,23 @@ public class DataComparisonElement
                }
                return (value < Double.MAX_VALUE) ? value : defval;
        }
+       
+       /**
+        * Get severity of most critical active threshold
+        * 
+        * @return severity of most critical active threshold (NORMAL if no active thresholds) 
+        */
+       public Severity getActiveThresholdSeverity()
+       {
+          Severity s = Severity.NORMAL;
+      for(Threshold t : thresholds)
+      {
+         if (!t.isActive())
+            continue;
+         
+         if (s.getValue() < t.getCurrentSeverity().getValue())
+            s = t.getCurrentSeverity();
+      }
+      return s;
+       }
 }