diff --git a/core/org.eclipse.cdt.ui/browser/ChangeLog-browser b/core/org.eclipse.cdt.ui/browser/ChangeLog-browser new file mode 100644 index 00000000000..74426f2ef4f --- /dev/null +++ b/core/org.eclipse.cdt.ui/browser/ChangeLog-browser @@ -0,0 +1,6 @@ +2004-06-21 Chris Wiebe + + - fix for bug #66108 (C++ browser cannot show members of class) + - all types now visible in the types view (ie not just classes & structs) + - runnables now use IProgressService.busyCursorWhile (prevents progress + dialog from being displayed during short operations) diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java index 9af1782dc5d..b00270a1e95 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java @@ -57,8 +57,6 @@ import org.eclipse.jface.action.IStatusLineManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.util.Assert; @@ -102,6 +100,7 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.IShowInSource; import org.eclipse.ui.part.ShowInContext; import org.eclipse.ui.part.ViewPart; +import org.eclipse.ui.progress.IProgressService; import org.eclipse.ui.texteditor.ITextEditor; public abstract class CBrowsingPart extends ViewPart implements IMenuListener, ISelectionListener, IViewPartInputProvider { @@ -759,7 +758,7 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I for (int j = 0; j < enclosedTypes.length; ++j) { ITypeInfo enclosedType = enclosedTypes[j]; if (enclosedType.getResolvedReference() != null) { - ICElement typeElem = enclosedType.getResolvedReference().getCElement(); + ICElement typeElem = enclosedType.getCElement(); if (typeElem != null && (typeElem.equals(cElem) || (typeElem instanceof IParent && hasChild(typeElem, cElem)))) { return namespaces[i]; } @@ -820,10 +819,11 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I for (int j = 0; j < enclosedTypes.length; ++j) { ITypeInfo enclosedType = enclosedTypes[j]; if (enclosedType.getResolvedReference() != null) { - ICElement typeElem = enclosedType.getResolvedReference().getCElement(); - if (typeElem != null && typeElem.equals(cElem)) { + ICElement typeElem = enclosedType.getCElement(); + if (typeElem != null && (typeElem.equals(cElem) || (typeElem instanceof IParent && hasChild(typeElem, cElem)))) { return enclosedType; } + } } } @@ -1221,9 +1221,9 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I } }; - IRunnableContext runnableContext = new ProgressMonitorDialog(getShell()); + IProgressService service = PlatformUI.getWorkbench().getProgressService(); try { - runnableContext.run(true, true, runnable); + service.busyCursorWhile(runnable); } catch (InvocationTargetException e) { String title = OpenTypeMessages.getString("OpenTypeAction.exception.title"); //$NON-NLS-1$ String message = OpenTypeMessages.getString("OpenTypeAction.exception.message"); //$NON-NLS-1$ @@ -1250,13 +1250,13 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I } } - protected boolean openInEditor(ITypeReference location) { - ICElement cElement = location.getCElement(); + private boolean openInEditor(ITypeReference location) { + ITranslationUnit unit = location.getTranslationUnit(); IEditorPart editorPart = null; try { - if (cElement != null) - editorPart = EditorUtility.openInEditor(cElement); + if (unit != null) + editorPart = EditorUtility.openInEditor(unit); if (editorPart == null) { // open as external file IPath path = location.getLocation(); @@ -1265,8 +1265,13 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I editorPart = EditorUtility.openInEditor(storage); } } - if (editorPart == null) - return false; + + // highlight the type in the editor + if (editorPart != null && editorPart instanceof ITextEditor) { + ITextEditor editor = (ITextEditor) editorPart; + editor.selectAndReveal(location.getOffset(), location.getLength()); + return true; + } } catch (CModelException ex) { ex.printStackTrace(); return false; @@ -1275,16 +1280,6 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I return false; } - // highlight the type in the editor - if (cElement != null && editorPart instanceof CEditor) { - CEditor editor = (CEditor) editorPart; - editor.setSelection(cElement); - return true; - } else if (editorPart instanceof ITextEditor) { - ITextEditor editor = (ITextEditor) editorPart; - editor.selectAndReveal(location.getOffset(), location.getLength()); - return true; - } return false; } diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java index 7b7021b23db..559d53a1c19 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java @@ -116,7 +116,7 @@ public class MembersView extends CBrowsingPart implements IPropertyChangeListene protected boolean isValidInput(Object element) { if (element instanceof ITypeInfo) { ITypeInfo type= (ITypeInfo)element; - if (type.getCElementType() == ICElement.C_NAMESPACE && exists(type)) + if (type.getCElementType() != ICElement.C_NAMESPACE && exists(type)) return true; } return false; diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersViewContentProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersViewContentProvider.java index 0ff1f0bd766..0d8f4fa6c45 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersViewContentProvider.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersViewContentProvider.java @@ -24,12 +24,12 @@ import org.eclipse.cdt.internal.ui.util.ExceptionHandler; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.util.Assert; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.progress.IProgressService; class MembersViewContentProvider extends CBrowsingContentProvider { @@ -165,10 +165,10 @@ class MembersViewContentProvider extends CBrowsingContentProvider { } } }; - - IRunnableContext runnableContext = new ProgressMonitorDialog(getShell()); + + IProgressService service = PlatformUI.getWorkbench().getProgressService(); try { - runnableContext.run(true, true, runnable); + service.busyCursorWhile(runnable); } catch (InvocationTargetException e) { String title = OpenTypeMessages.getString("OpenTypeAction.exception.title"); //$NON-NLS-1$ String message = OpenTypeMessages.getString("OpenTypeAction.exception.message"); //$NON-NLS-1$ @@ -184,7 +184,7 @@ class MembersViewContentProvider extends CBrowsingContentProvider { ICElement elem = null; if (location != null) - elem = location.getCElement(); + elem = info.getCElement(); if (elem == null) { // could not resolve location diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesViewContentProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesViewContentProvider.java index 0204986db88..433234edab3 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesViewContentProvider.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesViewContentProvider.java @@ -24,12 +24,12 @@ import org.eclipse.cdt.internal.ui.browser.opentype.OpenTypeMessages; import org.eclipse.cdt.internal.ui.util.ExceptionHandler; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.util.Assert; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.progress.IProgressService; class NamespacesViewContentProvider extends CBrowsingContentProvider { @@ -165,9 +165,9 @@ class NamespacesViewContentProvider extends CBrowsingContentProvider { } }; - IRunnableContext runnableContext = new ProgressMonitorDialog(getShell()); + IProgressService service = PlatformUI.getWorkbench().getProgressService(); try { - runnableContext.run(true, true, runnable); + service.busyCursorWhile(runnable); } catch (InvocationTargetException e) { String title = OpenTypeMessages.getString("OpenTypeAction.exception.title"); //$NON-NLS-1$ String message = OpenTypeMessages.getString("OpenTypeAction.exception.message"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesViewContentProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesViewContentProvider.java index d2ccf625bf2..8e8c06a8ff1 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesViewContentProvider.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesViewContentProvider.java @@ -77,9 +77,10 @@ class TypesViewContentProvider extends CBrowsingContentProvider { if (element instanceof ITypeInfo) { ITypeInfo info = (ITypeInfo)element; - final int kinds[] = { ICElement.C_CLASS, ICElement.C_STRUCT }; -// ICElement.C_UNION, ICElement.C_ENUMERATION, -// ICElement.C_TYPEDEF}; + final int kinds[] = { ICElement.C_CLASS, ICElement.C_STRUCT, + ICElement.C_UNION, ICElement.C_ENUMERATION, + ICElement.C_TYPEDEF}; + //TODO this should be a prefs option return info.getEnclosedTypes(kinds); } diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.java index ae72e4d8d54..c077c93fff5 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.java @@ -17,7 +17,7 @@ import org.eclipse.cdt.core.browser.ITypeReference; import org.eclipse.cdt.core.browser.ITypeSearchScope; import org.eclipse.cdt.core.browser.TypeSearchScope; import org.eclipse.cdt.core.model.CModelException; -import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.resources.FileStorage; import org.eclipse.cdt.internal.ui.util.EditorUtility; import org.eclipse.cdt.internal.ui.util.ExceptionHandler; @@ -28,8 +28,6 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.widgets.Shell; @@ -37,6 +35,8 @@ import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.progress.IProgressService; import org.eclipse.ui.texteditor.ITextEditor; public class OpenTypeAction implements IWorkbenchWindowActionDelegate { @@ -62,9 +62,9 @@ public class OpenTypeAction implements IWorkbenchWindowActionDelegate { } }; - IRunnableContext runnableContext = new ProgressMonitorDialog(getShell()); + IProgressService service = PlatformUI.getWorkbench().getProgressService(); try { - runnableContext.run(true, true, runnable); + service.busyCursorWhile(runnable); } catch (InvocationTargetException e) { String title = OpenTypeMessages.getString("OpenTypeAction.exception.title"); //$NON-NLS-1$ String message = OpenTypeMessages.getString("OpenTypeAction.exception.message"); //$NON-NLS-1$ @@ -106,9 +106,9 @@ public class OpenTypeAction implements IWorkbenchWindowActionDelegate { } }; - IRunnableContext runnableContext = new ProgressMonitorDialog(getShell()); + IProgressService service = PlatformUI.getWorkbench().getProgressService(); try { - runnableContext.run(true, true, runnable); + service.busyCursorWhile(runnable); } catch (InvocationTargetException e) { String title = OpenTypeMessages.getString("OpenTypeAction.exception.title"); //$NON-NLS-1$ String message = OpenTypeMessages.getString("OpenTypeAction.exception.message"); //$NON-NLS-1$ @@ -146,12 +146,12 @@ public class OpenTypeAction implements IWorkbenchWindowActionDelegate { * @return true if succesfully displayed. */ private boolean openTypeInEditor(ITypeReference location) { - ICElement cElement = location.getCElement(); + ITranslationUnit unit = location.getTranslationUnit(); IEditorPart editorPart = null; try { - if (cElement != null) - editorPart = EditorUtility.openInEditor(cElement); + if (unit != null) + editorPart = EditorUtility.openInEditor(unit); if (editorPart == null) { // open as external file IPath path = location.getLocation();