1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Patch for Hoda Amer

UI: 
      The menu item could not be hidden since the "New" menu belongs to the "C Perspective". 
The wizard was disabled for C Projects.
This commit is contained in:
John Camelon 2003-09-18 19:46:12 +00:00
parent 433976a043
commit 6a5af0ed88
5 changed files with 77 additions and 27 deletions

View file

@ -1,3 +1,6 @@
2003-09-18 Hoda Amer
Solution to bug#42611 : New Class Wizard should be hidden for C projects
2003-09-18 David Inglis
Add workbench build/rebuild in context menu.

View file

@ -133,9 +133,9 @@ MngCCWizard.description=Create a new Managed Make C++ Project.
MngCCWizardSettings.title=Managed Make C++ Settings
MngCCWizardSettings.description=Define the Managed Make C++ build settings.
NewClassWizard.title=New Class
NewClassWizard.title=New C++ Class
NewClassWizard.description=Create a new C++ Class.
NewClassWizard.page.title=Class
NewClassWizard.page.title=C++ Class
CProjectWizard.op_error.title=Error Creating Project
CProjectWizard.op_error.message=Project cannot be created

View file

@ -162,6 +162,8 @@ NewClassWizardPage.error.InvalidBaseClassName=Base class name is not valid.
NewClassWizardPage.warning.BaseClassNotExists=Warning: Base class does not exist in current project.
NewClassWizardPage.operations.getProjectClasses=Looking for classes in project
NewClassWizardPage.error.NotAvailableForNonCppProjects= The wizard is not available for non C++ projects.
# ------- BaseClassSelectionDialog -----
BaseClassSelectionDialog.title=Classes in this project

View file

@ -50,25 +50,27 @@ public class NewClassWizard extends BasicNewResourceWizard implements INewWizard
}
protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException {
fPage.createClass(monitor);
ITranslationUnit headerTU= fPage.getCreatedClassHeaderFile();
ITranslationUnit bodyTU= fPage.getCreatedClassBodyFile();
if (headerTU != null) {
IResource resource= headerTU.getResource();
selectAndReveal(resource);
openResource((IFile) resource);
if(fPage.createClass(monitor)){
ITranslationUnit headerTU= fPage.getCreatedClassHeaderFile();
ITranslationUnit bodyTU= fPage.getCreatedClassBodyFile();
if (headerTU != null) {
IResource resource= headerTU.getResource();
selectAndReveal(resource);
openResource((IFile) resource);
}
if (bodyTU != null) {
IResource resource= bodyTU.getResource();
selectAndReveal(resource);
openResource((IFile) resource);
}
}
if (bodyTU != null) {
IResource resource= bodyTU.getResource();
selectAndReveal(resource);
openResource((IFile) resource);
}
}
/**
* @see Wizard#performFinish
*/
public boolean performFinish() {
if(!fPage.selectionIsCpp())
return true;
IWorkspaceRunnable op= new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
try {

View file

@ -55,6 +55,7 @@ import org.eclipse.cdt.ui.CodeGeneration;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceStatus;
import org.eclipse.core.resources.IWorkspaceRoot;
@ -126,6 +127,8 @@ public class NewClassWizardPage extends WizardPage implements Listener {
protected IStatus fClassNameStatus;
protected IStatus fBaseClassStatus;
private boolean hasCppNature = false;
BasicSearchResultCollector resultCollector;
SearchEngine searchEngine;
@ -133,7 +136,13 @@ public class NewClassWizardPage extends WizardPage implements Listener {
public NewClassWizardPage(IStructuredSelection selection) {
super(PAGE_NAME);
currentSelection = selection;
hasCppNature = isSelectionCPP(currentSelection);
if(hasCppNature){
initializePageControls();
}
}
protected void initializePageControls(){
TypeFieldsAdapter adapter= new TypeFieldsAdapter();
fClassNameDialogField= new StringDialogField();
@ -175,13 +184,18 @@ public class NewClassWizardPage extends WizardPage implements Listener {
resultCollector = new BasicSearchResultCollector ();
searchEngine = new SearchEngine();
}
public void init() {
fAccessButtons.setEnabled(false);
setPageComplete(false);
eSelection = getSelectionCElement(currentSelection);
if(hasCppNature){
fAccessButtons.setEnabled(false);
setPageComplete(false);
eSelection = getSelectionCElement(currentSelection);
}else {
StatusInfo status = new StatusInfo();
status.setError(NewWizardMessages.getString("NewClassWizardPage.error.NotAvailableForNonCppProjects")); //$NON-NLS-1$
updateStatus(status);
}
}
// ----------------- Creating Controls --------------------
@ -189,6 +203,12 @@ public class NewClassWizardPage extends WizardPage implements Listener {
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
if(!hasCppNature)
{
setControl(new Composite(parent, SWT.NULL));
return;
}
int nColumns= 5;
initializeDialogUnits(parent);
@ -358,6 +378,25 @@ public class NewClassWizardPage extends WizardPage implements Listener {
}
// --------------- Helper methods for creating controls -----
public boolean selectionIsCpp(){
return hasCppNature;
}
private boolean isSelectionCPP(IStructuredSelection sel){
IProject project = null;
ICElement element = getSelectionCElement(sel);
if (element == null){
IResource resource = getSelectionResourceElement(sel);
project = resource.getProject();
}else {
project = element.getCProject().getProject();
}
if (project != null)
return CoreModel.getDefault().hasCCNature(project);
else
return false;
}
private ICElement getSelectionCElement(IStructuredSelection sel) {
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
List list= ((IStructuredSelection)sel).toList();
@ -521,7 +560,7 @@ public class NewClassWizardPage extends WizardPage implements Listener {
}
// -------------- Create a new Class ----------------------
public void createClass(IProgressMonitor monitor){
public boolean createClass(IProgressMonitor monitor){
if (monitor == null) {
monitor= new NullProgressMonitor();
}
@ -556,8 +595,10 @@ public class NewClassWizardPage extends WizardPage implements Listener {
}
}
return true;
}catch(CModelException e){
MessageDialog.openError(getContainer().getShell(), WorkbenchMessages.getString("WizardNewFileCreationPage.internalErrorTitle"), WorkbenchMessages.format("WizardNewFileCreationPage.internalErrorMessage", new Object[] {e.getMessage()})); //$NON-NLS-2$ //$NON-NLS-1$
return false;
}finally{
monitor.done();
}
@ -766,7 +807,9 @@ public class NewClassWizardPage extends WizardPage implements Listener {
BasicSearchMatch baseClass = (BasicSearchMatch)findInList(baseClassName, null, classElements);
// if(baseClass != null){
// baseClassFileName = baseClass.getLocation().toString();
// IPath baseClassFileLocation = baseClass.getLocation();
// IPath newFilePath = getContainerFullPath(linkedResourceGroupForHeader);
// baseClassFileName = baseClassName + HEADER_EXT;
// } else {
baseClassFileName = baseClassName + HEADER_EXT;
// }