if (newDoc != oldDoc) {
if (oldDoc != null) {
final RegionManager oldRegions = oldDoc.getRegionManager();
oldRegions.removeSelectionListener(CurveSelectionListener);
remove("regions");
Editor editor = oldDoc.getEditor();
EditorControls controls = editor.getToolStack();
controls.removeOpStackListener(ToolListener);
}
if (newDoc != null) {
final RegionManager newRegions = newDoc.getRegionManager();
newRegions.addSelectionListener(CurveSelectionListener);
put("regions", newRegions);
Editor editor = newDoc.getEditor();
EditorControls controls = editor.getToolStack();
controls.addOpStackListener(ToolListener);
}
else {
remove("regions");
remove("selection");