Added automatic refreshing of dashboard if changes were made by admin. Fixes #NX1243
authorEriks Jenkevics <eriks@netxms.org>
Thu, 18 May 2017 15:24:08 +0000 (18:24 +0300)
committerEriks Jenkevics <eriks@netxms.org>
Thu, 18 May 2017 15:24:08 +0000 (18:24 +0300)
ChangeLog
src/java/netxms-eclipse/Dashboard/src/org/netxms/ui/eclipse/dashboard/views/DashboardView.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/views/DashboardView.java

index eef2441..216266a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
 *
 
 - Improved audit logging
+-Fixed issues: NX-1243, NX-1244
 
 
 *
index 82a3847..1e9ffdc 100644 (file)
@@ -41,6 +41,8 @@ import org.eclipse.ui.contexts.IContextService;
 import org.eclipse.ui.handlers.IHandlerService;
 import org.eclipse.ui.part.ViewPart;
 import org.netxms.client.NXCSession;
+import org.netxms.client.SessionListener;
+import org.netxms.client.SessionNotification;
 import org.netxms.client.constants.UserAccessRights;
 import org.netxms.client.datacollection.DciDataRow;
 import org.netxms.client.objects.Dashboard;
@@ -67,6 +69,7 @@ public class DashboardView extends ViewPart implements ISaveablePart
        public static final String ID = "org.netxms.ui.eclipse.dashboard.views.DashboardView"; //$NON-NLS-1$
        
        private NXCSession session;
+       private SessionListener clientListener;
        private Dashboard dashboard;
        private boolean readOnly = true;
        private IntermediateSelectionProvider selectionProvider;
@@ -162,9 +165,39 @@ public class DashboardView extends ViewPart implements ISaveablePart
                activateContext();
                createActions();
                contributeToActionBars();
+               
+          clientListener = new SessionListener() {         
+         @Override
+         public void notificationHandler(SessionNotification n)
+         {
+            if (n.getCode() == SessionNotification.OBJECT_CHANGED && dashboard.getObjectId() == n.getSubCode())
+            {
+               parentComposite.getDisplay().asyncExec(new Runnable() {
+                  @Override
+                  public void run()
+                  {
+                     rebuildDashboard(true);
+                  }
+               });
+            }
+         }
+      };
+      
+      session.addListener(clientListener);
        }
 
-       /**
+       /* (non-Javadoc)
+    * @see org.eclipse.ui.part.WorkbenchPart#dispose()
+    */
+   @Override
+   public void dispose()
+   {
+      if ((session != null) && (clientListener != null))
+         session.removeListener(clientListener);
+      super.dispose();
+   }
+
+   /**
     * Activate context
     */
    private void activateContext()
index 3307543..76c244c 100644 (file)
@@ -41,6 +41,8 @@ import org.eclipse.ui.contexts.IContextService;
 import org.eclipse.ui.handlers.IHandlerService;
 import org.eclipse.ui.part.ViewPart;
 import org.netxms.client.NXCSession;
+import org.netxms.client.SessionListener;
+import org.netxms.client.SessionNotification;
 import org.netxms.client.constants.UserAccessRights;
 import org.netxms.client.datacollection.DciDataRow;
 import org.netxms.client.objects.Dashboard;
@@ -68,6 +70,7 @@ public class DashboardView extends ViewPart implements ISaveablePart
        public static final String ID = "org.netxms.ui.eclipse.dashboard.views.DashboardView"; //$NON-NLS-1$
        
        private NXCSession session;
+   private SessionListener clientListener;
        private Dashboard dashboard;
        private boolean readOnly = true;
        private IntermediateSelectionProvider selectionProvider;
@@ -163,8 +166,38 @@ public class DashboardView extends ViewPart implements ISaveablePart
                activateContext();
                createActions();
                contributeToActionBars();
-       }
+               
+               clientListener = new SessionListener() {         
+         @Override
+         public void notificationHandler(SessionNotification n)
+         {
+            if (n.getCode() == SessionNotification.OBJECT_CHANGED && dashboard.getObjectId() == n.getSubCode())
+            {
+               parentComposite.getDisplay().asyncExec(new Runnable() {
+                  @Override
+                  public void run()
+                  {
+                     rebuildDashboard(true);
+                  }
+               });
+            }
+         }
+      };
+      
+      session.addListener(clientListener);
+   }
 
+   /* (non-Javadoc)
+    * @see org.eclipse.ui.part.WorkbenchPart#dispose()
+    */
+   @Override
+   public void dispose()
+   {
+      if ((session != null) && (clientListener != null))
+         session.removeListener(clientListener);
+      super.dispose();
+   }
+   
        /**
     * Activate context
     */