use of org.netxms.ui.eclipse.usermanager.dialogs.SelectUserDialog in project netxms by netxms.
the class TemplateGraph method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
settings = (GraphSettings) getElement().getAdapter(GraphSettings.class);
acl = new HashMap<Long, AccessListElement>(settings.getAccessList().size());
for (AccessListElement e : settings.getAccessList()) acl.put(e.getUserId(), new AccessListElement(e));
// Initiate loading of user manager plugin if it was not loaded before
// $NON-NLS-1$
Platform.getAdapterManager().loadAdapter(new AccessListElement(0, 0), "org.eclipse.ui.model.IWorkbenchAdapter");
Composite dialogArea = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
dialogArea.setLayout(layout);
name = new LabeledText(dialogArea, SWT.NONE, SWT.BORDER);
name.setLabel(Messages.get().PredefinedGraph_Name);
name.setText(settings.getName());
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
name.setLayoutData(gd);
Group users = new Group(dialogArea, SWT.NONE);
users.setText(Messages.get().PredefinedGraph_UsersAndGroups);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
users.setLayoutData(gd);
layout = new GridLayout();
users.setLayout(layout);
final String[] columnNames = { Messages.get().PredefinedGraph_LoginName, Messages.get().PredefinedGraph_Rights };
final int[] columnWidths = { 150, 100 };
userList = new SortableTableViewer(users, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
userList.setContentProvider(new ArrayContentProvider());
userList.setLabelProvider(new AccessListLabelProvider());
userList.setComparator(new AccessListComparator());
userList.setInput(acl.values().toArray());
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
userList.getControl().setLayoutData(gd);
Composite buttons = new Composite(users, SWT.NONE);
FillLayout buttonsLayout = new FillLayout();
buttonsLayout.spacing = WidgetHelper.INNER_SPACING;
buttons.setLayout(buttonsLayout);
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
gd.widthHint = 184;
buttons.setLayoutData(gd);
final Button addButton = new Button(buttons, SWT.PUSH);
addButton.setText(Messages.get().PredefinedGraph_Add);
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
SelectUserDialog dlg = new SelectUserDialog(TemplateGraph.this.getShell(), AbstractUserObject.class);
if (dlg.open() == Window.OK) {
AbstractUserObject[] selection = dlg.getSelection();
for (AbstractUserObject user : selection) acl.put(user.getId(), new AccessListElement(user.getId(), 0));
userList.setInput(acl.values().toArray());
}
}
});
final Button deleteButton = new Button(buttons, SWT.PUSH);
deleteButton.setText(Messages.get().PredefinedGraph_Delete);
deleteButton.setEnabled(false);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@SuppressWarnings("unchecked")
@Override
public void widgetSelected(SelectionEvent e) {
IStructuredSelection sel = (IStructuredSelection) userList.getSelection();
Iterator<AccessListElement> it = sel.iterator();
while (it.hasNext()) {
AccessListElement element = it.next();
acl.remove(element.getUserId());
}
userList.setInput(acl.values().toArray());
}
});
Group rights = new Group(dialogArea, SWT.NONE);
rights.setText(Messages.get().PredefinedGraph_AccessRights);
rights.setLayout(new RowLayout(SWT.VERTICAL));
gd = new GridData();
gd.grabExcessVerticalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
rights.setLayoutData(gd);
createAccessCheck(rights, Messages.get().PredefinedGraph_Read, GraphSettings.ACCESS_READ);
createAccessCheck(rights, Messages.get().PredefinedGraph_Modify, GraphSettings.ACCESS_WRITE);
userList.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
if (sel.size() == 1) {
enableAllChecks(true);
AccessListElement element = (AccessListElement) sel.getFirstElement();
int rights = element.getAccessRights();
for (int i = 0, mask = 1; i < 16; i++, mask <<= 1) {
Button check = accessChecks.get(mask);
if (check != null) {
check.setSelection((rights & mask) == mask);
}
}
} else {
enableAllChecks(false);
}
deleteButton.setEnabled(sel.size() > 0);
}
});
return dialogArea;
}
use of org.netxms.ui.eclipse.usermanager.dialogs.SelectUserDialog in project netxms by netxms.
the class Members method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
session = ConsoleSharedData.getSession();
Composite dialogArea = new Composite(parent, SWT.NONE);
object = (UserGroup) getElement().getAdapter(UserGroup.class);
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
final String[] columnNames = { Messages.get().Members_LoginName };
final int[] columnWidths = { 300 };
userList = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
userList.setContentProvider(new ArrayContentProvider());
userList.setLabelProvider(new WorkbenchLabelProvider());
userList.setComparator(new UserComparator());
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
userList.getControl().setLayoutData(gd);
Composite buttons = new Composite(dialogArea, SWT.NONE);
FillLayout buttonsLayout = new FillLayout();
buttonsLayout.spacing = WidgetHelper.INNER_SPACING;
buttons.setLayout(buttonsLayout);
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
gd.widthHint = 184;
buttons.setLayoutData(gd);
final Button addButton = new Button(buttons, SWT.PUSH);
addButton.setText(Messages.get().Members_Add);
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
SelectUserDialog dlg = new SelectUserDialog(Members.this.getShell(), AbstractUserObject.class);
if (dlg.open() == Window.OK) {
AbstractUserObject[] selection = dlg.getSelection();
for (AbstractUserObject user : selection) members.put(user.getId(), user);
userList.setInput(members.values().toArray(new AbstractUserObject[members.size()]));
}
}
});
final Button deleteButton = new Button(buttons, SWT.PUSH);
deleteButton.setText(Messages.get().Members_Delete);
deleteButton.setEnabled(false);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@SuppressWarnings("unchecked")
@Override
public void widgetSelected(SelectionEvent e) {
IStructuredSelection sel = (IStructuredSelection) userList.getSelection();
Iterator<AbstractUserObject> it = sel.iterator();
while (it.hasNext()) {
AbstractUserObject element = it.next();
members.remove(element.getId());
}
userList.setInput(members.values().toArray());
}
});
userList.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
deleteButton.setEnabled(!userList.getSelection().isEmpty());
}
});
// Initial data
for (long userId : object.getMembers()) {
final AbstractUserObject user = session.findUserDBObjectById(userId);
if (user != null) {
members.put(user.getId(), user);
}
}
userList.setInput(members.values().toArray());
return dialogArea;
}
use of org.netxms.ui.eclipse.usermanager.dialogs.SelectUserDialog in project netxms by netxms.
the class GroupMembership method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
session = ConsoleSharedData.getSession();
Composite dialogArea = new Composite(parent, SWT.NONE);
object = (User) getElement().getAdapter(User.class);
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
final String[] columnNames = { Messages.get().GroupMembership_ColName };
final int[] columnWidths = { 300 };
groupList = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
groupList.setContentProvider(new ArrayContentProvider());
groupList.setLabelProvider(new WorkbenchLabelProvider());
groupList.setComparator(new UserComparator());
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
groupList.getControl().setLayoutData(gd);
Composite buttons = new Composite(dialogArea, SWT.NONE);
FillLayout buttonsLayout = new FillLayout();
buttonsLayout.spacing = WidgetHelper.INNER_SPACING;
buttons.setLayout(buttonsLayout);
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
gd.widthHint = 184;
buttons.setLayoutData(gd);
final Button addButton = new Button(buttons, SWT.PUSH);
addButton.setText(Messages.get().Members_Add);
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
SelectUserDialog dlg = new SelectUserDialog(GroupMembership.this.getShell(), UserGroup.class);
if (dlg.open() == Window.OK) {
AbstractUserObject[] selection = dlg.getSelection();
for (AbstractUserObject user : selection) groups.put(user.getId(), user);
groupList.setInput(groups.values().toArray(new AbstractUserObject[groups.size()]));
}
}
});
final Button deleteButton = new Button(buttons, SWT.PUSH);
deleteButton.setText(Messages.get().Members_Delete);
deleteButton.setEnabled(false);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@SuppressWarnings("unchecked")
@Override
public void widgetSelected(SelectionEvent e) {
IStructuredSelection sel = (IStructuredSelection) groupList.getSelection();
Iterator<AbstractUserObject> it = sel.iterator();
while (it.hasNext()) {
AbstractUserObject element = it.next();
groups.remove(element.getId());
}
groupList.setInput(groups.values().toArray());
}
});
groupList.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
deleteButton.setEnabled(!groupList.getSelection().isEmpty());
}
});
// Initial data
for (long groupId : object.getGroups()) {
final AbstractUserObject group = session.findUserDBObjectById(groupId);
if (group != null) {
groups.put(group.getId(), group);
}
}
groupList.setInput(groups.values().toArray());
return dialogArea;
}
use of org.netxms.ui.eclipse.usermanager.dialogs.SelectUserDialog in project netxms by netxms.
the class ResponsibleUsers method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
final NXCSession session = ConsoleSharedData.getSession();
object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
userList = session.findUserDBObjectsByIds(object.getResponsibleUsers());
// Initiate loading of user manager plugin if it was not loaded before
// $NON-NLS-1$
Platform.getAdapterManager().loadAdapter(new AccessListElement(0, 0), "org.eclipse.ui.model.IWorkbenchAdapter");
Composite dialogArea = new Composite(parent, SWT.NONE);
dialogArea.setLayout(new GridLayout());
final String[] columnNames = { "Login Name" };
final int[] columnWidths = { 150 };
userTable = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
userTable.setContentProvider(new ArrayContentProvider());
userTable.setLabelProvider(new ResponsibleUsersLabelProvider());
userTable.setComparator(new ResponsibleUsersComparator());
userTable.setInput(userList.toArray());
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
userTable.getControl().setLayoutData(gd);
Composite buttons = new Composite(dialogArea, SWT.NONE);
FillLayout buttonsLayout = new FillLayout();
buttonsLayout.spacing = WidgetHelper.INNER_SPACING;
buttons.setLayout(buttonsLayout);
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
gd.widthHint = 184;
buttons.setLayoutData(gd);
final Button addButton = new Button(buttons, SWT.PUSH);
addButton.setText("Add...");
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
SelectUserDialog dlg = new SelectUserDialog(getShell(), AbstractUserObject.class);
if (dlg.open() == Window.OK) {
AbstractUserObject[] selection = dlg.getSelection();
for (AbstractUserObject user : selection) userList.add(user);
userTable.setInput(userList.toArray());
}
}
});
final Button deleteButton = new Button(buttons, SWT.PUSH);
deleteButton.setText("Delete");
deleteButton.setEnabled(false);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@SuppressWarnings("unchecked")
@Override
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) userTable.getSelection();
Iterator<AbstractUserObject> it = selection.iterator();
while (it.hasNext()) {
AbstractUserObject element = it.next();
userList.remove(element);
}
userTable.setInput(userList.toArray());
}
});
userTable.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
deleteButton.setEnabled(!selection.isEmpty());
}
});
return dialogArea;
}
Aggregations