Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/GWT_Sandbox/InitFrom/src/org/litesoft/initfrom/client/ui/views/home/Home.java

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