1 11 package org.eclipse.ui.internal.presentations; 12 13 import org.eclipse.jface.action.Action; 14 import org.eclipse.ui.internal.ViewPane; 15 import org.eclipse.ui.internal.WorkbenchMessages; 16 import org.eclipse.ui.internal.WorkbenchPage; 17 import org.eclipse.ui.presentations.IPresentablePart; 18 import org.eclipse.ui.presentations.IStackPresentationSite; 19 20 public class SystemMenuDetach extends Action implements ISelfUpdatingAction { 21 22 private ViewPane viewPane; 23 private IStackPresentationSite site; 24 private WorkbenchPage page; 25 26 public SystemMenuDetach(IStackPresentationSite site) { 27 this.site = site; 28 setText(WorkbenchMessages.PartPane_detach); 29 update(); 30 } 31 32 public void update() { 33 IPresentablePart presentablePart = site.getSelectedPart(); 34 setEnabled(presentablePart != null && site.isPartMoveable(presentablePart)); 35 if(viewPane != null){ 36 setChecked(!viewPane.isDocked()); 37 page = viewPane.getPage(); 38 } 39 } 40 41 public boolean shouldBeVisible() { 42 if(page != null) { 43 return page.getActivePerspective().getPresentation().canDetach(); 44 } 45 return false; 46 } 47 48 public void dispose() { 49 site = null; 50 } 51 52 public void setPane(ViewPane current){ 53 viewPane = current; 54 update(); 55 } 56 57 public void run() { 58 if(site != null){ 59 if(!isChecked()){ 60 viewPane.doDetach(); 61 } 62 else{ 63 viewPane.doAttach(); 64 } 65 } 66 } 67 68 } 69 | Popular Tags |