Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/org.eclipse.cdt.ui/ChangeLog8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementGrouping.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IncludesGrouping.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ShowInCViewAction.java10
5 files changed, 35 insertions, 4 deletions
diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog
index ea6b5ee298a..762b49d5141 100644
--- a/core/org.eclipse.cdt.ui/ChangeLog
+++ b/core/org.eclipse.cdt.ui/ChangeLog
@@ -1,5 +1,13 @@
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.
* src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
* src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
index db2da879731..9ba55f9d7b1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
@@ -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;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementGrouping.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementGrouping.java
index d9596d0181a..6703e58964a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementGrouping.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementGrouping.java
@@ -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;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IncludesGrouping.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IncludesGrouping.java
index df89c41043b..c67e338a75e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IncludesGrouping.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IncludesGrouping.java
@@ -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);
+ }
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ShowInCViewAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ShowInCViewAction.java
index fd99d4fb895..a2ef5c3348d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ShowInCViewAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ShowInCViewAction.java
@@ -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);

Back to the top