eclipse plugin: Refactor the 'CheckPathsAreSet' to use an install

This commit is contained in:
Timotei Dolean 2011-06-24 15:18:15 +00:00
parent dd15c8434a
commit 41a436d1d4
5 changed files with 20 additions and 41 deletions

View file

@ -44,7 +44,7 @@ public class WesnothPlugin extends AbstractUIPlugin
Logger.getInstance().startLogger();
if (PlatformUI.isWorkbenchRunning()){
if (WorkspaceUtils.checkPathsAreSet(false) == false)
if (WorkspaceUtils.checkPathsAreSet( null, false) == false)
{
Display.getDefault().asyncExec(new Runnable() {
@Override

View file

@ -71,10 +71,15 @@ public class WesnothProjectBuilder extends IncrementalProjectBuilder
protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
throws CoreException
{
String installName = WesnothInstallsUtils.getInstallNameForResource( getProject() );
// check if Paths are set
if ( ! WorkspaceUtils.checkPathsAreSet( installName, true ) )
return null;
Logger.getInstance().log(Messages.WesnothProjectBuilder_0);
monitor.beginTask(String.format(Messages.WesnothProjectBuilder_1, getProject().getName()), 100);
Paths paths = Preferences.getPaths( WesnothInstallsUtils.getInstallNameForResource( getProject() ) );
Paths paths = Preferences.getPaths( installName );
monitor.subTask(Messages.WesnothProjectBuilder_3);
if ( paths.getUserDir( ).isEmpty( ) )

View file

@ -155,6 +155,8 @@ public class WesnothInstallsPage extends AbstractPreferencePage
addField(new LabelFieldEditor(Messages.WesnothPreferencesPage_14, getFieldEditorParent()));
// update the default
updateInterface( installs_.get( Preferences.getDefaultInstallName( ) ) );
guessDefaultPaths();
}
@ -551,7 +553,7 @@ public class WesnothInstallsPage extends AbstractPreferencePage
return install.Version;
} else if ( columnIndex == 2 ) { // is Default ?
if ( install.Name.equals( Preferences.getString( Constants.P_INST_DEFAULT_INSTALL ) ) )
if ( install.Name.equals( Preferences.getDefaultInstallName( ) ) )
return "Yes";
return "";

View file

@ -51,10 +51,8 @@ public class SchemaParser
public void parseSchema( boolean force )
{
//TODO should parse schema for each install type
if (true)
throw new RuntimeException("fix this!");
String installName = "";
parseSchemaFile( force, Preferences.getPaths( installName ).getSchemaPath( ) );
// for now, use the default install
parseSchemaFile( force, Preferences.getPaths( null ).getSchemaPath( ) );
}
/**

View file

@ -15,22 +15,18 @@ import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.eclipse.core.resources.FileInfoMatcherDescription;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceFilterDescription;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.AssertionFailedException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.preference.PreferenceDialog;
@ -330,11 +326,12 @@ public class WorkspaceUtils
Messages.Activator_5);
}
if (!checkPathsAreSet(false))
if (!checkPathsAreSet( null, false ))
{
PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(
WesnothPlugin.getShell(), "org.wesnoth.preferences.InstallsPage", null, null); //$NON-NLS-1$
if (pref.open() == Window.CANCEL || !checkPathsAreSet(true))
if ( pref.open() == Window.CANCEL ||
!checkPathsAreSet ( null, true ) )
{
GUIUtils.showErrorMessageBox(Messages.WorkspaceUtils_7 +
Messages.WorkspaceUtils_8);
@ -457,29 +454,6 @@ public class WorkspaceUtils
}
};
job.schedule();
}
/**
* Creates and adds an ignore filter on the specified project
* for folders matching the specified name. The specified folder won't appear
* in any views of the current project's structure
* @param project The project where to create the filter
* @param folderName The foldername to ignore
* @throws CoreException
*/
public static void createIgnoreFilter(IProject project, String folderName)
throws CoreException
{
// For details regarding the description see:
// FileInfoAttributesMatcher.encodeArguments()
// id = org.eclipse.ui.ide.multiFilter
// args = 1.0-name-matches-false-false-Love_to_death
project.createFilter(IResourceFilterDescription.EXCLUDE_ALL | IResourceFilterDescription.FOLDERS,
new FileInfoMatcherDescription("org.eclipse.ui.ide.multiFilter", //$NON-NLS-1$
"1.0-name-matches-false-false-" + folderName), //$NON-NLS-1$
IResource.BACKGROUND_REFRESH, new NullProgressMonitor());
}
/**
@ -489,12 +463,12 @@ public class WorkspaceUtils
* @param displayWarning true to display a messagebox warning
* the user if conditions are not met
*/
public static boolean checkPathsAreSet(boolean displayWarning)
public static boolean checkPathsAreSet( String installName, boolean displayWarning)
{
if ( !validPath( Preferences.getPaths( null ).getWesnothExecutablePath( ) ) ||
!validPath( Preferences.getPaths( null ).getUserDir( ) ) ||
!validPath( Preferences.getPaths( null ).getWMLToolsDir( ) ) ||
!validPath( Preferences.getPaths( null ).getWorkingDir( ) ))
if ( !validPath( Preferences.getPaths( installName ).getWesnothExecutablePath( ) ) ||
!validPath( Preferences.getPaths( installName ).getUserDir( ) ) ||
!validPath( Preferences.getPaths( installName ).getWMLToolsDir( ) ) ||
!validPath( Preferences.getPaths( installName ).getWorkingDir( ) ))
{
if (displayWarning)
GUIUtils.showWarnMessageBox(Messages.WorkspaceUtils_33);