Search in sources :

Example 6 with DciSummaryTableDescriptor

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

the class ExportFileBuilder method addSummaryTables.

/**
 * Add oject tools to list
 */
private void addSummaryTables() {
    SummaryTableSelectionDialog dlg = new SummaryTableSelectionDialog(getSite().getShell());
    if (dlg.open() == Window.OK) {
        for (DciSummaryTableDescriptor t : dlg.getSelection()) summaryTables.put(t.getId(), t);
        summaryTableViewer.setInput(summaryTables.values().toArray());
        setModified();
    }
}
Also used : SummaryTableSelectionDialog(org.netxms.ui.eclipse.serverconfig.dialogs.SummaryTableSelectionDialog) DciSummaryTableDescriptor(org.netxms.client.datacollection.DciSummaryTableDescriptor)

Example 7 with DciSummaryTableDescriptor

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

the class DataCollectionTest method testDciSummaryTables.

public void testDciSummaryTables() throws Exception {
    final NXCSession session = connect();
    DciSummaryTable t = new DciSummaryTable("test", "Test Table");
    t.getColumns().add(new DciSummaryTableColumn("Idle", "System.CPU.Idle"));
    t.getColumns().add(new DciSummaryTableColumn("I/O Wait", "System.CPU.IOWait"));
    int id = session.modifyDciSummaryTable(t);
    System.out.println("Assigned ID: " + id);
    t.setId(id);
    t.getColumns().add(new DciSummaryTableColumn("System", "^System\\.CPU\\.Sys.*", DciSummaryTableColumn.REGEXP_MATCH));
    session.modifyDciSummaryTable(t);
    List<DciSummaryTableDescriptor> list = session.listDciSummaryTables();
    for (DciSummaryTableDescriptor d : list) System.out.println(d.getId() + ": " + d.getMenuPath() + " " + d.getTitle());
    session.getDciSummaryTable(id);
    session.deleteDciSummaryTable(id);
    try {
        session.getDciSummaryTable(id);
        assertTrue(false);
    } catch (NXCException e) {
        if (e.getErrorCode() != RCC.INVALID_SUMMARY_TABLE_ID)
            throw e;
    }
    session.disconnect();
}
Also used : DciSummaryTable(org.netxms.client.datacollection.DciSummaryTable) DciSummaryTableColumn(org.netxms.client.datacollection.DciSummaryTableColumn) DciSummaryTableDescriptor(org.netxms.client.datacollection.DciSummaryTableDescriptor)

Example 8 with DciSummaryTableDescriptor

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

the class NXCSession method listDciSummaryTables.

/**
 * Get list of all configured DCI summary tables
 *
 * @return List of DciSummaryTableDescriptor objects
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public List<DciSummaryTableDescriptor> listDciSummaryTables() throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_SUMMARY_TABLES);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_ELEMENTS);
    final List<DciSummaryTableDescriptor> list = new ArrayList<DciSummaryTableDescriptor>(count);
    long varId = NXCPCodes.VID_ELEMENT_LIST_BASE;
    for (int i = 0; i < count; i++) {
        list.add(new DciSummaryTableDescriptor(response, varId));
        varId += 10;
    }
    return list;
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) ArrayList(java.util.ArrayList) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint) DciSummaryTableDescriptor(org.netxms.client.datacollection.DciSummaryTableDescriptor)

Example 9 with DciSummaryTableDescriptor

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

the class SummaryTableComparator method compare.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
	 */
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
    DciSummaryTableDescriptor d1 = (DciSummaryTableDescriptor) e1;
    DciSummaryTableDescriptor d2 = (DciSummaryTableDescriptor) e2;
    int result;
    switch(// $NON-NLS-1$
    (Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID")) {
        case SummaryTableManager.COLUMN_ID:
            result = d1.getId() - d2.getId();
            break;
        case SummaryTableManager.COLUMN_MENU_PATH:
            result = d1.getMenuPath().compareToIgnoreCase(d2.getMenuPath());
            break;
        case SummaryTableManager.COLUMN_TITLE:
            result = d1.getTitle().compareToIgnoreCase(d2.getTitle());
            break;
        default:
            result = 0;
            break;
    }
    return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
Also used : SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) DciSummaryTableDescriptor(org.netxms.client.datacollection.DciSummaryTableDescriptor)

Example 10 with DciSummaryTableDescriptor

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

the class SummaryTableManager method deleteSelection.

/**
 * Delete selected datasets
 */
private void deleteSelection() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.size() == 0)
        return;
    if (!MessageDialogHelper.openQuestion(getSite().getShell(), Messages.get().SummaryTableManager_ConfirmDelete, Messages.get().SummaryTableManager_Confirmation))
        return;
    final int[] idList = new int[selection.size()];
    int i = 0;
    for (Object o : selection.toList()) idList[i++] = ((DciSummaryTableDescriptor) o).getId();
    new ConsoleJob(Messages.get().SummaryTableManager_DeleteJobName, this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            for (int id : idList) session.deleteDciSummaryTable(id);
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    for (int id : idList) descriptors.remove(id);
                    viewer.setInput(descriptors.values().toArray());
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().SummaryTableManager_DeleteJobError;
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) DciSummaryTableDescriptor(org.netxms.client.datacollection.DciSummaryTableDescriptor) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

DciSummaryTableDescriptor (org.netxms.client.datacollection.DciSummaryTableDescriptor)13 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 PartInitException (org.eclipse.ui.PartInitException)3 DciSummaryTable (org.netxms.client.datacollection.DciSummaryTable)3 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)3 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)2 LabelProvider (org.eclipse.jface.viewers.LabelProvider)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 Viewer (org.eclipse.jface.viewers.Viewer)2 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 PropertyDialog (org.eclipse.ui.internal.dialogs.PropertyDialog)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 UUID (java.util.UUID)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1