use of org.netxms.ui.eclipse.usermanager.views.helpers.UserLabelProvider in project netxms by netxms.
the class UserManagementView method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
session = ConsoleSharedData.getSession();
final String[] names = { Messages.get().UserManagementView_Name, Messages.get().UserManagementView_Type, Messages.get().UserManagementView_FullName, Messages.get().UserManagementView_Description, Messages.get().UserManagementView_Source, Messages.get().UserManagementView_Authentication, Messages.get().UserManagementView_GUID, "LDAP DN", "Last Login", "Created" };
final int[] widths = { 100, 80, 180, 250, 80, 170, 250, 400, 250, 250 };
viewer = new SortableTableViewer(parent, names, widths, 0, SWT.UP, SortableTableViewer.DEFAULT_STYLE);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new UserLabelProvider());
viewer.setComparator(new UserComparator());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection != null) {
actionEditUser.setEnabled(selection.size() == 1);
actionChangePassword.setEnabled((selection.size() == 1) && (selection.getFirstElement() instanceof User));
actionDeleteUser.setEnabled(selection.size() > 0);
}
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
actionEditUser.run();
}
});
makeActions();
contributeToActionBars();
createPopupMenu();
// Listener for server's notifications
sessionListener = new SessionListener() {
@Override
public void notificationHandler(final SessionNotification n) {
if (n.getCode() == SessionNotification.USER_DB_CHANGED) {
viewer.getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
viewer.setInput(session.getUserDatabaseObjects());
if (editNewUser && (n.getSubCode() == SessionNotification.USER_DB_OBJECT_CREATED)) {
editNewUser = false;
viewer.setSelection(new StructuredSelection(n.getObject()), true);
actionEditUser.run();
}
}
});
}
}
};
// Request server to lock user database, and on success refresh view
new ConsoleJob(Messages.get().UserManagementView_OpenJobName, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.lockUserDatabase();
databaseLocked = true;
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(session.getUserDatabaseObjects());
session.addListener(sessionListener);
}
});
}
@Override
protected void jobFailureHandler() {
runInUIThread(new Runnable() {
@Override
public void run() {
UserManagementView.this.getViewSite().getPage().hideView(UserManagementView.this);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().UserManagementView_OpenJobError;
}
}.start();
}
Aggregations