mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
2004-09-01 Chris Wiebe
Fix for 68883 * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingContentProvider.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTableViewer.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTreeViewer.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesView.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesView.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsView.java
This commit is contained in:
parent
acc7f9cd6a
commit
7aa7200573
9 changed files with 193 additions and 30 deletions
|
@ -1,3 +1,15 @@
|
|||
2004-09-01 Chris Wiebe
|
||||
|
||||
Fix for 68883
|
||||
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingContentProvider.java
|
||||
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java
|
||||
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTableViewer.java
|
||||
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTreeViewer.java
|
||||
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java
|
||||
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesView.java
|
||||
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesView.java
|
||||
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsView.java
|
||||
|
||||
2004-09-01 Chris Wiebe
|
||||
|
||||
replace deprecated SearchUI.SEARCH_RESULT_VIEW_ID w/ NewSearchUI.SEARCH_VIEW_ID
|
||||
|
|
|
@ -15,8 +15,6 @@ import java.util.Collection;
|
|||
import org.eclipse.cdt.core.browser.AllTypesCache;
|
||||
import org.eclipse.cdt.core.browser.ITypeCacheChangedListener;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.internal.ui.BaseCElementContentProvider;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
|
@ -62,8 +60,11 @@ public abstract class CBrowsingContentProvider extends BaseCElementContentProvid
|
|||
}
|
||||
|
||||
public void typeCacheChanged(IProject project) {
|
||||
ICProject cproject = CoreModel.getDefault().create(project);
|
||||
postRefresh(cproject);
|
||||
if (project.exists() && project.isOpen()) {
|
||||
postAdjustInputAndSetSelection(CoreModel.getDefault().create(project));
|
||||
} else {
|
||||
postAdjustInputAndSetSelection(CoreModel.getDefault().getCModel());
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -133,7 +134,22 @@ public abstract class CBrowsingContentProvider extends BaseCElementContentProvid
|
|||
}
|
||||
}
|
||||
*/
|
||||
private void postRefresh(final Object element) {
|
||||
|
||||
private void postAdjustInputAndSetSelection(final Object element) {
|
||||
postRunnable(new Runnable() {
|
||||
public void run() {
|
||||
Control ctrl= fViewer.getControl();
|
||||
if (ctrl != null && !ctrl.isDisposed()) {
|
||||
ctrl.setRedraw(false);
|
||||
|
||||
fBrowsingPart.adjustInputPreservingSelection(element);
|
||||
ctrl.setRedraw(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* private void postRefresh(final Object element) {
|
||||
//System.out.println("UI refresh:" + root);
|
||||
postRunnable(new Runnable() {
|
||||
public void run() {
|
||||
|
@ -154,7 +170,7 @@ public abstract class CBrowsingContentProvider extends BaseCElementContentProvid
|
|||
});
|
||||
}
|
||||
|
||||
/* private void postAdd(final Object parent, final Object element) {
|
||||
private void postAdd(final Object parent, final Object element) {
|
||||
//System.out.println("UI add:" + parent + " " + element);
|
||||
postRunnable(new Runnable() {
|
||||
public void run() {
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.eclipse.cdt.internal.ui.browser.opentype.OpenTypeMessages;
|
|||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
||||
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
||||
import org.eclipse.cdt.internal.ui.util.ProblemTableViewer;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
|
||||
import org.eclipse.cdt.internal.ui.workingsets.WorkingSetFilterActionGroup;
|
||||
|
@ -922,7 +921,7 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I
|
|||
* @param parent the parent for the viewer
|
||||
*/
|
||||
protected StructuredViewer createViewer(Composite parent) {
|
||||
return new ProblemTableViewer(parent, SWT.MULTI);
|
||||
return new ElementTableViewer(parent, SWT.MULTI);
|
||||
}
|
||||
|
||||
protected int getLabelProviderFlags() {
|
||||
|
@ -1161,12 +1160,34 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I
|
|||
// Default is to do nothing
|
||||
}
|
||||
|
||||
void adjustInputPreservingSelection(Object input) {
|
||||
Object elementToSelect = null;
|
||||
ISelection selection = getSelectionProvider().getSelection();
|
||||
Object oldSelObj = null;
|
||||
if (selection instanceof IStructuredSelection) {
|
||||
oldSelObj = getSingleElementFromSelection(selection);
|
||||
if (input != null) {
|
||||
elementToSelect = findChildInInput(input, oldSelObj);
|
||||
if (elementToSelect != null) {
|
||||
adjustInputAndSetSelection(elementToSelect);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
adjustInputAndSetSelection(input);
|
||||
}
|
||||
|
||||
private Object findChildInInput(Object input, Object oldSelObj) {
|
||||
//TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
void adjustInputAndSetSelection(Object o) {
|
||||
if (!(o instanceof ICElement) && !(o instanceof ITypeInfo)) {
|
||||
setSelection(StructuredSelection.EMPTY, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Object elementToSelect= getSuitableElement(findElementToSelect(o));
|
||||
Object newInput= findInputForElement(o);
|
||||
Object oldInput= null;
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Created on Sep 1, 2004
|
||||
*
|
||||
* TODO To change the template for this generated file go to
|
||||
* Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.util.ProblemTableViewer;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Table;
|
||||
|
||||
/**
|
||||
* @author CWiebe
|
||||
*
|
||||
* TODO To change the template for this generated type comment go to
|
||||
* Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class ElementTableViewer extends ProblemTableViewer {
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
*/
|
||||
public ElementTableViewer(Composite parent) {
|
||||
super(parent);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param style
|
||||
*/
|
||||
public ElementTableViewer(Composite parent, int style) {
|
||||
super(parent, style);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @param table
|
||||
*/
|
||||
public ElementTableViewer(Table table) {
|
||||
super(table);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
protected void handleInvalidSelection(ISelection invalidSelection,
|
||||
ISelection newSelection) {
|
||||
updateSelection(newSelection);
|
||||
SelectionChangedEvent event = new SelectionChangedEvent(this,
|
||||
newSelection);
|
||||
firePostSelectionChanged(event);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Created on Sep 1, 2004
|
||||
*
|
||||
* TODO To change the template for this generated file go to
|
||||
* Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
|
||||
/**
|
||||
* @author CWiebe
|
||||
*
|
||||
* TODO To change the template for this generated type comment go to
|
||||
* Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class ElementTreeViewer extends ProblemTreeViewer {
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
*/
|
||||
public ElementTreeViewer(Composite parent) {
|
||||
super(parent);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param style
|
||||
*/
|
||||
public ElementTreeViewer(Composite parent, int style) {
|
||||
super(parent, style);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tree
|
||||
*/
|
||||
public ElementTreeViewer(Tree tree) {
|
||||
super(tree);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
|
@ -17,8 +17,8 @@ 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.ISourceRoot;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||
|
@ -96,7 +96,7 @@ public class MembersView extends CBrowsingPart implements IPropertyChangeListene
|
|||
* @param parent the parent for the viewer
|
||||
*/
|
||||
protected StructuredViewer createViewer(Composite parent) {
|
||||
ProblemTreeViewer viewer= new ProblemTreeViewer(parent, SWT.MULTI);
|
||||
ElementTreeViewer viewer= new ElementTreeViewer(parent, SWT.MULTI);
|
||||
// fMemberFilterActionGroup= new MemberFilterActionGroup(viewer, JavaUI.ID_MEMBERS_VIEW);
|
||||
return viewer;
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ public class MembersView extends CBrowsingPart implements IPropertyChangeListene
|
|||
return element;
|
||||
}
|
||||
|
||||
if (element instanceof ICElement) {
|
||||
if (element instanceof ICElement && !(element instanceof ITranslationUnit)) {
|
||||
ICElement parent = TypeUtil.getDeclaringContainerType((ICElement)element);
|
||||
if (parent != null) {
|
||||
ITypeInfo info = AllTypesCache.getTypeForElement(parent, true, true, null);
|
||||
|
@ -240,7 +240,8 @@ public class MembersView extends CBrowsingPart implements IPropertyChangeListene
|
|||
* @see org.eclipse.cdt.internal.ui.browser.cbrowsing.CBrowsingPart#findElementToSelect(java.lang.Object)
|
||||
*/
|
||||
protected Object findElementToSelect(Object element) {
|
||||
if (element instanceof ICElement && TypeUtil.isDeclaredType((ICElement)element)) {
|
||||
if (element instanceof ICElement && !(element instanceof ITranslationUnit)
|
||||
&& TypeUtil.isDeclaredType((ICElement)element)) {
|
||||
ICElement parent = TypeUtil.getDeclaringContainerType((ICElement)element);
|
||||
if (parent != null) {
|
||||
return element;
|
||||
|
|
|
@ -18,9 +18,9 @@ import org.eclipse.cdt.core.model.ICProject;
|
|||
import org.eclipse.cdt.core.model.IEnumeration;
|
||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||
import org.eclipse.cdt.core.model.IStructure;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.ITypeDef;
|
||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||
import org.eclipse.cdt.internal.ui.util.ProblemTableViewer;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
|
||||
|
@ -79,8 +79,8 @@ public class NamespacesView extends CBrowsingPart {
|
|||
// return fWrappedViewer;
|
||||
return viewer;
|
||||
}
|
||||
private ProblemTableViewer createTableViewer(Composite parent) {
|
||||
return new ProblemTableViewer(parent, SWT.MULTI);
|
||||
private ElementTableViewer createTableViewer(Composite parent) {
|
||||
return new ElementTableViewer(parent, SWT.MULTI);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,17 +163,17 @@ public class NamespacesView extends CBrowsingPart {
|
|||
if (element instanceof ITypeInfo) {
|
||||
ITypeInfo info = (ITypeInfo)element;
|
||||
ISourceRoot root = findSourceRoot(info);
|
||||
if (exists(root))
|
||||
if (exists(root) && !isProjectSourceRoot(root))
|
||||
return root;
|
||||
ICProject cProject = findCProject(info);
|
||||
if (exists(cProject))
|
||||
return cProject;
|
||||
}
|
||||
|
||||
if (element instanceof ICElement) {
|
||||
if (element instanceof ICElement && !(element instanceof ITranslationUnit)) {
|
||||
ICElement cElem = (ICElement)element;
|
||||
ISourceRoot root = findSourceRoot(cElem);
|
||||
if (exists(root))
|
||||
if (exists(root) && !isProjectSourceRoot(root))
|
||||
return root;
|
||||
ICProject cProject = findCProject(cElem);
|
||||
if (exists(cProject))
|
||||
|
@ -191,7 +191,7 @@ public class NamespacesView extends CBrowsingPart {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (element instanceof ICElement) {
|
||||
if (element instanceof ICElement && !(element instanceof ITranslationUnit)) {
|
||||
ICElement parent = (ICElement)element;
|
||||
while (parent != null) {
|
||||
if ((parent instanceof IStructure
|
||||
|
|
|
@ -20,9 +20,9 @@ import org.eclipse.cdt.core.model.ICProject;
|
|||
import org.eclipse.cdt.core.model.IEnumeration;
|
||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||
import org.eclipse.cdt.core.model.IStructure;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.ITypeDef;
|
||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||
import org.eclipse.jface.viewers.DoubleClickEvent;
|
||||
|
@ -47,7 +47,7 @@ public class ProjectsView extends CBrowsingPart {
|
|||
* @param parent the parent for the viewer
|
||||
*/
|
||||
protected StructuredViewer createViewer(Composite parent) {
|
||||
ProblemTreeViewer result= new ProblemTreeViewer(parent, SWT.MULTI);
|
||||
ElementTreeViewer result= new ElementTreeViewer(parent, SWT.MULTI);
|
||||
// fFilterUpdater= new FilterUpdater(result);
|
||||
// ResourcesPlugin.getWorkspace().addResourceChangeListener(fFilterUpdater);
|
||||
return result;
|
||||
|
@ -204,10 +204,21 @@ public class ProjectsView extends CBrowsingPart {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (element instanceof ITypeInfo) {
|
||||
if (element instanceof ITranslationUnit) {
|
||||
ICElement e = (ICElement)element;
|
||||
ISourceRoot root = findSourceRoot(e);
|
||||
if (exists(root) && !isProjectSourceRoot(root))
|
||||
return root;
|
||||
ICProject cProject = findCProject(e);
|
||||
if (exists(cProject))
|
||||
return cProject;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (element instanceof ITypeInfo) {
|
||||
ITypeInfo info = (ITypeInfo)element;
|
||||
ISourceRoot root = findSourceRoot(info);
|
||||
if (exists(root))
|
||||
if (exists(root) && !isProjectSourceRoot(root))
|
||||
return root;
|
||||
ICProject cProject = findCProject(info);
|
||||
if (exists(cProject))
|
||||
|
@ -225,7 +236,7 @@ public class ProjectsView extends CBrowsingPart {
|
|||
ITypeInfo info = AllTypesCache.getTypeForElement(parent, true, true, null);
|
||||
if (info != null) {
|
||||
ISourceRoot root = findSourceRoot(info);
|
||||
if (exists(root))
|
||||
if (exists(root) && !isProjectSourceRoot(root))
|
||||
return root;
|
||||
ICProject cProject = findCProject(info);
|
||||
if (exists(cProject))
|
||||
|
|
|
@ -19,9 +19,9 @@ import org.eclipse.cdt.core.model.ICProject;
|
|||
import org.eclipse.cdt.core.model.IEnumeration;
|
||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||
import org.eclipse.cdt.core.model.IStructure;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.ITypeDef;
|
||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||
import org.eclipse.cdt.internal.ui.util.ProblemTableViewer;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
|
||||
|
@ -80,8 +80,8 @@ public class TypesView extends CBrowsingPart {
|
|||
// return fWrappedViewer;
|
||||
return viewer;
|
||||
}
|
||||
private ProblemTableViewer createTableViewer(Composite parent) {
|
||||
return new ProblemTableViewer(parent, SWT.MULTI);
|
||||
private ElementTableViewer createTableViewer(Composite parent) {
|
||||
return new ElementTableViewer(parent, SWT.MULTI);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -166,7 +166,7 @@ public class TypesView extends CBrowsingPart {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (element instanceof ICElement) {
|
||||
if (element instanceof ICElement && !(element instanceof ITranslationUnit)) {
|
||||
ICElement parent = TypeUtil.getDeclaringContainerType((ICElement)element);
|
||||
if (parent != null) {
|
||||
ITypeInfo info = AllTypesCache.getTypeForElement(parent, true, true, null);
|
||||
|
@ -197,7 +197,7 @@ public class TypesView extends CBrowsingPart {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (element instanceof ICElement) {
|
||||
if (element instanceof ICElement && !(element instanceof ITranslationUnit)) {
|
||||
ICElement parent = (ICElement)element;
|
||||
while (parent != null) {
|
||||
if ((parent instanceof IStructure
|
||||
|
|
Loading…
Add table
Reference in a new issue