use of org.netxms.ui.eclipse.datacollection.views.helpers.SummaryTableLabelProvider in project netxms by netxms.
the class SummaryTableManager method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
// Create interface area
tableArea = new Composite(parent, SWT.BORDER);
FormLayout formLayout = new FormLayout();
tableArea.setLayout(formLayout);
// Create filter
filterText = new FilterText(tableArea, SWT.NONE);
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
onFilterModify();
}
});
filterText.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
settings.put("SummaryTableManager.showFilter", initShowFilter);
}
});
final String[] names = { Messages.get().SummaryTableManager_ID, Messages.get().SummaryTableManager_MenuPath, Messages.get().SummaryTableManager_Title };
final int[] widths = { 90, 250, 200 };
viewer = new SortableTableViewer(tableArea, names, widths, COLUMN_MENU_PATH, SWT.UP, SortableTableViewer.DEFAULT_STYLE);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new SummaryTableLabelProvider());
viewer.setComparator(new SummaryTableComparator());
filter = new SummaryTableFilter();
viewer.addFilter(filter);
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
actionEdit.setEnabled(selection.size() == 1);
actionDelete.setEnabled(selection.size() > 0);
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
editSummaryTable();
}
});
// 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();
filterText.setCloseAction(actionShowFilter);
enableFilter(initShowFilter);
refresh();
listener = new SessionListener() {
@Override
public void notificationHandler(SessionNotification n) {
if (n.getCode() == SessionNotification.DCI_SUMMARY_TABLE_DELETED) {
final int id = (int) n.getSubCode();
getSite().getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (descriptors.remove(id) != null)
viewer.setInput(descriptors.values().toArray());
}
});
} else if (n.getCode() == SessionNotification.DCI_SUMMARY_TABLE_UPDATED) {
getSite().getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
refresh();
}
});
}
}
};
session.addListener(listener);
activateContext();
}
Aggregations