Search in sources :

Example 6 with IConfigManager

use of de.janrufmonitor.framework.configuration.IConfigManager in project janrufmonitor by tbrandt77.

the class Formatter method getParsedDate.

/**
 * Parses date object in the specified text representation.
 * The wildcard definitions are taken for parsing.
 *
 * @param text text to parse
 * @param date object to get the information from
 * @return parsed text
 * @deprecated
 */
private String getParsedDate(String text, Date date) {
    if (date == null)
        return text;
    IConfigManager cfg = this.m_runtime.getConfigManagerFactory().getConfigManager();
    if (this.containString(text, IJAMConst.GLOBAL_VARIABLE_DATE)) {
        SimpleDateFormat formatter = new SimpleDateFormat(cfg.getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_VARIABLE_DATE));
        String datetext = formatter.format(date);
        text = StringUtils.replaceString(text, IJAMConst.GLOBAL_VARIABLE_DATE, datetext);
        text = text.trim();
    }
    if (this.containString(text, IJAMConst.GLOBAL_VARIABLE_TIME)) {
        SimpleDateFormat formatter = new SimpleDateFormat(cfg.getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_VARIABLE_TIME));
        String timetext = formatter.format(date);
        text = StringUtils.replaceString(text, IJAMConst.GLOBAL_VARIABLE_TIME, timetext);
        text = text.trim();
    }
    return text;
}
Also used : IConfigManager(de.janrufmonitor.framework.configuration.IConfigManager) SimpleDateFormat(java.text.SimpleDateFormat)

Example 7 with IConfigManager

use of de.janrufmonitor.framework.configuration.IConfigManager in project janrufmonitor by tbrandt77.

the class Formatter method getParsedCaller.

/**
 * Parses caller object in the specified text representation.
 * The wildcard definitions are taken for parsing.
 *
 * @param text text to parse
 * @param caller object to get the information from
 * @return parsed text
 * @deprecated
 */
public String getParsedCaller(String text, ICaller caller) {
    if (caller == null)
        return text;
    IConfigManager cfg = this.m_runtime.getConfigManagerFactory().getConfigManager();
    // komplex types
    String callernameExpression = cfg.getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_VARIABLE_CALLERNAME);
    text = StringUtils.replaceString(text, IJAMConst.GLOBAL_VARIABLE_CALLERNAME, callernameExpression);
    text = this.getParsedPhonenumber(text, caller.getPhoneNumber());
    text = this.getParsedAttributes(text, caller.getAttributes(), true);
    // changed: 2005/11/11: deprecated method is processed last
    text = this.getParsedName(text, caller.getName());
    text = this.cleanString(text.trim());
    return text.trim();
}
Also used : IConfigManager(de.janrufmonitor.framework.configuration.IConfigManager)

Example 8 with IConfigManager

use of de.janrufmonitor.framework.configuration.IConfigManager in project janrufmonitor by tbrandt77.

the class GoogleContactsProxy method ensureEditorConfigurationCatergories.

public void ensureEditorConfigurationCatergories(List subfolders) {
    List ol = new ArrayList();
    IConfigManager mgr = this.getRuntime().getConfigManagerFactory().getConfigManager();
    String value = mgr.getProperty("ui.jface.application.editor.Editor", "categories");
    if (value.trim().length() > 0) {
        String[] values = value.split(",");
        for (int i = 0; i < values.length; i++) {
            ol.add(values[i]);
        }
    }
    for (int i = 0; i < subfolders.size(); i++) {
        if (!ol.contains(subfolders.get(i))) {
            ol.add(subfolders.get(i));
        // mgr.setProperty("ui.jface.application.editor.Editor", "filter_cat_ol"+i, "(5,category="+subfolders.get(i)+")");
        }
    }
    value = "";
    for (int i = 0; i < ol.size(); i++) {
        value += ol.get(i) + ",";
    }
    mgr.setProperty("ui.jface.application.editor.Editor", "categories", value);
    mgr.saveConfiguration();
    getRuntime().getConfigurableNotifier().notifyByNamespace("ui.jface.application.editor.Editor");
}
Also used : IConfigManager(de.janrufmonitor.framework.configuration.IConfigManager) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ICallerList(de.janrufmonitor.framework.ICallerList)

Example 9 with IConfigManager

use of de.janrufmonitor.framework.configuration.IConfigManager in project janrufmonitor by tbrandt77.

the class OutlookContactProxy method ensureEditorConfigurationCatergories.

public void ensureEditorConfigurationCatergories(List subfolders) {
    List ol = new ArrayList();
    IConfigManager mgr = this.getRuntime().getConfigManagerFactory().getConfigManager();
    String value = mgr.getProperty("ui.jface.application.editor.Editor", "categories");
    if (value.trim().length() > 0) {
        String[] values = value.split(",");
        for (int i = 0; i < values.length; i++) {
            ol.add(values[i]);
        }
    }
    for (int i = 0; i < subfolders.size(); i++) {
        if (!ol.contains(subfolders.get(i))) {
            ol.add(subfolders.get(i));
        // mgr.setProperty("ui.jface.application.editor.Editor", "filter_cat_ol"+i, "(5,category="+subfolders.get(i)+")");
        }
    }
    value = "";
    for (int i = 0; i < ol.size(); i++) {
        value += ol.get(i) + ",";
    }
    mgr.setProperty("ui.jface.application.editor.Editor", "categories", value);
    mgr.saveConfiguration();
    getRuntime().getConfigurableNotifier().notifyByNamespace("ui.jface.application.editor.Editor");
}
Also used : IConfigManager(de.janrufmonitor.framework.configuration.IConfigManager) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) ICallerList(de.janrufmonitor.framework.ICallerList) List(java.util.List)

Example 10 with IConfigManager

use of de.janrufmonitor.framework.configuration.IConfigManager in project janrufmonitor by tbrandt77.

the class InfHandler method removeInfData.

public void removeInfData(Properties infData) {
    try {
        IConfigManager cpm = PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager();
        Iterator iter = infData.keySet().iterator();
        String key = null;
        while (iter.hasNext()) {
            key = (String) iter.next();
            StringTokenizer st = new StringTokenizer(key, this.NAMESPACE_SEPARATOR);
            String namespace = st.nextToken();
            String parameter = st.nextToken();
            String metainfo = st.nextToken();
            if (namespace.startsWith("-")) {
                String value = infData.getProperty(key);
                namespace = namespace.substring(1);
                this.m_logger.info("Detected module config removal.");
                this.m_logger.info("Adding " + namespace + "\\:" + parameter + "\\:" + metainfo);
                String v = cpm.getProperty(namespace, parameter, metainfo);
                if (v == null)
                    v = "";
                // value += infData.getProperty(key);
                v = this.concat(v, infData.getProperty(key));
                cpm.setProperty(namespace, parameter, metainfo, value, true);
            } else if (namespace.startsWith("+")) {
                namespace = namespace.substring(1);
                this.m_logger.info("Detected module config concatenation.");
                this.m_logger.info("De-Concatenating values for " + namespace + "\\:" + parameter + "\\:" + metainfo);
                String value = cpm.getProperty(namespace, parameter, metainfo);
                value = StringUtils.replaceString(value, infData.getProperty(key, "null"), "");
                if (value == null)
                    value = "";
                cpm.setProperty(namespace, parameter, metainfo, value, true);
            } else if (namespace.startsWith("~")) {
                namespace = namespace.substring(1);
                this.m_logger.info("Detected module config restore.");
                this.m_logger.info("Restoring values for " + namespace + "\\:" + parameter + "\\:" + metainfo);
                String value = cpm.getProperty("_" + namespace, parameter, metainfo);
                if (value == null)
                    value = "";
                if (value.length() > 0) {
                    // config restore means allways overwrite !!
                    cpm.setProperty(namespace, parameter, metainfo, value, true);
                } else {
                    cpm.removeProperty(namespace, parameter, metainfo);
                }
                cpm.removeProperty("_" + namespace, parameter, metainfo);
            } else if (namespace.startsWith("?")) {
                namespace = namespace.substring(1);
                this.m_logger.info("Detected module config add only if not present feature.");
                this.m_logger.info("Removing value for " + namespace + "\\:" + parameter + "\\:" + metainfo);
                cpm.removeProperty(namespace, parameter, metainfo);
            } else if (namespace.startsWith("%")) {
                namespace = namespace.substring(1);
                this.m_logger.info("Detected module config add always feature.");
                this.m_logger.info("Removing value for " + namespace + "\\:" + parameter + "\\:" + metainfo);
                cpm.removeProperty(namespace, parameter, metainfo);
            } else {
                cpm.removeProperty(namespace, parameter, metainfo);
            }
        }
        cpm.saveConfiguration();
    } catch (NullPointerException ex) {
        this.m_logger.severe("Configuration is invalid: " + ex.getMessage());
    } catch (NoSuchElementException ex) {
        this.m_logger.severe("Configuration is invalid: " + ex.getMessage());
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) IConfigManager(de.janrufmonitor.framework.configuration.IConfigManager) Iterator(java.util.Iterator) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

IConfigManager (de.janrufmonitor.framework.configuration.IConfigManager)13 Iterator (java.util.Iterator)4 ICallerList (de.janrufmonitor.framework.ICallerList)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 SimpleDateFormat (java.text.SimpleDateFormat)2 NoSuchElementException (java.util.NoSuchElementException)2 StringTokenizer (java.util.StringTokenizer)2 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)1 II18nManager (de.janrufmonitor.framework.i18n.II18nManager)1 ZipArchive (de.janrufmonitor.repository.zip.ZipArchive)1 ZipArchiveException (de.janrufmonitor.repository.zip.ZipArchiveException)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 Date (java.util.Date)1 Properties (java.util.Properties)1 FieldEditor (org.eclipse.jface.preference.FieldEditor)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1