org.eclipse.core.resources.IEncodedStorage Java Examples
The following examples show how to use
org.eclipse.core.resources.IEncodedStorage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XtextDocumentProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@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); } } if (encoding == null) { if (isWorkspaceExternalEditorInput(element)) encoding = getWorkspaceExternalEncoding((IURIEditorInput)element); else encoding = getWorkspaceOrDefaultEncoding(); } return encoding; }
Example #2
Source File: SVNStatusSyncInfo.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
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); } }
Example #3
Source File: StorageDocumentProvider.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * 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; }
Example #4
Source File: FileReportDocumentProvider.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * 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; }
Example #5
Source File: StorageAwareTrace.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected Reader getContentsAsText(IStorage storage) throws WrappedCoreException { if (storage instanceof IEncodedStorage) { try { IEncodedStorage enc = (IEncodedStorage) storage; Charset charset = Charset.forName(enc.getCharset()); InputStream contents = storage.getContents(); return new InputStreamReader(contents, charset); } catch (CoreException e) { throw new WrappedCoreException(e); } } return null; }
Example #6
Source File: Utilities.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public static String getCharset(IResource resource) { if (resource instanceof IEncodedStorage) { try { return ((IEncodedStorage)resource).getCharset(); } catch (CoreException ex) { // fall through } } return ResourcesPlugin.getEncoding(); }