eclipse-rcp - e4 RCP 应用程序:如何禁用与对话框的窗口交互?
问题描述
我有一个带有表格的窗口,允许用户添加/编辑和删除条目。这些按钮将弹出一个对话框窗口以执行操作(使用窗口构建器编辑器制作)。但是,当对话框窗口打开时,用户仍然可以与表格进行交互,这可能会出现问题。在对话框窗口关闭之前,如何“禁用”与表格窗口的交互?
对话类
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);
}
}
处理程序类打开对话框
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());
}
}
}
}
解决方案
这并不是传统意义上的对话框——它是在单独窗口中打开的另一部分。e4 对使用 Application.e4xmi 完成的对话框并没有很好的支持。大多数对话框是使用 JFaceDialog
类 ( org.eclipse.jface.dialogs.Dialog
) 完成的,并且不在 Application.e4xmi 中。
您可以通过使用styleOverride
(请参阅此处)指定SWT.APPLICATION_MODAL
标志覆盖窗口样式来调整窗口的行为。对话框的覆盖值将是
styleOverride 68720
68720
SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.MAX | SWT.RESIZE
是标志的数值。
推荐阅读
- amazon-web-services - AWS:从 Application LoadBalancer 获取 502 到 EC2 实例
- python - 使用 LSTM/RNN 预测数字序列
- database - 通过猫鼬连接到 MongoDB
- jenkins - 在 Jenkins 管道工具指令中展开变量
- google-cloud-platform - 通过 Terraform 安装 GKE 和 Anthos
- databricks - 在 Azure Databricks 群集重新启动之前不显示记录
- vue-router - 导航到另一条路线并返回后,Vue 中的 Bootstrap Carousel 停止工作
- javascript - 嵌入广告的 Youtube Iframe API
- python-3.x - 使用 brew uninstall python 卸载 python 3.9 时 - 错误:没有可用的公式或名称为“python”的木桶。正在弹出
- mysql - 在 MariaDB 10.4.21 中,如何在没有会话的情况下将表锁定为只读?