Author: timotei
Date: Sat Jul 30 09:56:30 2011
New Revision: 50472
URL: http://svn.gna.org/viewcvs/wesnoth?rev=50472&view=rev
Log:
eclipse plugin: Rework a bit the current setup workspace
routine to take in account the default install
when creating the projects
Modified:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/preferences/Preferences.java
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/ResourceUtils.java
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/StringUtils.java
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WizardUtils.java
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WorkspaceUtils.java
Modified:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/preferences/Preferences.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/preferences/Preferences.java?rev=50472&r1=50471&r2=50472&view=diff
==============================================================================
---
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/preferences/Preferences.java
(original)
+++
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/preferences/Preferences.java
Sat Jul 30 09:56:30 2011
@@ -144,7 +144,7 @@
Paths paths = paths_.get( installName );
if ( paths == null ) {
- paths = new Paths( getInstallPrefix( installName ) );
+ paths = new Paths( installName, getInstallPrefix( installName )
);
paths_.put( installName, paths );
}
@@ -158,10 +158,21 @@
public static class Paths
{
private String installPrefix_;
-
- public Paths( String installPrefix )
+ private String installName_;
+
+ public Paths( String installName, String installPrefix )
{
installPrefix_ = installPrefix;
+ installName_ = installName;
+ }
+
+ /**
+ * Returns the install name associated with this instance
+ * @return A string representing the install name
+ */
+ public String getInstallName()
+ {
+ return installName_;
}
/**
Modified:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/ResourceUtils.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/ResourceUtils.java?rev=50472&r1=50471&r2=50472&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/ResourceUtils.java
(original)
+++ trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/ResourceUtils.java
Sat Jul 30 09:56:30 2011
@@ -51,6 +51,7 @@
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;
@@ -323,6 +324,34 @@
Logger.getInstance().logWarn("The file does not exist or is
null: " + filePath); //$NON-NLS-1$
return valid;
}
+
+ /**
+ * Checks if the specified path is in the user's addons directory
+ * @param paths The paths to use when doing the check
+ * @param path The path to check
+ * @return True if the path is in user's addons
+ */
+ public static boolean isUserAddonsDirPath( Paths paths, String path ) {
+ if ( StringUtils.isNullOrEmpty( path ) )
+ return false;
+
+ return StringUtils.normalizePath( path ).contains(
+ StringUtils.normalizePath( paths.getAddonsDir( ) ) );
+ }
+
+ /**
+ * Checks if the specified path is in the campaigns directory
+ * @param paths The paths to use when doing the check
+ * @param path The path to check
+ * @return True if the path is in data/campaigns directory
+ */
+ public static boolean isCampaignDirPath( Paths paths, String path ) {
+ if ( StringUtils.isNullOrEmpty( path ) )
+ return false;
+
+ return StringUtils.normalizePath( path ).contains(
+ StringUtils.normalizePath( paths.getCampaignDir( ) ) );
+ }
/**
* Returns true if the resource is a WML config file
Modified: trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/StringUtils.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/StringUtils.java?rev=50472&r1=50471&r2=50472&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/StringUtils.java
(original)
+++ trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/StringUtils.java Sat
Jul 30 09:56:30 2011
@@ -178,7 +178,7 @@
}
/**
- * Normalizez the path given by the string, removing repeated separators
+ * Normalizes the path given by the string, removing repeated separators
* and replacing them by '|'
*
* @param path the string that represents the path to be normalized
Modified: trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WizardUtils.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WizardUtils.java?rev=50472&r1=50471&r2=50472&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WizardUtils.java
(original)
+++ trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WizardUtils.java Sat
Jul 30 09:56:30 2011
@@ -13,7 +13,7 @@
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
import org.wesnoth.WesnothPlugin;
-import org.wesnoth.wizards.NewWizardTemplate;
+import org.wesnoth.wizards.WizardTemplate;
public class WizardUtils
@@ -25,7 +25,7 @@
* @param selection The current selection
* @return
*/
- public static int launchWizard(NewWizardTemplate wizard, Shell shell,
+ public static int launchWizard(WizardTemplate wizard, Shell shell,
IStructuredSelection selection)
{
if (wizard == null)
Modified:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WorkspaceUtils.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WorkspaceUtils.java?rev=50472&r1=50471&r2=50472&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WorkspaceUtils.java
(original)
+++ trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WorkspaceUtils.java
Sat Jul 30 09:56:30 2011
@@ -41,6 +41,7 @@
import org.wesnoth.installs.WesnothInstallsUtils;
import org.wesnoth.navigator.WesnothProjectsExplorer;
import org.wesnoth.preferences.Preferences;
+import org.wesnoth.preferences.Preferences.Paths;
import org.wesnoth.projects.ProjectUtils;
public class WorkspaceUtils
@@ -347,44 +348,37 @@
try
{
// automatically import 'special' folders as projects
- List<File> files = new ArrayList<File>();
- String addonsDir = Preferences.getPaths( null
).getAddonsDir( );
- String campaignsDir = Preferences.getPaths( null
).getCampaignDir( );
+ List<File> userAddonsFiles = new ArrayList<File>();
+ Paths paths = Preferences.getPaths(
Preferences.getDefaultInstallName( ) );
if (GUIUtils.showMessageBox( Messages.WorkspaceUtils_18 ,
SWT.ICON_QUESTION | SWT.YES | SWT.NO) == SWT.YES)
{
// useraddons/add-ons/data
- File[] tmp = new File(addonsDir).listFiles();
+ File[] tmp = new File( paths.getAddonsDir( )
).listFiles();
if (tmp != null)
- files.addAll(Arrays.asList(tmp));
+ userAddonsFiles.addAll(Arrays.asList(tmp));
}
- if (GUIUtils.showMessageBox( Messages.WorkspaceUtils_20 ,
- SWT.ICON_QUESTION | SWT.YES | SWT.NO) == SWT.YES)
- {
- // workingdir/data/campaigns
- File[] tmp = new File(campaignsDir).listFiles();
- if (tmp != null)
- files.addAll(Arrays.asList(tmp));
- }
-
- monitor.beginTask(Messages.WorkspaceUtils_22, files.size()
* 35);
- for(File file: files)
+ monitor.beginTask( Messages.WorkspaceUtils_22,
+ userAddonsFiles.size() * 10 );
+
+ for( File file: userAddonsFiles )
{
if (file.isDirectory() == false ||
file.getName().startsWith(".")) //$NON-NLS-1$
continue;
String projectName = file.getName();
- if
(StringUtils.normalizePath(file.getAbsolutePath()).contains(
- StringUtils.normalizePath(campaignsDir)))
+ if ( ResourceUtils.isCampaignDirPath( paths,
+ file.getAbsolutePath( ) ) )
{
projectName = "_Mainline_" + file.getName();
//$NON-NLS-1$
}
ProjectUtils.createWesnothProject( projectName,
- file.getAbsolutePath( ), false, monitor );
+ file.getAbsolutePath( ), paths.getInstallName(
),
+ monitor );
}
if (guided)
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits