Search in sources :

Example 6 with IWriteCallerRepository

use of de.janrufmonitor.repository.types.IWriteCallerRepository in project janrufmonitor by tbrandt77.

the class ConsoleImport method execute.

public void execute() throws Exception {
    this.isExecuting = true;
    if (this.getExecuteParams().length != 1) {
        System.out.println("ERROR: Paramters are invalid. Please specify a valid module for installation.");
        this.isExecuting = false;
        return;
    }
    String filename = this.getExecuteParams()[0];
    IImExporter imp = ImExportFactory.getInstance().getImporter("OldDatFileCallerImporter");
    if (imp != null && imp instanceof ICallerImporter) {
        ((ICallerImporter) imp).setFilename(filename);
        ICallerList cl = ((ICallerImporter) imp).doImport();
        ICallerManager mgr = this.getRuntime().getCallerManagerFactory().getCallerManager("CallerDirectory");
        if (mgr != null && mgr.isActive() && mgr.isSupported(IWriteCallerRepository.class)) {
            ((IWriteCallerRepository) mgr).setCaller(cl);
            System.out.println("INFO: Successfully imported " + cl.size() + " caller entries.");
        } else {
            System.out.println("ERROR: Caller manager is missing.");
        }
    } else {
        System.out.println("ERROR: import filter for DAT files is missing.");
    }
    this.isExecuting = false;
}
Also used : ICallerList(de.janrufmonitor.framework.ICallerList) IWriteCallerRepository(de.janrufmonitor.repository.types.IWriteCallerRepository) IImExporter(de.janrufmonitor.repository.imexport.IImExporter) ICallerImporter(de.janrufmonitor.repository.imexport.ICallerImporter) ICallerManager(de.janrufmonitor.repository.ICallerManager)

Example 7 with IWriteCallerRepository

use of de.janrufmonitor.repository.types.IWriteCallerRepository 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)

Aggregations

ICallerManager (de.janrufmonitor.repository.ICallerManager)7 IWriteCallerRepository (de.janrufmonitor.repository.types.IWriteCallerRepository)7 ICallerList (de.janrufmonitor.framework.ICallerList)5 ICaller (de.janrufmonitor.framework.ICaller)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 IAttribute (de.janrufmonitor.framework.IAttribute)2 HandlerException (de.janrufmonitor.service.commons.http.handler.HandlerException)2 SWTExecuter (de.janrufmonitor.ui.swt.SWTExecuter)2 Shell (org.eclipse.swt.widgets.Shell)2 ICall (de.janrufmonitor.framework.ICall)1 ICallerImporter (de.janrufmonitor.repository.imexport.ICallerImporter)1 IImExporter (de.janrufmonitor.repository.imexport.IImExporter)1 IExtendedApplicationController (de.janrufmonitor.ui.jface.application.IExtendedApplicationController)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1