1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-20 07:25:23 +02:00

Added methods to create and convert to

default standard make C and C++ projects from simple projects such as 
when checking out new code "as a project" from CVS.
Using CCorePlugin as the holder of all knowledge as to what a C/C++ Standard Make project is.
This commit is contained in:
Judy N. Green 2002-08-15 20:41:10 +00:00
parent 5c11e9f0a3
commit cc9642e5a1
16 changed files with 124 additions and 166 deletions

View file

@ -28,13 +28,13 @@ StdCCWizard.description=Create a C++ Project
ConversionWizard.name=Convert a Project's Nature ConversionWizard.name=Convert a Project's Nature
ConversionWizard.description=Convert a Project's Nature ConversionWizard.description=Convert a Project's Nature
#Convert Unknown Project to C #Convert Simple Project to C
UKtoCConversionWizard.name=Convert Unknown to a C Project SimpleToCStdMakeConversionWizard.name=Convert to a C Project
UKtoCConversionWizard.description=Convert a Project's Nature from Unknown to C SimpleToCStdMakeConversionWizard.description=Convert a Project's Nature to C
#Convert Unknown Project to C++ #Convert Simple Project to C++
UKtoCCConversionWizard.name=Convert Unknown to a C++ Project SimpleToCCStdMakeConversionWizard.name=Convert to a C++ Project
UKtoCCConversionWizard.description=Convert a Project's Nature from Unknown to C++ SimpleToCCStdMakeConversionWizard.description=Convert a Project's Nature to C++
#Convert C to C++ #Convert C to C++
CtoCCConversionWizard.name=Convert C to a C++ Project CtoCCConversionWizard.name=Convert C to a C++ Project

View file

@ -146,8 +146,8 @@
id="org.eclipse.cdt.ui.CView"> id="org.eclipse.cdt.ui.CView">
</view> </view>
</extension> </extension>
<!-- For C Wizards -->
<!-- The wizards --> <!-- The wizards -->
<!-- For C Wizards -->
<extension <extension
point="org.eclipse.ui.newWizards"> point="org.eclipse.ui.newWizards">
<category <category
@ -166,17 +166,17 @@
%StdCWizard.description %StdCWizard.description
</description> </description>
</wizard> </wizard>
<!-- For C Conversion Wizards --> <!-- For C Conversion Wizards -->
<wizard <wizard
name="%UKtoCConversionWizard.name" name="%SimpleToCStdMakeConversionWizard.name"
icon="icons/full/ctool16/newcc_app.gif" icon="icons/full/ctool16/newcc_app.gif"
category="org.eclipse.cdt.ui.newCWizards" category="org.eclipse.cdt.ui.newCWizards"
class="org.eclipse.cdt.ui.wizards.conversion.UKtoCConversionWizard" class="org.eclipse.cdt.ui.wizards.conversion.SimpleToCStdMakeConversionWizard"
project="true" project="true"
finalPerspective="org.eclipse.cdt.ui.CPerspective" finalPerspective="org.eclipse.cdt.ui.CPerspective"
id="org.eclipse.cdt.ui.wizards.UKtoCConversionWizard"> id="org.eclipse.cdt.ui.wizards.SimpleToCStdMakeConversionWizard">
<description> <description>
%UKtoCConversionWizard.description %SimpleToCStdMakeConversionWizard.description
</description> </description>
</wizard> </wizard>
<!-- For C++ Wizards --> <!-- For C++ Wizards -->
@ -209,15 +209,15 @@
</description> </description>
</wizard> </wizard>
<wizard <wizard
name="%UKtoCCConversionWizard.name" name="%SimpleToCCStdMakeConversionWizard.name"
icon="icons/full/ctool16/newcc_app.gif" icon="icons/full/ctool16/newcc_app.gif"
category="org.eclipse.cdt.ui.newCCWizards" category="org.eclipse.cdt.ui.newCCWizards"
class="org.eclipse.cdt.ui.wizards.conversion.UKtoCCConversionWizard" class="org.eclipse.cdt.ui.wizards.conversion.SimpleToCCStdMakeConversionWizard"
project="true" project="true"
finalPerspective="org.eclipse.cdt.ui.CPerspective" finalPerspective="org.eclipse.cdt.ui.CPerspective"
id="org.eclipse.cdt.ui.wizards.UKtoCCConversionWizard"> id="org.eclipse.cdt.ui.wizards.SimpleToCCStdMakeConversionWizard">
<description> <description>
%UKtoCCConversionWizard.description %SimpleToCCStdMakeConversionWizard.description
</description> </description>
</wizard> </wizard>
</extension> </extension>
@ -431,6 +431,7 @@
id="org.eclipse.cdt.ui.cProjectNatureImage"> id="org.eclipse.cdt.ui.cProjectNatureImage">
</image> </image>
</extension> </extension>
<!-- =========================================================================== --> <!-- =========================================================================== -->
<!-- Debug Model Presentation --> <!-- Debug Model Presentation -->
<!-- =========================================================================== --> <!-- =========================================================================== -->

View file

@ -212,7 +212,7 @@ public class CPlugin extends AbstractUIPlugin {
public Object createPresentation() { public Object createPresentation() {
return new CDebugModelPresentation(); return new CDebugModelPresentation();
} }
public String getIdentifier() { public String getIdentifier() {
return PLUGIN_ID; return PLUGIN_ID;
} }
@ -290,7 +290,7 @@ public class CPlugin extends AbstractUIPlugin {
display.asyncExec(run); display.asyncExec(run);
} else { } else {
run.run(); run.run();
} }
} }
/** /**
@ -302,11 +302,11 @@ public class CPlugin extends AbstractUIPlugin {
manager.registerAdapters(new ResourceAdapterFactory(), IResource.class); manager.registerAdapters(new ResourceAdapterFactory(), IResource.class);
manager.registerAdapters(new CElementAdapterFactory(), ICElement.class); manager.registerAdapters(new CElementAdapterFactory(), ICElement.class);
runUI(new Runnable() { runUI(new Runnable() {
public void run() { public void run() {
CPluginImages.initialize(); CPluginImages.initialize();
} }
}); });
} }
/** /**
* @see AbstractUIPlugin#initializeDefaultPreferences * @see AbstractUIPlugin#initializeDefaultPreferences
@ -315,10 +315,10 @@ public class CPlugin extends AbstractUIPlugin {
super.initializeDefaultPreferences(store); super.initializeDefaultPreferences(store);
runUI(new Runnable() { runUI(new Runnable() {
public void run() { public void run() {
CPluginPreferencePage.initDefaults(store); CPluginPreferencePage.initDefaults(store);
CEditorPreferencePage.initDefaults(store); CEditorPreferencePage.initDefaults(store);
CView.initDefaults(store); CView.initDefaults(store);
} }
}); });
} }

View file

@ -88,23 +88,23 @@ CProjectWizardPage=C Wizard Page
# Defaults from ConvertProjectWizardPage # Defaults from ConvertProjectWizardPage
ConversionWizard.windowTitle=Convert C/C++ Projects ConversionWizard.windowTitle=Convert C/C++ Projects
ConversionWizard.description=Select Project(s) for Conversion ConversionWizard.description=Select Project(s) for Conversion
ConversionWizard.title=Add a C++ Nature to Eligible Project(s) ConversionWizard.title=Add a C++ Nature to Project(s)
ConversionWizard.projectlist=Candidates for Conversion ConversionWizard.projectlist=Candidates for Conversion
# Convert from Unkown to C # Convert from Simple to C
UKtoCConversionWizard.windowTitle=Convert Unknown Projects to C SimpleToCStdMakeConversionWizard.windowTitle=Convert Projects to C
UKtoCConversionWizard.description=Select Unknown Project(s) for Conversion SimpleToCStdMakeConversionWizard.description=Select Project(s) for Conversion
UKtoCConversionWizard.title=Add a C Nature to Eligible Project(s) SimpleToCStdMakeConversionWizard.title=Add a C Nature to Available Project(s)
# Convert from Unkown to C++ # Convert from Simple to C++
UKtoCCConversionWizard.windowTitle=Convert Unknown Projects to C++ SimpleToCCStdMakeConversionWizard.windowTitle=Convert Projects to C++
UKtoCCConversionWizard.description=Select Unknown Project(s) for Conversion SimpleToCCStdMakeConversionWizard.description=Select Project(s) for Conversion
UKtoCCConversionWizard.title=Add a C++ Nature to Eligible Project(s) SimpleToCCStdMakeConversionWizard.title=Add a C++ Nature to Available Project(s)
# Convert from C to C++ # Convert from C to C++
CtoCCConversionWizard.windowTitle=Convert C Projects to C++ CtoCCConversionWizard.windowTitle=Convert C Projects to C++
CtoCCConversionWizard.description=Select C Project(s) for Conversion CtoCCConversionWizard.description=Select C Project(s) for Conversion
CtoCCConversionWizard.title=Add a C++ Nature to Eligible Project(s) CtoCCConversionWizard.title=Add a C++ Nature to Project(s)
TabFolderPage=Tab Folder Page TabFolderPage=Tab Folder Page
TabFolderPage.title=Project TabFolderPage.title=Project

View file

@ -5,12 +5,11 @@ package org.eclipse.cdt.ui.wizards;
* All Rights Reserved. * All Rights Reserved.
*/ */
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.internal.ui.CPlugin;
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.cdt.core.CCProjectNature;
import org.eclipse.cdt.internal.ui.CPlugin;
/** /**
* C Project wizard that creates a new project resource in * C Project wizard that creates a new project resource in
@ -58,9 +57,9 @@ public abstract class CCProjectWizard extends CProjectWizard {
protected void doRun(IProgressMonitor monitor) throws CoreException { protected void doRun(IProgressMonitor monitor) throws CoreException {
super.doRun(monitor); super.doRun(monitor);
// Add C++ Nature. // Add C++ Nature to the newly created project.
if (newProject != null) { if (newProject != null){
CCProjectNature.addCCNature(newProject, monitor); CCorePlugin.getDefault().convertProjectFromCtoCC(newProject, monitor);
} }
} }
} }

View file

@ -22,7 +22,6 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.ErrorDialog;
@ -40,9 +39,6 @@ import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard; import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.core.ICProjectDescriptor;
import org.eclipse.cdt.core.ICProjectOwnerInfo;
import org.eclipse.cdt.internal.ui.CPlugin; import org.eclipse.cdt.internal.ui.CPlugin;
import org.eclipse.cdt.internal.ui.CPluginImages; import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.utils.ui.swt.IValidation; import org.eclipse.cdt.utils.ui.swt.IValidation;
@ -50,6 +46,7 @@ import org.eclipse.cdt.utils.ui.swt.IValidation;
/** /**
* C Project wizard that creates a new project resource in * C Project wizard that creates a new project resource in
* a location of the user's choice.
*/ */
public abstract class CProjectWizard extends BasicNewResourceWizard implements IExecutableExtension { public abstract class CProjectWizard extends BasicNewResourceWizard implements IExecutableExtension {
@ -300,43 +297,10 @@ public abstract class CProjectWizard extends BasicNewResourceWizard implements I
IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName()); IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
description.setLocation(newPath); description.setLocation(newPath);
newProject = createProject(description, newProjectHandle, monitor); newProject = CCorePlugin.getDefault().createCProject(description, newProjectHandle, monitor, getProjectID());
return newProject; return newProject;
} }
/**
* Creates a project resource given the project handle and description.
*
* @param description the project description to create a project resource for
* @param projectHandle the project handle to create a project resource for
* @param monitor the progress monitor to show visual progress with
*
* @exception CoreException if the operation fails
* @exception OperationCanceledException if the operation is canceled
*/
private IProject createProject(IProjectDescription description, IProject projectHandle,
IProgressMonitor monitor) throws CoreException, OperationCanceledException {
try {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.beginTask("Creating C Project", 3);//$NON-NLS-1$
projectHandle.create(description, new SubProgressMonitor(monitor, 1));
if (monitor.isCanceled())
throw new OperationCanceledException();
// Open first.
projectHandle.open(new SubProgressMonitor(monitor, 1));
// Add C Nature.
CProjectNature.addCNature(projectHandle, new SubProgressMonitor(monitor, 1));
CCorePlugin.getDefault().mapCProjectOwner(projectHandle, getProjectID());
} finally {
//monitor.done();
}
return projectHandle;
}
/** /**
* Method getID. * Method getID.

View file

@ -5,15 +5,13 @@ package org.eclipse.cdt.ui.wizards;
* All Rights Reserved. * All Rights Reserved.
*/ */
import org.eclipse.cdt.core.CCProjectNature; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.internal.ui.CPlugin; import org.eclipse.cdt.internal.ui.CPlugin;
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.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabFolder;
/** /**
*/ */
public class StdCCWizard extends StdMakeProjectWizard { public class StdCCWizard extends StdMakeProjectWizard {
@ -44,7 +42,8 @@ public class StdCCWizard extends StdMakeProjectWizard {
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
} }
monitor.beginTask("Standard C++ Make", 1); monitor.beginTask("Standard C++ Make", 1);
CCProjectNature.addCCNature(newProject, new SubProgressMonitor(monitor, 1)); // Add C++ Nature to the newly created project.
CCorePlugin.getDefault().convertProjectFromCtoCC(newProject, monitor);
} }
} }
} }

View file

@ -6,7 +6,6 @@ package org.eclipse.cdt.ui.wizards;
*/ */
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.internal.ui.CPlugin; import org.eclipse.cdt.internal.ui.CPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
@ -71,7 +70,10 @@ public abstract class StdMakeProjectWizard extends CProjectWizard {
} }
protected void doRun(IProgressMonitor monitor) throws CoreException { protected void doRun(IProgressMonitor monitor) throws CoreException {
// super.doRun() just creates the project and does not assign a builder to it.
super.doRun(monitor); super.doRun(monitor);
// Modify the project based on what the user has selected
if (newProject != null) { if (newProject != null) {
if (monitor == null) { if (monitor == null) {
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
@ -85,8 +87,9 @@ public abstract class StdMakeProjectWizard extends CProjectWizard {
if (settingsBlock != null) { if (settingsBlock != null) {
settingsBlock.doRun(newProject, new SubProgressMonitor(monitor, 1)); settingsBlock.doRun(newProject, new SubProgressMonitor(monitor, 1));
} }
// Set the Default C Builder.
CProjectNature.addCBuildSpec(newProject, new SubProgressMonitor(monitor, 1)); // Set the Default C Builder to make this a StdMakeProject.
CCorePlugin.getDefault().addDefaultCBuilder(newProject, new SubProgressMonitor(monitor, 1));
} }
} }

View file

@ -11,8 +11,10 @@ import org.eclipse.cdt.ui.wizards.CProjectWizard;
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.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.ui.IWorkbench;
/** /**
* ConversionWizard This wizard provides a method by which the user can * ConversionWizard This wizard provides a method by which the user can
@ -55,6 +57,14 @@ public abstract class ConversionWizard
super(title, desc); super(title, desc);
} }
/* (non-Javadoc)
* Method declared on IWorkbenchWizard.
*/
public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
super.init(workbench, currentSelection);
setWindowTitle(getWindowTitleResource());
}
/** /**
* Method getWindowTitleResource, allows Wizard Title label value to be * Method getWindowTitleResource, allows Wizard Title label value to be
* changed by subclasses * changed by subclasses

View file

@ -8,14 +8,13 @@ package org.eclipse.cdt.ui.wizards.conversion;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.internal.ui.CPlugin; import org.eclipse.cdt.internal.ui.CPlugin;
import org.eclipse.cdt.internal.ui.util.CoreUtility;
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;
/** /**
* *
* ConvertProjectWizardPage * ConvertCtoCCStdMakeProjectWizardPage
* Standard main page for a wizard that converts a project's nature from C to C++. * Standard main page for a wizard that converts a project's nature from C to C++.
* This conversion is one way in that the project cannot be converted back from a C++ project to a C project. * This conversion is one way in that the project cannot be converted back from a C++ project to a C project.
* *
@ -24,22 +23,22 @@ import org.eclipse.core.runtime.IProgressMonitor;
*<p> *<p>
* Example useage: * Example useage:
* <pre> * <pre>
* mainPage = new ConvertCtoCCProjectWizardPage("CtoCCConvertProjectPage"); * mainPage = new ConvertCtoCCStdMakeProjectWizardPage("CtoCCConvertProjectPage");
* mainPage.setTitle("Project Conversion"); * mainPage.setTitle("Project Conversion");
* mainPage.setDescription("Convert a project's nature from C to C++."); * mainPage.setDescription("Convert a project's nature from C to C++.");
* </pre> * </pre>
* </p> * </p>
*/ */
public class ConvertCtoCCProjectWizardPage extends ConvertProjectWizardPage { public class ConvertCtoCCStdMakeProjectWizardPage extends ConvertProjectWizardPage {
private static final String WZ_TITLE = "CtoCCConversionWizard.title"; //$NON-NLS-1$ private static final String WZ_TITLE = "CtoCCConversionWizard.title"; //$NON-NLS-1$
private static final String WZ_DESC = "CtoCCConversionWizard.description"; //$NON-NLS-1$ private static final String WZ_DESC = "CtoCCConversionWizard.description"; //$NON-NLS-1$
/** /**
* Constructor for ConvertCtoCCProjectWizardPage. * Constructor for ConvertCtoCCStdMakeProjectWizardPage.
* @param pageName * @param pageName
*/ */
public ConvertCtoCCProjectWizardPage(String pageName) { public ConvertCtoCCStdMakeProjectWizardPage(String pageName) {
super(pageName); super(pageName);
} }
@ -90,7 +89,7 @@ public class ConvertCtoCCProjectWizardPage extends ConvertProjectWizardPage {
*/ */
public void convertProject(IProject project, IProgressMonitor monitor, String projectID) public void convertProject(IProject project, IProgressMonitor monitor, String projectID)
throws CoreException { throws CoreException {
CoreUtility.addNatureToProject(project, CoreModel.CC_NATURE_ID, monitor);
CCorePlugin.getDefault().mapCProjectOwner(project, projectID); CCorePlugin.getDefault().convertProjectFromCtoCC(project, monitor, projectID);
} }
} }

View file

@ -60,8 +60,8 @@ import org.eclipse.ui.PlatformUI;
public abstract class ConvertProjectWizardPage public abstract class ConvertProjectWizardPage
extends WizardPage { extends WizardPage {
public static final String KEY_TITLE = "ProjectConvertionWizard.title"; public static final String KEY_TITLE = "ConvertionWizard.title";
public static final String KEY_CONVERTING = "ProjectConvertionWizard.converting"; public static final String KEY_CONVERTING = "ConvertionWizard.converting";
private static final String PROJECT_LIST = "ConversionWizard.projectlist"; private static final String PROJECT_LIST = "ConversionWizard.projectlist";
// The Main widget containing the table and its list of condidate open projects // The Main widget containing the table and its list of condidate open projects

View file

@ -8,14 +8,13 @@ package org.eclipse.cdt.ui.wizards.conversion;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.internal.ui.CPlugin; import org.eclipse.cdt.internal.ui.CPlugin;
import org.eclipse.cdt.internal.ui.util.CoreUtility;
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;
/** /**
* *
* ConvertUKtoCCProjectWizardPage * ConvertSimpleToCCStdMakeProjectWizardPage
* Standard main page for a wizard that adds a C++ project Nature to a project with no nature associated with it. * Standard main page for a wizard that adds a C++ project Nature to a project with no nature associated with it.
* This conversion is one way in that the project cannot be converted back (i.e have the nature removed). * This conversion is one way in that the project cannot be converted back (i.e have the nature removed).
* *
@ -24,22 +23,22 @@ import org.eclipse.core.runtime.IProgressMonitor;
*<p> *<p>
* Example useage: * Example useage:
* <pre> * <pre>
* mainPage = new ConvertUKtoCCProjectWizardPage("UKtoCCConvertProjectPage"); * mainPage = new ConvertSimpleToCCStdMakeProjectWizardPage("UKtoCCConvertProjectPage");
* mainPage.setTitle("Project Conversion"); * mainPage.setTitle("Project Conversion");
* mainPage.setDescription("Add C++ a Nature to a project."); * mainPage.setDescription("Add C++ a Nature to a project.");
* </pre> * </pre>
* </p> * </p>
*/ */
public class ConvertUKtoCCProjectWizardPage extends ConvertProjectWizardPage { public class ConvertSimpleToCCStdMakeProjectWizardPage extends ConvertSimpleToCStdMakeProjectWizardPage {
private static final String WZ_TITLE = "UKtoCCConversionWizard.title"; //$NON-NLS-1$ private static final String WZ_TITLE = "SimpleToCCStdMakeConversionWizard.title"; //$NON-NLS-1$
private static final String WZ_DESC = "UKtoCCConversionWizard.description"; //$NON-NLS-1$ private static final String WZ_DESC = "SimpleToCCStdMakeConversionWizard.description"; //$NON-NLS-1$
/** /**
* Constructor for ConvertUKtoCCProjectWizardPage. * Constructor for ConvertSimpleToCCStdMakeProjectWizardPage.
* @param pageName * @param pageName
*/ */
public ConvertUKtoCCProjectWizardPage(String pageName) { public ConvertSimpleToCCStdMakeProjectWizardPage(String pageName) {
super(pageName); super(pageName);
} }
@ -67,20 +66,16 @@ public class ConvertUKtoCCProjectWizardPage extends ConvertProjectWizardPage {
* @return boolean * @return boolean
*/ */
protected boolean isCandidate(IProject project) { protected boolean isCandidate(IProject project) {
boolean noCNature = false; boolean noCNature = super.isCandidate(project);
boolean noCCNature = false; boolean noCCNature = false;
// hasNature() throws a CoreException if the // hasNature() throws a CoreException if the
// project is not open and/or is not visible to this view // project is not open and/or is not visible to this view
// which is what happens when a project does not have a // which is what happens when a project does not have a
// C nature // C nature
try {
project.hasNature(CoreModel.C_NATURE_ID);
} catch (CoreException e) {
noCNature = true;
}
try { try {
project.hasNature(CoreModel.CC_NATURE_ID); noCCNature = !project.hasNature(CoreModel.CC_NATURE_ID);
} catch (CoreException e) { } catch (CoreException e) {
noCCNature = true; noCCNature = true;
} }
@ -88,8 +83,8 @@ public class ConvertUKtoCCProjectWizardPage extends ConvertProjectWizardPage {
} }
/** /**
* Method convertProject adds a C++ Nature to those projects * Method convertProject adds a C++ Nature and default make builder
* that were selected by the user. * to those projects that were selected by the user.
* *
* @param project * @param project
* @param monitor * @param monitor
@ -100,9 +95,7 @@ public class ConvertUKtoCCProjectWizardPage extends ConvertProjectWizardPage {
throws CoreException { throws CoreException {
if (!project.isOpen()){ if (!project.isOpen()){
project.open(monitor); project.open(monitor);
} }
CoreUtility.addNatureToProject(project, CoreModel.C_NATURE_ID, monitor); CCorePlugin.getDefault().convertProjectToCC(project, monitor, projectID);
CoreUtility.addNatureToProject(project, CoreModel.CC_NATURE_ID, monitor);
CCorePlugin.getDefault().mapCProjectOwner(project, projectID);
} }
} }

View file

@ -8,14 +8,13 @@ package org.eclipse.cdt.ui.wizards.conversion;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.internal.ui.CPlugin; import org.eclipse.cdt.internal.ui.CPlugin;
import org.eclipse.cdt.internal.ui.util.CoreUtility;
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;
/** /**
* *
* ConvertUKtoCProjectWizardPage * ConvertSimpleToCStdMakeProjectWizardPage
* Standard main page for a wizard that adds a C project Nature to a project with no nature associated with it. * Standard main page for a wizard that adds a C project Nature to a project with no nature associated with it.
* This conversion is one way in that the project cannot be converted back (i.e have the nature removed). * This conversion is one way in that the project cannot be converted back (i.e have the nature removed).
* *
@ -24,22 +23,22 @@ import org.eclipse.core.runtime.IProgressMonitor;
*<p> *<p>
* Example useage: * Example useage:
* <pre> * <pre>
* mainPage = new ConvertUKtoCProjectWizardPage("UKtoCConvertProjectPage"); * mainPage = new ConvertSimpleToCStdMakeProjectWizardPage("UKtoCConvertProjectPage");
* mainPage.setTitle("Project Conversion"); * mainPage.setTitle("Project Conversion");
* mainPage.setDescription("Add C a Nature to a project."); * mainPage.setDescription("Add C a Nature to a project.");
* </pre> * </pre>
* </p> * </p>
*/ */
public class ConvertUKtoCProjectWizardPage extends ConvertProjectWizardPage { public class ConvertSimpleToCStdMakeProjectWizardPage extends ConvertProjectWizardPage {
private static final String WZ_TITLE = "UKtoCConversionWizard.title"; //$NON-NLS-1$ private static final String WZ_TITLE = "SimpleToCStdMakeConversionWizard.title"; //$NON-NLS-1$
private static final String WZ_DESC = "UKtoCConversionWizard.description"; //$NON-NLS-1$ private static final String WZ_DESC = "SimpleToCStdMakeConversionWizard.description"; //$NON-NLS-1$
/** /**
* Constructor for ConvertUKtoCProjectWizardPage. * Constructor for ConvertSimpleToCStdMakeProjectWizardPage.
* @param pageName * @param pageName
*/ */
public ConvertUKtoCProjectWizardPage(String pageName) { public ConvertSimpleToCStdMakeProjectWizardPage(String pageName) {
super(pageName); super(pageName);
} }
@ -61,20 +60,20 @@ public class ConvertUKtoCProjectWizardPage extends ConvertProjectWizardPage {
/** /**
* Method isCandidate returns projects that have * Method isCandidate returns projects that have
* no "C" Nature * no "C" Nature, but are Projects in the Eclipse sense.
* *
* @param project * @param project
* @return boolean * @return boolean
*/ */
protected boolean isCandidate(IProject project) { protected boolean isCandidate(IProject project) {
boolean noCNature = false; boolean noCNature = false;
// hasNature() throws a CoreException if the // hasNature() throws a CoreException if the
// project is not open and/or is not visible to this view // project is not open and/or is not visible to this view
// which is what happens when a project does not have a // which is what happens when a project does not have a
// C nature // C nature
try { try {
project.hasNature(CoreModel.C_NATURE_ID); noCNature = !project.hasNature(CoreModel.C_NATURE_ID);
} catch (CoreException e) { } catch (CoreException e) {
noCNature = true; noCNature = true;
} }
@ -82,8 +81,8 @@ public class ConvertUKtoCProjectWizardPage extends ConvertProjectWizardPage {
} }
/** /**
* Method convertProject adds a C Nature to those projects * Method convertProject adds a C Nature and default make builder
* that were selected by the user. * to those projects that were selected by the user.
* *
* @param project * @param project
* @param monitor * @param monitor
@ -92,10 +91,10 @@ public class ConvertUKtoCProjectWizardPage extends ConvertProjectWizardPage {
*/ */
public void convertProject(IProject project, IProgressMonitor monitor, String projectID) public void convertProject(IProject project, IProgressMonitor monitor, String projectID)
throws CoreException { throws CoreException {
CCorePlugin.getDefault().convertProjectToC(project, monitor, projectID);
if (!project.isOpen()){ if (!project.isOpen()){
project.open(monitor); project.open(monitor);
} }
CoreUtility.addNatureToProject(project, CoreModel.C_NATURE_ID, monitor);
CCorePlugin.getDefault().mapCProjectOwner(project, projectID);
} }
} }

View file

@ -81,11 +81,8 @@ public class CtoCCConversionWizard extends ConversionWizard {
* @see Wizard#createPages * @see Wizard#createPages
*/ */
public void addPages() { public void addPages() {
mainPage = new ConvertCtoCCProjectWizardPage(getPrefix()); mainPage = new ConvertCtoCCStdMakeProjectWizardPage(getPrefix());
addPage(mainPage); addPage(mainPage);
// ensure proper window name by overwriting the title set by the super class
this.setWindowTitle(getWindowTitleResource());
} }
} }

View file

@ -11,27 +11,27 @@ import org.eclipse.cdt.internal.ui.CPlugin;
* This wizard provides a method by which the user can * This wizard provides a method by which the user can
* add a C++ nature to a project that previously had no nature associated with it. * add a C++ nature to a project that previously had no nature associated with it.
*/ */
public class UKtoCCConversionWizard extends ConversionWizard { public class SimpleToCCStdMakeConversionWizard extends ConversionWizard {
private static final String WZ_TITLE = "UKtoCCConversionWizard.title"; //$NON-NLS-1$ private static final String WZ_TITLE = "SimpleToCCStdMakeConversionWizard.title"; //$NON-NLS-1$
private static final String WZ_DESC = "UKtoCCConversionWizard.description"; //$NON-NLS-1$ private static final String WZ_DESC = "SimpleToCCStdMakeConversionWizard.description"; //$NON-NLS-1$
private static final String PREFIX= "UKtoCCConversionWizard"; //$NON-NLS-1$ private static final String PREFIX= "SimpleToCCStdMakeConversionWizard"; //$NON-NLS-1$
private static final String WINDOW_TITLE = "UKtoCCConversionWizard.windowTitle";//$NON-NLS-1$ private static final String WINDOW_TITLE = "SimpleToCCStdMakeConversionWizard.windowTitle";//$NON-NLS-1$
/** /**
* UKtoCCConversionWizard Wizard constructor * SimpleToCCStdMakeConversionWizard Wizard constructor
*/ */
public UKtoCCConversionWizard() { public SimpleToCCStdMakeConversionWizard() {
this(getWindowTitleResource(), getWzDescriptionResource()); this(getWindowTitleResource(), getWzDescriptionResource());
} }
/** /**
* UKtoCCConversionWizard Wizard constructor * SimpleToCCStdMakeConversionWizard Wizard constructor
* *
* @param title * @param title
* @param desc * @param desc
*/ */
public UKtoCCConversionWizard(String title, String desc) { public SimpleToCCStdMakeConversionWizard(String title, String desc) {
super(title, desc); super(title, desc);
} }
@ -81,11 +81,8 @@ public class UKtoCCConversionWizard extends ConversionWizard {
* @see Wizard#createPages * @see Wizard#createPages
*/ */
public void addPages() { public void addPages() {
mainPage = new ConvertUKtoCCProjectWizardPage(getPrefix()); mainPage = new ConvertSimpleToCCStdMakeProjectWizardPage(getPrefix());
addPage(mainPage); addPage(mainPage);
// ensure proper window name by overwriting the title set by the super class
this.setWindowTitle(getWindowTitleResource());
} }
} }

View file

@ -11,27 +11,27 @@ import org.eclipse.cdt.internal.ui.CPlugin;
* This wizard provides a method by which the user can * This wizard provides a method by which the user can
* add a C nature to a project that previously had no nature associated with it. * add a C nature to a project that previously had no nature associated with it.
*/ */
public class UKtoCConversionWizard extends ConversionWizard { public class SimpleToCStdMakeConversionWizard extends ConversionWizard {
private static final String WZ_TITLE = "UKtoCConversionWizard.title"; //$NON-NLS-1$ private static final String WZ_TITLE = "SimpleToCStdMakeConversionWizard.title"; //$NON-NLS-1$
private static final String WZ_DESC = "UKtoCConversionWizard.description"; //$NON-NLS-1$ private static final String WZ_DESC = "SimpleToCStdMakeConversionWizard.description"; //$NON-NLS-1$
private static final String PREFIX= "UKtoCConversionWizard"; //$NON-NLS-1$ private static final String PREFIX= "SimpleToCStdMakeConversionWizard"; //$NON-NLS-1$
private static final String WINDOW_TITLE = "UKtoCConversionWizard.windowTitle";//$NON-NLS-1$ private static final String WINDOW_TITLE = "SimpleToCStdMakeConversionWizard.windowTitle";//$NON-NLS-1$
/** /**
* UKtoCConversionWizard Wizard constructor * SimpleToCStdMakeConversionWizard Wizard constructor
*/ */
public UKtoCConversionWizard() { public SimpleToCStdMakeConversionWizard() {
this(getWindowTitleResource(), getWzDescriptionResource()); this(getWindowTitleResource(), getWzDescriptionResource());
} }
/** /**
* UKtoCConversionWizard Wizard constructor * SimpleToCStdMakeConversionWizard Wizard constructor
* *
* @param title * @param title
* @param desc * @param desc
*/ */
public UKtoCConversionWizard(String title, String desc) { public SimpleToCStdMakeConversionWizard(String title, String desc) {
super(title, desc); super(title, desc);
} }
@ -81,11 +81,8 @@ public class UKtoCConversionWizard extends ConversionWizard {
* @see Wizard#createPages * @see Wizard#createPages
*/ */
public void addPages() { public void addPages() {
mainPage = new ConvertUKtoCProjectWizardPage(getPrefix()); mainPage = new ConvertSimpleToCStdMakeProjectWizardPage(getPrefix());
addPage(mainPage); addPage(mainPage);
// ensure proper window name by overwriting the title set by the super class
this.setWindowTitle(getWindowTitleResource());
} }
} }