1 11 package org.eclipse.jdt.internal.debug.ui.heapwalking; 12 13 import org.eclipse.core.runtime.IStatus; 14 import org.eclipse.core.runtime.Status; 15 import org.eclipse.core.runtime.Preferences.IPropertyChangeListener; 16 import org.eclipse.core.runtime.Preferences.PropertyChangeEvent; 17 import org.eclipse.debug.ui.IDebugView; 18 import org.eclipse.jdt.debug.core.IJavaStackFrame; 19 import org.eclipse.jdt.internal.debug.core.HeapWalkingManager; 20 import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin; 21 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; 22 import org.eclipse.jface.action.IAction; 23 import org.eclipse.jface.viewers.ISelection; 24 import org.eclipse.swt.widgets.Event; 25 import org.eclipse.ui.IActionDelegate2; 26 import org.eclipse.ui.IViewActionDelegate; 27 import org.eclipse.ui.IViewPart; 28 29 34 public class AllReferencesInViewActionDelegate implements IPropertyChangeListener, IActionDelegate2, IViewActionDelegate { 35 36 private IAction fAction; 37 private IDebugView fView; 38 39 42 public void run(IAction action) { 43 HeapWalkingManager.getDefault().setShowReferenceInVarView(action.isChecked()); 44 if (action.isChecked() && fView.getViewer() != null){ 46 if (fView.getViewer().getInput() instanceof IJavaStackFrame){ 47 if (!HeapWalkingManager.supportsHeapWalking(fView.getViewer().getInput())){ 48 JDIDebugUIPlugin.statusDialog(Messages.AllReferencesInViewActionDelegate_0,new Status(IStatus.WARNING,JDIDebugUIPlugin.getUniqueIdentifier(),Messages.AllReferencesInViewActionDelegate_1)); 49 } 50 } 51 } 52 } 53 54 57 public void init(IAction action) { 58 fAction = action; 59 action.setChecked(HeapWalkingManager.getDefault().isShowReferenceInVarView()); 60 JDIDebugPlugin.getDefault().getPluginPreferences().addPropertyChangeListener(this); 61 } 62 63 66 public void init(IViewPart view) { 67 if (view instanceof IDebugView){ 68 fView = (IDebugView)view; 69 } 70 } 71 72 75 public void selectionChanged(IAction action, ISelection selection) { 76 } 77 78 81 public void dispose() { 82 JDIDebugPlugin.getDefault().getPluginPreferences().removePropertyChangeListener(this); 83 } 84 85 88 public void runWithEvent(IAction action, Event event) { 89 run(action); 90 } 91 92 95 public void propertyChange(PropertyChangeEvent event) { 96 if (JDIDebugPlugin.PREF_SHOW_REFERENCES_IN_VAR_VIEW.equals(event.getProperty()) || JDIDebugPlugin.PREF_ALL_REFERENCES_MAX_COUNT.equals(event.getProperty())){ 97 if (fAction != null){ 98 fAction.setChecked(HeapWalkingManager.getDefault().isShowReferenceInVarView()); 99 fView.getViewer().refresh(); 100 } 101 } 102 } 103 } 104 | Popular Tags |