Search in sources :

Example 1 with LogFilter

use of org.netxms.client.log.LogFilter in project netxms by netxms.

the class LogViewer method init.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.ViewPart#init(org.eclipse.ui.IViewSite)
	 */
@Override
public void init(IViewSite site) throws PartInitException {
    super.init(site);
    session = (NXCSession) ConsoleSharedData.getSession();
    logName = site.getSecondaryId();
    // $NON-NLS-1$
    setPartName(Messages.getString("LogViewer_" + logName));
    // $NON-NLS-1$ //$NON-NLS-2$
    final ImageDescriptor img = Activator.getImageDescriptor("icons/" + logName + ".png");
    if (img != null) {
        titleImage = img.createImage();
        this.setTitleImage(titleImage);
    }
    filter = new LogFilter();
    // Initiate loading of user manager plugin if it was not loaded before
    // $NON-NLS-1$
    Platform.getAdapterManager().loadAdapter(new AccessListElement(0, 0), "org.eclipse.ui.model.IWorkbenchAdapter");
}
Also used : ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) LogFilter(org.netxms.client.log.LogFilter) AccessListElement(org.netxms.client.AccessListElement)

Example 2 with LogFilter

use of org.netxms.client.log.LogFilter in project netxms by netxms.

the class ShowObjectSnmpTrapLog method execute.

/* (non-Javadoc)
    * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
    */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    ISelection selection = window.getActivePage().getSelection();
    if ((selection == null) || !(selection instanceof IStructuredSelection) || selection.isEmpty())
        return null;
    ColumnFilter cf = new ColumnFilter();
    cf.setOperation(ColumnFilterSetOperation.OR);
    for (Object o : ((IStructuredSelection) selection).toList()) {
        if (!(o instanceof AbstractObject))
            continue;
        cf.addSubFilter(new ColumnFilter((o instanceof AbstractNode) ? ColumnFilterType.EQUALS : ColumnFilterType.CHILDOF, ((AbstractObject) o).getObjectId()));
    }
    try {
        // $NON-NLS-1$
        LogViewer view = (LogViewer) window.getActivePage().showView(LogViewer.ID, "SnmpTrapLog", IWorkbenchPage.VIEW_ACTIVATE);
        LogFilter filter = new LogFilter();
        // $NON-NLS-1$
        filter.setColumnFilter("object_id", cf);
        List<OrderingColumn> orderingColumns = new ArrayList<OrderingColumn>(1);
        // $NON-NLS-1$
        orderingColumns.add(new OrderingColumn("trap_timestamp", Messages.get().ShowObjectSnmpTrapLog_Time, true));
        filter.setOrderingColumns(orderingColumns);
        view.queryWithFilter(filter);
    } catch (PartInitException e) {
        MessageDialogHelper.openError(window.getShell(), Messages.get().ShowObjectSnmpTrapLog_Error, String.format(Messages.get().ShowObjectSnmpTrapLog_ErrorOpenLogViewer, e.getMessage()));
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) AbstractNode(org.netxms.client.objects.AbstractNode) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ColumnFilter(org.netxms.client.log.ColumnFilter) AbstractObject(org.netxms.client.objects.AbstractObject) ISelection(org.eclipse.jface.viewers.ISelection) AbstractObject(org.netxms.client.objects.AbstractObject) LogViewer(org.netxms.ui.eclipse.logviewer.views.LogViewer) PartInitException(org.eclipse.ui.PartInitException) OrderingColumn(org.netxms.client.log.OrderingColumn) LogFilter(org.netxms.client.log.LogFilter)

Example 3 with LogFilter

use of org.netxms.client.log.LogFilter in project netxms by netxms.

the class LogTest method testAuditLog.

public void testAuditLog() throws Exception {
    final NXCSession session = connect();
    final Log log = session.openServerLog("AuditLog");
    final LogFilter filter = new LogFilter();
    ArrayList<OrderingColumn> orderingColumns = new ArrayList<OrderingColumn>(1);
    orderingColumns.add(new OrderingColumn(log.getColumn("record_id"), true));
    filter.setOrderingColumns(orderingColumns);
    log.query(filter);
    System.out.println("Number of records in result set: " + log.getNumRecords());
    final Table data = log.retrieveData(0, 15);
    for (int i = 0; i < data.getRowCount(); i++) {
        TableRow row = data.getRow(i);
        System.out.println("ROW " + i + ": (" + row.get(0).getValue() + ") " + row.get(5).getValue());
    }
    log.close();
}
Also used : Log(org.netxms.client.log.Log) ArrayList(java.util.ArrayList) OrderingColumn(org.netxms.client.log.OrderingColumn) LogFilter(org.netxms.client.log.LogFilter)

Example 4 with LogFilter

use of org.netxms.client.log.LogFilter in project netxms by netxms.

the class ShowObjectEvents method execute.

/* (non-Javadoc)
    * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
    */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    ISelection selection = window.getActivePage().getSelection();
    if ((selection == null) || !(selection instanceof IStructuredSelection) || selection.isEmpty())
        return null;
    ColumnFilter cf = new ColumnFilter();
    cf.setOperation(ColumnFilterSetOperation.OR);
    for (Object o : ((IStructuredSelection) selection).toList()) {
        if (!(o instanceof AbstractObject))
            continue;
        cf.addSubFilter(new ColumnFilter((o instanceof AbstractNode) ? ColumnFilterType.EQUALS : ColumnFilterType.CHILDOF, ((AbstractObject) o).getObjectId()));
    }
    try {
        // $NON-NLS-1$
        LogViewer view = (LogViewer) window.getActivePage().showView(LogViewer.ID, "EventLog", IWorkbenchPage.VIEW_ACTIVATE);
        LogFilter filter = new LogFilter();
        // $NON-NLS-1$
        filter.setColumnFilter("event_source", cf);
        List<OrderingColumn> orderingColumns = new ArrayList<OrderingColumn>(1);
        // $NON-NLS-1$
        orderingColumns.add(new OrderingColumn("event_timestamp", Messages.get().ShowObjectEvents_Time, true));
        filter.setOrderingColumns(orderingColumns);
        view.queryWithFilter(filter);
    } catch (PartInitException e) {
        MessageDialogHelper.openError(window.getShell(), Messages.get().ShowObjectEvents_Error, String.format(Messages.get().ShowObjectEvents_CannotOpenLogViewer, e.getMessage()));
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) AbstractNode(org.netxms.client.objects.AbstractNode) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ColumnFilter(org.netxms.client.log.ColumnFilter) AbstractObject(org.netxms.client.objects.AbstractObject) ISelection(org.eclipse.jface.viewers.ISelection) AbstractObject(org.netxms.client.objects.AbstractObject) LogViewer(org.netxms.ui.eclipse.logviewer.views.LogViewer) PartInitException(org.eclipse.ui.PartInitException) OrderingColumn(org.netxms.client.log.OrderingColumn) LogFilter(org.netxms.client.log.LogFilter)

Example 5 with LogFilter

use of org.netxms.client.log.LogFilter in project netxms by netxms.

the class ShowObjectSyslog method execute.

/* (non-Javadoc)
    * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
    */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    ISelection selection = window.getActivePage().getSelection();
    if ((selection == null) || !(selection instanceof IStructuredSelection) || selection.isEmpty())
        return null;
    ColumnFilter cf = new ColumnFilter();
    cf.setOperation(ColumnFilterSetOperation.OR);
    for (Object o : ((IStructuredSelection) selection).toList()) {
        if (!(o instanceof AbstractObject))
            continue;
        cf.addSubFilter(new ColumnFilter((o instanceof AbstractNode) ? ColumnFilterType.EQUALS : ColumnFilterType.CHILDOF, ((AbstractObject) o).getObjectId()));
    }
    try {
        // $NON-NLS-1$
        LogViewer view = (LogViewer) window.getActivePage().showView(LogViewer.ID, "syslog", IWorkbenchPage.VIEW_ACTIVATE);
        LogFilter filter = new LogFilter();
        // $NON-NLS-1$
        filter.setColumnFilter("source_object_id", cf);
        List<OrderingColumn> orderingColumns = new ArrayList<OrderingColumn>(1);
        // $NON-NLS-1$
        orderingColumns.add(new OrderingColumn("msg_timestamp", Messages.get().ShowObjectSyslog_Time, true));
        filter.setOrderingColumns(orderingColumns);
        view.queryWithFilter(filter);
    } catch (PartInitException e) {
        MessageDialogHelper.openError(window.getShell(), Messages.get().ShowObjectSyslog_Error, String.format(Messages.get().ShowObjectSyslog_ErrorOpenLogViewer, e.getMessage()));
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) AbstractNode(org.netxms.client.objects.AbstractNode) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ColumnFilter(org.netxms.client.log.ColumnFilter) AbstractObject(org.netxms.client.objects.AbstractObject) ISelection(org.eclipse.jface.viewers.ISelection) AbstractObject(org.netxms.client.objects.AbstractObject) LogViewer(org.netxms.ui.eclipse.logviewer.views.LogViewer) PartInitException(org.eclipse.ui.PartInitException) OrderingColumn(org.netxms.client.log.OrderingColumn) LogFilter(org.netxms.client.log.LogFilter)

Aggregations

LogFilter (org.netxms.client.log.LogFilter)6 OrderingColumn (org.netxms.client.log.OrderingColumn)5 ArrayList (java.util.ArrayList)4 ColumnFilter (org.netxms.client.log.ColumnFilter)4 ISelection (org.eclipse.jface.viewers.ISelection)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)3 PartInitException (org.eclipse.ui.PartInitException)3 AbstractNode (org.netxms.client.objects.AbstractNode)3 AbstractObject (org.netxms.client.objects.AbstractObject)3 LogViewer (org.netxms.ui.eclipse.logviewer.views.LogViewer)3 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 AccessListElement (org.netxms.client.AccessListElement)1 Log (org.netxms.client.log.Log)1