java.lang.ClassCastException 当最大化 mpart
java.lang.ClassCastException when maximize mpart
我有一个带有一些不同 MPart 的 Eclipse E4 应用程序。现在,当我通过双击选项卡最大化 MPart 时,我得到了 ClassCastException。同样,当我再次最小化它时,将抛出相同的异常。我查看了错误,但在我的源代码中找不到可以抛出此异常的位置。有人可以帮我弄这个吗?您可以在下面找到错误的完整堆栈跟踪。
java.lang.ClassCastException: org.eclipse.swt.layout.GridData cannot be cast to org.eclipse.swt.layout.FillData
at org.eclipse.swt.layout.FillLayout.computeChildSize(FillLayout.java:145)
at org.eclipse.swt.layout.FillLayout.computeSize(FillLayout.java:123)
at org.eclipse.swt.widgets.Composite.computeSizeInPixels(Composite.java:238)
at org.eclipse.swt.widgets.Control.computeSize(Control.java:663)
at org.eclipse.ui.forms.widgets.LayoutComposite.computeSize(LayoutComposite.java:37)
at org.eclipse.ui.forms.widgets.SizeCache.controlComputeSize(SizeCache.java:391)
at org.eclipse.ui.forms.widgets.SizeCache.computeMinimumWidth(SizeCache.java:430)
at org.eclipse.ui.forms.widgets.SizeCache.computeSize(SizeCache.java:189)
at org.eclipse.ui.forms.widgets.ExpandableComposite$ExpandableLayout.computeSize(ExpandableComposite.java:476)
at org.eclipse.ui.forms.widgets.ExpandableComposite.computeSize(ExpandableComposite.java:964)
at org.eclipse.swt.layout.FillData.computeSize(FillData.java:26)
at org.eclipse.swt.layout.FillLayout.computeChildSize(FillLayout.java:152)
at org.eclipse.swt.layout.FillLayout.computeSize(FillLayout.java:123)
at org.eclipse.swt.widgets.Composite.computeSizeInPixels(Composite.java:238)
at org.eclipse.swt.widgets.Control.computeSize(Control.java:663)
at org.eclipse.swt.layout.FillData.computeSize(FillData.java:26)
at org.eclipse.swt.layout.FillLayout.computeChildSize(FillLayout.java:152)
at org.eclipse.swt.layout.FillLayout.computeSize(FillLayout.java:123)
at org.eclipse.swt.widgets.Composite.computeSizeInPixels(Composite.java:238)
at org.eclipse.swt.widgets.Control.computeSize(Control.java:663)
at org.eclipse.ui.forms.widgets.LayoutComposite.computeSize(LayoutComposite.java:37)
at org.eclipse.ui.forms.widgets.SizeCache.controlComputeSize(SizeCache.java:391)
at org.eclipse.ui.forms.widgets.SizeCache.computeMinimumWidth(SizeCache.java:430)
at org.eclipse.ui.forms.widgets.SizeCache.computeSize(SizeCache.java:189)
at org.eclipse.ui.forms.widgets.Form$FormLayout.computeSize(Form.java:143)
at org.eclipse.ui.forms.widgets.Form.computeSize(Form.java:200)
at org.eclipse.ui.forms.widgets.SizeCache.controlComputeSize(SizeCache.java:391)
at org.eclipse.ui.forms.widgets.SizeCache.computeSize(SizeCache.java:270)
at org.eclipse.ui.forms.widgets.SharedScrolledComposite.reflow(SharedScrolledComposite.java:188)
at org.eclipse.ui.forms.widgets.SharedScrolledComposite.scheduleReflow(SharedScrolledComposite.java:237)
at org.eclipse.ui.forms.widgets.SharedScrolledComposite.access(SharedScrolledComposite.java:221)
at org.eclipse.ui.forms.widgets.SharedScrolledComposite.handleEvent(SharedScrolledComposite.java:68)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4410)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1103)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1084)
at org.eclipse.swt.widgets.Control.WM_SIZE(Control.java:5459)
at org.eclipse.swt.widgets.Scrollable.WM_SIZE(Scrollable.java:367)
at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1783)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4866)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5102)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2547)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:88)
at org.eclipse.swt.widgets.Control.WM_WINDOWPOSCHANGED(Control.java:5691)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4879)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5102)
at org.eclipse.swt.internal.win32.OS.SetWindowPos(Native Method)
at org.eclipse.swt.widgets.Widget.SetWindowPos(Widget.java:1482)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3251)
at org.eclipse.swt.widgets.Composite.setBoundsInPixels(Composite.java:1099)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3212)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3208)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:3203)
at org.eclipse.swt.layout.FillLayout.layout(FillLayout.java:219)
at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1383)
at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1794)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4866)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5102)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2547)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:88)
at org.eclipse.swt.widgets.Control.WM_WINDOWPOSCHANGED(Control.java:5691)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4879)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5115)
at org.eclipse.swt.internal.win32.OS.SetWindowPos(Native Method)
at org.eclipse.swt.widgets.Widget.SetWindowPos(Widget.java:1482)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3251)
at org.eclipse.swt.widgets.Composite.setBoundsInPixels(Composite.java:1099)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3212)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3208)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3284)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:3280)
at org.eclipse.swt.custom.CTabFolderLayout.layout(CTabFolderLayout.java:116)
at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1383)
at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1794)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4866)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5102)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2547)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:88)
at org.eclipse.swt.widgets.Control.WM_WINDOWPOSCHANGED(Control.java:5691)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4879)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5115)
at org.eclipse.swt.internal.win32.OS.EndDeferWindowPos(Native Method)
at org.eclipse.swt.widgets.Composite.resizeChildren(Composite.java:1027)
at org.eclipse.swt.widgets.Composite.resizeChildren(Composite.java:993)
at org.eclipse.swt.widgets.Composite.setResizeChildren(Composite.java:1207)
at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1798)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4866)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5102)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2547)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:88)
at org.eclipse.swt.widgets.Control.WM_WINDOWPOSCHANGED(Control.java:5691)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4879)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5102)
at org.eclipse.swt.internal.win32.OS.SetWindowPos(Native Method)
at org.eclipse.swt.widgets.Widget.SetWindowPos(Widget.java:1482)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3251)
at org.eclipse.swt.widgets.Composite.setBoundsInPixels(Composite.java:1099)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3212)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3208)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:3203)
at org.eclipse.swt.layout.FillLayout.layout(FillLayout.java:204)
at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1383)
at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1794)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4866)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5102)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2547)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:88)
at org.eclipse.swt.widgets.Control.WM_WINDOWPOSCHANGED(Control.java:5691)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4879)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5115)
at org.eclipse.swt.internal.win32.OS.EndDeferWindowPos(Native Method)
at org.eclipse.swt.widgets.Composite.resizeChildren(Composite.java:1027)
at org.eclipse.swt.widgets.Composite.resizeChildren(Composite.java:993)
at org.eclipse.swt.widgets.Composite.setResizeChildren(Composite.java:1207)
at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1384)
at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1368)
at org.eclipse.swt.widgets.Composite.setLayoutDeferred(Composite.java:1167)
at org.eclipse.swt.widgets.Display.runDeferredLayouts(Display.java:4252)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3809)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1121)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:161)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
我的 class 将渲染屏幕:
public class UsersScreen 扩展 MainPart {
/**
* Table with all the users
*/
private CustomNatTable<PlatformUser> userTable;
/**
* Table with all the different roles
*/
private CustomNatTable<RoleCompanyViewModel> roleTable;
/**
* @see org.eclipse.e4.ui.workbench.modeling.EPartService
*/
private EPartService partService;
/**
* Part of this part
*/
private MPart part;
/**
* List of all the roleCompany view models
*/
private ArrayList<RoleCompanyViewModel> roleData = new ArrayList<>();
/**
* List of all the userroles
*/
private ArrayList<UserRole> allUserRoles;
/**
* UserPermissionRepository repository to search for the user permissions
*/
private UserPermissionRepository userPermissionrepo;
/**
* Parent composite of the userTable
*/
private Composite userComposite;
/**
* Parent composite of the roleTable
*/
private Composite roleComposite;
private IEclipseContext context;
/**
* Creates the components and place it on the screen
*
* @param parent
* Parent composite where the components need to be write on
* @param application
* @see org.eclipse.e4.ui.model.application.MApplication
* @param service
* @see org.eclipse.e4.ui.workbench.modeling.EModelService
* @param partService
* @see org.eclipse.e4.ui.workbench.modeling.EPartService
* @param context
* @see org.eclipse.e4.core.contexts.IEclipseContext
* @param currentPart
* MPart of the UserScreen
*/
@PostConstruct
public void createComposite(Composite parent, MApplication application, EModelService service,
EPartService partService, final IEclipseContext context, MPart currentPart) {
this.userPermissionrepo = new RepositoryManager<UserPermissionRepository>()
.getRepository(UserPermissionRepository.class.getSimpleName());
this.application = application;
this.service = service;
this.partService = partService;
this.part = currentPart;
this.context = context;
FormToolkit toolkit = new FormToolkit(parent.getDisplay());
ScrolledForm form = toolkit.createScrolledForm(parent);
form.setText("User Management");
Composite body = form.getBody();
toolkit.decorateFormHeading(form.getForm());
toolkit.paintBordersFor(body);
form.getBody().setLayout(new FillLayout(SWT.HORIZONTAL));
Composite container = new Composite(body, SWT.NONE);
container.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
container.setLayout(new FillLayout());
Section userSection = toolkit.createSection(container, Section.TITLE_BAR);
//userSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
toolkit.paintBordersFor(userSection);
userSection.setText("Users");
Section roleSection = toolkit.createSection(container, Section.TITLE_BAR);
//roleSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 2));
toolkit.paintBordersFor(roleSection);
roleSection.setText("Roles");
userComposite = toolkit.createComposite(userSection);
roleComposite = toolkit.createComposite(roleSection);
userComposite.setLayout(new FillLayout());
roleComposite.setLayout(new FillLayout());
userSection.setClient(userComposite);
roleSection.setClient(roleComposite);
showToolItems();
createUserTable(userComposite, context);
createRoleTable(roleComposite, context);
}
/**
* Creates the role table on the parent composite
*
* @param roleTableComposite
* Composite where the table must be on
* @param context
* @see org.eclipse.e4.core.contexts.IEclipseContext
*/
private void createRoleTable(Composite roleTableComposite, final IEclipseContext context) {
ArrayList<NATColumnDefinition> roleDefinitions = new ArrayList<>();
NATColumnDefinition assigned = new NATColumnDefinition("on");
assigned.setLabel("Assigned");
assigned.setAligment(Alignment.COLUMN_CENTER_LABEL);
assigned.setColumnWidth(60);
assigned.setData(NATColumnDefinition.DataType.BOOLEAN_COLUMN_LABEL);
if (!connectionClosed && userPermissionrepo.containsPermission("AssignRole")) {
assigned.setEditor(NATColumnDefinition.EditorType.BOOLEAN_EDITOR_COLUMN_LABEL);
}
NATColumnDefinition roleName = new NATColumnDefinition("name");
roleName.setLabel("Name");
roleName.setAligment(Alignment.COLUMN_CENTER_LABEL);
roleName.setColumnWidth(120);
NATColumnDefinition description = new NATColumnDefinition("description");
description.setLabel("Description");
description.setAligment(Alignment.COLUMN_CENTER_LABEL);
description.setColumnWidth(240);
roleDefinitions.add(assigned);
roleDefinitions.add(roleName);
roleDefinitions.add(description);
roleTable = new CustomNatTable<>(roleDefinitions, roleTableComposite);
roleTableComposite.setLayout(new FillLayout(SWT.HORIZONTAL));
roleTable.showFilterRow(true);
roleTable.setSortEnabled(true);
roleTable.showHeaderGroups(false);
roleTable.showHeaderGroupGroups(false);
roleTable.expandTree(true);
roleTable.treeFormat(new TreeFormat<RoleCompanyViewModel>(new Comparator<RoleCompanyViewModel>() {
@Override
public int compare(RoleCompanyViewModel obj1, RoleCompanyViewModel obj2) {
if (obj1.getCompanyId() != null && obj2.getCompanyId() != null) {
return obj1.getCompanyId().compareTo(obj2.getCompanyId());
}
return 0;
}
}));
roleTable.generate();
roleTable.addMoficationListener(new IModificationListener<RoleCompanyViewModel>() {
@Override
public void objectModified(RoleCompanyViewModel changedObject, RoleCompanyViewModel originalObject) {
PlatformUser user = userTable.getSelectedItem();
if (changedObject.getChildren().size() > 0) {
ArrayList<RoleCompanyViewModel> userRoles = (ArrayList<RoleCompanyViewModel>) changedObject
.getChildren();
for (RoleCompanyViewModel viewModel : userRoles) {
UserRole role = new UserRole();
role.setPlatformUser(user);
role.setCompany(viewModel.getCompanyObject());
role.setRole(viewModel.getRoleObject());
if (viewModel.isOn()) {
SendInsertHandler<UserRole> handler = new SendInsertHandler<>();
handler.execute(role, context, UserRole.class.getSimpleName(), "UserManagement", part);
} else {
SendRemoveHandle<UserRole> handler = new SendRemoveHandle<>();
handler.execute(role, context, UserRole.class.getSimpleName(), "UserManagement", part);
}
}
} else {
UserRole role = new UserRole();
role.setPlatformUser(user);
role.setCompany(changedObject.getCompanyObject());
role.setRole(changedObject.getRoleObject());
if (changedObject.isOn()) {
SendInsertHandler<UserRole> handler = new SendInsertHandler<>();
handler.execute(role, context, UserRole.class.getSimpleName(), "UserManagement", part);
} else {
SendRemoveHandle<UserRole> handler = new SendRemoveHandle<>();
handler.execute(role, context, UserRole.class.getSimpleName(), "UserManagement", part);
}
}
}
});
updateRoleTable(null, null);
}
/**
* Creates the user table on the parent composite
*
* @param userTableComposite
* Composite where the table must be on
* @param context
* @see org.eclipse.e4.core.contexts.IEclipseContext
*/
private void createUserTable(Composite userTableComposite, final IEclipseContext context) {
ArrayList<NATColumnDefinition> userColumnDefinitions = new ArrayList<>();
NATColumnDefinition userName = new NATColumnDefinition("userName");
userName.setLabel("User name");
userName.setAligment(Alignment.COLUMN_CENTER_LABEL);
userName.setColumnWidth(120);
NATColumnDefinition firstName = new NATColumnDefinition("firstName");
firstName.setLabel("First name");
firstName.setAligment(Alignment.COLUMN_CENTER_LABEL);
firstName.setColumnWidth(120);
NATColumnDefinition lastName = new NATColumnDefinition("lastName");
lastName.setLabel("Last name");
lastName.setAligment(Alignment.COLUMN_CENTER_LABEL);
lastName.setColumnWidth(120);
NATColumnDefinition domain = new NATColumnDefinition("domain");
domain.setLabel("Domain");
domain.setAligment(Alignment.COLUMN_CENTER_LABEL);
domain.setColumnWidth(60);
NATColumnDefinition active = new NATColumnDefinition("active");
active.setLabel("Active");
active.setAligment(Alignment.COLUMN_CENTER_LABEL);
active.setColumnWidth(60);
active.setDataType(NATColumnDefinition.DataType.BOOLEAN_COLUMN_LABEL);
if (!connectionClosed && userPermissionrepo.containsPermission("DeactivateUser")) {
active.setEditor(NATColumnDefinition.EditorType.BOOLEAN_EDITOR_COLUMN_LABEL);
}
if (!connectionClosed && userPermissionrepo.containsPermission("EditUser")) {
firstName.setEditor(NATColumnDefinition.EditorType.TEXT_EDITOR_COLUMN_LABEL);
lastName.setEditor(NATColumnDefinition.EditorType.TEXT_EDITOR_COLUMN_LABEL);
}
userColumnDefinitions.add(userName);
userColumnDefinitions.add(firstName);
userColumnDefinitions.add(lastName);
userColumnDefinitions.add(domain);
userColumnDefinitions.add(active);
userTable = new CustomNatTable<>(userColumnDefinitions, userTableComposite);
// userTableComposite.setLayout(new FillLayout(SWT.HORIZONTAL));
userTable.showFilterRow(true);
userTable.setSortEnabled(true);
userTable.showHeaderGroups(false);
userTable.showHeaderGroupGroups(false);
userTable.generate();
userTable.addSelectionListener(new SelectionListener<PlatformUser>() {
@Override
public void itemSelected(PlatformUser item) {
checkSelection(item);
roleTable.refresh(false);
}
@Override
public void gridSelectionChanged(GridSelection selection) {
}
});
userTable.addMoficationListener(new IModificationListener<PlatformUser>() {
@Override
public void objectModified(PlatformUser changedObject, PlatformUser originalObject) {
SendUpdateHandler<PlatformUser> handler = new SendUpdateHandler<>();
handler.execute(changedObject, originalObject, context, changedObject.getClass().getSimpleName(),
"UserManagement", partService.getActivePart());
}
});
userDataChanged(null);
}
/**
* Handles the close action from the window
*/
@PreDestroy
public void windowClose() {
CloseScreenHandler handler = new CloseScreenHandler();
handler.execute("UserManagement", part);
MDirectToolItem addUser = getToolItem(application, service, "addUserToolItem");
addUser.setToBeRendered(false);
addUser.setVisible(false);
}
/**
* Will be called when some data has been changed in the RoleRepository
*
* @param repo
* Platform user repository
*/
@Inject
@Optional
public void roleDataChanged(@UIEventTopic("RoleRepository") RoleRepository repo) {
updateRoleTable(repo, null);
}
/**
* Will be called when some data has been changed in the
* PlatformUserRepository
*
* @param data
* Platform user repository
*/
@Inject
@Optional
public void userDataChanged(@UIEventTopic("PlatformUserRepository") PlatformUserRepository data) {
if(data == null)
{
RepositoryManager<PlatformUserRepository> manager = new RepositoryManager<PlatformUserRepository>();
data = manager.getRepository(PlatformUserRepository.class.getSimpleName());
}
userTable.setItems(data.getAllData());
userTable.refresh(true);
}
/**
* Will be called when some data has been changed in the CompanyRepository.
*
* @param repo
* Company repository
*/
@Inject
@Optional
public void companyDataChanged(@UIEventTopic("CompanyRepository") CompanyRepository repo) {
updateRoleTable(null, repo);
}
/**
* Handles the change of UserRoleRepository object
*
* @param repo
* UserRoleRepository object that has been changed
*/
@Inject
@Optional
public void userRolDataChanged(@UIEventTopic("UserRoleRepository") UserRoleRepository repo) {
allUserRoles = repo.getAllData();
PlatformUser selectedUser = userTable.getSelectedItem();
if(selectedUser != null)
{
checkSelection(selectedUser);
roleTable.refresh(false);
}
}
}
我发现了问题。一些旧代码仍在我的 class 中用于绘制 Nattable。
代码是一个 GridFactory,它将 table 放在网格上。删除此行解决了我的问题。
我有一个带有一些不同 MPart 的 Eclipse E4 应用程序。现在,当我通过双击选项卡最大化 MPart 时,我得到了 ClassCastException。同样,当我再次最小化它时,将抛出相同的异常。我查看了错误,但在我的源代码中找不到可以抛出此异常的位置。有人可以帮我弄这个吗?您可以在下面找到错误的完整堆栈跟踪。
java.lang.ClassCastException: org.eclipse.swt.layout.GridData cannot be cast to org.eclipse.swt.layout.FillData
at org.eclipse.swt.layout.FillLayout.computeChildSize(FillLayout.java:145)
at org.eclipse.swt.layout.FillLayout.computeSize(FillLayout.java:123)
at org.eclipse.swt.widgets.Composite.computeSizeInPixels(Composite.java:238)
at org.eclipse.swt.widgets.Control.computeSize(Control.java:663)
at org.eclipse.ui.forms.widgets.LayoutComposite.computeSize(LayoutComposite.java:37)
at org.eclipse.ui.forms.widgets.SizeCache.controlComputeSize(SizeCache.java:391)
at org.eclipse.ui.forms.widgets.SizeCache.computeMinimumWidth(SizeCache.java:430)
at org.eclipse.ui.forms.widgets.SizeCache.computeSize(SizeCache.java:189)
at org.eclipse.ui.forms.widgets.ExpandableComposite$ExpandableLayout.computeSize(ExpandableComposite.java:476)
at org.eclipse.ui.forms.widgets.ExpandableComposite.computeSize(ExpandableComposite.java:964)
at org.eclipse.swt.layout.FillData.computeSize(FillData.java:26)
at org.eclipse.swt.layout.FillLayout.computeChildSize(FillLayout.java:152)
at org.eclipse.swt.layout.FillLayout.computeSize(FillLayout.java:123)
at org.eclipse.swt.widgets.Composite.computeSizeInPixels(Composite.java:238)
at org.eclipse.swt.widgets.Control.computeSize(Control.java:663)
at org.eclipse.swt.layout.FillData.computeSize(FillData.java:26)
at org.eclipse.swt.layout.FillLayout.computeChildSize(FillLayout.java:152)
at org.eclipse.swt.layout.FillLayout.computeSize(FillLayout.java:123)
at org.eclipse.swt.widgets.Composite.computeSizeInPixels(Composite.java:238)
at org.eclipse.swt.widgets.Control.computeSize(Control.java:663)
at org.eclipse.ui.forms.widgets.LayoutComposite.computeSize(LayoutComposite.java:37)
at org.eclipse.ui.forms.widgets.SizeCache.controlComputeSize(SizeCache.java:391)
at org.eclipse.ui.forms.widgets.SizeCache.computeMinimumWidth(SizeCache.java:430)
at org.eclipse.ui.forms.widgets.SizeCache.computeSize(SizeCache.java:189)
at org.eclipse.ui.forms.widgets.Form$FormLayout.computeSize(Form.java:143)
at org.eclipse.ui.forms.widgets.Form.computeSize(Form.java:200)
at org.eclipse.ui.forms.widgets.SizeCache.controlComputeSize(SizeCache.java:391)
at org.eclipse.ui.forms.widgets.SizeCache.computeSize(SizeCache.java:270)
at org.eclipse.ui.forms.widgets.SharedScrolledComposite.reflow(SharedScrolledComposite.java:188)
at org.eclipse.ui.forms.widgets.SharedScrolledComposite.scheduleReflow(SharedScrolledComposite.java:237)
at org.eclipse.ui.forms.widgets.SharedScrolledComposite.access(SharedScrolledComposite.java:221)
at org.eclipse.ui.forms.widgets.SharedScrolledComposite.handleEvent(SharedScrolledComposite.java:68)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4410)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1103)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1084)
at org.eclipse.swt.widgets.Control.WM_SIZE(Control.java:5459)
at org.eclipse.swt.widgets.Scrollable.WM_SIZE(Scrollable.java:367)
at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1783)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4866)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5102)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2547)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:88)
at org.eclipse.swt.widgets.Control.WM_WINDOWPOSCHANGED(Control.java:5691)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4879)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5102)
at org.eclipse.swt.internal.win32.OS.SetWindowPos(Native Method)
at org.eclipse.swt.widgets.Widget.SetWindowPos(Widget.java:1482)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3251)
at org.eclipse.swt.widgets.Composite.setBoundsInPixels(Composite.java:1099)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3212)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3208)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:3203)
at org.eclipse.swt.layout.FillLayout.layout(FillLayout.java:219)
at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1383)
at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1794)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4866)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5102)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2547)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:88)
at org.eclipse.swt.widgets.Control.WM_WINDOWPOSCHANGED(Control.java:5691)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4879)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5115)
at org.eclipse.swt.internal.win32.OS.SetWindowPos(Native Method)
at org.eclipse.swt.widgets.Widget.SetWindowPos(Widget.java:1482)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3251)
at org.eclipse.swt.widgets.Composite.setBoundsInPixels(Composite.java:1099)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3212)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3208)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3284)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:3280)
at org.eclipse.swt.custom.CTabFolderLayout.layout(CTabFolderLayout.java:116)
at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1383)
at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1794)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4866)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5102)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2547)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:88)
at org.eclipse.swt.widgets.Control.WM_WINDOWPOSCHANGED(Control.java:5691)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4879)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5115)
at org.eclipse.swt.internal.win32.OS.EndDeferWindowPos(Native Method)
at org.eclipse.swt.widgets.Composite.resizeChildren(Composite.java:1027)
at org.eclipse.swt.widgets.Composite.resizeChildren(Composite.java:993)
at org.eclipse.swt.widgets.Composite.setResizeChildren(Composite.java:1207)
at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1798)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4866)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5102)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2547)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:88)
at org.eclipse.swt.widgets.Control.WM_WINDOWPOSCHANGED(Control.java:5691)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4879)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5102)
at org.eclipse.swt.internal.win32.OS.SetWindowPos(Native Method)
at org.eclipse.swt.widgets.Widget.SetWindowPos(Widget.java:1482)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3251)
at org.eclipse.swt.widgets.Composite.setBoundsInPixels(Composite.java:1099)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3212)
at org.eclipse.swt.widgets.Control.setBoundsInPixels(Control.java:3208)
at org.eclipse.swt.widgets.Control.setBounds(Control.java:3203)
at org.eclipse.swt.layout.FillLayout.layout(FillLayout.java:204)
at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1383)
at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1794)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4866)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5102)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2547)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:88)
at org.eclipse.swt.widgets.Control.WM_WINDOWPOSCHANGED(Control.java:5691)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4879)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5115)
at org.eclipse.swt.internal.win32.OS.EndDeferWindowPos(Native Method)
at org.eclipse.swt.widgets.Composite.resizeChildren(Composite.java:1027)
at org.eclipse.swt.widgets.Composite.resizeChildren(Composite.java:993)
at org.eclipse.swt.widgets.Composite.setResizeChildren(Composite.java:1207)
at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1384)
at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1368)
at org.eclipse.swt.widgets.Composite.setLayoutDeferred(Composite.java:1167)
at org.eclipse.swt.widgets.Display.runDeferredLayouts(Display.java:4252)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3809)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1121)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:161)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
我的 class 将渲染屏幕:
public class UsersScreen 扩展 MainPart {
/**
* Table with all the users
*/
private CustomNatTable<PlatformUser> userTable;
/**
* Table with all the different roles
*/
private CustomNatTable<RoleCompanyViewModel> roleTable;
/**
* @see org.eclipse.e4.ui.workbench.modeling.EPartService
*/
private EPartService partService;
/**
* Part of this part
*/
private MPart part;
/**
* List of all the roleCompany view models
*/
private ArrayList<RoleCompanyViewModel> roleData = new ArrayList<>();
/**
* List of all the userroles
*/
private ArrayList<UserRole> allUserRoles;
/**
* UserPermissionRepository repository to search for the user permissions
*/
private UserPermissionRepository userPermissionrepo;
/**
* Parent composite of the userTable
*/
private Composite userComposite;
/**
* Parent composite of the roleTable
*/
private Composite roleComposite;
private IEclipseContext context;
/**
* Creates the components and place it on the screen
*
* @param parent
* Parent composite where the components need to be write on
* @param application
* @see org.eclipse.e4.ui.model.application.MApplication
* @param service
* @see org.eclipse.e4.ui.workbench.modeling.EModelService
* @param partService
* @see org.eclipse.e4.ui.workbench.modeling.EPartService
* @param context
* @see org.eclipse.e4.core.contexts.IEclipseContext
* @param currentPart
* MPart of the UserScreen
*/
@PostConstruct
public void createComposite(Composite parent, MApplication application, EModelService service,
EPartService partService, final IEclipseContext context, MPart currentPart) {
this.userPermissionrepo = new RepositoryManager<UserPermissionRepository>()
.getRepository(UserPermissionRepository.class.getSimpleName());
this.application = application;
this.service = service;
this.partService = partService;
this.part = currentPart;
this.context = context;
FormToolkit toolkit = new FormToolkit(parent.getDisplay());
ScrolledForm form = toolkit.createScrolledForm(parent);
form.setText("User Management");
Composite body = form.getBody();
toolkit.decorateFormHeading(form.getForm());
toolkit.paintBordersFor(body);
form.getBody().setLayout(new FillLayout(SWT.HORIZONTAL));
Composite container = new Composite(body, SWT.NONE);
container.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
container.setLayout(new FillLayout());
Section userSection = toolkit.createSection(container, Section.TITLE_BAR);
//userSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
toolkit.paintBordersFor(userSection);
userSection.setText("Users");
Section roleSection = toolkit.createSection(container, Section.TITLE_BAR);
//roleSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 2));
toolkit.paintBordersFor(roleSection);
roleSection.setText("Roles");
userComposite = toolkit.createComposite(userSection);
roleComposite = toolkit.createComposite(roleSection);
userComposite.setLayout(new FillLayout());
roleComposite.setLayout(new FillLayout());
userSection.setClient(userComposite);
roleSection.setClient(roleComposite);
showToolItems();
createUserTable(userComposite, context);
createRoleTable(roleComposite, context);
}
/**
* Creates the role table on the parent composite
*
* @param roleTableComposite
* Composite where the table must be on
* @param context
* @see org.eclipse.e4.core.contexts.IEclipseContext
*/
private void createRoleTable(Composite roleTableComposite, final IEclipseContext context) {
ArrayList<NATColumnDefinition> roleDefinitions = new ArrayList<>();
NATColumnDefinition assigned = new NATColumnDefinition("on");
assigned.setLabel("Assigned");
assigned.setAligment(Alignment.COLUMN_CENTER_LABEL);
assigned.setColumnWidth(60);
assigned.setData(NATColumnDefinition.DataType.BOOLEAN_COLUMN_LABEL);
if (!connectionClosed && userPermissionrepo.containsPermission("AssignRole")) {
assigned.setEditor(NATColumnDefinition.EditorType.BOOLEAN_EDITOR_COLUMN_LABEL);
}
NATColumnDefinition roleName = new NATColumnDefinition("name");
roleName.setLabel("Name");
roleName.setAligment(Alignment.COLUMN_CENTER_LABEL);
roleName.setColumnWidth(120);
NATColumnDefinition description = new NATColumnDefinition("description");
description.setLabel("Description");
description.setAligment(Alignment.COLUMN_CENTER_LABEL);
description.setColumnWidth(240);
roleDefinitions.add(assigned);
roleDefinitions.add(roleName);
roleDefinitions.add(description);
roleTable = new CustomNatTable<>(roleDefinitions, roleTableComposite);
roleTableComposite.setLayout(new FillLayout(SWT.HORIZONTAL));
roleTable.showFilterRow(true);
roleTable.setSortEnabled(true);
roleTable.showHeaderGroups(false);
roleTable.showHeaderGroupGroups(false);
roleTable.expandTree(true);
roleTable.treeFormat(new TreeFormat<RoleCompanyViewModel>(new Comparator<RoleCompanyViewModel>() {
@Override
public int compare(RoleCompanyViewModel obj1, RoleCompanyViewModel obj2) {
if (obj1.getCompanyId() != null && obj2.getCompanyId() != null) {
return obj1.getCompanyId().compareTo(obj2.getCompanyId());
}
return 0;
}
}));
roleTable.generate();
roleTable.addMoficationListener(new IModificationListener<RoleCompanyViewModel>() {
@Override
public void objectModified(RoleCompanyViewModel changedObject, RoleCompanyViewModel originalObject) {
PlatformUser user = userTable.getSelectedItem();
if (changedObject.getChildren().size() > 0) {
ArrayList<RoleCompanyViewModel> userRoles = (ArrayList<RoleCompanyViewModel>) changedObject
.getChildren();
for (RoleCompanyViewModel viewModel : userRoles) {
UserRole role = new UserRole();
role.setPlatformUser(user);
role.setCompany(viewModel.getCompanyObject());
role.setRole(viewModel.getRoleObject());
if (viewModel.isOn()) {
SendInsertHandler<UserRole> handler = new SendInsertHandler<>();
handler.execute(role, context, UserRole.class.getSimpleName(), "UserManagement", part);
} else {
SendRemoveHandle<UserRole> handler = new SendRemoveHandle<>();
handler.execute(role, context, UserRole.class.getSimpleName(), "UserManagement", part);
}
}
} else {
UserRole role = new UserRole();
role.setPlatformUser(user);
role.setCompany(changedObject.getCompanyObject());
role.setRole(changedObject.getRoleObject());
if (changedObject.isOn()) {
SendInsertHandler<UserRole> handler = new SendInsertHandler<>();
handler.execute(role, context, UserRole.class.getSimpleName(), "UserManagement", part);
} else {
SendRemoveHandle<UserRole> handler = new SendRemoveHandle<>();
handler.execute(role, context, UserRole.class.getSimpleName(), "UserManagement", part);
}
}
}
});
updateRoleTable(null, null);
}
/**
* Creates the user table on the parent composite
*
* @param userTableComposite
* Composite where the table must be on
* @param context
* @see org.eclipse.e4.core.contexts.IEclipseContext
*/
private void createUserTable(Composite userTableComposite, final IEclipseContext context) {
ArrayList<NATColumnDefinition> userColumnDefinitions = new ArrayList<>();
NATColumnDefinition userName = new NATColumnDefinition("userName");
userName.setLabel("User name");
userName.setAligment(Alignment.COLUMN_CENTER_LABEL);
userName.setColumnWidth(120);
NATColumnDefinition firstName = new NATColumnDefinition("firstName");
firstName.setLabel("First name");
firstName.setAligment(Alignment.COLUMN_CENTER_LABEL);
firstName.setColumnWidth(120);
NATColumnDefinition lastName = new NATColumnDefinition("lastName");
lastName.setLabel("Last name");
lastName.setAligment(Alignment.COLUMN_CENTER_LABEL);
lastName.setColumnWidth(120);
NATColumnDefinition domain = new NATColumnDefinition("domain");
domain.setLabel("Domain");
domain.setAligment(Alignment.COLUMN_CENTER_LABEL);
domain.setColumnWidth(60);
NATColumnDefinition active = new NATColumnDefinition("active");
active.setLabel("Active");
active.setAligment(Alignment.COLUMN_CENTER_LABEL);
active.setColumnWidth(60);
active.setDataType(NATColumnDefinition.DataType.BOOLEAN_COLUMN_LABEL);
if (!connectionClosed && userPermissionrepo.containsPermission("DeactivateUser")) {
active.setEditor(NATColumnDefinition.EditorType.BOOLEAN_EDITOR_COLUMN_LABEL);
}
if (!connectionClosed && userPermissionrepo.containsPermission("EditUser")) {
firstName.setEditor(NATColumnDefinition.EditorType.TEXT_EDITOR_COLUMN_LABEL);
lastName.setEditor(NATColumnDefinition.EditorType.TEXT_EDITOR_COLUMN_LABEL);
}
userColumnDefinitions.add(userName);
userColumnDefinitions.add(firstName);
userColumnDefinitions.add(lastName);
userColumnDefinitions.add(domain);
userColumnDefinitions.add(active);
userTable = new CustomNatTable<>(userColumnDefinitions, userTableComposite);
// userTableComposite.setLayout(new FillLayout(SWT.HORIZONTAL));
userTable.showFilterRow(true);
userTable.setSortEnabled(true);
userTable.showHeaderGroups(false);
userTable.showHeaderGroupGroups(false);
userTable.generate();
userTable.addSelectionListener(new SelectionListener<PlatformUser>() {
@Override
public void itemSelected(PlatformUser item) {
checkSelection(item);
roleTable.refresh(false);
}
@Override
public void gridSelectionChanged(GridSelection selection) {
}
});
userTable.addMoficationListener(new IModificationListener<PlatformUser>() {
@Override
public void objectModified(PlatformUser changedObject, PlatformUser originalObject) {
SendUpdateHandler<PlatformUser> handler = new SendUpdateHandler<>();
handler.execute(changedObject, originalObject, context, changedObject.getClass().getSimpleName(),
"UserManagement", partService.getActivePart());
}
});
userDataChanged(null);
}
/**
* Handles the close action from the window
*/
@PreDestroy
public void windowClose() {
CloseScreenHandler handler = new CloseScreenHandler();
handler.execute("UserManagement", part);
MDirectToolItem addUser = getToolItem(application, service, "addUserToolItem");
addUser.setToBeRendered(false);
addUser.setVisible(false);
}
/**
* Will be called when some data has been changed in the RoleRepository
*
* @param repo
* Platform user repository
*/
@Inject
@Optional
public void roleDataChanged(@UIEventTopic("RoleRepository") RoleRepository repo) {
updateRoleTable(repo, null);
}
/**
* Will be called when some data has been changed in the
* PlatformUserRepository
*
* @param data
* Platform user repository
*/
@Inject
@Optional
public void userDataChanged(@UIEventTopic("PlatformUserRepository") PlatformUserRepository data) {
if(data == null)
{
RepositoryManager<PlatformUserRepository> manager = new RepositoryManager<PlatformUserRepository>();
data = manager.getRepository(PlatformUserRepository.class.getSimpleName());
}
userTable.setItems(data.getAllData());
userTable.refresh(true);
}
/**
* Will be called when some data has been changed in the CompanyRepository.
*
* @param repo
* Company repository
*/
@Inject
@Optional
public void companyDataChanged(@UIEventTopic("CompanyRepository") CompanyRepository repo) {
updateRoleTable(null, repo);
}
/**
* Handles the change of UserRoleRepository object
*
* @param repo
* UserRoleRepository object that has been changed
*/
@Inject
@Optional
public void userRolDataChanged(@UIEventTopic("UserRoleRepository") UserRoleRepository repo) {
allUserRoles = repo.getAllData();
PlatformUser selectedUser = userTable.getSelectedItem();
if(selectedUser != null)
{
checkSelection(selectedUser);
roleTable.refresh(false);
}
}
}
我发现了问题。一些旧代码仍在我的 class 中用于绘制 Nattable。 代码是一个 GridFactory,它将 table 放在网格上。删除此行解决了我的问题。