Search in sources :

Example 6 with SWTExecuter

use of de.janrufmonitor.ui.swt.SWTExecuter in project janrufmonitor by tbrandt77.

the class Dialog method configureShell.

protected void configureShell(Shell shell) {
    super.configureShell(shell);
    shell.setText(this.getI18nManager().getString(this.getNamespace(), (this.isOutgoing(this.m_call) ? "outgoing" : "call"), "label", this.getLanguage()));
    shell.addControlListener(new ControlAdapter() {

        public void controlMoved(ControlEvent e) {
            if (e.widget instanceof Shell && isFreePositioning()) {
                new SWTExecuter(true, getID()) {

                    protected void execute() {
                        moveWindow();
                    }
                }.start();
            }
        }
    });
    this.setDialogPosition(shell);
}
Also used : ControlAdapter(org.eclipse.swt.events.ControlAdapter) ControlEvent(org.eclipse.swt.events.ControlEvent) SWTExecuter(de.janrufmonitor.ui.swt.SWTExecuter)

Example 7 with SWTExecuter

use of de.janrufmonitor.ui.swt.SWTExecuter in project janrufmonitor by tbrandt77.

the class SynchronizerService method startup.

public void startup() {
    super.startup();
    if (isEnabled()) {
        IEventBroker eventBroker = this.getRuntime().getEventBroker();
        eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_RETURNED_HIBERNATE));
        if (this.m_configuration != null && this.m_configuration.getProperty(CFG_SYNCSTARTUP, "false").equalsIgnoreCase("true")) {
            final long delay = 1000 * Long.parseLong(this.m_configuration.getProperty(CFG_STARTUP_DELAY, "0"));
            this.m_logger.info("Startup delay on fritzbox sync set to " + delay + " ms.");
            Thread t = new Thread(new Runnable() {

                public void run() {
                    try {
                        Thread.sleep((delay + 2000));
                    } catch (InterruptedException e) {
                    }
                    new SWTExecuter() {

                        protected void execute() {
                            synchronize(false);
                        }
                    }.start();
                }
            });
            t.setName("FritzBox-Startup-Syncthread");
            t.start();
        }
        boolean isRefreshAfterCallend = this.m_configuration.getProperty(CFG_REFRESH_AFTER_CALLEND, "false").equalsIgnoreCase("true");
        if (isRefreshAfterCallend) {
            eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_OUTGOING_CALL_ACCEPTED));
            eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLACCEPTED));
        }
        timebasedSyncing();
    }
}
Also used : SWTExecuter(de.janrufmonitor.ui.swt.SWTExecuter) IEventBroker(de.janrufmonitor.framework.event.IEventBroker)

Example 8 with SWTExecuter

use of de.janrufmonitor.ui.swt.SWTExecuter in project janrufmonitor by tbrandt77.

the class CommentCommand method execute.

public void execute() throws Exception {
    this.isExecuting = true;
    IService s = this.getRuntime().getServiceFactory().getService("CommentService");
    if (s != null && s instanceof CommentService) {
        CommentService cs = (CommentService) s;
        if (!cs.isEnabled()) {
            new SWTExecuter(true, this.getID()) {

                protected void execute() {
                    MessageDialog.openError(new Shell(DisplayManager.getDefaultDisplay()), m_i18n.getString(getNamespace(), "servicedisabled", "label", m_language), m_i18n.getString(getNamespace(), "servicedisabled", "description", m_language));
                }
            }.start();
            this.isExecuting = false;
            return;
        }
        final ICaller c = cs.getLastCaller();
        if (c == null) {
            new SWTExecuter(true, this.getID()) {

                protected void execute() {
                    MessageDialog.openError(new Shell(DisplayManager.getDefaultDisplay()), m_i18n.getString(getNamespace(), "nocaller", "label", m_language), m_i18n.getString(getNamespace(), "nocaller", "description", m_language));
                }
            }.start();
            this.isExecuting = false;
            return;
        }
        if (c.getPhoneNumber().isClired()) {
            new SWTExecuter(true, this.getID()) {

                protected void execute() {
                    MessageDialog.openError(new Shell(DisplayManager.getDefaultDisplay()), m_i18n.getString(getNamespace(), "clircaller", "label", m_language), m_i18n.getString(getNamespace(), "clircaller", "description", m_language));
                }
            }.start();
        } else {
            new SWTExecuter(true, this.getID()) {

                protected void execute() {
                    new Comment(c).open();
                }
            }.start();
        }
    } else {
        this.m_logger.warning("Service CommentService not available.");
    }
    this.isExecuting = false;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) Shell(org.eclipse.swt.widgets.Shell) CommentService(de.janrufmonitor.service.comment.CommentService) SWTExecuter(de.janrufmonitor.ui.swt.SWTExecuter) IService(de.janrufmonitor.service.IService)

Example 9 with SWTExecuter

use of de.janrufmonitor.ui.swt.SWTExecuter in project janrufmonitor by tbrandt77.

the class ManageAction method run.

public void run() {
    IService s = this.getRuntime().getServiceFactory().getService("CommentService");
    if (s != null && s instanceof CommentService) {
        CommentService cs = (CommentService) s;
        if (!cs.isEnabled()) {
            new SWTExecuter(true, this.getID()) {

                protected void execute() {
                    MessageDialog.openError(new Shell(DisplayManager.getDefaultDisplay()), getI18nManager().getString(getNamespace(), "servicedisabled", "label", getLanguage()), getI18nManager().getString(getNamespace(), "servicedisabled", "description", getLanguage()));
                }
            }.start();
            return;
        }
    }
    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) {
                Object o2 = ((ICall) o).getCaller();
                if (((ICaller) o2).getPhoneNumber().isClired())
                    return;
                new Comment(((ICall) o)).open();
            }
            if (o instanceof ICaller) {
                if (((ICaller) o).getPhoneNumber().isClired())
                    return;
                new Comment(((ICaller) o)).open();
            }
        }
    }
}
Also used : Comment(de.janrufmonitor.ui.jface.application.comment.Comment) ICaller(de.janrufmonitor.framework.ICaller) Shell(org.eclipse.swt.widgets.Shell) CommentService(de.janrufmonitor.service.comment.CommentService) ICall(de.janrufmonitor.framework.ICall) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SWTExecuter(de.janrufmonitor.ui.swt.SWTExecuter) IService(de.janrufmonitor.service.IService)

Example 10 with SWTExecuter

use of de.janrufmonitor.ui.swt.SWTExecuter in project janrufmonitor by tbrandt77.

the class FritzBoxDialogPlugin method run.

public void run() {
    new SWTExecuter(this.getLabel()) {

        protected void execute() {
            ICaller o = m_dialog.getCall().getCaller();
            String dial = ((ICaller) o).getPhoneNumber().getTelephoneNumber();
            if (!((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase(getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_INTAREA))) {
                dial = "00" + ((ICaller) o).getPhoneNumber().getIntAreaCode() + dial;
            }
            if (!dial.startsWith("0"))
                dial = "0" + dial;
            String text = getI18nManager().getString(getNamespaceDial(), "dial", "description", getLanguage());
            text = StringUtils.replaceString(text, "{%1}", dial);
            if (MessageDialog.openConfirm(new Shell(DisplayManager.getDefaultDisplay()), getI18nManager().getString(getNamespaceDial(), "success", "label", getLanguage()), text)) {
                Properties config = getRuntime().getConfigManagerFactory().getConfigManager().getProperties(FritzBoxMonitor.NAMESPACE);
                FirmwareManager fwm = FirmwareManager.getInstance();
                try {
                    if (!fwm.isLoggedIn())
                        fwm.login();
                    fwm.doCall(dial, config.getProperty(CFG_CLICKDIAL, "50"));
                    text = getI18nManager().getString(getNamespaceDial(), "success", "description", getLanguage());
                    text = StringUtils.replaceString(text, "{%1}", dial);
                    MessageDialog.openInformation(new Shell(DisplayManager.getDefaultDisplay()), getI18nManager().getString(getNamespaceDial(), "success", "label", getLanguage()), text);
                } catch (IOException e) {
                    m_logger.warning(e.toString());
                    PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespaceDial(), "faileddial", e));
                } catch (FritzBoxLoginException e) {
                    m_logger.warning(e.toString());
                    PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespaceDial(), "faileddial", e));
                } catch (DoCallException e) {
                    m_logger.warning(e.toString());
                    PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespaceDial(), "faileddial", e));
                }
            }
        }
    }.start();
}
Also used : DoCallException(de.janrufmonitor.fritzbox.firmware.exception.DoCallException) ICaller(de.janrufmonitor.framework.ICaller) Shell(org.eclipse.swt.widgets.Shell) FritzBoxLoginException(de.janrufmonitor.fritzbox.firmware.exception.FritzBoxLoginException) Message(de.janrufmonitor.exception.Message) FirmwareManager(de.janrufmonitor.fritzbox.firmware.FirmwareManager) IOException(java.io.IOException) Properties(java.util.Properties) SWTExecuter(de.janrufmonitor.ui.swt.SWTExecuter)

Aggregations

SWTExecuter (de.janrufmonitor.ui.swt.SWTExecuter)24 Shell (org.eclipse.swt.widgets.Shell)14 InvocationTargetException (java.lang.reflect.InvocationTargetException)11 List (java.util.List)11 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)11 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)11 Message (de.janrufmonitor.exception.Message)9 ICaller (de.janrufmonitor.framework.ICaller)8 ArrayList (java.util.ArrayList)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 ICall (de.janrufmonitor.framework.ICall)6 File (java.io.File)6 Viewer (org.eclipse.jface.viewers.Viewer)6 MessageBox (org.eclipse.swt.widgets.MessageBox)6 IImExporter (de.janrufmonitor.repository.imexport.IImExporter)5 ITracker (de.janrufmonitor.repository.imexport.ITracker)4 Iterator (java.util.Iterator)4 ICallerList (de.janrufmonitor.framework.ICallerList)3 FirmwareManager (de.janrufmonitor.fritzbox.firmware.FirmwareManager)3