mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug #190155 : The MBS new project wizard allows finishing without asking custom pages first
This commit is contained in:
parent
8c4edac2ff
commit
4e30fbe8a0
4 changed files with 118 additions and 151 deletions
|
@ -12,11 +12,7 @@ package org.eclipse.cdt.managedbuilder.ui.wizards;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IProjectType;
|
||||
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
|
@ -24,7 +20,6 @@ import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIImages;
|
|||
import org.eclipse.cdt.ui.newui.CDTPrefUtil;
|
||||
import org.eclipse.cdt.ui.newui.UIMessages;
|
||||
import org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard;
|
||||
import org.eclipse.cdt.ui.wizards.CDTMainWizardPage;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.jface.viewers.CheckStateChangedEvent;
|
||||
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
||||
|
@ -73,6 +68,7 @@ public class CDTConfigWizardPage extends WizardPage {
|
|||
private MBSWizardHandler handler;
|
||||
public boolean pagesLoaded = false;
|
||||
private IToolChain[] visitedTCs = null;
|
||||
IWizardPage[] customPages = null;
|
||||
|
||||
public CDTConfigWizardPage(MBSWizardHandler h) {
|
||||
super(UIMessages.getString("CDTConfigWizardPage.0")); //$NON-NLS-1$
|
||||
|
@ -81,33 +77,6 @@ public class CDTConfigWizardPage extends WizardPage {
|
|||
setWizard(h.getWizard());
|
||||
}
|
||||
|
||||
void addCustomPages() {
|
||||
if (pagesLoaded) return;
|
||||
pagesLoaded = true;
|
||||
|
||||
if (! (getWizard() instanceof CDTCommonProjectWizard)) return;
|
||||
CDTCommonProjectWizard wz = (CDTCommonProjectWizard)getWizard();
|
||||
|
||||
IWizardPage p = getWizard().getStartingPage();
|
||||
MBSCustomPageManager.init();
|
||||
MBSCustomPageManager.addStockPage(p, CDTMainWizardPage.PAGE_ID);
|
||||
MBSCustomPageManager.addStockPage(this, CDTConfigWizardPage.PAGE_ID);
|
||||
|
||||
setCustomPagesFilter(wz);
|
||||
// load all custom pages specified via extensions
|
||||
try {
|
||||
MBSCustomPageManager.loadExtensions();
|
||||
} catch (BuildException e) { e.printStackTrace(); }
|
||||
|
||||
IWizardPage[] customPages = MBSCustomPageManager.getCustomPages();
|
||||
if (customPages != null) {
|
||||
for (int k = 0; k < customPages.length; k++) {
|
||||
wz.addPage(customPages[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public CfgHolder[] getCfgItems(boolean getDefault) {
|
||||
CfgHolder[] its;
|
||||
if (getDefault || table == null || !isVisited())
|
||||
|
@ -358,50 +327,7 @@ public class CDTConfigWizardPage extends WizardPage {
|
|||
}
|
||||
|
||||
public IWizardPage getNextPage() {
|
||||
addCustomPages();
|
||||
pagesLoaded = true;
|
||||
return MBSCustomPageManager.getNextPage(PAGE_ID);
|
||||
}
|
||||
|
||||
private void setCustomPagesFilter(CDTCommonProjectWizard wz) {
|
||||
String[] natures = wz.getNatures();
|
||||
if (natures == null || natures.length == 0)
|
||||
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.NATURE, null);
|
||||
else if (natures.length == 1)
|
||||
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.NATURE, natures[0]);
|
||||
else {
|
||||
Set x = new TreeSet();
|
||||
for (int i=0; i<natures.length; i++) x.add(natures[i]);
|
||||
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.NATURE, x);
|
||||
}
|
||||
// Project type can be obtained either from Handler (for old-style projects),
|
||||
// or multiple values will be got from separate ToolChains (for new-style).
|
||||
boolean ptIsNull = (handler.getProjectType() == null);
|
||||
if (!ptIsNull)
|
||||
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.PROJECT_TYPE, handler.getProjectType().getId());
|
||||
|
||||
IToolChain[] tcs = handler.getSelectedToolChains();
|
||||
int n = (tcs == null) ? 0 : tcs.length;
|
||||
Set x = new TreeSet();
|
||||
Set y = new TreeSet();
|
||||
for (int i=0; i<n; i++) {
|
||||
if (tcs[i] == null) // --- NO TOOLCHAIN ---
|
||||
continue; // has no custom pages.
|
||||
x.add(tcs[i]);
|
||||
|
||||
IConfiguration cfg = tcs[i].getParent();
|
||||
if (cfg == null)
|
||||
continue;
|
||||
IProjectType pt = cfg.getProjectType();
|
||||
if (pt != null)
|
||||
y.add(pt.getId());
|
||||
}
|
||||
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.TOOLCHAIN, x);
|
||||
if (ptIsNull) {
|
||||
if (y.size() > 0)
|
||||
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.PROJECT_TYPE, y);
|
||||
else
|
||||
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.PROJECT_TYPE, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -240,11 +240,9 @@ public final class MBSCustomPageData
|
|||
return true;
|
||||
|
||||
Iterator iterator = toolchainSet.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
ToolchainData tcd = (ToolchainData) iterator.next();
|
||||
|
||||
// look for toolchain with same id. The id in the tool-chain data should never
|
||||
// contain a version suffix.
|
||||
if (tcd.getId().equals(id))
|
||||
|
@ -252,22 +250,13 @@ public final class MBSCustomPageData
|
|||
// if we don't check versions then we're done
|
||||
if (tcd.getVersionsSupported() == null)
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
// is the toolchain of one of the specified versions?
|
||||
for (int k = 0; k < tcd.getVersionsSupported().length; k++)
|
||||
{
|
||||
// check for an exact version match
|
||||
for (int k = 0; k < tcd.getVersionsSupported().length; k++) {
|
||||
if (tcd.getVersionsSupported()[k].equals(version))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -338,50 +338,43 @@ public final class MBSCustomPageManager
|
|||
if(page == null)
|
||||
return false;
|
||||
|
||||
if (getPageHideStatus(pageID)) return false;
|
||||
if (getPageHideStatus(pageID))
|
||||
return false;
|
||||
|
||||
// first, find out what project type, toolchain, and nature have been set
|
||||
Map pagePropertiesMap = (Map) pageIDtoPagePropertiesMap.get(PAGE_ID);
|
||||
|
||||
Object projectType = pagePropertiesMap.get(PROJECT_TYPE);
|
||||
Set toolchainSet = (Set) pagePropertiesMap.get(TOOLCHAIN);
|
||||
List toolchainList = (List) pagePropertiesMap.get(TOOLCHAIN);
|
||||
Object nature = pagePropertiesMap.get(NATURE);
|
||||
|
||||
// does the page follow nature and project type constraints?
|
||||
if (page.shouldBeVisibleForNature(nature)
|
||||
&& page.shouldBeVisibleForProjectType(projectType))
|
||||
{
|
||||
|
||||
MBSCustomPageData.ToolchainData[] toolchainData = page.getToolchains();
|
||||
|
||||
// if no toolchains are specified then we're done
|
||||
if (toolchainData == null || toolchainSet == null)
|
||||
{
|
||||
if (toolchainData == null || toolchainList == null)
|
||||
return true;
|
||||
}
|
||||
|
||||
// otherwise, iterate through the toolchains to see if one matches
|
||||
for (int k = 0; k < toolchainData.length; k++)
|
||||
{
|
||||
// check all toolchains, see if there is one for which we should be present
|
||||
Iterator toolchainIterator = toolchainSet.iterator();
|
||||
|
||||
Iterator toolchainIterator = toolchainList.iterator();
|
||||
while (toolchainIterator.hasNext())
|
||||
{
|
||||
IToolChain toolchain = (IToolChain) toolchainIterator.next();
|
||||
if(toolchain != null){
|
||||
String id = ManagedBuildManager.getIdFromIdAndVersion(toolchain.getId());
|
||||
String version = ManagedBuildManager.getVersionFromIdAndVersion(toolchain.getId());
|
||||
|
||||
// check the ID and version
|
||||
if (page.shouldBeVisibleForToolchain(id, version))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -459,56 +452,20 @@ public final class MBSCustomPageManager
|
|||
{
|
||||
// find the current page in the set of pages
|
||||
MBSCustomPageData pageData = getPageData(currentPageID);
|
||||
MBSCustomPageData currentData = null;
|
||||
|
||||
Iterator iterator = pageSet.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
currentData = (MBSCustomPageData) iterator.next();
|
||||
|
||||
if (currentData == pageData)
|
||||
{
|
||||
|
||||
// we found the page we're looking for so stop looking
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentData == pageData)
|
||||
{
|
||||
// we found our page
|
||||
// look for the next page that satisfies all project type, toolchain, and nature criteria
|
||||
|
||||
// first, find out what project type, toolchain, and nature have been set
|
||||
// Map pagePropertiesMap = (Map) pageIDtoPagePropertiesMap.get(PAGE_ID);
|
||||
|
||||
// String projectType = pagePropertiesMap.get(PROJECT_TYPE).toString();
|
||||
|
||||
// Set toolchainSet = (Set) pagePropertiesMap.get(TOOLCHAIN);
|
||||
|
||||
// String nature = pagePropertiesMap.get(NATURE).toString();
|
||||
|
||||
if (pageData.equals((MBSCustomPageData)iterator.next())) {
|
||||
IWizardPage nextPage = null;
|
||||
|
||||
boolean pageFound = false;
|
||||
|
||||
while (iterator.hasNext() && !pageFound)
|
||||
while (iterator.hasNext() && nextPage == null)
|
||||
{
|
||||
MBSCustomPageData potentialPage = (MBSCustomPageData) iterator.next();
|
||||
|
||||
if (isPageVisible(potentialPage.getID()))
|
||||
{
|
||||
pageFound = true;
|
||||
nextPage = potentialPage.getWizardPage();
|
||||
}
|
||||
}
|
||||
|
||||
if (pageFound)
|
||||
return nextPage;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
|
@ -30,6 +31,7 @@ import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
|
|||
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
|
||||
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
|
||||
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
|
||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuilder;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IProjectType;
|
||||
|
@ -45,6 +47,7 @@ import org.eclipse.cdt.ui.templateengine.Template;
|
|||
import org.eclipse.cdt.ui.templateengine.TemplateEngineUI;
|
||||
import org.eclipse.cdt.ui.templateengine.TemplateEngineUIUtil;
|
||||
import org.eclipse.cdt.ui.templateengine.pages.UIWizardPage;
|
||||
import org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard;
|
||||
import org.eclipse.cdt.ui.wizards.CDTMainWizardPage;
|
||||
import org.eclipse.cdt.ui.wizards.CWizardHandler;
|
||||
import org.eclipse.cdt.ui.wizards.EntryDescriptor;
|
||||
|
@ -96,6 +99,7 @@ public class MBSWizardHandler extends CWizardHandler {
|
|||
// private EntryDescriptor entryDescriptor = null;
|
||||
private EntryInfo entryInfo;
|
||||
protected CfgHolder[] cfgs = null;
|
||||
protected IWizardPage[] customPages;
|
||||
|
||||
protected static final class EntryInfo {
|
||||
private SortedMap tcs;
|
||||
|
@ -365,16 +369,106 @@ public class MBSWizardHandler extends CWizardHandler {
|
|||
}
|
||||
table.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
if (listener != null)
|
||||
listener.toolChainListChanged(table.getSelectionCount());
|
||||
handleToolChainSelection();
|
||||
}});
|
||||
}
|
||||
updatePreferred(preferred);
|
||||
loadCustomPages();
|
||||
table.setVisible(true);
|
||||
parent.layout();
|
||||
if (fConfigPage != null) fConfigPage.pagesLoaded = false;
|
||||
}
|
||||
|
||||
private void handleToolChainSelection() {
|
||||
loadCustomPages();
|
||||
// Notify listener, if any.
|
||||
if (listener != null)
|
||||
listener.toolChainListChanged(table.getSelectionCount());
|
||||
}
|
||||
|
||||
private void loadCustomPages() {
|
||||
if (! (getWizard() instanceof CDTCommonProjectWizard))
|
||||
return; // not probable
|
||||
|
||||
CDTCommonProjectWizard wz = (CDTCommonProjectWizard)getWizard();
|
||||
|
||||
if (customPages == null) {
|
||||
MBSCustomPageManager.init();
|
||||
MBSCustomPageManager.addStockPage(getStartingPage(), CDTMainWizardPage.PAGE_ID);
|
||||
MBSCustomPageManager.addStockPage(getConfigPage(), CDTConfigWizardPage.PAGE_ID);
|
||||
|
||||
// load all custom pages specified via extensions
|
||||
try {
|
||||
MBSCustomPageManager.loadExtensions();
|
||||
} catch (BuildException e) { e.printStackTrace(); }
|
||||
|
||||
customPages = MBSCustomPageManager.getCustomPages();
|
||||
|
||||
if (customPages == null)
|
||||
customPages = new IWizardPage[0];
|
||||
|
||||
for (int k = 0; k < customPages.length; k++)
|
||||
customPages[k].setWizard(wz);
|
||||
}
|
||||
setCustomPagesFilter(wz);
|
||||
}
|
||||
|
||||
private void setCustomPagesFilter(CDTCommonProjectWizard wz) {
|
||||
String[] natures = wz.getNatures();
|
||||
if (natures == null || natures.length == 0)
|
||||
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.NATURE, null);
|
||||
else if (natures.length == 1)
|
||||
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.NATURE, natures[0]);
|
||||
else {
|
||||
Set x = new TreeSet();
|
||||
for (int i=0; i<natures.length; i++) x.add(natures[i]);
|
||||
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.NATURE, x);
|
||||
}
|
||||
// Project type can be obtained either from Handler (for old-style projects),
|
||||
// or multiple values will be got from separate ToolChains (for new-style).
|
||||
boolean ptIsNull = (getProjectType() == null);
|
||||
if (!ptIsNull)
|
||||
MBSCustomPageManager.addPageProperty(
|
||||
MBSCustomPageManager.PAGE_ID,
|
||||
MBSCustomPageManager.PROJECT_TYPE,
|
||||
getProjectType().getId()
|
||||
);
|
||||
|
||||
IToolChain[] tcs = getSelectedToolChains();
|
||||
int n = (tcs == null) ? 0 : tcs.length;
|
||||
List x = new ArrayList();
|
||||
Set y = new TreeSet();
|
||||
for (int i=0; i<n; i++) {
|
||||
if (tcs[i] == null) // --- NO TOOLCHAIN ---
|
||||
continue; // has no custom pages.
|
||||
x.add(tcs[i]);
|
||||
|
||||
IConfiguration cfg = tcs[i].getParent();
|
||||
if (cfg == null)
|
||||
continue;
|
||||
IProjectType pt = cfg.getProjectType();
|
||||
if (pt != null)
|
||||
y.add(pt.getId());
|
||||
}
|
||||
MBSCustomPageManager.addPageProperty(
|
||||
MBSCustomPageManager.PAGE_ID,
|
||||
MBSCustomPageManager.TOOLCHAIN,
|
||||
x);
|
||||
|
||||
if (ptIsNull) {
|
||||
if (y.size() > 0)
|
||||
MBSCustomPageManager.addPageProperty(
|
||||
MBSCustomPageManager.PAGE_ID,
|
||||
MBSCustomPageManager.PROJECT_TYPE,
|
||||
y);
|
||||
else
|
||||
MBSCustomPageManager.addPageProperty(
|
||||
MBSCustomPageManager.PAGE_ID,
|
||||
MBSCustomPageManager.PROJECT_TYPE,
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleUnSelection() {
|
||||
if (table != null) {
|
||||
table.setVisible(false);
|
||||
|
@ -450,8 +544,6 @@ public class MBSWizardHandler extends CWizardHandler {
|
|||
doPostProcess(project);
|
||||
|
||||
// process custom pages
|
||||
// if (fConfigPage != null && fConfigPage.pagesLoaded)
|
||||
getConfigPage().addCustomPages();
|
||||
doCustom();
|
||||
}
|
||||
|
||||
|
@ -499,8 +591,6 @@ public class MBSWizardHandler extends CWizardHandler {
|
|||
}
|
||||
}
|
||||
public String getHeader() { return head; }
|
||||
// public String getName() { return name; }
|
||||
// public Image getIcon() { return null; /*image;*/ }
|
||||
public boolean isDummy() { return false; }
|
||||
public boolean supportsPreferred() { return true; }
|
||||
|
||||
|
@ -649,6 +739,11 @@ public class MBSWizardHandler extends CWizardHandler {
|
|||
if(!entryInfo.canFinish(startingPage, getConfigPage()))
|
||||
return false;
|
||||
|
||||
if (customPages != null)
|
||||
for (int i=0; i<customPages.length; i++)
|
||||
if (!customPages[i].isPageComplete())
|
||||
return false;
|
||||
|
||||
return super.canFinich();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue