use of org.netxms.client.datacollection.WinPerfObject in project netxms by netxms.
the class WinPerfCounterSelectionDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
layout.verticalSpacing = WidgetHelper.INNER_SPACING;
dialogArea.setLayout(layout);
new Label(dialogArea, SWT.NONE).setText(Messages.get().WinPerfCounterSelectionDialog_ObjectsAndCounters);
new Label(dialogArea, SWT.NONE).setText(Messages.get().WinPerfCounterSelectionDialog_Instances);
objectTree = new TreeViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 400;
gd.widthHint = 350;
objectTree.getControl().setLayoutData(gd);
objectTree.setContentProvider(new WinPerfObjectTreeContentProvider());
objectTree.setLabelProvider(new WinPerfObjectTreeLabelProvider());
objectTree.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
String s1 = (e1 instanceof WinPerfCounter) ? ((WinPerfCounter) e1).getName() : ((WinPerfObject) e1).getName();
String s2 = (e2 instanceof WinPerfCounter) ? ((WinPerfCounter) e2).getName() : ((WinPerfObject) e2).getName();
return s1.compareToIgnoreCase(s2);
}
});
objectTree.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
onObjectSelection();
}
});
instanceList = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.widthHint = 350;
instanceList.getControl().setLayoutData(gd);
instanceList.setContentProvider(new ArrayContentProvider());
instanceList.setLabelProvider(new LabelProvider());
instanceList.setComparator(new StringComparator());
fillData();
return dialogArea;
}
use of org.netxms.client.datacollection.WinPerfObject in project netxms by netxms.
the class WinPerfCounterSelectionDialog method onObjectSelection.
/**
* Object tree selection handler
*/
private void onObjectSelection() {
IStructuredSelection selection = (IStructuredSelection) objectTree.getSelection();
if (selection.size() == 0) {
instanceList.setInput(new String[0]);
return;
}
WinPerfObject object = (selection.getFirstElement() instanceof WinPerfObject) ? (WinPerfObject) selection.getFirstElement() : ((WinPerfCounter) selection.getFirstElement()).getObject();
instanceList.setInput(object.getInstances());
instanceList.getTable().setEnabled(object.hasInstances());
selectedCounter = (selection.getFirstElement() instanceof WinPerfCounter) ? (WinPerfCounter) selection.getFirstElement() : null;
}
Aggregations