コード例 #1
0
    def test_closing(self):
        """Test that validation stops as soon as the event is rejected.

        """
        manifest1 = ClosingContributor1()
        manifest2 = ClosingContributor2()
        self.workbench.register(manifest1)
        self.workbench.register(manifest2)

        window = FalseWindow(self.workbench)

        plugin = self.workbench.get_plugin('ecpy.app')
        ev = CloseEvent()
        plugin.validate_closing(window, ev)

        assert not ev.is_accepted()
        assert not manifest2.called or not manifest1.called

        manifest1.accept = True
        manifest2.accept = True

        plugin.validate_closing(window, ev)

        assert ev.is_accepted()
        assert manifest2.called
コード例 #2
0
ファイル: test_app_plugin.py プロジェクト: PhilipVinc/ecpy
    def test_closing(self):
        """Test that validation stops as soon as the event is rejected.

        """
        manifest1 = ClosingContributor1()
        manifest2 = ClosingContributor2()
        self.workbench.register(manifest1)
        self.workbench.register(manifest2)

        window = FalseWindow(self.workbench)

        plugin = self.workbench.get_plugin('ecpy.app')
        ev = CloseEvent()
        plugin.validate_closing(window, ev)

        assert not ev.is_accepted()
        assert not manifest2.called or not manifest1.called

        manifest1.accept = True
        manifest2.accept = True

        plugin.validate_closing(window, ev)

        assert ev.is_accepted()
        assert manifest2.called
コード例 #3
0
    def test_closing(self):
        """ Test that validation stops as soon as the event is rejected.

        """
        self.workbench.register(HqcAppManifest())
        self.workbench.register(ClosingContributor1())
        self.workbench.register(ClosingContributor2())
        manifest1 = self.workbench.get_manifest('test.closing')
        manifest2 = self.workbench.get_manifest('test.closing2')
        window = Helper(self.workbench)

        plugin = self.workbench.get_plugin('hqc_meas.app')
        ev = CloseEvent()
        plugin.validate_closing(window, ev)

        assert_false(ev.is_accepted())
        assert_false(manifest2.called)

        manifest1.accept = True
        manifest2.accept = True

        plugin.validate_closing(window, ev)

        assert_true(ev.is_accepted())
        assert_true(manifest2.called)

        self.workbench.unregister(u'test.closing')
        self.workbench.unregister(u'hqc_meas.app')
コード例 #4
0
ファイル: test_app_plugin.py プロジェクト: zoulianmp/HQCMeas
    def test_closing(self):
        """ Test that validation stops as soon as the event is rejected.

        """
        self.workbench.register(HqcAppManifest())
        self.workbench.register(ClosingContributor1())
        self.workbench.register(ClosingContributor2())
        manifest1 = self.workbench.get_manifest('test.closing')
        manifest2 = self.workbench.get_manifest('test.closing2')
        window = Helper(self.workbench)

        plugin = self.workbench.get_plugin('hqc_meas.app')
        ev = CloseEvent()
        plugin.validate_closing(window, ev)

        assert_false(ev.is_accepted())
        assert_false(manifest2.called)

        manifest1.accept = True
        manifest2.accept = True

        plugin.validate_closing(window, ev)

        assert_true(ev.is_accepted())
        assert_true(manifest2.called)

        self.workbench.unregister(u'test.closing')
        self.workbench.unregister(u'hqc_meas.app')
コード例 #5
0
    def closeEvent(self, event):
        """ Handle the close event for the window.

        """
        event.accept()
        if not self._proxy_ref:
            return
        proxy = self._proxy_ref()
        d = proxy.declaration
        d_event = CloseEvent()
        d.closing(d_event)
        if d_event.is_accepted():
            deferredCall(finalize_close, d)
        else:
            event.ignore()
コード例 #6
0
    def closeEvent(self, event):
        """ Handle the close event for the dialog.

        """
        event.accept()
        if not self._proxy_ref:
            return
        proxy = self._proxy_ref()
        d = proxy.declaration
        d_event = CloseEvent()
        d.closing(d_event)
        if d_event.is_accepted():
            super(QWindowDialog, self).closeEvent(event)
        else:
            event.ignore()
コード例 #7
0
ファイル: wx_window.py プロジェクト: jf---/enaml
    def on_close(self, event):
        """ The event handler for the EVT_CLOSE event.

        """
        d = self.declaration
        d_event = CloseEvent()
        d.closing(d_event)
        if d_event.is_accepted():
            event.Skip()
            # Make sure the frame is not modal when closing, or no other
            # windows will be unblocked.
            self.widget.MakeModal(False)
            wx.CallAfter(finalize_close, d)
        else:
            event.Veto()
コード例 #8
0
ファイル: qt_window.py プロジェクト: MatthieuDartiailh/enaml
    def closeEvent(self, event):
        """ Handle the close event for the window.

        """
        event.accept()
        if not self._proxy_ref:
            return
        proxy = self._proxy_ref()
        d = proxy.declaration
        d_event = CloseEvent()
        d.closing(d_event)
        if d_event.is_accepted():
            deferredCall(finalize_close, d)
        else:
            event.ignore()
コード例 #9
0
 def validate_closing(self, window: Window, event: CloseEvent) -> None:
     """Run all closing checks to determine whether or not to close the app."""
     for closing in self.closing.contributions.values():
         closing.validate(window, event)
         if not event.is_accepted():
             break