mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Fix for 172221, by Ed Swartz, better support for external files in include browser.
This commit is contained in:
parent
fd426ee735
commit
fb9b38386a
3 changed files with 23 additions and 19 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.includebrowser;
|
||||
|
@ -79,6 +80,7 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
|
|||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
import org.eclipse.cdt.internal.ui.navigator.OpenCElementAction;
|
||||
import org.eclipse.cdt.internal.ui.util.Messages;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.EditorOpener;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.ExtendedTreeViewer;
|
||||
|
@ -643,7 +645,7 @@ public class IBViewPart extends ViewPart
|
|||
final ITranslationUnit tu= node.getRepresentedTranslationUnit();
|
||||
if (tu != null) {
|
||||
// open
|
||||
OpenFileAction ofa= new OpenFileAction(page);
|
||||
OpenCElementAction ofa= new OpenCElementAction(page);
|
||||
ofa.selectionChanged(selection);
|
||||
m.add(ofa);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.navigator;
|
||||
|
||||
|
@ -16,6 +17,7 @@ import org.eclipse.cdt.core.model.ISourceReference;
|
|||
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
|
@ -63,6 +65,9 @@ public class OpenCElementAction extends OpenFileAction {
|
|||
fOpenElement = null;
|
||||
if (selection.size() == 1) {
|
||||
Object element = selection.getFirstElement();
|
||||
if (!(element instanceof ICElement) && element instanceof IAdaptable) {
|
||||
element = ((IAdaptable) element).getAdapter(ICElement.class);
|
||||
}
|
||||
if (element instanceof ICElement
|
||||
&& (element instanceof ISourceReference || element instanceof IBinary)) {
|
||||
fOpenElement = (ICElement) element;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.viewsupport;
|
||||
|
@ -16,7 +17,6 @@ import org.eclipse.core.resources.IResource;
|
|||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.jface.text.IRegion;
|
||||
import org.eclipse.jface.text.Region;
|
||||
import org.eclipse.ui.IEditorDescriptor;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
|
@ -30,12 +30,11 @@ import org.eclipse.cdt.core.model.ICElement;
|
|||
import org.eclipse.cdt.core.model.ISourceRange;
|
||||
import org.eclipse.cdt.core.model.ISourceReference;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.resources.FileStorage;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
import org.eclipse.cdt.internal.core.model.ext.ICElementHandle;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
|
||||
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
||||
|
||||
/**
|
||||
* An utility to open editors for references or elements.
|
||||
|
@ -74,18 +73,16 @@ public class EditorOpener {
|
|||
* Opens the editor for an external location, selecting the given region.
|
||||
*/
|
||||
public static void openExternalFile(IWorkbenchPage page, IPath location, IRegion region, long timestamp) {
|
||||
IEditorPart editor= null;
|
||||
if (timestamp == 0) {
|
||||
timestamp= location.toFile().lastModified();
|
||||
}
|
||||
ExternalEditorInput ei= new ExternalEditorInput(new FileStorage(null, location));
|
||||
try {
|
||||
IEditorDescriptor descriptor = IDE.getEditorDescriptor(location.lastSegment());
|
||||
editor= IDE.openEditor(page, ei, descriptor.getId(), false);
|
||||
} catch (PartInitException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
selectRegion(location, region, timestamp, editor);
|
||||
IEditorPart editor= null;
|
||||
try {
|
||||
editor= EditorUtility.openInEditor(location, null);
|
||||
if (timestamp == 0) {
|
||||
timestamp= location.toFile().lastModified();
|
||||
}
|
||||
selectRegion(location, region, timestamp, editor);
|
||||
} catch (PartInitException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue