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