1 11 package org.eclipse.debug.internal.ui.views.variables.details; 12 13 import java.util.ArrayList ; 14 import java.util.HashMap ; 15 import java.util.Iterator ; 16 import java.util.List ; 17 import java.util.Map ; 18 19 import org.eclipse.debug.ui.IDetailPane; 20 import org.eclipse.jface.action.IAction; 21 import org.eclipse.ui.IViewSite; 22 import org.eclipse.ui.IWorkbenchPartSite; 23 import org.eclipse.ui.texteditor.IUpdate; 24 25 31 public abstract class AbstractDetailPane implements IDetailPane { 32 33 37 private IWorkbenchPartSite fWorkbenchPartSite; 38 39 43 private Map fActionMap = new HashMap (); 44 45 48 private List fSelectionActions = new ArrayList (); 49 50 53 public void init(IWorkbenchPartSite workbench) { 54 fWorkbenchPartSite = workbench; 55 56 } 57 58 61 public void dispose() { 62 fActionMap.clear(); 63 fSelectionActions.clear(); 64 } 65 66 72 protected void setAction(String actionID, IAction action) { 73 if (action == null) { 74 fActionMap.remove(actionID); 75 } else { 76 fActionMap.put(actionID, action); 77 } 78 } 79 80 88 protected void setGlobalAction(String actionID, IAction action){ 89 getViewSite().getActionBars().setGlobalActionHandler(actionID, action); 90 } 91 92 99 protected void setSelectionDependantAction(String actionID){ 100 if (actionID != null) fSelectionActions.add(actionID); 101 } 102 103 109 protected IAction getAction(String actionID) { 110 return (IAction) fActionMap.get(actionID); 111 } 112 113 120 protected void updateAction(String actionId) { 121 IAction action= getAction(actionId); 122 if (action instanceof IUpdate) { 123 ((IUpdate) action).update(); 124 } 125 } 126 127 134 protected void updateSelectionDependentActions() { 135 Iterator iterator= fSelectionActions.iterator(); 136 while (iterator.hasNext()) { 137 updateAction((String )iterator.next()); 138 } 139 } 140 141 147 protected IViewSite getViewSite(){ 148 if (fWorkbenchPartSite == null){ 149 return null; 150 } else { 151 return (IViewSite) fWorkbenchPartSite.getPart().getSite(); 152 } 153 } 154 155 161 protected IWorkbenchPartSite getWorkbenchPartSite() { 162 return fWorkbenchPartSite; 163 } 164 165 170 protected boolean isInView(){ 171 return fWorkbenchPartSite != null; 172 } 173 174 } 175 | Popular Tags |