Search in sources :

Example 71 with ProcessingException

use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.

the class AbstractForm method storeStateInternal.

/**
 * Store state of form, regardless of validity and completeness do not use or override this internal method directly
 */
protected void storeStateInternal() {
    if (!m_blockingCondition.isBlocking()) {
        String msg = TEXTS.get("FormDisposedMessage", getTitle());
        LOG.error(msg);
        throw new VetoException(msg);
    }
    fireFormStoreBefore();
    setFormStored(true);
    try {
        rebuildSearchFilter();
        m_searchFilter.setCompleted(true);
        getHandler().onStore();
        interceptStored();
        if (!isFormStored()) {
            // the form was marked as not stored in AbstractFormHandler#execStore() or AbstractForm#execStored().
            ProcessingException e = new ProcessingException("Form was marked as not stored.");
            e.consume();
            throw e;
        }
    } catch (RuntimeException | PlatformError e) {
        // clear search
        if (m_searchFilter != null) {
            m_searchFilter.clear();
        }
        // store was not successfully stored
        setFormStored(false);
        if (e instanceof RuntimeException) {
            // NOSONAR
            throwVetoExceptionInternal((RuntimeException) e);
        } else if (e instanceof PlatformError) {
            // NOSONAR
            throw e;
        }
        // if exception was caught and suppressed, this form was after all successfully stored
        // normally this code is not reached since the exception will be passed out
        setFormStored(true);
    }
    fireFormStoreAfter();
}
Also used : VetoException(org.eclipse.scout.rt.platform.exception.VetoException) PlatformError(org.eclipse.scout.rt.platform.exception.PlatformError) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Example 72 with ProcessingException

use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.

the class AbstractForm method loadFromXml.

@Override
public void loadFromXml(Element root) {
    String formId = getFormId();
    String xmlId = root.getAttribute("formId");
    if (!formId.equals(xmlId)) {
        throw new ProcessingException("xml id='{}' does not match form id='{}'", xmlId, formId);
    }
    // load properties
    Element xProps = XmlUtility.getFirstChildElement(root, "properties");
    if (xProps != null) {
        Map<String, Object> props = loadPropertiesFromXml(xProps);
        BeanUtility.setProperties(this, props, true, null);
        // load extension properties
        for (Element xExtension : XmlUtility.getChildElements(xProps, "extension")) {
            String extensionId = xExtension.getAttribute("extensionId");
            String extensionQname = xExtension.getAttribute("extensionQname");
            IFormExtension<? extends AbstractForm> extension = findFormExtensionById(extensionQname, extensionId);
            if (extension == null) {
                continue;
            }
            Map<String, Object> extensionProps = loadPropertiesFromXml(xExtension);
            BeanUtility.setProperties(extension, extensionProps, true, null);
        }
    }
    // load fields
    Element xFields = XmlUtility.getFirstChildElement(root, "fields");
    if (xFields != null) {
        for (Element xField : XmlUtility.getChildElements(xFields, "field")) {
            List<String> xmlFieldIds = new LinkedList<String>();
            // add enclosing field path to xml field IDs
            for (Element element : XmlUtility.getChildElements(xField, "enclosingField")) {
                xmlFieldIds.add(element.getAttribute("fieldId"));
            }
            xmlFieldIds.add(xField.getAttribute("fieldId"));
            FindFieldByXmlIdsVisitor v = new FindFieldByXmlIdsVisitor(xmlFieldIds.toArray(new String[xmlFieldIds.size()]));
            visitFields(v);
            IFormField f = v.getField();
            if (f != null) {
                f.loadFromXml(xField);
            }
        }
    }
    // in all tabboxes select the first tab that contains data, iff the current
    // tab has no values set
    getRootGroupBox().visitFields(new IFormFieldVisitor() {

        @Override
        public boolean visitField(IFormField field, int level, int fieldIndex) {
            if (field instanceof ITabBox) {
                ITabBox tabBox = (ITabBox) field;
                IGroupBox selbox = tabBox.getSelectedTab();
                if (selbox == null || !selbox.isSaveNeeded()) {
                    for (IGroupBox g : tabBox.getGroupBoxes()) {
                        if (g.isSaveNeeded()) {
                            tabBox.setSelectedTab(g);
                            break;
                        }
                    }
                }
            }
            return true;
        }
    });
}
Also used : IHtmlListElement(org.eclipse.scout.rt.platform.html.IHtmlListElement) Element(org.w3c.dom.Element) FindFieldByXmlIdsVisitor(org.eclipse.scout.rt.client.ui.form.internal.FindFieldByXmlIdsVisitor) LinkedList(java.util.LinkedList) IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) IGroupBox(org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox) IExtensibleObject(org.eclipse.scout.rt.shared.extension.IExtensibleObject) ITabBox(org.eclipse.scout.rt.client.ui.form.fields.tabbox.ITabBox) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Example 73 with ProcessingException

use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.

the class AbstractPageWithTable method attachToSearchFormInternal.

private void attachToSearchFormInternal() {
    if (m_searchForm == null) {
        return;
    }
    m_searchForm.setDisplayHint(ISearchForm.DISPLAY_HINT_VIEW);
    if (m_searchForm.getDisplayViewId() == null) {
        m_searchForm.setDisplayViewId(IForm.VIEW_ID_PAGE_SEARCH);
    }
    m_searchForm.setShowOnStart(false);
    // listen for search action
    m_searchFormListener = new FormListener() {

        @Override
        public void formChanged(FormEvent e) {
            switch(e.getType()) {
                case FormEvent.TYPE_LOAD_COMPLETE:
                    {
                        // do page reload to execute search
                        try {
                            T table = getTable(false);
                            if (table != null) {
                                table.discardAllRows();
                            }
                        } catch (RuntimeException | PlatformError ex) {
                            BEANS.get(ExceptionHandler.class).handle(ex);
                        }
                        break;
                    }
                case FormEvent.TYPE_STORE_AFTER:
                    {
                        // do page reload to execute search
                        try {
                            reloadPage();
                        } catch (RuntimeException | PlatformError ex) {
                            BEANS.get(ExceptionHandler.class).handle(ex);
                        }
                        break;
                    }
            }
        }
    };
    m_searchForm.addFormListener(m_searchFormListener);
    try {
        interceptInitSearchForm();
    } catch (Exception e) {
        BEANS.get(ExceptionHandler.class).handle(new ProcessingException("error creating search form '" + m_searchForm.getClass().getName() + "' for page '" + getClass().getName() + "'.", e));
    }
}
Also used : FormListener(org.eclipse.scout.rt.client.ui.form.FormListener) FormEvent(org.eclipse.scout.rt.client.ui.form.FormEvent) PlatformError(org.eclipse.scout.rt.platform.exception.PlatformError) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) VetoException(org.eclipse.scout.rt.platform.exception.VetoException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Example 74 with ProcessingException

use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.

the class AbstractFormField method initLocalKeyStrokes.

protected List<IKeyStroke> initLocalKeyStrokes() {
    List<Class<? extends IKeyStroke>> configuredKeyStrokes = getConfiguredKeyStrokes();
    List<IKeyStroke> contributedKeyStrokes = m_contributionHolder.getContributionsByClass(IKeyStroke.class);
    Map<String, IKeyStroke> ksMap = new HashMap<String, IKeyStroke>(configuredKeyStrokes.size() + contributedKeyStrokes.size());
    for (Class<? extends IKeyStroke> keystrokeClazz : configuredKeyStrokes) {
        IKeyStroke ks = ConfigurationUtility.newInnerInstance(this, keystrokeClazz);
        ks.initAction();
        if (ks.getKeyStroke() != null) {
            ksMap.put(ks.getKeyStroke().toUpperCase(), ks);
        }
    }
    for (IKeyStroke ks : contributedKeyStrokes) {
        try {
            ks.initAction();
            if (ks.getKeyStroke() != null) {
                ksMap.put(ks.getKeyStroke().toUpperCase(), ks);
            }
        } catch (Exception e) {
            BEANS.get(ExceptionHandler.class).handle(new ProcessingException("error initializing key stroke '" + ks.getClass().getName() + "'.", e));
        }
    }
    return CollectionUtility.arrayListWithoutNullElements(ksMap.values());
}
Also used : HashMap(java.util.HashMap) IKeyStroke(org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Example 75 with ProcessingException

use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.

the class AbstractBookmarkMenu method createNewBookmark.

protected void createNewBookmark(int kind) {
    Bookmark b = ClientSessionProvider.currentSession().getDesktop().createBookmark();
    if (b != null) {
        IBookmarkService service = BEANS.get(IBookmarkService.class);
        b.setKind(kind);
        IBookmarkForm form = null;
        if (getConfiguredBookmarkForm() != null) {
            try {
                form = getConfiguredBookmarkForm().newInstance();
            } catch (Exception e) {
                BEANS.get(ExceptionHandler.class).handle(new ProcessingException("error creating instance of class '" + getConfiguredBookmarkForm().getName() + "'.", e));
            }
        }
        if (form == null) {
            form = new BookmarkForm();
        }
        if (kind == Bookmark.GLOBAL_BOOKMARK) {
            form.setBookmarkRootFolder(service.getBookmarkData().getGlobalBookmarks());
        } else if (kind == Bookmark.USER_BOOKMARK) {
            form.setBookmarkRootFolder(service.getBookmarkData().getUserBookmarks());
        }
        form.setBookmark(b);
        form.startNew();
        form.waitFor();
        if (form.isFormStored()) {
            b.setTitle(form.getBookmark().getTitle());
            b.setKeyStroke(form.getBookmark().getKeyStroke());
            b.setOrder(form.getBookmark().getOrder());
            BookmarkFolder folder = form.getFolder();
            if (folder == null) {
                folder = form.getBookmarkRootFolder();
            }
            folder.getBookmarks().add(b);
            service.storeBookmarks();
        }
    }
}
Also used : Bookmark(org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark) BookmarkFolder(org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder) BookmarkForm(org.eclipse.scout.rt.client.ui.desktop.bookmark.BookmarkForm) IBookmarkForm(org.eclipse.scout.rt.client.ui.desktop.bookmark.IBookmarkForm) IBookmarkForm(org.eclipse.scout.rt.client.ui.desktop.bookmark.IBookmarkForm) IBookmarkService(org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Aggregations

ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)142 IOException (java.io.IOException)48 MessagingException (javax.mail.MessagingException)21 Test (org.junit.Test)19 ArrayList (java.util.ArrayList)17 File (java.io.File)14 VetoException (org.eclipse.scout.rt.platform.exception.VetoException)12 Folder (javax.mail.Folder)10 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)9 RemoteFile (org.eclipse.scout.rt.shared.services.common.file.RemoteFile)9 NoSuchProviderException (java.security.NoSuchProviderException)8 AssertionException (org.eclipse.scout.rt.platform.util.Assertions.AssertionException)8 FileInputStream (java.io.FileInputStream)7 InputStream (java.io.InputStream)7 UnsupportedEncodingException (java.io.UnsupportedEncodingException)7 FileOutputStream (java.io.FileOutputStream)6 Message (javax.mail.Message)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 OutputStream (java.io.OutputStream)5 HashMap (java.util.HashMap)5