/** * Save the current dialog bounds if they have changed. To use this method, the corresponding * dialog must be set in the constructor. */ public void saveBounds() { if (dialog == null) throw new IllegalStateException( "Corresponding dialog is not set when trying to save dialog bounds."); //$NON-NLS-1$ Shell sh = dialog.getShell(); if (sh != null && !sh.isDisposed() && isBoundsChanged()) saveBounds(sh.getBounds()); }
private void registerControlListener() { if (dialog != null) { final Shell s = dialog.getShell(); if (s != null) { s.addControlListener( new ControlListener() { public void controlMoved(ControlEvent e) { boundsChanged = true; removeControlListener(); } public void controlResized(ControlEvent e) { boundsChanged = true; removeControlListener(); } private void removeControlListener() { Shell sh = dialog.getShell(); if (sh != null) sh.removeControlListener(this); } }); } } }
public boolean isDisposed() { return dialog.getShell().isDisposed(); }