Eclipse Scout check when leave page

Marko Zadravec

I am writing a scout application, and I stumbled upon some problem. In my standard Outline I have more than one page. In page A I have some editable table with save button. What is in page B is not important for this discussion.

Outline
   page A
   page B

If page A is selected and I edit some data I would like to be notified if I click on page B that some data are not saved.

So before Outline switch between page A and B I would like to have control to not switch to page B because same data in A are not saved.

I have actually solve this problem with extending pages, but I an looking if there is some standard pre-defined way for this.

Daniel Wiehl

Unfortunately, there is no way to prevent the node selection from really happening. As you mentioned, you can listen for activation and deactivation events in your Page by overriding the methods execPageActivatedand execPageDeactivated, respectively. But by using this approach, you cannot take control over node switching.

A bit more of control you get by providing your own implementation of createPageChangeStrategy in your Outline class by injecting a custom DefaultPageChangeStrategy. So you get informed every time a node change happens with a respective pageChange event. As long as your page is invalid, you prevent the page switching from happening and restore the origin tree selection.

Please take a look at the following example:

@Override
IPageChangeStrategy createPageChangeStrategy() {
    return new DefaultPageChangeStrategy() {

      @Override
      public void pageChanged(IOutline outline, IPage deselectedPage, IPage selectedPage) {
        if (deselectedPage instanceof APage && !((APage) deselectedPage).isValid()) { // #isValid is your check method for validity.
          // Do not propagate the PageChangeEvent and restore the selection of the invalid page.

          // Uninstall the PageChangeStrategy to ignore the event of restoring the selection.
          final IPageChangeStrategy pageChangeStrategy = this;
          setPageChangeStrategy(null);

          // Restore the selection and install the PageChangeStrategy anew.
          new ClientSyncJob("Restore node selection", ClientSession.get()) {

            @Override
            protected void runVoid(IProgressMonitor monitor) throws Throwable {
              YourOutline.this.selectNode(deselectedPage);
              setPageChangeStrategy(pageChangeStrategy);
            }
          }.schedule();
        }
        else {
          super.pageChanged(outline, deselectedPage, selectedPage);
        }
      }
    };
  }

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Eclipse Scout在离开页面时检查

来自分类Dev

Eclipse Scout Neon模拟后端服务

来自分类Dev

Eclipse Scout在离开页面时检查

来自分类Dev

Scout Eclipse键检测到行选择

来自分类Dev

Eclipse Scout Neon在位置上滚动

来自分类Dev

在Tomcat上的Eclipse Scout Http部署失败

来自分类Dev

Eclipse Scout的GUI中未显示StandardOutline的表

来自分类Dev

在Eclipse Scout中RAP目标上BooleanField的位置是奇数

来自分类Dev

使用ScoutClientTestRunner的Eclipse Scout客户端单元测试

来自分类Dev

Eclipse Scout霓虹灯表单元鼠标悬停

来自分类Dev

UndeclaredThrowableException与仅限客户端的Eclipse Scout应用程序

来自分类Dev

Eclipse Scout:form.doOk()不调用ModifyHandler#execStore()

来自分类Dev

Eclipse Scout表菜单取决于表上下文

来自分类Dev

Eclipse Scout客户端单元测试

来自分类Dev

使用ScoutClientTestRunner的Eclipse Scout客户端单元测试

来自分类Dev

Eclipse Scout回调,用于在字段中输入值

来自分类Dev

Eclipse Scout Tool按钮在RAP上不显示图像

来自分类Dev

Scout Eclipse Server-客户端通信

来自分类Dev

从命令行导出Eclipse Scout项目

来自分类Dev

Eclipse Scout:挂钩打开字段的事件工具提示

来自分类Dev

Eclipse Scout Neon ListBox:execValidateValue(..)无法正常工作

来自分类Dev

组框的Eclipse Scout Neon工具提示文本

来自分类Dev

Eclipse Scout霓虹灯按钮可将空间填满

来自分类Dev

Eclipse Scout霓虹灯表单元鼠标悬停

来自分类Dev

Eclipse Scout-干净的数据库身份验证

来自分类Dev

Eclipse Scout对话框表单X(关闭)按钮不可单击

来自分类Dev

Eclipse Scout霓虹灯整个区域周围的复选框是可单击的

来自分类Dev

Change docstring when inheriting but leave method the same

来自分类Dev

Check if file is included on page

Related 相关文章

  1. 1

    Eclipse Scout在离开页面时检查

  2. 2

    Eclipse Scout Neon模拟后端服务

  3. 3

    Eclipse Scout在离开页面时检查

  4. 4

    Scout Eclipse键检测到行选择

  5. 5

    Eclipse Scout Neon在位置上滚动

  6. 6

    在Tomcat上的Eclipse Scout Http部署失败

  7. 7

    Eclipse Scout的GUI中未显示StandardOutline的表

  8. 8

    在Eclipse Scout中RAP目标上BooleanField的位置是奇数

  9. 9

    使用ScoutClientTestRunner的Eclipse Scout客户端单元测试

  10. 10

    Eclipse Scout霓虹灯表单元鼠标悬停

  11. 11

    UndeclaredThrowableException与仅限客户端的Eclipse Scout应用程序

  12. 12

    Eclipse Scout:form.doOk()不调用ModifyHandler#execStore()

  13. 13

    Eclipse Scout表菜单取决于表上下文

  14. 14

    Eclipse Scout客户端单元测试

  15. 15

    使用ScoutClientTestRunner的Eclipse Scout客户端单元测试

  16. 16

    Eclipse Scout回调,用于在字段中输入值

  17. 17

    Eclipse Scout Tool按钮在RAP上不显示图像

  18. 18

    Scout Eclipse Server-客户端通信

  19. 19

    从命令行导出Eclipse Scout项目

  20. 20

    Eclipse Scout:挂钩打开字段的事件工具提示

  21. 21

    Eclipse Scout Neon ListBox:execValidateValue(..)无法正常工作

  22. 22

    组框的Eclipse Scout Neon工具提示文本

  23. 23

    Eclipse Scout霓虹灯按钮可将空间填满

  24. 24

    Eclipse Scout霓虹灯表单元鼠标悬停

  25. 25

    Eclipse Scout-干净的数据库身份验证

  26. 26

    Eclipse Scout对话框表单X(关闭)按钮不可单击

  27. 27

    Eclipse Scout霓虹灯整个区域周围的复选框是可单击的

  28. 28

    Change docstring when inheriting but leave method the same

  29. 29

    Check if file is included on page

热门标签

归档