eclipse plugin: Rework the wizards to use the new Project Selection page

This commit is contained in:
Timotei Dolean 2011-07-30 07:55:56 +00:00
parent e72545d1c5
commit d9289cc9ea
26 changed files with 71 additions and 152 deletions

View file

@ -11,10 +11,9 @@ import org.eclipse.ui.dialogs.ContainerSelectionDialog;
import org.wesnoth.Messages;
import org.wesnoth.WesnothPlugin;
public class NewWizardPageTemplate extends WizardPage
public class WizardPageTemplate extends WizardPage
{
protected NewWizardPageTemplate(String pageName)
protected WizardPageTemplate(String pageName)
{
super(pageName);
}
@ -27,9 +26,9 @@ public class NewWizardPageTemplate extends WizardPage
}
@Override
public NewWizardTemplate getWizard()
public WizardTemplate getWizard()
{
return (NewWizardTemplate)super.getWizard();
return (WizardTemplate)super.getWizard();
}
/**

View file

@ -18,7 +18,7 @@ import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
import org.wesnoth.WesnothPlugin;
public abstract class NewWizardTemplate extends Wizard implements INewWizard
public abstract class WizardTemplate extends Wizard implements INewWizard
{
protected IStructuredSelection selection_;
protected IContainer selectionContainer_;
@ -30,7 +30,7 @@ public abstract class NewWizardTemplate extends Wizard implements INewWizard
// TODO: wizards should ask the install
// TODO: detect automatically whether a project is in data or add-ons/
// without the need for the user to specify
public NewWizardTemplate()
public WizardTemplate()
{
setNeedsProgressMonitor(true);
setHelpAvailable(true);

View file

@ -24,19 +24,21 @@ import org.wesnoth.templates.ReplaceableParameter;
import org.wesnoth.templates.TemplateProvider;
import org.wesnoth.utils.Pair;
import org.wesnoth.utils.ResourceUtils;
import org.wesnoth.wizards.NewWizardTemplate;
import org.wesnoth.wizards.WizardProjectPageTemplate;
import org.wesnoth.wizards.WizardTemplate;
public class CampaignNewWizard extends NewWizardTemplate
public class CampaignNewWizard extends WizardTemplate
{
protected CampaignPage0 page0_;
protected WizardProjectPageTemplate page0_;
protected CampaignPage1 page1_;
protected CampaignPage2 page2_;
@Override
public void addPages()
{
page0_ = new CampaignPage0();
page0_ = new WizardProjectPageTemplate( "campaignPage0",
Messages.CampaignPage0_1, Messages.CampaignPage0_2 );
addPage(page0_);
page1_ = new CampaignPage1();
@ -85,7 +87,7 @@ public class CampaignNewWizard extends NewWizardTemplate
if (page0_.getLocationPath().equals(ResourcesPlugin.getWorkspace().getRoot().getLocation()))
{
ProjectUtils.createWesnothProject(currentProject, null,
true, !page1_.isDataCampaignsProject(), monitor);
page0_.getSelectedInstallName( ), true, monitor);
}
else
{
@ -93,7 +95,7 @@ public class CampaignNewWizard extends NewWizardTemplate
newProjectDescription(page0_.getProjectName());
newDescription.setLocation(page0_.getLocationPath());
ProjectUtils.createWesnothProject(currentProject, newDescription,
true, !page1_.isDataCampaignsProject(), monitor);
page0_.getSelectedInstallName( ), true, monitor);
}
monitor.worked(2);
@ -110,10 +112,11 @@ public class CampaignNewWizard extends NewWizardTemplate
for (Pair<String, String> file : files)
{
if (file.Second.equals("pbl") && //$NON-NLS-1$
page1_.getGeneratePBLFile() == false)
page1_.needsPBLFile( ) == false)
continue;
if (file.Second.equals("build_xml") && //$NON-NLS-1$
page1_.isDataCampaignsProject())
if ( file.Second.equals("build_xml") && //$NON-NLS-1$
! page0_.needsBuildXML( ) )
continue;
ResourceUtils.createFile(currentProject, file.First, prepareTemplate(file.Second), true);

View file

@ -1,29 +0,0 @@
/*******************************************************************************
* Copyright (c) 2010 - 2011 by Timotei Dolean <timotei21@gmail.com>
*
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.wesnoth.wizards.campaign;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
import org.wesnoth.Messages;
public class CampaignPage0 extends WizardNewProjectCreationPage
{
public CampaignPage0() {
super("campaignPage0"); //$NON-NLS-1$
}
@Override
public void createControl(Composite parent)
{
super.createControl(parent);
setTitle(Messages.CampaignPage0_1);
setMessage(Messages.CampaignPage0_2);
}
}

View file

@ -18,10 +18,10 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.wesnoth.Messages;
import org.wesnoth.wizards.NewWizardPageTemplate;
import org.wesnoth.wizards.WizardPageTemplate;
public class CampaignPage1 extends NewWizardPageTemplate
public class CampaignPage1 extends WizardPageTemplate
{
private Text txtCampaignName_;
private Text txtVersion_;
@ -33,7 +33,6 @@ public class CampaignPage1 extends NewWizardPageTemplate
private Text txtIcon_;
private Button chkMultiCampaign_;
private Button chkGeneratePBL_;
private Button chkDataCampaignProject_;
public CampaignPage1() {
super("campaignPage1"); //$NON-NLS-1$
@ -86,13 +85,6 @@ public class CampaignPage1 extends NewWizardPageTemplate
txtTranslationDir_ = new Text(container, SWT.BORDER);
txtTranslationDir_.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
Label lblRelativeToThe = new Label(container, SWT.NONE);
lblRelativeToThe.setText(Messages.CampaignPage1_8);
chkDataCampaignProject_ = new Button(container, SWT.CHECK);
chkDataCampaignProject_.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
chkDataCampaignProject_.setText(Messages.CampaignPage1_9);
chkMultiCampaign_ = new Button(container, SWT.CHECK);
GridData gd_chkMultiCampaign_ = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
gd_chkMultiCampaign_.widthHint = 236;
@ -245,13 +237,8 @@ public class CampaignPage1 extends NewWizardPageTemplate
return chkMultiCampaign_.getSelection();
}
public boolean getGeneratePBLFile()
public boolean needsPBLFile()
{
return chkGeneratePBL_.getSelection();
}
public boolean isDataCampaignsProject()
{
return chkDataCampaignProject_.getSelection();
}
}

View file

@ -21,10 +21,10 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.wesnoth.Messages;
import org.wesnoth.utils.StringUtils;
import org.wesnoth.wizards.NewWizardPageTemplate;
import org.wesnoth.wizards.WizardPageTemplate;
public class CampaignPage2 extends NewWizardPageTemplate
public class CampaignPage2 extends WizardPageTemplate
{
private Text txtAbbrev_;
private Text txtDefine_;

View file

@ -24,18 +24,20 @@ import org.wesnoth.templates.ReplaceableParameter;
import org.wesnoth.templates.TemplateProvider;
import org.wesnoth.utils.Pair;
import org.wesnoth.utils.ResourceUtils;
import org.wesnoth.wizards.NewWizardTemplate;
import org.wesnoth.wizards.WizardProjectPageTemplate;
import org.wesnoth.wizards.WizardTemplate;
public class EmptyProjectNewWizard extends NewWizardTemplate
public class EmptyProjectNewWizard extends WizardTemplate
{
protected EmptyProjectPage0 page0_;
protected WizardProjectPageTemplate page0_;
protected EmptyProjectPage1 page1_;
@Override
public void addPages()
{
page0_ = new EmptyProjectPage0();
page0_ = new WizardProjectPageTemplate( "emptyProjectPage0",
Messages.EmptyProjectPage0_1, Messages.EmptyProjectPage0_2 );
addPage(page0_);
page1_ = new EmptyProjectPage1();
@ -87,8 +89,8 @@ public class EmptyProjectNewWizard extends NewWizardTemplate
// the project
if (page0_.getLocationPath().equals(ResourcesPlugin.getWorkspace().getRoot().getLocation()))
{
ProjectUtils.createWesnothProject(currentProject, null, true,
!page1_.isDataCampaignsProject(), monitor);
ProjectUtils.createWesnothProject(currentProject, null,
page0_.getSelectedInstallName( ), true, monitor);
}
else
{
@ -96,7 +98,7 @@ public class EmptyProjectNewWizard extends NewWizardTemplate
newProjectDescription(page0_.getProjectName());
newDescription.setLocation(page0_.getLocationPath());
ProjectUtils.createWesnothProject(currentProject, newDescription,
true, !page1_.isDataCampaignsProject(), monitor);
page0_.getSelectedInstallName( ), true, monitor);
}
monitor.worked(2);
@ -118,8 +120,8 @@ public class EmptyProjectNewWizard extends NewWizardTemplate
page1_.getGeneratePBLFile() == false)
continue;
if (file.Second.equals("build_xml") && //$NON-NLS-1$
page1_.isDataCampaignsProject())
if ( file.Second.equals("build_xml") && //$NON-NLS-1$
! page0_.needsBuildXML( ) )
continue;
ResourceUtils.createFile(currentProject, file.First, prepareTemplate(file.Second), true);

View file

@ -1,29 +0,0 @@
/*******************************************************************************
* Copyright (c) 2010 - 2011 by Timotei Dolean <timotei21@gmail.com>
*
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.wesnoth.wizards.emptyproject;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
import org.wesnoth.Messages;
public class EmptyProjectPage0 extends WizardNewProjectCreationPage
{
public EmptyProjectPage0() {
super("emptyProjectPage0"); //$NON-NLS-1$
}
@Override
public void createControl(Composite parent)
{
super.createControl(parent);
setTitle(Messages.EmptyProjectPage0_1);
setMessage(Messages.EmptyProjectPage0_2);
}
}

View file

@ -19,10 +19,9 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.wesnoth.Messages;
import org.wesnoth.wizards.NewWizardPageTemplate;
import org.wesnoth.wizards.WizardPageTemplate;
public class EmptyProjectPage1 extends NewWizardPageTemplate
public class EmptyProjectPage1 extends WizardPageTemplate
{
private Text txtTitle_;
private Text txtVersion_;
@ -34,7 +33,6 @@ public class EmptyProjectPage1 extends NewWizardPageTemplate
private Text txtIcon_;
private Text txtType_;
private Button chkGeneratePBL_;
private Button chkDataCampaignsProject_;
public EmptyProjectPage1() {
@ -60,11 +58,6 @@ public class EmptyProjectPage1 extends NewWizardPageTemplate
};
container.setLayout(new GridLayout(3, false));
chkDataCampaignsProject_ = new Button(container, SWT.CHECK);
chkDataCampaignsProject_.setText(Messages.EmptyProjectPage1_3);
new Label(container, SWT.NONE);
new Label(container, SWT.NONE);
chkGeneratePBL_ = new Button(container, SWT.CHECK);
chkGeneratePBL_.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
chkGeneratePBL_.setText(Messages.EmptyProjectPage1_4);
@ -169,7 +162,7 @@ public class EmptyProjectPage1 extends NewWizardPageTemplate
// match the pattern x.y.z
if (txtVersion_.getText().isEmpty() ||
!(txtVersion_.getText().matches("[\\d]+\\.[\\d]+\\.\\d[\\w\\W\\d\\D\\s\\S]*"))) //$NON-NLS-1$
!(txtVersion_.getText().matches("[\\d]+\\.[\\d]+\\.\\d[\\w\\W\\d\\D\\s\\S]*"))) //$NON-NLS-1$
{
setMessage(Messages.EmptyProjectPage1_35, DialogPage.WARNING);
return;
@ -252,9 +245,4 @@ public class EmptyProjectPage1 extends NewWizardPageTemplate
{
return chkGeneratePBL_.getSelection();
}
public boolean isDataCampaignsProject()
{
return chkDataCampaignsProject_.getSelection();
}
}

View file

@ -31,10 +31,10 @@ import org.wesnoth.Logger;
import org.wesnoth.Messages;
import org.wesnoth.templates.ReplaceableParameter;
import org.wesnoth.templates.TemplateProvider;
import org.wesnoth.wizards.NewWizardTemplate;
import org.wesnoth.wizards.WizardTemplate;
public class EraNewWizard extends NewWizardTemplate
public class EraNewWizard extends WizardTemplate
{
EraPage0 page0_;

View file

@ -24,10 +24,9 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.wesnoth.Messages;
import org.wesnoth.wizards.NewWizardPageTemplate;
import org.wesnoth.wizards.WizardPageTemplate;
public class EraPage0 extends NewWizardPageTemplate
public class EraPage0 extends WizardPageTemplate
{
private Text txtDirectory_;
private Text txtFileName_;

View file

@ -31,10 +31,10 @@ import org.wesnoth.Logger;
import org.wesnoth.Messages;
import org.wesnoth.templates.ReplaceableParameter;
import org.wesnoth.templates.TemplateProvider;
import org.wesnoth.wizards.NewWizardTemplate;
import org.wesnoth.wizards.WizardTemplate;
public class FactionNewWizard extends NewWizardTemplate
public class FactionNewWizard extends WizardTemplate
{
FactionPage0 page0_;
FactionPage1 page1_;

View file

@ -24,10 +24,10 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.wesnoth.Messages;
import org.wesnoth.wizards.NewWizardPageTemplate;
import org.wesnoth.wizards.WizardPageTemplate;
public class FactionPage0 extends NewWizardPageTemplate
public class FactionPage0 extends WizardPageTemplate
{
private Text txtFileName_;
private Text txtDirectory_;

View file

@ -18,10 +18,10 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.wesnoth.Messages;
import org.wesnoth.wizards.NewWizardPageTemplate;
import org.wesnoth.wizards.WizardPageTemplate;
public class FactionPage1 extends NewWizardPageTemplate
public class FactionPage1 extends WizardPageTemplate
{
private Text txtChoices_;
private Text txtExcept_;

View file

@ -14,12 +14,11 @@ import org.eclipse.jface.wizard.IWizardPage;
import org.wesnoth.Constants;
import org.wesnoth.schema.SchemaParser;
import org.wesnoth.utils.StringUtils;
import org.wesnoth.wizards.NewWizardTemplate;
import org.wesnoth.wizards.WizardTemplate;
import org.wesnoth.wml.WMLKey;
import org.wesnoth.wml.WMLTag;
public class WizardGenerator extends NewWizardTemplate
public class WizardGenerator extends WizardTemplate
{
private String tagName_;
private int indent_;

View file

@ -14,10 +14,10 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.wesnoth.Messages;
import org.wesnoth.wizards.NewWizardPageTemplate;
import org.wesnoth.wizards.WizardPageTemplate;
public class WizardGeneratorPage404 extends NewWizardPageTemplate
public class WizardGeneratorPage404 extends WizardPageTemplate
{
public WizardGeneratorPage404(String tag) {
super("wizardGeneratorPage404"); //$NON-NLS-1$

View file

@ -22,12 +22,12 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.wesnoth.Messages;
import org.wesnoth.utils.StringUtils;
import org.wesnoth.wizards.NewWizardPageTemplate;
import org.wesnoth.wizards.WizardPageTemplate;
import org.wesnoth.wml.WMLKey;
import org.wesnoth.wml.WMLKeyValue;
public class WizardGeneratorPageKey extends NewWizardPageTemplate
public class WizardGeneratorPageKey extends WizardPageTemplate
{
private List<WMLKey> keys_;
private int startIndex_, endIndex_;

View file

@ -28,11 +28,11 @@ import org.wesnoth.utils.GUIUtils;
import org.wesnoth.utils.ListUtils;
import org.wesnoth.utils.StringUtils;
import org.wesnoth.utils.WizardUtils;
import org.wesnoth.wizards.NewWizardPageTemplate;
import org.wesnoth.wizards.WizardPageTemplate;
import org.wesnoth.wml.WMLTag;
public class WizardGeneratorPageTag extends NewWizardPageTemplate
public class WizardGeneratorPageTag extends WizardPageTemplate
{
private java.util.List<WMLTag> tags_;
private Map<String, java.util.List<String>> content_;

View file

@ -24,10 +24,10 @@ import org.wesnoth.Logger;
import org.wesnoth.Messages;
import org.wesnoth.utils.EditorUtils;
import org.wesnoth.utils.WizardUtils;
import org.wesnoth.wizards.NewWizardTemplate;
import org.wesnoth.wizards.WizardTemplate;
public class WizardLauncher extends NewWizardTemplate
public class WizardLauncher extends WizardTemplate
{
WizardLauncherPage0 page0_;
WizardLauncherPage1 page1_;

View file

@ -25,10 +25,10 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.wesnoth.Messages;
import org.wesnoth.utils.EditorUtils;
import org.wesnoth.wizards.NewWizardPageTemplate;
import org.wesnoth.wizards.WizardPageTemplate;
public class WizardLauncherPage0 extends NewWizardPageTemplate
public class WizardLauncherPage0 extends WizardPageTemplate
{
private Text txtDirectory_;
private Text txtFileName_;

View file

@ -23,10 +23,10 @@ import org.wesnoth.Logger;
import org.wesnoth.Messages;
import org.wesnoth.templates.TemplateProvider;
import org.wesnoth.utils.StringUtils;
import org.wesnoth.wizards.NewWizardPageTemplate;
import org.wesnoth.wizards.WizardPageTemplate;
public class WizardLauncherPage1 extends NewWizardPageTemplate
public class WizardLauncherPage1 extends WizardPageTemplate
{
private Map<String, String> list_;
private Text txtOtherTag_;

View file

@ -27,10 +27,10 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.wesnoth.Logger;
import org.wesnoth.Messages;
import org.wesnoth.wizards.NewWizardTemplate;
import org.wesnoth.wizards.WizardTemplate;
public class NewConfigFileWizard extends NewWizardTemplate {
public class NewConfigFileWizard extends WizardTemplate {
private NewConfigFilePage0 page_;
/**

View file

@ -37,7 +37,7 @@ import org.wesnoth.templates.TemplateProvider;
import org.wesnoth.utils.GUIUtils;
import org.wesnoth.utils.ResourceUtils;
import org.wesnoth.utils.WorkspaceUtils;
import org.wesnoth.wizards.NewWizardTemplate;
import org.wesnoth.wizards.WizardTemplate;
/**
* This is a sample new wizard. Its role is to create a new file resource in the
@ -47,7 +47,7 @@ import org.wesnoth.wizards.NewWizardTemplate;
* sample multi-page editor (also available as a template) is registered for the
* same extension, it will be able to open it.
*/
public class ScenarioNewWizard extends NewWizardTemplate
public class ScenarioNewWizard extends WizardTemplate
{
private ScenarioPage0 page0_;
private ScenarioPage1 page1_;

View file

@ -28,7 +28,7 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Text;
import org.wesnoth.Messages;
import org.wesnoth.wizards.NewWizardPageTemplate;
import org.wesnoth.wizards.WizardPageTemplate;
/**
@ -36,7 +36,7 @@ import org.wesnoth.wizards.NewWizardPageTemplate;
* as the file name. The page will only accept file name without the extension
* OR with the extension that matches the expected one (cfg).
*/
public class ScenarioPage0 extends NewWizardPageTemplate
public class ScenarioPage0 extends WizardPageTemplate
{
private Text txtProject_;

View file

@ -20,10 +20,10 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.wesnoth.Messages;
import org.wesnoth.projects.ProjectUtils;
import org.wesnoth.wizards.NewWizardPageTemplate;
import org.wesnoth.wizards.WizardPageTemplate;
public class ScenarioPage1 extends NewWizardPageTemplate
public class ScenarioPage1 extends WizardPageTemplate
{
private Composite container_;

View file

@ -16,10 +16,10 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.wesnoth.Messages;
import org.wesnoth.wizards.NewWizardPageTemplate;
import org.wesnoth.wizards.WizardPageTemplate;
public class ScenarioPage2 extends NewWizardPageTemplate
public class ScenarioPage2 extends WizardPageTemplate
{
Button chkIsMultiplayerScenario_;
Button chkAllowNewGame_;