1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 17:35:35 +02:00

2004-08-04 Alain Magloire

Fix ShowInCView class
	* src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
	* src/org/eclipse/cdt/ui/CElementGrouping.java
	* src/org/eclipse/cdt/ui/Includes/Grouping.java
	* src/org/eclipse/cdt/ui/actions/ShowInCViewAction.java
This commit is contained in:
Alain Magloire 2004-08-04 18:01:56 +00:00
parent 2e49ff5679
commit 53bb3add57
5 changed files with 35 additions and 4 deletions

View file

@ -1,3 +1,11 @@
2004-08-04 Alain Magloire
Fix ShowInCView class
* src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
* src/org/eclipse/cdt/ui/CElementGrouping.java
* src/org/eclipse/cdt/ui/Includes/Grouping.java
* src/org/eclipse/cdt/ui/actions/ShowInCViewAction.java
2004-08-04 Alain Magloire
Implementation of Grouping for includes.

View file

@ -18,6 +18,7 @@ import org.eclipse.cdt.core.model.ICContainer;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IInclude;
import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.core.model.ISourceRoot;
import org.eclipse.cdt.core.model.ITranslationUnit;
@ -32,6 +33,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.model.IWorkbenchAdapter;
/**
* A base content provider for C elements. It provides access to the
@ -244,7 +246,10 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
Object parent = null;
if (element instanceof ICElement) {
parent = ((ICElement)element).getParent();
} else if (element instanceof IWorkbenchAdapter) {
parent = ((IWorkbenchAdapter)element).getParent(element);
}
// if the parent is the default ISourceRoot == ICProject return the project
if (parent instanceof ISourceRoot) {
if (isProjectSourceRoot((ISourceRoot)parent)) {
@ -259,6 +264,11 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
}
}
}
// if we are doing grouping for the includes return the grouping container.
if (element instanceof IInclude && fIncludesGrouping) {
parent = new IncludesGrouping(((IInclude)element).getTranslationUnit());
}
return parent;
}

View file

@ -18,7 +18,7 @@ import org.eclipse.ui.model.WorkbenchAdapter;
/**
*/
public class CElementGrouping extends WorkbenchAdapter implements IAdaptable {
public abstract class CElementGrouping extends WorkbenchAdapter implements IAdaptable {
public final static int INCLUDES_GROUPING = 0x00001;
public final static int NAMESPACE_GROUPING = 0x00010;

View file

@ -45,4 +45,13 @@ public class IncludesGrouping extends CElementGrouping {
return tu;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
if (obj instanceof IncludesGrouping) {
return tu.equals(((IncludesGrouping)obj).getParent(obj)) ;
}
return super.equals(obj);
}
}

View file

@ -63,9 +63,6 @@ public class ShowInCViewAction extends SelectionProviderAction {
* @see IAction#actionPerformed
*/
public void run() {
if(page == null) {
return;
}
ISelection selection = getSelection();
if (selection instanceof ITextSelection) {
run(fEditor);
@ -76,6 +73,13 @@ public class ShowInCViewAction extends SelectionProviderAction {
}
public void run(IStructuredSelection selection) {
if (page == null) {
page = CUIPlugin.getActivePage();
if (page == null) {
return;
}
}
//Locate a source and a target for us to use
try {
IWorkbenchPart part = page.showView(CUIPlugin.CVIEW_ID);