Search in sources :

Example 31 with IFilter

use of de.janrufmonitor.repository.filter.IFilter in project janrufmonitor by tbrandt77.

the class Journal method createFieldEditors.

protected void createFieldEditors() {
    this.setTitle(this.m_i18n.getString(this.getNamespace(), "title", "label", this.m_language));
    this.noDefaultAndApplyButton();
    List l = new ArrayList();
    l.add(new IFilter[0]);
    IFilterManager jfm = new JournalFilterManager();
    Properties c = getRuntime().getConfigManagerFactory().getConfigManager().getProperties(this.getConfigNamespace());
    Iterator iter = c.keySet().iterator();
    String key = null;
    while (iter.hasNext()) {
        key = (String) iter.next();
        if (key.startsWith("filter_")) {
            String filter = c.getProperty(key);
            l.add(jfm.getFiltersFromString(filter));
        }
    }
    // added 2015/04/03: added runtime filters
    if (jfm.hasRuntimeFilters()) {
        IFilter[][] rf = jfm.getRuntimeFilters();
        if (rf != null && rf.length > 0) {
            for (int i = 0; i < rf.length; i++) l.add(rf[i]);
        }
    }
    // added 2015/04/01: sort filter list
    Collections.sort(l, new Comparator() {

        public int compare(Object f1, Object f2) {
            if (f1 != null && f2 != null && f1 instanceof IFilter[] && f2 instanceof IFilter[]) {
                if (((IFilter[]) f1).length == ((IFilter[]) f2).length) {
                    return (((IFilter[]) f2)[0].toString().compareTo(((IFilter[]) f1)[0].toString()));
                }
                if (((IFilter[]) f1).length < ((IFilter[]) f2).length)
                    return -1;
                return 1;
            }
            return 0;
        }
    });
    String[][] filters = new String[l.size()][2];
    for (int i = 0; i < l.size(); i++) {
        filters[i][0] = getFilterLabel(jfm, (IFilter[]) l.get(i));
        filters[i][1] = jfm.getFiltersToString((IFilter[]) l.get(i));
    }
    ComboFieldEditor cfe = new ComboFieldEditor(this.getConfigNamespace() + SEPARATOR + "filter", this.m_i18n.getString(getNamespace(), "filter", "label", this.m_language), filters, this.getFieldEditorParent());
    addField(cfe);
    StringFieldEditor sfe = new StringFieldEditor(getConfigNamespace() + SEPARATOR + "rt_filters_years", this.m_i18n.getString(this.getNamespace(), "rt_filters_years", "label", this.m_language), 2, this.getFieldEditorParent());
    sfe.setTextLimit(2);
    addField(sfe);
}
Also used : ArrayList(java.util.ArrayList) JournalFilterManager(de.janrufmonitor.ui.jface.application.journal.JournalFilterManager) Properties(java.util.Properties) ComboFieldEditor(org.eclipse.jface.preference.ComboFieldEditor) Comparator(java.util.Comparator) StringFieldEditor(org.eclipse.jface.preference.StringFieldEditor) IFilterManager(de.janrufmonitor.ui.jface.application.IFilterManager) IFilter(de.janrufmonitor.repository.filter.IFilter) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List)

Example 32 with IFilter

use of de.janrufmonitor.repository.filter.IFilter in project janrufmonitor by tbrandt77.

the class JournalFilterManager method getRuntimeFilters.

@Override
public IFilter[][] getRuntimeFilters() {
    String cfg = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(Journal.NAMESPACE, "rt_filters_years");
    int years = 1;
    if (cfg != null && cfg.length() > 0) {
        years = Integer.parseInt(cfg);
    }
    if (years < 0)
        return new IFilter[][] {};
    int c_y = Calendar.getInstance().get(Calendar.YEAR);
    int c_m = Calendar.getInstance().get(Calendar.MONTH);
    List filters = new ArrayList(years * 12 + years);
    for (int y = c_y - years; y <= c_y; y++) {
        filters.add(new YearFilter(y));
        int max_month = 12;
        if (y == c_y)
            max_month = c_m + 1;
        for (int m = 1; m <= max_month; m++) {
            filters.add(new MonthYearFilter(y, m));
        }
    }
    IFilter[][] filters2 = new IFilter[filters.size()][1];
    for (int i = 0; i < filters2.length; i++) filters2[i][0] = (IFilter) filters.get(i);
    return filters2;
}
Also used : IFilter(de.janrufmonitor.repository.filter.IFilter) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) YearFilter(de.janrufmonitor.repository.filter.YearFilter) MonthYearFilter(de.janrufmonitor.repository.filter.MonthYearFilter) MonthYearFilter(de.janrufmonitor.repository.filter.MonthYearFilter)

Example 33 with IFilter

use of de.janrufmonitor.repository.filter.IFilter in project janrufmonitor by tbrandt77.

the class Last10Calls method getConfiguration.

public Properties getConfiguration() {
    Properties saved = super.getConfiguration();
    Properties journalConfig = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperties(Journal.NAMESPACE);
    if (journalConfig != null && journalConfig.size() > 0) {
        saved.setProperty(JournalConfigConst.CFG_REPOSITORY, journalConfig.getProperty(JournalConfigConst.CFG_REPOSITORY));
    }
    IFilter[] filters = new IFilter[1];
    int count = 10;
    try {
        count = Integer.parseInt(saved.getProperty(CFG_COUNT, "10"));
    } catch (Exception e) {
    }
    filters[0] = new ItemCountFilter(count);
    saved.setProperty("filter", new JournalFilterManager().getFiltersToString(filters));
    return saved;
}
Also used : IFilter(de.janrufmonitor.repository.filter.IFilter) ItemCountFilter(de.janrufmonitor.repository.filter.ItemCountFilter) JournalFilterManager(de.janrufmonitor.ui.jface.application.journal.JournalFilterManager) Properties(java.util.Properties)

Aggregations

IFilter (de.janrufmonitor.repository.filter.IFilter)33 List (java.util.List)15 ArrayList (java.util.ArrayList)12 Iterator (java.util.Iterator)10 ICallList (de.janrufmonitor.framework.ICallList)8 IAttribute (de.janrufmonitor.framework.IAttribute)7 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)7 ICallerList (de.janrufmonitor.framework.ICallerList)7 AttributeFilter (de.janrufmonitor.repository.filter.AttributeFilter)7 ICaller (de.janrufmonitor.framework.ICaller)6 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)6 IReadCallRepository (de.janrufmonitor.repository.types.IReadCallRepository)6 Properties (java.util.Properties)6 Message (de.janrufmonitor.exception.Message)5 ICallManager (de.janrufmonitor.repository.ICallManager)5 HandlerException (de.janrufmonitor.service.commons.http.handler.HandlerException)5 JournalFilterManager (de.janrufmonitor.ui.jface.application.journal.JournalFilterManager)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 IMsn (de.janrufmonitor.framework.IMsn)4 ICallerManager (de.janrufmonitor.repository.ICallerManager)4