use of org.netxms.client.log.ColumnFilter in project netxms by netxms.
the class EventConditionEditor method createFilter.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.logviewer.widgets.ConditionEditor#createFilter()
*/
@Override
public ColumnFilter createFilter() {
ColumnFilter filter = new ColumnFilter(ColumnFilterType.EQUALS, eventCode);
filter.setNegated(getSelectedOperation() == 1);
return filter;
}
use of org.netxms.client.log.ColumnFilter in project netxms by netxms.
the class IntegerConditionEditor method createFilter.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.logviewer.widgets.ConditionEditor#createFilter()
*/
@Override
public ColumnFilter createFilter() {
long n1;
try {
n1 = Long.parseLong(value1.getText());
} catch (NumberFormatException e) {
n1 = 0;
}
ColumnFilter filter;
switch(getSelectedOperation()) {
case // not equal
1:
filter = new ColumnFilter(ColumnFilterType.EQUALS, n1);
filter.setNegated(true);
break;
case // less
2:
filter = new ColumnFilter(ColumnFilterType.LESS, n1);
break;
case // less or equal
3:
filter = new ColumnFilter(ColumnFilterType.GREATER, n1);
filter.setNegated(true);
break;
case // greater or equal
4:
filter = new ColumnFilter(ColumnFilterType.LESS, n1);
filter.setNegated(true);
break;
case // greater
5:
filter = new ColumnFilter(ColumnFilterType.GREATER, n1);
break;
case // between
6:
long n2;
try {
n2 = Long.parseLong(value2.getText());
} catch (NumberFormatException e) {
n2 = 0;
}
filter = new ColumnFilter(n1, n2);
break;
default:
filter = new ColumnFilter(ColumnFilterType.EQUALS, n1);
break;
}
return filter;
}
use of org.netxms.client.log.ColumnFilter in project netxms by netxms.
the class SeverityConditionEditor method createFilter.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.logviewer.widgets.ConditionEditor#createFilter()
*/
@Override
public ColumnFilter createFilter() {
switch(getSelectedOperation()) {
case // IS
0:
return new ColumnFilter(ColumnFilterType.EQUALS, severity.getSelectionIndex());
case // IS NOT
1:
ColumnFilter filter = new ColumnFilter(ColumnFilterType.EQUALS, severity.getSelectionIndex());
filter.setNegated(true);
return filter;
case // BELOW
2:
return new ColumnFilter(ColumnFilterType.LESS, severity.getSelectionIndex());
case // ABOVE
3:
return new ColumnFilter(ColumnFilterType.GREATER, severity.getSelectionIndex());
}
return new ColumnFilter(ColumnFilterType.EQUALS, severity.getSelectionIndex());
}
use of org.netxms.client.log.ColumnFilter in project netxms by netxms.
the class TimestampConditionEditor method createFilter.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.logviewer.widgets.ConditionEditor#createFilter()
*/
@Override
public ColumnFilter createFilter() {
final Calendar c = Calendar.getInstance();
c.clear();
c.set(datePicker1.getYear(), datePicker1.getMonth(), datePicker1.getDay(), timePicker1.getHours(), timePicker1.getMinutes(), timePicker1.getSeconds());
final long timestamp = c.getTimeInMillis() / 1000;
ColumnFilter filter;
switch(getSelectedOperation()) {
case // between
0:
c.clear();
c.set(datePicker2.getYear(), datePicker2.getMonth(), datePicker2.getDay(), timePicker2.getHours(), timePicker2.getMinutes(), timePicker2.getSeconds());
filter = new ColumnFilter(timestamp, c.getTimeInMillis() / 1000);
break;
case // before
1:
filter = new ColumnFilter(ColumnFilterType.LESS, timestamp);
break;
case // after
2:
filter = new ColumnFilter(ColumnFilterType.GREATER, timestamp);
break;
case // today
3:
c.clear();
c.set(datePicker1.getYear(), datePicker1.getMonth(), datePicker1.getDay(), 0, 0, 0);
long from = c.getTimeInMillis() / 1000;
c.clear();
c.set(datePicker1.getYear(), datePicker1.getMonth(), datePicker1.getDay(), 23, 59, 59);
long to = c.getTimeInMillis() / 1000;
filter = new ColumnFilter(from, to);
break;
default:
filter = new ColumnFilter(timestamp, timestamp);
break;
}
return filter;
}
use of org.netxms.client.log.ColumnFilter 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;
}
Aggregations