mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-21 16:05:25 +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:
parent
5c11e9f0a3
commit
cc9642e5a1
16 changed files with 124 additions and 166 deletions
|
@ -28,13 +28,13 @@ StdCCWizard.description=Create a C++ Project
|
|||
ConversionWizard.name=Convert a Project's Nature
|
||||
ConversionWizard.description=Convert a Project's Nature
|
||||
|
||||
#Convert Unknown Project to C
|
||||
UKtoCConversionWizard.name=Convert Unknown to a C Project
|
||||
UKtoCConversionWizard.description=Convert a Project's Nature from Unknown to C
|
||||
#Convert Simple Project to C
|
||||
SimpleToCStdMakeConversionWizard.name=Convert to a C Project
|
||||
SimpleToCStdMakeConversionWizard.description=Convert a Project's Nature to C
|
||||
|
||||
#Convert Unknown Project to C++
|
||||
UKtoCCConversionWizard.name=Convert Unknown to a C++ Project
|
||||
UKtoCCConversionWizard.description=Convert a Project's Nature from Unknown to C++
|
||||
#Convert Simple Project to C++
|
||||
SimpleToCCStdMakeConversionWizard.name=Convert to a C++ Project
|
||||
SimpleToCCStdMakeConversionWizard.description=Convert a Project's Nature to C++
|
||||
|
||||
#Convert C to C++
|
||||
CtoCCConversionWizard.name=Convert C to a C++ Project
|
||||
|
|
|
@ -146,8 +146,8 @@
|
|||
id="org.eclipse.cdt.ui.CView">
|
||||
</view>
|
||||
</extension>
|
||||
<!-- For C Wizards -->
|
||||
<!-- The wizards -->
|
||||
<!-- For C Wizards -->
|
||||
<extension
|
||||
point="org.eclipse.ui.newWizards">
|
||||
<category
|
||||
|
@ -168,15 +168,15 @@
|
|||
</wizard>
|
||||
<!-- For C Conversion Wizards -->
|
||||
<wizard
|
||||
name="%UKtoCConversionWizard.name"
|
||||
name="%SimpleToCStdMakeConversionWizard.name"
|
||||
icon="icons/full/ctool16/newcc_app.gif"
|
||||
category="org.eclipse.cdt.ui.newCWizards"
|
||||
class="org.eclipse.cdt.ui.wizards.conversion.UKtoCConversionWizard"
|
||||
class="org.eclipse.cdt.ui.wizards.conversion.SimpleToCStdMakeConversionWizard"
|
||||
project="true"
|
||||
finalPerspective="org.eclipse.cdt.ui.CPerspective"
|
||||
id="org.eclipse.cdt.ui.wizards.UKtoCConversionWizard">
|
||||
id="org.eclipse.cdt.ui.wizards.SimpleToCStdMakeConversionWizard">
|
||||
<description>
|
||||
%UKtoCConversionWizard.description
|
||||
%SimpleToCStdMakeConversionWizard.description
|
||||
</description>
|
||||
</wizard>
|
||||
<!-- For C++ Wizards -->
|
||||
|
@ -209,15 +209,15 @@
|
|||
</description>
|
||||
</wizard>
|
||||
<wizard
|
||||
name="%UKtoCCConversionWizard.name"
|
||||
name="%SimpleToCCStdMakeConversionWizard.name"
|
||||
icon="icons/full/ctool16/newcc_app.gif"
|
||||
category="org.eclipse.cdt.ui.newCCWizards"
|
||||
class="org.eclipse.cdt.ui.wizards.conversion.UKtoCCConversionWizard"
|
||||
class="org.eclipse.cdt.ui.wizards.conversion.SimpleToCCStdMakeConversionWizard"
|
||||
project="true"
|
||||
finalPerspective="org.eclipse.cdt.ui.CPerspective"
|
||||
id="org.eclipse.cdt.ui.wizards.UKtoCCConversionWizard">
|
||||
id="org.eclipse.cdt.ui.wizards.SimpleToCCStdMakeConversionWizard">
|
||||
<description>
|
||||
%UKtoCCConversionWizard.description
|
||||
%SimpleToCCStdMakeConversionWizard.description
|
||||
</description>
|
||||
</wizard>
|
||||
</extension>
|
||||
|
@ -431,6 +431,7 @@
|
|||
id="org.eclipse.cdt.ui.cProjectNatureImage">
|
||||
</image>
|
||||
</extension>
|
||||
|
||||
<!-- =========================================================================== -->
|
||||
<!-- Debug Model Presentation -->
|
||||
<!-- =========================================================================== -->
|
||||
|
|
|
@ -88,23 +88,23 @@ CProjectWizardPage=C Wizard Page
|
|||
# Defaults from ConvertProjectWizardPage
|
||||
ConversionWizard.windowTitle=Convert C/C++ Projects
|
||||
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
|
||||
|
||||
# Convert from Unkown to C
|
||||
UKtoCConversionWizard.windowTitle=Convert Unknown Projects to C
|
||||
UKtoCConversionWizard.description=Select Unknown Project(s) for Conversion
|
||||
UKtoCConversionWizard.title=Add a C Nature to Eligible Project(s)
|
||||
# Convert from Simple to C
|
||||
SimpleToCStdMakeConversionWizard.windowTitle=Convert Projects to C
|
||||
SimpleToCStdMakeConversionWizard.description=Select Project(s) for Conversion
|
||||
SimpleToCStdMakeConversionWizard.title=Add a C Nature to Available Project(s)
|
||||
|
||||
# Convert from Unkown to C++
|
||||
UKtoCCConversionWizard.windowTitle=Convert Unknown Projects to C++
|
||||
UKtoCCConversionWizard.description=Select Unknown Project(s) for Conversion
|
||||
UKtoCCConversionWizard.title=Add a C++ Nature to Eligible Project(s)
|
||||
# Convert from Simple to C++
|
||||
SimpleToCCStdMakeConversionWizard.windowTitle=Convert Projects to C++
|
||||
SimpleToCCStdMakeConversionWizard.description=Select Project(s) for Conversion
|
||||
SimpleToCCStdMakeConversionWizard.title=Add a C++ Nature to Available Project(s)
|
||||
|
||||
# Convert from C to C++
|
||||
CtoCCConversionWizard.windowTitle=Convert C Projects to C++
|
||||
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.title=Project
|
||||
|
|
|
@ -5,12 +5,11 @@ package org.eclipse.cdt.ui.wizards;
|
|||
* 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.IProgressMonitor;
|
||||
|
||||
import org.eclipse.cdt.core.CCProjectNature;
|
||||
import org.eclipse.cdt.internal.ui.CPlugin;
|
||||
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
super.doRun(monitor);
|
||||
// Add C++ Nature.
|
||||
if (newProject != null) {
|
||||
CCProjectNature.addCCNature(newProject, monitor);
|
||||
// Add C++ Nature to the newly created project.
|
||||
if (newProject != null){
|
||||
CCorePlugin.getDefault().convertProjectFromCtoCC(newProject, monitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.eclipse.core.runtime.IPath;
|
|||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
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.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.CPluginImages;
|
||||
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
|
||||
* a location of the user's choice.
|
||||
*/
|
||||
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());
|
||||
description.setLocation(newPath);
|
||||
|
||||
newProject = createProject(description, newProjectHandle, monitor);
|
||||
newProject = CCorePlugin.getDefault().createCProject(description, newProjectHandle, monitor, getProjectID());
|
||||
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.
|
||||
|
|
|
@ -5,15 +5,13 @@ package org.eclipse.cdt.ui.wizards;
|
|||
* 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.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.swt.widgets.TabFolder;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
public class StdCCWizard extends StdMakeProjectWizard {
|
||||
|
@ -44,7 +42,8 @@ public class StdCCWizard extends StdMakeProjectWizard {
|
|||
monitor = new NullProgressMonitor();
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ package org.eclipse.cdt.ui.wizards;
|
|||
*/
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.internal.ui.CPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
@ -71,7 +70,10 @@ public abstract class StdMakeProjectWizard extends CProjectWizard {
|
|||
}
|
||||
|
||||
protected void doRun(IProgressMonitor monitor) throws CoreException {
|
||||
// super.doRun() just creates the project and does not assign a builder to it.
|
||||
super.doRun(monitor);
|
||||
|
||||
// Modify the project based on what the user has selected
|
||||
if (newProject != null) {
|
||||
if (monitor == null) {
|
||||
monitor = new NullProgressMonitor();
|
||||
|
@ -85,8 +87,9 @@ public abstract class StdMakeProjectWizard extends CProjectWizard {
|
|||
if (settingsBlock != null) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,10 @@ import org.eclipse.cdt.ui.wizards.CProjectWizard;
|
|||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
|
||||
import org.eclipse.swt.widgets.TabFolder;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
|
||||
/**
|
||||
* ConversionWizard This wizard provides a method by which the user can
|
||||
|
@ -55,6 +57,14 @@ public abstract class ConversionWizard
|
|||
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
|
||||
* changed by subclasses
|
||||
|
|
|
@ -8,14 +8,13 @@ package org.eclipse.cdt.ui.wizards.conversion;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
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.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
/**
|
||||
*
|
||||
* ConvertProjectWizardPage
|
||||
* ConvertCtoCCStdMakeProjectWizardPage
|
||||
* 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.
|
||||
*
|
||||
|
@ -24,22 +23,22 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
*<p>
|
||||
* Example useage:
|
||||
* <pre>
|
||||
* mainPage = new ConvertCtoCCProjectWizardPage("CtoCCConvertProjectPage");
|
||||
* mainPage = new ConvertCtoCCStdMakeProjectWizardPage("CtoCCConvertProjectPage");
|
||||
* mainPage.setTitle("Project Conversion");
|
||||
* mainPage.setDescription("Convert a project's nature from C to C++.");
|
||||
* </pre>
|
||||
* </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_DESC = "CtoCCConversionWizard.description"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Constructor for ConvertCtoCCProjectWizardPage.
|
||||
* Constructor for ConvertCtoCCStdMakeProjectWizardPage.
|
||||
* @param pageName
|
||||
*/
|
||||
public ConvertCtoCCProjectWizardPage(String pageName) {
|
||||
public ConvertCtoCCStdMakeProjectWizardPage(String pageName) {
|
||||
super(pageName);
|
||||
}
|
||||
|
||||
|
@ -90,7 +89,7 @@ public class ConvertCtoCCProjectWizardPage extends ConvertProjectWizardPage {
|
|||
*/
|
||||
public void convertProject(IProject project, IProgressMonitor monitor, String projectID)
|
||||
throws CoreException {
|
||||
CoreUtility.addNatureToProject(project, CoreModel.CC_NATURE_ID, monitor);
|
||||
CCorePlugin.getDefault().mapCProjectOwner(project, projectID);
|
||||
|
||||
CCorePlugin.getDefault().convertProjectFromCtoCC(project, monitor, projectID);
|
||||
}
|
||||
}
|
|
@ -60,8 +60,8 @@ import org.eclipse.ui.PlatformUI;
|
|||
public abstract class ConvertProjectWizardPage
|
||||
extends WizardPage {
|
||||
|
||||
public static final String KEY_TITLE = "ProjectConvertionWizard.title";
|
||||
public static final String KEY_CONVERTING = "ProjectConvertionWizard.converting";
|
||||
public static final String KEY_TITLE = "ConvertionWizard.title";
|
||||
public static final String KEY_CONVERTING = "ConvertionWizard.converting";
|
||||
private static final String PROJECT_LIST = "ConversionWizard.projectlist";
|
||||
|
||||
// The Main widget containing the table and its list of condidate open projects
|
||||
|
|
|
@ -8,14 +8,13 @@ package org.eclipse.cdt.ui.wizards.conversion;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
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.runtime.CoreException;
|
||||
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.
|
||||
* 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>
|
||||
* Example useage:
|
||||
* <pre>
|
||||
* mainPage = new ConvertUKtoCCProjectWizardPage("UKtoCCConvertProjectPage");
|
||||
* mainPage = new ConvertSimpleToCCStdMakeProjectWizardPage("UKtoCCConvertProjectPage");
|
||||
* mainPage.setTitle("Project Conversion");
|
||||
* mainPage.setDescription("Add C++ a Nature to a project.");
|
||||
* </pre>
|
||||
* </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_DESC = "UKtoCCConversionWizard.description"; //$NON-NLS-1$
|
||||
private static final String WZ_TITLE = "SimpleToCCStdMakeConversionWizard.title"; //$NON-NLS-1$
|
||||
private static final String WZ_DESC = "SimpleToCCStdMakeConversionWizard.description"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Constructor for ConvertUKtoCCProjectWizardPage.
|
||||
* Constructor for ConvertSimpleToCCStdMakeProjectWizardPage.
|
||||
* @param pageName
|
||||
*/
|
||||
public ConvertUKtoCCProjectWizardPage(String pageName) {
|
||||
public ConvertSimpleToCCStdMakeProjectWizardPage(String pageName) {
|
||||
super(pageName);
|
||||
}
|
||||
|
||||
|
@ -67,20 +66,16 @@ public class ConvertUKtoCCProjectWizardPage extends ConvertProjectWizardPage {
|
|||
* @return boolean
|
||||
*/
|
||||
protected boolean isCandidate(IProject project) {
|
||||
boolean noCNature = false;
|
||||
boolean noCNature = super.isCandidate(project);
|
||||
boolean noCCNature = false;
|
||||
|
||||
// hasNature() throws a CoreException if the
|
||||
// project is not open and/or is not visible to this view
|
||||
// which is what happens when a project does not have a
|
||||
// C nature
|
||||
|
||||
try {
|
||||
project.hasNature(CoreModel.C_NATURE_ID);
|
||||
} catch (CoreException e) {
|
||||
noCNature = true;
|
||||
}
|
||||
try {
|
||||
project.hasNature(CoreModel.CC_NATURE_ID);
|
||||
noCCNature = !project.hasNature(CoreModel.CC_NATURE_ID);
|
||||
} catch (CoreException e) {
|
||||
noCCNature = true;
|
||||
}
|
||||
|
@ -88,8 +83,8 @@ public class ConvertUKtoCCProjectWizardPage extends ConvertProjectWizardPage {
|
|||
}
|
||||
|
||||
/**
|
||||
* Method convertProject adds a C++ Nature to those projects
|
||||
* that were selected by the user.
|
||||
* Method convertProject adds a C++ Nature and default make builder
|
||||
* to those projects that were selected by the user.
|
||||
*
|
||||
* @param project
|
||||
* @param monitor
|
||||
|
@ -101,8 +96,6 @@ public class ConvertUKtoCCProjectWizardPage extends ConvertProjectWizardPage {
|
|||
if (!project.isOpen()){
|
||||
project.open(monitor);
|
||||
}
|
||||
CoreUtility.addNatureToProject(project, CoreModel.C_NATURE_ID, monitor);
|
||||
CoreUtility.addNatureToProject(project, CoreModel.CC_NATURE_ID, monitor);
|
||||
CCorePlugin.getDefault().mapCProjectOwner(project, projectID);
|
||||
CCorePlugin.getDefault().convertProjectToCC(project, monitor, projectID);
|
||||
}
|
||||
}
|
|
@ -8,14 +8,13 @@ package org.eclipse.cdt.ui.wizards.conversion;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
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.runtime.CoreException;
|
||||
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.
|
||||
* 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>
|
||||
* Example useage:
|
||||
* <pre>
|
||||
* mainPage = new ConvertUKtoCProjectWizardPage("UKtoCConvertProjectPage");
|
||||
* mainPage = new ConvertSimpleToCStdMakeProjectWizardPage("UKtoCConvertProjectPage");
|
||||
* mainPage.setTitle("Project Conversion");
|
||||
* mainPage.setDescription("Add C a Nature to a project.");
|
||||
* </pre>
|
||||
* </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_DESC = "UKtoCConversionWizard.description"; //$NON-NLS-1$
|
||||
private static final String WZ_TITLE = "SimpleToCStdMakeConversionWizard.title"; //$NON-NLS-1$
|
||||
private static final String WZ_DESC = "SimpleToCStdMakeConversionWizard.description"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Constructor for ConvertUKtoCProjectWizardPage.
|
||||
* Constructor for ConvertSimpleToCStdMakeProjectWizardPage.
|
||||
* @param pageName
|
||||
*/
|
||||
public ConvertUKtoCProjectWizardPage(String pageName) {
|
||||
public ConvertSimpleToCStdMakeProjectWizardPage(String pageName) {
|
||||
super(pageName);
|
||||
}
|
||||
|
||||
|
@ -61,7 +60,7 @@ public class ConvertUKtoCProjectWizardPage extends ConvertProjectWizardPage {
|
|||
|
||||
/**
|
||||
* Method isCandidate returns projects that have
|
||||
* no "C" Nature
|
||||
* no "C" Nature, but are Projects in the Eclipse sense.
|
||||
*
|
||||
* @param project
|
||||
* @return boolean
|
||||
|
@ -74,7 +73,7 @@ public class ConvertUKtoCProjectWizardPage extends ConvertProjectWizardPage {
|
|||
// which is what happens when a project does not have a
|
||||
// C nature
|
||||
try {
|
||||
project.hasNature(CoreModel.C_NATURE_ID);
|
||||
noCNature = !project.hasNature(CoreModel.C_NATURE_ID);
|
||||
} catch (CoreException e) {
|
||||
noCNature = true;
|
||||
}
|
||||
|
@ -82,8 +81,8 @@ public class ConvertUKtoCProjectWizardPage extends ConvertProjectWizardPage {
|
|||
}
|
||||
|
||||
/**
|
||||
* Method convertProject adds a C Nature to those projects
|
||||
* that were selected by the user.
|
||||
* Method convertProject adds a C Nature and default make builder
|
||||
* to those projects that were selected by the user.
|
||||
*
|
||||
* @param project
|
||||
* @param monitor
|
||||
|
@ -92,10 +91,10 @@ public class ConvertUKtoCProjectWizardPage extends ConvertProjectWizardPage {
|
|||
*/
|
||||
public void convertProject(IProject project, IProgressMonitor monitor, String projectID)
|
||||
throws CoreException {
|
||||
|
||||
CCorePlugin.getDefault().convertProjectToC(project, monitor, projectID);
|
||||
if (!project.isOpen()){
|
||||
project.open(monitor);
|
||||
}
|
||||
CoreUtility.addNatureToProject(project, CoreModel.C_NATURE_ID, monitor);
|
||||
CCorePlugin.getDefault().mapCProjectOwner(project, projectID);
|
||||
}
|
||||
}
|
|
@ -81,11 +81,8 @@ public class CtoCCConversionWizard extends ConversionWizard {
|
|||
* @see Wizard#createPages
|
||||
*/
|
||||
public void addPages() {
|
||||
mainPage = new ConvertCtoCCProjectWizardPage(getPrefix());
|
||||
mainPage = new ConvertCtoCCStdMakeProjectWizardPage(getPrefix());
|
||||
|
||||
addPage(mainPage);
|
||||
|
||||
// ensure proper window name by overwriting the title set by the super class
|
||||
this.setWindowTitle(getWindowTitleResource());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,27 +11,27 @@ import org.eclipse.cdt.internal.ui.CPlugin;
|
|||
* 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.
|
||||
*/
|
||||
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_DESC = "UKtoCCConversionWizard.description"; //$NON-NLS-1$
|
||||
private static final String PREFIX= "UKtoCCConversionWizard"; //$NON-NLS-1$
|
||||
private static final String WZ_TITLE = "SimpleToCCStdMakeConversionWizard.title"; //$NON-NLS-1$
|
||||
private static final String WZ_DESC = "SimpleToCCStdMakeConversionWizard.description"; //$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());
|
||||
}
|
||||
/**
|
||||
* UKtoCCConversionWizard Wizard constructor
|
||||
* SimpleToCCStdMakeConversionWizard Wizard constructor
|
||||
*
|
||||
* @param title
|
||||
* @param desc
|
||||
*/
|
||||
public UKtoCCConversionWizard(String title, String desc) {
|
||||
public SimpleToCCStdMakeConversionWizard(String title, String desc) {
|
||||
super(title, desc);
|
||||
}
|
||||
|
||||
|
@ -81,11 +81,8 @@ public class UKtoCCConversionWizard extends ConversionWizard {
|
|||
* @see Wizard#createPages
|
||||
*/
|
||||
public void addPages() {
|
||||
mainPage = new ConvertUKtoCCProjectWizardPage(getPrefix());
|
||||
mainPage = new ConvertSimpleToCCStdMakeProjectWizardPage(getPrefix());
|
||||
|
||||
addPage(mainPage);
|
||||
|
||||
// ensure proper window name by overwriting the title set by the super class
|
||||
this.setWindowTitle(getWindowTitleResource());
|
||||
}
|
||||
}
|
|
@ -11,27 +11,27 @@ import org.eclipse.cdt.internal.ui.CPlugin;
|
|||
* 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.
|
||||
*/
|
||||
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_DESC = "UKtoCConversionWizard.description"; //$NON-NLS-1$
|
||||
private static final String PREFIX= "UKtoCConversionWizard"; //$NON-NLS-1$
|
||||
private static final String WZ_TITLE = "SimpleToCStdMakeConversionWizard.title"; //$NON-NLS-1$
|
||||
private static final String WZ_DESC = "SimpleToCStdMakeConversionWizard.description"; //$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());
|
||||
}
|
||||
/**
|
||||
* UKtoCConversionWizard Wizard constructor
|
||||
* SimpleToCStdMakeConversionWizard Wizard constructor
|
||||
*
|
||||
* @param title
|
||||
* @param desc
|
||||
*/
|
||||
public UKtoCConversionWizard(String title, String desc) {
|
||||
public SimpleToCStdMakeConversionWizard(String title, String desc) {
|
||||
super(title, desc);
|
||||
}
|
||||
|
||||
|
@ -81,11 +81,8 @@ public class UKtoCConversionWizard extends ConversionWizard {
|
|||
* @see Wizard#createPages
|
||||
*/
|
||||
public void addPages() {
|
||||
mainPage = new ConvertUKtoCProjectWizardPage(getPrefix());
|
||||
mainPage = new ConvertSimpleToCStdMakeProjectWizardPage(getPrefix());
|
||||
|
||||
addPage(mainPage);
|
||||
|
||||
// ensure proper window name by overwriting the title set by the super class
|
||||
this.setWindowTitle(getWindowTitleResource());
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue