use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class UserManagementView method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
session = ConsoleSharedData.getSession();
final String[] names = { Messages.get().UserManagementView_Name, Messages.get().UserManagementView_Type, Messages.get().UserManagementView_FullName, Messages.get().UserManagementView_Description, Messages.get().UserManagementView_Source, Messages.get().UserManagementView_Authentication, Messages.get().UserManagementView_GUID, "LDAP DN", "Last Login", "Created" };
final int[] widths = { 100, 80, 180, 250, 80, 170, 250, 400, 250, 250 };
viewer = new SortableTableViewer(parent, names, widths, 0, SWT.UP, SortableTableViewer.DEFAULT_STYLE);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new UserLabelProvider());
viewer.setComparator(new UserComparator());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection != null) {
actionEditUser.setEnabled(selection.size() == 1);
actionChangePassword.setEnabled((selection.size() == 1) && (selection.getFirstElement() instanceof User));
actionDeleteUser.setEnabled(selection.size() > 0);
}
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
actionEditUser.run();
}
});
makeActions();
contributeToActionBars();
createPopupMenu();
// Listener for server's notifications
sessionListener = new SessionListener() {
@Override
public void notificationHandler(final SessionNotification n) {
if (n.getCode() == SessionNotification.USER_DB_CHANGED) {
viewer.getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
viewer.setInput(session.getUserDatabaseObjects());
if (editNewUser && (n.getSubCode() == SessionNotification.USER_DB_OBJECT_CREATED)) {
editNewUser = false;
viewer.setSelection(new StructuredSelection(n.getObject()), true);
actionEditUser.run();
}
}
});
}
}
};
// Request server to lock user database, and on success refresh view
new ConsoleJob(Messages.get().UserManagementView_OpenJobName, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.lockUserDatabase();
databaseLocked = true;
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(session.getUserDatabaseObjects());
session.addListener(sessionListener);
}
});
}
@Override
protected void jobFailureHandler() {
runInUIThread(new Runnable() {
@Override
public void run() {
UserManagementView.this.getViewSite().getPage().hideView(UserManagementView.this);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().UserManagementView_OpenJobError;
}
}.start();
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class SelectUserDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
session = ConsoleSharedData.getSession();
Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
dialogArea.setLayout(layout);
new Label(dialogArea, SWT.NONE).setText(Messages.get().SelectUserDialog_AvailableUsers);
final String[] columnNames = { Messages.get().SelectUserDialog_LoginName };
final int[] columnWidths = { 250 };
userList = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | (multiSelection ? SWT.MULTI : 0) | SWT.FULL_SELECTION);
userList.setContentProvider(new ArrayContentProvider());
userList.setLabelProvider(new WorkbenchLabelProvider());
userList.setComparator(new UserComparator());
userList.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
SelectUserDialog.this.okPressed();
}
});
userList.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return classFilter.isInstance(element);
}
});
userList.setInput(session.getUserDatabaseObjects());
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 300;
userList.getControl().setLayoutData(gd);
return dialogArea;
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer 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.widgets.SortableTableViewer in project netxms by netxms.
the class ActionManager method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
session = (NXCSession) ConsoleSharedData.getSession();
parent.setLayout(new FillLayout());
final String[] columnNames = { Messages.get().ActionManager_ColumnName, Messages.get().ActionManager_ColumnType, Messages.get().ActionManager_ColumnRcpt, Messages.get().ActionManager_ColumnSubj, Messages.get().ActionManager_ColumnData };
final int[] columnWidths = { 150, 90, 100, 120, 200 };
viewer = new SortableTableViewer(parent, columnNames, columnWidths, COLUMN_NAME, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new ActionLabelProvider());
viewer.setComparator(new ActionComparator());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection != null) {
actionEdit.setEnabled(selection.size() == 1);
actionDelete.setEnabled(selection.size() > 0);
}
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
actionEdit.run();
}
});
viewer.getTable().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
WidgetHelper.saveTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
}
});
createActions();
contributeToActionBars();
createPopupMenu();
session.addListener(this);
refreshActionList();
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class TunnelManager method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
parent.setLayout(new FormLayout());
// Create filter area
filterText = new FilterText(parent, SWT.NONE, null, true);
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
onFilterModify();
}
});
filterText.setCloseAction(new Action() {
@Override
public void run() {
enableFilter(false);
actionShowFilter.setChecked(false);
}
});
final String[] names = { "ID", "State", "Node", "IP address", "Channels", "System name", "Hostname", "Platform", "System information", "Agent version" };
final int[] widths = { 80, 80, 140, 150, 80, 150, 150, 250, 300, 150 };
viewer = new SortableTableViewer(parent, names, widths, 0, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new TunnelListLabelProvider());
viewer.setComparator(new TunnelListComparator());
filter = new TunnelManagerFilter();
viewer.addFilter(filter);
final IDialogSettings settings = Activator.getDefault().getDialogSettings();
initShowfilter = settings.getBoolean(ID + "initShowFilter");
WidgetHelper.restoreTableViewerSettings(viewer, settings, "TunnelManager");
viewer.getTable().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
WidgetHelper.saveTableViewerSettings(viewer, settings, "TunnelManager");
settings.put(ID + "initShowFilter", initShowfilter);
}
});
// Setup layout
FormData fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(filterText);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(100, 0);
viewer.getControl().setLayoutData(fd);
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
filterText.setLayoutData(fd);
createActions();
contributeToActionBars();
createPopupMenu();
activateContext();
// Set initial focus to filter input line
if (initShowfilter)
filterText.setFocus();
else
// Will hide filter area correctly
enableFilter(false);
refresh();
}
Aggregations