eclipse plugin: Convert the single-installation paths...
...to multiple-installations. There are still some parts that need to be properly implemented/polished.
This commit is contained in:
parent
565b67f54e
commit
f9f8a72f83
10 changed files with 138 additions and 79 deletions
|
@ -37,7 +37,6 @@ import org.wesnoth.wml.WMLTag;
|
|||
import org.wesnoth.wml.core.ConfigFile;
|
||||
import org.wesnoth.wml.impl.WmlFactoryImpl;
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class WMLProposalProvider extends AbstractWMLProposalProvider
|
||||
{
|
||||
|
|
|
@ -19,11 +19,13 @@ import org.eclipse.xtext.ui.editor.hyperlinking.HyperlinkHelper;
|
|||
import org.eclipse.xtext.ui.editor.hyperlinking.IHyperlinkAcceptor;
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.preferences.Preferences;
|
||||
import org.wesnoth.preferences.Preferences.Paths;
|
||||
import org.wesnoth.preprocessor.Define;
|
||||
import org.wesnoth.ui.Messages;
|
||||
import org.wesnoth.ui.WMLUtil;
|
||||
import org.wesnoth.ui.emf.ObjectStorageAdapter;
|
||||
import org.wesnoth.utils.ProjectUtils;
|
||||
import org.wesnoth.utils.WesnothInstallsUtils;
|
||||
import org.wesnoth.wml.WMLMacroCall;
|
||||
|
||||
|
||||
|
@ -42,13 +44,21 @@ public class WMLHyperlinkHelper extends HyperlinkHelper
|
|||
if (node == null)
|
||||
return;
|
||||
|
||||
createMacroHyperlink(node, acceptor, resource);
|
||||
IFile file = WMLUtil.getActiveEditorFile();
|
||||
if (file == null)
|
||||
{
|
||||
Logger.getInstance().logError(Messages.WMLHyperlinkHelper_0);
|
||||
return;
|
||||
}
|
||||
Paths paths = Preferences.getPaths( WesnothInstallsUtils.getInstallNameForResource( file ) );
|
||||
|
||||
createMacroHyperlink( file, paths, node, acceptor, resource );
|
||||
LeafNode prevNode = (LeafNode)NodeUtil.findLeafNodeAtOffset(rootNode,
|
||||
node.getOffset() - 1);
|
||||
if(prevNode == null)
|
||||
return;
|
||||
|
||||
createMapHyperlink(prevNode, node, acceptor, resource);
|
||||
createMapHyperlink( paths, prevNode, node, acceptor, resource );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,7 +68,7 @@ public class WMLHyperlinkHelper extends HyperlinkHelper
|
|||
* @param acceptor
|
||||
* @param resource
|
||||
*/
|
||||
private void createMacroHyperlink(LeafNode node,
|
||||
private void createMacroHyperlink( IFile file, Paths paths, LeafNode node,
|
||||
IHyperlinkAcceptor acceptor, XtextResource resource)
|
||||
{
|
||||
if (node.eContainer() == null ||
|
||||
|
@ -71,14 +81,6 @@ public class WMLHyperlinkHelper extends HyperlinkHelper
|
|||
|
||||
WMLMacroCall macro = (WMLMacroCall)container.getElement();
|
||||
|
||||
|
||||
IFile file = WMLUtil.getActiveEditorFile();
|
||||
if (file == null)
|
||||
{
|
||||
Logger.getInstance().logError(Messages.WMLHyperlinkHelper_0);
|
||||
return;
|
||||
}
|
||||
|
||||
// get the define for the macro
|
||||
Define define = ProjectUtils.getCacheForProject(file.getProject()).getDefines().get(macro.getName());
|
||||
if (define == null)
|
||||
|
@ -93,14 +95,15 @@ public class WMLHyperlinkHelper extends HyperlinkHelper
|
|||
|
||||
String filePath = define.getLocation().split(" ")[0]; //$NON-NLS-1$
|
||||
|
||||
if (filePath.startsWith("~")) // user addon relative location //$NON-NLS-1$
|
||||
if (filePath.startsWith("~")) { // user addon relative location //$NON-NLS-1$
|
||||
|
||||
filePath = filePath.replaceFirst("~", //$NON-NLS-1$
|
||||
Preferences.Paths.getUserDir( ).replace('\\', '/') +
|
||||
"/data/"); //$NON-NLS-1$
|
||||
else if (filePath.startsWith("core")) // data/core relative location //$NON-NLS-1$
|
||||
paths.getUserDir( ).replace('\\', '/') + "/data/"); //$NON-NLS-1$
|
||||
}
|
||||
else if (filePath.startsWith("core")) { // data/core relative location //$NON-NLS-1$
|
||||
filePath = filePath.replaceFirst("core", //$NON-NLS-1$
|
||||
Preferences.Paths.getWorkingDir( ).replace('\\', '/') +
|
||||
"/data/core/"); //$NON-NLS-1$
|
||||
paths.getWorkingDir( ).replace('\\', '/') + "/data/core/"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
FileLocationOpenerHyperlink macroTarget = new FileLocationOpenerHyperlink();
|
||||
macroTarget.setHyperlinkRegion(new Region(container.getOffset(), container.getLength()));
|
||||
|
@ -114,8 +117,8 @@ public class WMLHyperlinkHelper extends HyperlinkHelper
|
|||
* @param key The key (must me 'map_data' in this case)
|
||||
* @param value The value of key, that is, the location of the map
|
||||
*/
|
||||
private void createMapHyperlink(LeafNode key, LeafNode value,
|
||||
IHyperlinkAcceptor acceptor, XtextResource resource)
|
||||
private void createMapHyperlink( Paths paths, LeafNode key, LeafNode value,
|
||||
IHyperlinkAcceptor acceptor, XtextResource resource )
|
||||
{
|
||||
if (!(key.getText().equals("map_data"))) //$NON-NLS-1$
|
||||
return;
|
||||
|
@ -128,8 +131,7 @@ public class WMLHyperlinkHelper extends HyperlinkHelper
|
|||
mapLocation = mapLocation.substring(1, value.getLength() - 1);
|
||||
|
||||
mapLocation = mapLocation.replaceFirst("~", //$NON-NLS-1$
|
||||
Preferences.Paths.getUserDir( ).replace('\\','/') +
|
||||
"/data/"); //$NON-NLS-1$
|
||||
paths.getUserDir( ).replace('\\','/') + "/data/"); //$NON-NLS-1$
|
||||
|
||||
ObjectStorageAdapter adapter = (ObjectStorageAdapter)EcoreUtil.getAdapter(value.eAdapters(),
|
||||
ObjectStorageAdapter.class);
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.core.runtime.Path;
|
|||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.Messages;
|
||||
import org.wesnoth.preferences.Preferences;
|
||||
import org.wesnoth.preferences.Preferences.Paths;
|
||||
import org.wesnoth.utils.AntUtils;
|
||||
import org.wesnoth.utils.PreprocessorUtils;
|
||||
import org.wesnoth.utils.ProjectCache;
|
||||
|
@ -36,6 +37,7 @@ import org.wesnoth.utils.ProjectUtils;
|
|||
import org.wesnoth.utils.ResourceUtils;
|
||||
import org.wesnoth.utils.StringUtils;
|
||||
import org.wesnoth.utils.WMLSaxHandler;
|
||||
import org.wesnoth.utils.WesnothInstallsUtils;
|
||||
import org.wesnoth.utils.WorkspaceUtils;
|
||||
import org.wesnoth.wml.core.ConfigFile;
|
||||
|
||||
|
@ -72,8 +74,10 @@ public class WesnothProjectBuilder extends IncrementalProjectBuilder
|
|||
Logger.getInstance().log(Messages.WesnothProjectBuilder_0);
|
||||
monitor.beginTask(String.format(Messages.WesnothProjectBuilder_1, getProject().getName()), 100);
|
||||
|
||||
Paths paths = Preferences.getPaths( WesnothInstallsUtils.getInstallNameForResource( getProject() ) );
|
||||
|
||||
monitor.subTask(Messages.WesnothProjectBuilder_3);
|
||||
if ( Preferences.Paths.getUserDir( ).isEmpty( ) )
|
||||
if ( paths.getUserDir( ).isEmpty( ) )
|
||||
{
|
||||
Logger.getInstance().log(Messages.WesnothProjectBuilder_4,
|
||||
Messages.WesnothProjectBuilder_5);
|
||||
|
@ -93,8 +97,7 @@ public class WesnothProjectBuilder extends IncrementalProjectBuilder
|
|||
// in the user add-ons directory (incremental)
|
||||
monitor.subTask(Messages.WesnothProjectBuilder_8);
|
||||
Map<String, String> properties = new HashMap<String, String>();
|
||||
properties.put("wesnoth.user.dir", //$NON-NLS-1$
|
||||
Preferences.Paths.getUserDir( ));
|
||||
properties.put("wesnoth.user.dir", paths.getUserDir( )); //$NON-NLS-1$
|
||||
Logger.getInstance().log(Messages.WesnothProjectBuilder_10);
|
||||
|
||||
String result = AntUtils.runAnt(
|
||||
|
|
|
@ -27,6 +27,7 @@ public class ReloadFilesHandler extends AbstractHandler
|
|||
public Object execute(ExecutionEvent event)
|
||||
{
|
||||
SchemaParser.getInstance().parseSchema(true);
|
||||
|
||||
TemplateProvider.getInstance().loadTemplates();
|
||||
|
||||
// reload the cache only for already loaded files
|
||||
|
|
|
@ -36,17 +36,25 @@ public class SchemaParser
|
|||
return instance_;
|
||||
}
|
||||
|
||||
private Map<String, String> primitives_ = new HashMap<String, String>();
|
||||
private Map<String, String> primitives_ = new HashMap<String, String>();
|
||||
private Map<String, Tag> tags_ = new HashMap<String, Tag>();
|
||||
private boolean parsingDone_ = false;
|
||||
private boolean parsingDone_ = false;
|
||||
|
||||
/**
|
||||
* Parses the schema
|
||||
*
|
||||
* @param installName The install to use. It will get the default schema
|
||||
* path based on that
|
||||
*
|
||||
* @param force True to force parsing the schema, skipping the existing cache
|
||||
*/
|
||||
public void parseSchema(boolean force)
|
||||
public void parseSchema( boolean force )
|
||||
{
|
||||
parseSchema( force, Preferences.Paths.getSchemaPath( ) );
|
||||
//TODO should parse schema for each install type
|
||||
if (true)
|
||||
throw new RuntimeException("fix this!");
|
||||
String installName = "";
|
||||
parseSchemaFile( force, Preferences.getPaths( installName ).getSchemaPath( ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,7 +62,7 @@ public class SchemaParser
|
|||
* @param force True to force parsing the schema, skipping the existing cache
|
||||
* @param schemaPath The path to the 'schema.cfg' file
|
||||
*/
|
||||
public void parseSchema(boolean force, String schemaPath)
|
||||
public void parseSchemaFile( boolean force, String schemaPath )
|
||||
{
|
||||
if (parsingDone_ && !force)
|
||||
{
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.ui.console.MessageConsole;
|
|||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.Messages;
|
||||
import org.wesnoth.preferences.Preferences;
|
||||
import org.wesnoth.preferences.Preferences.Paths;
|
||||
|
||||
|
||||
public class GameUtils
|
||||
|
@ -54,15 +55,15 @@ public class GameUtils
|
|||
|
||||
protected static void runCampaignScenario(boolean scenario)
|
||||
{
|
||||
if (WorkspaceUtils.getSelectedResource() == null)
|
||||
IResource selectedResource = WorkspaceUtils.getSelectedResource();
|
||||
|
||||
if ( selectedResource == null )
|
||||
{
|
||||
GUIUtils.showWarnMessageBox(Messages.GameUtils_0 +
|
||||
Messages.GameUtils_1);
|
||||
return;
|
||||
}
|
||||
|
||||
IResource selectedResource = WorkspaceUtils.getSelectedResource();
|
||||
|
||||
try
|
||||
{
|
||||
String campaignId = null;
|
||||
|
@ -100,7 +101,8 @@ public class GameUtils
|
|||
args.add( scenarioId );
|
||||
}
|
||||
|
||||
startGame(args);
|
||||
startGame( WesnothInstallsUtils.getInstallNameForResource( selectedResource ),
|
||||
args );
|
||||
} catch (Exception e)
|
||||
{
|
||||
Logger.getInstance().logException(e);
|
||||
|
@ -112,18 +114,20 @@ public class GameUtils
|
|||
*/
|
||||
public static void startGame()
|
||||
{
|
||||
startGame(null);
|
||||
startGame( null, null );
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the wesnoth game with the specified extraArguments
|
||||
* @param extraArgs Extra arguments given to the game, or null.
|
||||
*/
|
||||
public static void startGame(List<String> extraArgs)
|
||||
public static void startGame( String installName, List<String> extraArgs )
|
||||
{
|
||||
List<String> args = new ArrayList<String>();
|
||||
String wesnothExec = Preferences.Paths.getWesnothExecutablePath( );
|
||||
String workingDir = Preferences.Paths.getWorkingDir( );
|
||||
|
||||
Paths paths = Preferences.getPaths( installName );
|
||||
String wesnothExec = paths.getWesnothExecutablePath( );
|
||||
String workingDir = paths.getWorkingDir( );
|
||||
|
||||
if (wesnothExec.isEmpty() || workingDir.isEmpty())
|
||||
{
|
||||
|
@ -135,8 +139,8 @@ public class GameUtils
|
|||
args.addAll(extraArgs);
|
||||
|
||||
// add the user's data directory path
|
||||
args.add("--config-dir"); //$NON-NLS-1$
|
||||
args.add(Preferences.Paths.getUserDir( ));
|
||||
args.add( "--config-dir" ); //$NON-NLS-1$
|
||||
args.add( paths.getUserDir( ) );
|
||||
|
||||
// we need to add the working dir (backward compatibility)
|
||||
args.add(workingDir);
|
||||
|
@ -177,7 +181,8 @@ public class GameUtils
|
|||
*/
|
||||
public static void startEditor(String mapName)
|
||||
{
|
||||
startGame(getEditorLaunchArguments(mapName));
|
||||
startGame( WesnothInstallsUtils.getInstallNameForResource( mapName ),
|
||||
getEditorLaunchArguments(mapName) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.wesnoth.Logger;
|
|||
import org.wesnoth.Messages;
|
||||
import org.wesnoth.WesnothPlugin;
|
||||
import org.wesnoth.preferences.Preferences;
|
||||
import org.wesnoth.preferences.Preferences.Paths;
|
||||
|
||||
public class PreprocessorUtils
|
||||
{
|
||||
|
@ -102,13 +103,17 @@ public class PreprocessorUtils
|
|||
filesTimeStamps_.put(filePath, new File(filePath).lastModified());
|
||||
|
||||
try{
|
||||
|
||||
Paths paths = Preferences.getPaths(
|
||||
ProjectUtils.getCacheForProject( file.getProject( ) ).getInstallName( ) );
|
||||
|
||||
List<String> arguments = new ArrayList<String>();
|
||||
|
||||
arguments.add( "--config-dir" ); //$NON-NLS-1$
|
||||
arguments.add( Preferences.Paths.getUserDir( ) );
|
||||
arguments.add( paths.getUserDir( ) );
|
||||
|
||||
arguments.add( "--data-dir" ); //$NON-NLS-1$
|
||||
arguments.add( Preferences.Paths.getWorkingDir( ) );
|
||||
arguments.add( paths.getWorkingDir( ) );
|
||||
|
||||
if (macrosFile != null && macrosFile.isEmpty() == false)
|
||||
{
|
||||
|
@ -154,7 +159,7 @@ public class PreprocessorUtils
|
|||
|
||||
Logger.getInstance().log(Messages.PreprocessorUtils_10 + filePath);
|
||||
ExternalToolInvoker wesnoth = new ExternalToolInvoker(
|
||||
Preferences.Paths.getWesnothExecutablePath( ),
|
||||
paths.getWesnothExecutablePath( ),
|
||||
arguments);
|
||||
wesnoth.runTool();
|
||||
if (waitForIt)
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.wesnoth.Constants;
|
|||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.Messages;
|
||||
import org.wesnoth.preferences.Preferences;
|
||||
|
||||
import org.wesnoth.preferences.Preferences.Paths;
|
||||
|
||||
public class WMLTools
|
||||
{
|
||||
|
@ -46,16 +46,19 @@ public class WMLTools
|
|||
public static ExternalToolInvoker runWMLIndent(String resourcePath, String stdin,
|
||||
boolean dryrun, OutputStream[] stdout, OutputStream[] stderr)
|
||||
{
|
||||
if (!checkPrerequisites(null, "wmlindent")) // wmlindent only check first //$NON-NLS-1$
|
||||
Paths paths = Preferences.getPaths( WesnothInstallsUtils.getInstallNameForResource( resourcePath ) );
|
||||
|
||||
//wmlindent only check first
|
||||
if ( !checkPrerequisites( paths, null, "wmlindent" ) ) //$NON-NLS-1$
|
||||
return null;
|
||||
|
||||
File wmllintFile = new File( Preferences.Paths.getWMLToolsDir( ) + "/wmlindent" ); //$NON-NLS-1$
|
||||
File wmllintFile = new File( paths.getWMLToolsDir( ) + "/wmlindent" ); //$NON-NLS-1$
|
||||
List<String> arguments = new ArrayList<String>();
|
||||
arguments.add(wmllintFile.getAbsolutePath());
|
||||
|
||||
if (resourcePath != null)
|
||||
{
|
||||
if (!checkPrerequisites(resourcePath, null))
|
||||
if (!checkPrerequisites( paths, resourcePath, null))
|
||||
return null;
|
||||
|
||||
if (dryrun || Preferences.getBool(Constants.P_WMLINDENT_DRYRUN) == true)
|
||||
|
@ -78,37 +81,38 @@ public class WMLTools
|
|||
*/
|
||||
public static ExternalToolInvoker runWMLParser2(String resourcePath)
|
||||
{
|
||||
if (!checkPrerequisites(resourcePath, "wesnoth/wmlparser2.py")) //$NON-NLS-1$
|
||||
Paths paths = Preferences.getPaths( WesnothInstallsUtils.getInstallNameForResource( resourcePath ) );
|
||||
|
||||
if ( !checkPrerequisites( paths, resourcePath, "wesnoth/wmlparser2.py" ) ) //$NON-NLS-1$
|
||||
return null;
|
||||
|
||||
File wmlparserFile = new File(Preferences.Paths.getWMLToolsDir( ) +
|
||||
"/wesnoth/wmlparser2.py" ); //$NON-NLS-1$
|
||||
File wmlparserFile = new File(paths.getWMLToolsDir( ) + "/wesnoth/wmlparser2.py" ); //$NON-NLS-1$
|
||||
|
||||
List<String> arguments = new ArrayList<String>();
|
||||
|
||||
arguments.add(wmlparserFile.getAbsolutePath());
|
||||
|
||||
// xml output
|
||||
arguments.add("-x"); //$NON-NLS-1$
|
||||
arguments.add( "-x" ); //$NON-NLS-1$
|
||||
|
||||
// no preprocess
|
||||
arguments.add("-n"); //$NON-NLS-1$
|
||||
arguments.add( "-n" ); //$NON-NLS-1$
|
||||
|
||||
// wesnoth executable's path
|
||||
arguments.add( "-w" ); //$NON-NLS-1$
|
||||
arguments.add( Preferences.Paths.getWesnothExecutablePath( ) );
|
||||
arguments.add( paths.getWesnothExecutablePath( ) );
|
||||
|
||||
// add user data directory
|
||||
arguments.add( "-c"); //$NON-NLS-1$
|
||||
arguments.add( Preferences.Paths.getUserDir( ) );
|
||||
arguments.add( paths.getUserDir( ) );
|
||||
|
||||
// add the working data directory
|
||||
arguments.add( "-a" ); //$NON-NLS-1$
|
||||
arguments.add( Preferences.Paths.getWorkingDir( ) );
|
||||
arguments.add( paths.getWorkingDir( ) );
|
||||
|
||||
// input file
|
||||
arguments.add("-i"); //$NON-NLS-1$
|
||||
arguments.add(resourcePath);
|
||||
arguments.add( "-i" ); //$NON-NLS-1$
|
||||
arguments.add( resourcePath );
|
||||
|
||||
return runPythonScript(arguments, null, false, false, null, null);
|
||||
}
|
||||
|
@ -136,10 +140,12 @@ public class WMLTools
|
|||
public static ExternalToolInvoker runWMLLint(String resourcePath, boolean dryrun,
|
||||
boolean showProgress, OutputStream[] stdout, OutputStream[] stderr)
|
||||
{
|
||||
if (!checkPrerequisites(resourcePath, "wmllint")) //$NON-NLS-1$
|
||||
Paths paths = Preferences.getPaths( WesnothInstallsUtils.getInstallNameForResource( resourcePath ) );
|
||||
|
||||
if ( !checkPrerequisites( paths, resourcePath, "wmllint" ) ) //$NON-NLS-1$
|
||||
return null;
|
||||
|
||||
File wmllintFile = new File( Preferences.Paths.getWMLToolsDir( ) + "/wmllint" ); //$NON-NLS-1$
|
||||
File wmllintFile = new File( paths.getWMLToolsDir( ) + "/wmllint" ); //$NON-NLS-1$
|
||||
|
||||
List<String> arguments = new ArrayList<String>();
|
||||
|
||||
|
@ -159,7 +165,7 @@ public class WMLTools
|
|||
arguments.add("--nospellcheck"); //$NON-NLS-1$
|
||||
|
||||
// add default core directory
|
||||
arguments.add( Preferences.Paths.getCoreDir( ) );
|
||||
arguments.add( paths.getCoreDir( ) );
|
||||
arguments.add( resourcePath );
|
||||
|
||||
return runPythonScript(arguments, null, true, true, stdout,stderr);
|
||||
|
@ -187,10 +193,12 @@ public class WMLTools
|
|||
public static ExternalToolInvoker runWMLScope(String resourcePath, boolean showProgress,
|
||||
OutputStream[] stdout, OutputStream[] stderr)
|
||||
{
|
||||
if (!checkPrerequisites(resourcePath, "wmlscope")) //$NON-NLS-1$
|
||||
Paths paths = Preferences.getPaths( WesnothInstallsUtils.getInstallNameForResource( resourcePath ) );
|
||||
|
||||
if ( !checkPrerequisites( paths, resourcePath, "wmlscope" ) ) //$NON-NLS-1$
|
||||
return null;
|
||||
|
||||
File wmlscopeFile = new File(Preferences.Paths.getWMLToolsDir( ) + "/wmlscope"); //$NON-NLS-1$
|
||||
File wmlscopeFile = new File( paths.getWMLToolsDir( ) + "/wmlscope" ); //$NON-NLS-1$
|
||||
|
||||
List<String> arguments = new ArrayList<String>();
|
||||
|
||||
|
@ -208,11 +216,11 @@ public class WMLTools
|
|||
if (Preferences.getBool(Constants.P_WMLSCOPE_COLLISIONS) == true)
|
||||
arguments.add("--collisions"); //$NON-NLS-1$
|
||||
|
||||
arguments.add("--unchecked"); //$NON-NLS-1$
|
||||
arguments.add("--unresolved"); //$NON-NLS-1$
|
||||
arguments.add( "--unchecked" ); //$NON-NLS-1$
|
||||
arguments.add( "--unresolved" ); //$NON-NLS-1$
|
||||
|
||||
// add default core directory
|
||||
arguments.add( Preferences.Paths.getCoreDir( ) );
|
||||
arguments.add( paths.getCoreDir( ) );
|
||||
arguments.add( resourcePath );
|
||||
|
||||
return runPythonScript(arguments, null, true, true, stdout, stderr);
|
||||
|
@ -383,11 +391,11 @@ public class WMLTools
|
|||
public static ExternalToolInvoker runWesnothAddonManager(String containerPath,
|
||||
OutputStream[] stdout, OutputStream[] stderr)
|
||||
{
|
||||
if (!checkPrerequisites(containerPath, "wesnoth_addon_manager")) //$NON-NLS-1$
|
||||
Paths paths = Preferences.getPaths( WesnothInstallsUtils.getInstallNameForResource( containerPath ) );
|
||||
if ( !checkPrerequisites( paths, containerPath, "wesnoth_addon_manager" ) ) //$NON-NLS-1$
|
||||
return null;
|
||||
|
||||
File wmllintFile = new File(Preferences.Paths.getWMLToolsDir( )
|
||||
+ "/wesnoth_addon_manager"); //$NON-NLS-1$
|
||||
File wmllintFile = new File(paths.getWMLToolsDir( ) + "/wesnoth_addon_manager"); //$NON-NLS-1$
|
||||
List<String> arguments = new ArrayList<String>();
|
||||
arguments.add(wmllintFile.getAbsolutePath());
|
||||
|
||||
|
@ -438,6 +446,7 @@ public class WMLTools
|
|||
}
|
||||
}
|
||||
|
||||
//TODO: break this method in 2 simpler
|
||||
/**
|
||||
* Checks if a wmlTool (that is in the wml tools directory) and
|
||||
* an additional file that is target of the tool exist / are valid.
|
||||
|
@ -446,7 +455,7 @@ public class WMLTools
|
|||
* @param wmlTool the wml tool file
|
||||
* @return True if the prerequisites are valid or false otherwise
|
||||
*/
|
||||
public static boolean checkPrerequisites(String filePath, String wmlTool)
|
||||
public static boolean checkPrerequisites( Paths paths, String filePath, String wmlTool )
|
||||
{
|
||||
if (filePath == null || filePath.isEmpty() || !new File(filePath).exists())
|
||||
{
|
||||
|
@ -463,13 +472,13 @@ public class WMLTools
|
|||
|
||||
if (wmlTool != null)
|
||||
{
|
||||
if ( Preferences.Paths.getWMLToolsDir( ).equals( "" ) ) //$NON-NLS-1$
|
||||
if ( paths.getWMLToolsDir( ).equals( "" ) ) //$NON-NLS-1$
|
||||
{
|
||||
GUIUtils.showWarnMessageBox(Messages.WMLTools_45 +
|
||||
Messages.WMLTools_46);
|
||||
return false;
|
||||
}
|
||||
File wmlToolFile = new File( Preferences.Paths.getWMLToolsDir( ) + wmlTool );
|
||||
File wmlToolFile = new File( paths.getWMLToolsDir( ) + wmlTool );
|
||||
|
||||
if (!wmlToolFile.exists())
|
||||
{
|
||||
|
|
|
@ -12,6 +12,8 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.wesnoth.Constants;
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.preferences.Preferences;
|
||||
|
@ -79,4 +81,28 @@ public class WesnothInstallsUtils
|
|||
}
|
||||
Preferences.getPreferences().setValue( Constants.P_INST_INSTALL_LIST, installs.toString() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the install name for the specified resource
|
||||
* @param resourcePath The path to the resource
|
||||
* @return The install name for the resource
|
||||
*/
|
||||
public static String getInstallNameForResource( String resourcePath )
|
||||
{
|
||||
return getInstallNameForResource( ResourcesPlugin.getWorkspace( ).getRoot( ).
|
||||
findMember( resourcePath ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the install name for the specified resource
|
||||
* @param resource The resource
|
||||
* @return The install name for the resource
|
||||
*/
|
||||
public static String getInstallNameForResource( IResource resource )
|
||||
{
|
||||
if ( resource == null )
|
||||
return ""; //$NON-NLS-1$
|
||||
|
||||
return ProjectUtils.getCacheForProject( resource.getProject( ) ).getInstallName( );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -305,7 +305,8 @@ public class WorkspaceUtils
|
|||
if (resource == null)
|
||||
return null;
|
||||
|
||||
String result = Preferences.Paths.getAddonsDir( );
|
||||
String result = Preferences.getPaths(
|
||||
WesnothInstallsUtils.getInstallNameForResource( resource ) ).getAddonsDir( );
|
||||
result += resource.getProject().getName() + Path.SEPARATOR;
|
||||
result += resource.getProjectRelativePath().toOSString();
|
||||
return result;
|
||||
|
@ -376,8 +377,8 @@ public class WorkspaceUtils
|
|||
|
||||
// automatically import 'special' folders as projects
|
||||
List<File> files = new ArrayList<File>();
|
||||
String addonsDir = Preferences.Paths.getAddonsDir( );
|
||||
String campaignsDir = Preferences.Paths.getCampaignDir( );
|
||||
String addonsDir = Preferences.getPaths( null ).getAddonsDir( );
|
||||
String campaignsDir = Preferences.getPaths( null ).getCampaignDir( );
|
||||
|
||||
File[] tmp = null;
|
||||
if (GUIUtils.showMessageBox(Messages.WorkspaceUtils_18 +
|
||||
|
@ -490,10 +491,10 @@ public class WorkspaceUtils
|
|||
*/
|
||||
public static boolean checkPathsAreSet(boolean displayWarning)
|
||||
{
|
||||
if ( !validPath( Preferences.Paths.getWesnothExecutablePath( ) ) ||
|
||||
!validPath( Preferences.Paths.getUserDir( ) ) ||
|
||||
!validPath( Preferences.Paths.getWMLToolsDir( ) ) ||
|
||||
!validPath( Preferences.Paths.getWorkingDir( ) ))
|
||||
if ( !validPath( Preferences.getPaths( null ).getWesnothExecutablePath( ) ) ||
|
||||
!validPath( Preferences.getPaths( null ).getUserDir( ) ) ||
|
||||
!validPath( Preferences.getPaths( null ).getWMLToolsDir( ) ) ||
|
||||
!validPath( Preferences.getPaths( null ).getWorkingDir( ) ))
|
||||
{
|
||||
if (displayWarning)
|
||||
GUIUtils.showWarnMessageBox(Messages.WorkspaceUtils_33);
|
||||
|
|
Loading…
Add table
Reference in a new issue