summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBin Feng2011-08-16 23:33:46 (EDT)
committer xgu2011-08-31 02:00:48 (EDT)
commitd749c5946f61fe1a2cd7969565cc81933ac287e7 (patch)
treee1eb60c37450d86ec807675fa93887fe1ebe6b1e
parentd1bf2361f8c6aefb4ec0167840f9e76c1a288250 (diff)
downloadorg.eclipse.birt-d749c5946f61fe1a2cd7969565cc81933ac287e7.zip
org.eclipse.birt-d749c5946f61fe1a2cd7969565cc81933ac287e7.tar.gz
org.eclipse.birt-d749c5946f61fe1a2cd7969565cc81933ac287e7.tar.bz2
Fix resource folder could not be resolved while it is set to none default value "current_project".
-rw-r--r--UI/org.eclipse.birt.report.designer.ui.data/src/org/eclipse/birt/report/designer/data/ui/util/DTPUtil.java37
1 files changed, 35 insertions, 2 deletions
diff --git a/UI/org.eclipse.birt.report.designer.ui.data/src/org/eclipse/birt/report/designer/data/ui/util/DTPUtil.java b/UI/org.eclipse.birt.report.designer.ui.data/src/org/eclipse/birt/report/designer/data/ui/util/DTPUtil.java
index d7e9c74..fe00005 100644
--- a/UI/org.eclipse.birt.report.designer.ui.data/src/org/eclipse/birt/report/designer/data/ui/util/DTPUtil.java
+++ b/UI/org.eclipse.birt.report.designer.ui.data/src/org/eclipse/birt/report/designer/data/ui/util/DTPUtil.java
@@ -35,6 +35,7 @@ import org.eclipse.birt.report.model.api.OdaDataSetHandle;
import org.eclipse.birt.report.model.api.OdaDataSourceHandle;
import org.eclipse.birt.report.model.api.activity.SemanticException;
import org.eclipse.birt.report.model.api.elements.structures.OdaDataSetParameter;
+import org.eclipse.core.resources.IProject;
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.eclipse.datatools.connectivity.oda.consumer.helper.DriverExtensionHelper;
import org.eclipse.datatools.connectivity.oda.design.DataSetDesign;
@@ -49,6 +50,7 @@ import org.eclipse.datatools.connectivity.oda.design.ui.designsession.DesignSess
import org.eclipse.datatools.connectivity.oda.util.ResourceIdentifiers;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.widgets.Display;
/**
* A Utility Class to handle procedures needed to be done <br>
@@ -408,7 +410,7 @@ public class DTPUtil
*/
public URI getBIRTResourcePath( )
{
- if ( UIUtil.getCurrentProject( ) == null )
+ if ( getCurrentProject( ) == null )
{
try
{
@@ -426,7 +428,7 @@ public class DTPUtil
try
{
return new URI( encode( ReportPlugin.getDefault( )
- .getResourceFolder( UIUtil.getCurrentProject( ),
+ .getResourceFolder( getCurrentProject( ),
(ModuleHandle) null ) ) );
}
catch ( URISyntaxException e )
@@ -434,6 +436,37 @@ public class DTPUtil
return null;
}
}
+
+ /**
+ * Guarantee getting current project within the scope of UI thread.
+ *
+ * @return Reference to IProject
+ */
+ private IProject getCurrentProject( )
+ {
+ final IProject[] project = new IProject[1];
+ Display display = Display.getCurrent( );
+ if ( display == null )
+ {
+ display = Display.getDefault( );
+ }
+
+ if ( display.getThread( ).equals( Thread.currentThread( ) ) )
+ {
+ project[0] = UIUtil.getCurrentProject( );
+ }
+ else
+ {
+ display.syncExec( new Runnable( ) {
+
+ public void run( )
+ {
+ project[0] = UIUtil.getCurrentProject( );
+ }
+ } );
+ }
+ return project[0];
+ }
private String encode( String location )
{