/** * Make this window draggable or not * * @param b whether the window should be movable with the mouse or not */ public void setMovable(boolean b) { if (!b) { if (moveDnDListener != null) { Display d = getDisplay(); if (d == null) throw new IllegalStateException("Uh, sorry, the window has to be in the widget tree"); d.removeDndListener(moveDnDListener); } } else { if (moveDnDListener == null) { Display d = getDisplay(); if (d == null) throw new IllegalStateException("Uh, sorry, the window has to be in the widget tree"); moveDnDListener = new WindowMoveDnDListenerImpl(); d.addDndListener(moveDnDListener); } } }
/** * Make this window resizable with the mouse or not. * * @param b flag whether the window shall be resizable or not */ public void setResizable(boolean b) { if (!b) { if (resizeDnDListener != null) { Display d = getDisplay(); if (d == null) throw new IllegalStateException( "Uh, sorry, the window has to be in the widget tree if you want to disable resizing :)"); d.removeDndListener(resizeDnDListener); resizeDnDListener = null; } } else { if (resizeDnDListener == null) { Display d = getDisplay(); if (d == null) throw new IllegalStateException( "Uh, sorry, the window has to be in the widget tree if you want to enable resizing :)"); d.removeDndListener( resizeDnDListener); // first remove old instance (in case of two subsequent // setResizable(true) calls) resizeDnDListener = new WindowResizeDnDListenerImpl(); d.addDndListener(resizeDnDListener); } } }