use of org.netxms.ui.eclipse.perfview.propertypages.helpers.AccessListLabelProvider in project netxms by netxms.
the class PredefinedGraph 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(PredefinedGraph.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.perfview.propertypages.helpers.AccessListLabelProvider 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;
}
Aggregations