Subversion Repository Public Repository

litesoft

@ 950
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
package org.litesoft.datt.client.ui.views.home;

import org.litesoft.GWT.client.command.*;
import org.litesoft.GWT.client.view.*;
import org.litesoft.GWT.client.widgets.*;
import org.litesoft.bo.views.*;
import org.litesoft.commonfoundation.base.*;
import org.litesoft.core.*;
import org.litesoft.core.simpletypes.*;
import org.litesoft.datt.client.*;
import org.litesoft.datt.client.accessors.*;
import org.litesoft.datt.client.boviews.*;
import org.litesoft.datt.client.support.*;
import org.litesoft.uispecification.*;

import com.google.gwt.event.dom.client.*;
import com.google.gwt.user.client.ui.*;

import java.util.*;

public class Home extends ScreenView implements ViewDefs {
    public static final String TITLE = "Distributed Agile Task Tracker";

    @Override
    protected UriFragmentIdParams createRefreshParams() {
        return null;
    }

    public Home() {
        super( title( TITLE ) );
        addStandardTitleBar();

        add( new BigButtonScreenHelper() {
            @Override
            public Widget build() {
                UserView zUser = ClientContext.get().get( CurrentUserViewAccessor.class ).getUser();
                List<Widget> zSections = new ArrayList<Widget>();
                Role zLastRole = ConstrainTo.notNull( Role.valueFor( zUser.getLastRestrictedResourceRole() ), Role.EndUser );
                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_STORIES, STORY_STORIES, STORY_MERGE_STORIES, INITIAL_PRIORITIZING_STORIES, REPRIORITIZE_STORIES ) );
                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/src/org/litesoft/datt/client/ui/views/home/Home.java

Diff revisions: vs.
Revision Author Commited Message
950 Diff Diff GeorgeS picture GeorgeS Thu 19 Jun, 2014 17:57:04 +0000

New Lines

948 Diff Diff GeorgeS picture GeorgeS Sat 07 Jun, 2014 23:42:39 +0000

Jusefuls Formatter Updated to New Code Format

939 Diff Diff GeorgeS picture GeorgeS Mon 02 Jun, 2014 21:30:31 +0000

Extracting commonfoundation

804 Diff Diff GeorgeS picture GeorgeS Wed 15 Aug, 2012 12:48:51 +0000
502 Diff Diff markcmarkc Mon 12 Sep, 2011 00:46:45 +0000
501 Diff Diff markcmarkc Sun 11 Sep, 2011 22:50:22 +0000

Added a customer

496 Diff Diff GeorgeS picture GeorgeS Sun 11 Sep, 2011 16:58:00 +0000
441 Diff Diff GeorgeS picture GeorgeS Sat 20 Aug, 2011 20:52:17 +0000
430 GeorgeS picture GeorgeS Sat 20 Aug, 2011 19:46:21 +0000