e4 RCP 应用程序:如何禁用 window 与对话框的交互?

e4 RCP Application: How do I disable window interaction with a Dialog?

我有一个 window 和一个 table 允许用户 add/edit 和删除条目。这些按钮将弹出一个对话框 window 来执行操作(使用 Window 构建器编辑器制作)。但是,当对话框 window 启动时,用户仍然可以与 table 进行交互,这可能会出现问题。我如何 "disable" 与 table window 交互,直到对话框 window 关闭?

对话框class

 public class RoleEditDialog {
        Text txtRoleName;
        Spinner spnrEksLvl;
        Spinner spnrLvl;

        @PostConstruct
        public void postConstruct(Composite parent) {
            parent.setLayout(null);

            Group group = new Group(parent, SWT.BORDER);
            group.setText("Role");
            group.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
            group.setBounds(29, 83, 236, 164);

            Label label = new Label(group, SWT.NONE);
            label.setText("Role Name");
            label.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
            label.setBounds(8, 30, 66, 14);

            txtRoleName = new Text(group, SWT.BORDER);
            txtRoleName.setBounds(74, 27, 152, 20);

            Label label_1 = new Label(group, SWT.NONE);
            label_1.setText("EKS Level");
            label_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
            label_1.setBounds(8, 67, 59, 14);

            spnrEksLvl = new Spinner(group, SWT.BORDER);
            spnrEksLvl.setBounds(74, 64, 152, 20);

            spnrLvl = new Spinner(group, SWT.BORDER);
            spnrLvl.setBounds(74, 101, 152, 20);

            Label label_2 = new Label(group, SWT.NONE);
            label_2.setText("Level");
            label_2.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
            label_2.setBounds(8, 104, 54, 14);

            Label label_3 = new Label(parent, SWT.NONE);
            label_3.setText("Role Administration");
            label_3.setFont(SWTResourceManager.getFont("Lucida Bright", 19, SWT.BOLD));
            label_3.setBounds(10, 10, 259, 29);

            Label label_4 = new Label(parent, SWT.NONE);
            label_4.setText("New/Update Role");
            label_4.setBounds(97, 38, 93, 15);      
        }

    }

用于打开对话框的处理程序class

public class OpenEditRoleHandler {
    @Inject
    EModelService modelService;
    @Inject
    MApplication application;

    @Execute
    public void execute(MPart part) 
    {
        RoleController roleController = new RoleController();
        if(part!=null)
        {
            RolesFrame rolesFrame = (RolesFrame) part.getObject(); 
            int selecRow = rolesFrame.table.getSelectionIndex();
            if(selecRow!=-1)
            {
                RightController rightController = new RightController();

                //Dialog
                modelService.find("ats_usermanagement_rcp.dialog.RoleAdmin", application).setToBeRendered(true);
                //Dialog part (I have more than one part so depending on if Add/Edit was selected the appropriate part would be rendered)
                modelService.find("ats_usermanagement_rcp.part.RoleEditDialog", application).setToBeRendered(true);     

                Role selectedRole = roleController.getRole((long) Integer.parseInt(rolesFrame.table.getItem(selecRow).getText(0)));

                MPart editPart = (MPart) modelService.find("ats_usermanagement_rcp.part.RoleEditDialog", application);
                RoleEditDialog editRole = (RoleEditDialog) editPart.getObject();

                editRole.txtRoleName.setText(selectedRole.getRolename());
                editRole.spnrLvl.setSelection(selectedRole.getLevel());
                editRole.spnrEksLvl.setSelection(selectedRole.getEksLevel());   
            }   
        }       
    }       
}

这实际上不是传统上称为对话框的内容 - 它是在单独的 window 中打开的另一部分。 e4 并没有很好地支持使用 Application.e4xmi 完成的对话。大多数对话都是使用 JFace Dialog class (org.eclipse.jface.dialogs.Dialog) 完成的,并且不在 Application.e4xmi.

您可以通过使用 styleOverride(参见 here)覆盖 window 样式来调整 window 的行为,以指定 SWT.APPLICATION_MODAL 标志。对话框的覆盖值为

styleOverride 68720

68720SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.MAX | SWT.RESIZE 标志的数值。