|
@@ -1,177 +1,176 @@ |
1 |
|
- |
package org.litesoft.nasvideo.client.ui.views.home; |
2 |
|
- |
|
3 |
|
- |
import org.litesoft.core.typeutils.Objects; |
4 |
|
- |
import java.util.*; |
5 |
|
- |
|
6 |
|
- |
import org.litesoft.GWT.client.*; |
7 |
|
- |
import org.litesoft.GWT.client.command.*; |
8 |
|
- |
import org.litesoft.GWT.client.dev.*; |
9 |
|
- |
import org.litesoft.GWT.client.view.*; |
10 |
|
- |
import org.litesoft.GWT.client.widgets.*; |
11 |
|
- |
import org.litesoft.bo.views.*; |
12 |
|
- |
import org.litesoft.core.*; |
13 |
|
- |
import org.litesoft.core.simpletypes.*; |
14 |
|
- |
import org.litesoft.nasvideo.client.*; |
15 |
|
- |
import org.litesoft.nasvideo.client.boviews.*; |
16 |
|
- |
import org.litesoft.uispecification.*; |
17 |
|
- |
|
18 |
|
- |
import com.google.gwt.event.dom.client.*; |
19 |
|
- |
import com.google.gwt.user.client.ui.*; |
20 |
|
- |
|
21 |
|
- |
public class Home extends ScreenView implements ViewDefs |
22 |
|
- |
{ |
23 |
|
- |
public static final String NasVideoTITLE = "Init From"; |
24 |
|
- |
|
25 |
|
- |
@Override |
26 |
|
- |
protected UriFragmentIdParams createRefreshParams() |
27 |
|
- |
{ |
28 |
|
- |
return null; |
29 |
|
- |
} |
30 |
|
- |
|
31 |
|
- |
@Override protected void addHome() |
32 |
|
- |
{ |
33 |
|
- |
} |
34 |
|
- |
|
35 |
|
- |
@Override |
36 |
|
- |
public Widget getBottomBar() |
37 |
|
- |
{ |
38 |
|
- |
return null; |
39 |
|
- |
} |
40 |
|
- |
|
41 |
|
- |
@Override |
42 |
|
- |
protected void logoutButtonClicked() |
43 |
|
- |
{ |
44 |
|
- |
if ( UtilsGwt.wasCtrlKeyDownOnCurrentEvent() && Dev.isDevMode() ) |
45 |
|
- |
{ |
46 |
|
- |
ClientContext.get().get( NextDemoUserRequestHandler.class ).nextDemoUser(); |
47 |
|
- |
return; |
48 |
|
- |
} |
49 |
|
- |
super.logoutButtonClicked(); |
50 |
|
- |
} |
51 |
|
- |
|
52 |
|
- |
public Home() |
53 |
|
- |
{ |
54 |
|
- |
super( null ); |
55 |
|
- |
addStandardTitleBar(); |
56 |
|
- |
addTitle( NasVideoTITLE ); |
57 |
|
- |
|
58 |
|
- |
add( new BigButtonScreenHelper() |
59 |
|
- |
{ |
60 |
|
- |
@Override |
61 |
|
- |
public Widget build() |
62 |
|
- |
{ |
63 |
|
- |
UserView zUser = ClientContext.get().get( CurrentUserViewAccessor.class ).getUser(); |
64 |
|
- |
List<Widget> zSections = new ArrayList<Widget>(); |
65 |
|
- |
Role zLastRole = Role.valueFor( zUser.getLastRestrictedResourceRole() ); |
66 |
|
- |
switch ( zLastRole ) |
67 |
|
- |
{ |
68 |
|
- |
default: |
69 |
|
- |
zLastRole = Role.EndUser; |
70 |
|
- |
// Fall Thru |
71 |
|
- |
case EndUser: |
72 |
|
- |
populateSections_EndUser( zSections ); |
73 |
|
- |
break; |
74 |
|
- |
case EndUserManager: |
75 |
|
- |
populateSections_EndUserManager( zSections ); |
76 |
|
- |
break; |
77 |
|
- |
case Developer: |
78 |
|
- |
populateSections_Developer( zSections ); |
79 |
|
- |
break; |
80 |
|
- |
case Customer: |
81 |
|
- |
populateSections_Customer( zSections ); |
82 |
|
- |
break; |
83 |
|
- |
case ProjectAdmin: |
84 |
|
- |
populateSections_ProjectAdmin( zSections ); |
85 |
|
- |
break; |
86 |
|
- |
} |
87 |
|
- |
Widget zRestrictedResource = createButton( ADMIN_RESTRICTED_RESOURCE_MANAGEMENT ); |
88 |
|
- |
if ( zRestrictedResource == null ) |
89 |
|
- |
{ |
90 |
|
- |
zRestrictedResource = createButton( ADMIN_RESTRICTED_RESOURCE_EDITOR ); |
91 |
|
- |
} |
92 |
|
- |
zSections.add( createSection( HOME_SECTION_ADMIN, zRestrictedResource, ADMIN_CHANGE_PASSWORD, ADMIN_MY_PROFILE, ADMIN_REPORTS, ADMIN_USERS ) ); |
93 |
|
- |
zSections.add( createSection( HOME_SECTION_HOME_SWITCH_VIEW, createSwitchHomeButtons( zUser.getCurrentRestrictedResourceAllowedRoles(), zLastRole ) ) ); |
94 |
|
- |
return addVerticallyDistributed( zSections ); |
95 |
|
- |
} |
96 |
|
- |
|
97 |
|
- |
@Override |
98 |
|
- |
protected Widget createScreenButton( ViewDef pViewDef ) |
99 |
|
- |
{ |
100 |
|
- |
String zUiString = pViewDef.getUiString(); |
101 |
|
- |
ShowScreenCommand zScreenCommand = new ShowScreenCommand( pViewDef ); |
102 |
|
- |
return ScreenBigButton.factory( zUiString ).add( zScreenCommand ).create(); |
103 |
|
- |
} |
104 |
|
- |
|
105 |
|
- |
private SizeableHorizontalPanel createSwitchHomeButtons( TextLines pAllowedRoles, Role pCurrentRole ) |
106 |
|
- |
{ |
107 |
|
- |
Set<Role> zAllowedRoles = new HashSet<Role>(); |
108 |
|
- |
for ( TextLine zAllowedRole : pAllowedRoles ) |
109 |
|
- |
{ |
110 |
|
- |
zAllowedRoles.add( Role.valueFor( zAllowedRole.getLine() ) ); |
111 |
|
- |
} |
112 |
|
- |
List<Widget> zButtons = new ArrayList<Widget>(); |
113 |
|
- |
for ( Role zRole : Role.values() ) |
114 |
|
- |
{ |
115 |
|
- |
if ( (zRole != pCurrentRole) && zAllowedRoles.contains( zRole ) ) |
116 |
|
- |
{ |
117 |
|
- |
ViewDef[] zViewDefs = ViewDefs.ROLES_MAP.get( zRole ); |
118 |
|
- |
if ( (zViewDefs != null) && (zViewDefs.length > 0) ) |
119 |
|
- |
{ |
120 |
|
- |
ViewDef zViewDef = zViewDefs[0]; |
121 |
|
- |
if ( zViewDef != null ) |
122 |
|
- |
{ |
123 |
|
- |
zButtons.add( createSwitchHomeButton( zViewDef, zRole ) ); |
124 |
|
- |
} |
125 |
|
- |
} |
126 |
|
- |
} |
127 |
|
- |
} |
128 |
|
- |
return createButtons( zButtons ); |
129 |
|
- |
} |
130 |
|
- |
|
131 |
|
- |
private Widget createSwitchHomeButton( ViewDef pViewDef, final Role pRole ) |
132 |
|
- |
{ |
133 |
|
- |
return ScreenBigButton.factory( pViewDef.getUiString() ).add( new ClickHandler() |
134 |
|
- |
{ |
135 |
|
- |
@Override |
136 |
|
- |
public void onClick( ClickEvent event ) |
137 |
|
- |
{ |
138 |
|
- |
CurrentUserViewAccessor zAccessor = ClientContext.get().get( CurrentUserViewAccessor.class ); |
139 |
|
- |
UserView zUser = zAccessor.getUser(); |
140 |
|
- |
if ( zUser.getTransactionSet() == null ) |
141 |
|
- |
{ |
142 |
|
- |
zAccessor.setUser( zUser = zUser.copyInto( ClientTransactionSet.create() ) ); |
143 |
|
- |
} |
144 |
|
- |
zUser.setLastRestrictedResourceRole( pRole.toString() ); |
145 |
|
- |
// todo: send it to the Server |
146 |
|
- |
refreshPage(); |
147 |
|
- |
} |
148 |
|
- |
} ).create(); |
149 |
|
- |
} |
150 |
|
- |
|
151 |
|
- |
private void populateSections_EndUser( List<Widget> pSections ) |
152 |
|
- |
{ |
153 |
|
- |
pSections.add( createSection( "END USERS", ENDUSERS_SAMPLE ) ); |
154 |
|
- |
} |
155 |
|
- |
|
156 |
|
- |
private void populateSections_EndUserManager( List<Widget> pSections ) |
157 |
|
- |
{ |
158 |
|
- |
pSections.add( createSection( "END USER MANAGER", ENDUSERMANAGERS_SAMPLE ) ); |
159 |
|
- |
} |
160 |
|
- |
|
161 |
|
- |
private void populateSections_Developer( List<Widget> pSections ) |
162 |
|
- |
{ |
163 |
|
- |
pSections.add( createSection( "DEVELOPER", DEVELOPERS_SAMPLE ) ); |
164 |
|
- |
} |
165 |
|
- |
|
166 |
|
- |
private void populateSections_Customer( List<Widget> pSections ) |
167 |
|
- |
{ |
168 |
|
- |
pSections.add( createSection( "CUSTOMER", CUSTOMERS_SAMPLE ) ); |
169 |
|
- |
} |
170 |
|
- |
|
171 |
|
- |
private void populateSections_ProjectAdmin( List<Widget> pSections ) |
172 |
|
- |
{ |
173 |
|
- |
pSections.add( createSection( "PROJECT ADMINISTRATOR", PROJECTADMINS_SAMPLE ) ); |
174 |
|
- |
} |
175 |
|
- |
}.build() ); |
176 |
|
- |
} |
177 |
|
- |
} |
|
1 |
+ |
package org.litesoft.nasvideo.client.ui.views.home; |
|
2 |
+ |
|
|
3 |
+ |
import java.util.*; |
|
4 |
+ |
|
|
5 |
+ |
import org.litesoft.GWT.client.*; |
|
6 |
+ |
import org.litesoft.GWT.client.command.*; |
|
7 |
+ |
import org.litesoft.GWT.client.dev.*; |
|
8 |
+ |
import org.litesoft.GWT.client.view.*; |
|
9 |
+ |
import org.litesoft.GWT.client.widgets.*; |
|
10 |
+ |
import org.litesoft.bo.views.*; |
|
11 |
+ |
import org.litesoft.core.*; |
|
12 |
+ |
import org.litesoft.core.simpletypes.*; |
|
13 |
+ |
import org.litesoft.initfrom.client.boviews.*; |
|
14 |
+ |
import org.litesoft.nasvideo.client.*; |
|
15 |
+ |
import org.litesoft.uispecification.*; |
|
16 |
+ |
|
|
17 |
+ |
import com.google.gwt.event.dom.client.*; |
|
18 |
+ |
import com.google.gwt.user.client.ui.*; |
|
19 |
+ |
|
|
20 |
+ |
public class Home extends ScreenView implements ViewDefs |
|
21 |
+ |
{ |
|
22 |
+ |
public static final String NasVideoTITLE = "Init From"; |
|
23 |
+ |
|
|
24 |
+ |
@Override |
|
25 |
+ |
protected UriFragmentIdParams createRefreshParams() |
|
26 |
+ |
{ |
|
27 |
+ |
return null; |
|
28 |
+ |
} |
|
29 |
+ |
|
|
30 |
+ |
@Override protected void addHome() |
|
31 |
+ |
{ |
|
32 |
+ |
} |
|
33 |
+ |
|
|
34 |
+ |
@Override |
|
35 |
+ |
public Widget getBottomBar() |
|
36 |
+ |
{ |
|
37 |
+ |
return null; |
|
38 |
+ |
} |
|
39 |
+ |
|
|
40 |
+ |
@Override |
|
41 |
+ |
protected void logoutButtonClicked() |
|
42 |
+ |
{ |
|
43 |
+ |
if ( UtilsGwt.wasCtrlKeyDownOnCurrentEvent() && Dev.isDevMode() ) |
|
44 |
+ |
{ |
|
45 |
+ |
ClientContext.get().get( NextDemoUserRequestHandler.class ).nextDemoUser(); |
|
46 |
+ |
return; |
|
47 |
+ |
} |
|
48 |
+ |
super.logoutButtonClicked(); |
|
49 |
+ |
} |
|
50 |
+ |
|
|
51 |
+ |
public Home() |
|
52 |
+ |
{ |
|
53 |
+ |
super( null ); |
|
54 |
+ |
addStandardTitleBar(); |
|
55 |
+ |
addTitle( NasVideoTITLE ); |
|
56 |
+ |
|
|
57 |
+ |
add( new BigButtonScreenHelper() |
|
58 |
+ |
{ |
|
59 |
+ |
@Override |
|
60 |
+ |
public Widget build() |
|
61 |
+ |
{ |
|
62 |
+ |
UserView zUser = ClientContext.get().get( CurrentUserViewAccessor.class ).getUser(); |
|
63 |
+ |
List<Widget> zSections = new ArrayList<Widget>(); |
|
64 |
+ |
Role zLastRole = Role.valueFor( zUser.getLastRestrictedResourceRole() ); |
|
65 |
+ |
switch ( zLastRole ) |
|
66 |
+ |
{ |
|
67 |
+ |
default: |
|
68 |
+ |
zLastRole = Role.EndUser; |
|
69 |
+ |
// Fall Thru |
|
70 |
+ |
case EndUser: |
|
71 |
+ |
populateSections_EndUser( zSections ); |
|
72 |
+ |
break; |
|
73 |
+ |
case EndUserManager: |
|
74 |
+ |
populateSections_EndUserManager( zSections ); |
|
75 |
+ |
break; |
|
76 |
+ |
case Developer: |
|
77 |
+ |
populateSections_Developer( zSections ); |
|
78 |
+ |
break; |
|
79 |
+ |
case Customer: |
|
80 |
+ |
populateSections_Customer( zSections ); |
|
81 |
+ |
break; |
|
82 |
+ |
case ProjectAdmin: |
|
83 |
+ |
populateSections_ProjectAdmin( zSections ); |
|
84 |
+ |
break; |
|
85 |
+ |
} |
|
86 |
+ |
Widget zRestrictedResource = createButton( ADMIN_RESTRICTED_RESOURCE_MANAGEMENT ); |
|
87 |
+ |
if ( zRestrictedResource == null ) |
|
88 |
+ |
{ |
|
89 |
+ |
zRestrictedResource = createButton( ADMIN_RESTRICTED_RESOURCE_EDITOR ); |
|
90 |
+ |
} |
|
91 |
+ |
zSections.add( createSection( HOME_SECTION_ADMIN, zRestrictedResource, ADMIN_CHANGE_PASSWORD, ADMIN_MY_PROFILE, ADMIN_REPORTS, ADMIN_USERS ) ); |
|
92 |
+ |
zSections.add( createSection( HOME_SECTION_HOME_SWITCH_VIEW, createSwitchHomeButtons( zUser.getCurrentRestrictedResourceAllowedRoles(), zLastRole ) ) ); |
|
93 |
+ |
return addVerticallyDistributed( zSections ); |
|
94 |
+ |
} |
|
95 |
+ |
|
|
96 |
+ |
@Override |
|
97 |
+ |
protected Widget createScreenButton( ViewDef pViewDef ) |
|
98 |
+ |
{ |
|
99 |
+ |
String zUiString = pViewDef.getUiString(); |
|
100 |
+ |
ShowScreenCommand zScreenCommand = new ShowScreenCommand( pViewDef ); |
|
101 |
+ |
return ScreenBigButton.factory( zUiString ).add( zScreenCommand ).create(); |
|
102 |
+ |
} |
|
103 |
+ |
|
|
104 |
+ |
private SizeableHorizontalPanel createSwitchHomeButtons( TextLines pAllowedRoles, Role pCurrentRole ) |
|
105 |
+ |
{ |
|
106 |
+ |
Set<Role> zAllowedRoles = new HashSet<Role>(); |
|
107 |
+ |
for ( TextLine zAllowedRole : pAllowedRoles ) |
|
108 |
+ |
{ |
|
109 |
+ |
zAllowedRoles.add( Role.valueFor( zAllowedRole.getLine() ) ); |
|
110 |
+ |
} |
|
111 |
+ |
List<Widget> zButtons = new ArrayList<Widget>(); |
|
112 |
+ |
for ( Role zRole : Role.values() ) |
|
113 |
+ |
{ |
|
114 |
+ |
if ( (zRole != pCurrentRole) && zAllowedRoles.contains( zRole ) ) |
|
115 |
+ |
{ |
|
116 |
+ |
ViewDef[] zViewDefs = ViewDefs.ROLES_MAP.get( zRole ); |
|
117 |
+ |
if ( (zViewDefs != null) && (zViewDefs.length > 0) ) |
|
118 |
+ |
{ |
|
119 |
+ |
ViewDef zViewDef = zViewDefs[0]; |
|
120 |
+ |
if ( zViewDef != null ) |
|
121 |
+ |
{ |
|
122 |
+ |
zButtons.add( createSwitchHomeButton( zViewDef, zRole ) ); |
|
123 |
+ |
} |
|
124 |
+ |
} |
|
125 |
+ |
} |
|
126 |
+ |
} |
|
127 |
+ |
return createButtons( zButtons ); |
|
128 |
+ |
} |
|
129 |
+ |
|
|
130 |
+ |
private Widget createSwitchHomeButton( ViewDef pViewDef, final Role pRole ) |
|
131 |
+ |
{ |
|
132 |
+ |
return ScreenBigButton.factory( pViewDef.getUiString() ).add( new ClickHandler() |
|
133 |
+ |
{ |
|
134 |
+ |
@Override |
|
135 |
+ |
public void onClick( ClickEvent event ) |
|
136 |
+ |
{ |
|
137 |
+ |
CurrentUserViewAccessor zAccessor = ClientContext.get().get( CurrentUserViewAccessor.class ); |
|
138 |
+ |
UserView zUser = zAccessor.getUser(); |
|
139 |
+ |
if ( zUser.getTransactionSet() == null ) |
|
140 |
+ |
{ |
|
141 |
+ |
zAccessor.setUser( zUser = zUser.copyInto( ClientTransactionSet.create() ) ); |
|
142 |
+ |
} |
|
143 |
+ |
zUser.setLastRestrictedResourceRole( pRole.toString() ); |
|
144 |
+ |
// todo: send it to the Server |
|
145 |
+ |
refreshPage(); |
|
146 |
+ |
} |
|
147 |
+ |
} ).create(); |
|
148 |
+ |
} |
|
149 |
+ |
|
|
150 |
+ |
private void populateSections_EndUser( List<Widget> pSections ) |
|
151 |
+ |
{ |
|
152 |
+ |
pSections.add( createSection( "END USERS", ENDUSERS_SAMPLE ) ); |
|
153 |
+ |
} |
|
154 |
+ |
|
|
155 |
+ |
private void populateSections_EndUserManager( List<Widget> pSections ) |
|
156 |
+ |
{ |
|
157 |
+ |
pSections.add( createSection( "END USER MANAGER", ENDUSERMANAGERS_SAMPLE ) ); |
|
158 |
+ |
} |
|
159 |
+ |
|
|
160 |
+ |
private void populateSections_Developer( List<Widget> pSections ) |
|
161 |
+ |
{ |
|
162 |
+ |
pSections.add( createSection( "DEVELOPER", DEVELOPERS_SAMPLE ) ); |
|
163 |
+ |
} |
|
164 |
+ |
|
|
165 |
+ |
private void populateSections_Customer( List<Widget> pSections ) |
|
166 |
+ |
{ |
|
167 |
+ |
pSections.add( createSection( "CUSTOMER", CUSTOMERS_SAMPLE ) ); |
|
168 |
+ |
} |
|
169 |
+ |
|
|
170 |
+ |
private void populateSections_ProjectAdmin( List<Widget> pSections ) |
|
171 |
+ |
{ |
|
172 |
+ |
pSections.add( createSection( "PROJECT ADMINISTRATOR", PROJECTADMINS_SAMPLE ) ); |
|
173 |
+ |
} |
|
174 |
+ |
}.build() ); |
|
175 |
+ |
} |
|
176 |
+ |
} |