Search in sources :

Example 16 with AbstractUserObject

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;
    }
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) AbstractUserObject(org.netxms.client.users.AbstractUserObject)

Example 17 with AbstractUserObject

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();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) AbstractUserObject(org.netxms.client.users.AbstractUserObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 18 with AbstractUserObject

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);
}
Also used : User(org.netxms.client.users.User) AbstractUserObject(org.netxms.client.users.AbstractUserObject) AbstractUserObject(org.netxms.client.users.AbstractUserObject) GroupMarker(org.eclipse.jface.action.GroupMarker) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Separator(org.eclipse.jface.action.Separator)

Example 19 with AbstractUserObject

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();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) AbstractUserObject(org.netxms.client.users.AbstractUserObject) AbstractUserObject(org.netxms.client.users.AbstractUserObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 20 with AbstractUserObject

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();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) AbstractUserObject(org.netxms.client.users.AbstractUserObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Aggregations

AbstractUserObject (org.netxms.client.users.AbstractUserObject)26 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)13 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 SelectionListener (org.eclipse.swt.events.SelectionListener)9 GridData (org.eclipse.swt.layout.GridData)9 GridLayout (org.eclipse.swt.layout.GridLayout)9 Button (org.eclipse.swt.widgets.Button)9 Composite (org.eclipse.swt.widgets.Composite)9 SelectUserDialog (org.netxms.ui.eclipse.usermanager.dialogs.SelectUserDialog)9 Iterator (java.util.Iterator)7 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)7 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)7 FillLayout (org.eclipse.swt.layout.FillLayout)7 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)7 NXCSession (org.netxms.client.NXCSession)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)5 RowLayout (org.eclipse.swt.layout.RowLayout)5 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)5 WorkbenchLabelProvider (org.eclipse.ui.model.WorkbenchLabelProvider)4