diff --git a/utils/java/eclipse_plugin/plugin.xml b/utils/java/eclipse_plugin/plugin.xml
index 7c8ef85cef6..3db9ccb030b 100644
--- a/utils/java/eclipse_plugin/plugin.xml
+++ b/utils/java/eclipse_plugin/plugin.xml
@@ -67,6 +67,20 @@
menubarPath="additions">
+
+
+
+
defines, boolean useThread)
+ {
+ try{
+ List arguments = new ArrayList();
+
+ if (defines != null && !defines.isEmpty())
+ {
+ String argument = "-p=";
+ for(int i=0;i properties)
+ public static String runAnt(String antFile, HashMap properties, boolean recordOutput)
{
final Project project = new Project();
ByteArrayOutputStream out=null;
@@ -30,7 +31,8 @@ public class AntUtils
try
{
out = new ByteArrayOutputStream();
- project.addBuildListener(AntUtils.createLogger(out));
+ if (recordOutput)
+ project.addBuildListener(AntUtils.createLogger(out));
project.init();
File buildFile = new File(antFile);
ProjectHelper.configureProject(project, buildFile);
@@ -43,13 +45,14 @@ public class AntUtils
project.setUserProperty(key,value);
}
project.executeTarget(project.getDefaultTarget());
+
+ return out.toString();
}
- catch (RuntimeException exc)
+ catch (Exception exc)
{
exc.printStackTrace();
+ return null;
}
-
- return out.toString();
}
/**
diff --git a/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WorkspaceUtils.java b/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WorkspaceUtils.java
index de89fcdbba4..13462381761 100644
--- a/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WorkspaceUtils.java
+++ b/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WorkspaceUtils.java
@@ -3,16 +3,24 @@
*/
package wesnoth_eclipse_plugin.utils;
+import java.io.File;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchWindow;
import wesnoth_eclipse_plugin.Activator;
+import wesnoth_eclipse_plugin.preferences.PreferenceConstants;
+import wesnoth_eclipse_plugin.preferences.PreferenceInitializer;
public class WorkspaceUtils
{
+ private static String temporaryFolder_ = "";
+
public static IProject getSelectedProject(IWorkbenchWindow window)
{
IStructuredSelection selection = getSelectedStructuredSelection(window);
@@ -43,19 +51,52 @@ public class WorkspaceUtils
public static IStructuredSelection getSelectedStructuredSelection(IWorkbenchWindow window)
{
if (window == null)
- {
- System.out.println("WokbenchWindow NULL!!");
return null;
- }
if (!(window.getSelectionService().getSelection() instanceof IStructuredSelection))
return null;
return (IStructuredSelection)window.getSelectionService().getSelection();
}
+
+ /**
+ * Returns the first WorkbenchWindow available.
+ * This is not always the same with ActiveWorkbecnWindow
+ * @return
+ */
public static IWorkbenchWindow getWorkbenchWindow()
{
if (Activator.getDefault().getWorkbench().getWorkbenchWindowCount() == 0)
return null;
return Activator.getDefault().getWorkbench().getWorkbenchWindows()[0];
}
+
+ /**
+ * Returns the temporary folder where the plugin can write resources
+ * @return
+ */
+ public static String getTemporaryFolder()
+ {
+ if (temporaryFolder_.isEmpty())
+ {
+ temporaryFolder_ = System.getProperty("java.io.tmpdir") + Path.SEPARATOR +
+ "wesnoth_plugin" + Path.SEPARATOR;
+
+ File tmpFile = new File(temporaryFolder_);
+ if (!tmpFile.exists())
+ tmpFile.mkdirs();
+ }
+ return temporaryFolder_;
+ }
+
+ /**
+ * Returns the resource path relative to the user directory
+ * @param resource the resource to be computed
+ * @return
+ */
+ public static String getPathRelativeToUserDir(IResource resource)
+ {
+ return PreferenceInitializer.getString(PreferenceConstants.P_WESNOTH_USER_DIR) + Path.SEPARATOR +
+ "data/add-ons/" + resource.getProject().getName() +
+ Path.SEPARATOR + resource.getProjectRelativePath().toOSString();
+ }
}