use of org.netxms.client.users.AbstractUserObject in project netxms by netxms.
the class LogLabelProvider method getColumnImage.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
*/
@Override
public Image getColumnImage(Object element, int columnIndex) {
final String value = ((TableRow) element).get(columnIndex).getValue();
switch(columns[columnIndex].getType()) {
case LogColumn.LC_SEVERITY:
try {
int severity = Integer.parseInt(value);
return StatusDisplayInfo.getStatusImage(severity);
} catch (NumberFormatException e) {
return null;
}
case LogColumn.LC_ALARM_STATE:
try {
int state = Integer.parseInt(value);
return alarmStateImages[state & Alarm.STATE_MASK];
} catch (NumberFormatException e) {
return null;
}
case LogColumn.LC_OBJECT_ID:
try {
long id = Long.parseLong(value);
AbstractObject object = session.findObjectById(id);
return (object != null) ? wbLabelProvider.getImage(object) : null;
} catch (NumberFormatException e) {
return null;
}
case LogColumn.LC_USER_ID:
try {
long id = Long.parseLong(value);
AbstractUserObject user = session.findUserDBObjectById(id);
return (user != null) ? wbLabelProvider.getImage(user) : null;
} catch (NumberFormatException e) {
return null;
}
default:
return null;
}
}
use of org.netxms.client.users.AbstractUserObject in project netxms by netxms.
the class UserManagementView method disableUser.
/**
* Disable user/group
*/
private void disableUser() {
final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
new ConsoleJob(Messages.get().UserManagementView_DeleteJobName, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (Object object : selection.toList()) {
((AbstractUserObject) object).setFlags(((AbstractUserObject) object).getFlags() | AbstractUserObject.DISABLED);
session.modifyUserDBObject(((AbstractUserObject) object), AbstractUserObject.MODIFY_FLAGS);
}
}
@Override
protected String getErrorMessage() {
return Messages.get().UserManagementView_DisableError;
}
}.start();
}
use of org.netxms.client.users.AbstractUserObject in project netxms by netxms.
the class UserManagementView method fillContextMenu.
/**
* Fill context menu
*
* @param mgr Menu manager
*/
protected void fillContextMenu(final IMenuManager mgr) {
final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
mgr.add(actionAddUser);
mgr.add(actionAddGroup);
mgr.add(new Separator());
boolean containDisabled = false;
boolean containEnabled = false;
boolean containLDAP = false;
for (Object object : selection.toList()) {
if (((AbstractUserObject) object).isDisabled())
containDisabled = true;
if (!((AbstractUserObject) object).isDisabled())
containEnabled = true;
if ((((AbstractUserObject) object).getFlags() & AbstractUserObject.LDAP_USER) != 0)
containLDAP = true;
}
if (containDisabled)
mgr.add(actionEnable);
if (containEnabled)
mgr.add(actionDisable);
if (containLDAP)
mgr.add(actionDetachUserFromLDAP);
final Object firstElement = selection.getFirstElement();
if (firstElement instanceof User && !containLDAP) {
mgr.add(actionChangePassword);
}
mgr.add(actionDeleteUser);
mgr.add(new Separator());
mgr.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
mgr.add(new Separator());
mgr.add(actionEditUser);
}
use of org.netxms.client.users.AbstractUserObject in project netxms by netxms.
the class UserManagementView method deleteUser.
/**
* Delete user or group
*/
private void deleteUser() {
final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
final String message = (selection.size() == 1) ? Messages.get().UserManagementView_ConfirmDeleteSingular : Messages.get().UserManagementView_ConfirmDeletePlural;
final Shell shell = getViewSite().getShell();
if (!MessageDialogHelper.openQuestion(shell, Messages.get().UserManagementView_ConfirmDeleteTitle, message)) {
return;
}
new ConsoleJob(Messages.get().UserManagementView_DeleteJobName, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (Object object : selection.toList()) {
session.deleteUserDBObject(((AbstractUserObject) object).getId());
}
}
@Override
protected String getErrorMessage() {
return Messages.get().UserManagementView_DeleteJobError;
}
}.start();
}
use of org.netxms.client.users.AbstractUserObject in project netxms by netxms.
the class UserManagementView method enableUser.
/**
* Enable user/group
*/
private void enableUser() {
final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
new ConsoleJob(Messages.get().UserManagementView_DeleteJobName, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (Object object : selection.toList()) {
((AbstractUserObject) object).setFlags(((AbstractUserObject) object).getFlags() & ~AbstractUserObject.DISABLED);
session.modifyUserDBObject(((AbstractUserObject) object), AbstractUserObject.MODIFY_FLAGS);
}
}
@Override
protected String getErrorMessage() {
return Messages.get().UserManagementView_EnableError;
}
}.start();
}
Aggregations