Reputation: 295
I have a window with a table that allow users to add/edit and delete entries. The buttons will bring up a dialog window to perform the actions (Made with Window builder editor). However when the dialog window is up users can still interact with the table which could prove problematic. How can I "disable" interaction with the table window until the dialog window is closed?
Dialog 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);
}
}
Handler class to open dialog
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());
}
}
}
}
Upvotes: 0
Views: 227
Reputation: 111142
This isn't really what is traditionally known as a Dialog - it is another part opening in a separate window. e4 doesn't really have good support for dialogs done using the Application.e4xmi. Most dialogs are done using the JFace Dialog
class (org.eclipse.jface.dialogs.Dialog
) and aren't in the Application.e4xmi.
You may be able to adjust the behaviour of the window by overriding the window style using the styleOverride
(see here) to specify the SWT.APPLICATION_MODAL
flag. The override value for a dialog would be
styleOverride 68720
68720
is the numeric value of the SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.MAX | SWT.RESIZE
flags.
Upvotes: 1