List of usage examples for org.eclipse.jface.util Geometry divide
public static Point divide(Point toDivide, int scalar)
From source file:org.eclipse.ui.internal.DetachedWindow.java
License:Open Source License
public void create() { windowShell = ((WorkbenchWindow) page.getWorkbenchWindow()).getDetachedWindowPool() .allocateShell(shellListener); windowShell.setData(this); windowShell.setText(""); //$NON-NLS-1$ DragUtil.addDragTarget(windowShell, this); hideViewsOnClose = true;/*from www.jav a 2 s . c o m*/ if (bounds.isEmpty()) { Point center = Geometry.centerPoint(page.getWorkbenchWindow().getShell().getBounds()); Point size = new Point(300, 200); Point upperLeft = Geometry.subtract(center, Geometry.divide(size, 2)); bounds = Geometry.createRectangle(upperLeft, size); } // Force the rect into the current display Rectangle dispBounds = getShell().getDisplay().getBounds(); if (bounds.width > dispBounds.width) bounds.width = dispBounds.width; if (bounds.height > dispBounds.height) bounds.height = dispBounds.height; if (bounds.x + bounds.width > dispBounds.width) bounds.x = dispBounds.width - bounds.width; if (bounds.y + bounds.height > dispBounds.height) bounds.y = dispBounds.height - bounds.height; getShell().setBounds(bounds); configureShell(windowShell); createContents(windowShell); windowShell.layout(true); folder.setBounds(windowShell.getClientArea()); }