use of org.eclipse.scout.rt.platform.exception.PlatformError in project scout.rt by eclipse.
the class AbstractDesktop method closeInternal.
@Override
public void closeInternal() {
setOpenedInternal(false);
detachGui();
List<IForm> showedForms = new ArrayList<IForm>();
// Remove showed forms
for (IForm form : m_formStore.values()) {
hideForm(form);
showedForms.add(form);
}
// extensions
for (IDesktopExtension ext : getDesktopExtensions()) {
try {
ContributionCommand cc = ext.desktopClosingDelegate();
if (cc == ContributionCommand.Stop) {
break;
}
} catch (RuntimeException | PlatformError t) {
LOG.error("extension {}", ext, t);
}
}
// close messageboxes
for (IMessageBox m : getMessageBoxes()) {
if (m != null) {
try {
m.getUIFacade().setResultFromUI(IMessageBox.CANCEL_OPTION);
} catch (RuntimeException | PlatformError e) {
LOG.error("Exception while closing messagebox", e);
}
}
}
// close filechoosers
for (IFileChooser f : getFileChoosers()) {
if (f != null) {
try {
f.getUIFacade().setResultFromUI(Collections.<BinaryResource>emptyList());
} catch (RuntimeException | PlatformError e) {
LOG.error("Exception while closing filechooser", e);
}
}
}
// close client callbacks
for (ClientCallback<?> c : CollectionUtility.arrayList(m_pendingPositionResponses)) {
if (c != null) {
try {
c.cancel(true);
c.failed(new ThreadInterruptedError("desktop is closing"));
} catch (RuntimeException | PlatformError e) {
LOG.error("Exception while closing client callback", e);
}
}
}
// close open forms
for (IForm form : showedForms) {
if (form != null) {
try {
form.doClose();
} catch (RuntimeException | PlatformError e) {
LOG.error("Exception while closing form", e);
}
}
}
// dispose outlines
for (IOutline outline : getAvailableOutlines()) {
try {
outline.disposeTree();
} catch (RuntimeException | PlatformError e) {
LOG.warn("Exception while disposing outline.", e);
}
}
ActionUtility.disposeActions(getActions());
fireDesktopClosed();
}
use of org.eclipse.scout.rt.platform.exception.PlatformError in project scout.rt by eclipse.
the class AbstractDesktop method getSimilarViewForms.
@Override
public List<IForm> getSimilarViewForms(final IForm form) {
if (form == null) {
return CollectionUtility.emptyArrayList();
}
final Object formKey;
try {
formKey = form.computeExclusiveKey();
} catch (final RuntimeException | PlatformError e) {
BEANS.get(ExceptionHandler.class).handle(e);
return CollectionUtility.emptyArrayList();
}
if (formKey == null) {
return CollectionUtility.emptyArrayList();
}
final IForm currentDetailForm = getPageDetailForm();
final IForm currentSearchForm = getPageSearchForm();
final List<IForm> similarForms = new ArrayList<>();
for (final IForm candidateView : m_formStore.getViewsByKey(formKey)) {
if (candidateView == currentDetailForm) {
continue;
}
if (candidateView == currentSearchForm) {
continue;
}
if (candidateView.getClass().equals(form.getClass())) {
similarForms.add(candidateView);
}
}
return similarForms;
}
use of org.eclipse.scout.rt.platform.exception.PlatformError in project scout.rt by eclipse.
the class AbstractOutline method releaseUnusedPages.
@Override
public void releaseUnusedPages() {
final HashSet<IPage> preservationSet = new HashSet<IPage>();
IPage<?> oldSelection = (IPage) getSelectedNode();
IPage<?> p = oldSelection;
if (p != null) {
while (p != null) {
preservationSet.add(p);
p = p.getParentPage();
}
}
ITreeVisitor v = new ITreeVisitor() {
@Override
public boolean visit(ITreeNode node) {
IPage<?> page = (IPage) node;
if (preservationSet.contains(page)) {
// nop
} else if (page.isChildrenLoaded() && (!page.isExpanded() || !(page.getParentPage() != null && page.getParentPage().isChildrenLoaded()))) {
try {
unloadNode(page);
} catch (RuntimeException | PlatformError e) {
BEANS.get(ExceptionHandler.class).handle(e);
}
}
return true;
}
};
try {
setTreeChanging(true);
visitNode(getRootNode(), v);
if (oldSelection != null) {
IPage<?> selectedPage = (IPage) getSelectedNode();
if (selectedPage == null) {
try {
getRootNode().ensureChildrenLoaded();
List<ITreeNode> children = getRootNode().getFilteredChildNodes();
if (CollectionUtility.hasElements(children)) {
selectNode(CollectionUtility.firstElement(children));
}
} catch (RuntimeException | PlatformError e) {
LOG.warn("Exception while selecting first page in outline [{}]", getClass().getName(), e);
}
}
}
} finally {
setTreeChanging(false);
}
}
use of org.eclipse.scout.rt.platform.exception.PlatformError in project scout.rt by eclipse.
the class DefaultPageChangeStrategy method pageChanged.
@Override
public void pageChanged(final IOutline outline, final IPage<?> deselectedPage, final IPage<?> selectedPage) {
if (outline == null) {
return;
}
outline.clearContextPage();
IForm detailForm = null;
ITable detailTable = null;
ISearchForm searchForm = null;
// new active page
outline.makeActivePageToContextPage();
IPage<?> activePage = outline.getActivePage();
if (activePage != null) {
try {
activePage.ensureChildrenLoaded();
} catch (RuntimeException | PlatformError e1) {
BEANS.get(ExceptionHandler.class).handle(e1);
}
if (activePage instanceof IPageWithTable) {
IPageWithTable tablePage = (IPageWithTable) activePage;
detailForm = activePage.getDetailForm();
if (activePage.isTableVisible()) {
detailTable = tablePage.getTable(false);
}
if (tablePage.isSearchActive()) {
searchForm = tablePage.getSearchFormInternal();
}
} else if (activePage instanceof IPageWithNodes) {
IPageWithNodes nodePage = (IPageWithNodes) activePage;
if (activePage.isDetailFormVisible()) {
detailForm = activePage.getDetailForm();
}
if (activePage.isTableVisible()) {
detailTable = nodePage.getTable(false);
}
}
}
// remove first
if (detailForm == null) {
outline.setDetailForm(null);
}
if (detailTable == null) {
outline.setDetailTable(null);
}
if (searchForm == null) {
outline.setSearchForm(null);
}
// add new
if (detailForm != null) {
outline.setDetailForm(detailForm);
}
if (detailTable != null) {
outline.setDetailTable(detailTable);
}
if (searchForm != null) {
outline.setSearchForm(searchForm);
}
}
use of org.eclipse.scout.rt.platform.exception.PlatformError in project scout.rt by eclipse.
the class AbstractWizard method initConfig.
@SuppressWarnings({ "boxing", "unchecked" })
protected void initConfig() {
setTitle(getConfiguredTitle());
setSubTitle(getConfiguredSubTitle());
// initially the wizard is in state "closed"
setClosedInternal(true);
setCloseTypeInternal(CloseType.Unknown);
m_contributionHolder = new ContributionComposite(AbstractWizard.this);
m_containerForm = createContainerForm();
Assertions.assertNotNull(m_containerForm, "Missing container form");
interceptDecorateContainerForm();
// Run the initialization on behalf of the container form.
runWithinContainerForm(new IRunnable() {
@Override
public void run() throws Exception {
// steps
List<Class<? extends IWizardStep<? extends IForm>>> configuredAvailableSteps = getConfiguredAvailableSteps();
List<IWizardStep> contributedSteps = m_contributionHolder.getContributionsByClass(IWizardStep.class);
OrderedCollection<IWizardStep<? extends IForm>> steps = new OrderedCollection<IWizardStep<? extends IForm>>();
for (Class<? extends IWizardStep<? extends IForm>> element : configuredAvailableSteps) {
IWizardStep<? extends IForm> step = ConfigurationUtility.newInnerInstance(AbstractWizard.this, element);
steps.addOrdered(step);
}
for (IWizardStep step : contributedSteps) {
steps.addOrdered(step);
}
injectStepsInternal(steps);
ExtensionUtility.moveModelObjects(steps);
setAvailableSteps(steps.getOrderedList());
// add listener to listen on any field in active form
m_anyFieldChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent e) {
try {
interceptAnyFieldChanged((IFormField) e.getSource());
} catch (RuntimeException | PlatformError t) {
LOG.error("{} {}={}", e.getSource(), e.getPropertyName(), e.getNewValue(), t);
}
}
};
propertySupport.addPropertyChangeListener(PROP_WIZARD_FORM, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent e) {
IForm oldForm = (IForm) e.getOldValue();
IForm newForm = (IForm) e.getNewValue();
if (oldForm != null) {
oldForm.getRootGroupBox().removeSubtreePropertyChangeListener(IValueField.PROP_VALUE, m_anyFieldChangeListener);
}
if (newForm != null) {
newForm.getRootGroupBox().addSubtreePropertyChangeListener(IValueField.PROP_VALUE, m_anyFieldChangeListener);
}
}
});
}
});
}
Aggregations