1 11 package org.eclipse.ui.internal.presentations; 12 13 import java.util.Arrays ; 14 import java.util.LinkedList ; 15 import java.util.List ; 16 17 import org.eclipse.jface.action.Action; 18 import org.eclipse.ui.internal.WorkbenchMessages; 19 import org.eclipse.ui.presentations.IPresentablePart; 20 import org.eclipse.ui.presentations.IStackPresentationSite; 21 22 public class SystemMenuCloseOthers extends Action implements 23 ISelfUpdatingAction { 24 25 private IStackPresentationSite stackPresentation; 26 private IPresentablePart current; 27 28 public SystemMenuCloseOthers(IStackPresentationSite stackPresentation) { 29 this.stackPresentation = stackPresentation; 30 setText(WorkbenchMessages.PartPane_closeOthers); 31 } 32 33 public void dispose() { 34 stackPresentation = null; 35 } 36 37 public void run() { 38 List others = new LinkedList (); 39 others.addAll(Arrays.asList(stackPresentation.getPartList())); 40 others.remove(current); 41 stackPresentation.close((IPresentablePart[]) others 42 .toArray(new IPresentablePart[others.size()])); 43 } 44 45 public void update() { 46 setTarget(stackPresentation.getSelectedPart()); 47 } 48 49 public boolean shouldBeVisible() { 50 return true; 51 } 52 53 57 public void setTarget(IPresentablePart current) { 58 this.current = current; 59 setEnabled(current != null && 60 stackPresentation.getPartList().length > 1); 61 } 62 } 63 | Popular Tags |