1 11 12 package org.eclipse.debug.internal.ui.views.memory.renderings; 13 14 import org.eclipse.debug.core.DebugEvent; 15 import org.eclipse.debug.core.IDebugEventSetListener; 16 import org.eclipse.jface.viewers.IStructuredContentProvider; 17 import org.eclipse.jface.viewers.StructuredViewer; 18 import org.eclipse.jface.viewers.Viewer; 19 import org.eclipse.swt.widgets.Control; 20 21 25 public abstract class BasicDebugViewContentProvider implements IStructuredContentProvider, IDebugEventSetListener { 26 27 protected StructuredViewer fViewer; 28 protected boolean fDisposed= false; 29 30 33 public void dispose() { 34 fDisposed= true; 35 } 36 37 41 protected boolean isDisposed() { 42 return fDisposed; 43 } 44 45 48 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { 49 fViewer= (StructuredViewer) viewer; 50 } 51 52 protected void asyncExec(Runnable r) { 53 if (fViewer != null) { 54 Control ctrl= fViewer.getControl(); 55 if (ctrl != null && !ctrl.isDisposed()) { 56 ctrl.getDisplay().asyncExec(r); 57 } 58 } 59 } 60 61 protected void syncExec(Runnable r) { 62 if (fViewer != null) { 63 Control ctrl= fViewer.getControl(); 64 if (ctrl != null && !ctrl.isDisposed()) { 65 ctrl.getDisplay().syncExec(r); 66 } 67 } 68 } 69 70 73 protected void refresh() { 74 if (fViewer != null) { 75 fViewer.refresh(); 76 } 77 } 78 79 82 protected void refresh(Object element) { 83 if (fViewer != null) { 84 fViewer.refresh(element); 85 } 86 } 87 88 92 public void handleDebugEvent(final DebugEvent event) { 93 if (fViewer == null) { 94 return; 95 } 96 Object element= event.getSource(); 97 if (element == null) { 98 return; 99 } 100 Runnable r= new Runnable () { 101 public void run() { 102 if (!isDisposed()) { 103 doHandleDebugEvent(event); 104 } 105 } 106 }; 107 108 asyncExec(r); 109 } 110 111 114 public void handleDebugEvents(DebugEvent[] events) { 115 for (int i=0; i < events.length; i++) 116 handleDebugEvent(events[i]); 117 } 118 119 122 protected abstract void doHandleDebugEvent(DebugEvent event); 123 } 124 | Popular Tags |