1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Bug 293079 - Allow new C/C++ project wizard extension

This commit is contained in:
Mike Kucera 2009-11-04 16:39:44 +00:00
parent daef4a8c6f
commit 7400462cd0
6 changed files with 131 additions and 15 deletions

View file

@ -11,12 +11,12 @@
package org.eclipse.cdt.managedbuilder.ui.wizards; package org.eclipse.cdt.managedbuilder.ui.wizards;
import org.eclipse.cdt.internal.ui.CPluginImages; import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.wizards.ICDTCommonProjectWizard;
import org.eclipse.cdt.managedbuilder.core.IInputType; import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain; import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIImages; import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIImages;
import org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard;
import org.eclipse.cdt.ui.wizards.CNewWizard; import org.eclipse.cdt.ui.wizards.CNewWizard;
import org.eclipse.cdt.ui.wizards.IWizardItemsListListener; import org.eclipse.cdt.ui.wizards.IWizardItemsListListener;
import org.eclipse.jface.wizard.IWizard; import org.eclipse.jface.wizard.IWizard;
@ -70,11 +70,11 @@ public abstract class AbstractCWizard extends CNewWizard {
protected boolean isLanguageCompatible(IToolChain tc, IWizard w) { protected boolean isLanguageCompatible(IToolChain tc, IWizard w) {
if (w == null) if (w == null)
return true; return true;
if (!(w instanceof CDTCommonProjectWizard)) if (!(w instanceof ICDTCommonProjectWizard))
return true; return true;
ITool[] tools = tc.getTools(); ITool[] tools = tc.getTools();
CDTCommonProjectWizard wz = (CDTCommonProjectWizard)w; ICDTCommonProjectWizard wz = (ICDTCommonProjectWizard)w;
String[] langIDs = wz.getLanguageIDs(); String[] langIDs = wz.getLanguageIDs();
String[] ctypeIDs = wz.getContentTypeIDs(); String[] ctypeIDs = wz.getContentTypeIDs();
String[] exts = wz.getExtensions(); String[] exts = wz.getExtensions();

View file

@ -13,13 +13,13 @@ package org.eclipse.cdt.managedbuilder.ui.wizards;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import org.eclipse.cdt.internal.ui.wizards.ICDTCommonProjectWizard;
import org.eclipse.cdt.managedbuilder.core.IProjectType; import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IToolChain; import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIImages; import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIImages;
import org.eclipse.cdt.ui.newui.CDTPrefUtil; import org.eclipse.cdt.ui.newui.CDTPrefUtil;
import org.eclipse.cdt.ui.newui.UIMessages; import org.eclipse.cdt.ui.newui.UIMessages;
import org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.jface.viewers.CheckStateChangedEvent; import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer; import org.eclipse.jface.viewers.CheckboxTableViewer;
@ -309,8 +309,8 @@ public class CDTConfigWizardPage extends WizardPage {
* Edit properties * Edit properties
*/ */
private void advancedDialog() { private void advancedDialog() {
if (getWizard() instanceof CDTCommonProjectWizard) { if (getWizard() instanceof ICDTCommonProjectWizard) {
CDTCommonProjectWizard nmWizard = (CDTCommonProjectWizard)getWizard(); ICDTCommonProjectWizard nmWizard = (ICDTCommonProjectWizard)getWizard();
IProject newProject = nmWizard.getProject(true, false); IProject newProject = nmWizard.getProject(true, false);
if (newProject != null) { if (newProject != null) {
boolean oldManage = CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOMNG); boolean oldManage = CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOMNG);

View file

@ -29,6 +29,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException; import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
import org.eclipse.cdt.internal.ui.wizards.ICDTCommonProjectWizard;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty; import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue; import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.BuildException;
@ -48,7 +49,6 @@ import org.eclipse.cdt.ui.templateengine.Template;
import org.eclipse.cdt.ui.templateengine.TemplateEngineUI; import org.eclipse.cdt.ui.templateengine.TemplateEngineUI;
import org.eclipse.cdt.ui.templateengine.TemplateEngineUIUtil; import org.eclipse.cdt.ui.templateengine.TemplateEngineUIUtil;
import org.eclipse.cdt.ui.templateengine.pages.UIWizardPage; 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.CDTMainWizardPage;
import org.eclipse.cdt.ui.wizards.CWizardHandler; import org.eclipse.cdt.ui.wizards.CWizardHandler;
import org.eclipse.cdt.ui.wizards.EntryDescriptor; import org.eclipse.cdt.ui.wizards.EntryDescriptor;
@ -166,8 +166,8 @@ public class MBSWizardHandler extends CWizardHandler {
path.length > 1 && (!path[0].equals(ManagedBuildWizard.OTHERS_LABEL))){ path.length > 1 && (!path[0].equals(ManagedBuildWizard.OTHERS_LABEL))){
templateId = path[path.length - 1]; templateId = path[path.length - 1];
Template templates[] = null; Template templates[] = null;
if(wizard instanceof CDTCommonProjectWizard) { if(wizard instanceof ICDTCommonProjectWizard) {
CDTCommonProjectWizard wz = (CDTCommonProjectWizard)wizard; ICDTCommonProjectWizard wz = (ICDTCommonProjectWizard)wizard;
String[] langIDs = wz.getLanguageIDs(); String[] langIDs = wz.getLanguageIDs();
if(langIDs.length > 0) { if(langIDs.length > 0) {
List<Template> lstTemplates = new ArrayList<Template>(); List<Template> lstTemplates = new ArrayList<Template>();
@ -421,10 +421,10 @@ public class MBSWizardHandler extends CWizardHandler {
} }
private void loadCustomPages() { private void loadCustomPages() {
if (! (getWizard() instanceof CDTCommonProjectWizard)) if (! (getWizard() instanceof ICDTCommonProjectWizard))
return; // not probable return; // not probable
CDTCommonProjectWizard wz = (CDTCommonProjectWizard)getWizard(); ICDTCommonProjectWizard wz = (ICDTCommonProjectWizard)getWizard();
if (customPages == null) { if (customPages == null) {
MBSCustomPageManager.init(); MBSCustomPageManager.init();
@ -447,7 +447,7 @@ public class MBSWizardHandler extends CWizardHandler {
setCustomPagesFilter(wz); setCustomPagesFilter(wz);
} }
private void setCustomPagesFilter(CDTCommonProjectWizard wz) { private void setCustomPagesFilter(ICDTCommonProjectWizard wz) {
String[] natures = wz.getNatures(); String[] natures = wz.getNatures();
if (natures == null || natures.length == 0) if (natures == null || natures.length == 0)
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.NATURE, null); MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.NATURE, null);

View file

@ -0,0 +1,113 @@
/*******************************************************************************
* Copyright (c) 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards;
import java.net.URI;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
/**
* @since 5.1
*/
public interface ICDTCommonProjectWizard extends IWizard {
/**
* First stage of creating the project but no progress displayed. Identical to
* calling createIProject(name, location, new NullProgressMonitor())
*
* @param name name of the project
* @param location location URI for the project
* @return the project
* @throws CoreException if project creation fails for any reason
*/
public IProject createIProject(final String name, final URI location) throws CoreException;
/**
* First stage of creating the project. Only used internally.
*
* @param name name of the project
* @param location location URI for the project
* @param monitor progress monitor
* @return the project
* @throws CoreException if project creation fails for any reason
*/
public IProject createIProject(final String name, final URI location, IProgressMonitor monitor) throws CoreException;
/**
* Get the file content types supported by this project
*
* @return array of file content types
*/
public String[] getContentTypeIDs();
/**
* Get the file extension specifications for each content type.
*
* @return array of file extension specifications
*/
public String[] getExtensions();
/**
* Get the languages supported by each content type
*
* @return array of languages
*/
public String[] getLanguageIDs();
/**
* Return the last project created by the call to getProject().
*
* @return the last project created
*/
public IProject getLastProject();
/**
* Get the project natures provided by this project.
*
* @return array of project natures
*/
public String[] getNatures();
/**
* Create and return the project specified by the wizard. Identical to calling
* getProject(defaults, true)
*
* @param defaults true if called from the first wizard page
* @return the newly created project
*/
public IProject getProject(boolean defaults);
/**
* Create and return the project specified by the wizard.
*
* @param defaults true if called from the first wizard page
* @param onFinish true if the method is called when finish is pressed, false
* otherwise. If onFinish is false, the project is temporary and can be removed
* if cancel is pressed.
* @return the newly created project
*/
public IProject getProject(boolean defaults, boolean onFinish);
/**
* Can be used to pass a configuration element to update the perspective based
* on the current settings in the Workbench/Perspectives preference page via
* {@link BasicNewProjectResourceWizard#updatePerspective(IConfigurationElement)}
*
* @param config the configuration element
* @param propertyName not used
* @param data not used
* @throws CoreException
*/
public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException;
}

View file

@ -52,8 +52,10 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.newui.UIMessages; import org.eclipse.cdt.ui.newui.UIMessages;
import org.eclipse.cdt.internal.ui.wizards.ICDTCommonProjectWizard;
public abstract class CDTCommonProjectWizard extends BasicNewResourceWizard public abstract class CDTCommonProjectWizard extends BasicNewResourceWizard
implements IExecutableExtension, IWizardWithMemory implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard
{ {
private static final String PREFIX= "CProjectWizard"; //$NON-NLS-1$ private static final String PREFIX= "CProjectWizard"; //$NON-NLS-1$
private static final String OP_ERROR= "CProjectWizard.op_error"; //$NON-NLS-1$ private static final String OP_ERROR= "CProjectWizard.op_error"; //$NON-NLS-1$

View file

@ -13,14 +13,15 @@ package org.eclipse.cdt.managedbuilder.xlc.ui.wizards;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.internal.ui.wizards.ICDTCommonProjectWizard;
import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager; import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager;
import org.eclipse.cdt.managedbuilder.xlc.ui.preferences.PreferenceConstants; import org.eclipse.cdt.managedbuilder.xlc.ui.preferences.PreferenceConstants;
import org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.IWizardPage;
/** /**
@ -44,7 +45,7 @@ public class XLCSettingsWizardRunnable implements IRunnableWithProgress {
if(pages != null && pages.length > 0) { if(pages != null && pages.length > 0) {
CDTCommonProjectWizard wizard = (CDTCommonProjectWizard) pages[0].getWizard(); ICDTCommonProjectWizard wizard = (ICDTCommonProjectWizard) pages[0].getWizard();
IProject project = wizard.getLastProject(); IProject project = wizard.getLastProject();
try { try {