mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Hoda Amer.
The user may start the wizard from the navigator view. In this case, the selection is a resource, not a CModel Element, which caused some troubles. This patch fixes this problem. Change log has been updated.
This commit is contained in:
parent
7a4da108d7
commit
18b219a690
3 changed files with 66 additions and 33 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2003-05-30 Hoda Amer
|
||||||
|
Added the new class wizard on May 27th
|
||||||
|
Fixed the inclusion problem on May 28th
|
||||||
|
Fixed the non-cmodel selection problem May 30th.
|
||||||
|
|
||||||
2003-04-27 Alain Magloire
|
2003-04-27 Alain Magloire
|
||||||
|
|
||||||
PR 36759, the outline does not update
|
PR 36759, the outline does not update
|
||||||
|
|
|
@ -160,6 +160,7 @@ NewClassWizardPage.warning.ClassNameDiscouraged=Class name is discouraged. {0}
|
||||||
NewClassWizardPage.error.InvalidBaseClassName=Base class name is not valid.
|
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
|
||||||
# ------- BaseClassSelectionDialog -----
|
# ------- BaseClassSelectionDialog -----
|
||||||
|
|
||||||
BaseClassSelectionDialog.title=Classes in this project
|
BaseClassSelectionDialog.title=Classes in this project
|
||||||
|
|
|
@ -349,10 +349,7 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
||||||
List list= ((IStructuredSelection)sel).toList();
|
List list= ((IStructuredSelection)sel).toList();
|
||||||
if (list.size() == 1) {
|
if (list.size() == 1) {
|
||||||
Object element= list.get(0);
|
Object element= list.get(0);
|
||||||
if ( (element instanceof ICElement)
|
if (element instanceof ICElement) {
|
||||||
//&& ((ICElement)element).getElementType() == ICElement.C_CCONTAINER)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return (ICElement)element;
|
return (ICElement)element;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -360,6 +357,24 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IResource getSelectionResourceElement(IStructuredSelection sel) {
|
||||||
|
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
||||||
|
List list= ((IStructuredSelection)sel).toList();
|
||||||
|
if (list.size() == 1) {
|
||||||
|
Object element= list.get(0);
|
||||||
|
if (element instanceof IResource) {
|
||||||
|
if(element instanceof IFile){
|
||||||
|
IFile file = (IFile)element;
|
||||||
|
return (IResource) file.getParent();
|
||||||
|
}else {
|
||||||
|
return (IResource)element;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private void getChildrenOfTypeClass(IParent parent, ArrayList elementsFound, IProgressMonitor monitor, int worked){
|
private void getChildrenOfTypeClass(IParent parent, ArrayList elementsFound, IProgressMonitor monitor, int worked){
|
||||||
ICElement[] elements = parent.getChildren();
|
ICElement[] elements = parent.getChildren();
|
||||||
monitor.worked( worked );
|
monitor.worked( worked );
|
||||||
|
@ -380,19 +395,24 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList findClassElementsInProject(){
|
private ArrayList findClassElementsInProject(){
|
||||||
if( elementsOfTypeClassInProject == null ){
|
if(eSelection == null){
|
||||||
|
return new ArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( elementsOfTypeClassInProject != null ){
|
||||||
|
return elementsOfTypeClassInProject;
|
||||||
|
}
|
||||||
|
|
||||||
elementsOfTypeClassInProject = new ArrayList();
|
elementsOfTypeClassInProject = new ArrayList();
|
||||||
IRunnableWithProgress runnable= new IRunnableWithProgress() {
|
IRunnableWithProgress runnable= new IRunnableWithProgress() {
|
||||||
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||||
if (monitor == null) {
|
if (monitor == null) {
|
||||||
monitor= new NullProgressMonitor();
|
monitor= new NullProgressMonitor();
|
||||||
}
|
}
|
||||||
monitor.beginTask("", 5); //$NON-NLS-1$
|
monitor.beginTask(NewWizardMessages.getString("NewClassWizardPage.operations.getProjectClasses"), 5); //$NON-NLS-1$
|
||||||
try{
|
try{
|
||||||
if(eSelection != null){
|
|
||||||
ICProject cProject = eSelection.getCProject();
|
ICProject cProject = eSelection.getCProject();
|
||||||
getChildrenOfTypeClass((IParent)cProject, elementsOfTypeClassInProject, monitor, 1);
|
getChildrenOfTypeClass((IParent)cProject, elementsOfTypeClassInProject, monitor, 1);
|
||||||
}
|
|
||||||
monitor.worked(5);
|
monitor.worked(5);
|
||||||
} finally{
|
} finally{
|
||||||
monitor.done();
|
monitor.done();
|
||||||
|
@ -407,7 +427,6 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return elementsOfTypeClassInProject;
|
return elementsOfTypeClassInProject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,6 +632,14 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
||||||
|
|
||||||
// -------------Helper methods for creating the class -------
|
// -------------Helper methods for creating the class -------
|
||||||
protected IPath getSelectionPath(){
|
protected IPath getSelectionPath(){
|
||||||
|
if(eSelection == null){
|
||||||
|
IResource resourceSelection = getSelectionResourceElement(currentSelection);
|
||||||
|
if(resourceSelection != null){
|
||||||
|
return resourceSelection.getLocation().makeAbsolute();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
// if it is a file, return the parent path
|
// if it is a file, return the parent path
|
||||||
if(eSelection instanceof ITranslationUnit)
|
if(eSelection instanceof ITranslationUnit)
|
||||||
return (eSelection.getParent().getPath());
|
return (eSelection.getParent().getPath());
|
||||||
|
|
Loading…
Add table
Reference in a new issue