use of org.netxms.ui.eclipse.actionmanager.dialogs.helpers.ActionSelectionDialogLabelProvider in project netxms by netxms.
the class ActionSelectionDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
final Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
dialogArea.setLayout(layout);
viewer = new TableViewer(dialogArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new ActionSelectionDialogLabelProvider());
viewer.setComparator(new ViewerComparator() {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
return ((ServerAction) e1).getName().compareToIgnoreCase(((ServerAction) e2).getName());
}
});
final NXCSession session = ConsoleSharedData.getSession();
new ConsoleJob("Get server actions", null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final List<ServerAction> list = session.getActions();
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(list.toArray());
}
});
}
@Override
protected String getErrorMessage() {
return "Cannot get server actions";
}
}.start();
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 400;
viewer.getControl().setLayoutData(gd);
return dialogArea;
}
Aggregations