Search in sources :

Example 1 with Formatter

use of de.janrufmonitor.util.formatter.Formatter in project janrufmonitor by tbrandt77.

the class GenericWebAction method run.

public void run() {
    Viewer v = this.m_app.getApplication().getViewer();
    if (v != null) {
        IStructuredSelection selection = (IStructuredSelection) v.getSelection();
        if (!selection.isEmpty()) {
            Object o = selection.getFirstElement();
            if (o instanceof ICall || o instanceof ICaller) {
                Properties configuration = getRuntime().getConfigManagerFactory().getConfigManager().getProperties(this.getNamespace());
                if (configuration != null) {
                    String url = configuration.getProperty("url");
                    if (url != null && url.trim().length() > 0) {
                        this.m_logger.info("Found valid web url to execute: " + url);
                        Formatter f = Formatter.getInstance(this.getRuntime());
                        url = f.parse(url, o);
                        this.m_logger.info("Parsed web url to execute: " + url);
                        Program.launch(url);
                    }
                } else {
                    this.m_logger.warning("Found invalid configuration for namespace: " + this.getNamespace());
                }
            }
        }
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICall(de.janrufmonitor.framework.ICall) Formatter(de.janrufmonitor.util.formatter.Formatter) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Properties(java.util.Properties)

Example 2 with Formatter

use of de.janrufmonitor.util.formatter.Formatter in project janrufmonitor by tbrandt77.

the class GenericWebDialogPlugin method run.

public void run() {
    Properties configuration = getRuntime().getConfigManagerFactory().getConfigManager().getProperties(this.getNamespace());
    if (configuration != null) {
        String url = configuration.getProperty("url");
        if (url != null && url.trim().length() > 0) {
            this.m_logger.info("Found valid web url to execute: " + url);
            Formatter f = Formatter.getInstance(this.getRuntime());
            url = f.parse(url, this.m_dialog.getCall());
            this.m_logger.info("Parsed web url to execute: " + url);
            Program.launch(url);
        }
    } else {
        this.m_logger.warning("Found invalid configuration for namespace: " + this.getNamespace());
    }
}
Also used : Formatter(de.janrufmonitor.util.formatter.Formatter) Properties(java.util.Properties)

Example 3 with Formatter

use of de.janrufmonitor.util.formatter.Formatter in project janrufmonitor by tbrandt77.

the class BalloonDialog method getParsedCaller.

private String getParsedCaller() {
    Formatter formatter = Formatter.getInstance(this.getRuntime());
    String name = "";
    if (this.m_call.getCaller() != null && this.m_call.getCaller().getPhoneNumber().isClired()) {
        name = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_CLIR);
    } else {
        name = formatter.parse(IJAMConst.GLOBAL_VARIABLE_CALLERNAME, this.m_call);
        // hack for 4.2.1 & sign is not shown
        name = StringUtils.replaceString(name, "&", "%amp%");
        name = StringUtils.replaceString(name, "%amp%", "&&");
    }
    return name;
}
Also used : Formatter(de.janrufmonitor.util.formatter.Formatter)

Example 4 with Formatter

use of de.janrufmonitor.util.formatter.Formatter in project janrufmonitor by tbrandt77.

the class BalloonDialog method getParsedNumber.

private String getParsedNumber() {
    Formatter formatter = Formatter.getInstance(this.getRuntime());
    String number = "";
    if (this.m_call.getCaller() != null && !this.m_call.getCaller().getPhoneNumber().isClired()) {
        number = formatter.parse(IJAMConst.GLOBAL_VARIABLE_CALLERNUMBER, this.m_call);
    }
    return number;
}
Also used : Formatter(de.janrufmonitor.util.formatter.Formatter)

Example 5 with Formatter

use of de.janrufmonitor.util.formatter.Formatter in project janrufmonitor by tbrandt77.

the class TrayIcon method getToolTipText.

private String getToolTipText(ICall aCall) {
    // menu fails to open.
    if (aCall != null && aCall.getCaller().getPhoneNumber().isClired()) {
        return this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_CLIR);
    }
    Formatter formatter = Formatter.getInstance(this.getRuntime());
    String p = "\r\n" + formatter.parse(IJAMConst.GLOBAL_VARIABLE_CALLERNUMBER, aCall);
    // cut tooltips > 128
    if (p.length() > 128)
        return p.substring(2, Math.max(132, p.length())).trim();
    String name = formatter.parse(IJAMConst.GLOBAL_VARIABLE_CALLERNAME, aCall);
    if ((name.length() + p.length()) > 128) {
        name = name.substring(0, (127 - 3 - p.length())) + "...";
    }
    return name + p;
}
Also used : Formatter(de.janrufmonitor.util.formatter.Formatter)

Aggregations

Formatter (de.janrufmonitor.util.formatter.Formatter)14 ICall (de.janrufmonitor.framework.ICall)4 ICaller (de.janrufmonitor.framework.ICaller)4 Properties (java.util.Properties)4 Iterator (java.util.Iterator)3 List (java.util.List)3 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ArrayList (java.util.ArrayList)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)2 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)2 Message (de.janrufmonitor.exception.Message)1 IAttribute (de.janrufmonitor.framework.IAttribute)1 ICallList (de.janrufmonitor.framework.ICallList)1 ICallerList (de.janrufmonitor.framework.ICallerList)1 IMultiPhoneCaller (de.janrufmonitor.framework.IMultiPhoneCaller)1 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)1 ICallManager (de.janrufmonitor.repository.ICallManager)1 IFilter (de.janrufmonitor.repository.filter.IFilter)1