mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-22 00:15:25 +02:00
2004-11-08 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
This commit is contained in:
parent
486c5d2c70
commit
17b5f315da
3 changed files with 350 additions and 223 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2004-11-08 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
|
||||||
|
|
||||||
2004-09-15 Chris Wiebe
|
2004-09-15 Chris Wiebe
|
||||||
|
|
||||||
fixed selection
|
fixed selection
|
||||||
|
|
|
@ -14,17 +14,33 @@ import java.util.Collection;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.browser.AllTypesCache;
|
import org.eclipse.cdt.core.browser.AllTypesCache;
|
||||||
import org.eclipse.cdt.core.browser.ITypeCacheChangedListener;
|
import org.eclipse.cdt.core.browser.ITypeCacheChangedListener;
|
||||||
|
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
||||||
|
import org.eclipse.cdt.core.model.IArchive;
|
||||||
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
|
import org.eclipse.cdt.core.model.ICElementVisitor;
|
||||||
|
import org.eclipse.cdt.core.model.ICModel;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.model.IElementChangedListener;
|
||||||
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.internal.ui.BaseCElementContentProvider;
|
import org.eclipse.cdt.internal.ui.BaseCElementContentProvider;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||||
import org.eclipse.jface.viewers.StructuredViewer;
|
import org.eclipse.jface.viewers.StructuredViewer;
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
|
||||||
public abstract class CBrowsingContentProvider extends BaseCElementContentProvider
|
public abstract class CBrowsingContentProvider extends BaseCElementContentProvider implements ITreeContentProvider,
|
||||||
implements ITreeContentProvider, ITypeCacheChangedListener {
|
IElementChangedListener, ITypeCacheChangedListener {
|
||||||
|
|
||||||
public static final Object CONTENT_CANCELLED = new Object();
|
public static final Object CONTENT_CANCELLED = new Object();
|
||||||
public static final Object CONTENT_ERROR = new Object();
|
public static final Object CONTENT_ERROR = new Object();
|
||||||
|
@ -36,20 +52,25 @@ public abstract class CBrowsingContentProvider extends BaseCElementContentProvid
|
||||||
protected static final Object[] INVALID_INPUT = NO_CHILDREN;
|
protected static final Object[] INVALID_INPUT = NO_CHILDREN;
|
||||||
|
|
||||||
protected StructuredViewer fViewer;
|
protected StructuredViewer fViewer;
|
||||||
protected Object fInput;
|
protected Object fInput = null;
|
||||||
|
protected IProject fProject = null;
|
||||||
protected CBrowsingPart fBrowsingPart;
|
protected CBrowsingPart fBrowsingPart;
|
||||||
protected int fReadsInDisplayThread;
|
protected int fReadsInDisplayThread;
|
||||||
|
|
||||||
public CBrowsingContentProvider(CBrowsingPart browsingPart) {
|
public CBrowsingContentProvider(CBrowsingPart browsingPart) {
|
||||||
fBrowsingPart= browsingPart;
|
fBrowsingPart = browsingPart;
|
||||||
fViewer= fBrowsingPart.getViewer();
|
fViewer = fBrowsingPart.getViewer();
|
||||||
AllTypesCache.addTypeCacheChangedListener(this);
|
AllTypesCache.addTypeCacheChangedListener(this);
|
||||||
|
CoreModel.getDefault().addElementChangedListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
|
||||||
|
* java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
public synchronized void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||||
if (newInput instanceof Collection) {
|
if (newInput instanceof Collection) {
|
||||||
// Get a template object from the collection
|
// Get a template object from the collection
|
||||||
Collection col = (Collection) newInput;
|
Collection col = (Collection) newInput;
|
||||||
|
@ -59,55 +80,150 @@ public abstract class CBrowsingContentProvider extends BaseCElementContentProvid
|
||||||
newInput = null;
|
newInput = null;
|
||||||
}
|
}
|
||||||
fInput = newInput;
|
fInput = newInput;
|
||||||
|
fProject = getProject(newInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
|
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
|
||||||
*/
|
*/
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
AllTypesCache.removeTypeCacheChangedListener(this);
|
AllTypesCache.removeTypeCacheChangedListener(this);
|
||||||
|
CoreModel.getDefault().removeElementChangedListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void typeCacheChanged(IProject project) {
|
public void typeCacheChanged(IProject project) {
|
||||||
if (project.exists() && project.isOpen()) {
|
if (fInput != null && (fProject == null || !fProject.isAccessible() || fProject.equals(project))) {
|
||||||
postAdjustInputAndSetSelection(CoreModel.getDefault().create(project));
|
Object input = null;
|
||||||
} else {
|
if (project != null && project.isAccessible()) {
|
||||||
postAdjustInputAndSetSelection(CoreModel.getDefault().getCModel());
|
input = getNewInput(project);
|
||||||
|
}
|
||||||
|
postAdjustInputAndSetSelection(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
private IProject getProject(Object input) {
|
||||||
* @see org.eclipse.cdt.core.model.IElementChangedListener#elementChanged(org.eclipse.cdt.core.model.ElementChangedEvent)
|
if (input instanceof ICElement) {
|
||||||
|
ICProject cProj = ((ICElement) input).getCProject();
|
||||||
|
if (cProj != null)
|
||||||
|
return cProj.getProject();
|
||||||
|
}
|
||||||
|
if (input instanceof ITypeInfo) {
|
||||||
|
return ((ITypeInfo) input).getEnclosingProject();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getNewInput(IProject project) {
|
||||||
|
if (fInput == null || fInput instanceof ICModel) {
|
||||||
|
return fInput;
|
||||||
|
}
|
||||||
|
if (fInput instanceof ICProject) {
|
||||||
|
ICProject cproject = CoreModel.getDefault().create(project);
|
||||||
|
if (!cproject.equals(fInput))
|
||||||
|
return cproject;
|
||||||
|
return fInput;
|
||||||
|
}
|
||||||
|
if (fInput instanceof ISourceRoot) {
|
||||||
|
ICProject cproject = CoreModel.getDefault().create(project);
|
||||||
|
ISourceRoot cSourceRoot = (ISourceRoot) fInput;
|
||||||
|
if (!cSourceRoot.getCProject().equals(cproject)) {
|
||||||
|
return cSourceRoot;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ISourceRoot[] roots = cproject.getSourceRoots();
|
||||||
|
for (int i = 0; i < roots.length; ++i) {
|
||||||
|
ISourceRoot root = roots[i];
|
||||||
|
if (!(root.getResource() instanceof IProject) && root.equals(cSourceRoot)) {
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CModelException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fInput instanceof ICElement) {
|
||||||
|
ICProject cproject = CoreModel.getDefault().create(project);
|
||||||
|
ICElement celem = (ICElement) fInput;
|
||||||
|
if (!celem.getCProject().equals(cproject)) {
|
||||||
|
return celem;
|
||||||
|
}
|
||||||
|
final ICElement[] searchInfo = new ICElement[] { celem, null };
|
||||||
|
try {
|
||||||
|
cproject.accept(new ICElementVisitor() {
|
||||||
|
public boolean visit(ICElement element) throws CoreException {
|
||||||
|
if (searchInfo[1] != null)
|
||||||
|
return false;
|
||||||
|
if (element.equals(searchInfo[0])) {
|
||||||
|
searchInfo[1] = element;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
|
if (searchInfo[1] != null)
|
||||||
|
return searchInfo[1];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (fInput instanceof ITypeInfo) {
|
||||||
|
ITypeInfo info = (ITypeInfo) fInput;
|
||||||
|
if (info.exists())
|
||||||
|
return info;
|
||||||
|
IProject infoProj = info.getEnclosingProject();
|
||||||
|
if (infoProj == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!infoProj.equals(project)) {
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
ITypeInfo globalNS = AllTypesCache.getGlobalNamespace(project);
|
||||||
|
if (info.equals(globalNS))
|
||||||
|
return globalNS;
|
||||||
|
info = AllTypesCache.getType(project, info.getCElementType(), info.getQualifiedTypeName());
|
||||||
|
if (info != null) {
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void elementChanged(ElementChangedEvent event) {
|
public void elementChanged(ElementChangedEvent event) {
|
||||||
try {
|
try {
|
||||||
processDelta(event.getDelta());
|
processDelta(event.getDelta());
|
||||||
} catch(CModelException e) {
|
} catch (CModelException e) {
|
||||||
CUIPlugin.getDefault().log(e.getStatus());
|
CUIPlugin.getDefault().log(e.getStatus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isPathEntryChange(ICElementDelta delta) {
|
protected boolean isPathEntryChange(ICElementDelta delta) {
|
||||||
int flags= delta.getFlags();
|
int flags = delta.getFlags();
|
||||||
return (delta.getKind() == ICElementDelta.CHANGED &&
|
return (delta.getKind() == ICElementDelta.CHANGED && ((flags & ICElementDelta.F_BINARY_PARSER_CHANGED) != 0
|
||||||
((flags & ICElementDelta.F_BINARY_PARSER_CHANGED) != 0 ||
|
|| (flags & ICElementDelta.F_ADDED_PATHENTRY_LIBRARY) != 0
|
||||||
(flags & ICElementDelta.F_ADDED_PATHENTRY_LIBRARY) != 0 ||
|
|| (flags & ICElementDelta.F_ADDED_PATHENTRY_SOURCE) != 0
|
||||||
(flags & ICElementDelta.F_ADDED_PATHENTRY_SOURCE) != 0 ||
|
|| (flags & ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY) != 0
|
||||||
(flags & ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY) != 0 ||
|
|| (flags & ICElementDelta.F_PATHENTRY_REORDER) != 0
|
||||||
(flags & ICElementDelta.F_PATHENTRY_REORDER) != 0 ||
|
|| (flags & ICElementDelta.F_REMOVED_PATHENTRY_SOURCE) != 0 || (flags & ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE) != 0));
|
||||||
(flags & ICElementDelta.F_REMOVED_PATHENTRY_SOURCE) != 0 ||
|
|
||||||
(flags & ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE) != 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*//**
|
/**
|
||||||
* Processes a delta recursively. When more than two children are affected the
|
* Processes a delta recursively. When more than two children are affected
|
||||||
* tree is fully refreshed starting at this node. The delta is processed in the
|
* the tree is fully refreshed starting at this node. The delta is processed
|
||||||
* current thread but the viewer updates are posted to the UI thread.
|
* in the current thread but the viewer updates are posted to the UI thread.
|
||||||
*//*
|
*/
|
||||||
protected void processDelta(ICElementDelta delta) throws CModelException {
|
protected void processDelta(ICElementDelta delta) throws CModelException {
|
||||||
int kind= delta.getKind();
|
int kind = delta.getKind();
|
||||||
int flags= delta.getFlags();
|
int flags = delta.getFlags();
|
||||||
ICElement element= delta.getElement();
|
ICElement element = delta.getElement();
|
||||||
|
|
||||||
|
if (element instanceof ITranslationUnit && ((ITranslationUnit) element).isWorkingCopy()) {
|
||||||
|
// ignore working copies
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//System.out.println("Processing " + element);
|
//System.out.println("Processing " + element);
|
||||||
|
|
||||||
|
@ -121,7 +237,7 @@ public abstract class CBrowsingContentProvider extends BaseCElementContentProvid
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kind == ICElementDelta.ADDED) {
|
if (kind == ICElementDelta.ADDED) {
|
||||||
Object parent= internalGetParent(element);
|
Object parent = internalGetParent(element);
|
||||||
postAdd(parent, element);
|
postAdd(parent, element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,39 +253,37 @@ public abstract class CBrowsingContentProvider extends BaseCElementContentProvid
|
||||||
postRefresh(element.getCProject());
|
postRefresh(element.getCProject());
|
||||||
}
|
}
|
||||||
|
|
||||||
ICElementDelta[] affectedChildren= delta.getAffectedChildren();
|
ICElementDelta[] affectedChildren = delta.getAffectedChildren();
|
||||||
for (int i= 0; i < affectedChildren.length; i++) {
|
for (int i = 0; i < affectedChildren.length; i++) {
|
||||||
processDelta(affectedChildren[i]);
|
processDelta(affectedChildren[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
private void postAdjustInputAndSetSelection(final Object element) {
|
private void postAdjustInputAndSetSelection(final Object input) {
|
||||||
postRunnable(new Runnable() {
|
postRunnable(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Control ctrl= fViewer.getControl();
|
Control ctrl = fViewer.getControl();
|
||||||
if (ctrl != null && !ctrl.isDisposed()) {
|
if (ctrl != null && !ctrl.isDisposed()) {
|
||||||
ctrl.setRedraw(false);
|
ctrl.setRedraw(false);
|
||||||
|
fBrowsingPart.adjustInputAndPreserveSelection(input);
|
||||||
fBrowsingPart.adjustInputPreservingSelection(element);
|
|
||||||
ctrl.setRedraw(true);
|
ctrl.setRedraw(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* private void postRefresh(final Object element) {
|
private void postRefresh(final Object element) {
|
||||||
//System.out.println("UI refresh:" + root);
|
//System.out.println("UI refresh:" + root);
|
||||||
postRunnable(new Runnable() {
|
postRunnable(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
// 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
|
// 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
|
||||||
Control ctrl= fViewer.getControl();
|
Control ctrl = fViewer.getControl();
|
||||||
if (ctrl != null && !ctrl.isDisposed()){
|
if (ctrl != null && !ctrl.isDisposed()) {
|
||||||
if(element instanceof IWorkingCopy){
|
if (element instanceof IWorkingCopy) {
|
||||||
if(fViewer.testFindItem(element) != null){
|
if (fViewer.testFindItem(element) != null) {
|
||||||
fViewer.refresh(element);
|
fViewer.refresh(element);
|
||||||
}else {
|
} else {
|
||||||
fViewer.refresh(((IWorkingCopy)element).getOriginalElement());
|
fViewer.refresh(((IWorkingCopy) element).getOriginalElement());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fViewer.refresh(element);
|
fViewer.refresh(element);
|
||||||
|
@ -184,15 +298,15 @@ public abstract class CBrowsingContentProvider extends BaseCElementContentProvid
|
||||||
postRunnable(new Runnable() {
|
postRunnable(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
// 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
|
// 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
|
||||||
Control ctrl= fViewer.getControl();
|
Control ctrl = fViewer.getControl();
|
||||||
if (ctrl != null && !ctrl.isDisposed()){
|
if (ctrl != null && !ctrl.isDisposed()) {
|
||||||
if(parent instanceof IWorkingCopy){
|
if (parent instanceof IWorkingCopy) {
|
||||||
if(fViewer.testFindItem(parent) != null){
|
if (fViewer.testFindItem(parent) != null) {
|
||||||
fViewer.refresh(parent);
|
fViewer.refresh(parent);
|
||||||
}else {
|
} else {
|
||||||
fViewer.refresh(((IWorkingCopy)parent).getOriginalElement());
|
fViewer.refresh(((IWorkingCopy) parent).getOriginalElement());
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
fViewer.refresh(parent);
|
fViewer.refresh(parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,25 +319,25 @@ public abstract class CBrowsingContentProvider extends BaseCElementContentProvid
|
||||||
postRunnable(new Runnable() {
|
postRunnable(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
// 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
|
// 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
|
||||||
Control ctrl= fViewer.getControl();
|
Control ctrl = fViewer.getControl();
|
||||||
if (ctrl != null && !ctrl.isDisposed()) {
|
if (ctrl != null && !ctrl.isDisposed()) {
|
||||||
Object parent = internalGetParent(element);
|
Object parent = internalGetParent(element);
|
||||||
if(parent instanceof IWorkingCopy){
|
if (parent instanceof IWorkingCopy) {
|
||||||
if(fViewer.testFindItem(parent) != null){
|
if (fViewer.testFindItem(parent) != null) {
|
||||||
fViewer.refresh(parent);
|
fViewer.refresh(parent);
|
||||||
}else {
|
} else {
|
||||||
fViewer.refresh(((IWorkingCopy)parent).getOriginalElement());
|
fViewer.refresh(((IWorkingCopy) parent).getOriginalElement());
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
fViewer.refresh(parent);
|
fViewer.refresh(parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
private void postRunnable(final Runnable r) {
|
private void postRunnable(final Runnable r) {
|
||||||
Control ctrl= fViewer.getControl();
|
Control ctrl = fViewer.getControl();
|
||||||
if (ctrl != null && !ctrl.isDisposed()) {
|
if (ctrl != null && !ctrl.isDisposed()) {
|
||||||
ctrl.getDisplay().asyncExec(r);
|
ctrl.getDisplay().asyncExec(r);
|
||||||
}
|
}
|
||||||
|
@ -240,12 +354,11 @@ public abstract class CBrowsingContentProvider extends BaseCElementContentProvid
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDisplayThread() {
|
private boolean isDisplayThread() {
|
||||||
Control ctrl= fViewer.getControl();
|
Control ctrl = fViewer.getControl();
|
||||||
if (ctrl == null)
|
if (ctrl == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Display currentDisplay= Display.getCurrent();
|
Display currentDisplay = Display.getCurrent();
|
||||||
return currentDisplay != null && currentDisplay.equals(ctrl.getDisplay());
|
return currentDisplay != null && currentDisplay.equals(ctrl.getDisplay());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1141,26 +1141,34 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I
|
||||||
// Default is to do nothing
|
// Default is to do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void adjustInputPreservingSelection(Object input) {
|
void adjustInputAndPreserveSelection(Object o) {
|
||||||
Object elementToSelect = null;
|
Object element = getOriginalElement(o);
|
||||||
ISelection selection = getSelectionProvider().getSelection();
|
if (!(element instanceof ICElement) && !(element instanceof ITypeInfo)) {
|
||||||
Object oldSelObj = null;
|
setSelection(StructuredSelection.EMPTY, true);
|
||||||
if (selection instanceof IStructuredSelection) {
|
|
||||||
oldSelObj = getSingleElementFromSelection(selection);
|
|
||||||
if (input != null) {
|
|
||||||
elementToSelect = findChildInInput(input, oldSelObj);
|
|
||||||
if (elementToSelect != null) {
|
|
||||||
adjustInputAndSetSelection(elementToSelect);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
Object elementToSelect= getSuitableElement(findElementToSelect(element));
|
||||||
adjustInputAndSetSelection(input);
|
Object newInput= findInputForElement(element);
|
||||||
|
Object oldInput= null;
|
||||||
|
Object viewerInput = getInput();
|
||||||
|
if (viewerInput instanceof ICElement || viewerInput instanceof ITypeInfo)
|
||||||
|
oldInput = viewerInput;
|
||||||
|
|
||||||
|
if (elementToSelect == null && !isValidInput(newInput) && (newInput == null && !isAncestorOf(element, oldInput)))
|
||||||
|
// Clear input
|
||||||
|
setInput(null);
|
||||||
|
else { // if (mustSetNewInput(elementToSelect, oldInput, newInput)) {
|
||||||
|
// Adjust input to selection
|
||||||
|
setInput(newInput);
|
||||||
|
// Recompute suitable element since it depends on the viewer's input
|
||||||
|
elementToSelect= getSuitableElement(elementToSelect);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object findChildInInput(Object input, Object oldSelObj) {
|
if (elementToSelect != null /*&& elementToSelect.exists()*/)
|
||||||
//TODO
|
setSelection(new StructuredSelection(elementToSelect), true);
|
||||||
return null;
|
else
|
||||||
|
setSelection(StructuredSelection.EMPTY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void adjustInputAndSetSelection(Object o) {
|
void adjustInputAndSetSelection(Object o) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue