Search in sources :

Example 1 with IExtendedApplicationController

use of de.janrufmonitor.ui.jface.application.IExtendedApplicationController in project janrufmonitor by tbrandt77.

the class ScoreNumberTellows method run.

public void run() {
    Viewer v = this.m_app.getApplication().getViewer();
    if (v != null) {
        IStructuredSelection selection = (IStructuredSelection) v.getSelection();
        if (!selection.isEmpty()) {
            Iterator iter = selection.iterator();
            while (iter.hasNext()) {
                Object o1 = iter.next();
                Object o = null;
                if (o1 instanceof ICall) {
                    o = ((ICall) o1).getCaller();
                }
                if (o1 instanceof ICaller) {
                    o = o1;
                }
                if (o != null) {
                    if (!((ICaller) o).getPhoneNumber().isClired() && !PhonenumberAnalyzer.getInstance(getRuntime()).isInternal(((ICaller) o).getPhoneNumber()) && (((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("49") || ((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("41") || ((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("43"))) {
                        final Object o2 = o1;
                        final Object o3 = o;
                        ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
                        try {
                            IRunnableWithProgress r = new IRunnableWithProgress() {

                                public void run(IProgressMonitor progressMonitor) {
                                    progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "scoring", "label", getLanguage()), IProgressMonitor.UNKNOWN);
                                    progressMonitor.worked(1);
                                    try {
                                        IAttributeMap m = TellowsProxy.getInstance().getTellowsData(((ICaller) o3).getPhoneNumber().getTelephoneNumber(), ((ICaller) o3).getPhoneNumber().getIntAreaCode());
                                        if (m.size() > 0) {
                                            ((ICaller) o3).getAttributes().addAll(m);
                                            if (m_app.getController() instanceof IExtendedApplicationController)
                                                ((IExtendedApplicationController) m_app.getController()).updateElement(o2, false);
                                            else
                                                m_app.getController().updateElement(o2);
                                        }
                                    } catch (Exception e) {
                                        PropagationFactory.getInstance().fire(new Message(Message.ERROR, getRuntime().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, "title", "label", getLanguage()), e), "Tray");
                                    }
                                    progressMonitor.done();
                                }
                            };
                            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);
                        }
                    }
                }
            }
            this.m_app.updateViews(true);
        }
    }
}
Also used : ICall(de.janrufmonitor.framework.ICall) Message(de.janrufmonitor.exception.Message) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) 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) Iterator(java.util.Iterator) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) IExtendedApplicationController(de.janrufmonitor.ui.jface.application.IExtendedApplicationController)

Example 2 with IExtendedApplicationController

use of de.janrufmonitor.ui.jface.application.IExtendedApplicationController in project janrufmonitor by tbrandt77.

the class TamMessageDelete 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) {
                if (((ICall) o).getAttributes().contains("fritzbox.tamurl")) {
                    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()))) {
                        ((ICall) o).getAttributes().remove("fritzbox.tamurl");
                        ((ICall) o).getAttributes().remove("fritzbox.tamduration");
                        if (m_app.getController() instanceof IExtendedApplicationController) {
                            ((IExtendedApplicationController) m_app.getController()).updateElement(((ICall) o), false);
                        } else {
                            m_app.getController().updateElement(((ICall) o));
                        }
                        this.m_app.updateViews(true);
                    }
                } else {
                    new SWTExecuter() {

                        protected void execute() {
                            int style = SWT.APPLICATION_MODAL | SWT.OK;
                            MessageBox messageBox = new MessageBox(new Shell(DisplayManager.getDefaultDisplay()), style);
                            messageBox.setMessage(getI18nManager().getString(getNamespace(), "notam", "label", getLanguage()));
                            messageBox.open();
                        }
                    }.start();
                    return;
                }
            }
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ICall(de.janrufmonitor.framework.ICall) Viewer(org.eclipse.jface.viewers.Viewer) IExtendedApplicationController(de.janrufmonitor.ui.jface.application.IExtendedApplicationController) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SWTExecuter(de.janrufmonitor.ui.swt.SWTExecuter) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 3 with IExtendedApplicationController

use of de.janrufmonitor.ui.jface.application.IExtendedApplicationController in project janrufmonitor by tbrandt77.

the class AssignAction method run.

public void run() {
    Viewer v = this.m_app.getApplication().getViewer();
    if (v != null && v instanceof TableViewer) {
        IStructuredSelection selection = (IStructuredSelection) v.getSelection();
        if (!selection.isEmpty()) {
            final ICall call = (ICall) selection.getFirstElement();
            ICaller caller = call.getCaller();
            final ICaller newCaller = openCallerWizard(caller);
            if (newCaller != null) {
                int l_status = SWT.NO;
                if (!newCaller.getPhoneNumber().isClired()) {
                    int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
                    MessageBox messageBox = new MessageBox(new Shell(DisplayManager.getDefaultDisplay()), style);
                    messageBox.setMessage(getI18nManager().getString(getNamespace(), "setall", "label", getLanguage()));
                    l_status = messageBox.open();
                }
                final int status = l_status;
                ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
                try {
                    IRunnableWithProgress r = new IRunnableWithProgress() {

                        public void run(IProgressMonitor progressMonitor) {
                            progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "assignprogress", "label", getLanguage()), IProgressMonitor.UNKNOWN);
                            progressMonitor.worked(1);
                            call.setCaller(newCaller);
                            if (status == SWT.NO && m_app.getController() instanceof IExtendedApplicationController) {
                                // added 2009/12/31: only update single entry
                                progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "assignprogress", "label", getLanguage()));
                                ((IExtendedApplicationController) m_app.getController()).updateElement(call, false);
                            } else {
                                progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "assignall", "label", getLanguage()));
                                m_app.getController().updateElement(call);
                            }
                            progressMonitor.done();
                        }
                    };
                    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);
                }
                if (!newCaller.getPhoneNumber().isClired()) {
                    new SWTExecuter() {

                        protected void execute() {
                            int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
                            MessageBox messageBox = new MessageBox(new Shell(DisplayManager.getDefaultDisplay()), style);
                            messageBox.setMessage(getI18nManager().getString(getNamespace(), "addressbookconfirm", "label", getLanguage()));
                            if (messageBox.open() == SWT.YES) {
                                List cpms = getRuntime().getCallerManagerFactory().getTypedCallerManagers(IWriteCallerRepository.class);
                                ICallerManager cmgr = null;
                                for (int i = 0; i < cpms.size(); i++) {
                                    cmgr = (ICallerManager) cpms.get(i);
                                    if (cmgr.isActive() && cmgr.isSupported(IWriteCallerRepository.class))
                                        ((IWriteCallerRepository) cmgr).updateCaller(newCaller);
                                }
                            }
                            m_app.updateViews(true);
                        }
                    }.start();
                } else {
                    m_app.updateViews(true);
                }
            // this.m_app.updateViews(true);
            }
        }
    }
}
Also used : ICall(de.janrufmonitor.framework.ICall) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) InvocationTargetException(java.lang.reflect.InvocationTargetException) ICallerManager(de.janrufmonitor.repository.ICallerManager) MessageBox(org.eclipse.swt.widgets.MessageBox) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ICaller(de.janrufmonitor.framework.ICaller) Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IWriteCallerRepository(de.janrufmonitor.repository.types.IWriteCallerRepository) IExtendedApplicationController(de.janrufmonitor.ui.jface.application.IExtendedApplicationController) List(java.util.List) TableViewer(org.eclipse.jface.viewers.TableViewer) SWTExecuter(de.janrufmonitor.ui.swt.SWTExecuter)

Example 4 with IExtendedApplicationController

use of de.janrufmonitor.ui.jface.application.IExtendedApplicationController in project janrufmonitor by tbrandt77.

the class ReIdentifyAction method run.

public void run() {
    Viewer v = this.m_app.getApplication().getViewer();
    if (v != null && v instanceof TableViewer) {
        IStructuredSelection selection = (IStructuredSelection) v.getSelection();
        if (!selection.isEmpty()) {
            final ICall call = (ICall) selection.getFirstElement();
            ICaller caller = call.getCaller();
            if (caller.getPhoneNumber().isClired()) {
                new SWTExecuter() {

                    protected void execute() {
                        int style = SWT.APPLICATION_MODAL | SWT.OK;
                        MessageBox messageBox = new MessageBox(new Shell(DisplayManager.getDefaultDisplay()), style);
                        messageBox.setMessage(getI18nManager().getString(getNamespace(), "clir", "label", getLanguage()));
                        messageBox.open();
                    }
                }.start();
                return;
            }
            List cms = getAllActiveCallerManagers(getRuntime());
            if (cms.size() == 0) {
                new SWTExecuter() {

                    protected void execute() {
                        int style = SWT.APPLICATION_MODAL | SWT.OK;
                        MessageBox messageBox = new MessageBox(new Shell(DisplayManager.getDefaultDisplay()), style);
                        messageBox.setMessage(getI18nManager().getString(getNamespace(), "nocms", "label", getLanguage()));
                        messageBox.open();
                    }
                }.start();
                return;
            }
            caller = Identifier.identify(getRuntime(), caller.getPhoneNumber(), cms);
            if (caller == null) {
                new SWTExecuter() {

                    protected void execute() {
                        int style = SWT.APPLICATION_MODAL | SWT.OK;
                        MessageBox messageBox = new MessageBox(new Shell(DisplayManager.getDefaultDisplay()), style);
                        messageBox.setMessage(getI18nManager().getString(getNamespace(), "notidentified", "label", getLanguage()));
                        messageBox.open();
                    }
                }.start();
                return;
            }
            final ICaller newCaller = openCallerWizard(caller);
            if (newCaller != null) {
                int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
                MessageBox messageBox = new MessageBox(DisplayManager.getDefaultDisplay().getActiveShell(), style);
                messageBox.setMessage(getI18nManager().getString(getNamespace(), "setall", "label", getLanguage()));
                final int status = messageBox.open();
                ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
                try {
                    IRunnableWithProgress r = new IRunnableWithProgress() {

                        public void run(IProgressMonitor progressMonitor) {
                            progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "assignprogress", "label", getLanguage()), IProgressMonitor.UNKNOWN);
                            progressMonitor.worked(1);
                            call.setCaller(newCaller);
                            processModifierServices(call);
                            if (status == SWT.NO && m_app.getController() instanceof IExtendedApplicationController) {
                                // added 2009/12/31: only update single entry
                                progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "assignprogress", "label", getLanguage()));
                                ((IExtendedApplicationController) m_app.getController()).updateElement(call, false);
                            } else {
                                progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "assignall", "label", getLanguage()));
                                m_app.getController().updateElement(call);
                            }
                            progressMonitor.done();
                        }
                    };
                    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);
                }
                this.m_app.updateViews(true);
            }
        }
    }
}
Also used : ICall(de.janrufmonitor.framework.ICall) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) InvocationTargetException(java.lang.reflect.InvocationTargetException) MessageBox(org.eclipse.swt.widgets.MessageBox) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ICaller(de.janrufmonitor.framework.ICaller) Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ArrayList(java.util.ArrayList) List(java.util.List) IExtendedApplicationController(de.janrufmonitor.ui.jface.application.IExtendedApplicationController) TableViewer(org.eclipse.jface.viewers.TableViewer) SWTExecuter(de.janrufmonitor.ui.swt.SWTExecuter)

Aggregations

ICall (de.janrufmonitor.framework.ICall)4 IExtendedApplicationController (de.janrufmonitor.ui.jface.application.IExtendedApplicationController)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 Viewer (org.eclipse.jface.viewers.Viewer)4 ICaller (de.janrufmonitor.framework.ICaller)3 SWTExecuter (de.janrufmonitor.ui.swt.SWTExecuter)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)3 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)3 MessageBox (org.eclipse.swt.widgets.MessageBox)3 Shell (org.eclipse.swt.widgets.Shell)3 List (java.util.List)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 Message (de.janrufmonitor.exception.Message)1 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)1 ICallerManager (de.janrufmonitor.repository.ICallerManager)1 IWriteCallerRepository (de.janrufmonitor.repository.types.IWriteCallerRepository)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1