Added template graph functionality. fixes #876
authorzev <zev@radensolutions.com>
Tue, 15 Dec 2015 15:00:38 +0000 (17:00 +0200)
committerzev <zev@radensolutions.com>
Wed, 2 Nov 2016 19:52:48 +0000 (21:52 +0200)
Menu filter is reworked. Object tool filter renamed as ObjectMenuFilter. Made option to add menu filter to any object. Filtering flags added to objectMenuFilter XML and removed from ObjectToll object.
NodeInfo class renamed to ObjectContext and now represent unified macro substitution class.

138 files changed:
ChangeLog
include/netxmsdb.h
include/nxtools.h
sql/objtools.in
src/java/client/netxms-client/src/main/java/org/netxms/client/NXCSession.java
src/java/client/netxms-client/src/main/java/org/netxms/client/ObjectMenuFilter.java [new file with mode: 0644]
src/java/client/netxms-client/src/main/java/org/netxms/client/datacollection/ChartConfig.java [moved from webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/ChartConfig.java with 52% similarity]
src/java/client/netxms-client/src/main/java/org/netxms/client/datacollection/ChartDciConfig.java [moved from webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/api/ChartDciConfig.java with 79% similarity]
src/java/client/netxms-client/src/main/java/org/netxms/client/datacollection/GraphSettings.java
src/java/client/netxms-client/src/main/java/org/netxms/client/datacollection/GraphSettingsChangeListener.java
src/java/client/netxms-client/src/main/java/org/netxms/client/objects/MenuFiltringObj.java [new file with mode: 0644]
src/java/client/netxms-client/src/main/java/org/netxms/client/objecttools/ObjectTool.java
src/java/client/netxms-client/src/main/java/org/netxms/client/objecttools/ObjectToolDetails.java
src/java/client/netxms-client/src/main/java/org/netxms/client/objecttools/ObjectToolFilter.java [deleted file]
src/java/client/netxms-client/src/main/java/org/netxms/client/xml/XmlDateConverter.java [moved from webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/XmlDateConverter.java with 97% similarity]
src/java/netxms-eclipse/Charts/src/org/netxms/ui/eclipse/charts/api/ChartDciConfig.java [deleted file]
src/java/netxms-eclipse/Core/src/org/netxms/ui/eclipse/console/Messages.java
src/java/netxms-eclipse/Core/src/org/netxms/ui/eclipse/console/messages.properties
src/java/netxms-eclipse/Core/src/org/netxms/ui/eclipse/console/messages_ar.properties
src/java/netxms-eclipse/Core/src/org/netxms/ui/eclipse/console/messages_cs.properties
src/java/netxms-eclipse/Core/src/org/netxms/ui/eclipse/console/messages_de.properties
src/java/netxms-eclipse/Core/src/org/netxms/ui/eclipse/console/messages_es.properties
src/java/netxms-eclipse/Core/src/org/netxms/ui/eclipse/console/messages_fr.properties
src/java/netxms-eclipse/Core/src/org/netxms/ui/eclipse/console/messages_pt.properties
src/java/netxms-eclipse/Core/src/org/netxms/ui/eclipse/console/messages_ru.properties
src/java/netxms-eclipse/Core/src/org/netxms/ui/eclipse/console/messages_zh_CN.properties
src/java/netxms-eclipse/Core/src/org/netxms/ui/eclipse/objects/ObjectContext.java [new file with mode: 0644]
src/java/netxms-eclipse/Dashboard/src/org/netxms/ui/eclipse/dashboard/propertypages/DataSources.java
src/java/netxms-eclipse/Dashboard/src/org/netxms/ui/eclipse/dashboard/propertypages/helpers/DciListLabelProvider.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/ComparisonChartElement.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/TubeChartElement.java
src/java/netxms-eclipse/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/internal/AbstractChartConfig.java
src/java/netxms-eclipse/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/internal/NetworkMapConfig.java
src/java/netxms-eclipse/DataCollection/src/org/netxms/ui/eclipse/datacollection/dialogs/DataSourceEditDlg.java
src/java/netxms-eclipse/ObjectTools/plugin.xml
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/Messages.java
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/ObjectToolsDynamicMenu.java
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/api/NodeInfo.java [deleted file]
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/api/ObjectToolExecutor.java
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages.properties
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages_ar.properties
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages_cs.properties
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages_de.properties
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages_es.properties
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages_fr.properties
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages_pt.properties
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages_ru.properties
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages_zh_CN.properties
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/propertypages/Filter.java
src/java/netxms-eclipse/ObjectView/src/org/netxms/ui/eclipse/objectview/objecttabs/elements/Commands.java
src/java/netxms-eclipse/PerfView/META-INF/MANIFEST.MF
src/java/netxms-eclipse/PerfView/plugin.xml
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/ChartConfig.java [deleted file]
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/GraphTemplatePropertyTester.java [new file with mode: 0644]
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/LoginListener.java [copied from src/java/client/netxms-client/src/main/java/org/netxms/client/datacollection/GraphSettingsChangeListener.java with 57% similarity]
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/PredefinedChartConfig.java [deleted file]
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/TemplateGraphDynamicMenu.java [new file with mode: 0644]
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/XmlDateConverter.java [deleted file]
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/actions/OpenGraphTemplateView.java [new file with mode: 0644]
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/api/GraphTemplateCache.java [new file with mode: 0644]
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/dialogs/SaveGraphDlg.java
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/propertypages/DataSources.java
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/propertypages/General.java
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/propertypages/PredefinedGraph.java
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/propertypages/TemplateDataSources.java [copied from src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/propertypages/DataSources.java with 86% similarity]
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/propertypages/helpers/DciListLabelProvider.java
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/propertypages/helpers/DciTemplateListLabelProvider.java [new file with mode: 0644]
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/views/HistoricalGraphView.java
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/views/PredefinedGraphTree.java
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/views/TemplateGraphView.java [new file with mode: 0644]
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/views/helpers/TemplateGraphLabelProvider.java [new file with mode: 0644]
src/java/netxms-eclipse/PolicyManager/src/org/netxms/ui/eclipse/policymanager/actions/UninstallPolicy.java
src/server/core/graph.cpp
src/server/tools/nxdbmgr/upgrade.cpp
webui/webapp/Core/src/org/netxms/ui/eclipse/console/Messages.java
webui/webapp/Core/src/org/netxms/ui/eclipse/console/messages.properties
webui/webapp/Core/src/org/netxms/ui/eclipse/console/messages_ar.properties
webui/webapp/Core/src/org/netxms/ui/eclipse/console/messages_cs.properties
webui/webapp/Core/src/org/netxms/ui/eclipse/console/messages_de.properties
webui/webapp/Core/src/org/netxms/ui/eclipse/console/messages_es.properties
webui/webapp/Core/src/org/netxms/ui/eclipse/console/messages_fr.properties
webui/webapp/Core/src/org/netxms/ui/eclipse/console/messages_pt.properties
webui/webapp/Core/src/org/netxms/ui/eclipse/console/messages_ru.properties
webui/webapp/Core/src/org/netxms/ui/eclipse/console/messages_zh_CN.properties
webui/webapp/Core/src/org/netxms/ui/eclipse/objects/ObjectContext.java [new file with mode: 0644]
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/propertypages/DataSources.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/propertypages/helpers/DciListLabelProvider.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/BarChartElement.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/ComparisonChartElement.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/TubeChartElement.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/internal/AbstractChartConfig.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/internal/TableValueConfig.java
webui/webapp/DataCollection/src/org/netxms/ui/eclipse/datacollection/dialogs/DataSourceEditDlg.java
webui/webapp/ObjectTools/plugin.xml
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/Messages.java
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/ObjectToolsDynamicMenu.java
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/api/NodeInfo.java [deleted file]
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/api/ObjectToolExecutor.java
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages.properties
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages_ar.properties
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages_cs.properties
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages_de.properties
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages_es.properties
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages_fr.properties
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages_pt.properties
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages_ru.properties
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages_zh_CN.properties
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/propertypages/Filter.java
webui/webapp/ObjectView/src/org/netxms/ui/eclipse/objectview/objecttabs/elements/Commands.java
webui/webapp/PerfView/META-INF/MANIFEST.MF
webui/webapp/PerfView/plugin.xml
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/GraphTemplatePropertyTester.java [new file with mode: 0644]
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/LoginListener.java [copied from src/java/client/netxms-client/src/main/java/org/netxms/client/datacollection/GraphSettingsChangeListener.java with 57% similarity]
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/PredefinedChartConfig.java [deleted file]
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/TemplateGraphDynamicMenu.java [new file with mode: 0644]
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/actions/OpenGraphTemplateView.java [new file with mode: 0644]
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/api/GraphTemplateCache.java [new file with mode: 0644]
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/dialogs/SaveGraphDlg.java
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/propertypages/DataSources.java
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/propertypages/General.java
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/propertypages/PredefinedGraph.java
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/propertypages/TemplateDataSources.java [copied from src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/propertypages/DataSources.java with 85% similarity]
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/propertypages/helpers/DciListLabelProvider.java
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/propertypages/helpers/DciTemplateListLabelProvider.java [new file with mode: 0644]
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/views/HistoricalGraphView.java
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/views/PredefinedGraphTree.java
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/views/TemplateGraphView.java [new file with mode: 0644]
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/views/helpers/TemplateGraphLabelProvider.java [new file with mode: 0644]
webui/webapp/PolicyManager/src/org/netxms/ui/eclipse/policymanager/actions/UninstallPolicy.java

index a3f712f..26a3de4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@
        - EPP rules can be configured to generate categorised alarms
        - Alarm categories can be created and configured in Alarm Category Configurator
        - By default view_all_alarms acl added to Everyone group
+- Added template graphs
 - New NXSL functions: mktime, GetSyslogRuleCheckCount, GetSyslogRuleMatchCount
 - New NXSL "Node" class attributes: isInMaintenanceMode, lastAgentCommTime
 - Operator "new" in NXSL which can be used to instantiate objects if object class supports it
@@ -14,7 +15,7 @@
 - SMS driver for SMSEagle gateway
 - Fixed FDB handling on Cisco switches
 - Added support for CHAP, MS-CHAPv1, and MS-CHAPv2 in RADIUS authentication
-- Fixed issues: #130, #953, #1043, #1097, #1192, #1206, #1285, #1312, #1318, #1320, #1326
+- Fixed issues: #130, #876, #953, #1043, #1097, #1192, #1206, #1285, #1312, #1318, #1320, #1326
 
 
 *
index ce3dc3d..15e92c2 100644 (file)
@@ -23,6 +23,6 @@
 #ifndef _netxmsdb_h
 #define _netxmsdb_h
 
-#define DB_FORMAT_VERSION   417
+#define DB_FORMAT_VERSION   418
 
 #endif
index a74bc43..b883316 100644 (file)
 #define TOOL_TYPE_SERVER_SCRIPT     8
 
 
-//
-// Object tool flags
-//
-
-#define TF_REQUIRES_SNMP            ((UINT32)0x00000001)
-#define TF_REQUIRES_AGENT           ((UINT32)0x00000002)
-#define TF_REQUIRES_OID_MATCH       ((UINT32)0x00000004)
-#define TF_ASK_CONFIRMATION         ((UINT32)0x00000008)
-#define TF_GENERATES_OUTPUT         ((UINT32)0x00000010)
-#define TF_DISABLED                 ((UINT32)0x00000020)
-#define TF_SHOW_IN_COMMANDS         ((UINT32)0x00000040)
-#define TF_SNMP_INDEXED_BY_VALUE    ((UINT32)0x00010000)
-
+/**
+ * Object tool flags
+ */
+#define TF_ASK_CONFIRMATION         ((UINT32)0x00000001)
+#define TF_GENERATES_OUTPUT         ((UINT32)0x00000002)
+#define TF_DISABLED                 ((UINT32)0x00000004)
+#define TF_SHOW_IN_COMMANDS         ((UINT32)0x00000008)
+#define TF_SNMP_INDEXED_BY_VALUE    ((UINT32)0x00000010)
 
-//
-// Column formats
-//
 
+/**
+ * Column formats
+ */
 #define CFMT_STRING     0
 #define CFMT_INTEGER    1
 #define CFMT_FLOAT      2
index f57b30c..f7471b4 100644 (file)
@@ -4,25 +4,25 @@
 */
 
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,flags,tool_filter,description,confirmation_text,command_name,command_short_name,icon)
-       VALUES (1,'7373a74b-e805-1a49-b52c-19410c1c347f','&Shutdown system',TOOL_TYPE_ACTION,'System.Shutdown',74,'','Shutdown target node via NetXMS agent',
+       VALUES (1,'7373a74b-e805-1a49-b52c-19410c1c347f','&Shutdown system',TOOL_TYPE_ACTION,'System.Shutdown',9,'<objectMenuFilter><flags>2</flags></objectMenuFilter>','Shutdown target node via NetXMS agent',
            'Host %n (%a) will be shut down. Are you sure?', 'Shutdown system','Shutdown',
            '89504e470d0a1a0a0000000d49484452000000100000001008060000001ff3ff610000000473424954080808087c086488000002bf49444154388d95933f689c7518c73fbf3f7779efaede995c137369d54123ba4843070b1204c10ed24db182939b90c1c1e2eee05871e8d0d2b98a8ba0c52ee2d0cb622acd99222dd1084d9a18cd3597f7bd6bdebbdffbfbe7701d82e8e0071ebec303dfe7e1e1fb883fea7542aba54c080dac153c261ed1a30540b51a8f359bd9c9e565afedd4943ab6b4f4d56873f38d5014ff6af04f95950aaad5fa7e7d7dfdbcee1d1c3cd95d59395b5a5c7c82ffc1fd4ee7acc9f349fd683090b1db15499ae2013b3f8f1c0e296f6f539c380140796707333747a856296d6ca081d1e1a138cc73a95d8cc28f468834459f3ecd7367cee0b38ccd7bf7787e711180dfaf5ee599850544a3c1760898d5556c51e06314d2c5288be150186b995d58404bc9eef5ebb87e86140229257690b17be33b4a4a3173ea14236b71d60a17a3901684b59652b34952ab31dcda6470f76794c9b0b6c0160665320eefae317ab04552ad529e9ec6c78003292dc861bf2f4408e369fb7b948a8cb2cd7085c115868998936887eb75514a617a3db66eb68505211d30f86b97dde536420844a341b17e8bf8db0a21ed12d23ddcda0ff46f7e4dac24482939b8b386b3060f4207206a457afb16be9f519f7f91f22baf52f9e91bfca7ef00829a4fb1af9fa3fed2cbf8419f6c75054a0a0fc800a025f151cafdcb17514af3ecc79f939fbf40d69c259d9ca1ffd687cc7d7411a5145b573e230e52d0120f68ffd8400ad8b97685c9934f31f9ee07b4de5e227ff37d8c311c4f12aad50afb5f5c62e7da65a400519204408f37108408de471e5cfa04fbe3b74c9d7b8ff2d32f1042805f7e25bdf1257fdeee103c8408528d53afa356c85a42b107d6812920bdd3c16f7448cae3d81a0b837cdc2b1c380f724203445d8ff161767cb66df1afe5380a0d3d05ca8d0f148110c02bb035b013109b1a17747b06baa20d3c84897dc93420feeb0b8f22203603dd19307f037f0665861328b32e0000000049454e44ae426082'
            );
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,flags,tool_filter,description,confirmation_text,command_name,command_short_name,icon)
-       VALUES (2,'b1e6192c-ff80-c842-a532-c60e40cb9fa4','&Restart system',TOOL_TYPE_ACTION,'System.Restart',74,'','Restart target node via NetXMS agent',
+       VALUES (2,'b1e6192c-ff80-c842-a532-c60e40cb9fa4','&Restart system',TOOL_TYPE_ACTION,'System.Restart',9,'<objectMenuFilter><flags>2</flags></objectMenuFilter>','Restart target node via NetXMS agent',
            'Host %n (%a) will be restarted. Are you sure?', 'Restart system','Restart',
            '89504e470d0a1a0a0000000d49484452000000100000001008060000001ff3ff610000000473424954080808087c0864880000029849444154388d85934d8b1c5514869f73eeadaaae6ea77bda388999882241fc5c0e09ae4484c4857b4177fa0b5474256edcfa075cbacbc23f6074a12332a0a2200a2189e8c468a23d93e99e9eaeaaae7beb1e1733f9902c7ce06c0ebc2f2fe7f0ca5fe311fdd71e77d93332922e08b749dcc5fe3bc9f72d5d1fcf861f7dd6f9f295353778ebdd0b71ff977374ad60f7888e1003bbb3379ceb930f4e7fbe7be5a7573da7f65697db17cf2ff2e757fe6e06a00e1141040aab59ebb5dc47076efbdb739cacc63edc9aabee4f64796248efb10dbcf738e750556268e97eff14b937ce6d1607126e55eae33c4956d5f4f72f21ae40d6cfe0bc4755c9f39cd4ccc0d27d7a695ae23c896fe7a645d5482c26340f0d19e639beb9811463c85788610a29c1d11d4284cc416a82848589861a49754bab390fac3f4ba69174f963ba7040d745249f4136033f63efd859769f78933a792c244265ea436d9a9a99e86895bc28b0e90fc03632bd88e463acb787580696f3e0fa299ade09e275a5feed2b09b5898f4ba35bdc40bb6b0034f5357cda4277bec354400d0b0d5d75406a5e42caa751d90596c425e22d00aa48771933a3c99e6230a8d1b241dcd1eb03a4a2c4563600f07615bc622da80510149aefa1b982ef3dc24d7d071b7afc71f0c781d58c83d107e48347d1f62a1a7f44f4d0c0130c4c4196d89fefa1273f215f7d9d4b379fa4dfdf22cb32bc7f99b5f533c45893edbc4fe75a8c0116c05b008b408434fd9a327f031b7d08c73670ee2c65595296259afe20fbe76de2fc9ba39e1cd6c6a7e4b0ae87d5200a4cbea4acce3318bd8865cfe1a283dd9fe9a65f901615a982d400c96360be9eda4ebbfdf0a6ec752f741ac11f1a89db02d9ba5bc8d483ae877587e2f0abdfac2b26b209488fa218b07627d7ff636dc524d52cff0513e53f37235ac3190000000049454e44ae426082'
            );
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,flags,tool_filter,description,confirmation_text,command_name,command_short_name,icon)
-       VALUES (3,'74cc4d38-9239-7b4f-9905-7f7adc4d489a','&Wakeup node',TOOL_TYPE_INTERNAL,'wakeup',64,'','Wakeup node using Wake-On-LAN magic packet','','Wakeup node using Wake-On-LAN','Wakeup',
+       VALUES (3,'74cc4d38-9239-7b4f-9905-7f7adc4d489a','&Wakeup node',TOOL_TYPE_INTERNAL,'wakeup',8,'','Wakeup node using Wake-On-LAN magic packet','','Wakeup node using Wake-On-LAN','Wakeup',
            '89504e470d0a1a0a0000000d49484452000000100000001008060000001ff3ff610000000473424954080808087c086488000000097048597300000dd700000dd70142289b780000001974455874536f667477617265007777772e696e6b73636170652e6f72679bee3c1a0000023649444154388d8d924f48545114c67ff7bd37ff7cf9071bc70a4d47271ca15c848d448185b40a89204890362d8568eb2270d7a2762d5cb7711504d1ae10c195218895a488528e4e06a653d338de7bdfbcf75ac84ce38c901f9ccdb9e7fbce39f77c627ce6872df6dd71f01f781e1d9c00866003215efaf99de7d6763afb1078721262053a800908ed5a5aa9b1e3bb0802a600c0717d3cdf3fae6cccd24a25abb302a80b990c265a009859d941299763249296d6b2a6732468d25a1f24156f00e0cbd62e9b5a71a0dd9a490cad14a570b4266c780cf546797cab1b1317139747435ddcec69266c78385a53c9b1b45265b548d022d51563f45a9c778b69ce35850058de928c0cb4933fd04c7ffece812e9639e5158480865098ebc9181fbfeef07a6e9dc68805c0af8243f45480ab174e33bb9426e7484a9b942710020c3b40e24c236f3facb1bd9b634d3a00d8e100ab992cb7af7421bc225aa9b280a195a414524972054d5f679488e5a394442949d8f4b8d4d14caea09115f55a490cad155a2b9452ecfdcef37e619ddef6287706ba89c76ce2319be1fe4e926d51663e6d90cdeda3d42147ebaa4fcc161da6a61739df52cfe88d8b0ca712f8be871d0e31bb94666a7a916c2e8feb7aff3cd33ef2f4c8612dd3a0a5d1a6bfa78d544f1bbeef33bf9a617e65939fb902c50a328068bd3bb10c1c71a3210401cb24143cbc82d2459c62ad8980154b2b3909bca87e91c09fea642d26ad67f7fb32afe6bebd5958dd1c2c48ddf45f8a10d87591bdcb89b3b3f7063a337f01f30f1c1c580292640000000049454e44ae426082'
            );
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,flags,tool_filter,description,confirmation_text)
-       VALUES (4,'1223b7fe-2098-2a4d-8618-67bdb66a907e','Restart &agent',TOOL_TYPE_ACTION,'Agent.Restart',10,'','Restart NetXMS agent on target node',
+       VALUES (4,'1223b7fe-2098-2a4d-8618-67bdb66a907e','Restart &agent',TOOL_TYPE_ACTION,'Agent.Restart',1,'<objectMenuFilter><flags>2</flags></objectMenuFilter>','Restart NetXMS agent on target node',
            'NetXMS agent on host %n (%a) will be restarted. Are you sure?');
 
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,flags,tool_filter,description,confirmation_text)
-       VALUES (5,'adc5168f-7e0b-f449-a876-cc4720d1a29a','&Info->&Switch forwarding database (FDB)',TOOL_TYPE_TABLE_SNMP,'Forwarding database',1,'','Show switch forwarding database','');
+       VALUES (5,'adc5168f-7e0b-f449-a876-cc4720d1a29a','&Info->&Switch forwarding database (FDB)',TOOL_TYPE_TABLE_SNMP,'Forwarding database',0,'<objectMenuFilter><flags>1</flags></objectMenuFilter>','Show switch forwarding database','');
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
        VALUES (5,0,'MAC Address','.1.3.6.1.2.1.17.4.3.1.1',CFMT_MAC_ADDR,0);
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
@@ -34,7 +34,7 @@ INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,flags,tool_
        VALUES (7,'a4d9c827-916b-2640-b6e2-d5bf512c39d7','&Connect->Open &web browser (HTTPS)',TOOL_TYPE_URL,'https://%a',0,'','Open embedded web browser to node using HTTPS','');
 
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,flags,tool_filter,description,confirmation_text)
-       VALUES (8,'ded1f018-9659-c548-8adb-4af5c759c7ba','&Info->&Agent->&Subagent list',TOOL_TYPE_TABLE_AGENT,'Subagent List\7fAgent.SubAgentList\7f^(.*) (.*) (.*) (.*)',2,'','Show list of loaded subagents','');
+       VALUES (8,'ded1f018-9659-c548-8adb-4af5c759c7ba','&Info->&Agent->&Subagent list',TOOL_TYPE_TABLE_AGENT,'Subagent List\7fAgent.SubAgentList\7f^(.*) (.*) (.*) (.*)',0,'<objectMenuFilter><flags>2</flags></objectMenuFilter>','Show list of loaded subagents','');
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
        VALUES (8,0,'Name','',CFMT_STRING,1);
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
@@ -45,17 +45,17 @@ INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_
        VALUES (8,3,'Module handle','',CFMT_STRING,3);
 
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,flags,tool_filter,description,confirmation_text)
-       VALUES (9,'cf606f35-ea88-2446-bdf5-366799e615c9','&Info->&Agent->Supported &parameters',TOOL_TYPE_TABLE_AGENT,'Supported parameters\7fAgent.SupportedParameters\7f^(.*)',2,'','Show list of parameters supported by agent','');
+       VALUES (9,'cf606f35-ea88-2446-bdf5-366799e615c9','&Info->&Agent->Supported &parameters',TOOL_TYPE_TABLE_AGENT,'Supported parameters\7fAgent.SupportedParameters\7f^(.*)',0,'<objectMenuFilter><flags>2</flags></objectMenuFilter>','Show list of parameters supported by agent','');
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
        VALUES (9,0,'Parameter','',CFMT_STRING,1);
 
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,flags,tool_filter,description,confirmation_text)
-       VALUES (10,'84c8b119-fda0-5d4f-b480-75229315ce20','&Info->&Agent->Supported &lists',TOOL_TYPE_TABLE_AGENT,'Supported lists\7fAgent.SupportedLists\7f^(.*)',2,'','Show list of lists supported by agent','');
+       VALUES (10,'84c8b119-fda0-5d4f-b480-75229315ce20','&Info->&Agent->Supported &lists',TOOL_TYPE_TABLE_AGENT,'Supported lists\7fAgent.SupportedLists\7f^(.*)',0,'<objectMenuFilter><flags>2</flags></objectMenuFilter>','Show list of lists supported by agent','');
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
        VALUES (10,0,'Parameter','',CFMT_STRING,1);
 
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,flags,tool_filter,description,confirmation_text)
-       VALUES (11,'d6ea7dcf-c342-b04e-a91b-566beda73c4d','&Info->&Agent->Supported &actions',TOOL_TYPE_TABLE_AGENT,'Supported actions\7fAgent.ActionList\7f^(.*) (.*) "(.*)".*',2,'','Show list of actions supported by agent','');
+       VALUES (11,'d6ea7dcf-c342-b04e-a91b-566beda73c4d','&Info->&Agent->Supported &actions',TOOL_TYPE_TABLE_AGENT,'Supported actions\7fAgent.ActionList\7f^(.*) (.*) "(.*)".*',0,'<objectMenuFilter><flags>2</flags></objectMenuFilter>','Show list of actions supported by agent','');
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
        VALUES (11,0,'Name','',CFMT_STRING,1);
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
@@ -64,7 +64,7 @@ INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_
        VALUES (11,2,'Data','',CFMT_STRING,3);
 
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,flags,tool_filter,description,confirmation_text)
-       VALUES (12,'780a1b84-e600-a748-89af-c5e02e5b8cfc','&Info->&Agent->Configured &ICMP targets',TOOL_TYPE_TABLE_AGENT,'Configured ICMP targets\7fICMP.TargetList\7f^(.*) (.*) (.*) (.*) (.*)',2,'','Show list of actions supported by agent','');
+       VALUES (12,'780a1b84-e600-a748-89af-c5e02e5b8cfc','&Info->&Agent->Configured &ICMP targets',TOOL_TYPE_TABLE_AGENT,'Configured ICMP targets\7fICMP.TargetList\7f^(.*) (.*) (.*) (.*) (.*)',0,'<objectMenuFilter><flags>2</flags></objectMenuFilter>','Show list of actions supported by agent','');
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
        VALUES (12,0,'IP Address','',CFMT_STRING,1);
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
@@ -78,14 +78,14 @@ INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_
 
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,flags,tool_filter,description,confirmation_text)
        VALUES (13,'7afea6f9-ccd2-1d45-9e8c-3aafe14cb565','&Info->&Process list',TOOL_TYPE_TABLE_AGENT,
-           'Process List\7fSystem.ProcessList\7f^([0-9]+) (.*)',2,'','Show list of currently running processes','');
+           'Process List\7fSystem.ProcessList\7f^([0-9]+) (.*)',0,'<objectMenuFilter><flags>2</flags></objectMenuFilter>','Show list of currently running processes','');
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
        VALUES (13,0,'PID','',CFMT_STRING,1);
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
        VALUES (13,1,'Name','',CFMT_STRING,2);
 
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,flags,tool_filter,description,confirmation_text)
-       VALUES (14,'80f3c244-87b1-954e-99e1-3c94062a2cc7','&Info->Topology table (Nortel)',TOOL_TYPE_TABLE_SNMP,'Topology table',1,'','Show topology table (Nortel protocol)','');
+       VALUES (14,'80f3c244-87b1-954e-99e1-3c94062a2cc7','&Info->Topology table (Nortel)',TOOL_TYPE_TABLE_SNMP,'Topology table',0,'<objectMenuFilter><flags>1</flags></objectMenuFilter>','Show topology table (Nortel protocol)','');
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
        VALUES (14,0,'Peer IP','.1.3.6.1.4.1.45.1.6.13.2.1.1.3',CFMT_IP_ADDR,0);
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
@@ -96,7 +96,7 @@ INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_
        VALUES (14,3,'Port','.1.3.6.1.4.1.45.1.6.13.2.1.1.2',CFMT_INTEGER,0);
 
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,flags,tool_filter,description,confirmation_text)
-       VALUES (15,'e7f69f34-7956-674b-aa5f-aa6d07e3bba3','&Info->Topology table (CDP)',TOOL_TYPE_TABLE_SNMP,'Topology table',1,'','Show topology table (CDP)','');
+       VALUES (15,'e7f69f34-7956-674b-aa5f-aa6d07e3bba3','&Info->Topology table (CDP)',TOOL_TYPE_TABLE_SNMP,'Topology table',0,'<objectMenuFilter><flags>1</flags></objectMenuFilter>','Show topology table (CDP)','');
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
        VALUES (15,0,'Device ID','.1.3.6.1.4.1.9.9.23.1.2.1.1.6',CFMT_STRING,0);
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
@@ -110,7 +110,7 @@ INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_
 
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,flags,tool_filter,description,confirmation_text)
        VALUES (16,'87370de4-e760-904a-9f9d-dfdf15f4dd9e','&Info->Active &user sessions',TOOL_TYPE_TABLE_AGENT,
-           'Active User Sessions\7fSystem.ActiveUserSessions\7f^"(.*)" "(.*)" "(.*)"',2,'','Show list of active user sessions','');
+           'Active User Sessions\7fSystem.ActiveUserSessions\7f^"(.*)" "(.*)" "(.*)"',0,'<objectMenuFilter><flags>2</flags></objectMenuFilter>','Show list of active user sessions','');
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
        VALUES (16,0,'User','',CFMT_STRING,1);
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
@@ -119,7 +119,7 @@ INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_
        VALUES (16,2,'From','',CFMT_STRING,3);
 
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,flags,tool_filter,description,confirmation_text)
-       VALUES (17,'81a0f545-3dbf-6c47-acfc-43ae88465360','&Info->AR&P cache (SNMP)',TOOL_TYPE_TABLE_SNMP,'ARP Cache',1,'','Show ARP cache','');
+       VALUES (17,'81a0f545-3dbf-6c47-acfc-43ae88465360','&Info->AR&P cache (SNMP)',TOOL_TYPE_TABLE_SNMP,'ARP Cache',0,'<objectMenuFilter><flags>1</flags></objectMenuFilter>','Show ARP cache','');
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
        VALUES (17,0,'IP Address','.1.3.6.1.2.1.4.22.1.3',CFMT_IP_ADDR,0);
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
@@ -129,7 +129,7 @@ INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_
 
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,flags,tool_filter,description,confirmation_text)
        VALUES (18,'86b9772e-b939-1849-bc5b-d2c1a170ec96','&Info->AR&P cache (Agent)',TOOL_TYPE_TABLE_AGENT,
-           'ARP Cache\7fNet.ArpCache\7f(.*) (.*) (.*)',2,'','Show ARP cache','');
+           'ARP Cache\7fNet.ArpCache\7f(.*) (.*) (.*)',0,'<objectMenuFilter><flags>1</flags></objectMenuFilter>','Show ARP cache','');
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
        VALUES (18,0,'IP Address','.1.3.6.1.2.1.4.22.1.3',CFMT_STRING,2);
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
@@ -138,7 +138,7 @@ INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_
        VALUES (18,2,'Interface','.1.3.6.1.2.1.4.22.1.1',CFMT_IFINDEX,3);
 
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,flags,tool_filter,description,confirmation_text)
-       VALUES (19,'565bb6e4-cee3-4741-82d6-0f379c742c55','&Info->&Routing table (SNMP)',TOOL_TYPE_TABLE_SNMP,'Routing Table',1,'','Show IP routing table','');
+       VALUES (19,'565bb6e4-cee3-4741-82d6-0f379c742c55','&Info->&Routing table (SNMP)',TOOL_TYPE_TABLE_SNMP,'Routing Table',0,'<objectMenuFilter><flags>1</flags></objectMenuFilter>','Show IP routing table','');
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
        VALUES (19,0,'Destination','.1.3.6.1.2.1.4.21.1.1',CFMT_IP_ADDR,0);
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
@@ -151,7 +151,7 @@ INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_
        VALUES (19,4,'Interface','.1.3.6.1.2.1.4.21.1.2',CFMT_IFINDEX,0);
 
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,flags,tool_filter,description,confirmation_text)
-       VALUES (20,'83eeea21-dd61-f84e-811d-3861ccee08ed','&Info->Topology table (LLDP)',TOOL_TYPE_TABLE_SNMP,'Topology Table',1,'','Show topology table (LLDP)','');
+       VALUES (20,'83eeea21-dd61-f84e-811d-3861ccee08ed','&Info->Topology table (LLDP)',TOOL_TYPE_TABLE_SNMP,'Topology Table',0,'<objectMenuFilter><flags>1</flags></objectMenuFilter>','Show topology table (LLDP)','');
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
        VALUES (20,0,'Chassis ID','.1.0.8802.1.1.2.1.4.1.1.5',CFMT_STRING,0);
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
@@ -166,7 +166,7 @@ INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_
        VALUES (20,5,'Remote port description','.1.0.8802.1.1.2.1.4.1.1.8',CFMT_STRING,0);
 
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,description,flags,tool_filter)
- VALUES (21,'9b011dcc-a62a-c945-87c9-d12ea7b034ac','QtechOLTsONT',2,'','Show ONTs on PON ports',5,'<objectToolFilter><toolOS></toolOS><toolTemplate></toolTemplate><snmpOid>.1.3.6.1.4.1.27514.1.10.4.1</snmpOid></objectToolFilter>');
+ VALUES (21,'9b011dcc-a62a-c945-87c9-d12ea7b034ac','QtechOLTsONT',2,'','Show ONTs on PON ports',0,'<objectMenuFilter><toolOS></toolOS><toolTemplate></toolTemplate><snmpOid>.1.3.6.1.4.1.27514.1.10.4.1</snmpOid><flags>5</flags></objectMenuFilter>');
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
  VALUES (21,0,'Num','.1.3.6.1.4.1.27514.1.11.4.1.1.1',1,1);
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
@@ -185,9 +185,9 @@ INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_
  VALUES (21,7,'Temp','.1.3.6.1.4.1.27514.1.11.4.1.1.24',0,1);
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
  VALUES (21,8,'Status','.1.3.6.1.4.1.27514.1.11.4.1.1.3',0,1);
+
 INSERT INTO object_tools (tool_id,guid,tool_name,tool_type,tool_data,description,flags,tool_filter)
- VALUES (22,'4bbcd005-18ab-4b4d-ad57-d978ced60d4f','QtechOLTsSFP',2,'','Show GPON SFP modules in PON ports',5,'<objectToolFilter><toolOS></toolOS><toolTemplate></toolTemplate><snmpOid>.1.3.6.1.4.1.27514.1.10.4.1</snmpOid></objectToolFilter>');
+ VALUES (22,'4bbcd005-18ab-4b4d-ad57-d978ced60d4f','QtechOLTsSFP',2,'','Show GPON SFP modules in PON ports',0,'<objectMenuFilter><toolOS></toolOS><toolTemplate></toolTemplate><snmpOid>.1.3.6.1.4.1.27514.1.10.4.1</snmpOid><flags>5</flags></objectMenuFilter>');
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
  VALUES (22,0,'Num','.1.3.6.1.4.1.27514.1.11.3.1.1.1.0',5,1);
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
@@ -202,7 +202,7 @@ INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_
  VALUES (22,5,'Temp','.1.3.6.1.4.1.27514.1.11.3.1.1.19.0',0,1);
 INSERT INTO object_tools_table_columns (tool_id,col_number,col_name,col_oid,col_format,col_substr)
  VALUES (22,6,'ManufacturedDate','.1.3.6.1.4.1.27514.1.11.3.1.1.17.0',0,1);
+
 INSERT INTO object_tools_acl (tool_id,user_id) VALUES (1,-2147483648);
 INSERT INTO object_tools_acl (tool_id,user_id) VALUES (2,-2147483648);
 INSERT INTO object_tools_acl (tool_id,user_id) VALUES (3,-2147483648);
index be2ef6c..f457b10 100644 (file)
@@ -525,7 +525,7 @@ public class NXCSession
                      processImageLibraryUpdate(msg);
                      break;
                   case NXCPCodes.CMD_GRAPH_UPDATE:
-                     GraphSettings graph = new GraphSettings(msg, NXCPCodes.VID_GRAPH_LIST_BASE);
+                     GraphSettings graph = GraphSettings.createGraphSettings(msg, NXCPCodes.VID_GRAPH_LIST_BASE);
                      sendNotification(new SessionNotification(SessionNotification.PREDEFINED_GRAPHS_CHANGED, graph.getId(), graph));
                      break;
                   case NXCPCodes.CMD_ALARM_CATEGORY_UPDATE:
@@ -6958,10 +6958,12 @@ public class NXCSession
       return file.getFile();
    }
 
+
    /**
-    * Get list of predefined graphs.
+    * Get list of predefined graphs or graph templates
     *
-    * @return list of predefined graphs
+    * @param graphTemplate defines if non template or template graph list should re requested 
+    * @return message with predefined graphs or with template graphs
     * @throws IOException  if socket or file I/O error occurs
     * @throws NXCException if NetXMS server returns an error or operation was timed out
     */
@@ -6976,7 +6978,7 @@ public class NXCSession
       long varId = NXCPCodes.VID_GRAPH_LIST_BASE;
       for(int i = 0; i < count; i++)
       {
-         list.add(new GraphSettings(response, varId));
+         list.add(GraphSettings.createGraphSettings(response, varId));
          varId += 10;
       }
       return list;
@@ -7004,18 +7006,7 @@ public class NXCSession
    public long saveGraph(GraphSettings graph, boolean overwrite) throws IOException, NXCException
    {
       final NXCPMessage msg = newMessage(NXCPCodes.CMD_SAVE_GRAPH);
-      msg.setFieldInt32(NXCPCodes.VID_GRAPH_ID, (int) graph.getId());
-      msg.setField(NXCPCodes.VID_NAME, graph.getName());
-      msg.setFieldInt32(NXCPCodes.VID_FLAGS, graph.getFlags());
-      msg.setField(NXCPCodes.VID_FILTER, graph.getFilters());
-      msg.setField(NXCPCodes.VID_GRAPH_CONFIG, graph.getConfig());
-      msg.setFieldInt32(NXCPCodes.VID_ACL_SIZE, graph.getAccessList().size());
-      long varId = NXCPCodes.VID_GRAPH_ACL_BASE;
-      for(AccessListElement e : graph.getAccessList())
-      {
-         msg.setFieldInt32(varId++, (int) e.getUserId());
-         msg.setFieldInt32(varId++, e.getAccessRights());
-      }      
+      graph.fillMessage(msg);
       msg.setFieldInt16(NXCPCodes.VID_OVERVRITE, overwrite ? 1 : 0);
       sendMessage(msg);
       final NXCPMessage response = waitForRCC(msg.getMessageId());
diff --git a/src/java/client/netxms-client/src/main/java/org/netxms/client/ObjectMenuFilter.java b/src/java/client/netxms-client/src/main/java/org/netxms/client/ObjectMenuFilter.java
new file mode 100644 (file)
index 0000000..426656d
--- /dev/null
@@ -0,0 +1,151 @@
+package org.netxms.client;
+
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.Set;
+import java.util.regex.Pattern;
+import org.netxms.base.Glob;
+import org.netxms.client.objects.AbstractNode;
+import org.netxms.client.objects.AbstractObject;
+import org.simpleframework.xml.Element;
+import org.simpleframework.xml.Root;
+import org.simpleframework.xml.Serializer;
+import org.simpleframework.xml.core.Persister;
+
+/**
+ * Class created to store 
+ */
+@Root(name="objectMenuFilter")
+public class ObjectMenuFilter
+{
+   @Element(required=false, name="toolOS")
+   public String toolNodeOS;
+
+   @Element(required=false)
+   public String toolWorkstationOS;
+   
+   @Element(required=false)
+   public String toolTemplate;
+   
+   @Element(required=false)
+   public String snmpOid;
+
+   @Element(required=false)
+   public int flags;
+
+   public static final int REQUIRES_SNMP                    = 0x00000001;
+   public static final int REQUIRES_AGENT                   = 0x00000002;
+   public static final int REQUIRES_OID_MATCH               = 0x00000004;
+   public static final int REQUIRES_NODE_OS_MATCH           = 0x00000008;
+   public static final int REQUIRES_TEMPLATE_MATCH          = 0x00000010;
+   public static final int REQUIRES_WORKSTATION_OS_MATCH    = 0x00000020;
+   
+   /**
+    * Create ObjectToolFilter object from XML document
+    * 
+    * @param xml XML document
+    * @return deserialized object
+    * @throws Exception if the object cannot be fully deserialized
+    */
+   public static ObjectMenuFilter createFromXml(final String xml) throws Exception
+   {
+      Serializer serializer = new Persister();
+      return serializer.read(ObjectMenuFilter.class, xml);
+   }
+   
+   /**
+    * Create XML from configuration.
+    * 
+    * @return XML document
+    * @throws Exception if the schema for the object is not valid
+    */
+   public String createXml() throws Exception
+   {
+      Serializer serializer = new Persister();
+      Writer writer = new StringWriter();
+      serializer.write(this, writer);
+      return writer.toString();
+   }
+   
+   public ObjectMenuFilter()
+   {
+      toolNodeOS = "";
+      toolWorkstationOS = "";
+      toolTemplate = "";
+      snmpOid = "";
+   }
+   
+   /**
+    * Check if tool is applicable for given node.
+    * 
+    * @param node AbstractNode object
+    * @return true if tool is applicable for given node
+    */
+   public boolean isApplicableForNode(AbstractNode node)
+   {
+      if (((flags & REQUIRES_SNMP) != 0) &&
+          ((node.getFlags() & AbstractNode.NF_IS_SNMP) == 0))
+         return false;  // Node does not support SNMP
+      
+      if (((flags & REQUIRES_AGENT) != 0) &&
+             ((node.getFlags() & AbstractNode.NF_IS_NATIVE_AGENT) == 0))
+            return false;  // Node does not have NetXMS agent
+      
+      if ((flags & REQUIRES_OID_MATCH) != 0)
+      {
+         if (!Glob.matchIgnoreCase(snmpOid, node.getSnmpOID()))
+            return false;  // OID does not match
+      }
+      
+      if ((flags & REQUIRES_NODE_OS_MATCH) != 0)
+      {
+             boolean match = false;
+             String[] substrings = toolNodeOS.split(",");
+             for(int i = 0; i < substrings.length; i++)
+             {;
+                if (Pattern.matches(substrings[i], node.getPlatformName()))
+                {
+                   match = true;
+                }
+             }
+             if (!match)
+                return false;  //Not correct type of OS
+      }
+          
+          if ((flags & REQUIRES_WORKSTATION_OS_MATCH) != 0)
+      {
+         boolean match = false;
+         String[] substrings = toolWorkstationOS.split(",");
+         for(int i = 0; i < substrings.length; i++)
+         {;
+            if (Pattern.matches(substrings[i], System.getProperty("os.name")))
+            {
+               match = true;
+            }
+         }
+         if (!match)
+            return false;  //Not correct type of OS
+      }
+           
+          if ((flags & REQUIRES_TEMPLATE_MATCH) != 0)
+      {
+         boolean match = false;
+         String[] substrings = toolTemplate.split(",");
+         Set<AbstractObject> parents = node.getAllParents(AbstractObject.OBJECT_TEMPLATE);
+         for(AbstractObject parent : parents)
+         {
+            for(int i = 0; i < substrings.length; i++)
+            {
+               if (Pattern.matches(substrings[i], parent.getObjectName()))
+               {
+                  match = true;
+               }
+            }
+         }
+         if (!match)
+            return false;  // Does not belong to those templates
+      }
+      
+      return true;
+   }
+}
  * 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.perfview;
+package org.netxms.client.datacollection;
 
 import java.io.StringWriter;
 import java.io.Writer;
 import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
 import org.netxms.client.TimePeriod;
-import org.netxms.client.datacollection.GraphItemStyle;
-import org.netxms.client.datacollection.GraphSettings;
-import org.netxms.ui.eclipse.charts.api.ChartDciConfig;
+import org.netxms.client.xml.XmlDateConverter;
 import org.simpleframework.xml.Element;
 import org.simpleframework.xml.ElementArray;
 import org.simpleframework.xml.Root;
@@ -40,75 +40,77 @@ import org.simpleframework.xml.core.Persister;
 public class ChartConfig
 {
        @ElementArray(required = true)
-       private ChartDciConfig[] dciList = new ChartDciConfig[0];
+       protected ChartDciConfig[] dciList = new ChartDciConfig[0];
        
        @Element(required = false)
-       private String title = ""; //$NON-NLS-1$
+       protected String title = ""; //$NON-NLS-1$
        
        @Element(required = false)
-       private int legendPosition = GraphSettings.POSITION_BOTTOM;
+       protected int legendPosition = GraphSettings.POSITION_BOTTOM;
        
        @Element(required = false)
-       private boolean showLegend = true;
+       protected boolean showLegend = true;
        
        @Element(required = false)
-       private boolean extendedLegend = true;
+       protected boolean extendedLegend = true;
        
        @Element(required = false)
-       private boolean showTitle = false;
+       protected boolean showTitle = false;
 
        @Element(required = false)
-       private boolean showGrid = true;
+       protected boolean showGrid = true;
 
        @Element(required = false)
-       private boolean showHostNames = false;
+       protected boolean showHostNames = false;
 
        @Element(required = false)
-       private boolean autoRefresh = true;
+       protected boolean autoRefresh = true;
 
        @Element(required = false)
-       private boolean logScale = false;
+       protected boolean logScale = false;
 
    @Element(required = false)
-   private boolean stacked = false;
+   protected boolean stacked = false;
 
    @Element(required = false)
-   private boolean translucent = true;
+   protected boolean translucent = true;
    
    @Element(required = false)
-   private boolean area = false;
+   protected boolean area = false;
    
    @Element(required = false)
-   private int lineWidth = 2;
+   protected int lineWidth = 2;
    
    @Element(required = false)
-   private boolean autoScale = true;
+   protected boolean autoScale = true;
    
    @Element(required = false)
-   private int minYScaleValue = 0;
+   protected int minYScaleValue = 0;
 
    @Element(required = false)
-   private int maxYScaleValue = 100;
+   protected int maxYScaleValue = 100;
 
        @Element(required = false)
-       private int refreshRate = 30;
+       protected int refreshRate = 30;
 
        @Element(required=false)
-       private int timeUnits = GraphSettings.TIME_UNIT_HOUR;
+       protected int timeUnits = GraphSettings.TIME_UNIT_HOUR;
        
        @Element(required=false)
-       private int timeRange = 1;
+       protected int timeRange = 1;
        
        @Element(required=false)
-       private int timeFrameType = GraphSettings.TIME_FRAME_BACK_FROM_NOW;
+       protected int timeFrameType = GraphSettings.TIME_FRAME_BACK_FROM_NOW;
        
        @Element(required=false)
        @Convert(XmlDateConverter.class)
-       private Date timeFrom;
+       protected Date timeFrom;
        
        @Element(required=false)
        @Convert(XmlDateConverter.class)
-       private Date timeTo;
+       protected Date timeTo;
+
+   private Set<GraphSettingsChangeListener> changeListeners = new HashSet<GraphSettingsChangeListener>(0);
        
        /**
         * Create chart settings object from XML document
@@ -117,271 +119,11 @@ public class ChartConfig
         * @return deserialized object
         * @throws Exception if the object cannot be fully deserialized
         */
-       public static ChartConfig createFromXml(final String xml) throws Exception
-       {
-               if (xml == null)
-                       return new ChartConfig();
-               return internalCreate(ChartConfig.class, xml);
-       }
-       
-       /**
-        * Internal creation method.
-        * 
-        * @param objectClass
-        * @param xml
-        * @return
-        * @throws Exception
-        */
-       protected static ChartConfig internalCreate(Class<? extends ChartConfig> objectClass, final String xml) throws Exception
-       {
-               // Compatibility mode: decode old predefined graph configuration
-               // should be removed in 1.2.2
-               if (!xml.startsWith("<chart>")) //$NON-NLS-1$
-               {
-                       ChartConfig config = objectClass.newInstance();
-                       config.parseLegacyConfig(xml);
-                       return config;
-               }
-               
-               Serializer serializer = new Persister(new AnnotationStrategy());
-               return serializer.read(objectClass, xml);
-       }
-
-       /**
-        * Parse legacy predefined graph config
-        * 
-        * @param settings
-        */
-       private void parseLegacyConfig(String settings)
-       {
-               autoRefresh = false;
-               showLegend = false;
-               showGrid = false;
-               
-               int dciCount = 0;
-               
-               GraphItemStyle[] itemStyles = new GraphItemStyle[GraphSettings.MAX_GRAPH_ITEM_COUNT];
-               for(int i = 0; i < itemStyles.length; i++)
-                       itemStyles[i] = new GraphItemStyle();
-               
-               String[] elements = settings.split("\u007F"); //$NON-NLS-1$
-               for(int i = 0; i < elements.length; i++)
-               {
-                       int index = elements[i].indexOf(':');
-                       if (index == -1)
-                               continue;
-                       
-                       final String name = elements[i].substring(0, index);
-                       final String value = elements[i].substring(index + 1);
-                       
-                       if (name.equals("A")) //$NON-NLS-1$
-                       {
-                               refreshRate = safeParseInt(value, 30);
-                       }
-                       else if (name.equals("F")) //$NON-NLS-1$
-                       {
-                               int flags = safeParseInt(value, 0);
-                               if ((flags & GraphSettings.GF_AUTO_UPDATE) != 0)
-                                       autoRefresh = true;
-                               if ((flags & GraphSettings.GF_SHOW_GRID) != 0)
-                                       showGrid = true;
-                               if ((flags & GraphSettings.GF_SHOW_LEGEND) != 0)
-                                       showLegend = true;
-                               if ((flags & GraphSettings.GF_SHOW_HOST_NAMES) != 0)
-                                       showHostNames = true;
-                               if ((flags & GraphSettings.GF_LOG_SCALE) != 0)
-                                       logScale = true;
-                       }
-                       else if (name.equals("N")) //$NON-NLS-1$
-                       {
-                               dciCount = safeParseInt(value, 0);
-                               dciList = new ChartDciConfig[dciCount];
-                               for(int j = 0; j < dciCount; j++)
-                                       dciList[j] = new ChartDciConfig();
-                       }
-                       else if (name.equals("TFT")) //$NON-NLS-1$
-                       {
-                               timeFrameType = safeParseInt(value, GraphSettings.TIME_FRAME_BACK_FROM_NOW);
-                       }
-                       else if (name.equals("TU")) //$NON-NLS-1$
-                       {
-                               timeUnits = safeParseInt(value, GraphSettings.TIME_UNIT_HOUR);
-                       }
-                       else if (name.equals("NTU")) //$NON-NLS-1$
-                       {
-                               timeRange = safeParseInt(value, 1);
-                       }
-                       else if (name.equals("TS")) //$NON-NLS-1$
-                       {
-                               timeFrom = new Date((long)safeParseInt(value, 0) * 1000L);
-                       }
-                       else if (name.equals("TF")) //$NON-NLS-1$
-                       {
-                               timeTo = new Date((long)safeParseInt(value, 0) * 1000L);
-                       }
-                       else if (name.equals("T")) //$NON-NLS-1$
-                       {
-                               title = value;
-                       }
-                       else if (name.equals("S")) //$NON-NLS-1$
-                       {
-                               // autoscale flag
-                       }
-                       else if (name.equals("G")) //$NON-NLS-1$
-                       {
-                               showGrid = (safeParseInt(value, 1) != 0);
-                       }
-                       else if (name.equals("L")) //$NON-NLS-1$
-                       {
-                               showLegend = (safeParseInt(value, 1) != 0);
-                       }
-                       else if (name.equals("R")) //$NON-NLS-1$
-                       {
-                               // show ruler flag
-                       }
-                       else if (name.equals("H")) //$NON-NLS-1$
-                       {
-                               showHostNames = (safeParseInt(value, 0) != 0);
-                       }
-                       else if (name.equals("O")) //$NON-NLS-1$
-                       {
-                               logScale = (safeParseInt(value, 0) != 0);
-                       }
-                       else if (name.equals("CA")) //$NON-NLS-1$
-                       {
-                               // axis color
-                       }
-                       else if (name.equals("CB")) //$NON-NLS-1$
-                       {
-                               // background color
-                       }
-                       else if (name.equals("CG")) //$NON-NLS-1$
-                       {
-                               // grid color
-                       }
-                       else if (name.equals("CLF")) //$NON-NLS-1$
-                       {
-                               // legend text color
-                       }
-                       else if (name.equals("CLB")) //$NON-NLS-1$
-                       {
-                               // legend background color
-                       }
-                       else if (name.equals("CP")) //$NON-NLS-1$
-                       {
-                               // plot area color
-                       }
-                       else if (name.equals("CR")) //$NON-NLS-1$
-                       {
-                               // ruler color
-                       }
-                       else if (name.equals("CS")) //$NON-NLS-1$
-                       {
-                               // selection color
-                       }
-                       else if (name.equals("CT")) //$NON-NLS-1$
-                       {
-                               // text color
-                       }
-                       else if (name.charAt(0) == 'C') // Item color
-                       {
-                               int item = safeParseInt(name.substring(1), -1);
-                               if ((item >= 0) && (item < itemStyles.length))
-                                       itemStyles[item].setColor(safeParseInt(value, 0));
-                       }
-                       else if (name.charAt(0) == 'T') // Item type
-                       {
-                               int item = safeParseInt(name.substring(1), -1);
-                               if ((item >= 0) && (item < itemStyles.length))
-                                       itemStyles[item].setType(safeParseInt(value, 0));
-                       }
-                       else if (name.charAt(0) == 'W') // Item line width
-                       {
-                               int item = safeParseInt(name.substring(1), -1);
-                               if ((item >= 0) && (item < itemStyles.length))
-                                       itemStyles[item].setLineWidth(safeParseInt(value, 0));
-                       }
-                       else if ((name.charAt(0) == 'F') && (name.charAt(1) == 'L'))    // Item flags
-                       {
-                               int item = safeParseInt(name.substring(2), -1);
-                               if ((item >= 0) && (item < itemStyles.length))
-                                       itemStyles[item].setFlags(safeParseInt(value, 0));
-                       }
-                       else if (name.charAt(0) == 'N') // Node ID
-                       {
-                               int item = safeParseInt(name.substring(1), -1);
-                               if ((item >= 0) && (item < dciCount))
-                                       dciList[item].nodeId = safeParseLong(value, 0);
-                       }
-                       else if (name.charAt(0) == 'I') // DCI information
-                       {
-                               if (name.charAt(1) == 'D')      // description
-                               {
-                                       int item = safeParseInt(name.substring(2), -1);
-                                       if ((item >= 0) && (item < dciCount))
-                                               dciList[item].name = value;
-                               }
-                               else if (name.charAt(1) == 'N') // name
-                               {
-                               }
-                               else if (name.charAt(1) == 'S') // source
-                               {
-                               }
-                               else if (name.charAt(1) == 'T') // data type
-                               {
-                               }
-                               else    // assume DCI ID - Ixxx
-                               {
-                                       int item = safeParseInt(name.substring(1), -1);
-                                       if ((item >= 0) && (item < dciCount))
-                                               dciList[item].dciId = safeParseLong(value, 0);
-                               }
-                       }
-               }
-               
-               // Apply item styles
-               for(int i = 0; (i < dciList.length) && (i < itemStyles.length); i++)
-               {
-                       dciList[i].color = "0x" + Integer.toHexString(itemStyles[i].getColor()); //$NON-NLS-1$
-                       dciList[i].lineWidth = itemStyles[i].getLineWidth();
-               }
-       }
-       
-       /**
-        * Parse int without throwing exception
-        * @param text text to parse
-        * @param defVal default value to be used in case of parse error
-        * @return parsed value
-        */
-       static private int safeParseInt(String text, int defVal)
-       {
-               try
-               {
-                       return Integer.parseInt(text);
-               }
-               catch(NumberFormatException e)
-               {
-               }
-               return defVal;
-       }
-
-       /**
-        * Parse long without throwing exception
-        * @param text text to parse
-        * @param defVal default value to be used in case of parse error
-        * @return parsed value
-        */
-       static private long safeParseLong(String text, long defVal)
-       {
-               try
-               {
-                       return Long.parseLong(text);
-               }
-               catch(NumberFormatException e)
-               {
-               }
-               return defVal;
-       }
+   public static ChartConfig createFromXml(final String xml) throws Exception
+   {
+      Serializer serializer = new Persister(new AnnotationStrategy());
+      return serializer.read(ChartConfig.class, xml);
+   }
        
        /**
         * Create XML from configuration.
@@ -802,5 +544,61 @@ public class ChartConfig
       timeUnits = tp.getTimeUnitValue();
       timeFrom = tp.getTimeFromValue();
       timeTo = tp.getTimeToValue();
-   }  
+   } 
+
+   /**
+    * Add change listener
+    * 
+    * @param listener change listener
+    */
+   public void addChangeListener(GraphSettingsChangeListener listener)
+   {
+      changeListeners.add(listener);
+   }
+   
+   /**
+    * Remove change listener
+    * 
+    * @param listener change listener to remove
+    */
+   public void removeChangeListener(GraphSettingsChangeListener listener)
+   {
+      changeListeners.remove(listener);
+   }
+   
+   /**
+    * Fire change notification
+    */
+   public void fireChangeNotification()
+   {
+      for(GraphSettingsChangeListener l : changeListeners)
+         l.onGraphSettingsChange(this);
+   }
+
+   public void setConfig(ChartConfig config)
+   {
+      dciList = config.dciList.clone();
+      title = config.title; 
+      legendPosition = config.legendPosition; 
+      showLegend = config.showLegend; 
+      extendedLegend = config.extendedLegend; 
+      showTitle = config.showTitle; 
+      showGrid = config.showGrid; 
+      showHostNames = config.showHostNames; 
+      autoRefresh = config.autoRefresh; 
+      logScale = config.logScale; 
+      stacked = config.stacked; 
+      translucent = config.translucent; 
+      area = config.area;
+      lineWidth = config.lineWidth;
+      autoScale = config.autoScale; 
+      minYScaleValue = config.minYScaleValue; 
+      maxYScaleValue = config.maxYScaleValue; 
+      refreshRate = config.refreshRate; 
+      timeUnits = config.timeUnits; 
+      timeRange = config.timeRange; 
+      timeFrameType = config.timeFrameType; 
+      timeFrom = config.timeFrom; 
+      timeTo = config.timeTo; 
+   }
 }
  * 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.charts.api;
+package org.netxms.client.datacollection;
 
-import org.netxms.client.datacollection.DataCollectionObject;
-import org.netxms.client.datacollection.DciValue;
 import org.simpleframework.xml.Attribute;
 import org.simpleframework.xml.Element;
 import org.simpleframework.xml.Root;
@@ -45,6 +43,12 @@ public class ChartDciConfig
        
        @Attribute
        public long dciId;
+
+   @Element(required=false)
+       public String dciName;
+
+   @Element(required=false)
+   public String dciDescription;
        
        @Element(required=false)
        public int type;
@@ -70,6 +74,9 @@ public class ChartDciConfig
    @Element(required=false)
    public boolean invertValues;
 
+   @Element(required=false)
+   public boolean multiMatch;
+
        @Element(required=false)
        public String instance;
        
@@ -86,6 +93,8 @@ public class ChartDciConfig
        {
                nodeId = 0;
                dciId = 0;
+               dciName = ""; //$NON-NLS-1$
+               dciDescription = ""; //$NON-NLS-1$
                type = ITEM;
                color = UNSET_COLOR;
                name = ""; //$NON-NLS-1$
@@ -94,6 +103,7 @@ public class ChartDciConfig
                area = false;
                showThresholds = false;
                invertValues = false;
+               multiMatch = false;
                instance = ""; //$NON-NLS-1$
                column = ""; //$NON-NLS-1$
       displayFormat = "%s"; //$NON-NLS-1$
@@ -108,6 +118,8 @@ public class ChartDciConfig
        {
                this.nodeId = src.nodeId;
                this.dciId = src.dciId;
+      this.dciName = src.dciName;
+      this.dciDescription = src.dciDescription;
                this.type = src.type;
                this.color = src.color;
                this.name = src.name;
@@ -116,6 +128,7 @@ public class ChartDciConfig
                this.area = src.area;
                this.showThresholds = src.showThresholds;
                this.invertValues = src.invertValues;
+               this.multiMatch = src.multiMatch;
                this.instance = src.instance;
                this.column = src.column;
                this.displayFormat = src.displayFormat;
@@ -130,6 +143,8 @@ public class ChartDciConfig
        {
                nodeId = dci.getNodeId();
                dciId = dci.getId();
+      dciName = dci.getName();
+      dciDescription = dci.getDescription();
                type = dci.getDcObjectType();
                name = dci.getDescription();
                color = UNSET_COLOR;
@@ -137,6 +152,7 @@ public class ChartDciConfig
                area = false;
                showThresholds = false;
                invertValues = false;
+               multiMatch = false;
                instance = ""; //$NON-NLS-1$
                column = ""; //$NON-NLS-1$
       displayFormat = "%s"; //$NON-NLS-1$
@@ -190,4 +206,36 @@ public class ChartDciConfig
        {
           return ((displayType == DEFAULT) && area) ? AREA : displayType;
        }
+
+   /**
+    * @return the dciName
+    */
+   public String getDciName()
+   {
+      return dciName == null ? "" : dciName;
+   }
+
+   /**
+    * @param dciName the dciName to set
+    */
+   public void setDciName(String dciName)
+   {
+      this.dciName = dciName;
+   }
+
+   /**
+    * @return the dciDescription
+    */
+   public String getDciDescription()
+   {
+      return dciDescription == null ? "" : dciDescription;
+   }
+
+   /**
+    * @param dciDescription the dciDescription to set
+    */
+   public void setDciDescription(String dciDescription)
+   {
+      this.dciDescription = dciDescription;
+   }
 }
index f10f70e..d500411 100644 (file)
@@ -20,16 +20,22 @@ package org.netxms.client.datacollection;
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
+import org.netxms.base.Logger;
+import org.netxms.base.NXCPCodes;
 import org.netxms.base.NXCPMessage;
 import org.netxms.client.AccessListElement;
+import org.netxms.client.ObjectMenuFilter;
+import org.netxms.client.objects.AbstractNode;
+import org.netxms.client.objects.MenuFiltringObj;
+import org.simpleframework.xml.Serializer;
+import org.simpleframework.xml.convert.AnnotationStrategy;
+import org.simpleframework.xml.core.Persister;
 
 /**
  * Settings for predefined graph
  */
-public class GraphSettings
+public class GraphSettings extends ChartConfig  implements MenuFiltringObj
 {
        public static final int MAX_GRAPH_ITEM_COUNT = 16;
        
@@ -67,9 +73,7 @@ public class GraphSettings
        private String name;
        private String shortName;
        private List<AccessListElement> accessList;
-       private String config;
-       private Set<GraphSettingsChangeListener> changeListeners = new HashSet<GraphSettingsChangeListener>(0);
-       private String filters;
+       private ObjectMenuFilter filters;
        
        /**
         * Create default settings
@@ -82,8 +86,7 @@ public class GraphSettings
                name = "noname";
                shortName = "noname";
                accessList = new ArrayList<AccessListElement>(0);
-               config = "<chart></chart>";
-      filters = "<objectToolFilter></objectToolFilter>";
+               filters = new ObjectMenuFilter();
        }
        
        /**
@@ -98,37 +101,106 @@ public class GraphSettings
                this.flags = flags;
                this.accessList = new ArrayList<AccessListElement>(accessList.size());
                this.accessList.addAll(accessList);
-               config = "<chart></chart>";
-               filters = "<objectToolFilter></objectToolFilter>";
+      filters = new ObjectMenuFilter();
        }
        
+   public GraphSettings(GraphSettings data, String name)
+   {
+      id = data.id;
+      ownerId = data.ownerId;
+      this.name = data.name;      
+      shortName = data.shortName;
+      flags = data.flags & ~GRAPH_FLAG_TEMPLATE;
+      this.accessList = new ArrayList<AccessListElement>(data.accessList.size());
+      this.accessList.addAll(data.accessList);
+      filters = data.filters;
+      setConfig(data);
+      setTitle(name);
+   }
+
+   /**
+    * Create chart settings object from XML document
+    * 
+    * @param xml XML document
+    * @return deserialized object
+    * @throws Exception if the object cannot be fully deserialized
+    */
+   public static GraphSettings createFromXml(final String xml) throws Exception
+   {
+      Serializer serializer = new Persister(new AnnotationStrategy());
+      return serializer.read(GraphSettings.class, xml);
+   }
+       
        /**
         * Create graph settings object from NXCP message
         * 
         * @param msg NXCP message
         * @param baseId base variable id
         */
-       public GraphSettings(final NXCPMessage msg, long baseId)
+       static public GraphSettings createGraphSettings(final NXCPMessage msg, long baseId)
        {
-               id = msg.getFieldAsInt64(baseId);
-               ownerId = msg.getFieldAsInt64(baseId + 1);
-      flags = (int)msg.getFieldAsInt64(baseId + 2);
-      name = msg.getFieldAsString(baseId + 3);
-      config = msg.getFieldAsString(baseId + 4);
-      filters = msg.getFieldAsString(baseId + 5);
+          GraphSettings gs;
+      try
+      {
+         gs = GraphSettings.createFromXml(msg.getFieldAsString(baseId + 4));
+      }
+      catch(Exception e)
+      {
+         gs = new GraphSettings();
+         Logger.debug("GraphSettings.CreateGraphSettings", "Cannot parse ChartConfig XML", e);
+      }
+      gs.id = msg.getFieldAsInt64(baseId);
+      gs.ownerId = msg.getFieldAsInt64(baseId + 1);
+      gs.flags = (int)msg.getFieldAsInt64(baseId + 2);
+      gs.name = msg.getFieldAsString(baseId + 3);
+      
+      try
+      {
+         gs.filters = ObjectMenuFilter.createFromXml(msg.getFieldAsString(baseId + 5));
+      }
+      catch(Exception e)
+      {
+         Logger.debug("GraphSettings.CreateGraphSettings", "Cannot parse ObjectMenuFilter XML: ", e);
+         gs.filters = new ObjectMenuFilter();
+      }
                
-               String[] parts = name.split("->");
-               shortName = (parts.length > 1) ? parts[parts.length - 1] : name;
+               String[] parts = gs.name.split("->");
+               gs.shortName = (parts.length > 1) ? parts[parts.length - 1] : gs.name;
                
                int count = msg.getFieldAsInt32(baseId + 6);  // ACL size
                long[] users = msg.getFieldAsUInt32Array(baseId + 7);
                long[] rights = msg.getFieldAsUInt32Array(baseId + 8);
-               accessList = new ArrayList<AccessListElement>(count);
+               gs.accessList = new ArrayList<AccessListElement>(count);
                for(int i = 0; i < count; i++)
                {
-                       accessList.add(new AccessListElement(users[i], (int)rights[i]));
+                  gs.accessList.add(new AccessListElement(users[i], (int)rights[i]));
                }
                
+               return gs;
+       }
+       
+       public void fillMessage(NXCPMessage msg)
+       {
+          msg.setFieldInt32(NXCPCodes.VID_GRAPH_ID, (int) id);
+      msg.setField(NXCPCodes.VID_NAME, name);
+      msg.setFieldInt32(NXCPCodes.VID_FLAGS, flags);
+      msg.setField(NXCPCodes.VID_FILTER, getFiltersAsXML());
+      try
+      {
+         msg.setField(NXCPCodes.VID_GRAPH_CONFIG, createXml());
+      }
+      catch(Exception e)
+      {
+         Logger.debug("GraphSettings.CreateGraphSettings", "Cannot convert ChartConfig to XML: ", e);
+         msg.setField(NXCPCodes.VID_GRAPH_CONFIG, "");
+      }
+      msg.setFieldInt32(NXCPCodes.VID_ACL_SIZE, accessList.size());
+      long varId = NXCPCodes.VID_GRAPH_ACL_BASE;
+      for(AccessListElement el : accessList)
+      {
+         msg.setFieldInt32(varId++, (int) el.getUserId());
+         msg.setFieldInt32(varId++, el.getAccessRights());
+      }      
        }
        
        /**
@@ -181,51 +253,6 @@ public class GraphSettings
                shortName = (parts.length > 1) ? parts[parts.length - 1] : name;
        }
 
-       /**
-        * Add change listener
-        * 
-        * @param listener change listener
-        */
-       public void addChangeListener(GraphSettingsChangeListener listener)
-       {
-               changeListeners.add(listener);
-       }
-       
-       /**
-        * Remove change listener
-        * 
-        * @param listener change listener to remove
-        */
-       public void removeChangeListener(GraphSettingsChangeListener listener)
-       {
-               changeListeners.remove(listener);
-       }
-       
-       /**
-        * Fire change notification
-        */
-       public void fireChangeNotification()
-       {
-               for(GraphSettingsChangeListener l : changeListeners)
-                       l.onGraphSettingsChange(this);
-       }
-
-       /**
-        * @return the config
-        */
-       public String getConfig()
-       {
-               return config;
-       }
-
-       /**
-        * @param config the config to set
-        */
-       public void setConfig(String config)
-       {
-               this.config = config;
-       }
-
    /**
     * @return the flags
     */
@@ -245,16 +272,72 @@ public class GraphSettings
    /**
     * @return the filters
     */
-   public String getFilters()
+   public ObjectMenuFilter getFilters()
    {
       return filters;
    }
 
    /**
+    * @return the filters as string
+    */
+   public String getFiltersAsXML()
+   {
+      try
+      {
+         return filters.createXml();
+      }
+      catch(Exception e)
+      {
+         Logger.debug("GraphSettings.CreateGraphSettings", "Cannot create XML from ObjectMenuFilter: ", e);
+         return "";
+      }
+   }
+
+   /**
     * @param filters the filters to set
     */
-   public void setFilters(String filters)
+   public void setFilters(ObjectMenuFilter filters)
    {
       this.filters = filters;
    }
+   
+   /**
+    * Checks if this graph template is applicable for node
+    * 
+    * @param node
+    * @return
+    */
+   public boolean isApplicableForNode(AbstractNode node)
+   {      
+      return filters.isApplicableForNode(node);
+   }
+
+   
+   /**
+    * Checks if this graph is template
+    * 
+    * @return isTemplate
+    */
+   public boolean isTemplate()
+   {
+      return (flags & GRAPH_FLAG_TEMPLATE) > 0;
+   }
+
+   @Override
+   public ObjectMenuFilter getFilter()
+   {
+      return filters;
+   }
+
+   @Override
+   public void setFilter(ObjectMenuFilter filter)
+   {
+      this.filters = filter;
+   }
+
+   @Override
+   public int getType()
+   {
+      return 0;
+   }
 }
index 26456e6..5eff6e0 100644 (file)
@@ -29,5 +29,5 @@ public interface GraphSettingsChangeListener
         * 
         * @param settings graph settings object
         */
-       public abstract void onGraphSettingsChange(GraphSettings settings);
+       public abstract void onGraphSettingsChange(ChartConfig settings);
 }
diff --git a/src/java/client/netxms-client/src/main/java/org/netxms/client/objects/MenuFiltringObj.java b/src/java/client/netxms-client/src/main/java/org/netxms/client/objects/MenuFiltringObj.java
new file mode 100644 (file)
index 0000000..baf258f
--- /dev/null
@@ -0,0 +1,22 @@
+package org.netxms.client.objects;
+
+import org.netxms.client.ObjectMenuFilter;
+
+public interface MenuFiltringObj
+{
+   /**
+    * Returns filter
+    */
+   public ObjectMenuFilter getFilter();
+   
+
+   /**
+    * Sets filter
+    */
+   public void setFilter(ObjectMenuFilter filter);
+   
+   /**
+    * Returns type of of object(for Object tools it is required for determining local commands)
+    */
+   public int getType();
+}
index b797917..500aa42 100644 (file)
@@ -23,18 +23,17 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
-import java.util.regex.Pattern;
-import org.netxms.base.Glob;
 import org.netxms.base.Logger;
 import org.netxms.base.NXCPMessage;
+import org.netxms.client.ObjectMenuFilter;
 import org.netxms.client.objects.AbstractNode;
-import org.netxms.client.objects.AbstractObject;
+import org.netxms.client.objects.MenuFiltringObj;
 
 /**
  * NetXMS object tool representation
  *
  */
-public class ObjectTool
+public class ObjectTool implements MenuFiltringObj
 {
        public static final int TYPE_INTERNAL       = 0;
        public static final int TYPE_ACTION         = 1;
@@ -45,18 +44,12 @@ public class ObjectTool
        public static final int TYPE_SERVER_COMMAND = 6;
        public static final int TYPE_FILE_DOWNLOAD  = 7;
    public static final int TYPE_SERVER_SCRIPT  = 8;
-       
-       public static final int REQUIRES_SNMP                 = 0x00000001;
-       public static final int REQUIRES_AGENT                = 0x00000002;
-       public static final int REQUIRES_OID_MATCH            = 0x00000004;
-       public static final int ASK_CONFIRMATION              = 0x00000008;
-       public static final int GENERATES_OUTPUT              = 0x00000010;
-       public static final int DISABLED                      = 0x00000020;
-       public static final int SHOW_IN_COMMANDS              = 0x00000040;
-   public static final int REQUIRES_NODE_OS_MATCH        = 0x00000080;
-   public static final int REQUIRES_TEMPLATE_MATCH       = 0x00000100;
-       public static final int SNMP_INDEXED_BY_VALUE         = 0x00010000;
-       public static final int REQUIRES_WORKSTATION_OS_MATCH = 0x00020000;
+
+   public static final int ASK_CONFIRMATION          = 0x00000001;
+   public static final int GENERATES_OUTPUT          = 0x00000002;
+   public static final int DISABLED                  = 0x00000004;
+   public static final int SHOW_IN_COMMANDS          = 0x00000008;
+   public static final int SNMP_INDEXED_BY_VALUE     = 0x00000010;
        
        protected long id;
        protected String name;
@@ -68,7 +61,7 @@ public class ObjectTool
        protected String confirmationText;
        protected String commandName;
    protected String commandShortName;
-   protected ObjectToolFilter filter;
+   protected ObjectMenuFilter filter;
        protected byte[] imageData;
        protected Map<String, InputField> inputFields;
 
@@ -77,7 +70,7 @@ public class ObjectTool
         */
        protected ObjectTool()
        {
-          filter = new ObjectToolFilter();
+          filter = new ObjectMenuFilter();
           inputFields = new HashMap<String, InputField>(0);
        }
        
@@ -102,11 +95,11 @@ public class ObjectTool
                imageData = msg.getFieldAsBinary(baseId + 10);
                try
       {
-         filter = ObjectToolFilter.createFromXml(filterData);
+         filter = ObjectMenuFilter.createFromXml(filterData);
       }
       catch(Exception e)
       {
-         filter = new ObjectToolFilter();
+         filter = new ObjectMenuFilter();
          if (!filterData.isEmpty())
             Logger.debug("ObjectTool.ObjectTool", "Failed to create object tool filter from XML");
       }
@@ -209,70 +202,7 @@ public class ObjectTool
         */
        public boolean isApplicableForNode(AbstractNode node)
        {
-               if (((flags & REQUIRES_SNMP) != 0) &&
-                        ((node.getFlags() & AbstractNode.NF_IS_SNMP) == 0))
-                       return false;   // Node does not support SNMP
-               
-               if (((flags & REQUIRES_AGENT) != 0) &&
-                                ((node.getFlags() & AbstractNode.NF_IS_NATIVE_AGENT) == 0))
-                               return false;   // Node does not have NetXMS agent
-               
-               if ((flags & REQUIRES_OID_MATCH) != 0)
-               {
-                       if (!Glob.matchIgnoreCase(filter.snmpOid, node.getSnmpOID()))
-                               return false;   // OID does not match
-               }
-               
-          if ((flags & REQUIRES_NODE_OS_MATCH) != 0)
-      {
-             boolean match = false;
-             String[] substrings = filter.toolNodeOS.split(",");
-             for(int i = 0; i < substrings.length; i++)
-             {;
-                if (Pattern.matches(substrings[i], node.getPlatformName()))
-                {
-                   match = true;
-                }
-             }
-             if (!match)
-                return false;  //Not correct type of OS
-      }
-          
-          if ((flags & REQUIRES_WORKSTATION_OS_MATCH) != 0)
-      {
-         boolean match = false;
-         String[] substrings = filter.toolWorkstationOS.split(",");
-         for(int i = 0; i < substrings.length; i++)
-         {;
-            if (Pattern.matches(substrings[i], System.getProperty("os.name")))
-            {
-               match = true;
-            }
-         }
-         if (!match)
-            return false;  //Not correct type of OS
-      }
-           
-          if ((flags & REQUIRES_TEMPLATE_MATCH) != 0)
-      {
-             boolean match = false;
-         String[] substrings = filter.toolTemplate.split(",");
-         Set<AbstractObject> parents = node.getAllParents(AbstractObject.OBJECT_TEMPLATE);
-         for(AbstractObject parent : parents)
-         {
-            for(int i = 0; i < substrings.length; i++)
-            {
-               if (Pattern.matches(substrings[i], parent.getObjectName()))
-               {
-                  match = true;
-               }
-            }
-         }
-         if (!match)
-            return false;  // Does not belong to those templates
-      }
-               
-               return true;
+               return filter.isApplicableForNode(node);
        }
 
        /**
@@ -451,4 +381,16 @@ public class ObjectTool
    {
       return filter.toolTemplate;
    }
+
+   @Override
+   public ObjectMenuFilter getFilter()
+   {
+      return filter;
+   }
+
+   @Override
+   public void setFilter(ObjectMenuFilter filter)
+   {
+      this.filter = filter;      
+   }
 }
index 1bf15dd..299b442 100644 (file)
@@ -27,6 +27,8 @@ import java.util.List;
 import org.netxms.base.Logger;
 import org.netxms.base.NXCPCodes;
 import org.netxms.base.NXCPMessage;
+import org.netxms.client.ObjectMenuFilter;
+import org.netxms.client.objects.MenuFiltringObj;
 
 /**
  * Detailed information about object tool
@@ -55,7 +57,7 @@ public class ObjectToolDetails extends ObjectTool
                data = "";
                flags = 0;
                description = "";
-               filter = new ObjectToolFilter();
+               filter = new ObjectMenuFilter();
                confirmationText = "";
                accessList = new ArrayList<Long>(0);
                columns = new ArrayList<ObjectToolTableColumn>(0);
@@ -89,11 +91,11 @@ public class ObjectToolDetails extends ObjectTool
                imageData = msg.getFieldAsBinary(NXCPCodes.VID_IMAGE_DATA);
       try
       {
-         filter = ObjectToolFilter.createFromXml(filterData);
+         filter = ObjectMenuFilter.createFromXml(filterData);
       }
       catch(Exception e)
       {
-         filter = new ObjectToolFilter();
+         filter = new ObjectMenuFilter();
          Logger.debug("ObjectToolDetails.ObjectToolDetails", "Failed to convert object tool filter to string");
       }
                
@@ -271,43 +273,6 @@ public class ObjectToolDetails extends ObjectTool
        }
 
        /**
-        * @param snmpOid the snmpOid to set
-        */
-       public void setSnmpOid(String snmpOid)
-       {
-          filter.snmpOid = snmpOid;
-               modified = true;
-       }
-       
-
-       /**
-    * @param toolTemplate the comma separated list of template name regexps
-    */
-   public void setToolTemplate(String toolTemplate)
-   {
-      filter.toolTemplate = toolTemplate;
-      modified = true;
-   }
-
-   /**
-    * @param toolNodeOS  the comma separated list of OS name regexps
-    */
-   public void setToolNodeOS(String toolNodeOS)
-   {
-      filter.toolNodeOS = toolNodeOS;
-      modified = true;
-   }
-   
-   /**
-    * @param toolWorkstationOS  the comma separated list of OS name regexps
-    */
-   public void setToolWorkstationOS(String toolWorkstationOS)
-   {
-      filter.toolWorkstationOS = toolWorkstationOS;
-      modified = true;
-   }
-
-       /**
         * @param data the data to set
         */
        public void setData(String data)
diff --git a/src/java/client/netxms-client/src/main/java/org/netxms/client/objecttools/ObjectToolFilter.java b/src/java/client/netxms-client/src/main/java/org/netxms/client/objecttools/ObjectToolFilter.java
deleted file mode 100644 (file)
index 03bffd4..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.netxms.client.objecttools;
-
-import java.io.StringWriter;
-import java.io.Writer;
-import org.simpleframework.xml.Element;
-import org.simpleframework.xml.Root;
-import org.simpleframework.xml.Serializer;
-import org.simpleframework.xml.core.Persister;
-
-/**
- * Class created to store 
- */
-@Root(name="objectToolFilter")
-public class ObjectToolFilter
-{
-   @Element(required=false, name="toolOS")
-   public String toolNodeOS;
-   
-   @Element(required=false)
-   public String toolWorkstationOS;
-   
-   @Element(required=false)
-   public String toolTemplate;
-   
-   @Element(required=false)
-   public String snmpOid;
-   
-   /**
-    * Create ObjectToolFilter object from XML document
-    * 
-    * @param xml XML document
-    * @return deserialized object
-    * @throws Exception if the object cannot be fully deserialized
-    */
-   public static ObjectToolFilter createFromXml(final String xml) throws Exception
-   {
-      Serializer serializer = new Persister();
-      return serializer.read(ObjectToolFilter.class, xml);
-   }
-   
-   /**
-    * Create XML from configuration.
-    * 
-    * @return XML document
-    * @throws Exception if the schema for the object is not valid
-    */
-   public String createXml() throws Exception
-   {
-      Serializer serializer = new Persister();
-      Writer writer = new StringWriter();
-      serializer.write(this, writer);
-      return writer.toString();
-   }
-   
-   public ObjectToolFilter()
-   {
-      toolNodeOS = "";
-      toolWorkstationOS = "";
-      toolTemplate = "";
-      snmpOid = "";
-   }
-}
@@ -16,7 +16,7 @@
  * 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.perfview;
+package org.netxms.client.xml;
 
 import java.util.Date;
 import org.simpleframework.xml.convert.Converter;
diff --git a/src/java/netxms-eclipse/Charts/src/org/netxms/ui/eclipse/charts/api/ChartDciConfig.java b/src/java/netxms-eclipse/Charts/src/org/netxms/ui/eclipse/charts/api/ChartDciConfig.java
deleted file mode 100644 (file)
index 3b71182..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/**
- * NetXMS - open source network management system
- * Copyright (C) 2003-2015 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.charts.api;
-
-import org.netxms.client.datacollection.DataCollectionObject;
-import org.netxms.client.datacollection.DciValue;
-import org.simpleframework.xml.Attribute;
-import org.simpleframework.xml.Element;
-import org.simpleframework.xml.Root;
-
-/**
- * DCI information for chart
- */
-@Root(name="dci", strict=false)
-public class ChartDciConfig
-{
-       public static final String UNSET_COLOR = "UNSET"; //$NON-NLS-1$
-       
-       public static final int ITEM = DataCollectionObject.DCO_TYPE_ITEM;
-       public static final int TABLE = DataCollectionObject.DCO_TYPE_TABLE;
-       
-       // display types
-       public static final int DEFAULT = 0;
-   public static final int LINE = 1;
-   public static final int AREA = 2;
-       
-       @Attribute
-       public long nodeId;
-       
-       @Attribute
-       public long dciId;
-       
-       @Element(required=false)
-       public int type;
-
-       @Element(required=false)
-       public String color;
-
-       @Element(required=false)
-       public String name;
-       
-       @Element(required=false)
-       public int lineWidth;
-       
-       @Element(required=false)
-       public int displayType;
-       
-       @Element(required=false)
-       public boolean area;
-       
-       @Element(required=false)
-       public boolean showThresholds;
-
-   @Element(required=false)
-   public boolean invertValues;
-
-       @Element(required=false)
-       public String instance;
-       
-       @Element(required=false)
-       public String column;
-       
-   @Element(required=false)
-   public String displayFormat;
-   
-       /**
-        * Default constructor
-        */
-       public ChartDciConfig()
-       {
-               nodeId = 0;
-               dciId = 0;
-               type = ITEM;
-               color = UNSET_COLOR;
-               name = ""; //$NON-NLS-1$
-               lineWidth = 2;
-               displayType = DEFAULT;
-               area = false;
-               showThresholds = false;
-               invertValues = false;
-               instance = ""; //$NON-NLS-1$
-               column = ""; //$NON-NLS-1$
-      displayFormat = "%s"; //$NON-NLS-1$
-       }
-
-       /**
-        * Copy constructor
-        * 
-        * @param src source object
-        */
-       public ChartDciConfig(ChartDciConfig src)
-       {
-               this.nodeId = src.nodeId;
-               this.dciId = src.dciId;
-               this.type = src.type;
-               this.color = src.color;
-               this.name = src.name;
-               this.lineWidth = src.lineWidth;
-               this.displayType = src.displayType;
-               this.area = src.area;
-               this.showThresholds = src.showThresholds;
-               this.invertValues = src.invertValues;
-               this.instance = src.instance;
-               this.column = src.column;
-               this.displayFormat = src.displayFormat;
-       }
-
-       /**
-        * Create DCI info from DciValue object
-        * 
-        * @param dci
-        */
-       public ChartDciConfig(DciValue dci)
-       {
-               nodeId = dci.getNodeId();
-               dciId = dci.getId();
-               type = dci.getDcObjectType();
-               name = dci.getDescription();
-               color = UNSET_COLOR;
-               lineWidth = 2;
-               area = false;
-               showThresholds = false;
-               invertValues = false;
-               instance = ""; //$NON-NLS-1$
-               column = ""; //$NON-NLS-1$
-      displayFormat = "%s"; //$NON-NLS-1$
-       }
-
-       /**
-        * @return the color
-        */
-       public int getColorAsInt()
-       {
-               if (color.equals(UNSET_COLOR))
-                       return -1;
-               if (color.startsWith("0x")) //$NON-NLS-1$
-                       return Integer.parseInt(color.substring(2), 16);
-               return Integer.parseInt(color, 10);
-       }
-
-       /**
-        * @param value
-        */
-       public void setColor(int value)
-       {
-               color = "0x" + Integer.toHexString(value); //$NON-NLS-1$
-       }
-       
-       /**
-        * Get DCI name. Always returns non-empty string.
-        * @return
-        */
-       public String getName()
-       {
-               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$
-       }
-       
-       /**
-        * Get display type
-        * 
-        * @return
-        */
-       public int getDisplayType()
-       {
-          return ((displayType == DEFAULT) && area) ? AREA : displayType;
-       }
-}
index c56b8da..97b1346 100644 (file)
@@ -140,6 +140,7 @@ public class Messages extends NLS
    public static String ApplicationWorkbenchWindowAdvisor_PkcsFiles;
    public static String ApplicationWorkbenchWindowAdvisor_Error;
        public static String ApplicationWorkbenchWindowAdvisor_Information;
+   public static String ObjectContext_MultipleNodes;
        public static String ObjectNameValidator_ErrorMessage1;
    public static String ObjectNameValidator_ErrorMessage2;
        public static String PasswordExpiredDialog_confirm_passwd;
index c5e747c..d38e74a 100644 (file)
@@ -109,6 +109,7 @@ ApplicationWorkbenchWindowAdvisor_Error=Error
 ApplicationWorkbenchWindowAdvisor_Information=Information
 NumericTextFieldValidator_ErrorMessage=Please enter number in range %s in field "%s"
 NumericTextFieldValidator_RangeSeparator=..
+ObjectContext_MultipleNodes=<multiple nodes>
 ObjectNameValidator_ErrorMessage1=Please provide non-empty object name in "%s" field
 ObjectNameValidator_ErrorMessage2=Object name in "%s" field contains invalid characters
 PasswordExpiredDialog_confirm_passwd=Confirm new password:
index d2d9465..915d427 100644 (file)
@@ -108,6 +108,7 @@ LoginJob_sync_users=Synchronizing user database...
 MacAddressValidator_ErrorMessage=Please enter valid MAC address in "%s" field
 NumericTextFieldValidator_ErrorMessage=Please enter number in range %s in field "%s"
 NumericTextFieldValidator_RangeSeparator=..
+ObjectContext_MultipleNodes=<multiple nodes>
 ObjectNameValidator_ErrorMessage1=Please provide non-empty object name in "%s" field
 ObjectNameValidator_ErrorMessage2=Object name in "%s" field contains invalid characters
 PasswordExpiredDialog_confirm_passwd=Confirm new password:
index 93bcc67..81e1b6d 100644 (file)
@@ -108,6 +108,7 @@ LoginJob_sync_users=Synchronizov\u00e1n\u00ed u\u017eivatelsk\u00e9 datab\u00e1z
 MacAddressValidator_ErrorMessage=Pros\u00edm vlo\u017ete platnou MAC adresu v poli "%s"
 NumericTextFieldValidator_ErrorMessage=Pros\u00edm vlo\u017ete \u010d\u00edslo v rozsahu %s do pole "%s"
 NumericTextFieldValidator_RangeSeparator=..
+ObjectContext_MultipleNodes=<v\u00edce prvk\u016f>
 ObjectNameValidator_ErrorMessage1=Pros\u00edm vypl\u0148te nepr\u00e1zdn\u00fd n\u00e1zev objektu v poli "%s"
 ObjectNameValidator_ErrorMessage2=N\u00e1zev objektu v poli "%s" obsahuje neplatn\u00e9 znaky
 PasswordExpiredDialog_confirm_passwd=Potvrdit nov\u00e9 heslo\:
index d2d9465..915d427 100644 (file)
@@ -108,6 +108,7 @@ LoginJob_sync_users=Synchronizing user database...
 MacAddressValidator_ErrorMessage=Please enter valid MAC address in "%s" field
 NumericTextFieldValidator_ErrorMessage=Please enter number in range %s in field "%s"
 NumericTextFieldValidator_RangeSeparator=..
+ObjectContext_MultipleNodes=<multiple nodes>
 ObjectNameValidator_ErrorMessage1=Please provide non-empty object name in "%s" field
 ObjectNameValidator_ErrorMessage2=Object name in "%s" field contains invalid characters
 PasswordExpiredDialog_confirm_passwd=Confirm new password:
index 1b25e23..ed52687 100644 (file)
@@ -108,6 +108,7 @@ LoginJob_sync_users=Sincronizando usuarios...
 MacAddressValidator_ErrorMessage=Please enter valid MAC address in "%s" field
 NumericTextFieldValidator_ErrorMessage=Please enter number in range %s in field "%s"
 NumericTextFieldValidator_RangeSeparator=..
+ObjectContext_MultipleNodes=<multiple nodes>
 ObjectNameValidator_ErrorMessage1=Please provide non-empty object name in "%s" field
 ObjectNameValidator_ErrorMessage2=Object name in "%s" field contains invalid characters
 PasswordExpiredDialog_confirm_passwd=Confirmar nueva contrase\u00f1a:
index d2d9465..915d427 100644 (file)
@@ -108,6 +108,7 @@ LoginJob_sync_users=Synchronizing user database...
 MacAddressValidator_ErrorMessage=Please enter valid MAC address in "%s" field
 NumericTextFieldValidator_ErrorMessage=Please enter number in range %s in field "%s"
 NumericTextFieldValidator_RangeSeparator=..
+ObjectContext_MultipleNodes=<multiple nodes>
 ObjectNameValidator_ErrorMessage1=Please provide non-empty object name in "%s" field
 ObjectNameValidator_ErrorMessage2=Object name in "%s" field contains invalid characters
 PasswordExpiredDialog_confirm_passwd=Confirm new password:
index d2d9465..915d427 100644 (file)
@@ -108,6 +108,7 @@ LoginJob_sync_users=Synchronizing user database...
 MacAddressValidator_ErrorMessage=Please enter valid MAC address in "%s" field
 NumericTextFieldValidator_ErrorMessage=Please enter number in range %s in field "%s"
 NumericTextFieldValidator_RangeSeparator=..
+ObjectContext_MultipleNodes=<multiple nodes>
 ObjectNameValidator_ErrorMessage1=Please provide non-empty object name in "%s" field
 ObjectNameValidator_ErrorMessage2=Object name in "%s" field contains invalid characters
 PasswordExpiredDialog_confirm_passwd=Confirm new password:
index 32303d9..151da4b 100644 (file)
@@ -108,6 +108,7 @@ LoginJob_sync_users=\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430
 MacAddressValidator_ErrorMessage=\u0423\u043a\u0430\u0436\u0438\u0442\u0435 MAC \u0432 \u043f\u043e\u043b\u0435 "%s"
 NumericTextFieldValidator_ErrorMessage=\u0423\u043a\u0430\u0436\u0438\u0442\u0435 \u0447\u0438\u0441\u043b\u043e \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 %s \u0432 \u043f\u043e\u043b\u0435 "%s"
 NumericTextFieldValidator_RangeSeparator=..
+ObjectContext_MultipleNodes=<\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0443\u0437\u043b\u043e\u0432>
 ObjectNameValidator_ErrorMessage1=\u0423\u043a\u0430\u0436\u0438\u0442\u0435 \u0438\u043c\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u043f\u043e\u043b\u0435 "%s"
 ObjectNameValidator_ErrorMessage2=\u0418\u043c\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u043f\u043e\u043b\u0435 "%s" \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b
 PasswordExpiredDialog_confirm_passwd=\u041d\u043e\u0432\u044b\u0439 \u043f\u0430\u0440\u043e\u043b\u044c (\u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e):
index 2a1f0b9..e94c731 100644 (file)
@@ -108,6 +108,7 @@ LoginJob_sync_users=\u6b63\u5728\u540c\u6b65\u7528\u6237\u6570\u636e\u5e93...
 MacAddressValidator_ErrorMessage=Please enter valid MAC address in "%s" field
 NumericTextFieldValidator_ErrorMessage=Please enter number in range %s in field "%s"
 NumericTextFieldValidator_RangeSeparator=..
+ObjectContext_MultipleNodes=<multiple nodes>
 ObjectNameValidator_ErrorMessage1=Please provide non-empty object name in "%s" field
 ObjectNameValidator_ErrorMessage2=Object name in "%s" field contains invalid characters
 PasswordExpiredDialog_confirm_passwd=\u786e\u8ba4\u65b0\u53e3\u4ee4:
diff --git a/src/java/netxms-eclipse/Core/src/org/netxms/ui/eclipse/objects/ObjectContext.java b/src/java/netxms-eclipse/Core/src/org/netxms/ui/eclipse/objects/ObjectContext.java
new file mode 100644 (file)
index 0000000..faf3e88
--- /dev/null
@@ -0,0 +1,177 @@
+package org.netxms.ui.eclipse.objects;
+
+import java.util.Map;
+import org.netxms.base.NXCommon;
+import org.netxms.client.events.Alarm;
+import org.netxms.client.objects.AbstractNode;
+import org.netxms.ui.eclipse.console.Messages;
+import org.netxms.ui.eclipse.console.resources.StatusDisplayInfo;
+import org.netxms.ui.eclipse.shared.ConsoleSharedData;
+
+/**
+ * Class to hold information about selected node
+ */
+public class ObjectContext
+{
+   public AbstractNode object;
+   public Alarm alarm;
+   
+   public ObjectContext(AbstractNode object, Alarm alarm)
+   {
+      this.object = object;
+      this.alarm = alarm;
+   }
+
+   /* (non-Javadoc)
+    * @see java.lang.Object#hashCode()
+    */
+   @Override
+   public int hashCode()
+   {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((alarm == null) ? 0 : alarm.hashCode());
+      result = prime * result + ((object == null) ? 0 : object.hashCode());
+      return result;
+   }
+
+   /* (non-Javadoc)
+    * @see java.lang.Object#equals(java.lang.Object)
+    */
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (this == obj)
+         return true;
+      if (obj == null)
+         return false;
+      if (getClass() != obj.getClass())
+         return false;
+      ObjectContext other = (ObjectContext)obj;
+      if ((other.object == null) || (this.object == null))
+         return (other.object == null) && (this.object == null);
+      return other.object.getObjectId() == this.object.getObjectId();
+   }
+   
+   /**
+    * Substitute macros in string
+    * 
+    * @param s
+    * @param node
+    * @param inputValues 
+    * @return
+    */
+   public String substituteMacros(String s, Map<String, String> inputValues)
+   {
+      StringBuilder sb = new StringBuilder();
+      
+      char[] src = s.toCharArray();
+      for(int i = 0; i < s.length(); i++)
+      {
+         if (src[i] == '%')
+         {
+            i++;
+            if (i == s.length())
+               break;   // malformed string
+            
+            switch(src[i])
+            {
+               case 'a':
+                  sb.append((object != null) ? object.getPrimaryIP().getHostAddress() : Messages.get().ObjectContext_MultipleNodes);
+                  break;
+               case 'A':   // alarm message
+                  if (alarm != null)
+                     sb.append(alarm.getMessage());
+                  break;
+               case 'c':
+                  if (alarm != null)
+                     sb.append(alarm.getSourceEventCode());
+                  break;
+               case 'g':
+                  sb.append((object != null) ? object.getGuid().toString() : Messages.get().ObjectContext_MultipleNodes);
+                  break;
+               case 'i':
+                  sb.append((object != null) ? String.format("0x%08X", object.getObjectId()) : Messages.get().ObjectContext_MultipleNodes); //$NON-NLS-1$
+                  break;
+               case 'I':
+                  sb.append((object != null) ? Long.toString(object.getObjectId()) : Messages.get().ObjectContext_MultipleNodes);
+                  break;
+               case 'm':   // alarm message
+                  if (alarm != null)
+                     sb.append(alarm.getMessage());
+                  break;
+               case 'n':
+                  sb.append((object != null) ? object.getObjectName() : Messages.get().ObjectContext_MultipleNodes);
+                  break;
+               case 'N':
+                  if (alarm != null)
+                     sb.append(ConsoleSharedData.getSession().getEventName(alarm.getSourceEventCode()));
+                  break;
+               case 's':
+                  if (alarm != null)
+                     sb.append(alarm.getCurrentSeverity());
+                  break;
+               case 'S':
+                  if (alarm != null)
+                     sb.append(StatusDisplayInfo.getStatusText(alarm.getCurrentSeverity()));
+                  break;
+               case 'U':
+                  sb.append(ConsoleSharedData.getSession().getUserName());
+                  break;
+               case 'v':
+                  sb.append(NXCommon.VERSION);
+                  break;
+               case 'y':   // alarm state
+                  if (alarm != null)
+                     sb.append(alarm.getState());
+                  break;
+               case 'Y':   // alarm ID
+                  if (alarm != null)
+                     sb.append(alarm.getId());
+                  break;
+               case '%':
+                  sb.append('%');
+                  break;
+               case '{':   // object's custom attribute
+                  StringBuilder attr = new StringBuilder();
+                  for(i++; i < s.length(); i++)
+                  {
+                     if (src[i] == '}')
+                        break;
+                     attr.append(src[i]);
+                  }
+                  if ((object != null) && (attr.length() > 0))
+                  {
+                     String value = object.getCustomAttributes().get(attr.toString());
+                     if (value != null)
+                        sb.append(value);
+                  }
+                  break;
+               case '(':   // input field
+                  StringBuilder name = new StringBuilder();
+                  for(i++; i < s.length(); i++)
+                  {
+                     if (src[i] == ')')
+                        break;
+                     name.append(src[i]);
+                  }
+                  if (name.length() > 0)
+                  {
+                     String value = inputValues.get(name.toString());
+                     if (value != null)
+                        sb.append(value);
+                  }
+                  break;
+               default:
+                  break;
+            }
+         }
+         else
+         {
+            sb.append(src[i]);
+         }
+      }
+      
+      return sb.toString();
+   }
+}
\ No newline at end of file
index 77b7a0c..d7012f8 100644 (file)
@@ -44,8 +44,8 @@ import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.ui.dialogs.PropertyPage;
+import org.netxms.client.datacollection.ChartDciConfig;
 import org.netxms.client.datacollection.DciValue;
-import org.netxms.ui.eclipse.charts.api.ChartDciConfig;
 import org.netxms.ui.eclipse.dashboard.Messages;
 import org.netxms.ui.eclipse.dashboard.propertypages.helpers.DciListLabelProvider;
 import org.netxms.ui.eclipse.dashboard.widgets.internal.AbstractChartConfig;
@@ -327,7 +327,7 @@ public class DataSources extends PropertyPage
                if (dci == null)
                        return;
                
-               DataSourceEditDlg dlg = new DataSourceEditDlg(getShell(), dci);
+               DataSourceEditDlg dlg = new DataSourceEditDlg(getShell(), dci, false);
                if (dlg.open() == Window.OK)
                {
                        viewer.update(dci, null);
index 5f578e4..807555c 100644 (file)
@@ -27,8 +27,8 @@ import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.swt.graphics.Image;
 import org.netxms.client.NXCSession;
+import org.netxms.client.datacollection.ChartDciConfig;
 import org.netxms.client.objects.AbstractObject;
-import org.netxms.ui.eclipse.charts.api.ChartDciConfig;
 import org.netxms.ui.eclipse.dashboard.Activator;
 import org.netxms.ui.eclipse.dashboard.Messages;
 import org.netxms.ui.eclipse.dashboard.propertypages.DataSources;
index 2fd3aab..1a98bbf 100644 (file)
@@ -21,9 +21,9 @@ package org.netxms.ui.eclipse.dashboard.widgets;
 import org.eclipse.swt.SWT;
 import org.eclipse.ui.IViewPart;
 import org.netxms.client.dashboards.DashboardElement;
+import org.netxms.client.datacollection.ChartDciConfig;
 import org.netxms.client.datacollection.GraphItem;
 import org.netxms.ui.eclipse.charts.api.ChartColor;
-import org.netxms.ui.eclipse.charts.api.ChartDciConfig;
 import org.netxms.ui.eclipse.charts.api.ChartFactory;
 import org.netxms.ui.eclipse.dashboard.widgets.internal.BarChartConfig;
 
index 1579715..b94843a 100644 (file)
@@ -31,9 +31,9 @@ import org.eclipse.swt.widgets.Widget;
 import org.eclipse.ui.IViewPart;
 import org.netxms.client.NXCSession;
 import org.netxms.client.dashboards.DashboardElement;
+import org.netxms.client.datacollection.ChartDciConfig;
 import org.netxms.client.datacollection.DciData;
 import org.netxms.client.datacollection.DciDataRow;
-import org.netxms.ui.eclipse.charts.api.ChartDciConfig;
 import org.netxms.ui.eclipse.charts.api.DataComparisonChart;
 import org.netxms.ui.eclipse.dashboard.Activator;
 import org.netxms.ui.eclipse.dashboard.Messages;
index 898ae4a..9c97dc0 100644 (file)
@@ -21,9 +21,9 @@ package org.netxms.ui.eclipse.dashboard.widgets;
 import org.eclipse.swt.SWT;
 import org.eclipse.ui.IViewPart;
 import org.netxms.client.dashboards.DashboardElement;
+import org.netxms.client.datacollection.ChartDciConfig;
 import org.netxms.client.datacollection.GraphItem;
 import org.netxms.ui.eclipse.charts.api.ChartColor;
-import org.netxms.ui.eclipse.charts.api.ChartDciConfig;
 import org.netxms.ui.eclipse.charts.api.ChartFactory;
 import org.netxms.ui.eclipse.charts.api.Gauge;
 import org.netxms.ui.eclipse.charts.api.GaugeColorMode;
index 9c19752..a8e64fc 100644 (file)
@@ -41,12 +41,12 @@ import org.eclipse.swt.widgets.Widget;
 import org.eclipse.ui.IViewPart;
 import org.netxms.client.NXCSession;
 import org.netxms.client.dashboards.DashboardElement;
+import org.netxms.client.datacollection.ChartDciConfig;
 import org.netxms.client.datacollection.DciData;
 import org.netxms.client.datacollection.GraphItem;
 import org.netxms.client.datacollection.GraphItemStyle;
 import org.netxms.ui.eclipse.actions.RefreshAction;
 import org.netxms.ui.eclipse.charts.api.ChartColor;
-import org.netxms.ui.eclipse.charts.api.ChartDciConfig;
 import org.netxms.ui.eclipse.charts.api.ChartFactory;
 import org.netxms.ui.eclipse.charts.api.HistoricalDataChart;
 import org.netxms.ui.eclipse.dashboard.Activator;
index 5d669cd..0af306a 100644 (file)
@@ -23,10 +23,10 @@ import org.eclipse.swt.SWT;
 import org.eclipse.ui.IViewPart;
 import org.netxms.client.constants.ObjectStatus;
 import org.netxms.client.dashboards.DashboardElement;
+import org.netxms.client.datacollection.ChartDciConfig;
 import org.netxms.client.datacollection.GraphItem;
 import org.netxms.client.objects.AbstractObject;
 import org.netxms.ui.eclipse.charts.api.ChartColor;
-import org.netxms.ui.eclipse.charts.api.ChartDciConfig;
 import org.netxms.ui.eclipse.charts.api.ChartFactory;
 import org.netxms.ui.eclipse.console.resources.StatusDisplayInfo;
 import org.netxms.ui.eclipse.dashboard.widgets.internal.ObjectStatusChartConfig;
index 92874eb..63f1456 100644 (file)
@@ -22,9 +22,9 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.ui.IViewPart;
 import org.netxms.client.dashboards.DashboardElement;
+import org.netxms.client.datacollection.ChartDciConfig;
 import org.netxms.client.datacollection.GraphItem;
 import org.netxms.ui.eclipse.charts.api.ChartColor;
-import org.netxms.ui.eclipse.charts.api.ChartDciConfig;
 import org.netxms.ui.eclipse.charts.api.ChartFactory;
 import org.netxms.ui.eclipse.dashboard.widgets.internal.PieChartConfig;
 
index 6d4ec0d..e7b158a 100644 (file)
@@ -21,9 +21,9 @@ package org.netxms.ui.eclipse.dashboard.widgets;
 import org.eclipse.swt.SWT;
 import org.eclipse.ui.IViewPart;
 import org.netxms.client.dashboards.DashboardElement;
+import org.netxms.client.datacollection.ChartDciConfig;
 import org.netxms.client.datacollection.GraphItem;
 import org.netxms.ui.eclipse.charts.api.ChartColor;
-import org.netxms.ui.eclipse.charts.api.ChartDciConfig;
 import org.netxms.ui.eclipse.charts.api.ChartFactory;
 import org.netxms.ui.eclipse.dashboard.widgets.internal.TubeChartConfig;
 
index 7bdb7a2..c1d05c9 100644 (file)
@@ -20,8 +20,8 @@ package org.netxms.ui.eclipse.dashboard.widgets.internal;
 
 import java.util.Map;
 import java.util.Set;
+import org.netxms.client.datacollection.ChartDciConfig;
 import org.netxms.client.datacollection.GraphSettings;
-import org.netxms.ui.eclipse.charts.api.ChartDciConfig;
 import org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData;
 import org.simpleframework.xml.Element;
 import org.simpleframework.xml.ElementArray;
index e39abf1..57b42e5 100644 (file)
@@ -40,7 +40,7 @@ public class NetworkMapConfig extends DashboardElementConfig
        
        @Element(required=false)
        private int zoomLevel = 100;    // in percents
-       
+
    @Element(required=false)
        private boolean objectDoubleClickEnabled = false;
 
index 55d743a..2ddf6cd 100644 (file)
@@ -31,7 +31,7 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Shell;
-import org.netxms.ui.eclipse.charts.api.ChartDciConfig;
+import org.netxms.client.datacollection.ChartDciConfig;
 import org.netxms.ui.eclipse.datacollection.Messages;
 import org.netxms.ui.eclipse.datacollection.widgets.DciSelector;
 import org.netxms.ui.eclipse.tools.ColorConverter;
@@ -47,23 +47,28 @@ public class DataSourceEditDlg extends Dialog
        private DciSelector dciSelector;
        private LabeledText name;
    private LabeledText displayFormat;
+   private LabeledText dciName;
+   private LabeledText dciDescription;
        private Button colorAuto;
        private Button colorCustom;
        private ColorSelector colorSelector;
        private Combo displayType;
        private Button checkShowThresholds;
        private Button checkInvertValues;
+   private Button checkMultipeMatch;
        private LabeledText instance;
        private LabeledText dataColumn;
+       private boolean graphIsTemplate;
        
        /**
         * @param parentShell
         * @param dci
         */
-       public DataSourceEditDlg(Shell parentShell, ChartDciConfig dci)
+       public DataSourceEditDlg(Shell parentShell, ChartDciConfig dci, boolean graphIsTemplate)
        {
                super(parentShell);
                this.dci = dci;
+               this.graphIsTemplate = graphIsTemplate;
        }
 
        /* (non-Javadoc)
@@ -89,17 +94,20 @@ public class DataSourceEditDlg extends Dialog
                layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
                layout.numColumns = 2;
                dialogArea.setLayout(layout);
-               
-               dciSelector = new DciSelector(dialogArea, SWT.NONE, false);
-               dciSelector.setLabel(Messages.get().DataSourceEditDlg_DCI);
-               dciSelector.setDciId(dci.nodeId, dci.dciId);
-               dciSelector.setDcObjectType(dci.type);
-               GridData gd = new GridData();
-               gd.horizontalAlignment = SWT.FILL;
-               gd.grabExcessHorizontalSpace = true;
-               gd.widthHint = 400;
-               gd.horizontalSpan = 2;
-               dciSelector.setLayoutData(gd);
+
+      GridData gd = new GridData();
+               if(!graphIsTemplate)
+      {
+               dciSelector = new DciSelector(dialogArea, SWT.NONE, false);
+               dciSelector.setLabel(Messages.get().DataSourceEditDlg_DCI);
+               dciSelector.setDciId(dci.nodeId, dci.dciId);
+               dciSelector.setDcObjectType(dci.type);
+               gd.horizontalAlignment = SWT.FILL;
+               gd.grabExcessHorizontalSpace = true;
+               gd.widthHint = 400;
+               gd.horizontalSpan = 2;
+               dciSelector.setLayoutData(gd);
+      }
                
                name = new LabeledText(dialogArea, SWT.NONE);
                name.setLabel(Messages.get().DataSourceEditDlg_DispName);
@@ -119,6 +127,27 @@ public class DataSourceEditDlg extends Dialog
       gd.horizontalSpan = 2;
       displayFormat.setLayoutData(gd);
       
+               if(graphIsTemplate)
+               {
+                  dciName = new LabeledText(dialogArea, SWT.NONE);
+                  dciName.setLabel("DCI Name");
+                  dciName.setText(dci.dciName);
+             gd = new GridData();
+             gd.horizontalAlignment = SWT.FILL;
+             gd.grabExcessHorizontalSpace = true;
+             gd.horizontalSpan = 2;
+             dciName.setLayoutData(gd);              
+
+             dciDescription = new LabeledText(dialogArea, SWT.NONE);
+             dciDescription.setLabel("DCI Description");
+             dciDescription.setText(dci.dciDescription);
+         gd = new GridData();
+         gd.horizontalAlignment = SWT.FILL;
+         gd.grabExcessHorizontalSpace = true;
+         gd.horizontalSpan = 2;
+         dciDescription.setLayoutData(gd);
+               }
+               
                if (dci.type == ChartDciConfig.TABLE)
                {
                        Group tableGroup = new Group(dialogArea, SWT.NONE);
@@ -179,6 +208,13 @@ public class DataSourceEditDlg extends Dialog
       checkInvertValues = new Button(optionsGroup, SWT.CHECK);
       checkInvertValues.setText(Messages.get().DataSourceEditDlg_InvertValues);
       checkInvertValues.setSelection(dci.invertValues);
+      
+      if(graphIsTemplate)
+      {
+         checkMultipeMatch = new Button(optionsGroup, SWT.CHECK);
+         checkMultipeMatch.setText("Multiple match");
+         checkMultipeMatch.setSelection(dci.multiMatch);         
+      }
 
       /*** Color group ***/
                Group colorGroup = new Group(dialogArea, SWT.NONE);
@@ -247,8 +283,17 @@ public class DataSourceEditDlg extends Dialog
        @Override
        protected void okPressed()
        {
-               dci.nodeId = dciSelector.getNodeId();
-               dci.dciId = dciSelector.getDciId();
+      if(graphIsTemplate)
+      {
+         dci.dciName = dciName.getText();
+         dci.dciDescription = dciDescription.getText();
+         dci.multiMatch = checkMultipeMatch.getSelection();
+      }
+      else
+      {
+               dci.nodeId = dciSelector.getNodeId();
+               dci.dciId = dciSelector.getDciId();
+      }
                dci.name = name.getText();
                dci.displayFormat = displayFormat.getText();
                if (colorAuto.getSelection())
index 6d82263..dceab33 100644 (file)
             id="org.netxms.ui.eclipse.objecttools.propertypages.Filter#3"
             name="%page.name.Filter">
          <enabledWhen>
-            <instanceof
-                  value="org.netxms.client.objecttools.ObjectTool">
-            </instanceof>
+            <or>
+               <instanceof
+                     value="org.netxms.client.objecttools.ObjectTool">
+               </instanceof>
+               <and>
+                  <instanceof
+                        value="org.netxms.client.datacollection.GraphSettings">
+                  </instanceof>
+                  <test
+                        property="org.netxms.ui.eclipse.perfview.isTemplateGraph">
+                  </test>
+               </and>
+            </or>
          </enabledWhen>
       </page>
       <page
index bcd123c..f56050e 100644 (file)
@@ -122,7 +122,6 @@ public class Messages extends NLS
    public static String ObjectToolsDynamicMenu_ExecuteServerCmd;
    public static String ObjectToolsDynamicMenu_HandlerNotDefined;
    public static String ObjectToolsDynamicMenu_Information;
-   public static String ObjectToolsDynamicMenu_MultipleNodes;
    public static String ObjectToolsDynamicMenu_ServerCmdExecError;
    public static String ObjectToolsDynamicMenu_ServerCommandExecuted;
    public static String ObjectToolsDynamicMenu_ServerScriptExecError;
index 9eb419a..3fd434f 100644 (file)
@@ -47,8 +47,8 @@ import org.netxms.client.objects.Container;
 import org.netxms.client.objects.ServiceRoot;
 import org.netxms.client.objects.Subnet;
 import org.netxms.client.objecttools.ObjectTool;
+import org.netxms.ui.eclipse.objects.ObjectContext;
 import org.netxms.ui.eclipse.objects.ObjectWrapper;
-import org.netxms.ui.eclipse.objecttools.api.NodeInfo;
 import org.netxms.ui.eclipse.objecttools.api.ObjectToolExecutor;
 import org.netxms.ui.eclipse.objecttools.api.ObjectToolsCache;
 import org.netxms.ui.eclipse.shared.ConsoleSharedData;
@@ -98,7 +98,7 @@ public class ObjectToolsDynamicMenu extends ContributionItem implements IWorkben
                if ((selection == null) || !(selection instanceof IStructuredSelection))
                        return;
 
-               final Set<NodeInfo> nodes = buildNodeSet((IStructuredSelection)selection);
+               final Set<ObjectContext> nodes = buildNodeSet((IStructuredSelection)selection);
                final Menu toolsMenu = new Menu(menu);
                
                final ImageCache imageCache = new ImageCache();
@@ -180,33 +180,33 @@ public class ObjectToolsDynamicMenu extends ContributionItem implements IWorkben
         * @param selection
         * @return
         */
-       private Set<NodeInfo> buildNodeSet(IStructuredSelection selection)
+       private Set<ObjectContext> buildNodeSet(IStructuredSelection selection)
        {
-               final Set<NodeInfo> nodes = new HashSet<NodeInfo>();
+               final Set<ObjectContext> nodes = new HashSet<ObjectContext>();
                final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
                
                for(Object o : selection.toList())
                {
                        if (o instanceof AbstractNode)
                        {
-                               nodes.add(new NodeInfo((AbstractNode)o, null));
+                               nodes.add(new ObjectContext((AbstractNode)o, null));
                        }
                        else if ((o instanceof Container) || (o instanceof ServiceRoot) || (o instanceof Subnet) || (o instanceof Cluster))
                        {
                                for(AbstractObject n : ((AbstractObject)o).getAllChilds(AbstractObject.OBJECT_NODE))
-                                       nodes.add(new NodeInfo((AbstractNode)n, null));
+                                       nodes.add(new ObjectContext((AbstractNode)n, null));
                        }
                        else if (o instanceof Alarm)
                        {
                                AbstractNode n = (AbstractNode)session.findObjectById(((Alarm)o).getSourceObjectId(), AbstractNode.class);
                                if (n != null)
-                                       nodes.add(new NodeInfo(n, (Alarm)o));
+                                       nodes.add(new ObjectContext(n, (Alarm)o));
                        } 
                        else if (o instanceof ObjectWrapper)
                        {
                           AbstractObject n = ((ObjectWrapper)o).getObject();
                           if ((n != null) && (n instanceof AbstractNode))
-                             nodes.add(new NodeInfo((AbstractNode)n, null));
+                             nodes.add(new ObjectContext((AbstractNode)n, null));
                        }
                }
                return nodes;
diff --git a/src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/api/NodeInfo.java b/src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/api/NodeInfo.java
deleted file mode 100644 (file)
index 55efb33..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.netxms.ui.eclipse.objecttools.api;
-
-import org.netxms.client.events.Alarm;
-import org.netxms.client.objects.AbstractNode;
-
-/**
- * Class to hold information about selected node
- */
-public class NodeInfo
-{
-   AbstractNode object;
-   Alarm alarm;
-   
-   public NodeInfo(AbstractNode object, Alarm alarm)
-   {
-      this.object = object;
-      this.alarm = alarm;
-   }
-
-   /* (non-Javadoc)
-    * @see java.lang.Object#hashCode()
-    */
-   @Override
-   public int hashCode()
-   {
-      final int prime = 31;
-      int result = 1;
-      result = prime * result + ((alarm == null) ? 0 : alarm.hashCode());
-      result = prime * result + ((object == null) ? 0 : object.hashCode());
-      return result;
-   }
-
-   /* (non-Javadoc)
-    * @see java.lang.Object#equals(java.lang.Object)
-    */
-   @Override
-   public boolean equals(Object obj)
-   {
-      if (this == obj)
-         return true;
-      if (obj == null)
-         return false;
-      if (getClass() != obj.getClass())
-         return false;
-      NodeInfo other = (NodeInfo)obj;
-      if ((other.object == null) || (this.object == null))
-         return (other.object == null) && (this.object == null);
-      return other.object.getObjectId() == this.object.getObjectId();
-   }
-}
\ No newline at end of file
index f6784bb..32b8d96 100644 (file)
@@ -34,15 +34,14 @@ import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
-import org.netxms.base.NXCommon;
 import org.netxms.client.AgentFileData;
 import org.netxms.client.NXCSession;
 import org.netxms.client.objecttools.InputField;
 import org.netxms.client.objecttools.InputFieldType;
 import org.netxms.client.objecttools.ObjectTool;
-import org.netxms.ui.eclipse.console.resources.StatusDisplayInfo;
 import org.netxms.ui.eclipse.filemanager.views.AgentFileViewer;
 import org.netxms.ui.eclipse.jobs.ConsoleJob;
+import org.netxms.ui.eclipse.objects.ObjectContext;
 import org.netxms.ui.eclipse.objecttools.Activator;
 import org.netxms.ui.eclipse.objecttools.Messages;
 import org.netxms.ui.eclipse.objecttools.dialogs.ObjectToolInputDialog;
@@ -74,7 +73,7 @@ public final class ObjectToolExecutor
     * @param nodes
     * @return
     */
-   public static boolean isToolAllowed(ObjectTool tool, Set<NodeInfo> nodes)
+   public static boolean isToolAllowed(ObjectTool tool, Set<ObjectContext> nodes)
    {
       if (tool.getType() != ObjectTool.TYPE_INTERNAL)
          return true;
@@ -82,7 +81,7 @@ public final class ObjectToolExecutor
       ObjectToolHandler handler = ObjectToolsCache.findHandler(tool.getData());
       if (handler != null)
       {
-         for(NodeInfo n : nodes)
+         for(ObjectContext n : nodes)
             if (!handler.canExecuteOnNode(n.object, tool))
                return false;
          return true;
@@ -100,9 +99,9 @@ public final class ObjectToolExecutor
     * @param nodes
     * @return
     */
-   public static boolean isToolApplicable(ObjectTool tool, Set<NodeInfo> nodes)
+   public static boolean isToolApplicable(ObjectTool tool, Set<ObjectContext> nodes)
    {
-      for(NodeInfo n : nodes)
+      for(ObjectContext n : nodes)
          if (!tool.isApplicableForNode(n.object))
             return false;
       return true;
@@ -113,7 +112,7 @@ public final class ObjectToolExecutor
     * 
     * @param tool Object tool
     */
-   public static void execute(final Set<NodeInfo> nodes, final ObjectTool tool)
+   public static void execute(final Set<ObjectContext> nodes, final ObjectTool tool)
    {
       final Map<String, String> inputValues;
       final InputField[] fields = tool.getInputFields();
@@ -140,12 +139,12 @@ public final class ObjectToolExecutor
          String message = tool.getConfirmationText();
          if (nodes.size() == 1)
          {
-            NodeInfo node = nodes.iterator().next();
-            message = substituteMacros(message, node, new HashMap<String, String>(0));
+            ObjectContext node = nodes.iterator().next();
+            message = node.substituteMacros(message, new HashMap<String, String>(0));
          }
          else
          {
-            message = substituteMacros(message, new NodeInfo(null, null), new HashMap<String, String>(0));
+            message = new ObjectContext(null, null).substituteMacros(message, new HashMap<String, String>(0));
          }
          if (!MessageDialogHelper.openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 
                Messages.get().ObjectToolsDynamicMenu_ConfirmExec, message))
@@ -193,7 +192,7 @@ public final class ObjectToolExecutor
                   @Override
                   public void run()
                   {
-                     for(NodeInfo n : nodes)
+                     for(ObjectContext n : nodes)
                         executeOnNode(n, tool, inputValues);
                   }
                });
@@ -208,7 +207,7 @@ public final class ObjectToolExecutor
       }
       else
       {
-         for(NodeInfo n : nodes)
+         for(ObjectContext n : nodes)
             executeOnNode(n, tool, inputValues);
       }
    }
@@ -234,7 +233,7 @@ public final class ObjectToolExecutor
     * @param tool
     * @param inputValues 
     */
-   private static void executeOnNode(final NodeInfo node, final ObjectTool tool, Map<String, String> inputValues)
+   private static void executeOnNode(final ObjectContext node, final ObjectTool tool, Map<String, String> inputValues)
    {
       switch(tool.getType())
       {
@@ -272,7 +271,7 @@ public final class ObjectToolExecutor
     * @param node
     * @param tool
     */
-   private static void executeTableTool(final NodeInfo node, final ObjectTool tool)
+   private static void executeTableTool(final ObjectContext node, final ObjectTool tool)
    {
       final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
       try
@@ -376,10 +375,10 @@ public final class ObjectToolExecutor
     * @param tool
     * @param inputValues 
     */
-   private static void executeAgentAction(final NodeInfo node, final ObjectTool tool, Map<String, String> inputValues)
+   private static void executeAgentAction(final ObjectContext node, final ObjectTool tool, Map<String, String> inputValues)
    {
       final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
-      String[] parts = splitCommandLine(substituteMacros(tool.getData(), node, inputValues));
+      String[] parts = splitCommandLine(node.substituteMacros(tool.getData(), inputValues));
       final String action = parts[0];
       final String[] args = Arrays.copyOfRange(parts, 1, parts.length);
       
@@ -429,7 +428,7 @@ public final class ObjectToolExecutor
     * @param tool
     * @param inputValues 
     */
-   private static void executeServerCommand(final NodeInfo node, final ObjectTool tool, final Map<String, String> inputValues)
+   private static void executeServerCommand(final ObjectContext node, final ObjectTool tool, final Map<String, String> inputValues)
    {
       final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
       if ((tool.getFlags() & ObjectTool.GENERATES_OUTPUT) == 0)
@@ -478,7 +477,7 @@ public final class ObjectToolExecutor
     * @param tool
     * @param inputValues 
     */
-   private static void executeServerScript(final NodeInfo node, final ObjectTool tool, final Map<String, String> inputValues)
+   private static void executeServerScript(final ObjectContext node, final ObjectTool tool, final Map<String, String> inputValues)
    {
       final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
       if ((tool.getFlags() & ObjectTool.GENERATES_OUTPUT) == 0)
@@ -527,9 +526,9 @@ public final class ObjectToolExecutor
     * @param tool
     * @param inputValues 
     */
-   private static void executeLocalCommand(final NodeInfo node, final ObjectTool tool, Map<String, String> inputValues)
+   private static void executeLocalCommand(final ObjectContext node, final ObjectTool tool, Map<String, String> inputValues)
    {
-      String command = substituteMacros(tool.getData(), node, inputValues);
+      String command = node.substituteMacros(tool.getData(), inputValues);
       
       if ((tool.getFlags() & ObjectTool.GENERATES_OUTPUT) == 0)
       {
@@ -574,12 +573,12 @@ public final class ObjectToolExecutor
     * @param tool
     * @param inputValues 
     */
-   private static void executeFileDownload(final NodeInfo node, final ObjectTool tool, Map<String, String> inputValues)
+   private static void executeFileDownload(final ObjectContext node, final ObjectTool tool, Map<String, String> inputValues)
    {
       final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
       String[] parameters = tool.getData().split("\u007F"); //$NON-NLS-1$
       
-      final String fileName = substituteMacros(parameters[0], node, inputValues);
+      final String fileName = node.substituteMacros(parameters[0], inputValues);
       final int maxFileSize = Integer.parseInt(parameters[1]);
       final boolean follow = parameters[2].equals("true") ? true : false; //$NON-NLS-1$
       
@@ -619,7 +618,7 @@ public final class ObjectToolExecutor
     * @param node
     * @param tool
     */
-   private static void executeInternalTool(final NodeInfo node, final ObjectTool tool)
+   private static void executeInternalTool(final ObjectContext node, final ObjectTool tool)
    {
       ObjectToolHandler handler = ObjectToolsCache.findHandler(tool.getData());
       if (handler != null)
@@ -637,9 +636,9 @@ public final class ObjectToolExecutor
     * @param tool
     * @param inputValues 
     */
-   private static void openURL(final NodeInfo node, final ObjectTool tool, Map<String, String> inputValues)
+   private static void openURL(final ObjectContext node, final ObjectTool tool, Map<String, String> inputValues)
    {
-      final String url = substituteMacros(tool.getData(), node, inputValues);
+      final String url = node.substituteMacros(tool.getData(), inputValues);
       
       final String sid = Long.toString(node.object.getObjectId()) + "&" + Long.toString(tool.getId()); //$NON-NLS-1$
       final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
@@ -653,126 +652,4 @@ public final class ObjectToolExecutor
          MessageDialogHelper.openError(window.getShell(), Messages.get().ObjectToolsDynamicMenu_Error, Messages.get().ObjectToolsDynamicMenu_CannotOpenWebBrowser + e.getLocalizedMessage());
       }
    }
-   
-   /**
-    * Substitute macros in string
-    * 
-    * @param s
-    * @param node
-    * @param inputValues 
-    * @return
-    */
-   private static String substituteMacros(String s, NodeInfo node, Map<String, String> inputValues)
-   {
-      StringBuilder sb = new StringBuilder();
-      
-      char[] src = s.toCharArray();
-      for(int i = 0; i < s.length(); i++)
-      {
-         if (src[i] == '%')
-         {
-            i++;
-            if (i == s.length())
-               break;   // malformed string
-            
-            switch(src[i])
-            {
-               case 'a':
-                  sb.append((node.object != null) ? node.object.getPrimaryIP().getHostAddress() : Messages.get().ObjectToolsDynamicMenu_MultipleNodes);
-                  break;
-               case 'A':   // alarm message
-                  if (node.alarm != null)
-                     sb.append(node.alarm.getMessage());
-                  break;
-               case 'c':
-                  if (node.alarm != null)
-                     sb.append(node.alarm.getSourceEventCode());
-                  break;
-               case 'g':
-                  sb.append((node.object != null) ? node.object.getGuid().toString() : Messages.get().ObjectToolsDynamicMenu_MultipleNodes);
-                  break;
-               case 'i':
-                  sb.append((node.object != null) ? String.format("0x%08X", node.object.getObjectId()) : Messages.get().ObjectToolsDynamicMenu_MultipleNodes); //$NON-NLS-1$
-                  break;
-               case 'I':
-                  sb.append((node.object != null) ? Long.toString(node.object.getObjectId()) : Messages.get().ObjectToolsDynamicMenu_MultipleNodes);
-                  break;
-               case 'm':   // alarm message
-                  if (node.alarm != null)
-                     sb.append(node.alarm.getMessage());
-                  break;
-               case 'n':
-                  sb.append((node.object != null) ? node.object.getObjectName() : Messages.get().ObjectToolsDynamicMenu_MultipleNodes);
-                  break;
-               case 'N':
-                  if (node.alarm != null)
-                     sb.append(ConsoleSharedData.getSession().getEventName(node.alarm.getSourceEventCode()));
-                  break;
-               case 's':
-                  if (node.alarm != null)
-                     sb.append(node.alarm.getCurrentSeverity());
-                  break;
-               case 'S':
-                  if (node.alarm != null)
-                     sb.append(StatusDisplayInfo.getStatusText(node.alarm.getCurrentSeverity()));
-                  break;
-               case 'U':
-                  sb.append(ConsoleSharedData.getSession().getUserName());
-                  break;
-               case 'v':
-                  sb.append(NXCommon.VERSION);
-                  break;
-               case 'y':   // alarm state
-                  if (node.alarm != null)
-                     sb.append(node.alarm.getState());
-                  break;
-               case 'Y':   // alarm ID
-                  if (node.alarm != null)
-                     sb.append(node.alarm.getId());
-                  break;
-               case '%':
-                  sb.append('%');
-                  break;
-               case '{':   // object's custom attribute
-                  StringBuilder attr = new StringBuilder();
-                  for(i++; i < s.length(); i++)
-                  {
-                     if (src[i] == '}')
-                        break;
-                     attr.append(src[i]);
-                  }
-                  if ((node.object != null) && (attr.length() > 0))
-                  {
-                     String value = node.object.getCustomAttributes().get(attr.toString());
-                     if (value != null)
-                        sb.append(value);
-                  }
-                  break;
-               case '(':   // input field
-                  StringBuilder name = new StringBuilder();
-                  for(i++; i < s.length(); i++)
-                  {
-                     if (src[i] == ')')
-                        break;
-                     name.append(src[i]);
-                  }
-                  if (name.length() > 0)
-                  {
-                     String value = inputValues.get(name.toString());
-                     if (value != null)
-                        sb.append(value);
-                  }
-                  break;
-               default:
-                  break;
-            }
-         }
-         else
-         {
-            sb.append(src[i]);
-         }
-      }
-      
-      return sb.toString();
-   }
 }
index 0fd09a6..fe48e6a 100644 (file)
@@ -115,7 +115,6 @@ ObjectToolsDynamicMenu_ExecuteOnNode=Execute action on node %s
 ObjectToolsDynamicMenu_ExecuteServerCmd=Execute server command
 ObjectToolsDynamicMenu_HandlerNotDefined=Cannot execute object tool: handler not defined
 ObjectToolsDynamicMenu_Information=Information
-ObjectToolsDynamicMenu_MultipleNodes=<multiple nodes>
 ObjectToolsDynamicMenu_ServerCmdExecError=Cannot execute command on server
 ObjectToolsDynamicMenu_ServerCommandExecuted=Server command executed successfully
 ObjectToolsDynamicMenu_ServerScriptExecError=Cannot execute script on server
index 60441b1..aae4021 100644 (file)
@@ -115,7 +115,6 @@ ObjectToolsDynamicMenu_ExecuteOnNode=Execute action on node %s
 ObjectToolsDynamicMenu_ExecuteServerCmd=Execute server command
 ObjectToolsDynamicMenu_HandlerNotDefined=Cannot execute object tool: handler not defined
 ObjectToolsDynamicMenu_Information=Information
-ObjectToolsDynamicMenu_MultipleNodes=<multiple nodes>
 ObjectToolsDynamicMenu_ServerCmdExecError=Cannot execute command on server
 ObjectToolsDynamicMenu_ServerCommandExecuted=Server command executed successfully
 ObjectToolsDynamicMenu_ServerScriptExecError=Cannot execute script on server
index c8082e9..4ef533b 100644 (file)
@@ -115,7 +115,6 @@ ObjectToolsDynamicMenu_ExecuteOnNode=Spustit akci na prvku %s
 ObjectToolsDynamicMenu_ExecuteServerCmd=Spustit p\u0159\u00edkaz serveru
 ObjectToolsDynamicMenu_HandlerNotDefined=Nelze spustit n\u00e1stroj objektu\: handler nen\u00ed definov\u00e1n
 ObjectToolsDynamicMenu_Information=Informace
-ObjectToolsDynamicMenu_MultipleNodes=<v\u00edce prvk\u016f>
 ObjectToolsDynamicMenu_ServerCmdExecError=Nelze spustit p\u0159\u00edkaz na serveru
 ObjectToolsDynamicMenu_ServerCommandExecuted=P\u0159\u00edkaz serveru usp\u011b\u0161n\u011b spu\u0161t\u011bn
 ObjectToolsDynamicMenu_ServerScriptExecError=Cannot execute script on server
index 005cd51..8492737 100644 (file)
@@ -115,7 +115,6 @@ ObjectToolsDynamicMenu_ExecuteOnNode=Execute action on node %s
 ObjectToolsDynamicMenu_ExecuteServerCmd=Execute server command
 ObjectToolsDynamicMenu_HandlerNotDefined=Cannot execute object tool: handler not defined
 ObjectToolsDynamicMenu_Information=Information
-ObjectToolsDynamicMenu_MultipleNodes=<multiple nodes>
 ObjectToolsDynamicMenu_ServerCmdExecError=Canot execute command on server
 ObjectToolsDynamicMenu_ServerCommandExecuted=Server command executed successfully
 ObjectToolsDynamicMenu_ServerScriptExecError=Cannot execute script on server
index d6fe2b5..ec72631 100644 (file)
@@ -115,7 +115,6 @@ ObjectToolsDynamicMenu_ExecuteOnNode=Execute action on node %s
 ObjectToolsDynamicMenu_ExecuteServerCmd=Execute server command
 ObjectToolsDynamicMenu_HandlerNotDefined=Cannot execute object tool: handler not defined
 ObjectToolsDynamicMenu_Information=Information
-ObjectToolsDynamicMenu_MultipleNodes=<multiple nodes>
 ObjectToolsDynamicMenu_ServerCmdExecError=Canot execute command on server
 ObjectToolsDynamicMenu_ServerCommandExecuted=Server command executed successfully
 ObjectToolsDynamicMenu_ServerScriptExecError=Cannot execute script on server
index 005cd51..8492737 100644 (file)
@@ -115,7 +115,6 @@ ObjectToolsDynamicMenu_ExecuteOnNode=Execute action on node %s
 ObjectToolsDynamicMenu_ExecuteServerCmd=Execute server command
 ObjectToolsDynamicMenu_HandlerNotDefined=Cannot execute object tool: handler not defined
 ObjectToolsDynamicMenu_Information=Information
-ObjectToolsDynamicMenu_MultipleNodes=<multiple nodes>
 ObjectToolsDynamicMenu_ServerCmdExecError=Canot execute command on server
 ObjectToolsDynamicMenu_ServerCommandExecuted=Server command executed successfully
 ObjectToolsDynamicMenu_ServerScriptExecError=Cannot execute script on server
index 005cd51..8492737 100644 (file)
@@ -115,7 +115,6 @@ ObjectToolsDynamicMenu_ExecuteOnNode=Execute action on node %s
 ObjectToolsDynamicMenu_ExecuteServerCmd=Execute server command
 ObjectToolsDynamicMenu_HandlerNotDefined=Cannot execute object tool: handler not defined
 ObjectToolsDynamicMenu_Information=Information
-ObjectToolsDynamicMenu_MultipleNodes=<multiple nodes>
 ObjectToolsDynamicMenu_ServerCmdExecError=Canot execute command on server
 ObjectToolsDynamicMenu_ServerCommandExecuted=Server command executed successfully
 ObjectToolsDynamicMenu_ServerScriptExecError=Cannot execute script on server
index 64ca438..3ce37a2 100644 (file)
@@ -115,7 +115,6 @@ ObjectToolsDynamicMenu_ExecuteOnNode=\u0412\u044b\u043f\u043e\u043b\u043d\u0435\
 ObjectToolsDynamicMenu_ExecuteServerCmd=\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435
 ObjectToolsDynamicMenu_HandlerNotDefined=\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443: \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d
 ObjectToolsDynamicMenu_Information=\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f
-ObjectToolsDynamicMenu_MultipleNodes=<\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0443\u0437\u043b\u043e\u0432>
 ObjectToolsDynamicMenu_ServerCmdExecError=\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435
 ObjectToolsDynamicMenu_ServerCommandExecuted=\u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e
 ObjectToolsDynamicMenu_ServerScriptExecError=\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435
index d6fe2b5..ec72631 100644 (file)
@@ -115,7 +115,6 @@ ObjectToolsDynamicMenu_ExecuteOnNode=Execute action on node %s
 ObjectToolsDynamicMenu_ExecuteServerCmd=Execute server command
 ObjectToolsDynamicMenu_HandlerNotDefined=Cannot execute object tool: handler not defined
 ObjectToolsDynamicMenu_Information=Information
-ObjectToolsDynamicMenu_MultipleNodes=<multiple nodes>
 ObjectToolsDynamicMenu_ServerCmdExecError=Canot execute command on server
 ObjectToolsDynamicMenu_ServerCommandExecuted=Server command executed successfully
 ObjectToolsDynamicMenu_ServerScriptExecError=Cannot execute script on server
index 39ce043..36ea875 100644 (file)
@@ -28,6 +28,9 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.dialogs.PropertyPage;
+import org.netxms.client.ObjectMenuFilter;
+import org.netxms.client.datacollection.GraphSettings;
+import org.netxms.client.objects.MenuFiltringObj;
 import org.netxms.client.objecttools.ObjectTool;
 import org.netxms.client.objecttools.ObjectToolDetails;
 import org.netxms.ui.eclipse.objecttools.Messages;
@@ -38,7 +41,7 @@ import org.netxms.ui.eclipse.tools.WidgetHelper;
  */
 public class Filter extends PropertyPage
 {
-       private ObjectToolDetails objectTool;
+       private ObjectMenuFilter filter;
        private Button checkAgent;
        private Button checkSNMP;
        private Button checkMatchOID;
@@ -66,7 +69,8 @@ public class Filter extends PropertyPage
        @Override
        protected Control createContents(Composite parent)
        {
-               objectTool = (ObjectToolDetails)getElement().getAdapter(ObjectToolDetails.class);
+          MenuFiltringObj obj = (MenuFiltringObj)getElement().getAdapter(MenuFiltringObj.class);
+          filter = obj.getFilter();
 
                Composite dialogArea = new Composite(parent, SWT.NONE);
                
@@ -78,15 +82,15 @@ public class Filter extends PropertyPage
                
                checkAgent = new Button(dialogArea, SWT.CHECK);
                checkAgent.setText(Messages.get().Filter_AgentNeeded);
-               checkAgent.setSelection((objectTool.getFlags() & ObjectTool.REQUIRES_AGENT) != 0);
+               checkAgent.setSelection((filter.flags & ObjectMenuFilter.REQUIRES_AGENT) != 0);
                
                checkSNMP = new Button(dialogArea, SWT.CHECK);
                checkSNMP.setText(Messages.get().Filter_SNMPNeeded);
-               checkSNMP.setSelection((objectTool.getFlags() & ObjectTool.REQUIRES_SNMP) != 0);
+               checkSNMP.setSelection((filter.flags & ObjectMenuFilter.REQUIRES_SNMP) != 0);
                
                checkMatchOID = new Button(dialogArea, SWT.CHECK);
                checkMatchOID.setText(Messages.get().Filter_OIDShouldMatch);
-               checkMatchOID.setSelection((objectTool.getFlags() & ObjectTool.REQUIRES_OID_MATCH) != 0);
+               checkMatchOID.setSelection((filter.flags & ObjectMenuFilter.REQUIRES_OID_MATCH) != 0);
                checkMatchOID.addSelectionListener(new SelectionListener() {
                        @Override
                        public void widgetSelected(SelectionEvent e)
@@ -104,7 +108,7 @@ public class Filter extends PropertyPage
                });
                
                textOID = new Text(dialogArea, SWT.BORDER);
-               textOID.setText(objectTool.getSnmpOid());
+               textOID.setText(filter.snmpOid);
                GridData gd = new GridData();
                gd.horizontalAlignment = SWT.FILL;
                gd.grabExcessHorizontalSpace = true;
@@ -114,7 +118,7 @@ public class Filter extends PropertyPage
                
                checkMatchNodeOS = new Button(dialogArea, SWT.CHECK);
                checkMatchNodeOS.setText(Messages.get().Filter_OSShouldMatch);
-               checkMatchNodeOS.setSelection((objectTool.getFlags() & ObjectTool.REQUIRES_NODE_OS_MATCH) != 0);
+               checkMatchNodeOS.setSelection((filter.flags & ObjectMenuFilter.REQUIRES_NODE_OS_MATCH) != 0);
                checkMatchNodeOS.addSelectionListener(new SelectionListener() {
                        @Override
                        public void widgetSelected(SelectionEvent e)
@@ -132,7 +136,7 @@ public class Filter extends PropertyPage
                });
                
                textNodeOS = new Text(dialogArea, SWT.BORDER);
-               textNodeOS.setText(objectTool.getToolNodeOS());
+               textNodeOS.setText(filter.toolNodeOS);
                gd = new GridData();
                gd.horizontalAlignment = SWT.FILL;
                gd.grabExcessHorizontalSpace = true;
@@ -140,11 +144,11 @@ public class Filter extends PropertyPage
                textNodeOS.setLayoutData(gd);
                textNodeOS.setEnabled(checkMatchNodeOS.getSelection());
                
-               if (objectTool.getType() == ObjectTool.TYPE_LOCAL_COMMAND)
+               if (obj instanceof ObjectTool && obj.getType() == ObjectTool.TYPE_LOCAL_COMMAND)
                {
                checkMatchWorkstationOS = new Button(dialogArea, SWT.CHECK);
                checkMatchWorkstationOS.setText("Workstation OS name should match this template(coma separated regular expression list)");
-               checkMatchWorkstationOS.setSelection((objectTool.getFlags() & ObjectTool.REQUIRES_WORKSTATION_OS_MATCH) != 0);
+               checkMatchWorkstationOS.setSelection((filter.flags & ObjectMenuFilter.REQUIRES_WORKSTATION_OS_MATCH) != 0);
                checkMatchWorkstationOS.addSelectionListener(new SelectionListener() {         
             @Override
             public void widgetSelected(SelectionEvent e)
@@ -162,7 +166,7 @@ public class Filter extends PropertyPage
          });
                
                textWorkstationOS = new Text(dialogArea, SWT.BORDER);
-               textWorkstationOS.setText(objectTool.getToolWorkstationOS());
+               textWorkstationOS.setText(filter.toolWorkstationOS);
                gd = new GridData();
                gd.horizontalAlignment = SWT.FILL;
          gd.grabExcessHorizontalSpace = true;
@@ -173,7 +177,7 @@ public class Filter extends PropertyPage
                
                checkMatchTemplate = new Button(dialogArea, SWT.CHECK);
                checkMatchTemplate.setText(Messages.get().Filter_TemplateShouldMatch);
-               checkMatchTemplate.setSelection((objectTool.getFlags() & ObjectTool.REQUIRES_TEMPLATE_MATCH) != 0);
+               checkMatchTemplate.setSelection((filter.flags & ObjectMenuFilter.REQUIRES_TEMPLATE_MATCH) != 0);
                checkMatchTemplate.addSelectionListener(new SelectionListener() {
          @Override
          public void widgetSelected(SelectionEvent e)
@@ -191,7 +195,7 @@ public class Filter extends PropertyPage
       });
       
                textTemplate = new Text(dialogArea, SWT.BORDER);
-               textTemplate.setText(objectTool.getToolTemplate());
+               textTemplate.setText(filter.toolTemplate);
       gd = new GridData();
       gd.horizontalAlignment = SWT.FILL;
       gd.grabExcessHorizontalSpace = true;
@@ -210,44 +214,44 @@ public class Filter extends PropertyPage
        protected void applyChanges(final boolean isApply)
        {
                if (checkAgent.getSelection())
-                       objectTool.setFlags(objectTool.getFlags() | ObjectTool.REQUIRES_AGENT);
+                  filter.flags = filter.flags | ObjectMenuFilter.REQUIRES_AGENT;
                else
-                       objectTool.setFlags(objectTool.getFlags() & ~ObjectTool.REQUIRES_AGENT);
+                  filter.flags = filter.flags & ~ObjectMenuFilter.REQUIRES_AGENT;
 
                if (checkSNMP.getSelection())
-                       objectTool.setFlags(objectTool.getFlags() | ObjectTool.REQUIRES_SNMP);
+                  filter.flags = filter.flags | ObjectMenuFilter.REQUIRES_SNMP;
                else
-                       objectTool.setFlags(objectTool.getFlags() & ~ObjectTool.REQUIRES_SNMP);
+                  filter.flags = filter.flags & ~ObjectMenuFilter.REQUIRES_SNMP;
 
                if (checkMatchOID.getSelection())
-                       objectTool.setFlags(objectTool.getFlags() | ObjectTool.REQUIRES_OID_MATCH);
+                       filter.flags = filter.flags | ObjectMenuFilter.REQUIRES_OID_MATCH;
                else
-                       objectTool.setFlags(objectTool.getFlags() & ~ObjectTool.REQUIRES_OID_MATCH);
+                  filter.flags = filter.flags & ~ObjectMenuFilter.REQUIRES_OID_MATCH;
                
-               objectTool.setSnmpOid(textOID.getText());               
+               filter.snmpOid = textOID.getText();             
 
       if (checkMatchNodeOS.getSelection())
-         objectTool.setFlags(objectTool.getFlags() | ObjectTool.REQUIRES_NODE_OS_MATCH);
+         filter.flags = filter.flags | ObjectMenuFilter.REQUIRES_NODE_OS_MATCH;
       else
-         objectTool.setFlags(objectTool.getFlags() & ~ObjectTool.REQUIRES_NODE_OS_MATCH);
+         filter.flags = filter.flags & ~ObjectMenuFilter.REQUIRES_NODE_OS_MATCH;
       
-      objectTool.setToolNodeOS(textNodeOS.getText());
+      filter.toolNodeOS = textNodeOS.getText();
       
       if ((checkMatchWorkstationOS != null) && checkMatchWorkstationOS.getSelection())
-         objectTool.setFlags(objectTool.getFlags() | ObjectTool.REQUIRES_WORKSTATION_OS_MATCH);
+         filter.flags = filter.flags | ObjectMenuFilter.REQUIRES_WORKSTATION_OS_MATCH;
       else
-         objectTool.setFlags(objectTool.getFlags() & ~ObjectTool.REQUIRES_WORKSTATION_OS_MATCH);
+         filter.flags = filter.flags & ~ObjectMenuFilter.REQUIRES_WORKSTATION_OS_MATCH;
       
       if (textWorkstationOS != null)
-         objectTool.setToolWorkstationOS(textWorkstationOS.getText());
+         filter.toolWorkstationOS = textWorkstationOS.getText();
 
       if (checkMatchTemplate.getSelection())
-         objectTool.setFlags(objectTool.getFlags() | ObjectTool.REQUIRES_TEMPLATE_MATCH);
+         filter.flags = filter.flags | ObjectMenuFilter.REQUIRES_TEMPLATE_MATCH;
       else
-         objectTool.setFlags(objectTool.getFlags() & ~ObjectTool.REQUIRES_TEMPLATE_MATCH);
+         filter.flags = filter.flags & ~ObjectMenuFilter.REQUIRES_TEMPLATE_MATCH;
       
-      objectTool.setToolTemplate(textTemplate.getText());
-       }
+      filter.toolTemplate = textTemplate.getText();
+   }
        
        /* (non-Javadoc)
         * @see org.eclipse.jface.preference.PreferencePage#performApply()
index 7d27e61..b718428 100644 (file)
@@ -33,7 +33,7 @@ import org.netxms.client.objects.Interface;
 import org.netxms.client.objects.Node;
 import org.netxms.client.objecttools.ObjectTool;
 import org.netxms.ui.eclipse.jobs.ConsoleJob;
-import org.netxms.ui.eclipse.objecttools.api.NodeInfo;
+import org.netxms.ui.eclipse.objects.ObjectContext;
 import org.netxms.ui.eclipse.objecttools.api.ObjectToolExecutor;
 import org.netxms.ui.eclipse.objecttools.api.ObjectToolsCache;
 import org.netxms.ui.eclipse.objectview.Activator;
@@ -115,8 +115,8 @@ public class Commands extends OverviewPageElement
                      if (!tool.isVisibleInCommands() || !tool.isEnabled() || !tool.isApplicableForNode((AbstractNode)getObject()))
                         continue;
 
-            final Set<NodeInfo> nodes = new HashSet<NodeInfo>(1);
-            nodes.add(new NodeInfo((AbstractNode)getObject(), null));
+            final Set<ObjectContext> nodes = new HashSet<ObjectContext>(1);
+            nodes.add(new ObjectContext((AbstractNode)getObject(), null));
             if (!ObjectToolExecutor.isToolAllowed(tool, nodes))
                continue;
                      
index 1d054ab..1b876d0 100644 (file)
@@ -12,7 +12,8 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.8.2",
  org.netxms.ui.eclipse.charts;bundle-version="2.0.5",
  org.netxms.ui.eclipse.objectview;bundle-version="2.0.7",
  org.netxms.ui.eclipse.datacollection;bundle-version="2.0.7",
- org.netxms.ui.eclipse.usermanager;bundle-version="2.0.8"
+ org.netxms.ui.eclipse.usermanager;bundle-version="2.0.8",
+ org.eclipse.core.expressions;bundle-version="3.4.400"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
 Export-Package: org.netxms.ui.eclipse.perfview.views,
index 0fa726c..4b40083 100644 (file)
             name="%view.name.HistData"
             restorable="true">
       </view>
+      <view
+            allowMultiple="true"
+            class="org.netxms.ui.eclipse.perfview.views.TemplateGraphView"
+            icon="icons/chart_line.png"
+            id="org.netxms.ui.eclipse.perfview.views.TemplateGraphView"
+            name="Template Graphs"
+            restorable="true">
+      </view>
    </extension>
 
    <extension
             name="%page.name.General">
          <enabledWhen>
             <instanceof
-                  value="org.netxms.ui.eclipse.perfview.ChartConfig">
+                  value="org.netxms.client.datacollection.ChartConfig">
             </instanceof>
          </enabledWhen>
       </page>
             id="org.netxms.ui.eclipse.perfview.propertypages.DataSources#10"
             name="%page.name.DataSources">
          <enabledWhen>
-            <instanceof
-                  value="org.netxms.ui.eclipse.perfview.ChartConfig">
-            </instanceof>
-         </enabledWhen>
+            <and>
+               <instanceof
+                     value="org.netxms.client.datacollection.ChartConfig">
+               </instanceof>
+               <not>
+                  <test
+                        property="org.netxms.ui.eclipse.perfview.isTemplateGraph">
+                  </test>
+               </not></and></enabledWhen>
       </page>
       <page
             class="org.netxms.ui.eclipse.perfview.propertypages.PredefinedGraph"
             name="%page.name.PredefGraph">
          <enabledWhen>
             <instanceof
-                  value="org.netxms.ui.eclipse.perfview.PredefinedChartConfig">
+                  value="org.netxms.client.datacollection.GraphSettings">
             </instanceof>
          </enabledWhen>
       </page>
+      <page
+            class="org.netxms.ui.eclipse.perfview.propertypages.TemplateDataSources"
+            id="org.netxms.ui.eclipse.perfview.propertypages.PredefinedGraph#10"
+            name="Template Source">
+         <enabledWhen>
+            <and>
+               <instanceof
+                     value="org.netxms.client.datacollection.GraphSettings">
+               </instanceof>
+               <test
+                     property="org.netxms.ui.eclipse.perfview.isTemplateGraph">
+               </test>
+            </and>
+         </enabledWhen>
+      </page>
    </extension>
    <extension
          point="org.eclipse.ui.commands">
             id="org.netxms.ui.eclipse.perfview.commands.show_graph_filter"
             name="Show filter">
       </command>
+      <command
+            description="Open Template Graphs"
+            id="org.netxms.ui.eclipse.perfview.commands.open_template_graph_view"
+            name="Template Graphs">
+      </command>
    </extension>
    <extension
          point="org.eclipse.ui.actionSets">
                style="push"
                toolbarPath="view/additions">
          </action>
+         <action
+               class="org.netxms.ui.eclipse.perfview.actions.OpenGraphTemplateView"
+               definitionId="org.netxms.ui.eclipse.perfview.commands.open_template_graph_view"
+               icon="icons/chart_line.png"
+               id="org.netxms.ui.eclipse.perfview.action.open_template_graph_view"
+               label="Template Graph Configuration"
+               menubarPath="config/additions"
+               style="push"
+               tooltip="Open Template Graph Configuration">
+         </action>
       </actionSet>
    </extension>
    <extension
             parentId="org.eclipse.ui.contexts.window">
       </context>
    </extension>
+   <extension
+         point="org.eclipse.ui.menus">
+      <menuContribution
+            locationURI="popup:org.eclipse.ui.popup.any?after=objectmgmt">
+         <dynamic
+               class="org.netxms.ui.eclipse.perfview.TemplateGraphDynamicMenu"
+               id="org.netxms.ui.eclipse.objecttools.templateGraphDynamicMenu">
+            <visibleWhen
+                  checkEnabled="false">
+               <iterate
+                     ifEmpty="false"
+                     operator="and">
+                  <or>
+                     <instanceof
+                           value="org.netxms.client.objects.Node">
+                     </instanceof>
+                     <instanceof
+                           value="org.netxms.client.events.Alarm">
+                     </instanceof>
+                     <instanceof
+                           value="org.netxms.client.objects.Cluster">
+                     </instanceof>
+                     <instanceof
+                           value="org.netxms.client.objects.MobileDevice">
+                     </instanceof>
+                  </or>
+               </iterate>
+            </visibleWhen>
+         </dynamic>
+      </menuContribution>
+   </extension>
+   <extension
+         point="org.netxms.ui.eclipse.loginlisteners">
+      <loginlistener
+            class="org.netxms.ui.eclipse.perfview.LoginListener">
+      </loginlistener>
+   </extension>
+   <extension
+         point="org.eclipse.core.expressions.propertyTesters">
+      <propertyTester
+            class="org.netxms.ui.eclipse.perfview.GraphTemplatePropertyTester"
+            id="org.netxms.ui.eclipse.perfview.GraphTemplatePropertyTester"
+            namespace="org.netxms.ui.eclipse.perfview"
+            properties="isTemplateGraph"
+            type="org.netxms.client.datacollection.GraphSettings">
+      </propertyTester>
+   </extension>
 
 </plugin>
diff --git a/src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/ChartConfig.java b/src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/ChartConfig.java
deleted file mode 100644 (file)
index de98b24..0000000
+++ /dev/null
@@ -1,806 +0,0 @@
-/**
- * NetXMS - open source network management system
- * Copyright (C) 2003-2014 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.perfview;
-
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.Date;
-import org.netxms.client.TimePeriod;
-import org.netxms.client.datacollection.GraphItemStyle;
-import org.netxms.client.datacollection.GraphSettings;
-import org.netxms.ui.eclipse.charts.api.ChartDciConfig;
-import org.simpleframework.xml.Element;
-import org.simpleframework.xml.ElementArray;
-import org.simpleframework.xml.Root;
-import org.simpleframework.xml.Serializer;
-import org.simpleframework.xml.convert.AnnotationStrategy;
-import org.simpleframework.xml.convert.Convert;
-import org.simpleframework.xml.core.Persister;
-
-/**
- * Base class for all chart widget configs
- */
-@Root(name="chart", strict=false)
-public class ChartConfig
-{
-       @ElementArray(required = true)
-       private ChartDciConfig[] dciList = new ChartDciConfig[0];
-       
-       @Element(required = false)
-       private String title = ""; //$NON-NLS-1$
-       
-       @Element(required = false)
-       private int legendPosition = GraphSettings.POSITION_BOTTOM;
-       
-       @Element(required = false)
-       private boolean showLegend = true;
-       
-       @Element(required = false)
-       private boolean extendedLegend = true;
-       
-       @Element(required = false)
-       private boolean showTitle = false;
-
-       @Element(required = false)
-       private boolean showGrid = true;
-
-       @Element(required = false)
-       private boolean showHostNames = false;
-
-       @Element(required = false)
-       private boolean autoRefresh = true;
-
-       @Element(required = false)
-       private boolean logScale = false;
-
-   @Element(required = false)
-   private boolean stacked = false;
-
-   @Element(required = false)
-   private boolean translucent = true;
-   
-   @Element(required = false)
-   private boolean area = false;
-   
-   @Element(required = false)
-   private int lineWidth = 2;
-   
-   @Element(required = false)
-   private boolean autoScale = true;
-   
-   @Element(required = false)
-   private int minYScaleValue = 0;
-
-   @Element(required = false)
-   private int maxYScaleValue = 100;
-
-       @Element(required = false)
-       private int refreshRate = 30;
-
-       @Element(required=false)
-       private int timeUnits = GraphSettings.TIME_UNIT_HOUR;
-       
-       @Element(required=false)
-       private int timeRange = 1;
-       
-       @Element(required=false)
-       private int timeFrameType = GraphSettings.TIME_FRAME_BACK_FROM_NOW;
-       
-       @Element(required=false)
-       @Convert(XmlDateConverter.class)
-       private Date timeFrom;
-       
-       @Element(required=false)
-       @Convert(XmlDateConverter.class)
-       private Date timeTo;
-       
-       /**
-        * Create chart settings object from XML document
-        * 
-        * @param xml XML document
-        * @return deserialized object
-        * @throws Exception if the object cannot be fully deserialized
-        */
-       public static ChartConfig createFromXml(final String xml) throws Exception
-       {
-               if (xml == null)
-                       return new ChartConfig();
-               return internalCreate(ChartConfig.class, xml);
-       }
-       
-       /**
-        * Internal creation method.
-        * 
-        * @param objectClass
-        * @param xml
-        * @return
-        * @throws Exception
-        */
-       protected static ChartConfig internalCreate(Class<? extends ChartConfig> objectClass, final String xml) throws Exception
-       {
-               // Compatibility mode: decode old predefined graph configuration
-               // should be removed in 1.2.2
-               if (!xml.startsWith("<chart>")) //$NON-NLS-1$
-               {
-                       ChartConfig config = objectClass.newInstance();
-                       config.parseLegacyConfig(xml);
-                       return config;
-               }
-               
-               Serializer serializer = new Persister(new AnnotationStrategy());
-               return serializer.read(objectClass, xml);
-       }
-
-       /**
-        * Parse legacy predefined graph config
-        * 
-        * @param settings
-        */
-       private void parseLegacyConfig(String settings)
-       {
-               autoRefresh = false;
-               showLegend = false;
-               showGrid = false;
-               
-               int dciCount = 0;
-               
-               GraphItemStyle[] itemStyles = new GraphItemStyle[GraphSettings.MAX_GRAPH_ITEM_COUNT];
-               for(int i = 0; i < itemStyles.length; i++)
-                       itemStyles[i] = new GraphItemStyle();
-               
-               String[] elements = settings.split("\u007F"); //$NON-NLS-1$
-               for(int i = 0; i < elements.length; i++)
-               {
-                       int index = elements[i].indexOf(':');
-                       if (index == -1)
-                               continue;
-                       
-                       final String name = elements[i].substring(0, index);
-                       final String value = elements[i].substring(index + 1);
-                       
-                       if (name.equals("A")) //$NON-NLS-1$
-                       {
-                               refreshRate = safeParseInt(value, 30);
-                       }
-                       else if (name.equals("F")) //$NON-NLS-1$
-                       {
-                               int flags = safeParseInt(value, 0);
-                               if ((flags & GraphSettings.GF_AUTO_UPDATE) != 0)
-                                       autoRefresh = true;
-                               if ((flags & GraphSettings.GF_SHOW_GRID) != 0)
-                                       showGrid = true;
-                               if ((flags & GraphSettings.GF_SHOW_LEGEND) != 0)
-                                       showLegend = true;
-                               if ((flags & GraphSettings.GF_SHOW_HOST_NAMES) != 0)
-                                       showHostNames = true;
-                               if ((flags & GraphSettings.GF_LOG_SCALE) != 0)
-                                       logScale = true;
-                       }
-                       else if (name.equals("N")) //$NON-NLS-1$
-                       {
-                               dciCount = safeParseInt(value, 0);
-                               dciList = new ChartDciConfig[dciCount];
-                               for(int j = 0; j < dciCount; j++)
-                                       dciList[j] = new ChartDciConfig();
-                       }
-                       else if (name.equals("TFT")) //$NON-NLS-1$
-                       {
-                               timeFrameType = safeParseInt(value, GraphSettings.TIME_FRAME_BACK_FROM_NOW);
-                       }
-                       else if (name.equals("TU")) //$NON-NLS-1$
-                       {
-                               timeUnits = safeParseInt(value, GraphSettings.TIME_UNIT_HOUR);
-                       }
-                       else if (name.equals("NTU")) //$NON-NLS-1$
-                       {
-                               timeRange = safeParseInt(value, 1);
-                       }
-                       else if (name.equals("TS")) //$NON-NLS-1$
-                       {
-                               timeFrom = new Date((long)safeParseInt(value, 0) * 1000L);
-                       }
-                       else if (name.equals("TF")) //$NON-NLS-1$
-                       {
-                               timeTo = new Date((long)safeParseInt(value, 0) * 1000L);
-                       }
-                       else if (name.equals("T")) //$NON-NLS-1$
-                       {
-                               title = value;
-                       }
-                       else if (name.equals("S")) //$NON-NLS-1$
-                       {
-                               // autoscale flag
-                       }
-                       else if (name.equals("G")) //$NON-NLS-1$
-                       {
-                               showGrid = (safeParseInt(value, 1) != 0);
-                       }
-                       else if (name.equals("L")) //$NON-NLS-1$
-                       {
-                               showLegend = (safeParseInt(value, 1) != 0);
-                       }
-                       else if (name.equals("R")) //$NON-NLS-1$
-                       {
-                               // show ruler flag
-                       }
-                       else if (name.equals("H")) //$NON-NLS-1$
-                       {
-                               showHostNames = (safeParseInt(value, 0) != 0);
-                       }
-                       else if (name.equals("O")) //$NON-NLS-1$
-                       {
-                               logScale = (safeParseInt(value, 0) != 0);
-                       }
-                       else if (name.equals("CA")) //$NON-NLS-1$
-                       {
-                               // axis color
-                       }
-                       else if (name.equals("CB")) //$NON-NLS-1$
-                       {
-                               // background color
-                       }
-                       else if (name.equals("CG")) //$NON-NLS-1$
-                       {
-                               // grid color
-                       }
-                       else if (name.equals("CLF")) //$NON-NLS-1$
-                       {
-                               // legend text color
-                       }
-                       else if (name.equals("CLB")) //$NON-NLS-1$
-                       {
-                               // legend background color
-                       }
-                       else if (name.equals("CP")) //$NON-NLS-1$
-                       {
-                               // plot area color
-                       }
-                       else if (name.equals("CR")) //$NON-NLS-1$
-                       {
-                               // ruler color
-                       }
-                       else if (name.equals("CS")) //$NON-NLS-1$
-                       {
-                               // selection color
-                       }
-                       else if (name.equals("CT")) //$NON-NLS-1$
-                       {
-                               // text color
-                       }
-                       else if (name.charAt(0) == 'C') // Item color
-                       {
-                               int item = safeParseInt(name.substring(1), -1);
-                               if ((item >= 0) && (item < itemStyles.length))
-                                       itemStyles[item].setColor(safeParseInt(value, 0));
-                       }
-                       else if (name.charAt(0) == 'T') // Item type
-                       {
-                               int item = safeParseInt(name.substring(1), -1);
-                               if ((item >= 0) && (item < itemStyles.length))
-                                       itemStyles[item].setType(safeParseInt(value, 0));
-                       }
-                       else if (name.charAt(0) == 'W') // Item line width
-                       {
-                               int item = safeParseInt(name.substring(1), -1);
-                               if ((item >= 0) && (item < itemStyles.length))
-                                       itemStyles[item].setLineWidth(safeParseInt(value, 0));
-                       }
-                       else if ((name.charAt(0) == 'F') && (name.charAt(1) == 'L'))    // Item flags
-                       {
-                               int item = safeParseInt(name.substring(2), -1);
-                               if ((item >= 0) && (item < itemStyles.length))
-                                       itemStyles[item].setFlags(safeParseInt(value, 0));
-                       }
-                       else if (name.charAt(0) == 'N') // Node ID
-                       {
-                               int item = safeParseInt(name.substring(1), -1);
-                               if ((item >= 0) && (item < dciCount))
-                                       dciList[item].nodeId = safeParseLong(value, 0);
-                       }
-                       else if (name.charAt(0) == 'I') // DCI information
-                       {
-                               if (name.charAt(1) == 'D')      // description
-                               {
-                                       int item = safeParseInt(name.substring(2), -1);
-                                       if ((item >= 0) && (item < dciCount))
-                                               dciList[item].name = value;
-                               }
-                               else if (name.charAt(1) == 'N') // name
-                               {
-                               }
-                               else if (name.charAt(1) == 'S') // source
-                               {
-                               }
-                               else if (name.charAt(1) == 'T') // data type
-                               {
-                               }
-                               else    // assume DCI ID - Ixxx
-                               {
-                                       int item = safeParseInt(name.substring(1), -1);
-                                       if ((item >= 0) && (item < dciCount))
-                                               dciList[item].dciId = safeParseLong(value, 0);
-                               }
-                       }
-               }
-               
-               // Apply item styles
-               for(int i = 0; (i < dciList.length) && (i < itemStyles.length); i++)
-               {
-                       dciList[i].color = "0x" + Integer.toHexString(itemStyles[i].getColor()); //$NON-NLS-1$
-                       dciList[i].lineWidth = itemStyles[i].getLineWidth();
-               }
-       }
-       
-       /**
-        * Parse int without throwing exception
-        * @param text text to parse
-        * @param defVal default value to be used in case of parse error
-        * @return parsed value
-        */
-       static private int safeParseInt(String text, int defVal)
-       {
-               try
-               {
-                       return Integer.parseInt(text);
-               }
-               catch(NumberFormatException e)
-               {
-               }
-               return defVal;
-       }
-
-       /**
-        * Parse long without throwing exception
-        * @param text text to parse
-        * @param defVal default value to be used in case of parse error
-        * @return parsed value
-        */
-       static private long safeParseLong(String text, long defVal)
-       {
-               try
-               {
-                       return Long.parseLong(text);
-               }
-               catch(NumberFormatException e)
-               {
-               }
-               return defVal;
-       }
-       
-       /**
-        * Create XML from configuration.
-        * 
-        * @return XML document
-        * @throws Exception if the schema for the object is not valid
-        */
-       public String createXml() throws Exception
-       {
-               Serializer serializer = new Persister(new AnnotationStrategy());
-               Writer writer = new StringWriter();
-               serializer.write(this, writer);
-               return writer.toString();
-       }
-
-       /**
-        * Get time range covered by graph in milliseconds
-        * 
-        * @return
-        */
-       public long getTimeRangeMillis()
-       {
-               switch(timeUnits)
-               {
-                       case GraphSettings.TIME_UNIT_MINUTE:
-                               return (long)timeRange * 60L * 1000L;
-                       case GraphSettings.TIME_UNIT_HOUR:
-                               return (long)timeRange * 60L * 60L * 1000L;
-                       case GraphSettings.TIME_UNIT_DAY:
-                               return (long)timeRange * 24L * 60L * 60L * 1000L;
-               }
-               return 0;
-       }
-
-       /**
-        * @return the title
-        */
-       public String getTitle()
-       {
-               return title;
-       }
-
-       /**
-        * @param title the title to set
-        */
-       public void setTitle(String title)
-       {
-               this.title = title;
-       }
-
-       /**
-        * @return the dciList
-        */
-       public ChartDciConfig[] getDciList()
-       {
-               return dciList;
-       }
-
-       /**
-        * @param dciList the dciList to set
-        */
-       public void setDciList(ChartDciConfig[] dciList)
-       {
-               this.dciList = dciList;
-       }
-
-       /**
-        * @return the legendPosition
-        */
-       public int getLegendPosition()
-       {
-               return legendPosition;
-       }
-
-       /**
-        * @param legendPosition the legendPosition to set
-        */
-       public void setLegendPosition(int legendPosition)
-       {
-               this.legendPosition = legendPosition;
-       }
-
-       /**
-        * @return the showLegend
-        */
-       public boolean isShowLegend()
-       {
-               return showLegend;
-       }
-
-       /**
-        * @param showLegend the showLegend to set
-        */
-       public void setShowLegend(boolean showLegend)
-       {
-               this.showLegend = showLegend;
-       }
-
-       /**
-        * @return the refreshRate
-        */
-       public int getRefreshRate()
-       {
-               return refreshRate;
-       }
-
-       /**
-        * @param refreshRate the refreshRate to set
-        */
-       public void setRefreshRate(int refreshRate)
-       {
-               this.refreshRate = refreshRate;
-       }
-       
-       /**
-        * @return the showTitle
-        */
-       public boolean isShowTitle()
-       {
-               return showTitle;
-       }
-
-       /**
-        * @param showTitle the showTitle to set
-        */
-       public void setShowTitle(boolean showTitle)
-       {
-               this.showTitle = showTitle;
-       }
-
-       /**
-        * @return the timeUnits
-        */
-       public int getTimeUnits()
-       {
-               return timeUnits;
-       }
-
-       /**
-        * @param timeUnits the timeUnits to set
-        */
-       public void setTimeUnits(int timeUnits)
-       {
-               this.timeUnits = timeUnits;
-       }
-
-       /**
-        * @return the timeRange
-        */
-       public int getTimeRange()
-       {
-               return timeRange;
-       }
-
-       /**
-        * @param timeRange the timeRange to set
-        */
-       public void setTimeRange(int timeRange)
-       {
-               this.timeRange = timeRange;
-       }
-
-       /**
-        * @return the showHostNames
-        */
-       public boolean isShowHostNames()
-       {
-               return showHostNames;
-       }
-
-       /**
-        * @param showHostNames the showHostNames to set
-        */
-       public void setShowHostNames(boolean showHostNames)
-       {
-               this.showHostNames = showHostNames;
-       }
-
-       /**
-        * @return the autoRefresh
-        */
-       public boolean isAutoRefresh()
-       {
-               return autoRefresh;
-       }
-
-       /**
-        * @param autoRefresh the autoRefresh to set
-        */
-       public void setAutoRefresh(boolean autoRefresh)
-       {
-               this.autoRefresh = autoRefresh;
-       }
-
-       /**
-        * @return the logScale
-        */
-       public boolean isLogScale()
-       {
-               return logScale;
-       }
-
-       /**
-        * @param logScale the logScale to set
-        */
-       public void setLogScale(boolean logScale)
-       {
-               this.logScale = logScale;
-       }
-
-       /**
-        * @return the timeFrameType
-        */
-       public int getTimeFrameType()
-       {
-               return timeFrameType;
-       }
-
-       /**
-        * @param timeFrameType the timeFrameType to set
-        */
-       public void setTimeFrameType(int timeFrameType)
-       {
-               this.timeFrameType = timeFrameType;
-       }
-
-       /**
-        * @return the timeFrom
-        */
-       public Date getTimeFrom()
-       {
-               return timeFrom;
-       }
-
-       /**
-        * @param timeFrom the timeFrom to set
-        */
-       public void setTimeFrom(Date timeFrom)
-       {
-               this.timeFrom = timeFrom;
-       }
-
-       /**
-        * @return the timeTo
-        */
-       public Date getTimeTo()
-       {
-               return timeTo;
-       }
-
-       /**
-        * @param timeTo the timeTo to set
-        */
-       public void setTimeTo(Date timeTo)
-       {
-               this.timeTo = timeTo;
-       }
-
-       /**
-        * @return the showGrid
-        */
-       public boolean isShowGrid()
-       {
-               return showGrid;
-       }
-
-       /**
-        * @param showGrid the showGrid to set
-        */
-       public void setShowGrid(boolean showGrid)
-       {
-               this.showGrid = showGrid;
-       }
-
-   /**
-    * @return the stacked
-    */
-   public boolean isStacked()
-   {
-      return stacked;
-   }
-
-   /**
-    * @param stacked the stacked to set
-    */
-   public void setStacked(boolean stacked)
-   {
-      this.stacked = stacked;
-   }
-
-   /**
-    * @return the translucent
-    */
-   public boolean isTranslucent()
-   {
-      return translucent;
-   }
-
-   /**
-    * @param translucent the translucent to set
-    */
-   public void setTranslucent(boolean translucent)
-   {
-      this.translucent = translucent;
-   }
-
-   /**
-    * @return the extendedLegend
-    */
-   public boolean isExtendedLegend()
-   {
-      return extendedLegend;
-   }
-
-   /**
-    * @param extendedLegend the extendedLegend to set
-    */
-   public void setExtendedLegend(boolean extendedLegend)
-   {
-      this.extendedLegend = extendedLegend;
-   }
-
-   /**
-    * @return the lineWidth
-    */
-   public int getLineWidth()
-   {
-      return lineWidth;
-   }
-
-   /**
-    * @param lineWidth the lineWidth to set
-    */
-   public void setLineWidth(int lineWidth)
-   {
-      this.lineWidth = lineWidth;
-   }
-
-   /**
-    * @return
-    */
-   public boolean isAutoScale()
-   {
-      return autoScale;
-   }
-
-   /**
-    * @param autoScale
-    */
-   public void setAutoScale(boolean autoScale)
-   {
-      this.autoScale = autoScale;
-   }
-
-   /**
-    * @return the area
-    */
-   public boolean isArea()
-   {
-      return area;
-   }
-
-   /**
-    * @param area the area to set
-    */
-   public void setArea(boolean area)
-   {
-      this.area = area;
-   }
-
-   /**
-    * @return
-    */
-   public int getMinYScaleValue()
-   {
-      return minYScaleValue;
-   }
-
-   /**
-    * @param minYScaleValue
-    */
-   public void setMinYScaleValue(int minYScaleValue)
-   {
-      this.minYScaleValue = minYScaleValue;
-   }
-
-   /**
-    * @return
-    */
-   public int getMaxYScaleValue()
-   {
-      return maxYScaleValue;
-   }
-
-   /**
-    * @param maxYScaleValue
-    */
-   public void setMaxYScaleValue(int maxYScaleValue)
-   {
-      this.maxYScaleValue = maxYScaleValue;
-   }
-
-   /**
-    * @return
-    */
-   public TimePeriod timePeriod()
-   {
-      return new TimePeriod(timeFrameType, timeRange, timeUnits, timeFrom, timeTo);
-   }
-   
-   /**
-    * @param tp
-    */
-   public void setTimePeriod(TimePeriod tp)
-   {
-      timeFrameType = tp.getTimeFrameType();
-      timeRange = tp.getTimeRangeValue();
-      timeUnits = tp.getTimeUnitValue();
-      timeFrom = tp.getTimeFromValue();
-      timeTo = tp.getTimeToValue();
-   }  
-}
diff --git a/src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/GraphTemplatePropertyTester.java b/src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/GraphTemplatePropertyTester.java
new file mode 100644 (file)
index 0000000..b1bb7ac
--- /dev/null
@@ -0,0 +1,45 @@
+/**
+ * NetXMS - open source network management system
+ * Copyright (C) 2003-2016 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.perfview;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.netxms.client.datacollection.GraphSettings;
+
+/**
+ * Property tester for server components
+ */
+public class GraphTemplatePropertyTester extends PropertyTester
+{
+   /* (non-Javadoc)
+    * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+    */
+   @Override
+   public boolean test(Object receiver, String property, Object[] args, Object expectedValue)
+   {
+      if (!(receiver instanceof GraphSettings))
+         return false;
+      
+      if (property.equals("isTemplateGraph")) //$NON-NLS-1$
+      {
+         return ((GraphSettings)receiver).isTemplate();
+      }
+      
+      return false;
+   }
+}
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-package org.netxms.client.datacollection;
+package org.netxms.ui.eclipse.perfview;
+
+import org.eclipse.swt.widgets.Display;
+import org.netxms.client.NXCSession;
+import org.netxms.ui.eclipse.console.api.ConsoleLoginListener;
+import org.netxms.ui.eclipse.perfview.api.GraphTemplateCache;
 
 /**
- * Interface for graph settings change listeners
+ * Early startup class
  *
  */
-public interface GraphSettingsChangeListener
+public class LoginListener implements ConsoleLoginListener
 {
-       /**
-        * Handler for graph settings change event.
-        * 
-        * @param settings graph settings object
+       /* (non-Javadoc)
+        * @see org.netxms.ui.eclipse.console.api.ConsoleLoginListener#afterLogin(org.netxms.client.NXCSession, org.eclipse.swt.widgets.Display)
         */
-       public abstract void onGraphSettingsChange(GraphSettings settings);
+       @Override
+       public void afterLogin(NXCSession session, Display display)
+       {
+          GraphTemplateCache.attachSession(session);
+       }
 }
diff --git a/src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/PredefinedChartConfig.java b/src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/PredefinedChartConfig.java
deleted file mode 100644 (file)
index 2ee3981..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * 
- */
-package org.netxms.ui.eclipse.perfview;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.netxms.client.AccessListElement;
-import org.netxms.client.datacollection.GraphSettings;
-
-/**
- * Chart config for predefined charts
- */
-public class PredefinedChartConfig extends ChartConfig
-{
-       private long id;
-       private long ownerId;
-       private String name;
-       private List<AccessListElement> accessList;
-       
-       /**
-        * Create predefined chart configuration from server-side configuration object.
-        * 
-        * @param serverConfig server-side configuration object
-        * @return
-        * @throws Exception
-        */
-       public static PredefinedChartConfig createFromServerConfig(GraphSettings serverConfig) throws Exception
-       {
-               PredefinedChartConfig config = (PredefinedChartConfig)internalCreate(PredefinedChartConfig.class, serverConfig.getConfig());
-               config.id = serverConfig.getId();
-               config.ownerId = serverConfig.getOwnerId();
-               config.name = serverConfig.getName();
-               config.accessList.addAll(serverConfig.getAccessList());
-               return config;
-       }
-       
-       /**
-        * Default constructor
-        */
-       public PredefinedChartConfig()
-       {
-               id = 0;
-               ownerId = 0;
-               name = Messages.get().PredefinedChartConfig_Unnamed;
-               accessList = new ArrayList<AccessListElement>();
-       }
-
-       /**
-        * Create server-side settings object ready to be sent to server.
-        * 
-        * @return
-        * @throws Exception 
-        */
-       public GraphSettings createServerSettings() throws Exception
-       {
-               GraphSettings settings = new GraphSettings(id, ownerId, 0, accessList);
-               settings.setName(name);
-               settings.setConfig(createXml());
-               return settings;
-       }
-
-       /**
-        * @return the id
-        */
-       public long getId()
-       {
-               return id;
-       }
-
-       /**
-        * @param id the id to set
-        */
-       public void setId(long id)
-       {
-               this.id = id;
-       }
-
-       /**
-        * @return the ownerId
-        */
-       public long getOwnerId()
-       {
-               return ownerId;
-       }
-
-       /**
-        * @param ownerId the ownerId to set
-        */
-       public void setOwnerId(long ownerId)
-       {
-               this.ownerId = ownerId;
-       }
-
-       /**
-        * @return the name
-        */
-       public String getName()
-       {
-               return name;
-       }
-
-       /**
-        * @param name the name to set
-        */
-       public void setName(String name)
-       {
-               this.name = name;
-       }
-
-       /**
-        * @return the accessList
-        */
-       public List<AccessListElement> getAccessList()
-       {
-               return accessList;
-       }
-}
diff --git a/src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/TemplateGraphDynamicMenu.java b/src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/TemplateGraphDynamicMenu.java
new file mode 100644 (file)
index 0000000..e7cb24e
--- /dev/null
@@ -0,0 +1,154 @@
+package org.netxms.ui.eclipse.perfview;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.ContributionItem;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.ISources;
+import org.eclipse.ui.menus.IWorkbenchContribution;
+import org.eclipse.ui.services.IEvaluationService;
+import org.eclipse.ui.services.IServiceLocator;
+import org.netxms.client.NXCSession;
+import org.netxms.client.datacollection.DciValue;
+import org.netxms.client.datacollection.GraphSettings;
+import org.netxms.client.objects.AbstractNode;
+import org.netxms.ui.eclipse.datacollection.widgets.LastValuesWidget;
+import org.netxms.ui.eclipse.jobs.ConsoleJob;
+import org.netxms.ui.eclipse.perfview.api.GraphTemplateCache;
+import org.netxms.ui.eclipse.shared.ConsoleSharedData;
+
+public class TemplateGraphDynamicMenu extends ContributionItem implements IWorkbenchContribution
+{
+   private IEvaluationService evalService;
+   
+   /**
+    * Creates a contribution item with a null id.
+    */
+   public TemplateGraphDynamicMenu()
+   {
+      super();
+   }
+
+   /**
+    * Creates a contribution item with the given (optional) id.
+    * 
+    * @param id the contribution item identifier, or null
+    */
+   public TemplateGraphDynamicMenu(String id)
+   {
+      super(id);
+   }
+   
+   @Override
+   public void initialize(IServiceLocator serviceLocator)
+   {
+      evalService = (IEvaluationService)serviceLocator.getService(IEvaluationService.class);
+   }
+   
+   /* (non-Javadoc)
+    * @see org.eclipse.jface.action.ContributionItem#fill(org.eclipse.swt.widgets.Menu, int)
+    */
+   @Override
+   public void fill(Menu menu, int index)
+   {
+      Object selection = evalService.getCurrentState().getVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
+      if ((selection == null) || !(selection instanceof IStructuredSelection) || ((IStructuredSelection)selection).size() != 1)
+         return;
+      
+      AbstractNode firstNode = null;
+      for(Object o : ((IStructuredSelection)selection).toList())
+      {
+         if (o instanceof AbstractNode)
+         {
+            firstNode = (AbstractNode)o;
+            break;
+         }
+      }
+      
+      if(firstNode == null)
+         return;
+
+      final AbstractNode node = firstNode;
+      GraphSettings[] settings = GraphTemplateCache.getInstance().getGraphTemplates(); //array should be already sorted
+      final Menu graphMenu = new Menu(menu);
+      
+      Map<String, Menu> menus = new HashMap<String, Menu>();
+      int added = 0;
+      for(int i = 0; i < settings.length; i++)
+      {
+         if(settings[i].isApplicableForNode(node))
+         {
+            String[] path = settings[i].getName().split("\\-\\>"); //$NON-NLS-1$
+            
+            Menu rootMenu = graphMenu;
+            for(int j = 0; j < path.length - 1; j++)
+            {
+               final String key = rootMenu.hashCode() + "@" + path[j].replace("&", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+               Menu currMenu = menus.get(key);
+               if (currMenu == null)
+               {
+                  currMenu = new Menu(rootMenu);
+                  MenuItem item = new MenuItem(rootMenu, SWT.CASCADE);
+                  item.setText(path[j]);
+                  item.setMenu(currMenu);
+                  menus.put(key, currMenu);
+               }
+               rootMenu = currMenu;
+            }
+            
+            final MenuItem item = new MenuItem(rootMenu, SWT.PUSH);
+            item.setText(path[path.length - 1]);
+            item.setData(settings[i]);
+            item.addSelectionListener(new SelectionAdapter() {
+               @Override
+               public void widgetSelected(SelectionEvent e)
+               {
+                  final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
+                  ConsoleJob job = new ConsoleJob("Get last values of " + node.getObjectName() , null, Activator.PLUGIN_ID, null) {
+                     @Override
+                     protected String getErrorMessage()
+                     {
+                        return "Not possible to get last values for node" + node.getObjectName();
+                     }
+
+                     @Override
+                     protected void runInternal(IProgressMonitor monitor) throws Exception
+                     {
+                        
+                        final DciValue[] data = session.getLastValues(node.getObjectId());
+                        runInUIThread(new Runnable() {
+                           @Override
+                           public void run()
+                           {
+                              GraphTemplateCache.execute(node, (GraphSettings)item.getData(), data);
+                           }
+                        });
+                     }
+                  };
+                  job.setUser(false);
+                  job.start();
+               }
+            });
+            
+            added++;
+         }
+      }
+      
+      if (added > 0)
+      {
+         MenuItem graphMenuItem = new MenuItem(menu, SWT.CASCADE, index);
+         graphMenuItem.setText("Graphs");
+         graphMenuItem.setMenu(graphMenu);
+      }
+      else
+      {
+         graphMenu.dispose();
+      }
+   }
+}
diff --git a/src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/XmlDateConverter.java b/src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/XmlDateConverter.java
deleted file mode 100644 (file)
index 64b39be..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * NetXMS - open source network management system
- * 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
- * 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.perfview;
-
-import java.util.Date;
-import org.simpleframework.xml.convert.Converter;
-import org.simpleframework.xml.stream.InputNode;
-import org.simpleframework.xml.stream.OutputNode;
-
-/**
- * Converter for date serialization/deserialization
- */
-public class XmlDateConverter implements Converter<Date>
-{
-       /* (non-Javadoc)
-        * @see org.simpleframework.xml.convert.Converter#read(org.simpleframework.xml.stream.InputNode)
-        */
-       @Override
-       public Date read(InputNode node) throws Exception
-       {
-               long n;
-               try
-               {
-                       n = Long.parseLong(node.getValue());
-               }
-               catch(NumberFormatException e)
-               {
-                       n = System.currentTimeMillis();
-               }
-               return new Date(n);
-       }
-
-       /* (non-Javadoc)
-        * @see org.simpleframework.xml.convert.Converter#write(org.simpleframework.xml.stream.OutputNode, java.lang.Object)
-        */
-       @Override
-       public void write(OutputNode node, Date object) throws Exception
-       {
-               node.setValue(Long.toString(object.getTime()));
-       }
-}
diff --git a/src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/actions/OpenGraphTemplateView.java b/src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/actions/OpenGraphTemplateView.java
new file mode 100644 (file)
index 0000000..7f02263
--- /dev/null
@@ -0,0 +1,80 @@
+/**
+ * NetXMS - open source network management system
+ * Copyright (C) 2003-2010 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.perfview.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PartInitException;
+import org.netxms.ui.eclipse.perfview.views.TemplateGraphView;
+import org.netxms.ui.eclipse.tools.MessageDialogHelper;
+
+/**
+ * @author Victor
+ *
+ */
+public class OpenGraphTemplateView implements IWorkbenchWindowActionDelegate
+{
+       private IWorkbenchWindow window;
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+        */
+       @Override
+       public void dispose()
+       {
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+        */
+       @Override
+       public void init(IWorkbenchWindow window)
+       {
+               this.window = window;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+        */
+       @Override
+       public void run(IAction action)
+       {
+               if(window != null)
+               {       
+                       try 
+                       {
+                               window.getActivePage().showView(TemplateGraphView.ID);
+                       } 
+                       catch (PartInitException e) 
+                       {
+                               MessageDialogHelper.openError(window.getShell(), "Cannot open Template Graph View", String.format("Error: %s", e.getMessage()));
+                       }
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+        */
+       @Override
+       public void selectionChanged(IAction action, ISelection selection)
+       {
+       }
+}
diff --git a/src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/api/GraphTemplateCache.java b/src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/api/GraphTemplateCache.java
new file mode 100644 (file)
index 0000000..e16e35e
--- /dev/null
@@ -0,0 +1,227 @@
+package org.netxms.ui.eclipse.perfview.api;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.regex.Pattern;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.netxms.client.NXCSession;
+import org.netxms.client.SessionListener;
+import org.netxms.client.SessionNotification;
+import org.netxms.client.datacollection.ChartDciConfig;
+import org.netxms.client.datacollection.DciValue;
+import org.netxms.client.datacollection.GraphSettings;
+import org.netxms.client.objects.AbstractNode;
+import org.netxms.ui.eclipse.objects.ObjectContext;
+import org.netxms.ui.eclipse.perfview.Activator;
+import org.netxms.ui.eclipse.perfview.Messages;
+import org.netxms.ui.eclipse.perfview.views.HistoricalGraphView;
+import org.netxms.ui.eclipse.tools.MessageDialogHelper;
+
+public class GraphTemplateCache
+{
+   private static GraphTemplateCache instance = null;
+
+   private NXCSession session = null;
+   private List<GraphSettings> templateList= new ArrayList<GraphSettings>();
+   
+   /**
+    * GraphTemplateCache constructor
+    * 
+    * @param session
+    */
+   public GraphTemplateCache(NXCSession session)
+   {
+      this.session = session;
+      
+      reload();
+      
+      session.addListener(new SessionListener() {
+         
+         @Override
+         public void notificationHandler(SessionNotification n)
+         {
+            switch(n.getCode())
+            {
+               case SessionNotification.PREDEFINED_GRAPHS_DELETED:
+               {
+                  
+                  for(int i = 0; i < templateList.size(); i++)
+                     if(templateList.get(i).getId() == n.getSubCode())
+                     {
+                        Object o = templateList.get(i);
+                        templateList.remove(o);
+                        break;
+                     }
+                  break;
+               }
+               case SessionNotification.PREDEFINED_GRAPHS_CHANGED:
+               {                  
+                  if(!(n.getObject() instanceof GraphSettings) || !((GraphSettings)n.getObject()).isTemplate())
+                  {
+                     return;
+                  }      
+                  
+                  boolean objectUpdated = false;
+                        
+                  for(int i = 0; i < templateList.size(); i++)
+                  {
+                     if(templateList.get(i).getId() == n.getSubCode())
+                     {
+                        templateList.set(i, (GraphSettings)n.getObject());
+                        objectUpdated = true;
+                        break;
+                     }
+                  }
+                        
+                  if(!objectUpdated)
+                  {
+                     templateList.add((GraphSettings)n.getObject());
+                  }
+                  break;
+               }
+            }
+         }
+      });
+   }
+   
+   /**
+    * Attach session to cache
+    * 
+    * @param session
+    */
+   public static void attachSession(NXCSession session)
+   {
+      instance = new GraphTemplateCache(session);
+   }
+
+   /**
+    * Get cache instance
+    * 
+    * @return
+    */
+   public static GraphTemplateCache getInstance()
+   {
+      return instance;
+   }
+   
+   /**
+    * Reload graph templates from server
+    */
+   private void reload()
+   {
+      try
+      {
+         synchronized(templateList)
+         {
+            templateList.clear();
+            templateList = session.getPredefinedGraphs(true);
+         }
+      }
+      catch(Exception e)
+      {
+         Activator.logError("Exception in ObjectToolsCache.reload()", e); //$NON-NLS-1$
+      }      
+   }
+   
+   /**
+    * Returns array of graph templates
+    * 
+    * @return
+    */
+   public GraphSettings[] getGraphTemplates()
+   {
+      GraphSettings[] graphs = templateList.toArray(new GraphSettings[templateList.size()]);
+      Arrays.sort(graphs, new Comparator<GraphSettings>() {
+         @Override
+         public int compare(GraphSettings arg0, GraphSettings arg1)
+         {
+            return arg0.getName().replace("&", "").compareToIgnoreCase(arg1.getName().replace("&", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+         }
+      });
+      
+      return graphs;
+   }
+
+   public static void execute(final AbstractNode node, final GraphSettings data, final DciValue[] values)
+   {
+      ObjectContext ctx = new ObjectContext(node, null);
+      String name = ctx.substituteMacros(data.getTitle(), null);
+      GraphSettings result = new GraphSettings(data, name);
+      
+      ChartDciConfig[] conf = result.getDciList();
+      ArrayList<ChartDciConfig> newList = new ArrayList<ChartDciConfig>();
+      int foundByDescription = -1;
+      int foundDCICount = 0;
+      //parse config and compare name as regexp and then compare description
+      for(int i = 0; i < conf.length; i++)
+      {
+         Pattern namePattern = Pattern.compile(conf[i].dciName);
+         Pattern descriptionPattern = Pattern.compile(conf[i].dciDescription);
+         int j;
+         for(j = 0; j < values.length; j++)
+         {
+            if(!conf[i].dciName.isEmpty() && namePattern.matcher(values[j].getName()).find())
+            {
+               newList.add(new ChartDciConfig(values[j]));
+               foundDCICount++;
+               if(!conf[i].multiMatch)
+                  break;
+            }
+            if(!conf[i].dciDescription.isEmpty() && descriptionPattern.matcher(values[j].getDescription()).find())
+            {
+               foundByDescription = j;
+            }
+         }
+         
+         if(j == values.length && foundByDescription >= 0)
+         {
+            foundDCICount++;
+            newList.add(new ChartDciConfig(values[foundByDescription]));
+         }
+      }
+      if(foundDCICount > 0)
+      {
+         result.setDciList(newList.toArray(new ChartDciConfig[newList.size()]));
+         showPredefinedGraph(result);
+      }
+      else
+      {
+         MessageDialogHelper.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Graph creation from template error", "None of template graphs DCI were found on a node.");
+      }
+   }
+   
+   /**
+    * Show predefined graph view
+    * 
+    * @param gs graph settings
+    */
+   private static void showPredefinedGraph(GraphSettings gs)
+   {
+      String encodedName;
+      try
+      {
+         encodedName = URLEncoder.encode(gs.getName(), "UTF-8"); //$NON-NLS-1$
+      }
+      catch(UnsupportedEncodingException e1)
+      {
+         encodedName = "___ERROR___"; //$NON-NLS-1$
+      }
+      String id = HistoricalGraphView.PREDEFINED_GRAPH_SUBID + "&" + encodedName; //$NON-NLS-1$
+      try
+      {
+         HistoricalGraphView g = (HistoricalGraphView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(HistoricalGraphView.ID, id, IWorkbenchPage.VIEW_ACTIVATE);
+         if (g != null)
+            g.initPredefinedGraph(gs);
+      }
+      catch(PartInitException e)
+      {
+         MessageDialogHelper.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.get().PredefinedGraphTree_Error, String.format(Messages.get().PredefinedGraphTree_ErrorOpeningView, e.getLocalizedMessage()));
+      }
+   }
+}
index 6247105..602537d 100644 (file)
@@ -29,7 +29,7 @@ public class SaveGraphDlg extends Dialog
        private Label errorMessage;
        private String name;
        private Button checkOverwrite;
-       private String ErrorMessage;
+       private String errorMessageText;
        private boolean havePermissionToOverwrite;
        
        /**
@@ -39,7 +39,7 @@ public class SaveGraphDlg extends Dialog
        {
                super(parentShell);
                name = initialName;
-               ErrorMessage = message;
+               errorMessageText = message;
                this.havePermissionToOverwrite = havePermissionToOverwrite;
        }
        
@@ -75,16 +75,19 @@ public class SaveGraphDlg extends Dialog
                gd.widthHint = 400;
                fieldName.setLayoutData(gd);
                
-      if(ErrorMessage != null && havePermissionToOverwrite)
+      if(errorMessageText != null)
       {
          errorMessage = new Label(dialogArea, SWT.LEFT);
          errorMessage.setForeground(SharedColors.getColor(SharedColors.STATUS_CRITICAL, parent.getDisplay()));
          errorMessage.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-         errorMessage.setText(ErrorMessage);
-         
-         checkOverwrite = new Button(dialogArea, SWT.CHECK);
-         checkOverwrite.setText(Messages.get().SaveGraphDlg_Overwrite);
+         errorMessage.setText(errorMessageText);         
       }   
+      
+      if(havePermissionToOverwrite)
+      {
+         checkOverwrite = new Button(dialogArea, SWT.CHECK);
+         checkOverwrite.setText(Messages.get().SaveGraphDlg_Overwrite);         
+      }
                
                return dialogArea;
        }
@@ -101,7 +104,7 @@ public class SaveGraphDlg extends Dialog
                        MessageDialogHelper.openWarning(getShell(), Messages.get().SaveGraphDlg_Warning, Messages.get().SaveGraphDlg_WarningEmptyName);
                        return;
                }
-               if (ErrorMessage != null && checkOverwrite.getSelection())
+               if (havePermissionToOverwrite && checkOverwrite.getSelection())
                {
                   setReturnCode(OVERRIDE);
                   super.close();
index 22cdeb2..acc248f 100644 (file)
@@ -46,15 +46,15 @@ import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.ui.dialogs.PropertyPage;
 import org.netxms.client.NXCSession;
+import org.netxms.client.datacollection.ChartConfig;
+import org.netxms.client.datacollection.ChartDciConfig;
 import org.netxms.client.datacollection.DciValue;
-import org.netxms.ui.eclipse.charts.api.ChartDciConfig;
+import org.netxms.client.datacollection.GraphSettings;
 import org.netxms.ui.eclipse.datacollection.dialogs.DataSourceEditDlg;
 import org.netxms.ui.eclipse.datacollection.dialogs.SelectDciDialog;
 import org.netxms.ui.eclipse.jobs.ConsoleJob;
 import org.netxms.ui.eclipse.perfview.Activator;
-import org.netxms.ui.eclipse.perfview.ChartConfig;
 import org.netxms.ui.eclipse.perfview.Messages;
-import org.netxms.ui.eclipse.perfview.PredefinedChartConfig;
 import org.netxms.ui.eclipse.perfview.propertypages.helpers.DciListLabelProvider;
 import org.netxms.ui.eclipse.shared.ConsoleSharedData;
 import org.netxms.ui.eclipse.tools.ColorCache;
@@ -83,6 +83,7 @@ public class DataSources extends PropertyPage
        private Button downButton;
        private List<ChartDciConfig> dciList = null;
        private ColorCache colorCache;
+       private boolean graphIsTemplate = false;
        
        /* (non-Javadoc)
         * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
@@ -92,6 +93,8 @@ public class DataSources extends PropertyPage
        {
                config = (ChartConfig)getElement().getAdapter(ChartConfig.class);
                
+               if(config instanceof GraphSettings)
+                  graphIsTemplate = ((GraphSettings)config).isTemplate();
                Composite dialogArea = new Composite(parent, SWT.NONE);
                colorCache = new ColorCache(dialogArea);
                
@@ -334,7 +337,7 @@ public class DataSources extends PropertyPage
                if (dci == null)
                        return;
                
-               DataSourceEditDlg dlg = new DataSourceEditDlg(getShell(), dci);
+               DataSourceEditDlg dlg = new DataSourceEditDlg(getShell(), dci, graphIsTemplate);
                if (dlg.open() == Window.OK)
                {
                        viewer.update(dci, null);
@@ -398,7 +401,7 @@ public class DataSources extends PropertyPage
        protected void applyChanges(final boolean isApply)
        {
                config.setDciList(dciList.toArray(new ChartDciConfig[dciList.size()]));
-               if ((config instanceof PredefinedChartConfig) && isApply)
+               if ((config instanceof GraphSettings) && isApply)
                {
                        setValid(false);
                        final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
@@ -406,7 +409,7 @@ public class DataSources extends PropertyPage
                                @Override
                                protected void runInternal(IProgressMonitor monitor) throws Exception
                                {
-                                       session.saveGraph(((PredefinedChartConfig)config).createServerSettings(), true);
+                                       session.saveGraph((GraphSettings)config, true);
                                }
        
                                @Override
index b4db54a..731494d 100644 (file)
@@ -34,11 +34,11 @@ import org.eclipse.swt.widgets.Scale;
 import org.eclipse.swt.widgets.Spinner;
 import org.eclipse.ui.dialogs.PropertyPage;
 import org.netxms.client.NXCSession;
+import org.netxms.client.datacollection.ChartConfig;
+import org.netxms.client.datacollection.GraphSettings;
 import org.netxms.ui.eclipse.jobs.ConsoleJob;
 import org.netxms.ui.eclipse.perfview.Activator;
-import org.netxms.ui.eclipse.perfview.ChartConfig;
 import org.netxms.ui.eclipse.perfview.Messages;
-import org.netxms.ui.eclipse.perfview.PredefinedChartConfig;
 import org.netxms.ui.eclipse.perfview.widgets.YAxisRangeEditor;
 import org.netxms.ui.eclipse.shared.ConsoleSharedData;
 import org.netxms.ui.eclipse.tools.WidgetHelper;
@@ -75,7 +75,7 @@ public class General extends PropertyPage
        @Override
        protected Control createContents(Composite parent)
        {
-               config = (ChartConfig)getElement().getAdapter(ChartConfig.class);
+          config = (ChartConfig)getElement().getAdapter(ChartConfig.class);
                
                Composite dialogArea = new Composite(parent, SWT.NONE);
                
@@ -346,7 +346,7 @@ public class General extends PropertyPage
                config.setMinYScaleValue(yAxisRange.getMinY());
                config.setMaxYScaleValue(yAxisRange.getMaxY());
                
-               if ((config instanceof PredefinedChartConfig) && isApply)
+               if ((config instanceof GraphSettings) && isApply)
                {
                        setValid(false);
                        final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
@@ -354,7 +354,7 @@ public class General extends PropertyPage
                                @Override
                                protected void runInternal(IProgressMonitor monitor) throws Exception
                                {
-                                       session.saveGraph(((PredefinedChartConfig)config).createServerSettings(), true);
+                                       session.saveGraph((GraphSettings)config, true);
                                        runInUIThread(new Runnable() {
                                                @Override
                                                public void run()
index 5002fda..5fa53a3 100644 (file)
@@ -46,7 +46,6 @@ import org.netxms.client.users.AbstractUserObject;
 import org.netxms.ui.eclipse.jobs.ConsoleJob;
 import org.netxms.ui.eclipse.perfview.Activator;
 import org.netxms.ui.eclipse.perfview.Messages;
-import org.netxms.ui.eclipse.perfview.PredefinedChartConfig;
 import org.netxms.ui.eclipse.perfview.propertypages.helpers.AccessListComparator;
 import org.netxms.ui.eclipse.perfview.propertypages.helpers.AccessListLabelProvider;
 import org.netxms.ui.eclipse.shared.ConsoleSharedData;
@@ -60,7 +59,7 @@ import org.netxms.ui.eclipse.widgets.SortableTableViewer;
  */
 public class PredefinedGraph extends PropertyPage
 {
-       private PredefinedChartConfig config;
+   private GraphSettings settings;
        private LabeledText name;
        private SortableTableViewer userList;
        private HashMap<Integer, Button> accessChecks = new HashMap<Integer, Button>(2);
@@ -72,10 +71,10 @@ public class PredefinedGraph extends PropertyPage
        @Override
        protected Control createContents(Composite parent)
        {
-               config = (PredefinedChartConfig)getElement().getAdapter(PredefinedChartConfig.class);
+          settings = (GraphSettings)getElement().getAdapter(GraphSettings.class);
                
-               acl = new HashMap<Long, AccessListElement>(config.getAccessList().size());
-               for(AccessListElement e : config.getAccessList())
+               acl = new HashMap<Long, AccessListElement>(settings.getAccessList().size());
+               for(AccessListElement e : settings.getAccessList())
                        acl.put(e.getUserId(), new AccessListElement(e));
                
                // Initiate loading of user manager plugin if it was not loaded before
@@ -91,7 +90,7 @@ public class PredefinedGraph extends PropertyPage
                
       name = new LabeledText(dialogArea, SWT.NONE, SWT.BORDER);
       name.setLabel(Messages.get().PredefinedGraph_Name);
-      name.setText(config.getName());
+      name.setText(settings.getName());
       GridData gd = new GridData();
       gd.horizontalAlignment = SWT.FILL;
       gd.grabExcessHorizontalSpace = true;
@@ -279,9 +278,9 @@ public class PredefinedGraph extends PropertyPage
         */
        protected void applyChanges(final boolean isApply)
        {
-               config.setName(name.getText());
-               config.getAccessList().clear();
-               config.getAccessList().addAll(acl.values());
+          settings.setName(name.getText());
+          settings.getAccessList().clear();
+          settings.getAccessList().addAll(acl.values());
                if (isApply)
                {
                        setValid(false);
@@ -290,7 +289,7 @@ public class PredefinedGraph extends PropertyPage
                                @Override
                                protected void runInternal(IProgressMonitor monitor) throws Exception
                                {
-                                       session.saveGraph(((PredefinedChartConfig)config).createServerSettings(), true);
+                                       session.saveGraph(settings, true);
                                }
        
                                @Override
@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.Action;
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
@@ -46,16 +47,16 @@ import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.ui.dialogs.PropertyPage;
 import org.netxms.client.NXCSession;
+import org.netxms.client.datacollection.ChartConfig;
+import org.netxms.client.datacollection.ChartDciConfig;
 import org.netxms.client.datacollection.DciValue;
-import org.netxms.ui.eclipse.charts.api.ChartDciConfig;
+import org.netxms.client.datacollection.GraphSettings;
 import org.netxms.ui.eclipse.datacollection.dialogs.DataSourceEditDlg;
 import org.netxms.ui.eclipse.datacollection.dialogs.SelectDciDialog;
 import org.netxms.ui.eclipse.jobs.ConsoleJob;
 import org.netxms.ui.eclipse.perfview.Activator;
-import org.netxms.ui.eclipse.perfview.ChartConfig;
 import org.netxms.ui.eclipse.perfview.Messages;
-import org.netxms.ui.eclipse.perfview.PredefinedChartConfig;
-import org.netxms.ui.eclipse.perfview.propertypages.helpers.DciListLabelProvider;
+import org.netxms.ui.eclipse.perfview.propertypages.helpers.DciTemplateListLabelProvider;
 import org.netxms.ui.eclipse.shared.ConsoleSharedData;
 import org.netxms.ui.eclipse.tools.ColorCache;
 import org.netxms.ui.eclipse.tools.ColorConverter;
@@ -65,18 +66,19 @@ import org.netxms.ui.eclipse.widgets.SortableTableViewer;
 /**
  * DCI list editor for dashboard element
  */
-public class DataSources extends PropertyPage
+public class TemplateDataSources extends PropertyPage
 {
        public static final int COLUMN_POSITION = 0;
-       public static final int COLUMN_NODE = 1;
-       public static final int COLUMN_METRIC = 2;
+       public static final int COLUMN_NAME = 1;
+       public static final int COLUMN_DESCRIPTION = 2;
        public static final int COLUMN_LABEL = 3;
        public static final int COLUMN_COLOR = 4;
        
        private ChartConfig config;
-       private DciListLabelProvider labelProvider;
+       private DciTemplateListLabelProvider labelProvider;
        private SortableTableViewer viewer;
        private Button addButton;
+       private Button importButton;
        private Button editButton;
        private Button deleteButton;
        private Button upButton;
@@ -91,7 +93,7 @@ public class DataSources extends PropertyPage
        protected Control createContents(Composite parent)
        {
                config = (ChartConfig)getElement().getAdapter(ChartConfig.class);
-               
+
                Composite dialogArea = new Composite(parent, SWT.NONE);
                colorCache = new ColorCache(dialogArea);
                
@@ -99,8 +101,7 @@ public class DataSources extends PropertyPage
       for(ChartDciConfig dci : config.getDciList())
        dciList.add(new ChartDciConfig(dci));
       
-               labelProvider = new DciListLabelProvider(dciList);
-               labelProvider.resolveDciNames(dciList);
+               labelProvider = new DciTemplateListLabelProvider(dciList);
                
                GridLayout layout = new GridLayout();
                layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
@@ -115,7 +116,6 @@ public class DataSources extends PropertyPage
                                        SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
       viewer.setContentProvider(new ArrayContentProvider());
       viewer.setLabelProvider(labelProvider);
-      viewer.disableSorting();
       viewer.getTable().addListener(SWT.PaintItem, new Listener() {
                        @Override
                        public void handleEvent(Event event)
@@ -199,12 +199,12 @@ public class DataSources extends PropertyPage
       gridData.horizontalAlignment = SWT.RIGHT;
       rightButtons.setLayoutData(gridData);
 
-      addButton = new Button(rightButtons, SWT.PUSH);
-      addButton.setText(Messages.get().DataSources_Add);
+      importButton = new Button(rightButtons, SWT.PUSH);
+      importButton.setText("Import");
       rd = new RowData();
       rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
-      addButton.setLayoutData(rd);
-      addButton.addSelectionListener(new SelectionListener() {
+      importButton.setLayoutData(rd);
+      importButton.addSelectionListener(new SelectionListener() {
                        @Override
                        public void widgetDefaultSelected(SelectionEvent e)
                        {
@@ -214,9 +214,28 @@ public class DataSources extends PropertyPage
                        @Override
                        public void widgetSelected(SelectionEvent e)
                        {
-                               addItem();
+                               importItem();
                        }
       });
+
+      addButton = new Button(rightButtons, SWT.PUSH);
+      addButton.setText(Messages.get().DataSources_Add);
+      rd = new RowData();
+      rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
+      addButton.setLayoutData(rd);
+      addButton.addSelectionListener(new SelectionListener() {
+         @Override
+         public void widgetDefaultSelected(SelectionEvent e)
+         {
+            widgetSelected(e);
+         }
+
+         @Override
+         public void widgetSelected(SelectionEvent e)
+         {
+            addItem();
+         }
+      });
                
       editButton = new Button(rightButtons, SWT.PUSH);
       editButton.setText(Messages.get().DataSources_Modify);
@@ -301,9 +320,9 @@ public class DataSources extends PropertyPage
        }
 
        /**
-        * Add new item
+        * Import new item
         */
-       private void addItem()
+       private void importItem()
        {
                SelectDciDialog dlg = new SelectDciDialog(getShell(), 0);
                if (dlg.open() == Window.OK)
@@ -314,7 +333,6 @@ public class DataSources extends PropertyPage
                        {
                        ChartDciConfig dci = new ChartDciConfig(item);
                        
-                       labelProvider.addCacheEntry(dci.nodeId, dci.dciId, dci.name);
                        select.add(dci);
                        dciList.add(dci);           
                        }
@@ -323,7 +341,25 @@ public class DataSources extends PropertyPage
          viewer.setSelection(new StructuredSelection(select));
                }
        }
-       
+
+   /**
+    * Add new item
+    */
+   private void addItem()
+   {
+      ChartDciConfig dci = new ChartDciConfig();
+
+      DataSourceEditDlg dlg = new DataSourceEditDlg(getShell(), dci, true);
+      if (dlg.open() == Window.OK)
+      {
+         List<ChartDciConfig> select = new ArrayList<ChartDciConfig>();select.add(dci);
+         select.add(dci);
+         dciList.add(dci);
+         viewer.setInput(dciList.toArray());
+         viewer.setSelection(new StructuredSelection(select));
+      }
+   }
+       
        /**
         * Edit selected item
         */
@@ -331,13 +367,14 @@ public class DataSources extends PropertyPage
        {
                IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
                ChartDciConfig dci = (ChartDciConfig)selection.getFirstElement();
+          
                if (dci == null)
                        return;
                
-               DataSourceEditDlg dlg = new DataSourceEditDlg(getShell(), dci);
+               DataSourceEditDlg dlg = new DataSourceEditDlg(getShell(), dci, true);
                if (dlg.open() == Window.OK)
                {
-                       viewer.update(dci, null);
+                     viewer.update(dci, null);               
                }
        }
        
@@ -398,7 +435,7 @@ public class DataSources extends PropertyPage
        protected void applyChanges(final boolean isApply)
        {
                config.setDciList(dciList.toArray(new ChartDciConfig[dciList.size()]));
-               if ((config instanceof PredefinedChartConfig) && isApply)
+               if ((config instanceof GraphSettings) && isApply)
                {
                        setValid(false);
                        final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
@@ -406,7 +443,7 @@ public class DataSources extends PropertyPage
                                @Override
                                protected void runInternal(IProgressMonitor monitor) throws Exception
                                {
-                                       session.saveGraph(((PredefinedChartConfig)config).createServerSettings(), true);
+                                       session.saveGraph((GraphSettings)config, true);
                                }
        
                                @Override
@@ -416,7 +453,7 @@ public class DataSources extends PropertyPage
                                                @Override
                                                public void run()
                                                {
-                                                       DataSources.this.setValid(true);
+                                                       TemplateDataSources.this.setValid(true);
                                                }
                                        });
                                }
index 3ff0034..fedf8a6 100644 (file)
@@ -27,8 +27,8 @@ import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.swt.graphics.Image;
 import org.netxms.client.NXCSession;
+import org.netxms.client.datacollection.ChartDciConfig;
 import org.netxms.client.objects.AbstractObject;
-import org.netxms.ui.eclipse.charts.api.ChartDciConfig;
 import org.netxms.ui.eclipse.jobs.ConsoleJob;
 import org.netxms.ui.eclipse.perfview.Activator;
 import org.netxms.ui.eclipse.perfview.Messages;
diff --git a/src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/propertypages/helpers/DciTemplateListLabelProvider.java b/src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/propertypages/helpers/DciTemplateListLabelProvider.java
new file mode 100644 (file)
index 0000000..41320c4
--- /dev/null
@@ -0,0 +1,75 @@
+/**
+ * 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.perfview.propertypages.helpers;
+
+import java.util.List;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.netxms.client.datacollection.ChartDciConfig;
+import org.netxms.ui.eclipse.perfview.Messages;
+import org.netxms.ui.eclipse.perfview.propertypages.TemplateDataSources;
+
+/**
+ * Label provider for DCI list
+ */
+public class DciTemplateListLabelProvider extends LabelProvider implements ITableLabelProvider
+{
+       private List<ChartDciConfig> elementList;
+       
+       /**
+        * The constructor
+        */
+       public DciTemplateListLabelProvider(List<ChartDciConfig> elementList)
+       {
+               this.elementList = elementList;
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+        */
+       @Override
+       public Image getColumnImage(Object element, int columnIndex)
+       {
+               return null;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+        */
+       @Override
+       public String getColumnText(Object element, int columnIndex)
+       {
+               ChartDciConfig dci = (ChartDciConfig)element;
+               switch(columnIndex)
+               {
+                       case TemplateDataSources.COLUMN_POSITION:
+                               return Integer.toString(elementList.indexOf(dci) + 1);
+                       case TemplateDataSources.COLUMN_NAME:
+                               return dci.getDciName(); //$NON-NLS-1$ //$NON-NLS-2$
+                       case TemplateDataSources.COLUMN_DESCRIPTION:
+                               return dci.getDciDescription();
+                       case TemplateDataSources.COLUMN_LABEL:
+                               return dci.name;
+                       case TemplateDataSources.COLUMN_COLOR:
+                               return dci.color.equalsIgnoreCase(ChartDciConfig.UNSET_COLOR) ? Messages.get().DciListLabelProvider_Auto : dci.color;
+               }
+               return null;
+       }
+}
index b504c99..5f5c897 100644 (file)
@@ -52,6 +52,8 @@ import org.netxms.client.AccessListElement;
 import org.netxms.client.NXCException;
 import org.netxms.client.NXCSession;
 import org.netxms.client.constants.RCC;
+import org.netxms.client.datacollection.ChartConfig;
+import org.netxms.client.datacollection.ChartDciConfig;
 import org.netxms.client.datacollection.DciData;
 import org.netxms.client.datacollection.GraphItem;
 import org.netxms.client.datacollection.GraphItemStyle;
@@ -61,13 +63,11 @@ import org.netxms.client.datacollection.Threshold;
 import org.netxms.client.objects.AbstractObject;
 import org.netxms.ui.eclipse.actions.RefreshAction;
 import org.netxms.ui.eclipse.charts.api.ChartColor;
-import org.netxms.ui.eclipse.charts.api.ChartDciConfig;
 import org.netxms.ui.eclipse.charts.api.ChartFactory;
 import org.netxms.ui.eclipse.charts.api.HistoricalDataChart;
 import org.netxms.ui.eclipse.console.resources.SharedIcons;
 import org.netxms.ui.eclipse.jobs.ConsoleJob;
 import org.netxms.ui.eclipse.perfview.Activator;
-import org.netxms.ui.eclipse.perfview.ChartConfig;
 import org.netxms.ui.eclipse.perfview.Messages;
 import org.netxms.ui.eclipse.perfview.dialogs.SaveGraphDlg;
 import org.netxms.ui.eclipse.shared.ConsoleSharedData;
@@ -97,9 +97,8 @@ public class HistoricalGraphView extends ViewPart implements GraphSettingsChange
    private boolean updateInProgress = false;
    private ViewRefreshController refreshController;
    private Composite chartParent = null;
-
    private GraphSettings settings = new GraphSettings();
-   private ChartConfig config = new ChartConfig();
+   private boolean useMoreThanOneShoucrNode = false;
 
    private Action actionRefresh;
    private Action actionAutoRefresh;
@@ -120,6 +119,7 @@ public class HistoricalGraphView extends ViewPart implements GraphSettingsChange
    private Action actionLegendBottom;
    private Action actionProperties;
    private Action actionSave;
+   private Action actionSaveAsTemplate;
    private Action[] presetActions;
    private Action actionCopyImage;
    
@@ -146,8 +146,8 @@ public class HistoricalGraphView extends ViewPart implements GraphSettingsChange
 
       session = (NXCSession)ConsoleSharedData.getSession();
 
-      config.setTimeFrom(new Date(System.currentTimeMillis() - config.getTimeRangeMillis()));
-      config.setTimeTo(new Date(System.currentTimeMillis()));
+      settings.setTimeFrom(new Date(System.currentTimeMillis() - settings.getTimeRangeMillis()));
+      settings.setTimeTo(new Date(System.currentTimeMillis()));
 
       // Extract DCI ids from view id
       // (first field will be unique view id, so we skip it)
@@ -167,6 +167,8 @@ public class HistoricalGraphView extends ViewPart implements GraphSettingsChange
                   dci.nodeId = Long.parseLong(subfields[0], 10);
                   dci.dciId = Long.parseLong(subfields[1], 10);
                   dci.name = URLDecoder.decode(subfields[5], "UTF-8"); //$NON-NLS-1$
+                  dci.dciName = URLDecoder.decode(subfields[4], "UTF-8"); //$NON-NLS-1$
+                  dci.dciDescription = URLDecoder.decode(subfields[5], "UTF-8"); //$NON-NLS-1$
                   items.add(dci);
                }
                catch(NumberFormatException e)
@@ -187,6 +189,7 @@ public class HistoricalGraphView extends ViewPart implements GraphSettingsChange
                   dci.nodeId = Long.parseLong(subfields[0], 10);
                   dci.dciId = Long.parseLong(subfields[1], 10);
                   dci.name = URLDecoder.decode(subfields[5], "UTF-8"); //$NON-NLS-1$
+                  dci.dciName = URLDecoder.decode(subfields[5], "UTF-8"); //$NON-NLS-1$
                   dci.instance = URLDecoder.decode(subfields[6], "UTF-8"); //$NON-NLS-1$
                   dci.column = URLDecoder.decode(subfields[7], "UTF-8"); //$NON-NLS-1$
                   items.add(dci);
@@ -231,8 +234,8 @@ public class HistoricalGraphView extends ViewPart implements GraphSettingsChange
                }
             }
          }
-         config.setTitle(getPartName());
-         config.setDciList(items.toArray(new ChartDciConfig[items.size()]));
+         settings.setTitle(getPartName());
+         settings.setDciList(items.toArray(new ChartDciConfig[items.size()]));
       }
    }
 
@@ -250,7 +253,7 @@ public class HistoricalGraphView extends ViewPart implements GraphSettingsChange
       {
          try
          {
-            config = ChartConfig.createFromXml(memento.getTextData());
+            settings = GraphSettings.createFromXml(memento.getTextData());
          }
          catch(Exception e)
          {
@@ -269,7 +272,7 @@ public class HistoricalGraphView extends ViewPart implements GraphSettingsChange
    {
       try
       {
-         memento.putTextData(config.createXml());
+         memento.putTextData(settings.createXml());
       }
       catch(Exception e)
       {
@@ -284,14 +287,6 @@ public class HistoricalGraphView extends ViewPart implements GraphSettingsChange
    public void initPredefinedGraph(GraphSettings gs)
    {
       settings = gs;
-      try
-      {
-         config = ChartConfig.createFromXml(settings.getConfig());
-      }
-      catch(Exception e)
-      {
-         e.printStackTrace();
-      }
       settings.addChangeListener(this);
       configureGraphFromSettings();
    }
@@ -307,29 +302,31 @@ public class HistoricalGraphView extends ViewPart implements GraphSettingsChange
       createPopupMenu();
 
       // General settings
-      setPartName(config.getTitle());
-      chart.setChartTitle(config.getTitle());
+      setPartName(settings.getTitle());
+      chart.setChartTitle(settings.getTitle());
 
       // Chart visual settings
-      chart.setLogScaleEnabled(config.isLogScale());
-      chart.setGridVisible(config.isShowGrid());
-      chart.setLegendVisible(config.isShowLegend());
-      chart.setLegendPosition(config.getLegendPosition());
-      chart.setExtendedLegend(config.isExtendedLegend());
-      chart.setStacked(config.isStacked());
-      chart.setTranslucent(config.isTranslucent());
-      chart.setLineWidth(config.getLineWidth());
-      if(!config.isAutoScale())
+      chart.setLogScaleEnabled(settings.isLogScale());
+      chart.setGridVisible(settings.isShowGrid());
+      chart.setLegendVisible(settings.isShowLegend());
+      chart.setLegendPosition(settings.getLegendPosition());
+      chart.setExtendedLegend(settings.isExtendedLegend());
+      chart.setStacked(settings.isStacked());
+      chart.setTranslucent(settings.isTranslucent());
+      chart.setLineWidth(settings.getLineWidth());
+      if(!settings.isAutoScale())
       {
-         chart.setYAxisRange(config.getMinYScaleValue(), config.getMaxYScaleValue());
+         chart.setYAxisRange(settings.getMinYScaleValue(), settings.getMaxYScaleValue());
       }
 
       // Data
-      final List<GraphItemStyle> styles = new ArrayList<GraphItemStyle>(config.getDciList().length);
+      final List<GraphItemStyle> styles = new ArrayList<GraphItemStyle>(settings.getDciList().length);
       int index = 0;
-      for(ChartDciConfig dci : config.getDciList())
+      int nodeId = 0;
+      for(ChartDciConfig dci : settings.getDciList())
       {
-         final String name = config.isShowHostNames() ? (session.getObjectName(dci.nodeId) + " - " + dci.getName()) : dci.getName(); //$NON-NLS-1$
+         nodeId |= dci.nodeId; //Check that all DCI's are form one node
+         final String name = settings.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, dci.getDisplayFormat()));
          int color = dci.getColorAsInt();
          if (color == -1)
@@ -337,20 +334,25 @@ public class HistoricalGraphView extends ViewPart implements GraphSettingsChange
          styles.add(new GraphItemStyle(getDisplayType(dci), color, 2, dci.invertValues ? GraphItemStyle.INVERTED : 0));
          index++;
       }
+      
+      //Check that all DCI's are form one node
+      if(index > 0)
+         useMoreThanOneShoucrNode = (nodeId != settings.getDciList()[0].nodeId);
+      
       chart.setItemStyles(styles);
 
-      if (config.getTimeFrameType() == GraphSettings.TIME_FRAME_BACK_FROM_NOW)
+      if (settings.getTimeFrameType() == GraphSettings.TIME_FRAME_BACK_FROM_NOW)
       {
-         config.setTimeFrom(new Date(System.currentTimeMillis() - config.getTimeRangeMillis()));
-         config.setTimeTo(new Date(System.currentTimeMillis()));
+         settings.setTimeFrom(new Date(System.currentTimeMillis() - settings.getTimeRangeMillis()));
+         settings.setTimeTo(new Date(System.currentTimeMillis()));
       }
 
       getDataFromServer();
 
       // Automatic refresh
-      actionAutoRefresh.setChecked(config.isAutoRefresh());
+      actionAutoRefresh.setChecked(settings.isAutoRefresh());
       refreshMenuSelection();
-      refreshController.setInterval(config.isAutoRefresh() ? config.getRefreshRate() : -1);
+      refreshController.setInterval(settings.isAutoRefresh() ? settings.getRefreshRate() : -1);
    }
    
    /**
@@ -367,7 +369,7 @@ public class HistoricalGraphView extends ViewPart implements GraphSettingsChange
          case ChartDciConfig.LINE:
             return GraphItemStyle.LINE;
          default:
-            return config.isArea() ? GraphItemStyle.AREA : GraphItemStyle.LINE;
+            return settings.isArea() ? GraphItemStyle.AREA : GraphItemStyle.LINE;
       } 
    }
 
@@ -417,7 +419,7 @@ public class HistoricalGraphView extends ViewPart implements GraphSettingsChange
     */
    private void getDataFromServer()
    {
-      final ChartDciConfig[] dciList = config.getDciList();
+      final ChartDciConfig[] dciList = settings.getDciList();
 
       // Request data from server
       ConsoleJob job = new ConsoleJob(Messages.get().HistoricalGraphView_JobName, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
@@ -434,14 +436,14 @@ public class HistoricalGraphView extends ViewPart implements GraphSettingsChange
                currentItem = dciList[i];
                if (currentItem.type == ChartDciConfig.ITEM)
                {
-                  data[i] = session.getCollectedData(currentItem.nodeId, currentItem.dciId, config.getTimeFrom(),
-                        config.getTimeTo(), 0);
+                  data[i] = session.getCollectedData(currentItem.nodeId, currentItem.dciId, settings.getTimeFrom(),
+                        settings.getTimeTo(), 0);
                   thresholds[i] = session.getThresholds(currentItem.nodeId, currentItem.dciId);
                }
           &nb