1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

more easy way of integrating to the general project types in the new project wizard

This commit is contained in:
Mikhail Sennikovsky 2007-06-19 09:29:21 +00:00
parent 1ec487930f
commit d31446aba0
3 changed files with 28 additions and 13 deletions

View file

@ -341,6 +341,7 @@ Specifying this attribute is fully equivalent to specifying the "org.eclips
<element ref="builder" minOccurs="0" maxOccurs="1"/> <element ref="builder" minOccurs="0" maxOccurs="1"/>
<element ref="optionCategory" minOccurs="0" maxOccurs="unbounded"/> <element ref="optionCategory" minOccurs="0" maxOccurs="unbounded"/>
<element ref="option" minOccurs="0" maxOccurs="unbounded"/> <element ref="option" minOccurs="0" maxOccurs="unbounded"/>
<element ref="supportedProperties" minOccurs="0" maxOccurs="1"/>
</sequence> </sequence>
<attribute name="id" type="string" use="required"> <attribute name="id" type="string" use="required">
<annotation> <annotation>

View file

@ -24,6 +24,7 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Map; import java.util.Map;
@ -4145,7 +4146,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
public static IConfiguration[] getExtensionConfigurations(IToolChain tChain, String propertyType, String propertyValue){ public static IConfiguration[] getExtensionConfigurations(IToolChain tChain, String propertyType, String propertyValue){
// List all = getSortedToolChains(); // List all = getSortedToolChains();
List list = findIdenticalElements((ToolChain)tChain, fToolChainSorter); List list = findIdenticalElements((ToolChain)tChain, fToolChainSorter);
List result = new ArrayList(); LinkedHashSet result = new LinkedHashSet();
boolean tcFound = false; boolean tcFound = false;
if(list != null){ if(list != null){
for(int i = 0; i < list.size(); i++){ for(int i = 0; i < list.size(); i++){
@ -4371,11 +4372,15 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
} }
public static IToolChain[] getExtensionsToolChains(String propertyType, String propertyValue){ public static IToolChain[] getExtensionsToolChains(String propertyType, String propertyValue){
return getExtensionsToolChains(propertyType, propertyValue, true);
}
public static IToolChain[] getExtensionsToolChains(String propertyType, String propertyValue, boolean supportedPropsOnly){
HashMap all = getSortedToolChains(); HashMap all = getSortedToolChains();
List result = new ArrayList(); List result = new ArrayList();
for(Iterator iter = all.values().iterator(); iter.hasNext();){ for(Iterator iter = all.values().iterator(); iter.hasNext();){
List list = (List)iter.next(); List list = (List)iter.next();
IToolChain tc = findToolChain(list, propertyType, propertyValue); IToolChain tc = findToolChain(list, propertyType, propertyValue, supportedPropsOnly);
if(tc != null) if(tc != null)
result.add(tc); result.add(tc);
} }
@ -4397,53 +4402,62 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
getSortedBuilders(); getSortedBuilders();
} }
private static IToolChain findToolChain(List list, String propertyType, String propertyValue){ private static IToolChain findToolChain(List list, String propertyType, String propertyValue, boolean supportedOnly){
ToolChain bestMatch = null; ToolChain bestMatch = null;
IConfiguration cfg = null; IConfiguration cfg = null;
IProjectType type = null; IProjectType type = null;
boolean valueSupported = false;
for(int i = 0; i < list.size(); i++){ for(int i = 0; i < list.size(); i++){
ToolChain tc = (ToolChain)list.get(i); ToolChain tc = (ToolChain)list.get(i);
if(!tc.supportsValue(propertyType, propertyValue)) if(tc.supportsValue(propertyType, propertyValue)){
return null; valueSupported = true;
} else if (valueSupported){
continue;
}
if(!tc.supportsBuild(true)) if(!tc.supportsBuild(true))
return null; return null;
if(bestMatch == null) if(bestMatch == null && valueSupported)
bestMatch = tc; bestMatch = tc;
IConfiguration tcCfg = tc.getParent(); IConfiguration tcCfg = tc.getParent();
if(tcCfg != null){ if(tcCfg != null){
if(cfg == null){ if(cfg == null && valueSupported){
bestMatch = tc; bestMatch = tc;
cfg = tcCfg; cfg = tcCfg;
} }
IBuildObjectProperties props =tcCfg.getBuildProperties(); IBuildObjectProperties props =tcCfg.getBuildProperties();
IBuildProperty prop = props.getProperty(propertyType); IBuildProperty prop = props.getProperty(propertyType);
if(prop != null && propertyValue.equals(prop.getValue().getId())){ if(valueSupported && prop != null && propertyValue.equals(prop.getValue().getId())){
bestMatch = tc; bestMatch = tc;
cfg = tcCfg; cfg = tcCfg;
} }
IProjectType tcType = tcCfg.getProjectType(); IProjectType tcType = tcCfg.getProjectType();
if(tcType != null){ if(tcType != null){
if(type == null){ if(type == null && valueSupported){
type = tcType; type = tcType;
bestMatch = tc; bestMatch = tc;
} }
props = tcType.getBuildProperties(); props = tcType.getBuildProperties();
prop = props.getProperty(propertyType); prop = props.getProperty(propertyType);
if(prop != null && propertyValue.equals(prop.getValue().getId())){ if(prop != null && propertyValue.equals(prop.getValue().getId())){
type = tcType;
bestMatch = tc; bestMatch = tc;
break; if(valueSupported){
type = tcType;
break;
}
} }
} }
} }
} }
return bestMatch; if(valueSupported || ! supportedOnly)
return bestMatch;
return null;
} }
private static List findIdenticalElements(IMatchKeyProvider p, ISorter sorter){ private static List findIdenticalElements(IMatchKeyProvider p, ISorter sorter){

View file

@ -47,7 +47,7 @@ public class ManagedBuildWizard extends AbstractCWizard {
ArrayList items = new ArrayList(); ArrayList items = new ArrayList();
// new style project types // new style project types
for (int i=0; i<vs.length; i++) { for (int i=0; i<vs.length; i++) {
IToolChain[] tcs = ManagedBuildManager.getExtensionsToolChains(MBSWizardHandler.ARTIFACT, vs[i].getId()); IToolChain[] tcs = ManagedBuildManager.getExtensionsToolChains(MBSWizardHandler.ARTIFACT, vs[i].getId(), false);
if (tcs == null || tcs.length == 0) continue; if (tcs == null || tcs.length == 0) continue;
MBSWizardHandler h = new MBSWizardHandler(vs[i], parent, wizard); MBSWizardHandler h = new MBSWizardHandler(vs[i], parent, wizard);
for (int j=0; j<tcs.length; j++) { for (int j=0; j<tcs.length; j++) {