X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms.e4.rap%2Fsrc%2Forg%2Fargeo%2Fcms%2Fe4%2Frap%2FAbstractRapE4App.java;h=68415f31adbabc9479936c6349a9508423e75ce0;hb=7fa402d36e0e194424589f4d7efeae5610d2c6eb;hp=c70e381c392442e91661fc7aa7084e9b3a885892;hpb=d6390257a328199a2a4a677b33e79b6535175169;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms.e4.rap/src/org/argeo/cms/e4/rap/AbstractRapE4App.java b/org.argeo.cms.e4.rap/src/org/argeo/cms/e4/rap/AbstractRapE4App.java index c70e381c3..68415f31a 100644 --- a/org.argeo.cms.e4.rap/src/org/argeo/cms/e4/rap/AbstractRapE4App.java +++ b/org.argeo.cms.e4.rap/src/org/argeo/cms/e4/rap/AbstractRapE4App.java @@ -1,22 +1,25 @@ package org.argeo.cms.e4.rap; -import java.security.PrivilegedAction; import java.util.HashMap; import java.util.Map; import javax.security.auth.Subject; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.argeo.cms.ui.dialogs.CmsFeedback; import org.eclipse.rap.e4.E4ApplicationConfig; -import org.eclipse.rap.e4.E4EntryPointFactory; import org.eclipse.rap.rwt.application.Application; import org.eclipse.rap.rwt.application.Application.OperationMode; import org.eclipse.rap.rwt.application.ApplicationConfiguration; -import org.eclipse.rap.rwt.application.EntryPoint; +import org.eclipse.rap.rwt.application.ExceptionHandler; import org.eclipse.rap.rwt.client.WebClient; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; public abstract class AbstractRapE4App implements ApplicationConfiguration { + private final static Log log = LogFactory.getLog(AbstractRapE4App.class); + private final BundleContext bc = FrameworkUtil.getBundle(AbstractRapE4App.class).getBundleContext(); private String pageTitle; @@ -24,41 +27,58 @@ public abstract class AbstractRapE4App implements ApplicationConfiguration { private String path; public void configure(Application application) { + application.setExceptionHandler(new ExceptionHandler() { + + @Override + public void handleException(Throwable throwable) { + CmsFeedback.show("Unexpected RWT exception", throwable); + // log.error("Unexpected RWT exception", throwable); + + } + }); + String lifeCycleUri = "bundleclass://" + bc.getBundle().getSymbolicName() + "/" + CmsLoginLifecycle.class.getName(); Map properties = new HashMap(); properties.put(WebClient.PAGE_TITLE, pageTitle); E4ApplicationConfig config = new E4ApplicationConfig(e4Xmi, lifeCycleUri, null, false, true, true); - config.isClearPersistedState(); - E4EntryPointFactory entryPointFactory = new E4EntryPointFactory(config) { - - @Override - public EntryPoint create() { - Subject subject = new Subject(); - EntryPoint ep = createEntryPoint(); - EntryPoint authEp = new EntryPoint() { - - @Override - public int createUI() { - return Subject.doAs(subject, new PrivilegedAction() { - - @Override - public Integer run() { - return ep.createUI(); - } - - }); - } - }; - return authEp; - } - - protected EntryPoint createEntryPoint() { - return super.create(); - } + Subject subject = new Subject(); + addEntryPoint(application, subject, config, properties); + // config.isClearPersistedState(); + // E4EntryPointFactory entryPointFactory = new E4EntryPointFactory(config) { + // + // @Override + // public EntryPoint create() { + // Subject subject = new Subject(); + // EntryPoint ep = createEntryPoint(); + // EntryPoint authEp = new EntryPoint() { + // + // @Override + // public int createUI() { + // return Subject.doAs(subject, new PrivilegedAction() { + // + // @Override + // public Integer run() { + // return ep.createUI(); + // } + // + // }); + // } + // }; + // return authEp; + // } + // + // protected EntryPoint createEntryPoint() { + // return super.create(); + // } + // + // }; + } - }; + protected void addEntryPoint(Application application, Subject subject, E4ApplicationConfig config, + Map properties) { + CmsE4EntryPointFactory entryPointFactory = new CmsE4EntryPointFactory(subject, config); application.addEntryPoint(path, entryPointFactory, properties); application.setOperationMode(OperationMode.SWT_COMPATIBILITY); }