]> git.argeo.org Git - lgpl/argeo-commons.git/blob - workbench/internal/useradmin/UiAdminUtils.java
Prepare next development cycle
[lgpl/argeo-commons.git] / workbench / internal / useradmin / UiAdminUtils.java
1 package org.argeo.cms.ui.workbench.internal.useradmin;
2
3 import javax.transaction.UserTransaction;
4
5 import org.argeo.cms.CmsException;
6 import org.argeo.cms.ui.workbench.internal.useradmin.providers.UserTransactionProvider;
7 import org.eclipse.ui.IWorkbenchWindow;
8 import org.eclipse.ui.PlatformUI;
9 import org.eclipse.ui.services.ISourceProviderService;
10
11 /** First effort to centralize back end methods used by the user admin UI */
12 public class UiAdminUtils {
13 /*
14 * INTERNAL METHODS: Below methods are meant to stay here and are not part
15 * of a potential generic backend to manage the useradmin
16 */
17 /** Easily notify the ActiveWindow that the transaction had a state change */
18 public final static void notifyTransactionStateChange(
19 UserTransaction userTransaction) {
20 try {
21 IWorkbenchWindow aww = PlatformUI.getWorkbench()
22 .getActiveWorkbenchWindow();
23 ISourceProviderService sourceProviderService = (ISourceProviderService) aww
24 .getService(ISourceProviderService.class);
25 UserTransactionProvider esp = (UserTransactionProvider) sourceProviderService
26 .getSourceProvider(UserTransactionProvider.TRANSACTION_STATE);
27 esp.fireTransactionStateChange();
28 } catch (Exception e) {
29 throw new CmsException("Unable to begin transaction", e);
30 }
31 }
32
33 /**
34 * Email addresses must match this regexp pattern ({@value #EMAIL_PATTERN}.
35 * Thanks to <a href=
36 * "http://www.mkyong.com/regular-expressions/how-to-validate-email-address-with-regular-expression/"
37 * >this tip</a>.
38 */
39 public final static String EMAIL_PATTERN = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
40 }