1 package de.loskutov.bco.editors; 2 3 import java.lang.reflect.Method ; 4 5 import org.eclipse.jdt.core.IBuffer; 6 import org.eclipse.jdt.core.IOpenable; 7 import org.eclipse.jdt.internal.core.BufferManager; 8 9 18 public final class BytecodeBufferManager { 19 20 private BytecodeBufferManager() { 21 super(); 22 } 23 24 public static IBuffer getBuffer(IOpenable owner) { 25 return BufferManager.getDefaultBufferManager().getBuffer(owner); 26 } 27 28 public static IBuffer createBuffer(IOpenable owner) { 29 return BufferManager.getDefaultBufferManager().createBuffer(owner); 30 } 31 32 35 public static void addBuffer(IBuffer buffer) { 36 BufferManager manager = BufferManager.getDefaultBufferManager(); 37 try { 38 Method addMethod = BufferManager.class.getDeclaredMethod( 39 "addBuffer", new Class []{IBuffer.class}); 40 addMethod.setAccessible(true); 41 addMethod.invoke(manager, new Object []{buffer}); 42 } catch (Exception e) { 43 e.printStackTrace(); 45 } 46 } 47 48 51 public static void removeBuffer(IBuffer buffer) { 52 if (buffer != null) { 53 BufferManager manager = BufferManager.getDefaultBufferManager(); 54 try { 55 Method removeMethod = BufferManager.class.getDeclaredMethod( 56 "removeBuffer", new Class []{IBuffer.class}); 57 removeMethod.setAccessible(true); 58 removeMethod.invoke(manager, new Object []{buffer}); 59 } catch (Exception e) { 60 e.printStackTrace(); 62 } 63 } 64 } 65 } 66 | Popular Tags |