View Javadoc

1   /**
2    *
3    */
4   package org.appfuse.webapp.client.application;
5   
6   import org.appfuse.webapp.client.application.base.activity.AsyncActivityProxy;
7   import org.appfuse.webapp.client.application.base.place.EntityProxyPlace;
8   import org.appfuse.webapp.client.application.base.place.EntitySearchPlace;
9   import org.appfuse.webapp.client.proxies.UserProxy;
10  import org.appfuse.webapp.client.ui.home.HomeActivity;
11  import org.appfuse.webapp.client.ui.home.HomePlace;
12  import org.appfuse.webapp.client.ui.login.LoginActivity;
13  import org.appfuse.webapp.client.ui.login.LoginPlace;
14  import org.appfuse.webapp.client.ui.logout.LogoutActivity;
15  import org.appfuse.webapp.client.ui.logout.LogoutPlace;
16  import org.appfuse.webapp.client.ui.reloadOptions.ReloadOptionsActivity;
17  import org.appfuse.webapp.client.ui.reloadOptions.ReloadOptionsPlace;
18  import org.appfuse.webapp.client.ui.upload.FileUploadActivity;
19  import org.appfuse.webapp.client.ui.upload.FileUploadPlace;
20  import org.appfuse.webapp.client.ui.users.active.ActiveUsersActivity;
21  import org.appfuse.webapp.client.ui.users.active.ActiveUsersPlace;
22  import org.appfuse.webapp.client.ui.users.editProfile.EditProfileActivity;
23  import org.appfuse.webapp.client.ui.users.editProfile.EditProfilePlace;
24  import org.appfuse.webapp.client.ui.users.editUser.EditUserActivity;
25  import org.appfuse.webapp.client.ui.users.search.UsersSearchActivity;
26  import org.appfuse.webapp.client.ui.users.signUp.SignUpActivity;
27  import org.appfuse.webapp.client.ui.users.signUp.SignUpPlace;
28  import org.appfuse.webapp.client.ui.users.updatePassword.UpdatePasswordActivity;
29  import org.appfuse.webapp.client.ui.users.updatePassword.UpdatePasswordPlace;
30  
31  import com.google.gwt.activity.shared.Activity;
32  import com.google.gwt.activity.shared.ActivityMapper;
33  import com.google.gwt.inject.client.AsyncProvider;
34  import com.google.gwt.place.shared.Place;
35  import com.google.inject.Inject;
36  import com.google.inject.Provider;
37  
38  /**
39   * @author ivangsa
40   *
41   */
42  public class ApplicationActivityMapper implements ActivityMapper {
43  
44      @Inject
45      private Provider<HomeActivity> homeActivityProvider;
46      @Inject
47      private Provider<LoginActivity> loginActivityProvider;
48      @Inject
49      private Provider<UpdatePasswordActivity> updatePasswordActivityProvider;
50      @Inject
51      private AsyncProvider<LogoutActivity> logoutActivityProvider;
52      @Inject
53      private AsyncProvider<ReloadOptionsActivity> reloadOptionsActivityProvider;
54      @Inject
55      private AsyncProvider<SignUpActivity> signUpActivityProvider;
56      @Inject
57      private AsyncProvider<EditProfileActivity> editProfileActivityProvider;
58      @Inject
59      private AsyncProvider<ActiveUsersActivity> activeUsersActivityProvider;
60      @Inject
61      private AsyncProvider<FileUploadActivity> fileUploadActivityProvider;
62      @Inject
63      private AsyncProvider<EditUserActivity> editUserActivityProvider;
64      @Inject
65      private AsyncProvider<UsersSearchActivity> usersSearchActivityProvider;
66  
67      @Override
68      public Activity getActivity(final Place place) {
69          Activity activity = null;
70  
71          if (place instanceof LoginPlace) {
72              activity = this.loginActivityProvider.get();
73          }
74          else if (place instanceof HomePlace) {
75              activity = this.homeActivityProvider.get();
76          }
77          else if (place instanceof UpdatePasswordPlace) {
78              activity = this.updatePasswordActivityProvider.get();
79          }
80          else if (place instanceof LogoutPlace) {
81              activity = new AsyncActivityProxy<LogoutActivity>(this.logoutActivityProvider);
82          }
83          else if (place instanceof SignUpPlace) {
84              activity = new AsyncActivityProxy<SignUpActivity>(this.signUpActivityProvider);
85          }
86          else if (place instanceof EditProfilePlace) {
87              activity = new AsyncActivityProxy<EditProfileActivity>(this.editProfileActivityProvider);
88          }
89          else if (place instanceof ActiveUsersPlace) {
90              activity = new AsyncActivityProxy<ActiveUsersActivity>(this.activeUsersActivityProvider);
91          }
92          else if (place instanceof FileUploadPlace) {
93              activity = new AsyncActivityProxy<FileUploadActivity>(this.fileUploadActivityProvider);
94          }
95          else if (place instanceof ReloadOptionsPlace) {
96              activity = new AsyncActivityProxy<ReloadOptionsActivity>(this.reloadOptionsActivityProvider);
97          }
98          else if (place instanceof EntityProxyPlace) {
99              final EntityProxyPlace proxyPlace = (EntityProxyPlace) place;
100             if (UserProxy.class.equals(proxyPlace.getProxyClass())) {
101                 activity = new AsyncActivityProxy<EditUserActivity>(this.editUserActivityProvider);
102             }
103         }
104         else if (place instanceof EntitySearchPlace) {
105             final EntitySearchPlace listPlace = (EntitySearchPlace) place;
106             if (UserProxy.class.equals(listPlace.getProxyClass())) {
107                 activity = new AsyncActivityProxy<UsersSearchActivity>(this.usersSearchActivityProvider);
108             }
109         }
110 
111         return activity;
112     }
113 
114 }