Search in sources :

Example 1 with ReportDefinition

use of org.netxms.client.reporting.ReportDefinition in project netxms by netxms.

the class ReportNavigator method refresh.

/**
 * Refresh reports tree
 */
private void refresh() {
    new ConsoleJob("Load Reports", null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final List<UUID> notGeneratedReport = new ArrayList<UUID>(0);
            final List<ReportDefinition> definitions = new ArrayList<ReportDefinition>();
            final List<UUID> reportIds = session.listReports();
            for (UUID reportId : reportIds) {
                try {
                    final ReportDefinition definition = session.getReportDefinition(reportId);
                    definitions.add(definition);
                } catch (NXCException e) {
                    if (e.getErrorCode() == RCC.INTERNAL_ERROR)
                        notGeneratedReport.add(reportId);
                }
            }
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    reportTree.setInput(definitions);
                    if (notGeneratedReport.size() > 0) {
                        String errorMessage = "Can't load compiled report: ";
                        for (int i = 0; i < notGeneratedReport.size(); i++) errorMessage += notGeneratedReport.get(i).toString() + (i == notGeneratedReport.size() - 1 ? "" : ", ");
                        MessageDialog.openError(null, "Error", errorMessage);
                    }
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return "Failed to load reports from the server";
        }
    }.start();
}
Also used : NXCException(org.netxms.client.NXCException) NXCException(org.netxms.client.NXCException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ArrayList(java.util.ArrayList) List(java.util.List) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) UUID(java.util.UUID) ReportDefinition(org.netxms.client.reporting.ReportDefinition)

Example 2 with ReportDefinition

use of org.netxms.client.reporting.ReportDefinition in project netxms by netxms.

the class ReportView method createPartControl.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    this.parentComposite = parent;
    selectionService = getSite().getWorkbenchWindow().getSelectionService();
    selectionListener = new ISelectionListener() {

        @Override
        public void selectionChanged(IWorkbenchPart part, ISelection selection) {
            if ((part instanceof ReportNavigator) && (selection instanceof IStructuredSelection) && !selection.isEmpty()) {
                ReportDefinition object = (ReportDefinition) ((IStructuredSelection) selection).getFirstElement();
                setObject(object);
            }
        }
    };
    selectionService.addSelectionListener(selectionListener);
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISelectionListener(org.eclipse.ui.ISelectionListener) ReportDefinition(org.netxms.client.reporting.ReportDefinition)

Example 3 with ReportDefinition

use of org.netxms.client.reporting.ReportDefinition in project netxms by netxms.

the class NXCSession method getReportDefinition.

/**
 * Get the report definition
 *
 * @param reportId The UUID of the report
 * @return The ReportDefinition object
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public ReportDefinition getReportDefinition(UUID reportId) throws NXCException, IOException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_RS_GET_REPORT_DEFINITION);
    msg.setField(NXCPCodes.VID_REPORT_DEFINITION, reportId);
    msg.setField(NXCPCodes.VID_LOCALE, Locale.getDefault().getLanguage());
    sendMessage(msg);
    return new ReportDefinition(reportId, waitForRCC(msg.getMessageId()));
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) ReportDefinition(org.netxms.client.reporting.ReportDefinition)

Aggregations

ReportDefinition (org.netxms.client.reporting.ReportDefinition)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 UUID (java.util.UUID)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 ISelectionListener (org.eclipse.ui.ISelectionListener)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1 NXCPMessage (org.netxms.base.NXCPMessage)1 NXCException (org.netxms.client.NXCException)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1