use of org.netxms.client.users.User in project netxms by netxms.
the class General method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected void applyChanges(final boolean isApply) {
final String newName = new String(textName.getText());
final String newDescription = new String(textDescription.getText());
// $NON-NLS-1$
final String newFullName = (object instanceof User) ? textFullName.getText() : "";
// $NON-NLS-1$
final String newXmppId = (object instanceof User) ? textXmppId.getText() : "";
if (newName.equals(initialName) && newDescription.equals(initialDescription) && newFullName.equals(initialFullName) && newXmppId.equals(initialXmppId))
// Nothing to apply
return;
if (isApply)
setValid(false);
new ConsoleJob(Messages.get().General_JobTitle, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
initialName = newName;
initialFullName = newFullName;
initialDescription = newDescription;
initialXmppId = newXmppId;
int fields = AbstractUserObject.MODIFY_LOGIN_NAME | AbstractUserObject.MODIFY_DESCRIPTION;
object.setName(newName);
object.setDescription(newDescription);
if (object instanceof User) {
((User) object).setFullName(newFullName);
((User) object).setXmppId(newXmppId);
fields |= AbstractUserObject.MODIFY_FULL_NAME | AbstractUserObject.MODIFY_XMPP_ID;
}
session.modifyUserDBObject(object, fields);
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
General.this.setValid(true);
}
});
}
}
@Override
protected String getErrorMessage() {
return Messages.get().General_JobError;
}
}.start();
}
use of org.netxms.client.users.User in project netxms by netxms.
the class AccessControl method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite dialogArea = (Composite) super.createContents(parent);
dco = editor.getObject();
// Initiate loading of user manager plugin if it was not loaded before
// $NON-NLS-1$ //$NON-NLS-2$
Platform.getAdapterManager().loadAdapter(new User(""), "org.eclipse.ui.model.IWorkbenchAdapter");
// Build internal copy of access list
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
for (Long uid : dco.getAccessList()) {
AbstractUserObject o = session.findUserDBObjectById(uid);
if (o != null)
acl.add(o);
}
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.INNER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
Label label = new Label(dialogArea, SWT.NONE);
label.setText("Restrict access to the following users");
viewer = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new AccessListLabelProvider());
viewer.setComparator(new ObjectLabelComparator((ILabelProvider) viewer.getLabelProvider()));
viewer.getTable().setSortDirection(SWT.UP);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 300;
viewer.getTable().setLayoutData(gd);
setViewerInput();
Composite buttons = new Composite(dialogArea, SWT.NONE);
RowLayout buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttons.setLayout(buttonLayout);
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
gd.verticalIndent = WidgetHelper.OUTER_SPACING - WidgetHelper.INNER_SPACING;
buttons.setLayoutData(gd);
buttonAdd = new Button(buttons, SWT.PUSH);
buttonAdd.setText("Add");
buttonAdd.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
addUser();
}
});
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
buttonAdd.setLayoutData(rd);
buttonRemove = new Button(buttons, SWT.PUSH);
buttonRemove.setText("Remove");
buttonRemove.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
removeUsers();
}
});
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
buttonRemove.setLayoutData(rd);
return dialogArea;
}
Aggregations