Search in sources :

Example 6 with ICallerList

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

the class EditorController method deleteElements.

public synchronized void deleteElements(Object list) {
    if (list != null && list instanceof ICallerList) {
        Map cms = new HashMap();
        ICallerList tmplist = null;
        ICaller c = null;
        for (int i = 0; i < ((ICallerList) list).size(); i++) {
            c = ((ICallerList) list).get(i);
            IAttribute att = c.getAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER);
            String cname = (att == null ? "all" : att.getValue());
            if (cms.containsKey(cname)) {
                tmplist = (ICallerList) cms.get(cname);
                tmplist.add(c);
            } else {
                tmplist = this.getRuntime().getCallerFactory().createCallerList(1);
                tmplist.add(c);
                cms.put(cname, tmplist);
            }
        }
        List managers = this.getActiveCallerManagers();
        ICallerManager mgr = null;
        for (int i = 0; i < managers.size(); i++) {
            mgr = this.getRuntime().getCallerManagerFactory().getCallerManager((String) managers.get(i));
            if (mgr != null) {
                if (mgr.isSupported(IWriteCallerRepository.class)) {
                    tmplist = (ICallerList) cms.get("all");
                    if (tmplist != null) {
                        this.m_logger.info("removing " + tmplist.size() + " callers to manager: " + mgr.getManagerID());
                        ((IWriteCallerRepository) mgr).removeCaller(tmplist);
                    }
                    tmplist = (ICallerList) cms.get(mgr.getManagerID());
                    if (tmplist != null) {
                        this.m_logger.info("removing " + tmplist.size() + " callers to manager: " + mgr.getManagerID());
                        ((IWriteCallerRepository) mgr).removeCaller(tmplist);
                    }
                }
            }
        }
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICallerList(de.janrufmonitor.framework.ICallerList) HashMap(java.util.HashMap) IWriteCallerRepository(de.janrufmonitor.repository.types.IWriteCallerRepository) IAttribute(de.janrufmonitor.framework.IAttribute) ArrayList(java.util.ArrayList) List(java.util.List) ICallerList(de.janrufmonitor.framework.ICallerList) HashMap(java.util.HashMap) Map(java.util.Map) ICallerManager(de.janrufmonitor.repository.ICallerManager)

Example 7 with ICallerList

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

the class DeleteAction method run.

public void run() {
    Viewer v = this.m_app.getApplication().getViewer();
    if (v != null && v instanceof TreeViewer) {
        IStructuredSelection selection = (IStructuredSelection) v.getSelection();
        if (!selection.isEmpty()) {
            Iterator i = selection.iterator();
            ICallerList list = getRuntime().getCallerFactory().createCallerList();
            Object o = null;
            while (i.hasNext()) {
                o = i.next();
                if (o instanceof ICaller) {
                    list.add((ICaller) o);
                }
            }
            if (list.size() > 0) {
                if (MessageDialog.openConfirm(new Shell(DisplayManager.getDefaultDisplay()), this.getI18nManager().getString(this.getNamespace(), "delete", "label", this.getLanguage()), this.getI18nManager().getString(this.getNamespace(), "delete", "description", this.getLanguage()))) {
                    this.m_app.getController().deleteElements(list);
                    this.m_app.getApplication().initializeController();
                    this.m_app.updateViews(true);
                }
            }
        }
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) Shell(org.eclipse.swt.widgets.Shell) ICallerList(de.janrufmonitor.framework.ICallerList) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Iterator(java.util.Iterator) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 8 with ICallerList

use of de.janrufmonitor.framework.ICallerList 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 9 with ICallerList

use of de.janrufmonitor.framework.ICallerList 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 10 with ICallerList

use of de.janrufmonitor.framework.ICallerList 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)

Aggregations

ICallerList (de.janrufmonitor.framework.ICallerList)81 ICaller (de.janrufmonitor.framework.ICaller)40 List (java.util.List)36 ArrayList (java.util.ArrayList)32 IAttribute (de.janrufmonitor.framework.IAttribute)24 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)24 SQLException (java.sql.SQLException)24 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)18 IMultiPhoneCaller (de.janrufmonitor.framework.IMultiPhoneCaller)17 IOException (java.io.IOException)15 Message (de.janrufmonitor.exception.Message)14 Iterator (java.util.Iterator)11 Map (java.util.Map)11 File (java.io.File)10 HashMap (java.util.HashMap)10 Viewer (org.eclipse.jface.viewers.Viewer)10 ICallerManager (de.janrufmonitor.repository.ICallerManager)9 ComFailException (com.jacob.com.ComFailException)8 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 AttributeFilter (de.janrufmonitor.repository.filter.AttributeFilter)7