mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-05 23:35:48 +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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Ed Swartz (Nokia)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.includebrowser;
|
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.ui.CUIPlugin;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
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.util.Messages;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.EditorOpener;
|
import org.eclipse.cdt.internal.ui.viewsupport.EditorOpener;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.ExtendedTreeViewer;
|
import org.eclipse.cdt.internal.ui.viewsupport.ExtendedTreeViewer;
|
||||||
|
@ -643,7 +645,7 @@ public class IBViewPart extends ViewPart
|
||||||
final ITranslationUnit tu= node.getRepresentedTranslationUnit();
|
final ITranslationUnit tu= node.getRepresentedTranslationUnit();
|
||||||
if (tu != null) {
|
if (tu != null) {
|
||||||
// open
|
// open
|
||||||
OpenFileAction ofa= new OpenFileAction(page);
|
OpenCElementAction ofa= new OpenCElementAction(page);
|
||||||
ofa.selectionChanged(selection);
|
ofa.selectionChanged(selection);
|
||||||
m.add(ofa);
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||||
|
* Ed Swartz (Nokia)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.navigator;
|
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.internal.ui.util.EditorUtility;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
|
@ -63,6 +65,9 @@ public class OpenCElementAction extends OpenFileAction {
|
||||||
fOpenElement = null;
|
fOpenElement = null;
|
||||||
if (selection.size() == 1) {
|
if (selection.size() == 1) {
|
||||||
Object element = selection.getFirstElement();
|
Object element = selection.getFirstElement();
|
||||||
|
if (!(element instanceof ICElement) && element instanceof IAdaptable) {
|
||||||
|
element = ((IAdaptable) element).getAdapter(ICElement.class);
|
||||||
|
}
|
||||||
if (element instanceof ICElement
|
if (element instanceof ICElement
|
||||||
&& (element instanceof ISourceReference || element instanceof IBinary)) {
|
&& (element instanceof ISourceReference || element instanceof IBinary)) {
|
||||||
fOpenElement = (ICElement) element;
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Ed Swartz (Nokia)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.viewsupport;
|
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.core.runtime.IPath;
|
||||||
import org.eclipse.jface.text.IRegion;
|
import org.eclipse.jface.text.IRegion;
|
||||||
import org.eclipse.jface.text.Region;
|
import org.eclipse.jface.text.Region;
|
||||||
import org.eclipse.ui.IEditorDescriptor;
|
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
import org.eclipse.ui.PartInitException;
|
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.ISourceRange;
|
||||||
import org.eclipse.cdt.core.model.ISourceReference;
|
import org.eclipse.cdt.core.model.ISourceReference;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.resources.FileStorage;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.model.ext.ICElementHandle;
|
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.
|
* 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.
|
* Opens the editor for an external location, selecting the given region.
|
||||||
*/
|
*/
|
||||||
public static void openExternalFile(IWorkbenchPage page, IPath location, IRegion region, long timestamp) {
|
public static void openExternalFile(IWorkbenchPage page, IPath location, IRegion region, long timestamp) {
|
||||||
IEditorPart editor= null;
|
IEditorPart editor= null;
|
||||||
if (timestamp == 0) {
|
try {
|
||||||
timestamp= location.toFile().lastModified();
|
editor= EditorUtility.openInEditor(location, null);
|
||||||
}
|
if (timestamp == 0) {
|
||||||
ExternalEditorInput ei= new ExternalEditorInput(new FileStorage(null, location));
|
timestamp= location.toFile().lastModified();
|
||||||
try {
|
}
|
||||||
IEditorDescriptor descriptor = IDE.getEditorDescriptor(location.lastSegment());
|
selectRegion(location, region, timestamp, editor);
|
||||||
editor= IDE.openEditor(page, ei, descriptor.getId(), false);
|
} catch (PartInitException e) {
|
||||||
} catch (PartInitException e) {
|
CUIPlugin.getDefault().log(e);
|
||||||
CUIPlugin.getDefault().log(e);
|
}
|
||||||
}
|
|
||||||
selectRegion(location, region, timestamp, editor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue