Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlena Laskavaia2008-10-17 15:05:54 +0000
committerAlena Laskavaia2008-10-17 15:05:54 +0000
commit2654d40beaa519c6930c9cd1af1d63d2dc86131d (patch)
tree654a2b71c25c2f5ad2c6833e412ff21cdc3ec555
parent2760c4fe5f4a65793eb2dbc06381fb1c6a2cf399 (diff)
downloadorg.eclipse.cdt-2654d40beaa519c6930c9cd1af1d63d2dc86131d.tar.gz
org.eclipse.cdt-2654d40beaa519c6930c9cd1af1d63d2dc86131d.tar.xz
org.eclipse.cdt-2654d40beaa519c6930c9cd1af1d63d2dc86131d.zip
[251124] - applied patch, fixing unfinished code that allow language separation for templates
-rw-r--r--build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CCProjectWizard.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.java36
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CProjectWizard.java6
5 files changed, 80 insertions, 7 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml b/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml
index dd98aa0fe9a..6d34f1ceb17 100644
--- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml
@@ -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>
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 2641987acde..5753acf9bb2 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
@@ -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$
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CCProjectWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CCProjectWizard.java
index 644cf57fad5..113b7965d36 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CCProjectWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CCProjectWizard.java
@@ -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 };
+ }
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.java
index 1c944e74a1f..69f93f15a0c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.java
@@ -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;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CProjectWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CProjectWizard.java
index c2b2b4a2dd5..27ab19f0d9d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CProjectWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CProjectWizard.java
@@ -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 };
+ }
+
}

Back to the top