@Override protected Point getInitialLocation(Point size) { if (fAnchor == null) { return super.getInitialLocation(size); } Point point = fAnchor; Rectangle monitor = getShell().getMonitor().getClientArea(); if (monitor.width < point.x + size.x) { point.x = Math.max(0, point.x - size.x); } if (monitor.height < point.y + size.y) { point.y = Math.max(0, point.y - size.y); } return point; }
@Override protected Point getInitialLocation(Point size) { if (fAnchor == null) { return super.getInitialLocation(size); } Point point = fAnchor; Rectangle monitor = getShell().getMonitor().getClientArea(); if (monitor.width < point.x + size.x) { point.x = Math.max(0, point.x - size.x); } if (monitor.height < point.y + size.y) { point.y = Math.max(0, point.y - size.y); } return point; }
/** * Returns the initial location to use for the shell based upon the * current selection in the viewer. Bottom is preferred to top, and * right is preferred to left, therefore if possible the popup will * be located below and to the right of the selection. * * @param initialSize * the initial size of the shell, as returned by * <code>getInitialSize</code>. * @return the initial location of the shell */ @Override protected Point getInitialLocation(Point initialSize) { if (fAnchor == null) { return super.getInitialLocation(initialSize); } Point point = fAnchor; Rectangle monitor = getShell().getMonitor().getClientArea(); if (monitor.width < point.x + initialSize.x) { point.x = Math.max(0, point.x - initialSize.x); } if (monitor.height < point.y + initialSize.y) { point.y = Math.max(0, point.y - initialSize.y); } return point; }
protected Point getInitialLocation(Point initialSize) { Point result = super.getInitialLocation(initialSize); IDialogSettings settings = getDialogSettings(); if (settings != null) { try { String prefix = uniqueID == null ? getClass().getName() : uniqueID; int x = settings.getInt(prefix + X_ORIGIN); int y = settings.getInt(prefix + Y_ORIGIN); result = new Point(x, y); Shell parent = getParentShell(); if (parent != null) { Point parentLocation = parent.getLocation(); result.x += parentLocation.x; result.y += parentLocation.y; } } catch (NumberFormatException e) { } } return result; }
@Override protected Point getInitialLocation(Point initialSize) { if (getShell().getParent() == null) { return super.getInitialLocation(initialSize); } Rectangle bounds = getShell().getParent().getMonitor().getBounds(); GC gc = new GC(getShell().getDisplay()); int textExtendX = gc.textExtent(message).x; gc.dispose(); return new Point(bounds.x + bounds.width / 2 - textExtendX / 2, bounds.y + bounds.height / 5); }