Search in sources :

Example 76 with IAttribute

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

the class Etiquet method renderAsText.

public String renderAsText() {
    if (this.m_o != null) {
        if (this.m_o instanceof ICall) {
            this.m_o = ((ICall) this.m_o).getCaller();
        }
        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) {
            IAttributeMap m = ((ITreeItemCallerData) m_o).getAttributes();
            IPhonenumber pn = ((ITreeItemCallerData) m_o).getPhone();
            if (m.contains(IMacAddressBookNumberMapping.MAPPING_ATTTRIBUTE_ID + pn.getTelephoneNumber())) {
                IAttribute type = m.get(IMacAddressBookNumberMapping.MAPPING_ATTTRIBUTE_ID + pn.getTelephoneNumber());
                if (type != null) {
                    return PIMRuntime.getInstance().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, type.getValue(), "label", getLanguage());
                }
            }
        }
    }
    return "";
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICall(de.janrufmonitor.framework.ICall) IAttribute(de.janrufmonitor.framework.IAttribute) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) ITreeItemCallerData(de.janrufmonitor.ui.jface.application.ITreeItemCallerData) ITreeItemCallerData(de.janrufmonitor.ui.jface.application.ITreeItemCallerData) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 77 with IAttribute

use of de.janrufmonitor.framework.IAttribute 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 78 with IAttribute

use of de.janrufmonitor.framework.IAttribute 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 79 with IAttribute

use of de.janrufmonitor.framework.IAttribute 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 80 with IAttribute

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

the class IdentifyAction method run.

public synchronized void run() {
    Viewer v = this.m_app.getApplication().getViewer();
    if (v != null && v instanceof Viewer) {
        final IStructuredSelection selection = (IStructuredSelection) v.getSelection();
        if (!selection.isEmpty()) {
            if (selection.getFirstElement() instanceof ICaller) {
                ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
                try {
                    IRunnableWithProgress r = new IRunnableWithProgress() {

                        public void run(IProgressMonitor progressMonitor) {
                            progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "identifyprogress", "label", getLanguage()), IProgressMonitor.UNKNOWN);
                            progressMonitor.worked(1);
                            final ICaller caller = (ICaller) selection.getFirstElement();
                            List phones = new ArrayList();
                            if (caller instanceof IMultiPhoneCaller) {
                                phones.addAll(((IMultiPhoneCaller) caller).getPhonenumbers());
                            } else {
                                phones.add(caller.getPhoneNumber());
                            }
                            String ignoreCM = "";
                            IAttribute att = caller.getAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER);
                            if (att != null) {
                                ignoreCM = att.getValue();
                            }
                            List activeCMs = getAllActiveCallerManagers(getRuntime(), ignoreCM);
                            ICaller identifiedCaller = null;
                            // identification only makes sence if there are active CMs or if there are numbers
                            if (activeCMs.size() > 0 && phones.size() > 0) {
                                IPhonenumber pn = null;
                                for (int i = 0; i < phones.size(); i++) {
                                    pn = (IPhonenumber) phones.get(i);
                                    identifiedCaller = Identifier.identify(getRuntime(), pn, activeCMs);
                                    if (identifiedCaller != null)
                                        break;
                                }
                            }
                            progressMonitor.done();
                            if (identifiedCaller == null) {
                                progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "failedidentify", "label", getLanguage()), IProgressMonitor.UNKNOWN);
                                PropagationFactory.getInstance().fire(new Message(Message.INFO, getNamespace(), "failedidentify", new Exception("Caller with number " + caller.getPhoneNumber() + " not identified...")));
                                return;
                            }
                            // remove repository flag and set all numbers
                            if (!(identifiedCaller instanceof IMultiPhoneCaller)) {
                                identifiedCaller = getRuntime().getCallerFactory().toMultiPhoneCaller(identifiedCaller);
                            }
                            ((IMultiPhoneCaller) identifiedCaller).setPhonenumbers(phones);
                            ((IMultiPhoneCaller) identifiedCaller).setPhoneNumber((IPhonenumber) phones.get(0));
                            IAttributeMap m = getRuntime().getCallerFactory().createAttributeMap();
                            m.addAll(caller.getAttributes());
                            m.addAll(identifiedCaller.getAttributes());
                            m.remove(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER);
                            identifiedCaller.setAttributes(m);
                            final ICaller theIdentifiedCaller = identifiedCaller;
                            new SWTExecuter() {

                                protected void execute() {
                                    if (MessageDialog.openConfirm(new Shell(DisplayManager.getDefaultDisplay()), getI18nManager().getString(getNamespace(), "identify", "label", getLanguage()), getI18nManager().getString(getNamespace(), "identify", "description", getLanguage()))) {
                                        ICaller newCaller = openCallerWizard(theIdentifiedCaller);
                                        if (newCaller != null) {
                                            ICallerList list = getRuntime().getCallerFactory().createCallerList(1);
                                            list.add(caller);
                                            m_app.getController().deleteElements(list);
                                            list.clear();
                                            list.add(newCaller);
                                            m_app.getController().addElements(list);
                                            m_app.updateViews(true);
                                        }
                                    }
                                }
                            }.start();
                        }
                    };
                    pmd.setBlockOnOpen(false);
                    pmd.run(true, false, r);
                // ModalContext.run(r, true, pmd.getProgressMonitor(), DisplayManager.getDefaultDisplay());
                } catch (InterruptedException e) {
                    m_logger.log(Level.SEVERE, e.getMessage(), e);
                } catch (InvocationTargetException e) {
                    m_logger.log(Level.SEVERE, e.getMessage(), e);
                }
            }
        }
    }
}
Also used : Message(de.janrufmonitor.exception.Message) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ArrayList(java.util.ArrayList) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ICaller(de.janrufmonitor.framework.ICaller) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Shell(org.eclipse.swt.widgets.Shell) ICallerList(de.janrufmonitor.framework.ICallerList) IAttribute(de.janrufmonitor.framework.IAttribute) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) ArrayList(java.util.ArrayList) ICallerList(de.janrufmonitor.framework.ICallerList) List(java.util.List) IMultiPhoneCaller(de.janrufmonitor.framework.IMultiPhoneCaller) SWTExecuter(de.janrufmonitor.ui.swt.SWTExecuter) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Aggregations

IAttribute (de.janrufmonitor.framework.IAttribute)111 ICaller (de.janrufmonitor.framework.ICaller)44 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)40 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)39 List (java.util.List)34 ICallerList (de.janrufmonitor.framework.ICallerList)31 ArrayList (java.util.ArrayList)29 Iterator (java.util.Iterator)25 ICall (de.janrufmonitor.framework.ICall)19 IMultiPhoneCaller (de.janrufmonitor.framework.IMultiPhoneCaller)15 SQLException (java.sql.SQLException)15 File (java.io.File)14 AttributeFilter (de.janrufmonitor.repository.filter.AttributeFilter)12 IOException (java.io.IOException)12 Message (de.janrufmonitor.exception.Message)11 ComFailException (com.jacob.com.ComFailException)10 Date (java.util.Date)10 IMsn (de.janrufmonitor.framework.IMsn)9 Dispatch (com.jacob.com.Dispatch)8 UUID (de.janrufmonitor.util.uuid.UUID)8