Search in sources :

Example 6 with DciSummaryTableColumn

use of org.netxms.client.datacollection.DciSummaryTableColumn in project netxms by netxms.

the class NXCSession method queryAdHocDciSummaryTable.

/**
 * Query ad-hoc DCI summary table.
 *
 * @param baseObjectId base container object ID
 * @param columns columns for resulting table
 * @param function data aggregation function
 * @param periodStart start of query period
 * @param periodEnd end of query period
 * @param multiInstance The multiInstance flag
 * @return table with last values data for all nodes under given base container
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public Table queryAdHocDciSummaryTable(long baseObjectId, List<DciSummaryTableColumn> columns, AggregationFunction function, Date periodStart, Date periodEnd, boolean multiInstance) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_QUERY_ADHOC_SUMMARY_TABLE);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) baseObjectId);
    msg.setFieldInt32(NXCPCodes.VID_NUM_COLUMNS, columns.size());
    msg.setFieldInt16(NXCPCodes.VID_FUNCTION, (function != null) ? function.getValue() : AggregationFunction.LAST.getValue());
    msg.setField(NXCPCodes.VID_TIME_FROM, periodStart);
    msg.setField(NXCPCodes.VID_TIME_TO, periodEnd);
    // FIXME: define flags properly
    msg.setFieldInt32(NXCPCodes.VID_FLAGS, multiInstance ? 1 : 0);
    long id = NXCPCodes.VID_COLUMN_INFO_BASE;
    for (DciSummaryTableColumn c : columns) {
        c.fillMessage(msg, id);
        id += 10;
    }
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    return new Table(response);
}
Also used : DciSummaryTable(org.netxms.client.datacollection.DciSummaryTable) MappingTable(org.netxms.client.mt.MappingTable) NXCPMessage(org.netxms.base.NXCPMessage) DciSummaryTableColumn(org.netxms.client.datacollection.DciSummaryTableColumn)

Example 7 with DciSummaryTableColumn

use of org.netxms.client.datacollection.DciSummaryTableColumn in project netxms by netxms.

the class DCISummaryTableColumnSelector method selectionButtonHandler.

/* (non-Javadoc)
    * @see org.netxms.ui.eclipse.widgets.AbstractSelector#selectionButtonHandler()
    */
@Override
protected void selectionButtonHandler() {
    String[] valuesArray = null;
    if (sourceTable != null) {
        valuesArray = sourceTable.getColumnDisplayNames();
    }
    if (sourceSummaryTable != null) {
        List<DciSummaryTableColumn> column = sourceSummaryTable.getColumns();
        List<String> tmp = new ArrayList<String>();
        for (int i = 0; i < column.size(); i++) {
            tmp.add(column.get(i).getName());
        }
        valuesArray = tmp.toArray(new String[tmp.size()]);
    }
    TableColumnSelectionDialog dlg = new TableColumnSelectionDialog(getShell(), valuesArray);
    if (dlg.open() == Window.OK) {
        columnName = dlg.getSelectedName();
        setText(columnName == null ? emptySelectionName : columnName);
        fireModifyListeners();
    }
}
Also used : TableColumnSelectionDialog(org.netxms.ui.eclipse.dashboard.propertypages.TableColumnSelectionDialog) ArrayList(java.util.ArrayList) DciSummaryTableColumn(org.netxms.client.datacollection.DciSummaryTableColumn)

Example 8 with DciSummaryTableColumn

use of org.netxms.client.datacollection.DciSummaryTableColumn in project netxms by netxms.

the class SummaryTableColumns method moveUp.

/**
 * Move currently selected element up
 */
private void moveUp() {
    final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.size() == 1) {
        final DciSummaryTableColumn column = (DciSummaryTableColumn) selection.getFirstElement();
        int index = columns.indexOf(column);
        if (index > 0) {
            Collections.swap(columns, index - 1, index);
            viewer.setInput(columns.toArray());
            viewer.setSelection(new StructuredSelection(column));
        }
    }
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DciSummaryTableColumn(org.netxms.client.datacollection.DciSummaryTableColumn) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 9 with DciSummaryTableColumn

use of org.netxms.client.datacollection.DciSummaryTableColumn in project netxms by netxms.

the class SummaryTableColumns method addColumn.

/**
 * Add new column
 */
private void addColumn() {
    // $NON-NLS-1$ //$NON-NLS-2$
    DciSummaryTableColumn column = new DciSummaryTableColumn("", "", 0, ";");
    EditDciSummaryTableColumnDlg dlg = new EditDciSummaryTableColumnDlg(getShell(), column);
    if (dlg.open() == Window.OK) {
        columns.add(column);
        viewer.setInput(columns.toArray());
        viewer.setSelection(new StructuredSelection(column));
    }
}
Also used : EditDciSummaryTableColumnDlg(org.netxms.ui.eclipse.datacollection.dialogs.EditDciSummaryTableColumnDlg) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DciSummaryTableColumn(org.netxms.client.datacollection.DciSummaryTableColumn)

Example 10 with DciSummaryTableColumn

use of org.netxms.client.datacollection.DciSummaryTableColumn in project netxms by netxms.

the class SummaryTableColumns method createContents.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    table = (DciSummaryTable) getElement().getAdapter(DciSummaryTable.class);
    columns = new ArrayList<DciSummaryTableColumn>(table.getColumns().size());
    for (DciSummaryTableColumn c : table.getColumns()) columns.add(new DciSummaryTableColumn(c));
    Composite dialogArea = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.numColumns = 2;
    dialogArea.setLayout(layout);
    new Label(dialogArea, SWT.NONE).setText(Messages.get().SummaryTableColumns_Columns);
    viewer = new TableViewer(dialogArea, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.horizontalSpan = 2;
    viewer.getControl().setLayoutData(gd);
    setupColumnList();
    viewer.setInput(columns.toArray());
    Composite leftButtons = new Composite(dialogArea, SWT.NONE);
    gd = new GridData();
    gd.horizontalAlignment = SWT.LEFT;
    leftButtons.setLayoutData(gd);
    RowLayout buttonsLayout = new RowLayout(SWT.HORIZONTAL);
    buttonsLayout.marginBottom = 0;
    buttonsLayout.marginLeft = 0;
    buttonsLayout.marginRight = 0;
    buttonsLayout.marginTop = 0;
    buttonsLayout.spacing = WidgetHelper.OUTER_SPACING;
    buttonsLayout.fill = true;
    buttonsLayout.pack = false;
    leftButtons.setLayout(buttonsLayout);
    upButton = new Button(leftButtons, SWT.PUSH);
    upButton.setText(Messages.get().Thresholds_Up);
    upButton.setEnabled(false);
    upButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveUp();
        }
    });
    downButton = new Button(leftButtons, SWT.PUSH);
    downButton.setText(Messages.get().Thresholds_Down);
    downButton.setEnabled(false);
    downButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveDown();
        }
    });
    Composite buttons = new Composite(dialogArea, SWT.NONE);
    gd = new GridData();
    gd.horizontalAlignment = SWT.RIGHT;
    buttons.setLayoutData(gd);
    buttonsLayout = new RowLayout(SWT.HORIZONTAL);
    buttonsLayout.marginBottom = 0;
    buttonsLayout.marginLeft = 0;
    buttonsLayout.marginRight = 0;
    buttonsLayout.marginTop = 0;
    buttonsLayout.spacing = WidgetHelper.OUTER_SPACING;
    buttonsLayout.fill = true;
    buttonsLayout.pack = false;
    buttons.setLayout(buttonsLayout);
    importButton = new Button(buttons, SWT.PUSH);
    importButton.setText(Messages.get().SummaryTableColumns_Import);
    RowData rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    importButton.setLayoutData(rd);
    importButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            importColumns();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    addButton = new Button(buttons, SWT.PUSH);
    addButton.setText(Messages.get().Thresholds_Add);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    addButton.setLayoutData(rd);
    addButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            addColumn();
        }
    });
    modifyButton = new Button(buttons, SWT.PUSH);
    modifyButton.setText(Messages.get().Thresholds_Edit);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    modifyButton.setLayoutData(rd);
    modifyButton.setEnabled(false);
    modifyButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            editColumn();
        }
    });
    deleteButton = new Button(buttons, SWT.PUSH);
    deleteButton.setText(Messages.get().Thresholds_Delete);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    deleteButton.setLayoutData(rd);
    deleteButton.setEnabled(false);
    deleteButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            deleteColumns();
        }
    });
    /**
     * Selection change listener for thresholds list **
     */
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            int index = columns.indexOf(selection.getFirstElement());
            upButton.setEnabled((selection.size() == 1) && (index > 0));
            downButton.setEnabled((selection.size() == 1) && (index >= 0) && (index < columns.size() - 1));
            modifyButton.setEnabled(selection.size() == 1);
            deleteButton.setEnabled(selection.size() > 0);
        }
    });
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            editColumn();
        }
    });
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DciSummaryTableColumn(org.netxms.client.datacollection.DciSummaryTableColumn) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

DciSummaryTableColumn (org.netxms.client.datacollection.DciSummaryTableColumn)11 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 ArrayList (java.util.ArrayList)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)4 DciSummaryTable (org.netxms.client.datacollection.DciSummaryTable)3 Date (java.util.Date)2 EditDciSummaryTableColumnDlg (org.netxms.ui.eclipse.datacollection.dialogs.EditDciSummaryTableColumnDlg)2 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 RowData (org.eclipse.swt.layout.RowData)1 RowLayout (org.eclipse.swt.layout.RowLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1