diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CDTConfigWizardPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CDTConfigWizardPage.java index e2a55d2956d..c86c5f163a2 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CDTConfigWizardPage.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CDTConfigWizardPage.java @@ -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 0) - MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.PROJECT_TYPE, y); - else - MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.PROJECT_TYPE, null); - } - } - + } } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageData.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageData.java index 7ce7848143b..1a918dfd22e 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageData.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageData.java @@ -238,13 +238,11 @@ public final class MBSCustomPageData // if no toolchains specified then always return true if (toolchainSet.size() == 0) 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; } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageManager.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageManager.java index 37d18a8e86f..dee46c43a37 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageManager.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSCustomPageManager.java @@ -338,46 +338,39 @@ 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; - } } } } @@ -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(); - - IWizardPage nextPage = null; - - boolean pageFound = false; - - while (iterator.hasNext() && !pageFound) - { - MBSCustomPageData potentialPage = (MBSCustomPageData) iterator.next(); - - if (isPageVisible(potentialPage.getID())) + if (pageData.equals((MBSCustomPageData)iterator.next())) { + IWizardPage nextPage = null; + while (iterator.hasNext() && nextPage == null) { - pageFound = true; - nextPage = potentialPage.getWizardPage(); + MBSCustomPageData potentialPage = (MBSCustomPageData) iterator.next(); + if (isPageVisible(potentialPage.getID())) + nextPage = potentialPage.getWizardPage(); } - } - - if (pageFound) return nextPage; - + } } - return null; } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java index 30abeca3511..d66f4a84917 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java @@ -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 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