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:
parent
433976a043
commit
6a5af0ed88
5 changed files with 77 additions and 27 deletions
|
@ -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
|
2003-09-18 David Inglis
|
||||||
Add workbench build/rebuild in context menu.
|
Add workbench build/rebuild in context menu.
|
||||||
|
|
||||||
|
|
|
@ -133,9 +133,9 @@ MngCCWizard.description=Create a new Managed Make C++ Project.
|
||||||
MngCCWizardSettings.title=Managed Make C++ Settings
|
MngCCWizardSettings.title=Managed Make C++ Settings
|
||||||
MngCCWizardSettings.description=Define the Managed Make C++ build 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.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.title=Error Creating Project
|
||||||
CProjectWizard.op_error.message=Project cannot be created
|
CProjectWizard.op_error.message=Project cannot be created
|
||||||
|
|
|
@ -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.warning.BaseClassNotExists=Warning: Base class does not exist in current project.
|
||||||
|
|
||||||
NewClassWizardPage.operations.getProjectClasses=Looking for classes in project
|
NewClassWizardPage.operations.getProjectClasses=Looking for classes in project
|
||||||
|
|
||||||
|
NewClassWizardPage.error.NotAvailableForNonCppProjects= The wizard is not available for non C++ projects.
|
||||||
# ------- BaseClassSelectionDialog -----
|
# ------- BaseClassSelectionDialog -----
|
||||||
|
|
||||||
BaseClassSelectionDialog.title=Classes in this project
|
BaseClassSelectionDialog.title=Classes in this project
|
||||||
|
|
|
@ -50,25 +50,27 @@ public class NewClassWizard extends BasicNewResourceWizard implements INewWizard
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException {
|
protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException {
|
||||||
fPage.createClass(monitor);
|
if(fPage.createClass(monitor)){
|
||||||
ITranslationUnit headerTU= fPage.getCreatedClassHeaderFile();
|
ITranslationUnit headerTU= fPage.getCreatedClassHeaderFile();
|
||||||
ITranslationUnit bodyTU= fPage.getCreatedClassBodyFile();
|
ITranslationUnit bodyTU= fPage.getCreatedClassBodyFile();
|
||||||
if (headerTU != null) {
|
if (headerTU != null) {
|
||||||
IResource resource= headerTU.getResource();
|
IResource resource= headerTU.getResource();
|
||||||
selectAndReveal(resource);
|
selectAndReveal(resource);
|
||||||
openResource((IFile) 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
|
* @see Wizard#performFinish
|
||||||
*/
|
*/
|
||||||
public boolean performFinish() {
|
public boolean performFinish() {
|
||||||
|
if(!fPage.selectionIsCpp())
|
||||||
|
return true;
|
||||||
IWorkspaceRunnable op= new IWorkspaceRunnable() {
|
IWorkspaceRunnable op= new IWorkspaceRunnable() {
|
||||||
public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
|
public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -55,6 +55,7 @@ import org.eclipse.cdt.ui.CodeGeneration;
|
||||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IResourceStatus;
|
import org.eclipse.core.resources.IResourceStatus;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
|
@ -126,6 +127,8 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
||||||
protected IStatus fClassNameStatus;
|
protected IStatus fClassNameStatus;
|
||||||
protected IStatus fBaseClassStatus;
|
protected IStatus fBaseClassStatus;
|
||||||
|
|
||||||
|
private boolean hasCppNature = false;
|
||||||
|
|
||||||
BasicSearchResultCollector resultCollector;
|
BasicSearchResultCollector resultCollector;
|
||||||
SearchEngine searchEngine;
|
SearchEngine searchEngine;
|
||||||
|
|
||||||
|
@ -133,7 +136,13 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
||||||
public NewClassWizardPage(IStructuredSelection selection) {
|
public NewClassWizardPage(IStructuredSelection selection) {
|
||||||
super(PAGE_NAME);
|
super(PAGE_NAME);
|
||||||
currentSelection = selection;
|
currentSelection = selection;
|
||||||
|
hasCppNature = isSelectionCPP(currentSelection);
|
||||||
|
if(hasCppNature){
|
||||||
|
initializePageControls();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initializePageControls(){
|
||||||
TypeFieldsAdapter adapter= new TypeFieldsAdapter();
|
TypeFieldsAdapter adapter= new TypeFieldsAdapter();
|
||||||
|
|
||||||
fClassNameDialogField= new StringDialogField();
|
fClassNameDialogField= new StringDialogField();
|
||||||
|
@ -175,13 +184,18 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
||||||
|
|
||||||
resultCollector = new BasicSearchResultCollector ();
|
resultCollector = new BasicSearchResultCollector ();
|
||||||
searchEngine = new SearchEngine();
|
searchEngine = new SearchEngine();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
fAccessButtons.setEnabled(false);
|
if(hasCppNature){
|
||||||
setPageComplete(false);
|
fAccessButtons.setEnabled(false);
|
||||||
eSelection = getSelectionCElement(currentSelection);
|
setPageComplete(false);
|
||||||
|
eSelection = getSelectionCElement(currentSelection);
|
||||||
|
}else {
|
||||||
|
StatusInfo status = new StatusInfo();
|
||||||
|
status.setError(NewWizardMessages.getString("NewClassWizardPage.error.NotAvailableForNonCppProjects")); //$NON-NLS-1$
|
||||||
|
updateStatus(status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------- Creating Controls --------------------
|
// ----------------- 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)
|
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
||||||
*/
|
*/
|
||||||
public void createControl(Composite parent) {
|
public void createControl(Composite parent) {
|
||||||
|
if(!hasCppNature)
|
||||||
|
{
|
||||||
|
setControl(new Composite(parent, SWT.NULL));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int nColumns= 5;
|
int nColumns= 5;
|
||||||
|
|
||||||
initializeDialogUnits(parent);
|
initializeDialogUnits(parent);
|
||||||
|
@ -358,6 +378,25 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------- Helper methods for creating controls -----
|
// --------------- 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) {
|
private ICElement getSelectionCElement(IStructuredSelection sel) {
|
||||||
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
||||||
List list= ((IStructuredSelection)sel).toList();
|
List list= ((IStructuredSelection)sel).toList();
|
||||||
|
@ -521,7 +560,7 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
||||||
}
|
}
|
||||||
// -------------- Create a new Class ----------------------
|
// -------------- Create a new Class ----------------------
|
||||||
|
|
||||||
public void createClass(IProgressMonitor monitor){
|
public boolean createClass(IProgressMonitor monitor){
|
||||||
if (monitor == null) {
|
if (monitor == null) {
|
||||||
monitor= new NullProgressMonitor();
|
monitor= new NullProgressMonitor();
|
||||||
}
|
}
|
||||||
|
@ -556,8 +595,10 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}catch(CModelException e){
|
}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$
|
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{
|
}finally{
|
||||||
monitor.done();
|
monitor.done();
|
||||||
}
|
}
|
||||||
|
@ -766,7 +807,9 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
||||||
BasicSearchMatch baseClass = (BasicSearchMatch)findInList(baseClassName, null, classElements);
|
BasicSearchMatch baseClass = (BasicSearchMatch)findInList(baseClassName, null, classElements);
|
||||||
|
|
||||||
// if(baseClass != null){
|
// if(baseClass != null){
|
||||||
// baseClassFileName = baseClass.getLocation().toString();
|
// IPath baseClassFileLocation = baseClass.getLocation();
|
||||||
|
// IPath newFilePath = getContainerFullPath(linkedResourceGroupForHeader);
|
||||||
|
// baseClassFileName = baseClassName + HEADER_EXT;
|
||||||
// } else {
|
// } else {
|
||||||
baseClassFileName = baseClassName + HEADER_EXT;
|
baseClassFileName = baseClassName + HEADER_EXT;
|
||||||
// }
|
// }
|
||||||
|
|
Loading…
Add table
Reference in a new issue