Search in sources :

Example 11 with ICaller

use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.

the class QuickImagePathAction method run.

public void run() {
    Viewer v = this.m_app.getApplication().getViewer();
    if (v != null && v instanceof Viewer) {
        final IStructuredSelection selection = (IStructuredSelection) v.getSelection();
        if (!selection.isEmpty()) {
            Iterator i = selection.iterator();
            ICallerList list = this.getRuntime().getCallerFactory().createCallerList(selection.size());
            Object o = null;
            while (i.hasNext()) {
                o = i.next();
                if (o instanceof ICaller) {
                    ICaller caller = ((ICaller) o);
                    if (this.hasCallerImage(caller)) {
                        File image = getCallerImageFile(caller);
                        if (image != null) {
                            if (!isCentralImageStore(caller)) {
                                String name = image.getName();
                                File image_in_store = new File(getCentralImageStorePath(), name);
                                if (!image_in_store.exists()) {
                                    try {
                                        FileInputStream fin = new FileInputStream(image);
                                        FileOutputStream fout = new FileOutputStream(image_in_store);
                                        if (m_logger.isLoggable(Level.INFO))
                                            m_logger.info("Copiing " + image.getAbsolutePath() + " to " + image_in_store.getAbsolutePath());
                                        Stream.copy(fin, fout, true);
                                        setAttribute(caller, IJAMConst.ATTRIBUTE_NAME_IMAGEPATH, PathResolver.getInstance(getRuntime()).encode(image_in_store.getAbsolutePath()));
                                        list.add(caller);
                                    } catch (IOException e) {
                                        m_logger.log(Level.SEVERE, e.getMessage(), e);
                                    }
                                } else {
                                    m_logger.warning("Image file " + image_in_store.getAbsolutePath() + " already exists in central image store. File gets overwritten.");
                                    try {
                                        FileInputStream fin = new FileInputStream(image);
                                        FileOutputStream fout = new FileOutputStream(image_in_store);
                                        if (m_logger.isLoggable(Level.INFO))
                                            m_logger.info("Copiing " + image.getAbsolutePath() + " to " + image_in_store.getAbsolutePath());
                                        Stream.copy(fin, fout, true);
                                        setAttribute(caller, IJAMConst.ATTRIBUTE_NAME_IMAGEPATH, PathResolver.getInstance(getRuntime()).encode(image_in_store.getAbsolutePath()));
                                        list.add(caller);
                                    } catch (IOException e) {
                                        m_logger.log(Level.SEVERE, e.getMessage(), e);
                                    }
                                }
                            } else {
                                if (m_logger.isLoggable(Level.INFO))
                                    m_logger.info("Image file " + image.getAbsolutePath() + " is already in central image store.");
                            }
                        } else {
                            m_logger.warning("Image file could not be copied to central image store. Image is not set.");
                        }
                    }
                }
            }
            if (list.size() > 0) {
                this.m_app.getController().updateElement(list);
            }
            m_app.updateViews(true);
        }
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICallerList(de.janrufmonitor.framework.ICallerList) FileOutputStream(java.io.FileOutputStream) Iterator(java.util.Iterator) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 12 with ICaller

use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.

the class CallerColoringAction method run.

public void run() {
    Viewer v = this.m_app.getApplication().getViewer();
    if (v != null && v instanceof TreeViewer) {
        Tree t = ((TreeViewer) v).getTree();
        ICallerList cl = ((EditorController) this.m_app.getController()).getCallerList();
        ICaller c = null;
        for (int i = 0, n = cl.size(); i < n; i++) {
            c = cl.get(i);
            Color color = this.getColor(c, t);
            if (color != null) {
                t.getItem(i).setForeground(color);
            }
            if (i % 2 == 0) {
                t.getItem(i).setBackground(getIterationColor(t));
            }
        }
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) EditorController(de.janrufmonitor.ui.jface.application.editor.EditorController) ICallerList(de.janrufmonitor.framework.ICallerList) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Color(org.eclipse.swt.graphics.Color) Tree(org.eclipse.swt.widgets.Tree) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer)

Example 13 with ICaller

use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.

the class LastCalled method renderAsText.

public String renderAsText() {
    if (this.m_o != null) {
        if (this.m_o instanceof ICaller) {
            this.m_o = new TreeItemCallerData(((ICaller) this.m_o).getAttributes(), ((ICaller) this.m_o).getPhoneNumber());
        }
        if (this.m_o instanceof ITreeItemCallerData) {
            IPhonenumber pn = ((ITreeItemCallerData) m_o).getPhone();
            List cms = PIMRuntime.getInstance().getCallManagerFactory().getTypedCallManagers(IReadCallRepository.class);
            if (cms.size() > 0) {
                ICallManager cm = null;
                for (int i = 0, j = cms.size(); i < j; i++) {
                    cm = (ICallManager) cms.get(i);
                    if (cm.isActive() && cm.isSupported(IReadCallRepository.class)) {
                        IFilter[] filters = new IFilter[] { new PhonenumberFilter(pn), new ItemCountFilter(1) };
                        ICallList cl = ((IReadCallRepository) cm).getCalls(filters, 1, 0);
                        cl.sort(0, false);
                        if (cl.size() > 0) {
                            ICall c = cl.get(0);
                            return getFormatter().parse(IJAMConst.GLOBAL_VARIABLE_CALLTIME, c.getDate());
                        }
                    }
                }
            }
        }
    }
    return "";
}
Also used : IReadCallRepository(de.janrufmonitor.repository.types.IReadCallRepository) ICall(de.janrufmonitor.framework.ICall) ICallManager(de.janrufmonitor.repository.ICallManager) ICaller(de.janrufmonitor.framework.ICaller) IFilter(de.janrufmonitor.repository.filter.IFilter) ItemCountFilter(de.janrufmonitor.repository.filter.ItemCountFilter) ICallList(de.janrufmonitor.framework.ICallList) PhonenumberFilter(de.janrufmonitor.repository.filter.PhonenumberFilter) ICallList(de.janrufmonitor.framework.ICallList) List(java.util.List) ITreeItemCallerData(de.janrufmonitor.ui.jface.application.ITreeItemCallerData) ITreeItemCallerData(de.janrufmonitor.ui.jface.application.ITreeItemCallerData) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 14 with ICaller

use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.

the class GeoCodingAction method run.

public void run() {
    Viewer v = this.m_app.getApplication().getViewer();
    if (v != null && v instanceof Viewer) {
        final IStructuredSelection selection = (IStructuredSelection) v.getSelection();
        if (!selection.isEmpty()) {
            Iterator i = selection.iterator();
            ICallerList list = this.getRuntime().getCallerFactory().createCallerList(selection.size());
            Object o = null;
            while (i.hasNext()) {
                o = i.next();
                if (o instanceof ICaller) {
                    Point p = GeoCoder.getInstance().getCoordinates(((ICaller) o).getAttributes());
                    if (p != null) {
                        ((ICaller) o).setAttribute(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_ACC, Integer.toString(p.getAccurance())));
                        ((ICaller) o).setAttribute(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_LNG, Double.toString(p.getLongitude())));
                        ((ICaller) o).setAttribute(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_LAT, Double.toString(p.getLatitude())));
                        list.add((ICaller) o);
                    }
                }
            }
            if (list.size() > 0) {
                this.m_app.getController().updateElement(list);
            }
            m_app.updateViews(true);
        }
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICallerList(de.janrufmonitor.framework.ICallerList) Iterator(java.util.Iterator) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Point(de.janrufmonitor.util.math.Point)

Example 15 with ICaller

use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.

the class NewAction method run.

public void run() {
    Viewer v = this.m_app.getApplication().getViewer();
    if (v != null && v instanceof TreeViewer) {
        ICaller newCaller = openCallerWizard(null);
        if (newCaller != null) {
            ICallerList l = this.getRuntime().getCallerFactory().createCallerList(1);
            l.add(newCaller);
            this.m_app.getController().addElements(l);
            this.m_app.updateViews(true);
        }
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICallerList(de.janrufmonitor.framework.ICallerList) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer)

Aggregations

ICaller (de.janrufmonitor.framework.ICaller)144 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)62 ICallerList (de.janrufmonitor.framework.ICallerList)49 List (java.util.List)46 IAttribute (de.janrufmonitor.framework.IAttribute)42 ICall (de.janrufmonitor.framework.ICall)41 ArrayList (java.util.ArrayList)40 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)32 SQLException (java.sql.SQLException)26 IMultiPhoneCaller (de.janrufmonitor.framework.IMultiPhoneCaller)25 IOException (java.io.IOException)25 Viewer (org.eclipse.jface.viewers.Viewer)24 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 File (java.io.File)20 Date (java.util.Date)17 Iterator (java.util.Iterator)17 Shell (org.eclipse.swt.widgets.Shell)17 IMsn (de.janrufmonitor.framework.IMsn)16 Properties (java.util.Properties)15 ICip (de.janrufmonitor.framework.ICip)14