mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Fix for 199258, 'Show In' support for Include Browser.
This commit is contained in:
parent
d3ec428d4e
commit
d8b4bbf90c
2 changed files with 26 additions and 2 deletions
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.includebrowser;
|
package org.eclipse.cdt.internal.ui.includebrowser;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
@ -18,6 +19,7 @@ import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.jface.viewers.StructuredSelection;
|
||||||
import org.eclipse.ui.editors.text.ILocationProvider;
|
import org.eclipse.ui.editors.text.ILocationProvider;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
@ -54,6 +56,24 @@ public class IBConversions {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ISelection nodeSelectionToRepresentedTUSelection(ISelection sel) {
|
||||||
|
if (sel instanceof IStructuredSelection) {
|
||||||
|
IStructuredSelection ssel= (IStructuredSelection) sel;
|
||||||
|
ArrayList tus= new ArrayList();
|
||||||
|
for (Iterator iter = ssel.iterator(); iter.hasNext();) {
|
||||||
|
Object obj= iter.next();
|
||||||
|
if (obj instanceof IBNode) {
|
||||||
|
ITranslationUnit tu= ((IBNode) obj).getRepresentedTranslationUnit();
|
||||||
|
if (tu != null) {
|
||||||
|
tus.add(tu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new StructuredSelection(tus);
|
||||||
|
}
|
||||||
|
return StructuredSelection.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
public static ITranslationUnit objectToTU(Object object) {
|
public static ITranslationUnit objectToTU(Object object) {
|
||||||
if (object instanceof ITranslationUnit) {
|
if (object instanceof ITranslationUnit) {
|
||||||
return (ITranslationUnit) object;
|
return (ITranslationUnit) object;
|
||||||
|
|
|
@ -79,6 +79,7 @@ import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
|
@ -151,10 +152,13 @@ public class IBViewPart extends ViewPart
|
||||||
updateDescription();
|
updateDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInput(final ITranslationUnit input) {
|
public void setInput(ITranslationUnit input) {
|
||||||
if (fPagebook.isDisposed()) {
|
if (fPagebook.isDisposed()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (input instanceof IWorkingCopy) {
|
||||||
|
input= ((IWorkingCopy) input).getOriginalElement();
|
||||||
|
}
|
||||||
fSetInputJob.cancel();
|
fSetInputJob.cancel();
|
||||||
if (input == null) {
|
if (input == null) {
|
||||||
setMessage(IBMessages.IBViewPart_instructionMessage);
|
setMessage(IBMessages.IBViewPart_instructionMessage);
|
||||||
|
@ -730,7 +734,7 @@ public class IBViewPart extends ViewPart
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShowInContext getShowInContext() {
|
public ShowInContext getShowInContext() {
|
||||||
return new ShowInContext(null, fTreeViewer.getSelection());
|
return new ShowInContext(null, IBConversions.nodeSelectionToRepresentedTUSelection(fTreeViewer.getSelection()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean show(ShowInContext context) {
|
public boolean show(ShowInContext context) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue