diff --git a/utils/umc_dev/org.wesnoth/src/org/wesnoth/builder/WesnothProjectBuilder.java b/utils/umc_dev/org.wesnoth/src/org/wesnoth/builder/WesnothProjectBuilder.java index bca58a2d6f2..0f0f4e13d3b 100644 --- a/utils/umc_dev/org.wesnoth/src/org/wesnoth/builder/WesnothProjectBuilder.java +++ b/utils/umc_dev/org.wesnoth/src/org/wesnoth/builder/WesnothProjectBuilder.java @@ -19,13 +19,6 @@ import java.util.Map; import java.util.Queue; import java.util.concurrent.LinkedBlockingDeque; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; import org.wesnoth.Constants; import org.wesnoth.Logger; import org.wesnoth.Messages; @@ -44,6 +37,14 @@ import org.wesnoth.utils.WorkspaceUtils; import org.wesnoth.wml.SimpleWMLParser; import org.wesnoth.wml.WMLConfig; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + /** * The builder does the following steps in order to create and ensure * a correct PDL (Project Dependency Lits) @@ -324,10 +325,11 @@ public class WesnothProjectBuilder extends IncrementalProjectBuilder } @SuppressWarnings( "unused" ) - private void runWMLLint( IProgressMonitor monitor, IFile file ) + private void runWMLLint( String installName, IProgressMonitor monitor, IFile file ) { monitor.subTask( String.format( "Running WMLlint on file %s ...", file.getName( ) ) ); - ExternalToolInvoker tool = WMLTools.runWMLLint(file.getLocation().toOSString(), false, false); + ExternalToolInvoker tool = WMLTools.runWMLLint( installName, + file.getLocation().toOSString(), false, false ); tool.waitForTool(); try { @@ -351,10 +353,11 @@ public class WesnothProjectBuilder extends IncrementalProjectBuilder * @throws CoreException */ @SuppressWarnings( "unused" ) - private void runWMLScope( IProgressMonitor monitor, IFile file ) + private void runWMLScope( String installName, IProgressMonitor monitor, IFile file ) { monitor.subTask( String.format( "Running WMLScope on file %s ...", file.getName( ) ) ); - ExternalToolInvoker tool = WMLTools.runWMLScope( file.getLocation().toOSString(), false ); + ExternalToolInvoker tool = WMLTools.runWMLScope( installName, + file.getLocation().toOSString(), false ); tool.waitForTool(); try { diff --git a/utils/umc_dev/org.wesnoth/src/org/wesnoth/preprocessor/Define.java b/utils/umc_dev/org.wesnoth/src/org/wesnoth/preprocessor/Define.java index b344cf3e23b..85d657edba6 100644 --- a/utils/umc_dev/org.wesnoth/src/org/wesnoth/preprocessor/Define.java +++ b/utils/umc_dev/org.wesnoth/src/org/wesnoth/preprocessor/Define.java @@ -103,10 +103,11 @@ public class Define * @param file * @return Returns a map of defines */ - public static Map readDefines(String file) + public static Map readDefines( String installName, String file ) { DefinesSAXHandler handler = (DefinesSAXHandler) ResourceUtils. - getWMLSAXHandlerFromResource(file, new DefinesSAXHandler()); + getWMLSAXHandlerFromResource( installName, file, + new DefinesSAXHandler( ) ); if (handler != null){ Logger.getInstance().log("loaded " + handler.getDefines().size() + " defines for file:" + file); //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/utils/umc_dev/org.wesnoth/src/org/wesnoth/projects/ProjectCache.java b/utils/umc_dev/org.wesnoth/src/org/wesnoth/projects/ProjectCache.java index 85e09dbd61d..f4e49c6c547 100644 --- a/utils/umc_dev/org.wesnoth/src/org/wesnoth/projects/ProjectCache.java +++ b/utils/umc_dev/org.wesnoth/src/org/wesnoth/projects/ProjectCache.java @@ -21,7 +21,6 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import org.eclipse.core.resources.IProject; import org.wesnoth.Constants; import org.wesnoth.Logger; import org.wesnoth.builder.DependencyListBuilder; @@ -33,6 +32,8 @@ import org.wesnoth.wml.WMLConfig; import org.wesnoth.wml.WMLTag; import org.wesnoth.wml.WMLVariable; +import org.eclipse.core.resources.IProject; + /** * A class that stores some project specific infos * for current session. @@ -202,7 +203,7 @@ public class ProjectCache implements Serializable if (definesFile_.exists() == false) return; - defines_ = Define.readDefines(definesFile_.getAbsolutePath()); + defines_ = Define.readDefines( getInstallName( ), definesFile_.getAbsolutePath( ) ); definesTimestamp_ = definesFile_.lastModified( ); } diff --git a/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/ResourceUtils.java b/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/ResourceUtils.java index d1f629b3d98..db67c9e8ed4 100644 --- a/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/ResourceUtils.java +++ b/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/ResourceUtils.java @@ -28,6 +28,19 @@ import java.util.Set; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import org.wesnoth.Constants; +import org.wesnoth.Logger; +import org.wesnoth.Messages; +import org.wesnoth.builder.DependencyListNode; +import org.wesnoth.preferences.Preferences.Paths; +import org.wesnoth.projects.ProjectUtils; +import org.wesnoth.templates.ReplaceableParameter; +import org.wesnoth.templates.TemplateProvider; +import org.wesnoth.wml.SimpleWMLParser; +import org.wesnoth.wml.WMLMacroCall; +import org.wesnoth.wml.WMLRoot; +import org.wesnoth.wml.WmlFactory2; + import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; @@ -47,18 +60,7 @@ import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; import org.eclipse.swt.SWT; -import org.wesnoth.Constants; -import org.wesnoth.Logger; -import org.wesnoth.Messages; -import org.wesnoth.builder.DependencyListNode; -import org.wesnoth.preferences.Preferences.Paths; -import org.wesnoth.projects.ProjectUtils; -import org.wesnoth.templates.ReplaceableParameter; -import org.wesnoth.templates.TemplateProvider; -import org.wesnoth.wml.SimpleWMLParser; -import org.wesnoth.wml.WMLMacroCall; -import org.wesnoth.wml.WMLRoot; -import org.wesnoth.wml.WmlFactory2; + import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; @@ -491,10 +493,10 @@ public class ResourceUtils * @param saxHandler The SAX Handler used to handle the parsed wml * @return */ - public static DefaultHandler getWMLSAXHandlerFromResource(String resourcePath, - DefaultHandler saxHandler) + public static DefaultHandler getWMLSAXHandlerFromResource( String installName, + String resourcePath, DefaultHandler saxHandler) { - ExternalToolInvoker parser = WMLTools.runWMLParser2(resourcePath); + ExternalToolInvoker parser = WMLTools.runWMLParser2( installName, resourcePath); if (parser == null) return null; try{ diff --git a/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WMLTools.java b/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WMLTools.java index a0eb7c06b7a..48d54ae1779 100644 --- a/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WMLTools.java +++ b/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WMLTools.java @@ -19,6 +19,13 @@ import java.util.List; import java.util.Locale; import java.util.concurrent.atomic.AtomicInteger; +import org.wesnoth.Constants; +import org.wesnoth.Logger; +import org.wesnoth.Messages; +import org.wesnoth.installs.WesnothInstallsUtils; +import org.wesnoth.preferences.Preferences; +import org.wesnoth.preferences.Preferences.Paths; + import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.WorkspaceJob; @@ -27,12 +34,6 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.ui.IEditorReference; import org.eclipse.ui.console.MessageConsole; -import org.wesnoth.Constants; -import org.wesnoth.Logger; -import org.wesnoth.Messages; -import org.wesnoth.installs.WesnothInstallsUtils; -import org.wesnoth.preferences.Preferences; -import org.wesnoth.preferences.Preferences.Paths; public class WMLTools { @@ -46,10 +47,11 @@ public class WMLTools * @param stderr The array of streams where to output the stderr content * @return null if there were errors or an ExternalToolInvoker instance */ - public static ExternalToolInvoker runWMLIndent(String resourcePath, String stdin, - boolean dryrun, OutputStream[] stdout, OutputStream[] stderr) + public static ExternalToolInvoker runWMLIndent( String installName, + String resourcePath, String stdin, boolean dryrun, + OutputStream[] stdout, OutputStream[] stderr ) { - Paths paths = Preferences.getPaths( WesnothInstallsUtils.getInstallNameForResource( resourcePath ) ); + Paths paths = Preferences.getPaths( installName ); //wmlindent only check first if ( !checkWMLTool( paths, Tools.WMLINDENT.toString( ) ) ) //$NON-NLS-1$ @@ -82,9 +84,10 @@ public class WMLTools * @param resourcePath * @return null if there were errors or an ExternalToolInvoker instance */ - public static ExternalToolInvoker runWMLParser2(String resourcePath) + public static ExternalToolInvoker runWMLParser2( String installName, + String resourcePath ) { - Paths paths = Preferences.getPaths( WesnothInstallsUtils.getInstallNameForResource( resourcePath ) ); + Paths paths = Preferences.getPaths( installName ); if ( !ResourceUtils.isValidFilePath( resourcePath ) || !checkWMLTool( paths, "wesnoth/wmlparser2.py" ) ) //$NON-NLS-1$ @@ -129,9 +132,11 @@ public class WMLTools * @param showProgress true to show the progress of the tool * @return null if there were errors or an ExternalToolInvoker instance */ - public static ExternalToolInvoker runWMLLint(String resourcePath, boolean dryrun, boolean showProgress) + public static ExternalToolInvoker runWMLLint( String installName, + String resourcePath, boolean dryrun, boolean showProgress ) { - return runWMLLint(resourcePath, dryrun, showProgress, new OutputStream[0], new OutputStream[0]); + return runWMLLint( installName, resourcePath, dryrun, showProgress, + new OutputStream[0], new OutputStream[0]); } /** @@ -143,10 +148,11 @@ public class WMLTools * @param stdout The array of streams where to output the stdout content * @param stderr The array of streams where to output the stderr content */ - public static ExternalToolInvoker runWMLLint(String resourcePath, boolean dryrun, - boolean showProgress, OutputStream[] stdout, OutputStream[] stderr) + public static ExternalToolInvoker runWMLLint( String installName, + String resourcePath, boolean dryrun, boolean showProgress, + OutputStream[] stdout, OutputStream[] stderr ) { - Paths paths = Preferences.getPaths( WesnothInstallsUtils.getInstallNameForResource( resourcePath ) ); + Paths paths = Preferences.getPaths( installName ); if ( !ResourceUtils.isValidFilePath( resourcePath ) || !checkWMLTool( paths, Tools.WMLLINT.toString( ) ) ) @@ -184,9 +190,11 @@ public class WMLTools * @param resourcePath the full path of the target where "wmlindent" will be runned on * @return null if there were errors or an ExternalToolInvoker instance */ - public static ExternalToolInvoker runWMLScope(String resourcePath, boolean showProgress) + public static ExternalToolInvoker runWMLScope( String installName, + String resourcePath, boolean showProgress ) { - return runWMLScope(resourcePath, showProgress, new OutputStream[0], new OutputStream[0]); + return runWMLScope( installName, resourcePath, showProgress, + new OutputStream[0], new OutputStream[0] ); } /** @@ -197,10 +205,11 @@ public class WMLTools * @param stderr The array of streams where to output the stderr content * @return null if there were errors or an ExternalToolInvoker instance */ - public static ExternalToolInvoker runWMLScope(String resourcePath, boolean showProgress, - OutputStream[] stdout, OutputStream[] stderr) + public static ExternalToolInvoker runWMLScope( String installName, + String resourcePath, boolean showProgress, + OutputStream[] stdout, OutputStream[] stderr ) { - Paths paths = Preferences.getPaths( WesnothInstallsUtils.getInstallNameForResource( resourcePath ) ); + Paths paths = Preferences.getPaths( installName ); if ( !ResourceUtils.isValidFilePath( resourcePath ) || !checkWMLTool( paths, Tools.WMLSCOPE.toString( ) ) ) @@ -241,8 +250,9 @@ public class WMLTools * @param targetPath If this is not null if will use the targetpath as the * argument for launching the tool */ - public static void runWMLToolAsWorkspaceJob(final Tools tool, final String targetPath) + public static void runWMLToolAsWorkspaceJob( final Tools tool, final String targetPath ) { + //TODO: remove/rework this hackish method. if (tool == Tools.WESNOTH_ADDON_MANAGER) return; @@ -280,6 +290,7 @@ public class WMLTools String location; IResource resource = null; + String installName = Preferences.getDefaultInstallName( ); IFile selFile = WorkspaceUtils.getSelectedFile(); if (targetPath != null) @@ -296,6 +307,8 @@ public class WMLTools resource = WorkspaceUtils.getSelectedContainer(); location = resource.getLocation().toOSString(); } + + installName = WesnothInstallsUtils.getInstallNameForResource( resource ); } switch(tool) @@ -305,18 +318,20 @@ public class WMLTools { String stdin = EditorUtils.getEditorDocument().get(); // don't output to stdout as we will put that in the editor - toolInvoker = WMLTools.runWMLIndent(null, stdin, false, - null, stdout); + toolInvoker = WMLTools.runWMLIndent( installName, + null, stdin, false, null, stdout ); } else - toolInvoker = WMLTools.runWMLIndent(location, null, false, - stdout, stderr); + toolInvoker = WMLTools.runWMLIndent( installName, + location, null, false, stdout, stderr ); break; case WMLLINT: - toolInvoker = WMLTools.runWMLLint(location, true, false, stdout, stderr); + toolInvoker = WMLTools.runWMLLint( installName, + location, true, false, stdout, stderr ); break; case WMLSCOPE: - toolInvoker = WMLTools.runWMLScope(location, false, stdout, stderr); + toolInvoker = WMLTools.runWMLScope( installName, + location, false, stdout, stderr ); break; } monitor.worked(50);