mail[Wesnoth-commits] r44294 - /trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WorkspaceUtils.java


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by timotei_cluj on July 18, 2010 - 16:50:
Author: timotei
Date: Sun Jul 18 16:50:09 2010
New Revision: 44294

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44294&view=rev
Log:
eclipse plugin: make 'getStructuredSelection' thread safe

Modified:
    
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WorkspaceUtils.java

Modified: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WorkspaceUtils.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WorkspaceUtils.java?rev=44294&r1=44293&r2=44294&view=diff
==============================================================================
--- 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WorkspaceUtils.java
 (original)
+++ 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WorkspaceUtils.java
 Sun Jul 18 16:50:09 2010
@@ -26,6 +26,7 @@
 import org.eclipse.jface.preference.PreferenceDialog;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.dialogs.PreferencesUtil;
 
@@ -64,18 +65,30 @@
                IStructuredSelection selection = 
getSelectedStructuredSelection(window);
                if (selection == null || !(selection.getFirstElement() 
instanceof IFile))
                        return null;
-
                return (IFile) selection.getFirstElement();
        }
 
-       public static IStructuredSelection 
getSelectedStructuredSelection(IWorkbenchWindow window)
+       public static IStructuredSelection 
getSelectedStructuredSelection(final IWorkbenchWindow window)
        {
                if (window == null)
                        return null;
-
-               if (!(window.getSelectionService().getSelection() instanceof 
IStructuredSelection))
-                       return null;
-               return (IStructuredSelection) 
window.getSelectionService().getSelection();
+               MyRunnable<IStructuredSelection> runnable = new 
MyRunnable<IStructuredSelection>(null){
+                       @Override
+                       public void run()
+                       {
+                               try{
+                                       runnableObject_ = null;
+                                       if 
(!(window.getSelectionService().getSelection() instanceof 
IStructuredSelection))
+                                               return;
+                                       runnableObject_ = 
(IStructuredSelection) window.getSelectionService().getSelection();
+                               }
+                               catch (Exception e) {
+                                       e.printStackTrace();
+                               }
+                       }
+               };
+               Display.getDefault().syncExec(runnable);
+               return runnable.runnableObject_;
        }
 
        public static IProject getSelectedProject()




Related Messages


Powered by MHonArc, Updated Sun Jul 18 17:00:12 2010