1 11 package org.eclipse.jdt.internal.debug.ui.monitors; 12 13 14 import org.eclipse.jface.action.IAction; 15 import org.eclipse.jface.viewers.ISelection; 16 import org.eclipse.ui.IViewActionDelegate; 17 import org.eclipse.ui.IViewPart; 18 import org.eclipse.ui.texteditor.IUpdate; 19 20 public abstract class ToggleViewAction implements IViewActionDelegate, IUpdate { 21 22 protected MonitorsView fMonitorsView; 23 protected IAction fAction; 24 25 28 public void init(IViewPart view) { 29 if (view instanceof MonitorsView) { 30 fMonitorsView= (MonitorsView)view; 31 fMonitorsView.add(this); 32 } 33 } 34 35 38 public void selectionChanged(IAction action, ISelection selection) { 39 fAction= action; 40 } 41 42 45 public void update() { 46 if (fMonitorsView.getViewId() != getViewId()) { 47 fAction.setChecked(false); 48 } 49 } 50 51 54 public void run(IAction action) { 55 fMonitorsView.setViewId(getViewId()); 56 fMonitorsView.updateObjects(); 57 } 58 59 protected abstract int getViewId(); 60 } 61 | Popular Tags |