code: def reject(self):
          
          if self.stacked_widget.currentWidget() == self.resource_edit_page:
              self.edit_item = None
              self.switch_context(self.profile_edit_page)
          else:
              super(NeedsManagerDialog, self).reject()
docs: Overload the base dialog reject event so we can handle state change.
  
          If the user is in resource editing mode, clicking close button,
          window [x] or pressing escape should switch context back to the
          profile view, not close the whole window.
  
          See https://github.com/AIFDR/inasafe/issues/1387