use of org.eclipse.scout.rt.platform.util.concurrent.IRunnable in project scout.rt by eclipse.
the class UiSession method startDesktop.
protected void startDesktop(Map<String, String> sessionStartupParams) {
final IFuture<Void> future = ModelJobs.schedule(new IRunnable() {
@Override
public void run() throws Exception {
IDesktop desktop = m_clientSession.getDesktop();
IDesktopUIFacade uiFacade = desktop.getUIFacade();
boolean desktopOpen = desktop.isOpened();
if (!desktopOpen) {
uiFacade.openFromUI();
}
// Don't handle deep links for persistent sessions,
// in that case the client state shall be recovered rather than following the deep link
PropertyMap.CURRENT.get().put(DeepLinkUrlParameter.HANDLE_DEEP_LINK, !isPersistent() || !desktopOpen);
uiFacade.fireGuiAttached();
}
}, ModelJobs.newInput(ClientRunContexts.copyCurrent().withSession(m_clientSession, true).withProperties(// Make startup parameters available at {@link PropertyMap#CURRENT} during desktop attaching
sessionStartupParams)).withName("Starting Desktop").withExceptionHandling(null, false));
BEANS.get(UiJobs.class).awaitAndGet(future);
}
use of org.eclipse.scout.rt.platform.util.concurrent.IRunnable in project scout.rt by eclipse.
the class ClientSessionTest method testStopWithBlockingClientCallback.
@Test
public void testStopWithBlockingClientCallback() throws Exception {
TestingUtility.registerBean(new BeanMetaData(TestEnvironmentClientSession.class));
TestingUtility.registerBean(new BeanMetaData(JobCompletionDelayOnSessionShutdown.class).withProducer(new IBeanInstanceProducer<JobCompletionDelayOnSessionShutdown>() {
@Override
public JobCompletionDelayOnSessionShutdown produce(IBean<JobCompletionDelayOnSessionShutdown> bean) {
return new JobCompletionDelayOnSessionShutdown() {
@Override
protected Long getDefaultValue() {
return 1000L;
}
};
}
}));
session = BEANS.get(ClientSessionProvider.class).provide(ClientRunContexts.empty().withUserAgent(UserAgents.createDefault()));
// request a geo location
Future<Coordinates> geo = ModelJobs.schedule(new Callable<Future<Coordinates>>() {
@Override
public Future<Coordinates> call() throws Exception {
return IDesktop.CURRENT.get().requestGeolocation();
}
}, ModelJobs.newInput(ClientRunContexts.empty().withSession(session, true))).awaitDoneAndGet();
assertFalse(geo.isDone());
// close from ui
ModelJobs.schedule(new IRunnable() {
@Override
public void run() throws Exception {
session.getDesktop().getUIFacade().closeFromUI(true);
}
}, ModelJobs.newInput(ClientRunContexts.empty().withSession(session, true))).awaitDone();
assertTrue(geo.isCancelled());
}
use of org.eclipse.scout.rt.platform.util.concurrent.IRunnable in project scout.rt by eclipse.
the class ClientRunContextTest method testCurrentTransactionScope.
@Test
public void testCurrentTransactionScope() {
RunContexts.empty().run(new IRunnable() {
@Override
public void run() throws Exception {
assertEquals(TransactionScope.REQUIRED, ClientRunContexts.copyCurrent().getTransactionScope());
}
});
RunContexts.empty().withTransactionScope(TransactionScope.REQUIRES_NEW).run(new IRunnable() {
@Override
public void run() throws Exception {
assertEquals(TransactionScope.REQUIRED, ClientRunContexts.copyCurrent().getTransactionScope());
}
});
}
use of org.eclipse.scout.rt.platform.util.concurrent.IRunnable 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);
}
}
});
}
});
}
use of org.eclipse.scout.rt.platform.util.concurrent.IRunnable in project scout.rt by eclipse.
the class AbstractWizard method start.
@Override
public void start() {
assertClosed();
if (m_blockingCondition.isBlocking()) {
throw new ProcessingException("The wizard " + getClass().getSimpleName() + " has already been started");
}
m_blockingCondition.setBlocking(true);
setClosedInternal(false);
setCloseTypeInternal(CloseType.Unknown);
// Run the initialization on behalf of this Form.
runWithinContainerForm(new IRunnable() {
@Override
public void run() throws Exception {
interceptStart();
if (m_containerForm.isFormStartable()) {
m_containerForm.startWizard();
}
interceptPostStart();
}
});
}
Aggregations