use of org.eclipse.scout.rt.platform.exception.PlatformError 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.PlatformError in project scout.rt by eclipse.
the class AbstractForm method closeFormInternal.
private void closeFormInternal(boolean kill) {
if (isBlockingInternal()) {
try {
// check if there is an active close, cancel or finish button
final Set<Integer> enabledSystemTypes = new HashSet<Integer>();
final Set<IButton> enabledSystemButtons = new HashSet<IButton>();
IFormFieldVisitor v = new IFormFieldVisitor() {
@Override
public boolean visitField(IFormField field, int level, int fieldIndex) {
if (field instanceof IButton) {
IButton b = (IButton) field;
if (b.isEnabled() && b.isVisible()) {
enabledSystemTypes.add(b.getSystemType());
enabledSystemButtons.add(b);
}
}
return true;
}
};
visitFields(v);
interceptOnCloseRequest(kill, enabledSystemTypes);
} catch (RuntimeException | PlatformError e) {
throw BEANS.get(PlatformExceptionTranslator.class).translate(e).withContextInfo("form", getClass().getName());
}
}
}
use of org.eclipse.scout.rt.platform.exception.PlatformError in project scout.rt by eclipse.
the class AbstractForm method doReset.
@Override
public void doReset() {
setFormLoading(true);
// reset values
P_AbstractCollectingFieldVisitor v = new P_AbstractCollectingFieldVisitor() {
@Override
public boolean visitField(IFormField field, int level, int fieldIndex) {
if (field instanceof IValueField) {
IValueField f = (IValueField) field;
f.resetValue();
} else if (field instanceof IComposerField) {
IComposerField f = (IComposerField) field;
f.resetValue();
}
return true;
}
};
try {
visitFields(v);
// init again
initForm();
// load again
loadStateInternal();
} catch (RuntimeException | PlatformError e) {
throw BEANS.get(PlatformExceptionTranslator.class).translate(e).withContextInfo("form", getClass().getName());
}
}
use of org.eclipse.scout.rt.platform.exception.PlatformError in project scout.rt by eclipse.
the class AbstractForm method storeToXml.
@Override
public void storeToXml(Element root) {
root.setAttribute("formId", getFormId());
root.setAttribute("formQname", getClass().getName());
// add custom properties
Element xProps = root.getOwnerDocument().createElement("properties");
root.appendChild(xProps);
IPropertyFilter filter = new IPropertyFilter() {
@Override
public boolean accept(FastPropertyDescriptor descriptor) {
if (descriptor.getPropertyType().isInstance(IFormField.class)) {
return false;
}
if (!descriptor.getPropertyType().isPrimitive() && !Serializable.class.isAssignableFrom(descriptor.getPropertyType())) {
return false;
}
if (descriptor.getReadMethod() == null || descriptor.getWriteMethod() == null) {
return false;
}
return true;
}
};
Map<String, Object> props = BeanUtility.getProperties(this, AbstractForm.class, filter);
storePropertiesToXml(xProps, props);
// add extension properties
for (IExtension<?> ex : getAllExtensions()) {
Map<String, Object> extensionProps = BeanUtility.getProperties(ex, AbstractFormExtension.class, filter);
if (extensionProps.isEmpty()) {
continue;
}
Element xExtension = root.getOwnerDocument().createElement("extension");
xProps.appendChild(xExtension);
xExtension.setAttribute("extensionId", ex.getClass().getSimpleName());
xExtension.setAttribute("extensionQname", ex.getClass().getName());
storePropertiesToXml(xExtension, extensionProps);
}
// add fields
final Element xFields = root.getOwnerDocument().createElement("fields");
root.appendChild(xFields);
final Holder<RuntimeException> exceptionHolder = new Holder<>(RuntimeException.class);
final Holder<PlatformError> errorHolder = new Holder<>(PlatformError.class);
P_AbstractCollectingFieldVisitor v = new P_AbstractCollectingFieldVisitor() {
@Override
public boolean visitField(IFormField field, int level, int fieldIndex) {
if (field.getForm() != AbstractForm.this) {
// field is part of a wrapped form and is handled by the AbstractWrappedFormField
return true;
}
Element xField = xFields.getOwnerDocument().createElement("field");
try {
field.storeToXml(xField);
xFields.appendChild(xField);
} catch (RuntimeException e) {
exceptionHolder.setValue(e);
return false;
} catch (PlatformError e) {
errorHolder.setValue(e);
return false;
}
return true;
}
};
visitFields(v);
if (exceptionHolder.getValue() != null) {
throw exceptionHolder.getValue();
} else if (errorHolder.getValue() != null) {
throw errorHolder.getValue();
}
}
use of org.eclipse.scout.rt.platform.exception.PlatformError in project scout.rt by eclipse.
the class AbstractDesktop method initConfig.
protected void initConfig() {
m_eventHistory = createEventHistory();
// add convenience observer for event history
addDesktopListener(new DesktopListener() {
@Override
public void desktopChanged(DesktopEvent e) {
IEventHistory<DesktopEvent> h = getEventHistory();
if (h != null) {
h.notifyEvent(e);
}
}
});
ClientSessionProvider.currentSession().getMemoryPolicy().registerDesktop(this);
BEANS.get(IDeviceTransformationService.class).install(this);
initDesktopExtensions();
setTitle(getConfiguredTitle());
setCssClass(getConfiguredCssClass());
setSelectViewTabsKeyStrokesEnabled(getConfiguredSelectViewTabsKeyStrokesEnabled());
setSelectViewTabsKeyStrokeModifier(getConfiguredSelectViewTabsKeyStrokeModifier());
setLogoId(getConfiguredLogoId());
setDisplayStyle(getConfiguredDisplayStyle());
initDisplayStyle(getDisplayStyle());
setCacheSplitterPosition(getConfiguredCacheSplitterPosition());
List<IDesktopExtension> extensions = getDesktopExtensions();
m_contributionHolder = new ContributionComposite(this);
// outlines
OrderedCollection<IOutline> outlines = new OrderedCollection<IOutline>();
for (IDesktopExtension ext : extensions) {
try {
ext.contributeOutlines(outlines);
} catch (Exception t) {
LOG.error("contributing outlines by {}", ext, t);
}
}
List<IOutline> contributedOutlines = m_contributionHolder.getContributionsByClass(IOutline.class);
outlines.addAllOrdered(contributedOutlines);
// move outlines
ExtensionUtility.moveModelObjects(outlines);
setAvailableOutlines(outlines.getOrderedList());
// actions (keyStroke, menu, viewButton, toolButton)
List<IAction> actionList = new ArrayList<IAction>();
for (IDesktopExtension ext : extensions) {
try {
ext.contributeActions(actionList);
} catch (Exception t) {
LOG.error("contributing actions by {}", ext, t);
}
}
List<IAction> contributedActions = m_contributionHolder.getContributionsByClass(IAction.class);
actionList.addAll(contributedActions);
// build complete menu and viewButton lists
// only top level menus
OrderedComparator orderedComparator = new OrderedComparator();
List<IMenu> menuList = new ActionFinder().findActions(actionList, IMenu.class, false);
ExtensionUtility.moveModelObjects(menuList);
Collections.sort(menuList, orderedComparator);
m_menus = menuList;
List<IViewButton> viewButtonList = new ActionFinder().findActions(actionList, IViewButton.class, false);
ExtensionUtility.moveModelObjects(viewButtonList);
Collections.sort(viewButtonList, orderedComparator);
m_viewButtons = viewButtonList;
// add dynamic keyStrokes
List<IKeyStroke> ksList = new ActionFinder().findActions(actionList, IKeyStroke.class, true);
for (IKeyStroke ks : ksList) {
try {
ks.initAction();
} catch (RuntimeException | PlatformError e) {
LOG.error("could not initialize key stroke '{}'.", ks, e);
}
}
addKeyStrokes(ksList.toArray(new IKeyStroke[ksList.size()]));
// init outlines
for (IOutline o : m_availableOutlines) {
try {
o.initTree();
} catch (Exception e) {
LOG.error("Could not init outline {}", o, e);
}
}
addPropertyChangeListener(new P_LocalPropertyChangeListener());
}
Aggregations