1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 01:36:01 +02:00

- 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)
This commit is contained in:
Alain Magloire 2004-06-21 18:48:53 +00:00
parent b16d7061a2
commit a2e471d3f5
7 changed files with 49 additions and 47 deletions

View file

@ -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)

View file

@ -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;
}

View file

@ -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;

View file

@ -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

View file

@ -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$

View file

@ -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);
}

View file

@ -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();