void update() {
Document newDoc = getDocument();
Document oldDoc = docRef.get();
if (newDoc != oldDoc) {
if (oldDoc != null) {
ScaleModel model = oldDoc.getScaleModel();
model.removeScaleListener(this);
}
if (newDoc != null) {
ScaleModel model = newDoc.getScaleModel();
model.addScaleListener(this);
setEnabled(model.canScaleDown());
}
else {
setEnabled(false);
}
docRef = new WeakReference<Document>(newDoc);