Search in sources :

Example 1 with DciSummaryTable

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

the class SummaryTableManager method editSummaryTable.

/**
 * Edit existing dataset
 */
private void editSummaryTable() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.size() != 1)
        return;
    final DciSummaryTableDescriptor d = (DciSummaryTableDescriptor) selection.getFirstElement();
    new ConsoleJob(Messages.get().SummaryTableManager_ReadJobName, this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final DciSummaryTable t = session.getDciSummaryTable(d.getId());
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    PropertyDialog dlg = PropertyDialog.createDialogOn(getSite().getShell(), null, t);
                    dlg.getShell().setText(Messages.get().SummaryTableManager_TitleEdit);
                    dlg.open();
                    d.updateFromTable(t);
                    viewer.update(d, null);
                }
            });
        }

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

Example 2 with DciSummaryTable

use of org.netxms.client.datacollection.DciSummaryTable 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 3 with DciSummaryTable

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

the class NXCSession method getDciSummaryTable.

/**
 * Get DCI summary table configuration.
 *
 * @param id DCI summary table ID.
 * @return The DciSummaryTable object
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public DciSummaryTable getDciSummaryTable(int id) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_SUMMARY_TABLE_DETAILS);
    msg.setFieldInt32(NXCPCodes.VID_SUMMARY_TABLE_ID, id);
    sendMessage(msg);
    return new DciSummaryTable(waitForRCC(msg.getMessageId()));
}
Also used : DciSummaryTable(org.netxms.client.datacollection.DciSummaryTable) NXCPMessage(org.netxms.base.NXCPMessage)

Example 4 with DciSummaryTable

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

the class SummaryTableManager method createSummaryTable.

/**
 * Create new loyalty program
 */
private void createSummaryTable(boolean isTableSource) {
    // $NON-NLS-1$ //$NON-NLS-2$
    DciSummaryTable t = new DciSummaryTable("", "", isTableSource);
    PropertyDialog dlg = PropertyDialog.createDialogOn(getSite().getShell(), null, t);
    if (dlg != null) {
        dlg.getShell().setText(Messages.get().SummaryTableManager_TitleCreate);
        dlg.open();
        if (t.getId() != 0) {
            // was saved to server
            DciSummaryTableDescriptor d = new DciSummaryTableDescriptor(t);
            descriptors.put(d.getId(), d);
            viewer.setInput(descriptors.values().toArray());
            viewer.setSelection(new StructuredSelection(d));
        }
    }
}
Also used : DciSummaryTable(org.netxms.client.datacollection.DciSummaryTable) PropertyDialog(org.eclipse.ui.internal.dialogs.PropertyDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) DciSummaryTableDescriptor(org.netxms.client.datacollection.DciSummaryTableDescriptor)

Aggregations

DciSummaryTable (org.netxms.client.datacollection.DciSummaryTable)4 DciSummaryTableDescriptor (org.netxms.client.datacollection.DciSummaryTableDescriptor)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 PropertyDialog (org.eclipse.ui.internal.dialogs.PropertyDialog)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 PartInitException (org.eclipse.ui.PartInitException)1 NXCPMessage (org.netxms.base.NXCPMessage)1 DciSummaryTableColumn (org.netxms.client.datacollection.DciSummaryTableColumn)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1