fixed invalid thread access; other fixes
authorVictor Kirhenshtein <victor@netxms.org>
Mon, 13 Jan 2014 23:36:06 +0000 (01:36 +0200)
committerVictor Kirhenshtein <victor@netxms.org>
Mon, 13 Jan 2014 23:36:06 +0000 (01:36 +0200)
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/Activator.java
src/java/netxms-eclipse/PerfView/src/org/netxms/ui/eclipse/perfview/objecttabs/PerformanceTab.java
webui/webapp/DataCollection/src/org/netxms/ui/eclipse/datacollection/SourceProvider.java
webui/webapp/ObjectView/src/org/netxms/ui/eclipse/objectview/SourceProvider.java
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/Activator.java
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/objecttabs/PerformanceTab.java
webui/webapp/PerfView/src/org/netxms/ui/eclipse/perfview/views/HistoricalGraphView.java

index a1a6289..dd96d72 100644 (file)
@@ -18,6 +18,7 @@
  */
 package org.netxms.ui.eclipse.perfview;
 
+import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
@@ -89,4 +90,35 @@ public class Activator extends AbstractUIPlugin
        {
                return imageDescriptorFromPlugin(PLUGIN_ID, path);
        }
+
+   /**
+    * Log via platform logging facilities
+    * 
+    * @param msg
+    */
+   public static void logInfo(String msg)
+   {
+      log(Status.INFO, msg, null);
+   }
+
+   /**
+    * Log via platform logging facilities
+    * 
+    * @param msg
+    */
+   public static void logError(String msg, Exception e)
+   {
+      log(Status.ERROR, msg, e);
+   }
+
+   /**
+    * Log via platform logging facilities
+    * 
+    * @param msg
+    * @param e
+    */
+   public static void log(int status, String msg, Exception e)
+   {
+      getDefault().getLog().log(new Status(status, PLUGIN_ID, Status.OK, msg, e));
+   }
 }
index 3226d69..241a250 100644 (file)
@@ -38,6 +38,7 @@ import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.progress.UIJob;
 import org.netxms.client.NXCSession;
 import org.netxms.client.datacollection.PerfTabDci;
@@ -45,6 +46,7 @@ import org.netxms.client.objects.AbstractNode;
 import org.netxms.client.objects.AbstractObject;
 import org.netxms.ui.eclipse.console.resources.SharedColors;
 import org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab;
+import org.netxms.ui.eclipse.perfview.Activator;
 import org.netxms.ui.eclipse.perfview.Messages;
 import org.netxms.ui.eclipse.perfview.PerfTabGraphSettings;
 import org.netxms.ui.eclipse.perfview.objecttabs.internal.PerfTabGraph;
@@ -110,7 +112,7 @@ public class PerformanceTab extends ObjectTab
                waitingImage.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true, 2, 1));
                try
                {
-                       waitingImage.setImage(new URL("platform:/plugin/org.netxms.ui.eclipse.library/icons/loading.gif")); //$NON-NLS-1$
+                       waitingImage.setImage(new URL("platform:/plugin/org.netxms.ui.eclipse.console/icons/loading.gif")); //$NON-NLS-1$
                }
                catch(MalformedURLException e)
                {
@@ -125,7 +127,8 @@ public class PerformanceTab extends ObjectTab
                                try
                                {
                                        final PerfTabDci[] items = session.getPerfTabItems(object.getObjectId());
-                                       new UIJob(PerformanceTab.this.getClientArea().getDisplay(), Messages.get().PerformanceTab_JobName) {
+                                       final Display display = PerformanceTab.this.getClientArea().getDisplay();
+                                       new UIJob(display, Messages.get().PerformanceTab_JobName) {
                                                @Override
                                                public IStatus runInUIThread(IProgressMonitor monitor)
                                                {
@@ -141,6 +144,7 @@ public class PerformanceTab extends ObjectTab
                                }
                                catch(Exception e)
                                {
+                                  Activator.logError("Exception in performance tab loading job", e);
                                }
                                return Status.OK_STATUS;
                        }
index 3c2144a..407a855 100644 (file)
@@ -31,6 +31,7 @@ import org.eclipse.ui.services.IServiceLocator;
  */
 public class SourceProvider extends AbstractSourceProvider
 {
+   private static final String INSTANCE_ATTRIBUTE = "netxms.datacollection.SourceProvider"; //$NON-NLS-1$
    private static final String SUMMARY_TABLES_EXIST = "org.netxms.ui.eclipse.datacollection.SummaryTablesExist";
    
    private static final String[] PROVIDED_SOURCE_NAMES = 
@@ -48,7 +49,7 @@ public class SourceProvider extends AbstractSourceProvider
     */
    public static SourceProvider getInstance(Display display)
    {
-      return (SourceProvider)RWT.getUISession(display).getAttribute("netxms.datacollection.SourceProvider");
+      return (SourceProvider)RWT.getUISession(display).getAttribute(INSTANCE_ATTRIBUTE);
    }
    
    /* (non-Javadoc)
@@ -60,7 +61,7 @@ public class SourceProvider extends AbstractSourceProvider
       super.initialize(locator);
       stateMap.put(SUMMARY_TABLES_EXIST, false);
       display = Display.getCurrent();
-      RWT.getUISession(display).setAttribute("netxms.datacollection.SourceProvider", this);
+      RWT.getUISession(display).setAttribute(INSTANCE_ATTRIBUTE, this);
    }
    
    /* (non-Javadoc)
@@ -102,5 +103,6 @@ public class SourceProvider extends AbstractSourceProvider
    @Override
    public void dispose()
    {
+      RWT.getUISession().removeAttribute(INSTANCE_ATTRIBUTE);
    }
 }
index 868531c..d265a19 100644 (file)
@@ -20,6 +20,7 @@ package org.netxms.ui.eclipse.objectview;
 
 import java.util.HashMap;
 import java.util.Map;
+import org.eclipse.rap.rwt.RWT;
 import org.eclipse.ui.AbstractSourceProvider;
 import org.eclipse.ui.ISources;
 import org.eclipse.ui.services.IServiceLocator;
@@ -29,12 +30,12 @@ import org.eclipse.ui.services.IServiceLocator;
  */
 public class SourceProvider extends AbstractSourceProvider
 {
+   private static final String INSTANCE_ATTRIBUTE = "netxms.objectview.SourceProvider"; //$NON-NLS-1$
        public static final String ACTIVE_TAB = "org.netxms.ui.eclipse.objectview.ActiveTab"; //$NON-NLS-1$
        
        private static final String[] PROVIDED_SOURCE_NAMES = new String[] { ACTIVE_TAB };
-       private static final Map<String, Object> stateMap = new HashMap<String, Object>(1);
-
-       private static SourceProvider instance = null;
+       
+       private final Map<String, Object> stateMap = new HashMap<String, Object>(1);
        
        /**
         * Get source provider instance.
@@ -43,7 +44,7 @@ public class SourceProvider extends AbstractSourceProvider
         */
        public static SourceProvider getInstance()
        {
-               return instance;
+               return (SourceProvider)RWT.getUISession().getAttribute(INSTANCE_ATTRIBUTE);
        }
        
        /* (non-Javadoc)
@@ -54,7 +55,7 @@ public class SourceProvider extends AbstractSourceProvider
        {
                super.initialize(locator);
                stateMap.put(ACTIVE_TAB, null);
-               instance = this;
+               RWT.getUISession().setAttribute(INSTANCE_ATTRIBUTE, this);
        }
 
        /* (non-Javadoc)
@@ -82,6 +83,7 @@ public class SourceProvider extends AbstractSourceProvider
        @Override
        public void dispose()
        {
+          RWT.getUISession().removeAttribute(INSTANCE_ATTRIBUTE);
        }
        
        /**
index a1a6289..dd96d72 100644 (file)
@@ -18,6 +18,7 @@
  */
 package org.netxms.ui.eclipse.perfview;
 
+import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
@@ -89,4 +90,35 @@ public class Activator extends AbstractUIPlugin
        {
                return imageDescriptorFromPlugin(PLUGIN_ID, path);
        }
+
+   /**
+    * Log via platform logging facilities
+    * 
+    * @param msg
+    */
+   public static void logInfo(String msg)
+   {
+      log(Status.INFO, msg, null);
+   }
+
+   /**
+    * Log via platform logging facilities
+    * 
+    * @param msg
+    */
+   public static void logError(String msg, Exception e)
+   {
+      log(Status.ERROR, msg, e);
+   }
+
+   /**
+    * Log via platform logging facilities
+    * 
+    * @param msg
+    * @param e
+    */
+   public static void log(int status, String msg, Exception e)
+   {
+      getDefault().getLog().log(new Status(status, PLUGIN_ID, Status.OK, msg, e));
+   }
 }
index 9b9092d..e608a7f 100644 (file)
@@ -38,6 +38,7 @@ import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.progress.UIJob;
 import org.netxms.client.NXCSession;
 import org.netxms.client.datacollection.PerfTabDci;
@@ -45,6 +46,7 @@ import org.netxms.client.objects.AbstractNode;
 import org.netxms.client.objects.AbstractObject;
 import org.netxms.ui.eclipse.console.resources.SharedColors;
 import org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab;
+import org.netxms.ui.eclipse.perfview.Activator;
 import org.netxms.ui.eclipse.perfview.Messages;
 import org.netxms.ui.eclipse.perfview.PerfTabGraphSettings;
 import org.netxms.ui.eclipse.perfview.objecttabs.internal.PerfTabGraph;
@@ -110,7 +112,7 @@ public class PerformanceTab extends ObjectTab
                waitingImage.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true, 2, 1));
                try
                {
-                       waitingImage.setImage(new URL("platform:/plugin/org.netxms.ui.eclipse.library/icons/loading.gif")); //$NON-NLS-1$
+                       waitingImage.setImage(new URL("platform:/plugin/org.netxms.webui.core/icons/progress.gif")); //$NON-NLS-1$
                }
                catch(MalformedURLException e)
                {
@@ -125,7 +127,8 @@ public class PerformanceTab extends ObjectTab
                                try
                                {
                                        final PerfTabDci[] items = session.getPerfTabItems(object.getObjectId());
-                                       new UIJob(PerformanceTab.this.getClientArea().getDisplay(), Messages.get().PerformanceTab_JobName) {
+                                       final Display display = PerformanceTab.this.getClientArea().getDisplay();
+                                       new UIJob(display, Messages.get(display).PerformanceTab_JobName) {
                                                @Override
                                                public IStatus runInUIThread(IProgressMonitor monitor)
                                                {
@@ -141,6 +144,7 @@ public class PerformanceTab extends ObjectTab
                                }
                                catch(Exception e)
                                {
+                                  Activator.logError("Exception in performance tab loading job", e);
                                }
                                return Status.OK_STATUS;
                        }
index c77fcb6..8ed20cd 100644 (file)
@@ -908,7 +908,6 @@ public class HistoricalGraphView extends ViewPart implements GraphSettingsChange
                   if (e.getErrorCode() == RCC.OBJECT_ALREADY_EXISTS)
                   {
                      runInUIThread(new Runnable() {
-
                         @Override
                         public void run()
                         {
@@ -922,7 +921,6 @@ public class HistoricalGraphView extends ViewPart implements GraphSettingsChange
                      if (e.getErrorCode() == RCC.ACCESS_DENIED)
                      {
                         runInUIThread(new Runnable() {
-
                            @Override
                            public void run()
                            {