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();
}
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;
}
});
}
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));
}
}
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());
}
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();
}
}
}
Aggregations