Search in sources :

Example 91 with ICaller

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

the class ChangeAction 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 = ((ICall) o).getCaller();
            }
            if (o instanceof ICaller) {
                if (((ICaller) o).getPhoneNumber().isClired())
                    return;
                IAttribute att = ((ICaller) o).getAttribute(SoundConst.ATTRIBUTE_USER_SOUNDFILE);
                if (att == null) {
                    att = this.getRuntime().getCallerFactory().createAttribute(SoundConst.ATTRIBUTE_USER_SOUNDFILE, "");
                }
                // Create the dialog
                WizardDialog.setDefaultImage(SWTImageManager.getInstance(this.getRuntime()).get(IJAMConst.IMAGE_KEY_PIM_ICON));
                SoundDataWizard sdoW = new SoundDataWizard(att.getValue());
                WizardDialog dlg = new WizardDialog(new Shell(DisplayManager.getDefaultDisplay()), sdoW);
                dlg.open();
                if (dlg.getReturnCode() == WizardDialog.OK) {
                    att.setValue(sdoW.getResult());
                    ((ICaller) o).setAttribute(att);
                    this.m_app.getController().updateElement(o);
                    this.m_app.updateViews(false);
                }
            }
        }
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) Shell(org.eclipse.swt.widgets.Shell) ICall(de.janrufmonitor.framework.ICall) IAttribute(de.janrufmonitor.framework.IAttribute) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 92 with ICaller

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

the class DefaultCallDialogService method receivedValidRule.

public void receivedValidRule(final ICall aCall) {
    ICaller theCaller = aCall.getCaller();
    if (theCaller != null) {
        this.m_logger.info("Opening new dialog instance...");
        final long ms = System.currentTimeMillis();
        this.m_logger.fine("Time measure in ms (init): " + (System.currentTimeMillis() - ms));
        new SWTExecuter(true, this.getID()) {

            protected void execute() {
                if (m_configuration.getProperty(CFG_BALLOON, "false").equalsIgnoreCase("false")) {
                    m_logger.fine("Time measure in ms (SWTExecuter): " + (System.currentTimeMillis() - ms));
                    Dialog j = new Dialog(m_configuration, aCall);
                    m_logger.fine("Time measure in ms (SWTExecuter.open() - before): " + (System.currentTimeMillis() - ms));
                    j.open();
                    m_logger.fine("Time measure in ms (SWTExecuter.open() - after): " + (System.currentTimeMillis() - ms));
                    j = null;
                } else {
                    m_logger.fine("Time measure in ms (SWTExecuter): " + (System.currentTimeMillis() - ms));
                    ExtendedBalloonDialog j = new ExtendedBalloonDialog(m_configuration, aCall);
                    try {
                        Thread.sleep(getDelay());
                    } catch (InterruptedException e) {
                    }
                    j.createDialog();
                    m_logger.fine("Time measure in ms (SWTExecuter.open() - before): " + (System.currentTimeMillis() - ms));
                    j.open();
                    m_logger.fine("Time measure in ms (SWTExecuter.open() - after): " + (System.currentTimeMillis() - ms));
                    j = null;
                }
            }
        }.start();
        this.m_logger.fine("Time measure in ms (end): " + (System.currentTimeMillis() - ms));
    } else {
        this.m_logger.warning("Dialog not opened due to invalid caller data.");
    }
}
Also used : ExtendedBalloonDialog(de.janrufmonitor.ui.jface.application.dialog.ExtendedBalloonDialog) ICaller(de.janrufmonitor.framework.ICaller) ExtendedBalloonDialog(de.janrufmonitor.ui.jface.application.dialog.ExtendedBalloonDialog) Dialog(de.janrufmonitor.ui.jface.application.dialog.Dialog) SWTExecuter(de.janrufmonitor.ui.swt.SWTExecuter)

Example 93 with ICaller

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

the class AbstractFilterManager method getFiltersToLabelText.

public String getFiltersToLabelText(IFilter[] f, int shorten) {
    if (f != null && f.length > 0) {
        boolean processedCaller = false;
        StringBuffer sb = new StringBuffer();
        sb.append(this.getI18nManager().getString(this.getNamespace(), "view_limit", "label", this.getLanguage()));
        for (int i = 0; i < f.length; i++) {
            IFilter f1 = f[i];
            if (f1.getType().equals(FilterType.CIP)) {
                sb.append(this.getI18nManager().getString(this.getNamespace(), "view_cip", "label", this.getLanguage()));
                sb.append(this.getRuntime().getCipManager().getCipLabel(((CipFilter) f1).getCip(), this.getLanguage()));
                if ((i + 1) < f.length)
                    sb.append(", ");
            }
            if (f1.getType().equals(FilterType.MSN)) {
                sb.append(this.getI18nManager().getString(this.getNamespace(), "view_msn", "label", this.getLanguage()));
                IMsn[] m = ((MsnFilter) f1).getMsn();
                for (int k = 0, l = m.length; k < l; k++) {
                    sb.append(m[k].getMSN());
                    m[k].setAdditional(this.getRuntime().getMsnManager().getMsnLabel(m[k]));
                    if (m[k].getAdditional().length() > 0) {
                        sb.append(" (" + m[k].getAdditional() + ")");
                    }
                    if ((k + 1) < l)
                        sb.append(", ");
                }
                if ((i + 1) < f.length)
                    sb.append(", ");
            }
            if (f1.getType().equals(FilterType.DATE)) {
                sb.append(this.getI18nManager().getString(this.getNamespace(), "view_date", "label", this.getLanguage()));
                if (((DateFilter) f1).getTimeframe() == -1) {
                    Date d1 = ((DateFilter) f1).getDateFrom();
                    Date d2 = ((DateFilter) f1).getDateTo();
                    SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
                    sb.append("[");
                    sb.append(sdf.format(d2));
                    sb.append(" - ");
                    if (d1 != null)
                        sb.append(sdf.format(d1));
                    else {
                        sb.append(this.getI18nManager().getString(this.getNamespace(), "today", "label", this.getLanguage()));
                    }
                    sb.append("]");
                    if ((i + 1) < f.length)
                        sb.append(", ");
                } else {
                    sb.append("[");
                    sb.append(this.getI18nManager().getString(this.getNamespace(), Long.toString(((DateFilter) f1).getTimeframe()), "label", this.getLanguage()));
                    sb.append("]");
                    if ((i + 1) < f.length)
                        sb.append(", ");
                }
            }
            if (f1.getType().equals(FilterType.YEAR)) {
                sb.append(this.getI18nManager().getString(this.getNamespace(), "view_date", "label", this.getLanguage()));
                sb.append("[");
                sb.append(((YearFilter) f1).getYear());
                sb.append("]");
                if ((i + 1) < f.length)
                    sb.append(", ");
            }
            if (f1.getType().equals(FilterType.MONTH_YEAR)) {
                sb.append(this.getI18nManager().getString(this.getNamespace(), "view_date", "label", this.getLanguage()));
                sb.append("[");
                sb.append(((MonthYearFilter) f1).getYear());
                sb.append(".");
                sb.append((((MonthYearFilter) f1).getMonth() > 9 ? ((MonthYearFilter) f1).getMonth() : "0" + ((MonthYearFilter) f1).getMonth()));
                sb.append("]");
                if ((i + 1) < f.length)
                    sb.append(", ");
            }
            if (f1.getType().equals(FilterType.CALLER) && !processedCaller) {
                sb.append(this.getI18nManager().getString(this.getNamespace(), "view_caller", "label", this.getLanguage()));
                if ((i + 1) < f.length && !processedCaller)
                    sb.append(", ");
                processedCaller = true;
            }
            if (f1.getType().equals(FilterType.PHONENUMBER)) {
                PhonenumberFilter cf = ((PhonenumberFilter) f1);
                IPhonenumber pnc = getRuntime().getCallerFactory().createPhonenumber(cf.getPhonenumber().getIntAreaCode(), cf.getPhonenumber().getAreaCode(), "0000000000");
                ICaller c = Identifier.identifyDefault(getRuntime(), pnc);
                if (c != null) {
                    IAttribute city = c.getAttribute(IJAMConst.ATTRIBUTE_NAME_CITY);
                    if (city != null && city.getValue().trim().length() > 0) {
                        sb.append(this.getI18nManager().getString(this.getNamespace(), "view_area", "label", this.getLanguage()).substring(2));
                        sb.append(city.getValue().trim());
                        sb.append(" (0");
                        sb.append(cf.getPhonenumber().getAreaCode());
                        sb.append(")");
                        if ((i + 1) < f.length)
                            sb.append(", ");
                        continue;
                    }
                }
                sb.append(this.getI18nManager().getString(this.getNamespace(), "view_intarea", "label", this.getLanguage()));
                sb.append("00" + cf.getPhonenumber().getIntAreaCode());
                if (cf.getPhonenumber().getAreaCode().trim().length() > 0) {
                    sb.append(this.getI18nManager().getString(this.getNamespace(), "view_area", "label", this.getLanguage()));
                    sb.append("0" + cf.getPhonenumber().getAreaCode().trim());
                }
                if ((i + 1) < f.length)
                    sb.append(", ");
            }
            if (f1.getType().equals(FilterType.ITEMCOUNT)) {
                ItemCountFilter cf = ((ItemCountFilter) f1);
                sb.append(this.getI18nManager().getString(this.getNamespace(), "view_itemcount", "label", this.getLanguage()));
                sb.append(cf.getLimit());
                if ((i + 1) < f.length)
                    sb.append(", ");
            }
            if (f1.getType().equals(FilterType.ATTRIBUTE)) {
                AttributeFilter cf = ((AttributeFilter) f1);
                IAttributeMap m = cf.getAttributeMap();
                if (m != null && m.size() > 0) {
                    Iterator it = m.iterator();
                    IAttribute a = null;
                    while (it.hasNext()) {
                        a = (IAttribute) it.next();
                        if (a.getName().equalsIgnoreCase(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS)) {
                            sb.append(this.getI18nManager().getString(this.getNamespace(), a.getValue(), "label", this.getLanguage()));
                        } else if (a.getName().equalsIgnoreCase(IJAMConst.ATTRIBUTE_NAME_CATEGORY)) {
                            sb.append(this.getI18nManager().getString(this.getNamespace(), a.getName(), "label", this.getLanguage()));
                            sb.append(a.getValue());
                        } else {
                            sb.append(this.getI18nManager().getString(this.getNamespace(), a.getName(), "label", this.getLanguage()));
                        }
                        if (it.hasNext())
                            sb.append(", ");
                    }
                }
                if ((i + 1) < f.length)
                    sb.append(", ");
            }
            if (f1.getType().equals(FilterType.CHARACTER)) {
                CharacterFilter cf = ((CharacterFilter) f1);
                sb.append(this.getI18nManager().getString(this.getNamespace(), "view_" + cf.getAttributeName(), "label", this.getLanguage()));
                sb.append("[");
                sb.append(cf.getCharacter().toUpperCase());
                sb.append("...]");
                if ((i + 1) < f.length)
                    sb.append(", ");
            }
        }
        String s = sb.toString();
        if (s.trim().endsWith(","))
            s = s.trim().substring(0, s.trim().length() - 1);
        if (shorten > -1 && shorten < s.length()) {
            return s.substring(0, Math.min(shorten, s.length())) + "...";
        }
        if (s.trim().length() > 0)
            return s;
    }
    return this.getI18nManager().getString(this.getNamespace(), "view_all", "label", this.getLanguage());
}
Also used : CharacterFilter(de.janrufmonitor.repository.filter.CharacterFilter) CipFilter(de.janrufmonitor.repository.filter.CipFilter) Date(java.util.Date) ICaller(de.janrufmonitor.framework.ICaller) IFilter(de.janrufmonitor.repository.filter.IFilter) ItemCountFilter(de.janrufmonitor.repository.filter.ItemCountFilter) MsnFilter(de.janrufmonitor.repository.filter.MsnFilter) IAttribute(de.janrufmonitor.framework.IAttribute) AttributeFilter(de.janrufmonitor.repository.filter.AttributeFilter) Iterator(java.util.Iterator) PhonenumberFilter(de.janrufmonitor.repository.filter.PhonenumberFilter) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) IMsn(de.janrufmonitor.framework.IMsn) DateFilter(de.janrufmonitor.repository.filter.DateFilter) SimpleDateFormat(java.text.SimpleDateFormat) MonthYearFilter(de.janrufmonitor.repository.filter.MonthYearFilter) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 94 with ICaller

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

the class TableCellModifier method modify.

public void modify(Object element, String column, Object value) {
    if (element instanceof Item)
        element = ((Item) element).getData();
    ITableCellRenderer r = RendererRegistry.getInstance().getRenderer(column);
    if (r instanceof ITableAttributeCellEditorRenderer && ((ITableAttributeCellEditorRenderer) r).getAttribute() != null) {
        if (element instanceof ICall) {
            ICall c = ((ICall) element);
            IAttribute cAtt = c.getAttribute(((ITableAttributeCellEditorRenderer) r).getAttribute().getName());
            if (cAtt != null && value instanceof String) {
                if (cAtt.getValue().equalsIgnoreCase((String) value)) {
                    return;
                }
            }
            IAttribute att = ((ITableAttributeCellEditorRenderer) r).getAttribute();
            ((ITableAttributeCellEditorRenderer) r).applyAttributeChanges(c, att, value);
            if (this.m_ac.getController() instanceof IExtendedApplicationController) {
                ((IExtendedApplicationController) this.m_ac.getController()).updateElement(c, false);
            } else {
                this.m_ac.getController().updateElement(c);
            }
        }
        if (element instanceof ICaller) {
            ICaller c = ((ICaller) element);
            IAttribute cAtt = c.getAttribute(((ITableAttributeCellEditorRenderer) r).getAttribute().getName());
            if (cAtt != null && value instanceof String) {
                if (cAtt.getValue().equalsIgnoreCase((String) value)) {
                    return;
                }
            }
            IAttribute att = ((ITableAttributeCellEditorRenderer) r).getAttribute();
            ((ITableAttributeCellEditorRenderer) r).applyAttributeChanges(c, att, value);
            if (this.m_ac.getController() instanceof IExtendedApplicationController) {
                ((IExtendedApplicationController) this.m_ac.getController()).updateElement(c, false);
            } else {
                this.m_ac.getController().updateElement(c);
            }
        }
    }
    this.m_v.refresh();
}
Also used : Item(org.eclipse.swt.widgets.Item) ITableCellRenderer(de.janrufmonitor.ui.jface.application.rendering.ITableCellRenderer) ICaller(de.janrufmonitor.framework.ICaller) ICall(de.janrufmonitor.framework.ICall) IAttribute(de.janrufmonitor.framework.IAttribute) ITableAttributeCellEditorRenderer(de.janrufmonitor.ui.jface.application.rendering.ITableAttributeCellEditorRenderer)

Example 95 with ICaller

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

the class ChangeAction 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()) {
            if (selection.getFirstElement() instanceof IMultiPhoneCaller) {
                ICaller caller = (IMultiPhoneCaller) selection.getFirstElement();
                ICaller newCaller = openCallerWizard(caller);
                if (newCaller != null) {
                    // ICallerList list = this.getRuntime().getCallerFactory().createCallerList(1);
                    // list.add(caller);
                    // this.m_app.getController().deleteElements(list);
                    // 
                    // list.clear();
                    // list.add(newCaller);
                    // 
                    // this.m_app.getController().addElements(list);
                    ICallerList list = this.getRuntime().getCallerFactory().createCallerList(1);
                    list.add(newCaller);
                    this.m_app.getController().updateElement(list);
                    this.m_app.updateViews(true);
                }
            } else if (selection.getFirstElement() instanceof ICaller) {
                ICaller caller = (ICaller) selection.getFirstElement();
                ICaller newCaller = openCallerWizard(caller);
                if (newCaller != null) {
                    ICallerList list = this.getRuntime().getCallerFactory().createCallerList(1);
                    list.add(caller);
                    this.m_app.getController().deleteElements(list);
                    list.clear();
                    list.add(newCaller);
                    this.m_app.getController().addElements(list);
                    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) IMultiPhoneCaller(de.janrufmonitor.framework.IMultiPhoneCaller) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

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