1 11 package org.eclipse.ui.internal.presentations.defaultpresentation; 12 13 import org.eclipse.swt.SWT; 14 import org.eclipse.swt.graphics.Point; 15 import org.eclipse.swt.graphics.Rectangle; 16 import org.eclipse.swt.widgets.Control; 17 import org.eclipse.swt.widgets.Event; 18 import org.eclipse.swt.widgets.Listener; 19 import org.eclipse.swt.widgets.Monitor; 20 import org.eclipse.ui.internal.presentations.BasicPartList; 21 import org.eclipse.ui.internal.presentations.util.ISystemMenu; 22 import org.eclipse.ui.internal.presentations.util.PresentablePartFolder; 23 import org.eclipse.ui.presentations.IPresentablePart; 24 import org.eclipse.ui.presentations.IStackPresentationSite; 25 26 29 public class DefaultPartList implements ISystemMenu { 30 31 private IStackPresentationSite site; 32 private PresentablePartFolder folder; 33 34 public DefaultPartList(IStackPresentationSite site, PresentablePartFolder folder) { 35 this.site = site; 36 this.folder = folder; 37 } 38 39 42 public void show(Control control, Point displayCoordinates, 43 IPresentablePart currentSelection) { 44 45 int shellStyle = SWT.RESIZE | SWT.ON_TOP | SWT.NO_TRIM; 46 int tableStyle = SWT.V_SCROLL | SWT.H_SCROLL; 47 final BasicPartList editorList = new BasicPartList(control.getShell(), 48 shellStyle, tableStyle, site, folder); 49 editorList.setInput(folder); 50 Point size = editorList.computeSizeHint(); 51 int x = displayCoordinates.x; 52 int y = displayCoordinates.y; 53 54 Monitor mon = folder.getTabFolder().getControl().getMonitor(); 55 Rectangle bounds = mon.getClientArea(); 56 if (x + size.x > bounds.x + bounds.width) { 57 x = bounds.x + bounds.width - size.x; 58 } 59 if (y + size.y > bounds.y + bounds.height) { 60 y = bounds.y + bounds.height - size.y; 61 } 62 editorList.setLocation(new Point(x, y)); 63 editorList.setVisible(true); 64 editorList.setFocus(); 65 editorList.getTableViewer().getTable().getShell().addListener( 66 SWT.Deactivate, new Listener() { 67 68 public void handleEvent(Event event) { 69 editorList.setVisible(false); 70 } 71 } 72 ); 73 } 74 75 public void dispose() { 76 77 } 78 79 } 80 | Popular Tags |