mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 09:25:31 +02:00
Bug 252744 - Make ExternalEditorInput compatible to FileStoreEditorInput
This commit is contained in:
parent
e1e813365b
commit
f6622589f1
11 changed files with 159 additions and 210 deletions
|
@ -21,7 +21,6 @@ import org.eclipse.core.resources.IFile;
|
|||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceRuleFactory;
|
||||
import org.eclipse.core.resources.IStorage;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
|
@ -49,7 +48,6 @@ import org.eclipse.jface.util.PropertyChangeEvent;
|
|||
import org.eclipse.text.edits.DeleteEdit;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IFileEditorInput;
|
||||
import org.eclipse.ui.IStorageEditorInput;
|
||||
import org.eclipse.ui.editors.text.ForwardingDocumentProvider;
|
||||
import org.eclipse.ui.editors.text.ILocationProvider;
|
||||
import org.eclipse.ui.editors.text.ILocationProviderExtension;
|
||||
|
@ -856,15 +854,17 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
IBufferFactory factory = CUIPlugin.getDefault().getBufferFactory();
|
||||
tuInfo.fCopy = original.getSharedWorkingCopy(getProgressMonitor(), factory, requestor);
|
||||
|
||||
if (tuInfo.fModel == null && element instanceof IStorageEditorInput) {
|
||||
IStorage storage= ((IStorageEditorInput)element).getStorage();
|
||||
IResource markerResource= original.getCProject().getProject();
|
||||
tuInfo.fModel= new ExternalSearchAnnotationModel(markerResource, storage);
|
||||
IAnnotationModel fileBufferAnnotationModel= tuInfo.fTextFileBuffer.getAnnotationModel();
|
||||
if (fileBufferAnnotationModel != null) {
|
||||
((AnnotationModel)tuInfo.fModel).addAnnotationModel("fileBufferModel", fileBufferAnnotationModel); //$NON-NLS-1$
|
||||
if (tuInfo.fModel == null) {
|
||||
IPath location = original.getLocation();
|
||||
if (location != null) {
|
||||
IResource markerResource= original.getCProject().getProject();
|
||||
tuInfo.fModel= new ExternalSearchAnnotationModel(markerResource, location);
|
||||
IAnnotationModel fileBufferAnnotationModel= tuInfo.fTextFileBuffer.getAnnotationModel();
|
||||
if (fileBufferAnnotationModel != null) {
|
||||
((AnnotationModel)tuInfo.fModel).addAnnotationModel("fileBufferModel", fileBufferAnnotationModel); //$NON-NLS-1$
|
||||
}
|
||||
tuInfo.fCachedReadOnlyState= true;
|
||||
}
|
||||
tuInfo.fCachedReadOnlyState= true;
|
||||
}
|
||||
if (tuInfo.fModel instanceof TranslationUnitAnnotationModel) {
|
||||
TranslationUnitAnnotationModel model= (TranslationUnitAnnotationModel) tuInfo.fModel;
|
||||
|
|
|
@ -10,12 +10,10 @@
|
|||
* Norbert Ploett (Siemens AG)
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.editor;
|
||||
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IStorage;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
@ -25,37 +23,37 @@ import org.eclipse.cdt.core.model.ICModelMarker;
|
|||
|
||||
public class ExternalSearchAnnotationModel extends ResourceMarkerAnnotationModel {
|
||||
|
||||
private final IStorage fStorage;
|
||||
private final IPath fLocation;
|
||||
private final int fDepth;
|
||||
private final String fLocationAttribute;
|
||||
|
||||
/**
|
||||
* @param markerResource
|
||||
* @param storage
|
||||
* @param location
|
||||
*/
|
||||
public ExternalSearchAnnotationModel(IResource markerResource, IStorage storage) {
|
||||
this(markerResource, storage, IResource.DEPTH_ZERO, ICModelMarker.C_MODEL_MARKER_EXTERNAL_LOCATION);
|
||||
public ExternalSearchAnnotationModel(IResource markerResource, IPath location) {
|
||||
this(markerResource, location, IResource.DEPTH_ZERO, ICModelMarker.C_MODEL_MARKER_EXTERNAL_LOCATION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param markerResource
|
||||
* @param storage
|
||||
* @param location
|
||||
* @param depth
|
||||
*/
|
||||
ExternalSearchAnnotationModel(IResource markerResource, IStorage storage, int depth) {
|
||||
this(markerResource, storage, depth, ICModelMarker.C_MODEL_MARKER_EXTERNAL_LOCATION);
|
||||
ExternalSearchAnnotationModel(IResource markerResource, IPath location, int depth) {
|
||||
this(markerResource, location, depth, ICModelMarker.C_MODEL_MARKER_EXTERNAL_LOCATION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param markerResource
|
||||
* @param storage
|
||||
* @param location
|
||||
* @param depth
|
||||
* @param locationAttribute
|
||||
*/
|
||||
ExternalSearchAnnotationModel(IResource markerResource,
|
||||
IStorage storage, int depth, String locationAttribute) {
|
||||
IPath location, int depth, String locationAttribute) {
|
||||
super(markerResource);
|
||||
fStorage= storage;
|
||||
fLocation= location;
|
||||
fDepth= depth;
|
||||
fLocationAttribute= locationAttribute;
|
||||
}
|
||||
|
@ -76,8 +74,7 @@ public class ExternalSearchAnnotationModel extends ResourceMarkerAnnotationModel
|
|||
if (externalFileName != null) { // Only accept markers with external
|
||||
// paths set
|
||||
IPath externalPath = new Path(externalFileName);
|
||||
IPath storagePath = fStorage.getFullPath();
|
||||
acceptable = externalPath.equals(storagePath); // Only accept
|
||||
acceptable = externalPath.equals(fLocation); // Only accept
|
||||
// markers for this
|
||||
// annotation
|
||||
// model's external
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
* Norbert Ploett (Siemens AG)
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.editor;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.core.filesystem.URIUtil;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IStorage;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -28,8 +28,6 @@ import org.eclipse.ui.editors.text.ILocationProvider;
|
|||
import org.eclipse.ui.editors.text.ILocationProviderExtension;
|
||||
import org.eclipse.ui.editors.text.TextFileDocumentProvider;
|
||||
|
||||
import org.eclipse.cdt.core.resources.EFSFileStorage;
|
||||
import org.eclipse.cdt.core.resources.FileStorage;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
|
||||
|
@ -67,29 +65,31 @@ public class ExternalSearchDocumentProvider extends TextFileDocumentProvider {
|
|||
if (element instanceof IStorageEditorInput) {
|
||||
IStorage storage= ((IStorageEditorInput)element).getStorage();
|
||||
if (storage.getFullPath() != null) {
|
||||
return createExternalSearchAnnotationModel(storage, null);
|
||||
return createExternalSearchAnnotationModel(storage.getFullPath(), null);
|
||||
}
|
||||
}
|
||||
if (element instanceof IPathEditorInput) {
|
||||
IPath path= ((IPathEditorInput)element).getPath();
|
||||
IStorage storage= new FileStorage(path);
|
||||
return createExternalSearchAnnotationModel(storage, null);
|
||||
IPath location = ((IPathEditorInput) element).getPath();
|
||||
if (location != null) {
|
||||
return createExternalSearchAnnotationModel(location, null);
|
||||
}
|
||||
}
|
||||
if (element instanceof IAdaptable) {
|
||||
IAdaptable adaptable= (IAdaptable) element;
|
||||
|
||||
ILocationProviderExtension extendedProvider = (ILocationProviderExtension) adaptable.getAdapter(ILocationProviderExtension.class);
|
||||
|
||||
if(extendedProvider != null) {
|
||||
URI uri = extendedProvider.getURI(element);
|
||||
IStorage storage = new EFSFileStorage(uri);
|
||||
return createExternalSearchAnnotationModel(storage, null);
|
||||
}
|
||||
ILocationProvider provider = (ILocationProvider) adaptable.getAdapter(ILocationProvider.class);
|
||||
if (provider != null) {
|
||||
IPath path = provider.getPath(element);
|
||||
IStorage storage = new FileStorage(path);
|
||||
return createExternalSearchAnnotationModel(storage, null);
|
||||
IPath location = provider.getPath(element);
|
||||
if (location != null) {
|
||||
return createExternalSearchAnnotationModel(location, null);
|
||||
}
|
||||
if (provider instanceof ILocationProviderExtension) {
|
||||
ILocationProviderExtension extendedProvider = (ILocationProviderExtension) provider;
|
||||
URI uri = extendedProvider.getURI(element);
|
||||
location = URIUtil.toPath(uri);
|
||||
if (location != null) {
|
||||
return createExternalSearchAnnotationModel(location, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -102,26 +102,29 @@ public class ExternalSearchDocumentProvider extends TextFileDocumentProvider {
|
|||
* @return a new annotation model for the external editor input
|
||||
*/
|
||||
private IAnnotationModel createExternalSearchAnnotationModel(ExternalEditorInput externalInput) {
|
||||
IStorage storage = externalInput.getStorage();
|
||||
IResource markerResource = externalInput.getMarkerResource();
|
||||
return createExternalSearchAnnotationModel(storage, markerResource);
|
||||
IPath location = externalInput.getPath();
|
||||
if (location != null) {
|
||||
IResource markerResource = externalInput.getMarkerResource();
|
||||
return createExternalSearchAnnotationModel(location, markerResource);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an annotation model for the given file and associated resource marker.
|
||||
*
|
||||
* @param storage the file in the form of a <code>IStorage</code>
|
||||
* @param location the local file system location
|
||||
* @param markerResource the resource to retrieve markers from, may be <code>null</code>
|
||||
* @return a new annotation model for the file
|
||||
*/
|
||||
private IAnnotationModel createExternalSearchAnnotationModel(IStorage storage, IResource markerResource) {
|
||||
private IAnnotationModel createExternalSearchAnnotationModel(IPath location, IResource markerResource) {
|
||||
AnnotationModel model= null;
|
||||
if (markerResource != null){
|
||||
model = new ExternalSearchAnnotationModel(markerResource, storage);
|
||||
model = new ExternalSearchAnnotationModel(markerResource, location);
|
||||
} else {
|
||||
// no marker resource available - search workspace root and all project resources (depth one)
|
||||
markerResource= CUIPlugin.getWorkspace().getRoot();
|
||||
model = new ExternalSearchAnnotationModel(markerResource, storage, IResource.DEPTH_ONE);
|
||||
model = new ExternalSearchAnnotationModel(markerResource, location, IResource.DEPTH_ONE);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
|
|
@ -8,19 +8,14 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.editor;
|
||||
|
||||
import org.eclipse.ui.IStorageEditorInput;
|
||||
import org.eclipse.ui.editors.text.ILocationProvider;
|
||||
import org.eclipse.ui.editors.text.ILocationProviderExtension;
|
||||
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
|
||||
/**
|
||||
* ITranslationUnitEditorInput
|
||||
*/
|
||||
public interface ITranslationUnitEditorInput extends IStorageEditorInput, ILocationProvider, ILocationProviderExtension {
|
||||
public interface ITranslationUnitEditorInput {
|
||||
|
||||
ITranslationUnit getTranslationUnit();
|
||||
|
||||
|
|
|
@ -227,7 +227,7 @@ public class OpenIncludeAction extends Action {
|
|||
}
|
||||
|
||||
/**
|
||||
* Recuse in the project.
|
||||
* Recurse in the project.
|
||||
* @param parent
|
||||
* @param name
|
||||
* @param list
|
||||
|
@ -239,15 +239,17 @@ public class OpenIncludeAction extends Action {
|
|||
public boolean visit(IResourceProxy proxy) throws CoreException {
|
||||
if (proxy.getType() == IResource.FILE && proxy.getName().equalsIgnoreCase(name.lastSegment())) {
|
||||
IPath rPath = proxy.requestResource().getLocation();
|
||||
int numSegToRemove = rPath.segmentCount() - name.segmentCount();
|
||||
IPath sPath = rPath.removeFirstSegments(numSegToRemove);
|
||||
sPath = sPath.setDevice(name.getDevice());
|
||||
if (Platform.getOS().equals(Platform.OS_WIN32) ?
|
||||
sPath.toOSString().equalsIgnoreCase(name.toOSString()) :
|
||||
sPath.equals(name)) {
|
||||
list.add(rPath);
|
||||
if (rPath != null) {
|
||||
int numSegToRemove = rPath.segmentCount() - name.segmentCount();
|
||||
IPath sPath = rPath.removeFirstSegments(numSegToRemove);
|
||||
sPath = sPath.setDevice(name.getDevice());
|
||||
if (Platform.getOS().equals(Platform.OS_WIN32) ?
|
||||
sPath.toOSString().equalsIgnoreCase(name.toOSString()) :
|
||||
sPath.equals(name)) {
|
||||
list.add(rPath);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class PDOMSearchResult extends AbstractTextSearchResult implements IEdito
|
|||
path= fileInput.getFile().getLocation();
|
||||
} else if (input instanceof ExternalEditorInput) {
|
||||
final ExternalEditorInput extInput = (ExternalEditorInput)input;
|
||||
path= extInput.getStorage().getFullPath();
|
||||
path= extInput.getPath();
|
||||
} else if (input instanceof IStorageEditorInput) {
|
||||
try {
|
||||
final IStorage storage= ((IStorageEditorInput)input).getStorage();
|
||||
|
|
|
@ -160,7 +160,7 @@ public class EditorReopener implements IDocCommentOwnershipListener {
|
|||
} else if(oldInput instanceof ExternalEditorInput) {
|
||||
ExternalEditorInput eei= (ExternalEditorInput) oldInput;
|
||||
ICElement element= CoreModel.getDefault().create(eei.getMarkerResource());
|
||||
newPart= EditorUtility.openInEditor(eei.getPath(null), element);
|
||||
newPart= EditorUtility.openInEditor(eei.getPath(), element);
|
||||
}
|
||||
if(oldPart == oldActive)
|
||||
newActive= newPart;
|
||||
|
|
|
@ -65,7 +65,6 @@ 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.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.core.resources.EFSFileStorage;
|
||||
import org.eclipse.cdt.core.resources.FileStorage;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
|
@ -253,7 +252,7 @@ public class EditorUtility {
|
|||
if (resource instanceof IFile) {
|
||||
return new FileEditorInput((IFile) resource);
|
||||
}
|
||||
return new ExternalEditorInput(unit, new EFSFileStorage(unit.getLocationURI()));
|
||||
return new ExternalEditorInput(unit);
|
||||
}
|
||||
|
||||
if (element instanceof IBinary) {
|
||||
|
@ -277,7 +276,10 @@ public class EditorUtility {
|
|||
return new FileEditorInput((IFile) input);
|
||||
}
|
||||
if (input instanceof IStorage) {
|
||||
return new ExternalEditorInput((IStorage)input);
|
||||
final IPath location= ((IStorage)input).getFullPath();
|
||||
if (location != null) {
|
||||
return new ExternalEditorInput(location);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -361,15 +363,15 @@ public class EditorUtility {
|
|||
}
|
||||
|
||||
if(fileStore != null)
|
||||
return new ExternalEditorInput(unit, new EFSFileStorage(locationURI));
|
||||
return new ExternalEditorInput(unit);
|
||||
}
|
||||
// no translation unit - still try to get a sensible marker resource
|
||||
// from the associated element
|
||||
IResource markerResource= cproject.getProject();
|
||||
return new ExternalEditorInput(new EFSFileStorage(locationURI), markerResource);
|
||||
return new ExternalEditorInput(locationURI, markerResource);
|
||||
}
|
||||
}
|
||||
return new ExternalEditorInput(new EFSFileStorage(locationURI));
|
||||
return new ExternalEditorInput(locationURI);
|
||||
}
|
||||
|
||||
|
||||
|
@ -407,15 +409,15 @@ public class EditorUtility {
|
|||
if (cproject != null) {
|
||||
ITranslationUnit unit = CoreModel.getDefault().createTranslationUnitFrom(cproject, location);
|
||||
if (unit != null) {
|
||||
return new ExternalEditorInput(unit, new FileStorage(location));
|
||||
return new ExternalEditorInput(unit);
|
||||
}
|
||||
// no translation unit - still try to get a sensible marker resource
|
||||
// from the associated element
|
||||
IResource markerResource= cproject.getProject();
|
||||
return new ExternalEditorInput(new FileStorage(location), markerResource);
|
||||
return new ExternalEditorInput(location, markerResource);
|
||||
}
|
||||
}
|
||||
return new ExternalEditorInput(new FileStorage(location));
|
||||
return new ExternalEditorInput(location);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,22 +14,18 @@ package org.eclipse.cdt.internal.ui.util;
|
|||
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.core.filesystem.EFS;
|
||||
import org.eclipse.core.filesystem.IFileStore;
|
||||
import org.eclipse.core.filesystem.URIUtil;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IStorage;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.ui.IEditorRegistry;
|
||||
import org.eclipse.ui.IMemento;
|
||||
import org.eclipse.ui.IPersistableElement;
|
||||
import org.eclipse.ui.IStorageEditorInput;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.editors.text.ILocationProvider;
|
||||
import org.eclipse.ui.ide.FileStoreEditorInput;
|
||||
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.resources.EFSFileStorage;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput;
|
||||
|
||||
|
@ -37,129 +33,79 @@ import org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput;
|
|||
/**
|
||||
* An EditorInput for an external (non-workspace) file.
|
||||
*/
|
||||
public class ExternalEditorInput implements ITranslationUnitEditorInput, IPersistableElement {
|
||||
public final class ExternalEditorInput extends FileStoreEditorInput implements ITranslationUnitEditorInput {
|
||||
|
||||
private IStorage externalFile;
|
||||
private IResource markerResource;
|
||||
private final IPath location;
|
||||
private final IResource markerResource;
|
||||
private ITranslationUnit unit;
|
||||
private IPath location;
|
||||
|
||||
/*
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!(obj instanceof IStorageEditorInput))
|
||||
return false;
|
||||
IStorageEditorInput other = (IStorageEditorInput)obj;
|
||||
// externalFile storage type may not be the same so compare the paths
|
||||
/**
|
||||
* Create an editor input for an external translation unit.
|
||||
*
|
||||
* @param unit the translation unit
|
||||
*/
|
||||
public ExternalEditorInput(ITranslationUnit unit) {
|
||||
this(unit.getLocationURI(), unit.getCProject().getProject());
|
||||
Assert.isNotNull(unit);
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an editor input for an external file of the local file system.
|
||||
*
|
||||
* @param location the file system location
|
||||
*/
|
||||
public ExternalEditorInput(IPath location) {
|
||||
this(URIUtil.toURI(location), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an editor input for an external file of the local file system.
|
||||
*
|
||||
* @param location the file system location
|
||||
* @param markerResource the associated marker resource, may be <code>null</code>
|
||||
*/
|
||||
public ExternalEditorInput(IPath location, IResource markerResource) {
|
||||
this(URIUtil.toURI(location), markerResource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an editor input for a location URI.
|
||||
*
|
||||
* @param locationURI the location URI
|
||||
*/
|
||||
public ExternalEditorInput(URI locationURI) {
|
||||
this(locationURI, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an editor input for a location URI.
|
||||
*
|
||||
* @param locationURI the location URI
|
||||
* @param markerResource the associated marker resource, may be <code>null</code>
|
||||
*/
|
||||
public ExternalEditorInput(URI locationURI, IResource markerResource) {
|
||||
super(getFileStore(locationURI));
|
||||
this.location = URIUtil.toPath(locationURI);
|
||||
this.markerResource = markerResource;
|
||||
}
|
||||
|
||||
private static IFileStore getFileStore(URI locationURI) {
|
||||
try {
|
||||
return externalFile.getFullPath().equals(other.getStorage().getFullPath());
|
||||
return EFS.getStore(locationURI);
|
||||
} catch (CoreException exc) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IEditorInput#exists()
|
||||
*/
|
||||
public boolean exists() {
|
||||
// External file can not be deleted
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IAdaptable#getAdapter(Class)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (ILocationProvider.class.equals(adapter)) {
|
||||
return this;
|
||||
}
|
||||
return Platform.getAdapterManager().getAdapter(this, adapter);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IEditorInput#getImageDescriptor()
|
||||
*/
|
||||
public ImageDescriptor getImageDescriptor() {
|
||||
IEditorRegistry registry= PlatformUI.getWorkbench().getEditorRegistry();
|
||||
return registry.getImageDescriptor(externalFile.getFullPath().getFileExtension());
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IEditorInput#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return externalFile.getName();
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IEditorInput#getPersistable()
|
||||
*/
|
||||
public IPersistableElement getPersistable() {
|
||||
if (location != null) {
|
||||
return this;
|
||||
CUIPlugin.log(exc);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* see IStorageEditorInput#getStorage()
|
||||
*/
|
||||
public IStorage getStorage() {
|
||||
return externalFile;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IEditorInput#getToolTipText()
|
||||
*/
|
||||
public String getToolTipText() {
|
||||
IPath path = externalFile.getFullPath();
|
||||
if(path != null)
|
||||
return path.toString();
|
||||
return unit.getLocationURI().toString();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput#getTranslationUnit()
|
||||
*/
|
||||
public ITranslationUnit getTranslationUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.editors.text.ILocationProvider#getPath(java.lang.Object)
|
||||
*/
|
||||
public IPath getPath(Object element) {
|
||||
return location;
|
||||
}
|
||||
|
||||
public ExternalEditorInput(ITranslationUnit unit, IStorage exFile) {
|
||||
this(exFile, exFile.getFullPath());
|
||||
this.unit = unit;
|
||||
markerResource= unit.getCProject().getProject();
|
||||
}
|
||||
|
||||
public ExternalEditorInput(IStorage exFile) {
|
||||
this(exFile, exFile.getFullPath());
|
||||
}
|
||||
|
||||
public ExternalEditorInput(IStorage exFile, IPath location) {
|
||||
externalFile = exFile;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor accepts the storage for the editor
|
||||
* and a reference to a resource which holds the markers for the external file.
|
||||
*/
|
||||
public ExternalEditorInput(IStorage exFile, IResource markerResource) {
|
||||
this(exFile, exFile.getFullPath());
|
||||
this.markerResource = markerResource ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the resource where markers for this external editor input are stored
|
||||
*/
|
||||
|
@ -170,29 +116,32 @@ public class ExternalEditorInput implements ITranslationUnitEditorInput, IPersis
|
|||
/*
|
||||
* @see org.eclipse.ui.IPersistableElement#getFactoryId()
|
||||
*/
|
||||
@Override
|
||||
public String getFactoryId() {
|
||||
return ExternalEditorInputFactory.ID;
|
||||
if (getPath() != null) {
|
||||
return ExternalEditorInputFactory.ID;
|
||||
}
|
||||
return super.getFactoryId();
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
|
||||
*/
|
||||
@Override
|
||||
public void saveState(IMemento memento) {
|
||||
ExternalEditorInputFactory.saveState(memento, this);
|
||||
if (getPath() != null) {
|
||||
ExternalEditorInputFactory.saveState(memento, this);
|
||||
} else {
|
||||
super.saveState(memento);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.editors.text.ILocationProviderExtension#getURI(java.lang.Object)
|
||||
* @see org.eclipse.ui.IPathEditorInput#getPath()
|
||||
* Note: ExternalEditorInput must not implement IPathEditorInput!
|
||||
*/
|
||||
public URI getURI(Object element) {
|
||||
if (externalFile instanceof EFSFileStorage) {
|
||||
return ((EFSFileStorage) externalFile).getLocationURI();
|
||||
}
|
||||
IPath location = getPath(element);
|
||||
if (location != null) {
|
||||
return URIUtil.toURI(location);
|
||||
}
|
||||
return null;
|
||||
public IPath getPath() {
|
||||
return location;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2008 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
|
||||
|
@ -8,7 +8,6 @@
|
|||
* Contributors:
|
||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.util;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -72,7 +71,7 @@ public class ExternalEditorInputFactory implements IElementFactory {
|
|||
* @param input the element
|
||||
*/
|
||||
static void saveState(IMemento memento, ExternalEditorInput input) {
|
||||
IPath location= input.getPath(input);
|
||||
IPath location= input.getPath();
|
||||
if (location != null) {
|
||||
memento.putString(TAG_PATH, location.toOSString());
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
|
|||
ICProject cproject = CoreModel.getDefault().create(project);
|
||||
String id = CoreModel.getRegistedContentTypeId(project, path.lastSegment());
|
||||
ExternalTranslationUnit tu = new ExternalTranslationUnit(cproject, URIUtil.toURI(path), id);
|
||||
return new ExternalEditorInput( tu, new LocalFileStorage( fsfile ) );
|
||||
return new ExternalEditorInput( tu );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -194,15 +194,15 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
|
|||
return new FileEditorInput( file );
|
||||
}
|
||||
if ( element instanceof FileStorage || element instanceof LocalFileStorage ) {
|
||||
return new ExternalEditorInput( (IStorage)element );
|
||||
return new ExternalEditorInput( ((IStorage) element).getFullPath() );
|
||||
}
|
||||
if ( element instanceof ExternalTranslationUnit ) {
|
||||
ExternalTranslationUnit etu = (ExternalTranslationUnit) element;
|
||||
return new ExternalEditorInput( etu , new LocalFileStorage( etu.getLocation().toFile() ) );
|
||||
return new ExternalEditorInput( etu );
|
||||
}
|
||||
if (element instanceof CSourceNotFoundElement)
|
||||
{
|
||||
return new CSourceNotFoundEditorInput((CSourceNotFoundElement) element);
|
||||
return new CSourceNotFoundEditorInput(element);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -222,6 +222,7 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
|
|||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getImage( Object element ) {
|
||||
Image baseImage = getBaseImage( element );
|
||||
if ( baseImage != null ) {
|
||||
|
@ -367,6 +368,7 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
|
|||
return getImageCache().getImageFor( new OverlayImageDescriptor( fDebugImageRegistry.get( descriptor ), computeBreakpointOverlays( watchpoint ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText( Object element ) {
|
||||
String bt = getBaseText( element );
|
||||
if ( bt == null )
|
||||
|
|
Loading…
Add table
Reference in a new issue