Package com.log4jviewer.filters

Examples of com.log4jviewer.filters.FilterItemModel


            public void handleEvent(final Event evt) {
                ISelection selection = tableViewer.getSelection();

                if (!selection.isEmpty()) {
                    TableItem eventItem = (TableItem) evt.item;
                    FilterItemModel evtFilterItemModel = (FilterItemModel) eventItem.getData();
                    int selectedItemIndex = filterRuleTable.getSelectionIndex();
                    FilterItemModel selectedFilterItemModel = (FilterItemModel) tableViewer
                            .getElementAt(selectedItemIndex);

                    if (selectedFilterItemModel.equals(evtFilterItemModel)) {
                        evt.detail |= SWT.SELECTED;
                    }
                }
            }
        });
View Full Code Here


                logicOperandColumnTitle,
                logicOperandColumnWidth);
        logicOperandColumn.setLabelProvider(new ColumnLabelProvider() {
            @Override
            public String getText(final Object element) {
                FilterItemModel filterItemModel = (FilterItemModel) element;
                FilterItemModel firstItem = (FilterItemModel) tableViewer.getElementAt(0);

                String logicOperand = "";

                if (!filterItemModel.equals(firstItem)) {
                    logicOperand = filterItemModel.getLogicOperand().getValue();
                    logger.debug("Filter's rule logic operand: {}", logicOperand);
                }
                return logicOperand;
            }
        });

        logicOperandColumn.setEditingSupport(new RulesLogicCellEditor(tableViewer));

        // 'Field type' filter's rule column
        final String fieldTypeColumnTitle = "Field type";
        final int fieldTypeColumnWidth = 85;
        TableViewerColumn fieldTypeColumn = createSingleColumn(tableViewer,
                fieldTypeColumnTitle,
                fieldTypeColumnWidth);
        fieldTypeColumn.setLabelProvider(new ColumnLabelProvider() {
            @Override
            public String getText(final Object element) {
                FilterItemModel filterItemModel = (FilterItemModel) element;
                String fieldType = filterItemModel.getFieldType().getValue();
                logger.debug("Filter's rule field type: {}", fieldType);
                return fieldType;
            }
        });
        fieldTypeColumn.setEditingSupport(new RulesFieldTypeCellEditor(tableViewer));

        // 'Include' filter's rule column
        final String includeColumnTitle = "Include";
        final int includeColumnWidth = 60;
        TableViewerColumn includeColumn = createSingleColumn(tableViewer, includeColumnTitle,
                includeColumnWidth);
        includeColumn.setLabelProvider(new ColumnLabelProvider() {
            @Override
            public String getText(final Object element) {
                FilterItemModel filterItemModel = (FilterItemModel) element;
                String filterItemInclude = FilterConstants.EXCLUDE;

                if (filterItemModel.isInclude()) {
                    filterItemInclude = FilterConstants.INCLUDE;
                }
                logger.debug("Filter's rule include: {}", filterItemInclude);
                return filterItemInclude;
            }

        });
        includeColumn.setEditingSupport(new RulesIncludeCellEditor(tableViewer));

        // 'Match pattern' filter's rule column
        final String patternColumnTitle = "Match pattern";
        final int patternColumnWidth = 250;
        TableViewerColumn matchPatternColumn = createSingleColumn(tableViewer,
                patternColumnTitle,
                patternColumnWidth);
        matchPatternColumn.setLabelProvider(new ColumnLabelProvider() {
            @Override
            public String getText(final Object element) {
                FilterItemModel filterItemModel = (FilterItemModel) element;
                String matchPattern = filterItemModel.getPattern();
                logger.debug("Filter's rule match pattern: {}", matchPattern);
                return matchPattern;
            }
        });
        matchPatternColumn.setEditingSupport(new RulesMatchPatternCellEditor(tableViewer));
View Full Code Here

        return currentImage;
    }

    private void doAddNewFilterItemButtonAction() {
        if (filterContentProvider.isSelectedFilterIndexValid()) {
            FilterItemModel filterItemModel = filterContentProvider.createFilterItem();
            tableViewer.add(filterItemModel);
        }
        checkAndSetAddButtonState();
    }
View Full Code Here

        return canEdit;
    }

    @Override
    protected Object getValue(final Object element) {
        FilterItemModel filterItemModel = (FilterItemModel) element;
        int logicOperandIndex = 0;

        for (int i = 0; i < FilterConstants.LOGIC_OPERANDS.length; i++) {
            if (filterItemModel.getLogicOperand().equals(FilterConstants.LOGIC_OPERANDS[i])) {
                logicOperandIndex = i;
                break;
            }
        }
        return logicOperandIndex;
View Full Code Here

        return logicOperandIndex;
    }

    @Override
    protected void setValue(final Object element, final Object value) {
        FilterItemModel item = (FilterItemModel) element;
        LogicOperand[] logicOperands = FilterItemModel.LogicOperand.values();
        item.setLogicOperand(logicOperands[(Integer) value]);
        tableViewer.update(item, null);
    }
View Full Code Here

        return true;
    }

    @Override
    protected Object getValue(final Object element) {
        FilterItemModel filterItemModel = (FilterItemModel) element;
        String includeItem;

        if (filterItemModel.isEnabled()) {
            includeItem = FilterConstants.INCLUDE;
        } else {
            includeItem = FilterConstants.EXCLUDE;
        }
        int includeIndex = 0;
View Full Code Here

        return includeIndex;
    }

    @Override
    protected void setValue(final Object element, final Object value) {
        FilterItemModel filterItemModel = (FilterItemModel) element;

        if ((FilterConstants.MATCH_PATTERN_INCLUDE[(Integer) value]).equals(FilterConstants.INCLUDE)) {
            filterItemModel.setInclude(true);
        } else {
            filterItemModel.setInclude(false);
        }
        tableViewer.update(element, null);
    }
View Full Code Here

        this.tableViewer = tableViewer;
    }

    @Override
    protected CellEditor getCellEditor(final Object element) {
        FilterItemModel filterItemModel = (FilterItemModel) element;
        CellEditor cellEditor = null;

        // Add Levels ComboBox for Level type
        if ((FilterConstants.LEVEL).equals(filterItemModel.getFieldType())) {
            cellEditor = new ComboBoxCellEditor(tableViewer.getTable(), FilterConstants.LOG_LEVELS,
                    SWT.READ_ONLY);
        } else {
            cellEditor = new TextCellEditor(tableViewer.getTable());

            // If need to enter Line number (Text with digits only)
            if ((FilterConstants.LINE).equals(filterItemModel.getFieldType())) {
                ((Text) cellEditor.getControl()).addVerifyListener(new VerifyListener() {
                    @Override
                    public void verifyText(final VerifyEvent e) {
                        // Here, we could use a RegExp such as the following
                        // if using JRE1.4 such as e.doit = e.text.matches("[\\-0-9]*");
 
View Full Code Here

        return true;
    }

    @Override
    protected Object getValue(final Object element) {
        FilterItemModel filterItemModel = (FilterItemModel) element;
        Object matchPattern = filterItemModel.getPattern();

        if (FilterConstants.LEVEL.equals(filterItemModel.getFieldType())) {
            matchPattern = 0;
        }
        // If used Free Text
        return matchPattern;
    }
View Full Code Here

        return matchPattern;
    }

    @Override
    protected void setValue(final Object element, final Object value) {
        FilterItemModel filterItemModel = (FilterItemModel) element;

        if (value instanceof Number) {
            // If ComboBox levels
            filterItemModel.setPattern(FilterConstants.LOG_LEVELS[(Integer) value]);
        } else {
            String matchPattern = String.valueOf(value);
            // If empty number line (Line type)
            if ((matchPattern.length() == 0) && FilterConstants.LINE.equals(filterItemModel.getFieldType())) {
                matchPattern = "0";
            }
            // If free text
            filterItemModel.setPattern(matchPattern);
        }
        tableViewer.update(element, null);
    }
View Full Code Here

TOP

Related Classes of com.log4jviewer.filters.FilterItemModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.