Java Code Examples for org.eclipse.core.resources.IEncodedStorage

The following are top voted examples for showing how to use org.eclipse.core.resources.IEncodedStorage. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: subclipse   File: SVNStatusSyncInfo.java   Source Code and License 6 votes vote down vote up
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 2
Project: bts   File: XtextDocumentProvider.java   Source Code and License 6 votes vote down vote up
@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;
}
 
Example 3
Project: APICloud-Studio   File: SVNStatusSyncInfo.java   Source Code and License 6 votes vote down vote up
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 4
Project: birt   File: StorageDocumentProvider.java   Source Code and License 6 votes vote down vote up
/**
 * 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 5
Project: birt   File: FileReportDocumentProvider.java   Source Code and License 6 votes vote down vote up
/**
 * 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 6
Project: subclipse   File: Utilities.java   Source Code and License 5 votes vote down vote up
public static String getCharset(IResource resource) {
	if (resource instanceof IEncodedStorage) {
		try {
			return ((IEncodedStorage)resource).getCharset();
		} catch (CoreException ex) {
			// fall  through
		}
	}
	return ResourcesPlugin.getEncoding();
}
 
Example 7
Project: APICloud-Studio   File: Utilities.java   Source Code and License 5 votes vote down vote up
public static String getCharset(IResource resource) {
	if (resource instanceof IEncodedStorage) {
		try {
			return ((IEncodedStorage)resource).getCharset();
		} catch (CoreException ex) {
			// fall  through
		}
	}
	return ResourcesPlugin.getEncoding();
}