mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
[251124] - applied patch, fixing unfinished code that allow language separation for templates
This commit is contained in:
parent
2760c4fe5f
commit
2654d40bea
5 changed files with 80 additions and 7 deletions
|
@ -3770,19 +3770,19 @@
|
|||
<extension point="org.eclipse.cdt.core.templates">
|
||||
<template
|
||||
id="org.eclipse.cdt.build.core.templates.HelloWorldCCProject"
|
||||
filterPattern=".*"
|
||||
filterPattern=".*g\+\+"
|
||||
location="$nl$/templates/projecttemplates/HelloWorldCCProject/template.xml"
|
||||
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
|
||||
</template>
|
||||
<template
|
||||
id="org.eclipse.cdt.build.templates.HelloWorldCAnsiProject"
|
||||
filterPattern=".*"
|
||||
filterPattern=".*gcc"
|
||||
location="$nl$/templates/projecttemplates/HelloWorldCAnsiProject/template.xml"
|
||||
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
|
||||
</template>
|
||||
<template
|
||||
id="org.eclipse.cdt.build.core.templates.MakefileHelloWorldCCProject"
|
||||
filterPattern=".*"
|
||||
filterPattern=".*g\+\+"
|
||||
location="$nl$/templates/projecttemplates/MakefileHelloWorldCCProject/template.xml"
|
||||
projectType="org.eclipse.cdt.build.makefile.projectType">
|
||||
</template>
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.managedbuilder.ui.wizards;
|
|||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
@ -119,11 +120,17 @@ public class MBSWizardHandler extends CWizardHandler {
|
|||
private IWizardPage[] templatePages;
|
||||
private IWizardPage predatingPage;
|
||||
private IWizardPage followingPage;
|
||||
private IWizard wizard;
|
||||
|
||||
public EntryInfo(EntryDescriptor dr, SortedMap<String, IToolChain> _tcs){
|
||||
entryDescriptor = dr;
|
||||
tcs = _tcs;
|
||||
}
|
||||
|
||||
public EntryInfo(EntryDescriptor dr, SortedMap<String, IToolChain> _tcs, IWizard w){
|
||||
this(dr, _tcs);
|
||||
wizard = w;
|
||||
}
|
||||
|
||||
public boolean isValid(){
|
||||
initialize();
|
||||
|
@ -154,8 +161,25 @@ public class MBSWizardHandler extends CWizardHandler {
|
|||
if(!entryDescriptor.isDefaultForCategory() &&
|
||||
path.length > 1 && (!path[0].equals(ManagedBuildWizard.OTHERS_LABEL))){
|
||||
templateId = path[path.length - 1];
|
||||
Template templates[] = TemplateEngineUI.getDefault().getTemplates(projectTypeId);
|
||||
if(templates.length == 0)
|
||||
Template templates[] = null;
|
||||
if(wizard instanceof CDTCommonProjectWizard) {
|
||||
CDTCommonProjectWizard wz = (CDTCommonProjectWizard)wizard;
|
||||
String[] langIDs = wz.getLanguageIDs();
|
||||
if(langIDs.length > 0) {
|
||||
List<Template> lstTemplates = new ArrayList<Template>();
|
||||
for(int i = 0; i < langIDs.length; ++i) {
|
||||
lstTemplates.addAll(Arrays.asList(TemplateEngineUI.getDefault().
|
||||
getTemplates(projectTypeId, null, langIDs[i])));
|
||||
}
|
||||
templates = lstTemplates.toArray(new Template[lstTemplates.size()]);
|
||||
}
|
||||
}
|
||||
if(null == templates) {
|
||||
templates =
|
||||
TemplateEngineUI.getDefault().
|
||||
getTemplates(projectTypeId);
|
||||
}
|
||||
if((null == templates) || (templates.length == 0))
|
||||
break;
|
||||
|
||||
for(int i = 0; i < templates.length; i++){
|
||||
|
@ -723,12 +747,12 @@ public class MBSWizardHandler extends CWizardHandler {
|
|||
}
|
||||
|
||||
public boolean isApplicable(EntryDescriptor data) {
|
||||
EntryInfo info = new EntryInfo(data, full_tcs);
|
||||
EntryInfo info = new EntryInfo(data, full_tcs, wizard);
|
||||
return info.isValid() && (info.getToolChainsCount() > 0);
|
||||
}
|
||||
|
||||
public void initialize(EntryDescriptor data) throws CoreException {
|
||||
EntryInfo info = new EntryInfo(data, full_tcs);
|
||||
EntryInfo info = new EntryInfo(data, full_tcs, wizard);
|
||||
if(!info.isValid())
|
||||
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderUIPlugin.getUniqueIdentifier(), "inappropriate descriptor")); //$NON-NLS-1$
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
import org.eclipse.cdt.core.CCProjectNature;
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.ui.newui.UIMessages;
|
||||
|
||||
|
@ -37,5 +38,11 @@ public class CCProjectWizard extends CDTCommonProjectWizard {
|
|||
} catch (CoreException e) {}
|
||||
return prj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getContentTypeIDs() {
|
||||
return new String[] { CCorePlugin.CONTENT_TYPE_CXXSOURCE, CCorePlugin.CONTENT_TYPE_CXXHEADER };
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,9 @@ package org.eclipse.cdt.ui.wizards;
|
|||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.filesystem.EFS;
|
||||
import org.eclipse.core.filesystem.IFileInfo;
|
||||
|
@ -30,6 +33,9 @@ import org.eclipse.core.runtime.IConfigurationElement;
|
|||
import org.eclipse.core.runtime.IExecutableExtension;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.content.IContentType;
|
||||
import org.eclipse.core.runtime.content.IContentTypeManager;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
|
||||
|
@ -38,6 +44,8 @@ import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.LanguageManager;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
@ -306,12 +314,40 @@ implements IExecutableExtension, IWizardWithMemory
|
|||
|
||||
// Methods below should provide data for language check
|
||||
public String[] getLanguageIDs (){
|
||||
String[] contentTypeIds = getContentTypeIDs();
|
||||
if(contentTypeIds.length > 0) {
|
||||
IContentTypeManager manager = Platform.getContentTypeManager();
|
||||
List<String> languageIDs = new ArrayList<String>();
|
||||
for(int i = 0; i < contentTypeIds.length; ++i) {
|
||||
IContentType contentType = manager.getContentType(contentTypeIds[i]);
|
||||
if(null != contentType) {
|
||||
ILanguage language = LanguageManager.getInstance().getLanguage(contentType);
|
||||
if(!languageIDs.contains(language.getId())) {
|
||||
languageIDs.add(language.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return languageIDs.toArray(new String[languageIDs.size()]);
|
||||
}
|
||||
return EMPTY_ARR;
|
||||
}
|
||||
public String[] getContentTypeIDs (){
|
||||
return EMPTY_ARR;
|
||||
}
|
||||
public String[] getExtensions (){
|
||||
String[] contentTypeIds = getContentTypeIDs();
|
||||
if(contentTypeIds.length > 0) {
|
||||
IContentTypeManager manager = Platform.getContentTypeManager();
|
||||
List<String> extensions = new ArrayList<String>();
|
||||
for(int i = 0; i < contentTypeIds.length; ++i) {
|
||||
IContentType contentType = manager.getContentType(contentTypeIds[i]);
|
||||
if(null != contentType) {
|
||||
String[] thisTypeExtensions = contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
|
||||
extensions.addAll(Arrays.asList(thisTypeExtensions));
|
||||
}
|
||||
}
|
||||
return extensions.toArray(new String[extensions.size()]);
|
||||
}
|
||||
return EMPTY_ARR;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.core.resources.IProject;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.ui.newui.UIMessages;
|
||||
|
||||
|
@ -37,4 +38,9 @@ public class CProjectWizard extends CDTCommonProjectWizard {
|
|||
return prj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getContentTypeIDs() {
|
||||
return new String[] { CCorePlugin.CONTENT_TYPE_CSOURCE, CCorePlugin.CONTENT_TYPE_CHEADER };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue