Configurable display format for dashboard elements data sources
authorVictor Kirhenshtein <victor@netxms.org>
Mon, 25 Apr 2016 07:23:52 +0000 (10:23 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Mon, 25 Apr 2016 07:23:52 +0000 (10:23 +0300)
40 files changed:
ChangeLog
src/java/client/netxms-client/src/main/java/org/netxms/client/datacollection/GraphItem.java
src/java/netxms-eclipse/Charts/src/org/netxms/ui/eclipse/charts/api/ChartDciConfig.java
src/java/netxms-eclipse/Charts/src/org/netxms/ui/eclipse/charts/widgets/GaugeWidget.java
src/java/netxms-eclipse/Charts/src/org/netxms/ui/eclipse/charts/widgets/internal/DataComparisonElement.java
src/java/netxms-eclipse/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/AvailabilityChartElement.java
src/java/netxms-eclipse/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/BarChartElement.java
src/java/netxms-eclipse/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/GaugeElement.java
src/java/netxms-eclipse/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/LineChartElement.java
src/java/netxms-eclipse/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/ObjectStatusChartElement.java
src/java/netxms-eclipse/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/PieChartElement.java
src/java/netxms-eclipse/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/TableComparisonChartElement.java
src/java/netxms-eclipse/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/TubeChartElement.java
src/java/netxms-eclipse/DataCollection/src/org/netxms/ui/eclipse/datacollection/dialogs/DataSourceEditDlg.java
src/java/netxms-eclipse/NetworkMaps/src/org/netxms/ui/eclipse/networkmaps/views/helpers/ObjectTooltip.java
src/java/netxms-eclipse/ObjectView/src/org/netxms/ui/eclipse/objectview/objecttabs/elements/AvailabilityChart.java
src/java/netxms-eclipse/ObjectView/src/org/netxms/ui/eclipse/objectview/views/TabbedObjectView.java
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/objecttabs/internal/PerfTabGraph.java
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/views/DataComparisonView.java
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/views/HistoricalGraphView.java
src/java/netxms-eclipse/SLM/src/org/netxms/ui/eclipse/slm/views/ServiceAvailability.java
webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/api/ChartDciConfig.java
webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/widgets/GaugeWidget.java
webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/widgets/internal/DataComparisonElement.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/AvailabilityChartElement.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/BarChartElement.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/GaugeElement.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/LineChartElement.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/ObjectStatusChartElement.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/PieChartElement.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/TableComparisonChartElement.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/TubeChartElement.java
webui/webapp/DataCollection/src/org/netxms/ui/eclipse/datacollection/dialogs/DataSourceEditDlg.java
webui/webapp/NetworkMaps/src/org/netxms/ui/eclipse/networkmaps/views/helpers/ObjectTooltip.java
webui/webapp/ObjectView/src/org/netxms/ui/eclipse/objectview/objecttabs/elements/AvailabilityChart.java
webui/webapp/ObjectView/src/org/netxms/ui/eclipse/objectview/views/TabbedObjectView.java
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/objecttabs/internal/PerfTabGraph.java
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/views/DataComparisonView.java
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/views/HistoricalGraphView.java
webui/webapp/SLM/src/org/netxms/ui/eclipse/slm/views/ServiceAvailability.java

index 51f3efa..f47fa8e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@
 - Management console
        - Improved dashboard gauge widget
        - Added translucence option for dashboard line charts
+       - Configurable display format for dashboard elements data sources
 - Android console
        - Reorganized alarm notification section (issue #1194)
 - Fixed issues: #1194, #1200
index 4b67fcf..757c360 100644 (file)
@@ -30,6 +30,7 @@ public class GraphItem
        private int dataType;
        private String name;
        private String description;
+   private String displayFormat;
        private String dataColumn;
        private String instance;
 
@@ -45,6 +46,7 @@ public class GraphItem
                dataType = DataCollectionItem.DT_STRING;
                name = "<noname>";
                description = "<noname>";
+      displayFormat = "%s";
                dataColumn = "";
                instance = "";
        }
@@ -58,8 +60,9 @@ public class GraphItem
         * @param dataType
         * @param name
         * @param description
+        * @param displayFormat
         */
-       public GraphItem(long nodeId, long dciId, int source, int dataType, String name, String description)
+       public GraphItem(long nodeId, long dciId, int source, int dataType, String name, String description, String displayFormat)
        {
                this.nodeId = nodeId;
                this.dciId = dciId;
@@ -68,6 +71,7 @@ public class GraphItem
                this.dataType = dataType;
                this.name = name;
                this.description = description;
+      this.displayFormat = displayFormat;
                this.dataColumn = "";
                this.instance = "";
        }
@@ -82,7 +86,7 @@ public class GraphItem
         * @param name
         * @param description
         */
-       public GraphItem(long nodeId, long dciId, int source, int dataType, String name, String description, String instance, String dataColumn)
+       public GraphItem(long nodeId, long dciId, int source, int dataType, String name, String description, String displayFormat, String instance, String dataColumn)
        {
                this.nodeId = nodeId;
                this.dciId = dciId;
@@ -91,6 +95,7 @@ public class GraphItem
                this.dataType = dataType;
                this.name = name;
                this.description = description;
+      this.displayFormat = displayFormat;
                this.dataColumn = dataColumn;
                this.instance = instance;
        }
@@ -238,4 +243,20 @@ public class GraphItem
        {
                this.instance = instance;
        }
+
+   /**
+    * @return the displayFormat
+    */
+   public String getDisplayFormat()
+   {
+      return displayFormat;
+   }
+
+   /**
+    * @param displayFormat the displayFormat to set
+    */
+   public void setDisplayFormat(String displayFormat)
+   {
+      this.displayFormat = displayFormat;
+   }
 }
index 58401a3..0166f0e 100644 (file)
@@ -68,6 +68,9 @@ public class ChartDciConfig
        @Element(required=false)
        public String column;
        
+   @Element(required=false)
+   public String displayFormat;
+   
        /**
         * Default constructor
         */
@@ -84,6 +87,7 @@ public class ChartDciConfig
                invertValues = false;
                instance = ""; //$NON-NLS-1$
                column = ""; //$NON-NLS-1$
+      displayFormat = "%s"; //$NON-NLS-1$
        }
 
        /**
@@ -104,6 +108,7 @@ public class ChartDciConfig
                this.invertValues = src.invertValues;
                this.instance = src.instance;
                this.column = src.column;
+               this.displayFormat = src.displayFormat;
        }
 
        /**
@@ -124,6 +129,7 @@ public class ChartDciConfig
                invertValues = false;
                instance = ""; //$NON-NLS-1$
                column = ""; //$NON-NLS-1$
+      displayFormat = "%s"; //$NON-NLS-1$
        }
 
        /**
@@ -154,4 +160,14 @@ public class ChartDciConfig
        {
                return ((name != null) && !name.isEmpty()) ? name : ("[" + Long.toString(dciId) + "]"); //$NON-NLS-1$ //$NON-NLS-2$
        }
+       
+       /**
+        * Get display format
+        * 
+        * @return
+        */
+       public String getDisplayFormat()
+       {
+          return ((displayFormat != null) && !displayFormat.isEmpty()) ? displayFormat : "%s"; //$NON-NLS-1$
+       }
 }
index 5ac92e3..81aaca1 100644 (file)
@@ -466,15 +466,15 @@ public abstract class GaugeWidget extends GenericChart implements Gauge, PaintLi
       switch(dci.getObject().getDataType())
       {
          case DataCollectionItem.DT_INT:
-            return Integer.toString((int)dci.getValue());
+            return String.format(dci.getDisplayFormat(), (int)dci.getValue());
          case DataCollectionItem.DT_UINT:
          case DataCollectionItem.DT_INT64:
          case DataCollectionItem.DT_UINT64:
-            return Long.toString((long)dci.getValue());
+            return String.format(dci.getDisplayFormat(), (long)dci.getValue());
          case DataCollectionItem.DT_STRING:
-            return dci.getRawValue();
+            return String.format(dci.getDisplayFormat(), dci.getRawValue());
          default:
-            return Double.toString(dci.getValue());
+            return String.format(dci.getDisplayFormat(), dci.getValue());
       }
    }
 
index 1bf1f0f..667b1bc 100644 (file)
@@ -202,4 +202,14 @@ public class DataComparisonElement
       }
       return s;
        }
+       
+       /**
+        * Get display format
+        * 
+        * @return
+        */
+       public String getDisplayFormat()
+       {
+          return dci.getDisplayFormat();
+       }
 }
index 09f3a28..d72f611 100644 (file)
@@ -73,8 +73,8 @@ public class AvailabilityChartElement extends ElementWidget implements DisposeLi
                chart.setTranslucent(config.isTranslucent());
                chart.setRotation(225.0);
                
-               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().AvailabilityChartElement_Up, Messages.get().AvailabilityChartElement_Uptime), 100);
-               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().AvailabilityChartElement_Down, Messages.get().AvailabilityChartElement_Downtime), 0);
+               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().AvailabilityChartElement_Up, Messages.get().AvailabilityChartElement_Uptime, "%s"), 100);
+               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().AvailabilityChartElement_Down, Messages.get().AvailabilityChartElement_Downtime, "%s"), 0);
                chart.setPaletteEntry(0, new ChartColor(127, 154, 72));
                chart.setPaletteEntry(1, new ChartColor(158, 65, 62));
                chart.initializationComplete();
index 122440c..2fd3aab 100644 (file)
@@ -67,7 +67,7 @@ public class BarChartElement extends ComparisonChartElement
                int index = 0;
                for(ChartDciConfig dci : config.getDciList())
                {
-                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName()), 0.0);
+                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName(), dci.getDisplayFormat()), 0.0);
                        int color = dci.getColorAsInt();
                        if (color != -1)
                                chart.setPaletteEntry(index, new ChartColor(color));
index 00fb198..898ae4a 100644 (file)
@@ -85,7 +85,7 @@ public class GaugeElement extends ComparisonChartElement
                int index = 0;
                for(ChartDciConfig dci : config.getDciList())
                {
-                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName()), 0.0);
+                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName(), dci.getDisplayFormat()), 0.0);
                        int color = dci.getColorAsInt();
                        if (color != -1)
                                chart.setPaletteEntry(index, new ChartColor(color));
index 1b31049..94283b6 100644 (file)
@@ -99,7 +99,7 @@ public class LineChartElement extends ElementWidget
                int index = 0;
                for(ChartDciConfig dci : config.getDciList())
                {
-                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName()));
+                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName(), dci.getDisplayFormat()));
                        int color = dci.getColorAsInt();
                        if (color == -1)
                                color = ChartColor.getDefaultColor(index).getRGB();
index 796d2e1..d2f75ca 100644 (file)
@@ -69,7 +69,7 @@ public class ObjectStatusChartElement extends ComparisonChartElement
 
                for(int i = 0; i <= ObjectStatus.UNKNOWN.getValue(); i++)
                {
-                       chart.addParameter(new GraphItem(0, 0, 0, 0, StatusDisplayInfo.getStatusText(i), StatusDisplayInfo.getStatusText(i)), 0.0);
+                       chart.addParameter(new GraphItem(0, 0, 0, 0, StatusDisplayInfo.getStatusText(i), StatusDisplayInfo.getStatusText(i), "%s"), 0.0);
                        chart.setPaletteEntry(i, new ChartColor(StatusDisplayInfo.getStatusColor(i).getRGB()));
                }
                chart.initializationComplete();
index 6c5bf44..92874eb 100644 (file)
@@ -68,7 +68,7 @@ public class PieChartElement extends ComparisonChartElement
                int index = 0;
                for(ChartDciConfig dci : config.getDciList())
                {
-                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName()), 0.0);
+                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName(), dci.getDisplayFormat()), 0.0);
                        int color = dci.getColorAsInt();
                        if (color != -1)
                                chart.setPaletteEntry(index, new ChartColor(color));
index 26801dd..ec0b4fa 100644 (file)
@@ -179,7 +179,7 @@ public abstract class TableComparisonChartElement extends ElementWidget
                                if ((instanceMap.size() >= DataChart.MAX_CHART_ITEMS) ||
                                    ((value == 0) && config.isIgnoreZeroValues()))
                                        continue;
-                               index = chart.addParameter(new GraphItem(config.getNodeId(), config.getDciId(), 0, 0, Long.toString(config.getDciId()), instance), 0.0);
+                               index = chart.addParameter(new GraphItem(config.getNodeId(), config.getDciId(), 0, 0, Long.toString(config.getDciId()), instance, "%s"), 0.0);
                                instanceMap.put(instance, index);
                                rebuild = true;
                        }
index 5ea61bf..6d4ec0d 100644 (file)
@@ -68,7 +68,7 @@ public class TubeChartElement extends ComparisonChartElement
                int index = 0;
                for(ChartDciConfig dci : config.getDciList())
                {
-                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName()), 0.0);
+                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName(), dci.getDisplayFormat()), 0.0);
                        int color = dci.getColorAsInt();
                        if (color != -1)
                                chart.setPaletteEntry(index, new ChartColor(color));
index a779a16..540a534 100644 (file)
@@ -45,6 +45,7 @@ public class DataSourceEditDlg extends Dialog
        private ChartDciConfig dci;
        private DciSelector dciSelector;
        private LabeledText name;
+   private LabeledText displayFormat;
        private Button colorAuto;
        private Button colorCustom;
        private ColorSelector colorSelector;
@@ -108,6 +109,15 @@ public class DataSourceEditDlg extends Dialog
                gd.horizontalSpan = 2;
                name.setLayoutData(gd);
                
+      displayFormat = new LabeledText(dialogArea, SWT.NONE);
+      displayFormat.setLabel("Display format");
+      displayFormat.setText(dci.displayFormat);
+      gd = new GridData();
+      gd.horizontalAlignment = SWT.FILL;
+      gd.grabExcessHorizontalSpace = true;
+      gd.horizontalSpan = 2;
+      displayFormat.setLayoutData(gd);
+      
                if (dci.type == ChartDciConfig.TABLE)
                {
                        Group tableGroup = new Group(dialogArea, SWT.NONE);
@@ -230,6 +240,7 @@ public class DataSourceEditDlg extends Dialog
                dci.nodeId = dciSelector.getNodeId();
                dci.dciId = dciSelector.getDciId();
                dci.name = name.getText();
+               dci.displayFormat = displayFormat.getText();
                if (colorAuto.getSelection())
                {
                        dci.color = ChartDciConfig.UNSET_COLOR;
index 848f584..64fe6ff 100644 (file)
@@ -187,7 +187,7 @@ public class ObjectTooltip extends Figure
 
                for(int i = 0; i <= ObjectStatus.UNKNOWN.getValue(); i++)
                {
-                       chart.addParameter(new GraphItem(0, 0, 0, 0, StatusDisplayInfo.getStatusText(i), StatusDisplayInfo.getStatusText(i)),
+                       chart.addParameter(new GraphItem(0, 0, 0, 0, StatusDisplayInfo.getStatusText(i), StatusDisplayInfo.getStatusText(i), "%s"),
                                        objectCount[i]);
                        chart.setPaletteEntry(i, new ChartColor(StatusDisplayInfo.getStatusColor(i).getRGB()));
                }
index 186db46..f37e225 100644 (file)
@@ -137,8 +137,8 @@ public class AvailabilityChart extends OverviewPageElement
                chart.setLabelsVisible(false);
                chart.setRotation(225.0);
                
-               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().AvailabilityChart_Up, Messages.get().AvailabilityChart_Up), 100);
-               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().AvailabilityChart_Down, Messages.get().AvailabilityChart_Down), 0);
+               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().AvailabilityChart_Up, Messages.get().AvailabilityChart_Up, "%s"), 100); //$NON-NLS-1$
+               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().AvailabilityChart_Down, Messages.get().AvailabilityChart_Down, "%s"), 0); //$NON-NLS-1$
                chart.setPaletteEntry(0, new ChartColor(127, 154, 72));
                chart.setPaletteEntry(1, new ChartColor(158, 65, 62));
                chart.initializationComplete();
index b5945e1..56ba186 100644 (file)
@@ -180,7 +180,7 @@ public class TabbedObjectView extends ViewPart
                selectionProvider = new IntermediateSelectionProvider();
                getSite().setSelectionProvider(selectionProvider);
                
-               final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
+               final NXCSession session = ConsoleSharedData.getSession();
                sessionListener = new SessionListener() {
                        @Override
                        public void notificationHandler(SessionNotification n)
@@ -457,6 +457,7 @@ public class TabbedObjectView extends ViewPart
        @Override
        public void dispose()
        {
+          ConsoleSharedData.getSession().removeListener(sessionListener);
                CommandBridge.getInstance().unregisterCommand("TabbedObjectView/selectTab"); //$NON-NLS-1$
       CommandBridge.getInstance().unregisterCommand("TabbedObjectView/changeObject"); //$NON-NLS-1$
                ConsoleSharedData.getSession().removeListener(sessionListener);
index 84ff527..1421381 100644 (file)
@@ -97,7 +97,7 @@ public class PerfTabGraph extends DashboardComposite
       {
                   chart.setYAxisRange(settings.getMinYScaleValue(), settings.getMaxYScaleValue());
       }
-               chart.addParameter(new GraphItem(nodeId, dci.getId(), 0, 0, "", settings.getRuntimeName())); //$NON-NLS-1$
+               chart.addParameter(new GraphItem(nodeId, dci.getId(), 0, 0, "", settings.getRuntimeName(), "%s")); //$NON-NLS-1$
                
                addDisposeListener(new DisposeListener() {
          @Override
@@ -128,7 +128,7 @@ public class PerfTabGraph extends DashboardComposite
                        else
                                styles.set(items.size() - 1, style);
                        chart.setItemStyles(styles);
-                       chart.addParameter(new GraphItem(nodeId, dci.getId(), 0, 0, "", settings.getRuntimeName())); //$NON-NLS-1$
+                       chart.addParameter(new GraphItem(nodeId, dci.getId(), 0, 0, "", settings.getRuntimeName(), "%s")); //$NON-NLS-1$
                }
        }
        
index c8fb93a..3c50d5d 100644 (file)
@@ -157,7 +157,8 @@ public class DataComparisonView extends ViewPart
                                                                Integer.parseInt(subfields[2], 10), // source
                                                                Integer.parseInt(subfields[3], 10), // data type
                                                                URLDecoder.decode(subfields[4], "UTF-8"), // name //$NON-NLS-1$
-                                                               URLDecoder.decode(subfields[5], "UTF-8"))); // description //$NON-NLS-1$
+                                                               URLDecoder.decode(subfields[5], "UTF-8"), // description //$NON-NLS-1$
+                                                               "%s")); // format //$NON-NLS-1$
                                        }
                                        catch(NumberFormatException e)
                                        {
@@ -179,7 +180,8 @@ public class DataComparisonView extends ViewPart
                                                                URLDecoder.decode(subfields[4], "UTF-8"), // name //$NON-NLS-1$
                                                                URLDecoder.decode(subfields[5], "UTF-8"), //$NON-NLS-1$
                                                                URLDecoder.decode(subfields[6], "UTF-8"), //$NON-NLS-1$
-                                                               URLDecoder.decode(subfields[7], "UTF-8"))); // description //$NON-NLS-1$
+                                                               URLDecoder.decode(subfields[7], "UTF-8"), // description //$NON-NLS-1$
+                                                               "%s"));  // format //$NON-NLS-1$
                                        }
                                        catch(NumberFormatException e)
                                        {
index 540e17a..ad8fcd7 100644 (file)
@@ -327,7 +327,7 @@ public class HistoricalGraphView extends ViewPart implements GraphSettingsChange
       for(ChartDciConfig dci : config.getDciList())
       {
          final String name = config.isShowHostNames() ? (session.getObjectName(dci.nodeId) + " - " + dci.getName()) : dci.getName(); //$NON-NLS-1$
-         chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), name));
+         chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), name, dci.getDisplayFormat()));
          int color = dci.getColorAsInt();
          if (color == -1)
             color = ChartColor.getDefaultColor(index).getRGB();
index 74d57b7..b5c3fe0 100644 (file)
@@ -143,8 +143,8 @@ public class ServiceAvailability extends ViewPart
                chart.setLabelsVisible(true);
                chart.setRotation(225.0);
                
-               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().ServiceAvailability_Up, Messages.get().ServiceAvailability_Up), 100);
-               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().ServiceAvailability_Down, Messages.get().ServiceAvailability_Down), 0);
+               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().ServiceAvailability_Up, Messages.get().ServiceAvailability_Up, "%s"), 100);
+               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().ServiceAvailability_Down, Messages.get().ServiceAvailability_Down, "%s"), 0);
                chart.setPaletteEntry(0, new ChartColor(127, 154, 72));
                chart.setPaletteEntry(1, new ChartColor(158, 65, 62));
                chart.initializationComplete();
index 6d07523..0166f0e 100644 (file)
@@ -59,7 +59,7 @@ public class ChartDciConfig
        @Element(required=false)
        public boolean showThresholds;
 
-       @Element(required=false)
+   @Element(required=false)
    public boolean invertValues;
 
        @Element(required=false)
@@ -68,6 +68,9 @@ public class ChartDciConfig
        @Element(required=false)
        public String column;
        
+   @Element(required=false)
+   public String displayFormat;
+   
        /**
         * Default constructor
         */
@@ -84,6 +87,7 @@ public class ChartDciConfig
                invertValues = false;
                instance = ""; //$NON-NLS-1$
                column = ""; //$NON-NLS-1$
+      displayFormat = "%s"; //$NON-NLS-1$
        }
 
        /**
@@ -104,6 +108,7 @@ public class ChartDciConfig
                this.invertValues = src.invertValues;
                this.instance = src.instance;
                this.column = src.column;
+               this.displayFormat = src.displayFormat;
        }
 
        /**
@@ -124,6 +129,7 @@ public class ChartDciConfig
                invertValues = false;
                instance = ""; //$NON-NLS-1$
                column = ""; //$NON-NLS-1$
+      displayFormat = "%s"; //$NON-NLS-1$
        }
 
        /**
@@ -154,4 +160,14 @@ public class ChartDciConfig
        {
                return ((name != null) && !name.isEmpty()) ? name : ("[" + Long.toString(dciId) + "]"); //$NON-NLS-1$ //$NON-NLS-2$
        }
+       
+       /**
+        * Get display format
+        * 
+        * @return
+        */
+       public String getDisplayFormat()
+       {
+          return ((displayFormat != null) && !displayFormat.isEmpty()) ? displayFormat : "%s"; //$NON-NLS-1$
+       }
 }
index e1128ff..2c7f7f0 100644 (file)
@@ -462,15 +462,15 @@ public abstract class GaugeWidget extends GenericChart implements Gauge, PaintLi
       switch(dci.getObject().getDataType())
       {
          case DataCollectionItem.DT_INT:
-            return Integer.toString((int)dci.getValue());
+            return String.format(dci.getDisplayFormat(), (int)dci.getValue());
          case DataCollectionItem.DT_UINT:
          case DataCollectionItem.DT_INT64:
          case DataCollectionItem.DT_UINT64:
-            return Long.toString((long)dci.getValue());
+            return String.format(dci.getDisplayFormat(), (long)dci.getValue());
          case DataCollectionItem.DT_STRING:
-            return dci.getRawValue();
+            return String.format(dci.getDisplayFormat(), dci.getRawValue());
          default:
-            return Double.toString(dci.getValue());
+            return String.format(dci.getDisplayFormat(), dci.getValue());
       }
    }
 
index 1bf1f0f..667b1bc 100644 (file)
@@ -202,4 +202,14 @@ public class DataComparisonElement
       }
       return s;
        }
+       
+       /**
+        * Get display format
+        * 
+        * @return
+        */
+       public String getDisplayFormat()
+       {
+          return dci.getDisplayFormat();
+       }
 }
index 09f3a28..d72f611 100644 (file)
@@ -73,8 +73,8 @@ public class AvailabilityChartElement extends ElementWidget implements DisposeLi
                chart.setTranslucent(config.isTranslucent());
                chart.setRotation(225.0);
                
-               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().AvailabilityChartElement_Up, Messages.get().AvailabilityChartElement_Uptime), 100);
-               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().AvailabilityChartElement_Down, Messages.get().AvailabilityChartElement_Downtime), 0);
+               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().AvailabilityChartElement_Up, Messages.get().AvailabilityChartElement_Uptime, "%s"), 100);
+               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().AvailabilityChartElement_Down, Messages.get().AvailabilityChartElement_Downtime, "%s"), 0);
                chart.setPaletteEntry(0, new ChartColor(127, 154, 72));
                chart.setPaletteEntry(1, new ChartColor(158, 65, 62));
                chart.initializationComplete();
index 122440c..2fd3aab 100644 (file)
@@ -67,7 +67,7 @@ public class BarChartElement extends ComparisonChartElement
                int index = 0;
                for(ChartDciConfig dci : config.getDciList())
                {
-                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName()), 0.0);
+                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName(), dci.getDisplayFormat()), 0.0);
                        int color = dci.getColorAsInt();
                        if (color != -1)
                                chart.setPaletteEntry(index, new ChartColor(color));
index 00fb198..898ae4a 100644 (file)
@@ -85,7 +85,7 @@ public class GaugeElement extends ComparisonChartElement
                int index = 0;
                for(ChartDciConfig dci : config.getDciList())
                {
-                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName()), 0.0);
+                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName(), dci.getDisplayFormat()), 0.0);
                        int color = dci.getColorAsInt();
                        if (color != -1)
                                chart.setPaletteEntry(index, new ChartColor(color));
index 1b31049..94283b6 100644 (file)
@@ -99,7 +99,7 @@ public class LineChartElement extends ElementWidget
                int index = 0;
                for(ChartDciConfig dci : config.getDciList())
                {
-                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName()));
+                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName(), dci.getDisplayFormat()));
                        int color = dci.getColorAsInt();
                        if (color == -1)
                                color = ChartColor.getDefaultColor(index).getRGB();
index 796d2e1..d2f75ca 100644 (file)
@@ -69,7 +69,7 @@ public class ObjectStatusChartElement extends ComparisonChartElement
 
                for(int i = 0; i <= ObjectStatus.UNKNOWN.getValue(); i++)
                {
-                       chart.addParameter(new GraphItem(0, 0, 0, 0, StatusDisplayInfo.getStatusText(i), StatusDisplayInfo.getStatusText(i)), 0.0);
+                       chart.addParameter(new GraphItem(0, 0, 0, 0, StatusDisplayInfo.getStatusText(i), StatusDisplayInfo.getStatusText(i), "%s"), 0.0);
                        chart.setPaletteEntry(i, new ChartColor(StatusDisplayInfo.getStatusColor(i).getRGB()));
                }
                chart.initializationComplete();
index 6c5bf44..92874eb 100644 (file)
@@ -68,7 +68,7 @@ public class PieChartElement extends ComparisonChartElement
                int index = 0;
                for(ChartDciConfig dci : config.getDciList())
                {
-                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName()), 0.0);
+                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName(), dci.getDisplayFormat()), 0.0);
                        int color = dci.getColorAsInt();
                        if (color != -1)
                                chart.setPaletteEntry(index, new ChartColor(color));
index 72216af..ec0b4fa 100644 (file)
@@ -64,7 +64,7 @@ public abstract class TableComparisonChartElement extends ElementWidget
                super(parent, element, viewPart);
                session = (NXCSession)ConsoleSharedData.getSession();
 
-               setLayout(new FillLayout());    
+               setLayout(new FillLayout());
                
                addDisposeListener(new DisposeListener() {
          @Override
@@ -179,7 +179,7 @@ public abstract class TableComparisonChartElement extends ElementWidget
                                if ((instanceMap.size() >= DataChart.MAX_CHART_ITEMS) ||
                                    ((value == 0) && config.isIgnoreZeroValues()))
                                        continue;
-                               index = chart.addParameter(new GraphItem(config.getNodeId(), config.getDciId(), 0, 0, Long.toString(config.getDciId()), instance), 0.0);
+                               index = chart.addParameter(new GraphItem(config.getNodeId(), config.getDciId(), 0, 0, Long.toString(config.getDciId()), instance, "%s"), 0.0);
                                instanceMap.put(instance, index);
                                rebuild = true;
                        }
index 5ea61bf..6d4ec0d 100644 (file)
@@ -68,7 +68,7 @@ public class TubeChartElement extends ComparisonChartElement
                int index = 0;
                for(ChartDciConfig dci : config.getDciList())
                {
-                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName()), 0.0);
+                       chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), dci.getName(), dci.getDisplayFormat()), 0.0);
                        int color = dci.getColorAsInt();
                        if (color != -1)
                                chart.setPaletteEntry(index, new ChartColor(color));
index a779a16..540a534 100644 (file)
@@ -45,6 +45,7 @@ public class DataSourceEditDlg extends Dialog
        private ChartDciConfig dci;
        private DciSelector dciSelector;
        private LabeledText name;
+   private LabeledText displayFormat;
        private Button colorAuto;
        private Button colorCustom;
        private ColorSelector colorSelector;
@@ -108,6 +109,15 @@ public class DataSourceEditDlg extends Dialog
                gd.horizontalSpan = 2;
                name.setLayoutData(gd);
                
+      displayFormat = new LabeledText(dialogArea, SWT.NONE);
+      displayFormat.setLabel("Display format");
+      displayFormat.setText(dci.displayFormat);
+      gd = new GridData();
+      gd.horizontalAlignment = SWT.FILL;
+      gd.grabExcessHorizontalSpace = true;
+      gd.horizontalSpan = 2;
+      displayFormat.setLayoutData(gd);
+      
                if (dci.type == ChartDciConfig.TABLE)
                {
                        Group tableGroup = new Group(dialogArea, SWT.NONE);
@@ -230,6 +240,7 @@ public class DataSourceEditDlg extends Dialog
                dci.nodeId = dciSelector.getNodeId();
                dci.dciId = dciSelector.getDciId();
                dci.name = name.getText();
+               dci.displayFormat = displayFormat.getText();
                if (colorAuto.getSelection())
                {
                        dci.color = ChartDciConfig.UNSET_COLOR;
index 848f584..64fe6ff 100644 (file)
@@ -187,7 +187,7 @@ public class ObjectTooltip extends Figure
 
                for(int i = 0; i <= ObjectStatus.UNKNOWN.getValue(); i++)
                {
-                       chart.addParameter(new GraphItem(0, 0, 0, 0, StatusDisplayInfo.getStatusText(i), StatusDisplayInfo.getStatusText(i)),
+                       chart.addParameter(new GraphItem(0, 0, 0, 0, StatusDisplayInfo.getStatusText(i), StatusDisplayInfo.getStatusText(i), "%s"),
                                        objectCount[i]);
                        chart.setPaletteEntry(i, new ChartColor(StatusDisplayInfo.getStatusColor(i).getRGB()));
                }
index 186db46..f37e225 100644 (file)
@@ -137,8 +137,8 @@ public class AvailabilityChart extends OverviewPageElement
                chart.setLabelsVisible(false);
                chart.setRotation(225.0);
                
-               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().AvailabilityChart_Up, Messages.get().AvailabilityChart_Up), 100);
-               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().AvailabilityChart_Down, Messages.get().AvailabilityChart_Down), 0);
+               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().AvailabilityChart_Up, Messages.get().AvailabilityChart_Up, "%s"), 100); //$NON-NLS-1$
+               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().AvailabilityChart_Down, Messages.get().AvailabilityChart_Down, "%s"), 0); //$NON-NLS-1$
                chart.setPaletteEntry(0, new ChartColor(127, 154, 72));
                chart.setPaletteEntry(1, new ChartColor(158, 65, 62));
                chart.initializationComplete();
index bffe660..e4b5a7d 100644 (file)
@@ -179,7 +179,7 @@ public class TabbedObjectView extends ViewPart
                selectionProvider = new IntermediateSelectionProvider();
                getSite().setSelectionProvider(selectionProvider);
                
-               final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
+               final NXCSession session = ConsoleSharedData.getSession();
                sessionListener = new SessionListener() {
                        @Override
                        public void notificationHandler(SessionNotification n)
@@ -456,6 +456,7 @@ public class TabbedObjectView extends ViewPart
        @Override
        public void dispose()
        {
+          ConsoleSharedData.getSession().removeListener(sessionListener);
                CommandBridge.getInstance().unregisterCommand("TabbedObjectView/selectTab"); //$NON-NLS-1$
       CommandBridge.getInstance().unregisterCommand("TabbedObjectView/changeObject"); //$NON-NLS-1$
                ConsoleSharedData.getSession().removeListener(sessionListener);
index 84ff527..1421381 100644 (file)
@@ -97,7 +97,7 @@ public class PerfTabGraph extends DashboardComposite
       {
                   chart.setYAxisRange(settings.getMinYScaleValue(), settings.getMaxYScaleValue());
       }
-               chart.addParameter(new GraphItem(nodeId, dci.getId(), 0, 0, "", settings.getRuntimeName())); //$NON-NLS-1$
+               chart.addParameter(new GraphItem(nodeId, dci.getId(), 0, 0, "", settings.getRuntimeName(), "%s")); //$NON-NLS-1$
                
                addDisposeListener(new DisposeListener() {
          @Override
@@ -128,7 +128,7 @@ public class PerfTabGraph extends DashboardComposite
                        else
                                styles.set(items.size() - 1, style);
                        chart.setItemStyles(styles);
-                       chart.addParameter(new GraphItem(nodeId, dci.getId(), 0, 0, "", settings.getRuntimeName())); //$NON-NLS-1$
+                       chart.addParameter(new GraphItem(nodeId, dci.getId(), 0, 0, "", settings.getRuntimeName(), "%s")); //$NON-NLS-1$
                }
        }
        
index c095bde..3855700 100644 (file)
@@ -152,7 +152,8 @@ public class DataComparisonView extends ViewPart
                                                                Integer.parseInt(subfields[2], 10), // source
                                                                Integer.parseInt(subfields[3], 10), // data type
                                                                URLDecoder.decode(subfields[4], "UTF-8"), // name //$NON-NLS-1$
-                                                               URLDecoder.decode(subfields[5], "UTF-8"))); // description //$NON-NLS-1$
+                                                               URLDecoder.decode(subfields[5], "UTF-8"), // description //$NON-NLS-1$
+                                                               "%s")); // format //$NON-NLS-1$
                                        }
                                        catch(NumberFormatException e)
                                        {
@@ -174,7 +175,8 @@ public class DataComparisonView extends ViewPart
                                                                URLDecoder.decode(subfields[4], "UTF-8"), // name //$NON-NLS-1$
                                                                URLDecoder.decode(subfields[5], "UTF-8"), //$NON-NLS-1$
                                                                URLDecoder.decode(subfields[6], "UTF-8"), //$NON-NLS-1$
-                                                               URLDecoder.decode(subfields[7], "UTF-8"))); // description //$NON-NLS-1$
+                                                               URLDecoder.decode(subfields[7], "UTF-8"), // description //$NON-NLS-1$
+                                                               "%s"));  // format //$NON-NLS-1$
                                        }
                                        catch(NumberFormatException e)
                                        {
index 2e2b999..69ae649 100644 (file)
@@ -322,7 +322,7 @@ public class HistoricalGraphView extends ViewPart implements GraphSettingsChange
       for(ChartDciConfig dci : config.getDciList())
       {
          final String name = config.isShowHostNames() ? (session.getObjectName(dci.nodeId) + " - " + dci.getName()) : dci.getName(); //$NON-NLS-1$
-         chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), name));
+         chart.addParameter(new GraphItem(dci.nodeId, dci.dciId, 0, 0, Long.toString(dci.dciId), name, dci.getDisplayFormat()));
          int color = dci.getColorAsInt();
          if (color == -1)
             color = ChartColor.getDefaultColor(index).getRGB();
index 74d57b7..b5c3fe0 100644 (file)
@@ -143,8 +143,8 @@ public class ServiceAvailability extends ViewPart
                chart.setLabelsVisible(true);
                chart.setRotation(225.0);
                
-               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().ServiceAvailability_Up, Messages.get().ServiceAvailability_Up), 100);
-               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().ServiceAvailability_Down, Messages.get().ServiceAvailability_Down), 0);
+               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().ServiceAvailability_Up, Messages.get().ServiceAvailability_Up, "%s"), 100);
+               chart.addParameter(new GraphItem(0, 0, 0, 0, Messages.get().ServiceAvailability_Down, Messages.get().ServiceAvailability_Down, "%s"), 0);
                chart.setPaletteEntry(0, new ChartColor(127, 154, 72));
                chart.setPaletteEntry(1, new ChartColor(158, 65, 62));
                chart.initializationComplete();