Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.eclipse.xtext.ui.editor.info;
 
import  org.eclipse.core.resources.IFile;
import  org.eclipse.core.runtime.CoreException;
import  org.eclipse.ui.part.FileEditorInput;

Author(s):
Jan Koehnlein
public class ResourceWorkingCopyFileEditorInput extends FileEditorInput {
	private Resource resource;
		super(createFileProxy(resource));
		this. = resource;
	}
	public Resource getResource() {
		return ;
	}
	public String getEncoding() throws CoreException {
		if( instanceof XtextResource) {
		}
		return getFile().getCharset();
	}
	static IFile createFileProxy(final Resource resourcethrows IllegalArgumentExceptionIOException {
		return (IFile) Proxy.newProxyInstance(ResourceWorkingCopyFileEditorInput.class.getClassLoader(), new Class<?>[] { IFile.class },
	}	
		private byte[] buffer;
		private IFile file;
//		private String debug;
			 = ResourceUtil.getFile(resource);
			boolean isModified = resource.isModified();
			OutputStream outputStream = new BufferedOutputStream(outputBuffer);
			try {
				resource.save(outputStreamnull);
finally {
				outputStream.close();
				resource.setModified(isModified);
			}
			 = outputBuffer.toByteArray();
//			debug = new String(buffer);
		}
		public Object invoke(Object proxyMethod methodObject[] argsthrows Throwable {
//			System.out.println(method.getName());
			if(method.getName().equals("getContents")) { //$NON-NLS-1$
			}
			if(method.getName().equals("equals")) { //$NON-NLS-1$
				return proxy == args[0] ||  == args[0] || .equals(args[0]);
			}
			if(method.getName().equals("isConflicting")) { //$NON-NLS-1$
				return proxy == args[0] ||  == args[0];
			}
			return method.invoke(args);
		}
	}
New to GrepCode? Check out our FAQ X