use of org.netxms.ui.eclipse.nxsl.views.helpers.ScriptComparator in project netxms by netxms.
the class ScriptLibrary 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();
parent.setLayout(new FillLayout());
final String[] names = { Messages.get().ScriptLibrary_ColumnId, Messages.get().ScriptLibrary_ColumnName };
final int[] widths = { 70, 400 };
viewer = new SortableTableViewer(parent, names, widths, 0, SWT.UP, SortableTableViewer.DEFAULT_STYLE);
WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new ScriptLabelProvider());
viewer.setComparator(new ScriptComparator());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection != null) {
actionEdit.setEnabled(selection.size() == 1);
actionRename.setEnabled(selection.size() == 1);
actionDelete.setEnabled(selection.size() > 0);
actionCopyName.setEnabled(selection.size() == 1);
}
}
});
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);
}
});
activateContext();
createActions();
contributeToActionBars();
createPopupMenu();
refreshScriptList();
}
Aggregations