1 11 12 package org.eclipse.debug.internal.ui.views.memory; 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 55 protected void asyncExec(Runnable r) { 56 if (fViewer != null) { 57 Control ctrl= fViewer.getControl(); 58 if (ctrl != null && !ctrl.isDisposed()) { 59 ctrl.getDisplay().asyncExec(r); 60 } 61 } 62 } 63 64 67 protected void syncExec(Runnable r) { 68 if (fViewer != null) { 69 Control ctrl= fViewer.getControl(); 70 if (ctrl != null && !ctrl.isDisposed()) { 71 ctrl.getDisplay().syncExec(r); 72 } 73 } 74 } 75 76 79 protected void refresh() { 80 if (fViewer != null) { 81 fViewer.refresh(); 82 } 83 } 84 85 88 protected void refresh(Object element) { 89 if (fViewer != null) { 90 fViewer.refresh(element); 91 } 92 } 93 94 98 public void handleDebugEvent(final DebugEvent event) { 99 if (fViewer == null) { 100 return; 101 } 102 Object element= event.getSource(); 103 if (element == null) { 104 return; 105 } 106 Runnable r= new Runnable () { 107 public void run() { 108 if (!isDisposed()) { 109 doHandleDebugEvent(event); 110 } 111 } 112 }; 113 114 asyncExec(r); 115 } 116 117 120 public void handleDebugEvents(DebugEvent[] events) { 121 for (int i=0; i < events.length; i++) 122 handleDebugEvent(events[i]); 123 } 124 125 128 protected abstract void doHandleDebugEvent(DebugEvent event); 129 } | Popular Tags |