1 13 package org.eclipse.debug.internal.ui.views.breakpoints; 14 15 16 import java.util.HashSet ; 17 import java.util.Set ; 18 19 import org.eclipse.core.resources.IMarkerDelta; 20 import org.eclipse.debug.core.DebugPlugin; 21 import org.eclipse.debug.core.IBreakpointManager; 22 import org.eclipse.debug.core.IBreakpointManagerListener; 23 import org.eclipse.debug.core.IBreakpointsListener; 24 import org.eclipse.debug.core.model.IBreakpoint; 25 import org.eclipse.jface.viewers.AbstractTreeViewer; 26 import org.eclipse.jface.viewers.CheckboxTreeViewer; 27 import org.eclipse.jface.viewers.StructuredSelection; 28 import org.eclipse.ui.PlatformUI; 29 import org.eclipse.ui.activities.ActivityManagerEvent; 30 import org.eclipse.ui.activities.IActivityManagerListener; 31 import org.eclipse.ui.activities.IWorkbenchActivitySupport; 32 33 37 public class BreakpointsViewEventHandler implements IBreakpointsListener, IActivityManagerListener, IBreakpointManagerListener { 38 39 private BreakpointsView fView; 40 41 44 public BreakpointsViewEventHandler(BreakpointsView view) { 45 fView= view; 46 IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager(); 47 breakpointManager.addBreakpointListener(this); 48 breakpointManager.addBreakpointManagerListener(this); 49 IWorkbenchActivitySupport activitySupport = PlatformUI.getWorkbench().getActivitySupport(); 50 if (activitySupport != null) { 51 activitySupport.getActivityManager().addActivityManagerListener(this); 52 } 53 } 54 55 58 public void dispose() { 59 IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager(); 60 breakpointManager.removeBreakpointListener(this); 61 breakpointManager.removeBreakpointManagerListener(this); 62 IWorkbenchActivitySupport activitySupport = PlatformUI.getWorkbench().getActivitySupport(); 63 if (activitySupport != null) { 64 activitySupport.getActivityManager().removeActivityManagerListener(this); 65 } 66 } 67 68 71 public void breakpointsAdded(final IBreakpoint[] breakpoints) { 72 if (fView.isAvailable() && fView.isVisible()) { 73 fView.asyncExec(new Runnable () { 74 public void run() { 75 if (fView.isAvailable()) { 76 CheckboxTreeViewer viewer = fView.getCheckboxViewer(); 77 viewer.getControl().setRedraw(false); 78 BreakpointsContentProvider provider = (BreakpointsContentProvider)viewer.getContentProvider(); 79 provider.reorganize(); 80 81 for (int i = 0; i < breakpoints.length; i++) { 87 IBreakpoint breakpoint = breakpoints[i]; 88 BreakpointContainer[] roots = provider.getRoots(breakpoint); 89 if (roots != null) { 90 for (int j = 0; j < roots.length; j++) { 91 viewer.expandToLevel(roots[j], AbstractTreeViewer.ALL_LEVELS); 92 } 93 } 94 } 95 fView.getViewer().refresh(); 96 viewer.setSelection(new StructuredSelection(breakpoints)); 97 viewer.getControl().setRedraw(true); 98 fView.updateObjects(); 99 } 100 } 101 }); 102 } 103 } 104 105 108 public void breakpointsRemoved(final IBreakpoint[] breakpoints, IMarkerDelta[] deltas) { 109 if (fView.isAvailable() && fView.isVisible()) { 110 fView.asyncExec(new Runnable () { 111 public void run() { 112 if (fView.isAvailable()) { 113 CheckboxTreeViewer viewer= (CheckboxTreeViewer)fView.getViewer(); 114 viewer.getControl().setRedraw(false); 115 ((BreakpointsContentProvider)viewer.getContentProvider()).reorganize(); 116 viewer.getControl().setRedraw(true); 117 fView.updateObjects(); 118 } 119 } 120 }); 121 } 122 } 123 124 127 public void breakpointsChanged(final IBreakpoint[] breakpoints, final IMarkerDelta[] deltas) { 128 if (fView.isAvailable() & fView.isVisible()) { 129 fView.asyncExec(new Runnable () { 130 public void run() { 131 if (fView.isAvailable()) { 132 CheckboxTreeViewer viewer = (CheckboxTreeViewer)fView.getViewer(); 133 viewer.getControl().setRedraw(false); 134 BreakpointsContentProvider provider = (BreakpointsContentProvider) viewer.getContentProvider(); 135 Set updates = new HashSet (); 136 for (int i = 0; i < breakpoints.length; i++) { 137 IBreakpoint breakpoint = breakpoints[i]; 138 viewer.update(breakpoint, null); 139 BreakpointContainer[] containers = provider.getContainers(breakpoint); 140 if (containers != null) { 141 for (int j = 0; j < containers.length; j++ ) { 142 updates.add(containers[j]); 143 } 144 } else { 145 updates.add(breakpoint); 146 } 147 } 148 Object [] objects = updates.toArray(); 149 for (int i = 0; i < objects.length; i++) { 150 fView.updateCheckedState(objects[i]); 151 } 152 viewer.getControl().setRedraw(true); 153 fView.updateObjects(); 154 } 155 } 156 }); 157 } 158 } 159 160 164 public void activityManagerChanged(final ActivityManagerEvent activityManagerEvent) { 165 if (fView.isAvailable() & fView.isVisible() && activityManagerEvent.haveEnabledActivityIdsChanged()) { 166 fView.asyncExec(new Runnable () { 167 public void run() { 168 fView.getViewer().refresh(); 169 } 170 }); 171 } 172 } 173 174 177 public void breakpointManagerEnablementChanged(boolean enabled) { 178 if (fView.isAvailable() & fView.isVisible()) { 179 fView.asyncExec(new Runnable () { 180 public void run() { 181 fView.getViewer().refresh(); 182 } 183 }); 184 } 185 } 186 } 187 | Popular Tags |