Search in sources :

Example 6 with ColumnFilter

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

the class AlarmHDStateConditionEditor method createFilter.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.logviewer.widgets.ConditionEditor#createFilter()
	 */
@Override
public ColumnFilter createFilter() {
    ColumnFilter filter = new ColumnFilter(ColumnFilterType.EQUALS, state.getSelectionIndex());
    filter.setNegated(getSelectedOperation() == 1);
    return filter;
}
Also used : ColumnFilter(org.netxms.client.log.ColumnFilter)

Example 7 with ColumnFilter

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

the class ColumnFilterEditor method buildFilterTree.

/**
 * Build filter tree
 */
public ColumnFilter buildFilterTree() {
    if (conditions.size() == 0)
        return null;
    if (conditions.size() > 1) {
        ColumnFilter root = new ColumnFilter();
        root.setOperation(booleanOperation);
        for (ConditionEditor e : conditions) {
            ColumnFilter filter = e.createFilter();
            root.addSubFilter(filter);
        }
        return root;
    } else {
        return conditions.get(0).createFilter();
    }
}
Also used : ColumnFilter(org.netxms.client.log.ColumnFilter)

Example 8 with ColumnFilter

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

the class ColumnFilterEditor method attachFilterBuilder.

/**
 * @param filterBuilder the filterBuilder to set
 */
public void attachFilterBuilder(FilterBuilder filterBuilder, ColumnFilter initialFilter) {
    this.filterBuilder = filterBuilder;
    if ((initialFilter == null) || (initialFilter.getSubFilters() == null)) {
        addCondition(null);
    } else {
        for (ColumnFilter f : initialFilter.getSubFilters()) {
            f.setOperation(f.getOperation());
            addCondition(f);
        }
    }
}
Also used : ColumnFilter(org.netxms.client.log.ColumnFilter)

Example 9 with ColumnFilter

use of org.netxms.client.log.ColumnFilter 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 10 with ColumnFilter

use of org.netxms.client.log.ColumnFilter 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

ColumnFilter (org.netxms.client.log.ColumnFilter)16 LogFilter (org.netxms.client.log.LogFilter)4 OrderingColumn (org.netxms.client.log.OrderingColumn)4 ArrayList (java.util.ArrayList)3 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 Calendar (java.util.Calendar)1