1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-07 18:43:32 +02:00

Added Project Conversion Functionality, through wizards. Unkown to c?C++ and C to C++.

This commit is contained in:
Judy N. Green 2002-08-13 15:05:20 +00:00
parent 97c9e131f6
commit 9cd17db724
11 changed files with 1261 additions and 6 deletions

View file

@ -7,7 +7,7 @@ editorActionsName=Editor Actions
editorRulerActionsName=Editor Ruler Actions
completionContributorName=Completion Contribution
nature.name=C Nature
perspective.name=C
perspective.name=C/C++ Development - Eclipse Platform
viewsCategory.name=&C
BuildConsoleView.name=C-Build
CView.name=C/C++ Projects
@ -16,14 +16,30 @@ MakeView.name=Make Targets
# The Wizard
# C
newCWizardsCategory.name=C
StdCWizard.name =Standard Make C Project
StdCWizard.name=Standard Make C Project
StdCWizard.description=Create a C Project
# C++
newCCWizardsCategory.name=C++
StdCCWizard.name =Standard Make C++ Project
StdCCWizard.name=Standard Make C++ Project
StdCCWizard.description=Create a C++ Project
#Project Conversion
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 Unknown Project to C++
UKtoCCConversionWizard.name=Convert Unknown to a C++ Project
UKtoCCConversionWizard.description=Convert a Project's Nature from Unknown to C++
#Convert C to C++
CtoCCConversionWizard.name=Convert C to a C++ Project
CtoCCConversionWizard.description=Convert a Project's Nature from C to C++
NewFileWizard.name=File
NewFileCreationWizard.description=Create a file
OpenNewFileWizardAction.label=&File

View file

@ -148,8 +148,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,6 +168,19 @@
%StdCWizard.description
</description>
</wizard>
<!-- For C Conversion Wizards -->
<wizard
name="%UKtoCConversionWizard.name"
icon="icons/full/ctool16/newcc_app.gif"
category="org.eclipse.cdt.ui.newCWizards"
class="org.eclipse.cdt.ui.wizards.conversion.UKtoCConversionWizard"
project="true"
finalPerspective="org.eclipse.cdt.ui.CPerspective"
id="org.eclipse.cdt.ui.wizards.UKtoCConversionWizard">
<description>
%UKtoCConversionWizard.description
</description>
</wizard>
<!-- For C++ Wizards -->
<category
name="%newCCWizardsCategory.name"
@ -185,6 +198,30 @@
%StdCCWizard.description
</description>
</wizard>
<wizard
name="%CtoCCConversionWizard.name"
icon="icons/full/ctool16/newc_app.gif"
category="org.eclipse.cdt.ui.newCCWizards"
class="org.eclipse.cdt.ui.wizards.conversion.CtoCCConversionWizard"
project="true"
finalPerspective="org.eclipse.cdt.ui.CPerspective"
id="org.eclipse.cdt.ui.wizards.CtoCCConversionWizard">
<description>
%CtoCCConversionWizard.description
</description>
</wizard>
<wizard
name="%UKtoCCConversionWizard.name"
icon="icons/full/ctool16/newcc_app.gif"
category="org.eclipse.cdt.ui.newCCWizards"
class="org.eclipse.cdt.ui.wizards.conversion.UKtoCCConversionWizard"
project="true"
finalPerspective="org.eclipse.cdt.ui.CPerspective"
id="org.eclipse.cdt.ui.wizards.UKtoCCConversionWizard">
<description>
%UKtoCCConversionWizard.description
</description>
</wizard>
</extension>
<extension
id="org.eclipse.cdt.ui.ceditor"
@ -410,7 +447,7 @@
<extension
point="org.eclipse.cdt.core.CBuildConsole">
<CBuildConsole class="org.eclipse.cdt.internal.ui.CConsole">
</CBuildConsole>
</CBuildConsole>
</extension>
</plugin>

View file

@ -77,13 +77,35 @@ StdCWizardSettings.description=Define the Standard Make C build settings.
StdCCWizard.title=Standard Make C++ Project
StdCCWizard.description=Create a new Standard Make C++ Project.
StdCCWizardSettings.title=Standard Make C++ Settings
StdCCWizardSettings.description=Define the Standard Make C++ build settings
StdCCWizardSettings.description=Define the Standard Make C++ build settings.
CProjectWizard.op_description=C Project Wizard
CProjectWizard.windowTitle=New Project
CProjectWizard.description=C Project Wizard
CProjectWizard.title=C Project Wizard
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.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 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 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)
TabFolderPage=Tab Folder Page
TabFolderPage.title=Project
TabFolderPage.desc=Project Settings

View file

@ -0,0 +1,151 @@
package org.eclipse.cdt.ui.wizards.conversion;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.internal.ui.CPlugin;
import org.eclipse.cdt.ui.wizards.CProjectWizard;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.widgets.TabFolder;
/**
* ConversionWizard This wizard provides a method by which the user can
* change the nature of their projects. This class cannot be implemented. It
* is meant to be subclassed, with the subclasses providing the new labels,
* and pages.
*
* @author Judy N. Green
* @since Aug 8, 2002
* @see CtoCCConversionWizard#addPages
*/
public abstract class ConversionWizard
extends CProjectWizard {
// Titles and descriptions may be overwritten by subclasses through the accessor methods.
private static final String WZ_TITLE = "ConversionWizard.title"; //$NON-NLS-1$
private static final String WZ_DESC = "ConversionWizard.description"; //$NON-NLS-1$
private static final String PREFIX = "ConversionWizard"; //$NON-NLS-1$
// Window Title should be overwritten by subclasses
private static final String WINDOW_TITLE = "ConversionWizard.windowTitle"; //$NON-NLS-1$
// the wizards main page containing the list of projects that the user may select for conversion.
protected ConvertProjectWizardPage mainPage;
/**
* Conversion Wizard constructor
*/
public ConversionWizard() {
this(getWindowTitleResource(), getWzDescriptionResource());
}
/**
* Conversion Wizard constructor
*
* @param title
* @param desc
*/
public ConversionWizard(String title, String desc) {
super(title, desc);
}
/**
* Method getWindowTitleResource, allows Wizard Title label value to be
* changed by subclasses
*
* @return String
*/
protected static String getWindowTitleResource() {
return CPlugin.getResourceString(WINDOW_TITLE);
}
/**
* Method getWzDescriptionResource, allows Wizard description label value
* to be changed by subclasses
*
* @return String
*/
protected static String getWzDescriptionResource() {
return CPlugin.getResourceString(WZ_DESC);
}
/**
* Method getWzTitleResource, allows Wizard description label value
* to be changed by subclasses
*
* @return String
*/
protected static String getWzTitleResource() {
return CPlugin.getResourceString(WZ_TITLE);
}
/**
* Method getPrefix, allows prefix value to be changed by subclasses
*
* @return String
*/
protected static String getPrefix() {
return PREFIX;
}
/**
* Method addTabItems, allows subclasses to add additional pages
*
* @see org.eclipse.cdt.ui.wizards.CProjectWizard#addTabItems(TabFolder)
*/
public void addTabItems(TabFolder folder) {
// we have no tabs, but must implement this abstract method
}
/**
* Method doRun calls the doRunPrologue and mainPage's doRun method and the
* doRunEpliogue. Subclasses may overwrite to add further actions
*
* @see org.eclipse.cdt.ui.wizards.CProjectWizard#doRun(IProgressMonitor)
*/
protected void doRun(IProgressMonitor monitor) {
doRunPrologue(monitor);
mainPage.doRun(monitor, getProjectID());
doRunEpilogue(monitor);
monitor.done();
}
/**
* Return the type of project that it is being converted to
* The default if a make project
*/
public String getProjectID() {
return CCorePlugin.getDefault().PLUGIN_ID + ".make";//$NON-NLS-1$
}
/**
* Method addPages allows subclasses to add as many pages as they need. Overwrite
* to create a conversion specific page.
*
* @see Wizard#createPages
*/
public abstract void addPages();
/**
* Required by superclass but with no implementation here
*
* @param monitor
*/
protected void doRunPrologue(IProgressMonitor monitor) {}
/**
* Required by superclass but with no implementation here
*
* @param monitor
*/
protected void doRunEpilogue(IProgressMonitor monitor) {}
}

View file

@ -0,0 +1,96 @@
package org.eclipse.cdt.ui.wizards.conversion;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
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
* 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.
*
* @author Judy N. Green
* @since Aug 6, 2002
*<p>
* Example useage:
* <pre>
* mainPage = new ConvertCtoCCProjectWizardPage("CtoCCConvertProjectPage");
* mainPage.setTitle("Project Conversion");
* mainPage.setDescription("Convert a project's nature from C to C++.");
* </pre>
* </p>
*/
public class ConvertCtoCCProjectWizardPage 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.
* @param pageName
*/
public ConvertCtoCCProjectWizardPage(String pageName) {
super(pageName);
}
/**
* Method getWzTitleResource returns the correct Title Label for this class
* overriding the default in the superclass.
*/
protected String getWzTitleResource(){
return CPlugin.getResourceString(WZ_TITLE);
}
/**
* Method getWzDescriptionResource returns the correct description
* Label for this class overriding the default in the superclass.
*/
protected String getWzDescriptionResource(){
return CPlugin.getResourceString(WZ_DESC);
}
/**
* Method isCandidate returns projects that have
* a "C" Nature but do not have a "C++" Nature
*
* @param project
* @return boolean
*/
protected boolean isCandidate(IProject project) {
if (project.isOpen()) {
try {
if (project.hasNature(CoreModel.C_NATURE_ID)
&& !project.hasNature(CoreModel.CC_NATURE_ID))
return true;
} catch (CoreException e) {
CPlugin.log(e);
}
}
return false;
}
/**
* Method convertProject adds a C++ Nature to those projects
* that were selected by the user.
*
* @param project
* @param monitor
* @param projectID
* @throws CoreException
*/
public void convertProject(IProject project, IProgressMonitor monitor, String projectID)
throws CoreException {
CoreUtility.addNatureToProject(project, CoreModel.CC_NATURE_ID, monitor);
CCorePlugin.getDefault().mapCProjectOwner(project, projectID);
}
}

View file

@ -0,0 +1,451 @@
package org.eclipse.cdt.ui.wizards.conversion;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import java.util.Vector;
import org.eclipse.cdt.internal.ui.CPlugin;
import org.eclipse.cdt.internal.ui.util.SWTUtil;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
/**
* <p>
* ConvertProjectWizardPage Standard main page for a wizard that converts a
* project's nature.<br> This class provides the UI components and populates
* the table with all projects that meet the criteria specified by
* subclasses in the method isCandidate(IProject). This class does the
* conversion through the method convertProjects([]Object), which is also
* defined by all subclasses.<br> Subclasses provide the methods that
* determine what files are displayed and what action is performed on them as
* well as the labels for the Wizard.
* </p>
*
* @author Judy N. Green
* @since Aug 6, 2002 <p>
*/
public abstract class ConvertProjectWizardPage
extends WizardPage {
public static final String KEY_TITLE = "ProjectConvertionWizard.title";
public static final String KEY_CONVERTING = "ProjectConvertionWizard.converting";
private static final String PROJECT_LIST = "ConversionWizard.projectlist";
// The Main widget containing the table and its list of condidate open projects
protected CheckboxTableViewer tableViewer;
protected Button selectAllButton;
protected Button deselectAllButton;
// We only need to calculate this once per instantiation of this wizard
private Object[] listItems = null;
/**
* Constructor for ConvertProjectWizardPage.
*
* @param pageName
*/
public ConvertProjectWizardPage(String pageName) {
super(pageName);
setTitle(getWzTitleResource());
setDescription(getWzDescriptionResource());
}
// get methods to allow values to be changed by subclasses
protected abstract String getWzTitleResource();
protected abstract String getWzDescriptionResource();
/**
* Returns the elements that the user has checked
*
* @return Object[]
*/
protected Object[] getCheckedElements() {
return tableViewer.getCheckedElements();
}
/**
* Creates the main wizard page.
*
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite)
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
container.setLayout(layout);
setControl(createAvailableProjectsGroup(container));
addToMainPage(container);
// will default to false until a selection is made
setPageComplete(validatePage());
}
/**
* Method addToMainPage allows subclasses to add
* elements to the main page.
*
*/
protected void addToMainPage(Composite container){
// by default do nothing
}
/**
* Creates a list of projects that can be selected by the user.
*
* @param parent the parent composite
* @return Composite
*/
private final Composite createAvailableProjectsGroup(Composite parent) {
// Add a label
Label label = new Label(parent, SWT.LEFT);
label.setText(CPlugin.getResourceString(PROJECT_LIST));
Composite container = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 5;
layout.marginWidth = 5;
layout.numColumns = 2;
container.setLayout(layout);
GridData data = new GridData(GridData.FILL_BOTH);
container.setLayoutData(data);
// create the table
Table table = new Table(container,
SWT.CHECK | SWT.BORDER | SWT.MULTI |
SWT.SINGLE | SWT.H_SCROLL |
SWT.V_SCROLL);
data = new GridData(GridData.FILL_BOTH);
table.setLayoutData(data);
table.setHeaderVisible(true);
table.setLinesVisible(false);
TableLayout tableLayout = new TableLayout();
table.setHeaderVisible(false);
table.setLayout(tableLayout);
// add a table viewer
tableViewer = new CheckboxTableViewer(table);
tableViewer.setLabelProvider(new ProjectLabelProvider());
tableViewer.setContentProvider(new ProjectContentProvider());
// set initial input
tableViewer.setInput(getElements());
// define and assign sorter
tableViewer.setSorter(new ViewerSorter() {
public int compare(Viewer viewer, Object object1, Object object2) {
if ((object1 instanceof IProject) && (object2 instanceof IProject)) {
IProject left = (IProject)object1;
IProject right = (IProject)object2;
int result = left.getName().compareToIgnoreCase(right.getName());
if (result != 0) {
return result;
}
return left.getName().compareToIgnoreCase(right.getName());
}
return super.compare(viewer, object1, object2);
}
public boolean isSorterProperty(Object element, String property) {
return true;
}
});
tableViewer.setAllChecked(false);
tableViewer.refresh();
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent e) {
// will default to false until a selection is made
setPageComplete(validatePage());
updateSelectionButtons();
}
});
// Add button panel
Composite buttons= new Composite(container, SWT.NULL);
buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
layout= new GridLayout();
layout.marginHeight= 0;
layout.marginWidth= 0;
layout.verticalSpacing = 8;
buttons.setLayout(layout);
selectAllButton= new Button(buttons, SWT.PUSH);
selectAllButton.setLayoutData(getButtonGridData(selectAllButton));
selectAllButton.setText("Select All"); //$NON-NLS-1$
selectAllButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
ConvertProjectWizardPage.this.tableViewer.setAllChecked(true);
// update the pageComplete status
setPageComplete(true);
updateSelectionButtons();
}
});
deselectAllButton= new Button(buttons, SWT.PUSH);
deselectAllButton.setLayoutData(getButtonGridData(deselectAllButton));
deselectAllButton.setText("Deselect All"); //$NON-NLS-1$
deselectAllButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
ConvertProjectWizardPage.this.tableViewer.setAllChecked(false);
// update the pageComplete status
setPageComplete(false);
updateSelectionButtons();
}
});
// enable or disable selection buttons
Object[] elements = getElements();
boolean enableSelectionButtons = (elements != null) && (elements.length > 0);
selectAllButton.setEnabled(enableSelectionButtons);
// we've called setAllChecked(false) earlier
deselectAllButton.setEnabled(false);
return parent;
}
/*
* Method updateSelectionButtons, enables/disables buttons
* dependent on what is selected
*/
private void updateSelectionButtons() {
// update select and deselect buttons as required
Object[] checkedObjects = tableViewer.getCheckedElements();
int totalItems = tableViewer.getTable().getItemCount();
boolean allSelected = checkedObjects.length == totalItems;
boolean noneSelected = checkedObjects.length == 0;
selectAllButton.setEnabled(!allSelected);
deselectAllButton.setEnabled(!noneSelected);
}
/*
* Method getButtonGridData creates
* and returns a GridData for the given button
*
* @GridData
*/
private static GridData getButtonGridData(Button button) {
GridData data= new GridData(GridData.FILL_HORIZONTAL);
data.widthHint= SWTUtil.getButtonWidthHint(button);
data.heightHint= SWTUtil.getButtonHeigthHint(button);
return data;
}
/**
* Returns whether this page's controls currently all contain valid values.
*
* @return <code>true</code> if the user has selected at least one
* candidate project.
*/
protected boolean validatePage() {
Object[] selection = tableViewer.getCheckedElements();
return ((selection != null) && (selection.length > 0));
}
/**
* Provides the contents for the list using the enclosing class's method
* getElements();
*/
public class ProjectContentProvider
implements IStructuredContentProvider {
public Object[] getElements(Object parent) {
return listItems;
}
public void dispose() {}
public void inputChanged(Viewer viewer, Object oldInput,
Object newInput) {}
}
/**
* Provides labels for the listed items. In this case it returns each
* project's name
*/
public class ProjectLabelProvider
extends LabelProvider
implements ITableLabelProvider {
public String getColumnText(Object obj, int index) {
if (index == 0) {
return ((IProject)obj).getName();
}
return "";
}
public Image getColumnImage(Object obj, int index) {
return PlatformUI.getWorkbench().getSharedImages().getImage(
ISharedImages.IMG_OBJ_PROJECT);
}
}
/**
* Returns a list of open projects that are determined to be candidates
* through the method isCandidate().
*
* @return Object[] which may be null
*/
protected Object[] getElements() {
IWorkspace workspace = CPlugin.getWorkspace();
IProject[] projects = workspace.getRoot().getProjects();
Vector candidates = new Vector(projects.length);
IProject next = null;
// ensure we only present valid candidates to the user
for (int i = 0; i < projects.length; i++) {
next = (IProject)projects[i];
if ((next != null) && isCandidate(next)) {
candidates.addElement(next);
}
next = null;
}
// convert to an array for return
Object[] candidateArray = null;
if (candidates.size() > 0) {
candidateArray = new Object[candidates.size()];
candidates.copyInto(candidateArray);
}
// update the global variable that will
// be returned by the ProjectContentProvider
listItems = candidateArray;
return candidateArray;
}
/**
* doRun can be overwritten in subclasses to change behaviour, but this is
* generally not required. It is called from the corresponding Conversion
* Wizard
*
* @param monitor
* @param projectID
*/
public void doRun(IProgressMonitor monitor, String projectID) {
Object[] selection = getCheckedElements();
int totalSelected = selection.length;
if ((selection != null) && (totalSelected > 0)) {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.beginTask(CPlugin.getResourceString(KEY_TITLE), 1);
try {
convertProjects(selection, monitor, projectID);
}
catch (CoreException ce) {
CPlugin.log(ce);
}
}
}
/**
* convertProjects calls the convertProject() method on each project
* passed to it.
*
* @param selected
* @param monitor
* @param projectID
* @throws CoreException
*/
private void convertProjects(Object[] selected, IProgressMonitor monitor, String projectID)
throws CoreException {
monitor.beginTask(CPlugin.getResourceString(KEY_CONVERTING),
selected.length);
for (int i = 0; i < selected.length; i++) {
IProject project = (IProject)selected[i];
convertProject(project, monitor, projectID);
monitor.worked(1);
}
}
/**
* Method finish we always finish successfully :)
*
* @return boolean
*/
public boolean finish() {
return true;
}
/**
* Must be overwritten in subclasses to change behaviour Determines which
* projects will be displayed in the list
*
* @param project
* @return boolean
*/
protected abstract boolean isCandidate(IProject project);
/**
* convertProject must be overwritten in subclasses to change behaviour
*
* @param project
* @param monitor
* @param projectID
* @throws CoreException
*/
protected abstract void convertProject(IProject project,
IProgressMonitor monitor, String projectID)
throws CoreException;
}

View file

@ -0,0 +1,108 @@
package org.eclipse.cdt.ui.wizards.conversion;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
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
* 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).
*
* @author Judy N. Green
* @since Aug 6, 2002
*<p>
* Example useage:
* <pre>
* mainPage = new ConvertUKtoCCProjectWizardPage("UKtoCCConvertProjectPage");
* mainPage.setTitle("Project Conversion");
* mainPage.setDescription("Add C++ a Nature to a project.");
* </pre>
* </p>
*/
public class ConvertUKtoCCProjectWizardPage extends ConvertProjectWizardPage {
private static final String WZ_TITLE = "UKtoCCConversionWizard.title"; //$NON-NLS-1$
private static final String WZ_DESC = "UKtoCCConversionWizard.description"; //$NON-NLS-1$
/**
* Constructor for ConvertUKtoCCProjectWizardPage.
* @param pageName
*/
public ConvertUKtoCCProjectWizardPage(String pageName) {
super(pageName);
}
/**
* Method getWzTitleResource returns the correct Title Label for this class
* overriding the default in the superclass.
*/
protected String getWzTitleResource(){
return CPlugin.getResourceString(WZ_TITLE);
}
/**
* Method getWzDescriptionResource returns the correct description
* Label for this class overriding the default in the superclass.
*/
protected String getWzDescriptionResource(){
return CPlugin.getResourceString(WZ_DESC);
}
/**
* Method isCandidate returns projects that have
* neither a "C" Nature nor a "C++" Nature
*
* @param project
* @return boolean
*/
protected boolean isCandidate(IProject project) {
boolean noCNature = false;
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);
} catch (CoreException e) {
noCCNature = true;
}
return (noCNature && noCCNature);
}
/**
* Method convertProject adds a C++ Nature to those projects
* that were selected by the user.
*
* @param project
* @param monitor
* @param projectID
* @throws CoreException
*/
public void convertProject(IProject project, IProgressMonitor monitor, String projectID)
throws CoreException {
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);
}
}

View file

@ -0,0 +1,101 @@
package org.eclipse.cdt.ui.wizards.conversion;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
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
* 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).
*
* @author Judy N. Green
* @since Aug 6, 2002
*<p>
* Example useage:
* <pre>
* mainPage = new ConvertUKtoCProjectWizardPage("UKtoCConvertProjectPage");
* mainPage.setTitle("Project Conversion");
* mainPage.setDescription("Add C a Nature to a project.");
* </pre>
* </p>
*/
public class ConvertUKtoCProjectWizardPage extends ConvertProjectWizardPage {
private static final String WZ_TITLE = "UKtoCConversionWizard.title"; //$NON-NLS-1$
private static final String WZ_DESC = "UKtoCConversionWizard.description"; //$NON-NLS-1$
/**
* Constructor for ConvertUKtoCProjectWizardPage.
* @param pageName
*/
public ConvertUKtoCProjectWizardPage(String pageName) {
super(pageName);
}
/**
* Method getWzTitleResource returns the correct Title Label for this class
* overriding the default in the superclass.
*/
protected String getWzTitleResource(){
return CPlugin.getResourceString(WZ_TITLE);
}
/**
* Method getWzDescriptionResource returns the correct description
* Label for this class overriding the default in the superclass.
*/
protected String getWzDescriptionResource(){
return CPlugin.getResourceString(WZ_DESC);
}
/**
* Method isCandidate returns projects that have
* no "C" Nature
*
* @param project
* @return boolean
*/
protected boolean isCandidate(IProject project) {
boolean noCNature = 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;
}
return (noCNature);
}
/**
* Method convertProject adds a C Nature to those projects
* that were selected by the user.
*
* @param project
* @param monitor
* @param projectID
* @throws CoreException
*/
public void convertProject(IProject project, IProgressMonitor monitor, String projectID)
throws CoreException {
if (!project.isOpen()){
project.open(monitor);
}
CoreUtility.addNatureToProject(project, CoreModel.C_NATURE_ID, monitor);
CCorePlugin.getDefault().mapCProjectOwner(project, projectID);
}
}

View file

@ -0,0 +1,91 @@
package org.eclipse.cdt.ui.wizards.conversion;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.cdt.internal.ui.CPlugin;
/**
* This wizard provides a method by which the user can
* change the nature of their projects.
*/
public class CtoCCConversionWizard extends ConversionWizard {
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 PREFIX= "CtoCCConversionWizard"; //$NON-NLS-1$
private static final String WINDOW_TITLE = "CtoCCConversionWizard.windowTitle";//$NON-NLS-1$
/**
* CtoCCConversion Wizard constructor
*/
public CtoCCConversionWizard() {
this(getWindowTitleResource(), getWzDescriptionResource());
}
/**
* CtoCCConversion Wizard constructor
*
* @param title
* @param desc
*/
public CtoCCConversionWizard(String title, String desc) {
super(title, desc);
}
/**
* Method getWzDescriptionResource, allows Wizard description label value
* to be changed by subclasses
*
* @return String
*/
protected static String getWzDescriptionResource() {
return CPlugin.getResourceString(WZ_DESC);
}
/**
* Method getWzTitleResource, allows Wizard description label value
* to be changed by subclasses
*
* @return String
*/
protected static String getWzTitleResource() {
return CPlugin.getResourceString(WZ_TITLE);
}
/**
* Method getWindowTitleResource, allows Wizard Title label value to be
* changed by subclasses
*
* @return String
*/
protected static String getWindowTitleResource() {
return CPlugin.getResourceString(WINDOW_TITLE);
}
/**
* Method getPrefix, allows prefix value to be changed by subclasses
*
* @return String
*/
protected static String getPrefix() {
return PREFIX;
}
/**
* Method addPages adds our C to C++ conversion Wizard page.
*
* @see Wizard#createPages
*/
public void addPages() {
mainPage = new ConvertCtoCCProjectWizardPage(getPrefix());
addPage(mainPage);
// ensure proper window name by overwriting the title set by the super class
this.setWindowTitle(getWindowTitleResource());
}
}

View file

@ -0,0 +1,91 @@
package org.eclipse.cdt.ui.wizards.conversion;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
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 {
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 WINDOW_TITLE = "UKtoCCConversionWizard.windowTitle";//$NON-NLS-1$
/**
* UKtoCCConversionWizard Wizard constructor
*/
public UKtoCCConversionWizard() {
this(getWindowTitleResource(), getWzDescriptionResource());
}
/**
* UKtoCCConversionWizard Wizard constructor
*
* @param title
* @param desc
*/
public UKtoCCConversionWizard(String title, String desc) {
super(title, desc);
}
/**
* Method getWzDescriptionResource, allows Wizard description label value
* to be changed by subclasses
*
* @return String
*/
protected static String getWzDescriptionResource() {
return CPlugin.getResourceString(WZ_DESC);
}
/**
* Method getWzTitleResource, allows Wizard description label value
* to be changed by subclasses
*
* @return String
*/
protected static String getWzTitleResource() {
return CPlugin.getResourceString(WZ_TITLE);
}
/**
* Method getWindowTitleResource, allows Wizard Title label value to be
* changed by subclasses
*
* @return String
*/
protected static String getWindowTitleResource() {
return CPlugin.getResourceString(WINDOW_TITLE);
}
/**
* Method getPrefix, allows prefix value to be changed by subclasses
*
* @return String
*/
protected static String getPrefix() {
return PREFIX;
}
/**
* Method addPages adds our C++ conversion Wizard page.
*
* @see Wizard#createPages
*/
public void addPages() {
mainPage = new ConvertUKtoCCProjectWizardPage(getPrefix());
addPage(mainPage);
// ensure proper window name by overwriting the title set by the super class
this.setWindowTitle(getWindowTitleResource());
}
}

View file

@ -0,0 +1,91 @@
package org.eclipse.cdt.ui.wizards.conversion;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
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 {
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 WINDOW_TITLE = "UKtoCConversionWizard.windowTitle";//$NON-NLS-1$
/**
* UKtoCConversionWizard Wizard constructor
*/
public UKtoCConversionWizard() {
this(getWindowTitleResource(), getWzDescriptionResource());
}
/**
* UKtoCConversionWizard Wizard constructor
*
* @param title
* @param desc
*/
public UKtoCConversionWizard(String title, String desc) {
super(title, desc);
}
/**
* Method getWzDescriptionResource, allows Wizard description label value
* to be changed by subclasses
*
* @return String
*/
protected static String getWzDescriptionResource() {
return CPlugin.getResourceString(WZ_DESC);
}
/**
* Method getWzTitleResource, allows Wizard description label value
* to be changed by subclasses
*
* @return String
*/
protected static String getWzTitleResource() {
return CPlugin.getResourceString(WZ_TITLE);
}
/**
* Method getWindowTitleResource, allows Wizard Title label value to be
* changed by subclasses
*
* @return String
*/
protected static String getWindowTitleResource() {
return CPlugin.getResourceString(WINDOW_TITLE);
}
/**
* Method getPrefix, allows prefix value to be changed by subclasses
*
* @return String
*/
protected static String getPrefix() {
return PREFIX;
}
/**
* Method addPages adds our C to C++ conversion Wizard page.
*
* @see Wizard#createPages
*/
public void addPages() {
mainPage = new ConvertUKtoCProjectWizardPage(getPrefix());
addPage(mainPage);
// ensure proper window name by overwriting the title set by the super class
this.setWindowTitle(getWindowTitleResource());
}
}