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 368084d5b08..9c66209fce8 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 @@ -92,6 +92,7 @@ public class MBSWizardHandler extends CWizardHandler { private EntryInfo entryInfo; protected static final class EntryInfo { + private SortedMap tcs; private EntryDescriptor entryDescriptor; private Template template; private boolean initialized; @@ -102,8 +103,9 @@ public class MBSWizardHandler extends CWizardHandler { private IWizardPage predatingPage; private IWizardPage followingPage; - public EntryInfo(EntryDescriptor dr){ + public EntryInfo(EntryDescriptor dr, SortedMap _tcs){ entryDescriptor = dr; + tcs = _tcs; } public boolean isValid(){ @@ -203,6 +205,59 @@ public class MBSWizardHandler extends CWizardHandler { } return true; } + + /** + * Filters toolchains + * + * @return - set of compatible toolchain's IDs + */ + protected Set tc_filter() { + Set full = tcs.keySet(); + if (entryDescriptor == null) + return full; + Set out = new LinkedHashSet(full.size()); + Iterator it = full.iterator(); + while (it.hasNext()) { + String s = (String)it.next(); + if (isToolChainAcceptable(s)) + out.add(s); + } + return out; + } + + /** + * Checks whether given toolchain can be displayed + * + * @param tcId - toolchain _NAME_ to check + * @return - true if toolchain can be displayed + */ + public boolean isToolChainAcceptable(String tcId) { + if (template == null || template.getTemplateInfo() == null) + return true; + + String[] ss = template.getTemplateInfo().getToolChainIds(); + if (ss == null || ss.length == 0) + return true; + + Object ob = tcs.get(tcId); + if (ob == null || !(ob instanceof IToolChain)) + return false; + + String id1 = ((IToolChain)ob).getId(); + IToolChain sup = ((IToolChain)ob).getSuperClass(); + String id2 = sup == null ? null : sup.getId(); + + for (int i=0; i 0) table.select(position); - + if (counter > 0) table.select(position); + } table.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (listener != null) @@ -465,7 +521,10 @@ public class MBSWizardHandler extends CWizardHandler { return ts; } public int getToolChainsCount() { - return tc_filter(full_tcs.keySet()).size(); + if (entryInfo == null) + return full_tcs.size(); + else + return entryInfo.tc_filter().size(); } public String getPropertyId() { return propertyId; @@ -535,79 +594,18 @@ public class MBSWizardHandler extends CWizardHandler { } public boolean isApplicable(EntryDescriptor data) { - EntryInfo info = new EntryInfo(data); - return info.isValid(); + EntryInfo info = new EntryInfo(data, full_tcs); + return info.isValid() && (info.getToolChainsCount() > 0); } public void initialize(EntryDescriptor data) throws CoreException { - EntryInfo info = new EntryInfo(data); + EntryInfo info = new EntryInfo(data, full_tcs); if(!info.isValid()) throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderUIPlugin.getUniqueIdentifier(), "inappropriate descriptor")); //$NON-NLS-1$ entryInfo = info; } - /** - * Filters toolchains according to entryDescriptor data - * - * @param full - full set of toolchain IDs - * @return - set of compatible toolchain's IDs - * - * Note that full_tcs map should remain unchanged - */ - protected Set tc_filter(Set full) { - if(entryInfo == null) - return full; - - EntryDescriptor entryDescriptor = entryInfo.getDescriptor(); - if (entryDescriptor == null) - return full; - Set out = new LinkedHashSet(full.size()); - Iterator it = full.iterator(); - while (it.hasNext()) { - String s = (String)it.next(); - if (isToolChainAcceptable(s, entryDescriptor)) - out.add(s); - } - return out; - } - - /** - * Checks whether given toolchain can be displayed - * - * @param tcId - toolchain to check - * @param ed - Entry descriptor (Who Am I) - * @return - true if toolchain can be displayed - */ - protected boolean isToolChainAcceptable(String tcId, EntryDescriptor ed) { - // This method is temporary diabled - // (always returns true) until the - // end of discusion tracked by bug #184457 - if (true) return true; - - if (entryInfo == null || entryInfo.template == null || - entryInfo.template.getTemplateInfo() == null) - return true; - - String[] ss = entryInfo.template.getTemplateInfo().getToolChainIds(); - if (ss == null && ss.length == 0) - return true; - - Object ob = full_tcs.get(tcId); - if (ob == null || !(ob instanceof IToolChain)) - return false; - - String id1 = ((IToolChain)ob).getId(); - IToolChain sup = ((IToolChain)ob).getSuperClass(); - String id2 = sup == null ? null : sup.getId(); - - for (int i=0; i