private static IResourceVariant createBaseResourceVariant(IResource local, LocalResourceStatus baseStatusInfo) { if( baseStatusInfo == null || baseStatusInfo.getLastChangedRevision() == null ) return null; if( local.getType() == IResource.FILE ) { String charset = null; try { charset = ((IEncodedStorage)local).getCharset(); } catch (CoreException e) { SVNProviderPlugin.log(IStatus.ERROR, e.getMessage(), e); } return new BaseFile(local, baseStatusInfo, charset); } else { return new BaseFolder(local, baseStatusInfo); } }
@Override public String getEncoding(Object element) { String encoding = super.getEncoding(element); if (encoding == null && element instanceof IStorageEditorInput) { try { IStorage storage = ((IStorageEditorInput) element).getStorage(); URI uri = storage2UriMapper.getUri(storage); if (uri != null) { encoding = encodingProvider.getEncoding(uri); } else if (storage instanceof IEncodedStorage) { encoding = ((IEncodedStorage)storage).getCharset(); } } catch (CoreException e) { throw new WrappedException(e); } } return encoding; }
/** * Returns the persisted encoding for the given element. * * @param element * the element for which to get the persisted encoding * @return the persisted encoding */ protected String getPersistedEncoding( Object element ) { if ( element instanceof IStorageEditorInput ) { IStorage storage; try { storage = ( (IStorageEditorInput) element ).getStorage( ); if ( storage instanceof IEncodedStorage ) return ( (IEncodedStorage) storage ).getCharset( ); } catch ( CoreException e ) { return null; } } return null; }
/** * Returns the persisted encoding for the given element. * * @param element * the element for which to get the persisted encoding * @return the persisted encoding */ protected String getPersistedEncoding( Object element ) { if ( element instanceof IEncodedStorage ) { try { return ( (IEncodedStorage) element ).getCharset( ); } catch ( CoreException e ) { return null; } } return null; }
public static String getCharset(IResource resource) { if (resource instanceof IEncodedStorage) { try { return ((IEncodedStorage)resource).getCharset(); } catch (CoreException ex) { // fall through } } return ResourcesPlugin.getEncoding(); }