1 11 package org.eclipse.ui.internal; 12 13 import org.eclipse.jface.action.Action; 14 import org.eclipse.ui.IWorkbenchWindow; 15 import org.eclipse.ui.actions.ActionFactory; 16 17 21 public class LockToolBarAction extends Action implements 22 ActionFactory.IWorkbenchAction { 23 24 28 private IWorkbenchWindow workbenchWindow; 29 30 35 public LockToolBarAction(IWorkbenchWindow window) { 36 super(WorkbenchMessages.LockToolBarAction_text); 37 if (window == null) { 38 throw new IllegalArgumentException (); 39 } 40 this.workbenchWindow = window; 41 setActionDefinitionId("org.eclipse.ui.window.lockToolBar"); setToolTipText(WorkbenchMessages.LockToolBarAction_toolTip); 44 setEnabled(true); 45 window.getWorkbench().getDisplay().asyncExec(new Runnable () { 48 public void run() { 49 if (workbenchWindow != null) { 50 setChecked(((WorkbenchWindow) workbenchWindow) 51 .isCoolBarLocked()); 52 } 53 } 54 }); 55 window.getWorkbench().getHelpSystem().setHelp(this, 56 IWorkbenchHelpContextIds.LOCK_TOOLBAR_ACTION); 57 } 58 59 62 public void run() { 63 if (workbenchWindow == null) { 64 return; 66 } 67 boolean locked = isChecked(); 68 ((WorkbenchWindow) workbenchWindow).lockCoolBar(locked); 69 } 70 71 74 public void dispose() { 75 workbenchWindow = null; 76 } 77 78 } 79 | Popular Tags |