protected void setMiddle() { Rectangle screenSize = shell.getParent().getBounds(); Rectangle shellSize = shell.getBounds(); shell.setLocation(screenSize.x + screenSize.width / 2 - shellSize.width / 2, screenSize.y + screenSize.height / 2 - shellSize.height / 2); }
public static void setSize( Shell shell, int minWidth, int minHeight, boolean packIt ) { PropsUI props = PropsUI.getInstance(); WindowProperty winprop = props.getScreen( shell.getText() ); if ( winprop != null ) { winprop.setShell( shell, minWidth, minHeight ); } else { if ( packIt ) { shell.pack(); } else { shell.layout(); } // OK, sometimes this produces dialogs that are waay too big. // Try to limit this a bit, m'kay? // Use the same algorithm by cheating :-) // winprop = new WindowProperty( shell ); winprop.setShell( shell, minWidth, minHeight ); // Now, as this is the first time it gets opened, try to put it in the middle of the screen... Rectangle shellBounds = shell.getBounds(); Monitor monitor = shell.getDisplay().getPrimaryMonitor(); if ( shell.getParent() != null ) { monitor = shell.getParent().getMonitor(); } Rectangle monitorClientArea = monitor.getClientArea(); int middleX = monitorClientArea.x + ( monitorClientArea.width - shellBounds.width ) / 2; int middleY = monitorClientArea.y + ( monitorClientArea.height - shellBounds.height ) / 2; shell.setLocation( middleX, middleY ); } }
public static void setSize( Shell shell, int prefWidth, int prefHeight ) { PropsUI props = PropsUI.getInstance(); WindowProperty winprop = props.getScreen( shell.getText() ); if ( winprop != null ) { winprop.setShell( shell, prefWidth, prefHeight ); } else { shell.layout(); winprop = new WindowProperty( shell.getText(), false, new Rectangle( 0, 0, prefWidth, prefHeight ) ); winprop.setShell( shell ); // Now, as this is the first time it gets opened, try to put it in the middle of the screen... Rectangle shellBounds = shell.getBounds(); Monitor monitor = shell.getDisplay().getPrimaryMonitor(); if ( shell.getParent() != null ) { monitor = shell.getParent().getMonitor(); } Rectangle monitorClientArea = monitor.getClientArea(); int middleX = monitorClientArea.x + ( monitorClientArea.width - shellBounds.width ) / 2; int middleY = monitorClientArea.y + ( monitorClientArea.height - shellBounds.height ) / 2; shell.setLocation( middleX, middleY ); } }
@Override public void widgetDisposed(DisposeEvent e) { Composite parent= null; if (e.widget instanceof Shell) parent= ((Shell)e.widget).getParent(); if (parent instanceof Shell) fInformationControls.remove(parent); }
@Override public void widgetDisposed(DisposeEvent e) { Composite parent= null; if (e.widget instanceof Shell) parent= ((Shell)e.widget).getParent(); if (parent instanceof Shell) fInformationControls.remove(parent); }
public static boolean isDisplayModal(Shell activeShell) { while (activeShell != null) { if ((activeShell.getStyle() & (SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL | SWT.SYSTEM_MODAL)) > 0) return true; activeShell = (Shell) activeShell.getParent(); } return false; }
public SwtDialog(Shell shell, ActionContext actionContext){ super((Shell) shell.getParent()); this.actionContext = actionContext; this.myShell = shell; setRWTShell(); }
protected Point getInitialLocation(Point initialSize) { Composite parentShell = shell.getParent(); Rectangle containerBounds = (parentShell != null) ? parentShell.getBounds() : shell.getDisplay().getClientArea(); int x = Math.max(0, containerBounds.x + (containerBounds.width - initialSize.x) / 2); int y = Math.max(0, containerBounds.y + (containerBounds.height - initialSize.y) / 3); return new Point(x, y); }
private void moveToParentDialogCenter(Shell dialog) { if (dialog.getParent() == null) { // No parent shell no positioning return; } Point dialogSize = dialog.getSize(); Rectangle parentDialogBounds = dialog.getParent().getBounds(); Point newLocation = computeCenteredLocation(dialogSize, parentDialogBounds); dialog.setLocation(newLocation); }
public DragHost(Shell shell) { dragWindow = (MWindow) shell.getData(AbstractPartRenderer.OWNING_ME); baseWindow = (MWindow) shell.getParent().getData( AbstractPartRenderer.OWNING_ME); dragElement = dragWindow.getChildren().get(0); }
public DragHost(Shell shell) { dragWindow = (MWindow) shell.getData(AbstractPartRenderer.OWNING_ME); baseWindow = (MWindow) shell.getParent().getData( AbstractPartRenderer.OWNING_ME); dragElement = dragWindow.getChildren().get(0); }
public static void center(Shell dialog) { Shell parent = (Shell) dialog.getParent(); Rectangle parentBounds = parent.getBounds(); Rectangle childBounds = dialog.getBounds(); dialog.setLocation(parentBounds.x + (parentBounds.width - childBounds.width) / 2, parentBounds.y + (parentBounds.height - childBounds.height) / 2); }
/** * Opens the key binding preference page, closes this dialog */ private int openPreferencePage() { // Create a preference dialog on the keys preference page. Shell shell = getShell(); if (shell.getParent() != null) { shell = shell.getParent().getShell(); } PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell, keysPageId, null, getSelectedBinding()); close(); return dialog.open(); }
@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); }
/** * Opens the dialog. */ public void open() { shell.pack(); final Shell parentShell = (Shell) shell.getParent(); Rectangle rect = parentShell.getBounds(); Rectangle bounds = shell.getBounds(); bounds.x = rect.x + (rect.width - bounds.width) / 2; bounds.y = rect.y + (rect.height - bounds.height) / 2; shell.setBounds(bounds); shell.open(); } /**