use of org.netxms.ui.eclipse.serverconfig.views.helpers.MappingTableListComparator in project netxms by netxms.
the class MappingTables method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
final int[] widths = { 80, 160, 80, 400 };
final String[] names = { Messages.get().MappingTables_ColID, Messages.get().MappingTables_ColName, Messages.get().MappingTables_ColFlags, Messages.get().MappingTables_ColDescription };
viewer = new SortableTableViewer(parent, names, widths, COLUMN_NAME, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new MappingTableListLabelProvider());
viewer.setComparator(new MappingTableListComparator());
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
editTable();
}
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
actionEditTable.setEnabled(selection.size() == 1);
actionDeleteTables.setEnabled(selection.size() > 0);
}
});
final IDialogSettings settings = Activator.getDefault().getDialogSettings();
// $NON-NLS-1$
WidgetHelper.restoreTableViewerSettings(viewer, settings, "MappingTablesList");
viewer.getTable().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
// $NON-NLS-1$
WidgetHelper.saveTableViewerSettings(viewer, settings, "MappingTablesList");
}
});
createActions();
contributeToActionBars();
createPopupMenu();
session = ConsoleSharedData.getSession();
refresh(0);
final Display display = getSite().getShell().getDisplay();
listener = new SessionListener() {
@Override
public void notificationHandler(SessionNotification n) {
if (n.getCode() == SessionNotification.MAPPING_TABLE_UPDATED) {
final Integer id = (int) n.getSubCode();
display.asyncExec(new Runnable() {
@Override
public void run() {
refresh(id);
}
});
} else if (n.getCode() == SessionNotification.MAPPING_TABLE_DELETED) {
final Integer id = (int) n.getSubCode();
display.asyncExec(new Runnable() {
@Override
public void run() {
mappingTables.remove(id);
viewer.setInput(mappingTables.values().toArray());
}
});
}
}
};
session.addListener(listener);
}
Aggregations