Search in sources :

Example 1 with WinPerfObject

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;
}
Also used : WinPerfObjectTreeLabelProvider(org.netxms.ui.eclipse.datacollection.dialogs.helpers.WinPerfObjectTreeLabelProvider) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) WinPerfObject(org.netxms.client.datacollection.WinPerfObject) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) StringComparator(org.netxms.ui.eclipse.tools.StringComparator) GridLayout(org.eclipse.swt.layout.GridLayout) WinPerfCounter(org.netxms.client.datacollection.WinPerfCounter) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) WinPerfObject(org.netxms.client.datacollection.WinPerfObject) TableViewer(org.eclipse.jface.viewers.TableViewer) WinPerfObjectTreeLabelProvider(org.netxms.ui.eclipse.datacollection.dialogs.helpers.WinPerfObjectTreeLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider) WinPerfObjectTreeContentProvider(org.netxms.ui.eclipse.datacollection.dialogs.helpers.WinPerfObjectTreeContentProvider)

Example 2 with WinPerfObject

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;
}
Also used : WinPerfCounter(org.netxms.client.datacollection.WinPerfCounter) WinPerfObject(org.netxms.client.datacollection.WinPerfObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

WinPerfCounter (org.netxms.client.datacollection.WinPerfCounter)2 WinPerfObject (org.netxms.client.datacollection.WinPerfObject)2 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 WinPerfObjectTreeContentProvider (org.netxms.ui.eclipse.datacollection.dialogs.helpers.WinPerfObjectTreeContentProvider)1 WinPerfObjectTreeLabelProvider (org.netxms.ui.eclipse.datacollection.dialogs.helpers.WinPerfObjectTreeLabelProvider)1 StringComparator (org.netxms.ui.eclipse.tools.StringComparator)1