Search in sources :

Example 1 with Comment

use of de.janrufmonitor.ui.jface.application.comment.Comment 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 2 with Comment

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

the class PDFHistoryAction method run.

public void run() {
    FileDialog dialog = new FileDialog(new Shell(DisplayManager.getDefaultDisplay()), SWT.SAVE);
    dialog.setFilterExtensions(new String[] { "*.pdf" });
    dialog.setFilterNames(new String[] { getI18nManager().getString(getNamespace(), "pdffilter", "label", getLanguage()) });
    dialog.setText(getI18nManager().getString(getNamespace(), "pdf", "label", getLanguage()));
    String filename = dialog.open();
    if (filename != null && filename.length() > 0) {
        if (this.m_app.getApplication() instanceof Comment) {
            ICaller c = ((Comment) this.m_app.getApplication()).getCurrentCaller();
            IService srv = getRuntime().getServiceFactory().getService("CommentService");
            if (srv != null && srv instanceof CommentService) {
                CommentCallerHandler cch = ((CommentService) srv).getHandler();
                if (cch.hasCommentCaller(c)) {
                    ICommentCaller cc = cch.getCommentCaller(c);
                    try {
                        Class pdfclass = Thread.currentThread().getContextClassLoader().loadClass("de.janrufmonitor.ui.jface.application.comment.action.PDFCreator");
                        Constructor con = pdfclass.getConstructor(new Class[] { ICommentCaller.class, String.class });
                        Object pdfcreator = con.newInstance(new Object[] { cc, filename });
                        Method m = pdfclass.getMethod("createPdf", (Class) null);
                        m.invoke(pdfcreator, (Object) null);
                    } catch (ClassNotFoundException e) {
                        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
                    } catch (SecurityException e) {
                        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
                    } catch (NoSuchMethodException e) {
                        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
                    } catch (IllegalArgumentException e) {
                        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
                    } catch (InstantiationException e) {
                        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
                    } catch (IllegalAccessException e) {
                        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
                    } catch (InvocationTargetException e) {
                        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
                    }
                }
            }
        }
    }
}
Also used : Comment(de.janrufmonitor.ui.jface.application.comment.Comment) ICommentCaller(de.janrufmonitor.service.comment.api.ICommentCaller) Constructor(java.lang.reflect.Constructor) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) ICaller(de.janrufmonitor.framework.ICaller) Shell(org.eclipse.swt.widgets.Shell) CommentService(de.janrufmonitor.service.comment.CommentService) CommentCallerHandler(de.janrufmonitor.service.comment.CommentCallerHandler) FileDialog(org.eclipse.swt.widgets.FileDialog) IService(de.janrufmonitor.service.IService)

Example 3 with Comment

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

the class NewAction method run.

public void run() {
    Object callableObject = null;
    if (this.m_app instanceof Comment) {
        callableObject = ((Comment) this.m_app).getCallableObject();
    }
    CommentDialog cd = new CommentDialog(DisplayManager.getDefaultDisplay().getActiveShell(), null, callableObject);
    int result = cd.open();
    if (result == CommentDialog.OK) {
        IComment c = cd.getResult();
        this.m_app.getController().updateElement(c);
        this.m_app.updateViews(true);
    }
}
Also used : IComment(de.janrufmonitor.service.comment.api.IComment) Comment(de.janrufmonitor.ui.jface.application.comment.Comment) IComment(de.janrufmonitor.service.comment.api.IComment) CommentDialog(de.janrufmonitor.ui.jface.dialogs.CommentDialog)

Example 4 with Comment

use of de.janrufmonitor.ui.jface.application.comment.Comment 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 IComment) {
                Object callableObject = null;
                if (this.m_app instanceof Comment) {
                    callableObject = ((Comment) this.m_app).getCallableObject();
                }
                CommentDialog cd = new CommentDialog(DisplayManager.getDefaultDisplay().getActiveShell(), ((IComment) o), callableObject);
                int result = cd.open();
                if (result == CommentDialog.OK) {
                    IComment c = cd.getResult();
                    this.m_app.getController().updateElement(c);
                    this.m_app.updateViews(true);
                }
            }
        }
    }
}
Also used : IComment(de.janrufmonitor.service.comment.api.IComment) Comment(de.janrufmonitor.ui.jface.application.comment.Comment) IComment(de.janrufmonitor.service.comment.api.IComment) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CommentDialog(de.janrufmonitor.ui.jface.dialogs.CommentDialog)

Aggregations

Comment (de.janrufmonitor.ui.jface.application.comment.Comment)4 ICaller (de.janrufmonitor.framework.ICaller)2 IService (de.janrufmonitor.service.IService)2 CommentService (de.janrufmonitor.service.comment.CommentService)2 IComment (de.janrufmonitor.service.comment.api.IComment)2 CommentDialog (de.janrufmonitor.ui.jface.dialogs.CommentDialog)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 Viewer (org.eclipse.jface.viewers.Viewer)2 Shell (org.eclipse.swt.widgets.Shell)2 ICall (de.janrufmonitor.framework.ICall)1 CommentCallerHandler (de.janrufmonitor.service.comment.CommentCallerHandler)1 ICommentCaller (de.janrufmonitor.service.comment.api.ICommentCaller)1 SWTExecuter (de.janrufmonitor.ui.swt.SWTExecuter)1 Constructor (java.lang.reflect.Constructor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 FileDialog (org.eclipse.swt.widgets.FileDialog)1