mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 08:46:02 +02:00
Bug 382746 - Adding C/C++ nature for C Project impossible
This patch modifies the wizard so that the C projects also show in the list of projects. - If a given C project is selected and the C nature is selected, the project is not modified. - If a given C project is selected and the C++ nature is selected, the C++ nature is added and project type and toolchain selection have no effect because it is assumed that the project type and toolchain had already been setup before hand. - Old-style projects (CDT 3.0) are not converted anymore. Unchanged behavior: - C++ projects never show in the list of projects. Removing nature is (still) unsupported. - Non-CDT project behave as they use to. Change-Id: Ie6282c11d90c42d21ecad2996ab49ebd64c38ece Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
This commit is contained in:
parent
1c258538de
commit
c29c9bc057
3 changed files with 24 additions and 26 deletions
|
@ -1,5 +1,5 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Copyright (c) 2003, 2010 QNX Software Systems and others.
|
# Copyright (c) 2003, 2015 QNX Software Systems and others.
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are made available under the terms of the Eclipse Public License v1.0
|
# are made available under the terms of the Eclipse Public License v1.0
|
||||||
# which accompanies this distribution, and is available at
|
# which accompanies this distribution, and is available at
|
||||||
|
@ -46,7 +46,7 @@ MakeCCWizardSettings.title=C++/Make Project Settings
|
||||||
MakeCCWizardSettings.description=Define the project and 'make' builder settings
|
MakeCCWizardSettings.description=Define the project and 'make' builder settings
|
||||||
|
|
||||||
WizardMakeProjectConversion.title=Convert to a C/C++ project
|
WizardMakeProjectConversion.title=Convert to a C/C++ project
|
||||||
WizardMakeProjectConversion.description=The wizard adds C/C++ Nature to the selected projects to enable C/C++ Tools Support for them. It also converts old-style C/C++ projects to the new style.
|
WizardMakeProjectConversion.description=The wizard adds C/C++ Nature to the selected projects to enable C/C++ Tools Support for them.
|
||||||
WizardMakeProjectConversion.monitor.convertingToMakeProject=Converting to C/C++ Project...
|
WizardMakeProjectConversion.monitor.convertingToMakeProject=Converting to C/C++ Project...
|
||||||
WizardMakeProjectConversion.projectOptions.title=Project options
|
WizardMakeProjectConversion.projectOptions.title=Project options
|
||||||
WizardMakeProjectConversion.projectOptions.projectType=Specify project type
|
WizardMakeProjectConversion.projectOptions.projectType=Specify project type
|
||||||
|
|
|
@ -351,7 +351,7 @@
|
||||||
<adapt type="org.eclipse.core.resources.IProject" >
|
<adapt type="org.eclipse.core.resources.IProject" >
|
||||||
<test
|
<test
|
||||||
property="org.eclipse.core.resources.projectNature"
|
property="org.eclipse.core.resources.projectNature"
|
||||||
value="org.eclipse.cdt.core.cnature"/>
|
value="org.eclipse.cdt.core.ccnature"/>
|
||||||
</adapt>
|
</adapt>
|
||||||
</not>
|
</not>
|
||||||
</and>
|
</and>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2013 QNX Software Systems and others.
|
* Copyright (c) 2000, 2015 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Intel corporation - customization for New Project model.
|
* Intel corporation - customization for New Project model.
|
||||||
* Marc-Andre Laperle (Ericsson) - Bug 394492 Project options not visible
|
* Marc-Andre Laperle (Ericsson) - Bug 394492 Project options not visible
|
||||||
|
* Marc-Andre Laperle (Ericsson) - Bug 382746 Add C++ nature to C Project
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.managedbuilder.ui.wizards;
|
package org.eclipse.cdt.managedbuilder.ui.wizards;
|
||||||
|
|
||||||
|
@ -16,8 +17,8 @@ package org.eclipse.cdt.managedbuilder.ui.wizards;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCProjectNature;
|
||||||
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
|
||||||
import org.eclipse.cdt.ui.newui.AbstractPage;
|
import org.eclipse.cdt.ui.newui.AbstractPage;
|
||||||
import org.eclipse.cdt.ui.newui.CDTPrefUtil;
|
import org.eclipse.cdt.ui.newui.CDTPrefUtil;
|
||||||
import org.eclipse.cdt.ui.newui.PageLayout;
|
import org.eclipse.cdt.ui.newui.PageLayout;
|
||||||
|
@ -250,29 +251,29 @@ public class ConvertToMakeWizardPage extends ConvertProjectWizardPage {
|
||||||
/**
|
/**
|
||||||
* Method isCandidate returns true for:
|
* Method isCandidate returns true for:
|
||||||
* - non-CDT projects
|
* - non-CDT projects
|
||||||
* - old style Make CDT projects
|
* - C projects, to be potentially converted to C++
|
||||||
* So new model projects and
|
|
||||||
* old style managed projects
|
|
||||||
* are refused.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isCandidate(IProject project) {
|
public boolean isCandidate(IProject project) {
|
||||||
boolean a = !AbstractPage.isCDTPrj(project);
|
boolean isCDTProject = AbstractPage.isCDTPrj(project);
|
||||||
boolean b = ManagedBuilderCorePlugin.getDefault().isOldStyleMakeProject(project);
|
boolean cOnly = false;
|
||||||
return a || b;
|
try {
|
||||||
|
cOnly = !project.hasNature(CCProjectNature.CC_NATURE_ID);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
// If the project doesn't exist or is not open, it cannot be converted
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !isCDTProject || cOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void convertProject(IProject project, String bsId, IProgressMonitor monitor) throws CoreException{
|
public void convertProject(IProject project, String bsId, IProgressMonitor monitor) throws CoreException{
|
||||||
monitor.beginTask(MakeUIPlugin.getResourceString("WizardMakeProjectConversion.monitor.convertingToMakeProject"), 3); //$NON-NLS-1$
|
monitor.beginTask(MakeUIPlugin.getResourceString("WizardMakeProjectConversion.monitor.convertingToMakeProject"), 3); //$NON-NLS-1$
|
||||||
try {
|
try {
|
||||||
if (ManagedBuilderCorePlugin.getDefault().isOldStyleMakeProject(project)) {
|
boolean wasCDTProject = AbstractPage.isCDTPrj(project);
|
||||||
ManagedBuilderCorePlugin.getDefault().convertOldStdMakeToNewStyle(project, monitor);
|
super.convertProject(project, bsId, new SubProgressMonitor(monitor, 1));
|
||||||
} else {
|
if (!wasCDTProject && isSetProjectType()) {
|
||||||
super.convertProject(project, bsId, new SubProgressMonitor(monitor, 1));
|
h_selected.convertProject(project, monitor);
|
||||||
if (isSetProjectType()) {
|
|
||||||
h_selected.convertProject(project, monitor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
monitor.done();
|
monitor.done();
|
||||||
|
@ -283,13 +284,10 @@ public class ConvertToMakeWizardPage extends ConvertProjectWizardPage {
|
||||||
public void convertProject(IProject project, IProgressMonitor monitor, String projectID) throws CoreException {
|
public void convertProject(IProject project, IProgressMonitor monitor, String projectID) throws CoreException {
|
||||||
monitor.beginTask(MakeUIPlugin.getResourceString("WizardMakeProjectConversion.monitor.convertingToMakeProject"), 3); //$NON-NLS-1$
|
monitor.beginTask(MakeUIPlugin.getResourceString("WizardMakeProjectConversion.monitor.convertingToMakeProject"), 3); //$NON-NLS-1$
|
||||||
try {
|
try {
|
||||||
if (ManagedBuilderCorePlugin.getDefault().isOldStyleMakeProject(project)) {
|
boolean wasCDTProject = AbstractPage.isCDTPrj(project);
|
||||||
ManagedBuilderCorePlugin.getDefault().convertOldStdMakeToNewStyle(project, monitor);
|
super.convertProject(project, new SubProgressMonitor(monitor, 1), projectID);
|
||||||
} else {
|
if (!wasCDTProject && isSetProjectType()) {
|
||||||
super.convertProject(project, new SubProgressMonitor(monitor, 1), projectID);
|
h_selected.convertProject(project, monitor);
|
||||||
if (isSetProjectType()) {
|
|
||||||
h_selected.convertProject(project, monitor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
monitor.done();
|
monitor.done();
|
||||||
|
|
Loading…
Add table
Reference in a new issue