Changeset 1483

Show
Ignore:
Timestamp:
10/15/10 14:52:00 (3 years ago)
Author:
sball@…
Message:

UserRegistration?, part 1

Location:
trunk/mpdb-client/src/edu/rpi/metpetdb
Files:
6 added
15 modified

Legend:

Unmodified
Added
Removed
  • trunk/mpdb-client/src/edu/rpi/metpetdb/MetPetDBApplication.gwt.xml

    r1402 r1483  
    33         
    44        <inherits name="com.google.gwt.user.User"/> 
     5        <inherits name="com.claudiushauptmann.gwt.recaptcha.gwt-recaptcha"/> 
    56        <!--  <inherits name="rocket.User" />--> 
    67        <inherits name="com.google.gwt.i18n.I18N"/> 
     
    1415        <inherits name="com.google.gwt.http.HTTP"/> 
    1516        <inherits name="com.objetdirect.tatami.Tatami"/> 
    16  
    1717         
    1818        <entry-point class='edu.rpi.metpetdb.client.ui.MetPetDBApplication'/> 
     
    2121 
    2222        <source path="client" /> 
     23         
    2324<extend-property name="locale" values="en_US"></extend-property> 
    2425     
     
    5455        <servlet path="/searchIPhone1_1.scv" class= "edu.rpi.metpetdb.server.search.SearchIPhone1_1"/> 
    5556         
     57         
     58        <servlet class="edu.rpi.metpetdb.server.recaptcha.RecaptchaRemoteServiceImpl" path="/recaptcha"/> 
    5659<!--    <replace-with class="com.google.gwt.dom.client.DOMImplMozillaFix"> 
    5760        <when-type-is class="com.google.gwt.dom.client.DOMImpl"/> 
  • trunk/mpdb-client/src/edu/rpi/metpetdb/client/service/UserService.java

    r1366 r1483  
    55import java.util.Set; 
    66 
    7 import com.google.gwt.user.client.rpc.AsyncCallback; 
    87import com.google.gwt.user.client.rpc.RemoteService; 
     8 
    99 
    1010import edu.rpi.metpetdb.client.error.LoginRequiredException; 
     
    1212import edu.rpi.metpetdb.client.error.UnableToSendEmailException; 
    1313import edu.rpi.metpetdb.client.error.ValidationException; 
     14import edu.rpi.metpetdb.client.error.validation.InvalidProfileRequestException; 
    1415import edu.rpi.metpetdb.client.error.validation.LoginFailureException; 
    1516import edu.rpi.metpetdb.client.model.ResumeSessionResponse; 
     
    7576         *              the welcome message could not be sent to the user's account. 
    7677         */ 
    77         User registerNewUser(UserWithPassword newbie) throws ValidationException, 
     78        User registerNewUser(UserWithPassword newbie, String challenge, String response) throws ValidationException, 
    7879                        MpDbException, UnableToSendEmailException; 
    7980 
     
    139140        User confirmUser(String confirmationCode) throws MpDbException, 
    140141                        LoginRequiredException; 
     142 
     143        User confirmContributor(String contributionCode) throws MpDbException, 
     144        LoginRequiredException; 
     145 
    141146         
    142147        User save(User user) throws MpDbException, ValidationException; 
     
    146151        public void sendConfirmationCode(User u) throws ValidationException, 
    147152        MpDbException, UnableToSendEmailException; 
     153         
     154        public User sendContributorCode(User u, String explanationText) throws ValidationException, 
     155        MpDbException, UnableToSendEmailException,  InvalidProfileRequestException; 
     156         
    148157         
    149158        Collection<User> getEligableSponsors(Role e) throws MpDbException; 
  • trunk/mpdb-client/src/edu/rpi/metpetdb/client/service/UserServiceAsync.java

    r1366 r1483  
    2525        void beginEditMyProfile(AsyncCallback<User> ac); 
    2626 
    27         void registerNewUser(UserWithPassword newbie, AsyncCallback<User> ac); 
     27        void registerNewUser(UserWithPassword newbie, String challenge, String response, AsyncCallback<User> ac); 
    2828 
    2929        void changePassword(UserWithPassword uwp, AsyncCallback<MObject> ac); 
     
    3434 
    3535        void confirmUser(String confirmationCode, AsyncCallback<User> ac); 
     36 
     37        void confirmContributor(String confirmationCode, AsyncCallback<User> ac); 
    3638 
    3739        void allNames(AsyncCallback<Set<String>> ac); 
     
    4446 
    4547        public void sendConfirmationCode(User u, AsyncCallback<Void> ac); 
     48 
     49        public void sendContributorCode(User u, String explanationText, AsyncCallback<User> ac); 
    4650 
    4751        public void getEligableSponsors(Role e, AsyncCallback<Collection<User>> ac); 
  • trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/MetPetDBApplication.java

    r1355 r1483  
    491491                }); 
    492492 
    493                 hdrnav.addItem("My Samples", TokenSpace.samplesForUser); 
    494                 hdrnav.addItem(LocaleHandler.lc_text.projectMenu(), TokenSpace.allProjects); 
     493                if (MpDb.currentUser() != null && MpDb.currentUser().getContributorEnabled()) 
     494                        hdrnav.addItem("My Samples", TokenSpace.samplesForUser); 
     495 
     496                if (MpDb.currentUser() != null && MpDb.currentUser().getContributorEnabled())            
     497                        hdrnav.addItem(LocaleHandler.lc_text.projectMenu(), TokenSpace.allProjects); 
     498 
    495499                hdrnav.addItem("Search", TokenSpace.search); 
    496                 hdrnav.addItem("Upload Data", TokenSpace.bulkUpload); 
     500 
     501                if (MpDb.currentUser() != null && MpDb.currentUser().getContributorEnabled()) 
     502                        hdrnav.addItem("Upload Data", TokenSpace.bulkUpload); 
     503                 
    497504                hdrnav.addItem("Wiki", new Command() { 
    498505                        public void execute() { 
  • trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/MpDb.java

    r1272 r1483  
    2727import edu.rpi.metpetdb.client.service.ProjectService; 
    2828import edu.rpi.metpetdb.client.service.ProjectServiceAsync; 
     29import edu.rpi.metpetdb.client.service.RecaptchaRemoteService; 
     30import edu.rpi.metpetdb.client.service.RecaptchaRemoteServiceAsync; 
    2931import edu.rpi.metpetdb.client.service.ReferenceService; 
    3032import edu.rpi.metpetdb.client.service.ReferenceServiceAsync; 
     
    103105         
    104106        public static final GeoReferenceServiceAsync geoReference_svc; 
     107         
     108        public static final RecaptchaRemoteServiceAsync recaptcha_svc; 
    105109 
    106110        public static DatabaseObjectConstraints doc; 
     
    191195                geoReference_svc = (GeoReferenceServiceAsync) bindService(GWT 
    192196                                .create(GeoReferenceService.class), "geoReference"); 
     197                 
     198                recaptcha_svc = (RecaptchaRemoteServiceAsync) bindService(GWT.create(RecaptchaRemoteService.class), "recaptcha"); 
    193199 
    194200                // factory = (HtmlFactory) GWT.create(HtmlFactory.class); 
  • trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/TokenSpace.java

    r1383 r1483  
    4545import edu.rpi.metpetdb.client.ui.search.Search; 
    4646import edu.rpi.metpetdb.client.ui.user.Confirmation; 
     47import edu.rpi.metpetdb.client.ui.user.Contribution; 
    4748import edu.rpi.metpetdb.client.ui.user.EditUserProfile; 
    4849import edu.rpi.metpetdb.client.ui.user.ProjectSamplesList; 
     
    411412                } 
    412413        }; 
     414         
     415        public static final Screen contribution = new Screen("ContributorCode") { 
     416                public void executeToken(final String args) { 
     417                        new VoidLoggedInOp() { 
     418                                @Override 
     419                                public void command() { 
     420                                        show(new Contribution().fill(args)); 
     421                                } 
     422                        }.execute(); 
     423                } 
     424        }; 
     425         
    413426        public static final Screen requestRoleChange = new Screen( 
    414427                        "RequestRoleChange") { 
     
    497510                register(createImageMap); 
    498511                register(confirmation); 
     512                register(contribution); 
    499513                register(rebuildSearchIndex); 
    500514                register(requestRoleChange); 
  • trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/input/DetailsPanel.java

    r1398 r1483  
    115115                                } 
    116116                        } 
    117                         dpEntries.put(atts[row], new DetailsPanelEntry(atts[row], newRow)); 
     117         
     118                                dpEntries.put(atts[row], new DetailsPanelEntry(atts[row], newRow)); 
    118119                } 
    119120 
     
    154155                final Element label = DOM.createLabel(); 
    155156                DOM.appendChild(labelTD, label); 
    156                 DOM.setInnerText(label, labelText); 
    157  
    158                 if (attr.getConstraint().required) { 
     157         
     158         
     159 
     160                        DOM.setInnerText(label, labelText); 
     161 
     162                if (attr.getConstraint() != null && attr.getConstraint().required) { 
    159163                        final Element em = DOM.createElement("em"); 
    160164                        DOM.setInnerText(em, "(required)"); 
     
    162166                } 
    163167 
     168                 
     169                 
    164170                final Element valueTD = DOM.createTD(); 
     171 
     172 
    165173                DOM.appendChild(tr, valueTD); 
    166174 
     175                 
     176 
     177                 
    167178                attr.setMyPanel(this); 
    168                 return new DetailsPanelRow(tr, labelTD, valueTD, label, attr 
    169                                 .getConstraint().required); 
     179                 
     180                         
     181                return new DetailsPanelRow(tr, labelTD, valueTD, label, attr.getConstraint().required);                  
    170182        } 
    171183 
     
    260272                        final DetailsPanelEntry dpEntry =  
    261273                                (DetailsPanelEntry) dpEntries.get(attr); 
    262                         showEditWidget(dpEntry, attr); 
     274                         
     275                                showEditWidget(dpEntry, attr); 
     276                         
     277                         
    263278                        final CurrentError err = new CurrentError(); 
    264279                        dpEntry.setCurrentError(err); 
     
    363378        } 
    364379 
    365         private Widget[] getEditWidgets(final GenericAttribute attr) { 
     380        public Widget[] getEditWidgets(final GenericAttribute attr) { 
    366381                if (!isEditMode()) 
    367382                        throw new IllegalStateException(); 
     
    376391                return ((DetailsPanelEntry) dpEntries.get(attr)).getCurrentError(); 
    377392        } 
     393         
     394         
     395 
     396        public CurrentMessage getCurrentMessage(final GenericAttribute attr) { 
     397 
     398                return ((DetailsPanelEntry) dpEntries.get(attr)).getCurrentMessage(); 
     399        } 
     400         
    378401 
    379402        protected boolean isEditMode() { 
  • trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/input/DetailsPanelEntry.java

    r521 r1483  
    44import java.util.Iterator; 
    55 
     6import com.google.gwt.user.client.DOM; 
     7import com.google.gwt.user.client.Element; 
    68import com.google.gwt.user.client.ui.Widget; 
    79 
     10import edu.rpi.metpetdb.client.ui.CSS; 
    811import edu.rpi.metpetdb.client.ui.input.attributes.GenericAttribute; 
     12import edu.rpi.metpetdb.client.ui.input.attributes.TextAreaAttribute; 
    913 
    1014/** 
     
    2024        private Widget[] currentEditWidgets; 
    2125        private Widget[] currentDisplayWidgets; 
    22  
     26        private CurrentMessage currentMessage = new CurrentMessage(); 
     27         
    2328        /** 
    2429         * Creates a new DetailsPanelEntry, all of them need to have atleast 1 row 
     
    3540                this.entryRows.add(row); 
    3641                this.attr = ga; 
     42                 
     43                if (ga instanceof TextAreaAttribute)// && MpDb.currentUser() != null && !MpDb.currentUser().getContributorEnabled()) 
     44                { 
     45                         
     46                        currentMessage.setText(((TextAreaAttribute)ga).getDescription()); 
     47                         
     48 
     49                         
     50                        Element label = DOM.createTD(); 
     51 
     52                        CSS.setStyleName(label, "description-message"); 
     53                        label.setClassName("description-message"); 
     54                         
     55                         
     56                        Element description = DOM.createDiv(); 
     57                         
     58                        description.setClassName("description"); 
     59                         
     60                        description.setInnerText((((TextAreaAttribute)ga).getDescription())); 
     61                         
     62                        label.appendChild(description); 
     63                         
     64                        row.getRow().appendChild(label); 
     65                } 
     66 
    3767        } 
    3868 
     
    113143                this.currentError = currentError; 
    114144        } 
     145 
     146        public CurrentMessage getCurrentMessage() { 
     147                return currentMessage; 
     148        } 
     149 
     150        public void setCurrentMessage(CurrentMessage currentMessage) { 
     151                this.currentMessage = currentMessage; 
     152        } 
    115153} 
  • trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/input/attributes/GenericAttribute.java

    r1335 r1483  
    1717import edu.rpi.metpetdb.client.ui.CSS; 
    1818import edu.rpi.metpetdb.client.ui.input.CurrentError; 
     19import edu.rpi.metpetdb.client.ui.input.CurrentMessage; 
    1920import edu.rpi.metpetdb.client.ui.input.DetailsPanel; 
    2021import edu.rpi.metpetdb.client.ui.input.DetailsPanelTableLoc; 
     
    3940         *            that are a part of this attribute 
    4041         */ 
     42         
     43        protected GenericAttribute(final String labelString) 
     44        { 
     45                labels = new String[] {labelString, null}; 
     46        } 
     47         
    4148        protected GenericAttribute(final PropertyConstraint[] pcs) { 
    4249                if (pcs.length == 1) { 
     
    93100                }); 
    94101        } 
     102         
     103        protected  GenericAttribute(final PropertyConstraint pc, Widget widget) 
     104        { 
     105                this(new PropertyConstraint[] { 
     106                                pc 
     107                                 
     108                }); 
     109                 
     110                this.getMyPanel().add(widget); 
     111        } 
    95112 
    96113        /** 
     
    158175         */ 
    159176        public PropertyConstraint getConstraint() { 
    160                 return constraints[0]; 
     177                if (constraints != null && constraints.length > 0) 
     178                        return constraints[0]; 
     179                else 
     180                        return null; 
    161181        } 
    162182        /** 
     
    190210        } 
    191211        protected Object mGet(final MObject obj) { 
    192                 return resolve(obj).mGet(constraints[0].property); 
     212                if (constraints != null && constraints.length > 0) 
     213                        return resolve(obj).mGet(constraints[0].property); 
     214                else 
     215                        return labels[0]; 
    193216        } 
    194217        protected HashMap<PropertyConstraint, Object> mGetAll(final DataType obj) { 
     
    235258 
    236259        protected void applyStyle(final Widget editWidget, final boolean valid) { 
     260                 
     261                if (constraints == null || constraints.length == 0) 
     262                        return; 
     263                 
    237264                if (constraints[0].required) 
    238265                        editWidget.addStyleName(CSS.REQUIRED); 
     
    247274        public void commitEdit(final DataType obj, final Widget[] editWidget, 
    248275                        final CurrentError err, final Command r) { 
     276                 
     277                if (constraints == null || constraints.length == 0) 
     278                        return; 
     279                 
    249280                for (int i = 0; i < constraints.length; ++i) { 
    250281                        try { 
     
    268299                err.setText(whybad.format()); 
    269300        } 
    270  
     301         
    271302        protected Object get(final Widget[] editWidgets, 
    272303                        final PropertyConstraint constraint, final int i) 
  • trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/input/attributes/TextAreaAttribute.java

    r809 r1483  
    44import com.google.gwt.user.client.ui.HTML; 
    55import com.google.gwt.user.client.ui.HasText; 
     6import com.google.gwt.user.client.ui.Label; 
    67import com.google.gwt.user.client.ui.TextArea; 
    78import com.google.gwt.user.client.ui.Widget; 
     
    1516        protected int visibleLength; 
    1617 
     18        private String description; 
     19        public TextAreaAttribute(final  StringConstraint sc, String description) 
     20        { 
     21                super(sc); 
     22                this.description = description; 
     23        } 
     24         
    1725        public TextAreaAttribute(final StringConstraint sc) { 
    1826                super(sc); 
     
    3846                b.setVisibleLines(3); 
    3947                applyStyle(b, true); 
     48 
     49                Label descriptionLabel = new Label(description); 
     50                 
     51                DOM.setElementAttribute(descriptionLabel.getElement(), "label" , "label"); 
     52 
    4053                return new Widget[] { 
    4154                        b 
     
    5871                mSet(obj, v != null && ((String) v).length() > 0 ? v : null); 
    5972        } 
     73 
     74        public String getDescription() { 
     75                return description; 
     76        } 
     77 
     78        public void setDescription(String description) { 
     79                this.description = description; 
     80        } 
    6081} 
  • trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/input/attributes/TextAttribute.java

    r1473 r1483  
    2323        protected boolean negative = false; 
    2424 
     25    public TextAttribute(final String labelString) 
     26    { 
     27            super(labelString); 
     28    } 
     29 
     30         
    2531        public TextAttribute(final StringConstraint sc) { 
    2632                super(sc); 
  • trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/user/Confirmation.java

    r850 r1483  
    11package edu.rpi.metpetdb.client.ui.user; 
    22 
     3import com.google.gwt.user.client.History; 
    34import com.google.gwt.user.client.ui.Button; 
    45import com.google.gwt.user.client.ui.ClickListener; 
     
    1011import edu.rpi.metpetdb.client.model.User; 
    1112import edu.rpi.metpetdb.client.ui.MpDb; 
     13import edu.rpi.metpetdb.client.ui.TokenSpace; 
    1214import edu.rpi.metpetdb.client.ui.commands.ServerOp; 
    1315 
     
    2426                confirm = new Button("Confirm", this); 
    2527                add(instructions); 
     28                 
    2629                if (!MpDb.currentUser().getEnabled()) { 
    2730                        add(confirmationCode); 
    2831                        add(confirm); 
     32                         
    2933                } else { 
    3034                        instructions 
    3135                                        .setText("Your account is already enabled - you cannot confirm it."); 
    3236                } 
     37                 
     38                 
    3339        } 
    3440 
     
    5056                                        MpDb.setCurrentUser(result); 
    5157                                        instructions.setText("Your account is now enabled"); 
     58                                        History.newItem(TokenSpace.editProfile.makeToken(null)); 
     59                                         
    5260                                } 
    5361                        }.begin(); 
    5462                } 
     63                 
    5564        } 
    5665 
  • trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/user/EditUserProfile.java

    r1366 r1483  
    11package edu.rpi.metpetdb.client.ui.user; 
    22 
     3import com.google.gwt.user.client.DOM; 
     4import com.google.gwt.user.client.History; 
    35import com.google.gwt.user.client.ui.Button; 
     6import com.google.gwt.user.client.ui.CheckBox; 
    47import com.google.gwt.user.client.ui.ClickListener; 
    58import com.google.gwt.user.client.ui.FlowPanel; 
     9import com.google.gwt.user.client.ui.Label; 
     10import com.google.gwt.user.client.ui.TextArea; 
    611import com.google.gwt.user.client.ui.Widget; 
    712 
    813import edu.rpi.metpetdb.client.error.LoginRequiredException; 
     14import edu.rpi.metpetdb.client.error.validation.InvalidProfileRequestException; 
    915import edu.rpi.metpetdb.client.locale.LocaleHandler; 
    1016import edu.rpi.metpetdb.client.model.User; 
     
    1824import edu.rpi.metpetdb.client.ui.input.OnEnterPanel; 
    1925import edu.rpi.metpetdb.client.ui.input.Submit; 
     26import edu.rpi.metpetdb.client.ui.input.attributes.CheckBoxAttribute; 
    2027import edu.rpi.metpetdb.client.ui.input.attributes.GenericAttribute; 
    2128import edu.rpi.metpetdb.client.ui.input.attributes.PasswordAttribute; 
     29import edu.rpi.metpetdb.client.ui.input.attributes.TextAreaAttribute; 
    2230import edu.rpi.metpetdb.client.ui.input.attributes.TextAttribute; 
    23 import edu.rpi.metpetdb.client.ui.widgets.MLink; 
    2431import edu.rpi.metpetdb.client.ui.widgets.MText; 
    2532import edu.rpi.metpetdb.client.ui.widgets.panels.MPagePanel; 
     
    2835        private static User user; 
    2936 
     37        private static TextAreaAttribute contributorRequestAttribute = new TextAreaAttribute( 
     38                        MpDb.doc.User_researchInterests, ""); 
     39 
     40        private static CheckBoxAttribute requestContributorAttribute = new CheckBoxAttribute( 
     41                        MpDb.doc.User_requestContributor); 
     42 
    3043        public EditUserProfile(final User whoToEdit) { 
    3144                setPageTitle("Edit Profile"); 
     45                 
     46                Label label1 = new Label(LocaleHandler.lc_text.editProfile_description_1()); 
     47                 
     48                this.add(label1); 
     49                DOM.appendChild(label1.getElement(), DOM.createElement("br") ); 
     50                DOM.appendChild(label1.getElement(), DOM.createElement("br") ); 
     51 
     52                Label label2 = new Label(LocaleHandler.lc_text.editProfile_description_2()); 
     53                this.add(label2); 
     54                DOM.appendChild(label2.getElement(), DOM.createElement("br")); 
     55                DOM.appendChild(label2.getElement(), DOM.createElement("br") ); 
     56 
     57                Label label3 = new Label(LocaleHandler.lc_text.editProfile_description_3());             
     58                this.add(label3); 
     59                DOM.appendChild(label3.getElement(), DOM.createElement("br")); 
     60                DOM.appendChild(label3.getElement(), DOM.createElement("br") ); 
     61                 
     62                 
    3263                user = whoToEdit; 
    33                 if (MpDb.isCurrentUser(user)){ 
    34                         add(new MLink("Request Role Change", TokenSpace.requestRoleChange)); 
    35                         add(new MLink("Review my pending role changes", TokenSpace.reviewRoleChanges)); 
     64 
     65                displayMemberStatus(); 
     66 
     67                if (MpDb.isCurrentUser(user)) { 
    3668                        add(new PasswordChanger(user)); 
    3769                        add(new InfoChanger(user)); 
     70                } 
     71        } 
     72 
     73        private void displayMemberStatus() { 
     74                if (MpDb.isCurrentUser(user) && user.getContributorEnabled()) { 
     75                        add(new MText("You are a Contributor")); 
     76                } else if (MpDb.isCurrentUser(user) && user.getEnabled()) { 
     77                        add(new MText("You are a Member")); 
     78                } else { 
     79                        add(new MText("You are not a confirmed user")); 
    3880                } 
    3981        } 
     
    4486                        throw new LoginRequiredException(); 
    4587        } 
    46          
    47         private static void setUser(User u){ 
     88 
     89        private static void setUser(User u) { 
    4890                user = u; 
    4991        } 
    50          
    51         static class InfoChanger extends FlowPanel implements ClickListener{ 
     92 
     93        static class InfoChanger extends FlowPanel implements ClickListener { 
    5294                private static final GenericAttribute[] userAttributes = { 
    53                         new TextAttribute(MpDb.doc.User_name), 
    54                         new TextAttribute(MpDb.doc.User_emailAddress), 
    55                         new TextAttribute(MpDb.doc.User_address),  
    56                         new TextAttribute(MpDb.doc.User_city),  
    57                         new TextAttribute(MpDb.doc.User_province), 
    58                         new TextAttribute(MpDb.doc.User_country), 
    59                         new TextAttribute(MpDb.doc.User_postalCode),  
    60                         new TextAttribute(MpDb.doc.User_institution),  
    61                         new TextAttribute(MpDb.doc.User_referenceEmail), 
     95                                new TextAttribute(MpDb.doc.User_name), 
     96                                new TextAttribute(MpDb.doc.User_emailAddress), 
     97                                new TextAttribute(MpDb.doc.User_address), 
     98                                new TextAttribute(MpDb.doc.User_city), 
     99                                new TextAttribute(MpDb.doc.User_province), 
     100                                new TextAttribute(MpDb.doc.User_country), 
     101                                new TextAttribute(MpDb.doc.User_postalCode), 
     102                                new TextAttribute(MpDb.doc.User_institution), 
     103                                contributorRequestAttribute, 
     104                                new TextAttribute(MpDb.doc.User_professionalUrl), 
     105                                requestContributorAttribute 
    62106                }; 
    63107                private User u; 
    64108                private final DetailsPanel<User> p_main; 
    65109                private final FlowPanel infoContainer = new FlowPanel(); 
    66                 private final MText infoHeader = new MText("Change your information", "h2"); 
     110                private final MText infoHeader = new MText("Change your information", 
     111                                "h2"); 
    67112                private final Button changeInfo; 
    68                  
    69                 private void setUser(User u){ 
     113 
     114 
     115                private void setUser(User u) { 
    70116                        this.u = u; 
    71117                } 
    72                  
     118 
    73119                InfoChanger(final User whoToEdit) { 
    74120                        u = whoToEdit; 
    75                         changeInfo = new Submit(LocaleHandler.lc_text 
    76                                         .buttonUpdateInfo()); 
     121                        changeInfo = new Submit(LocaleHandler.lc_text.buttonUpdateInfo()); 
     122 
    77123                        changeInfo.addClickListener(this); 
    78                         p_main = new DetailsPanel<User>(userAttributes, 
    79                         new Button[] { 
    80                                         changeInfo 
     124 
     125                        p_main = new DetailsPanel<User>(userAttributes, new Button[] { 
     126                                changeInfo 
    81127                        }); 
    82128 
    83129                        p_main.edit(u); 
     130 
     131                        if (p_main.getBean().getRequestContributor() 
     132                                        || p_main.getBean().getContributorEnabled()) { 
     133                                for (int i = 0; i < p_main.getWidgetCount(); i++) { 
     134                                        Widget currWidget = p_main.getWidget(i); 
     135 
     136                                        if (currWidget instanceof CheckBox) { 
     137                                                CheckBox cb = (CheckBox) currWidget; 
     138                                                cb.setEnabled(false); 
     139                                        } 
     140                                } 
     141                        } 
     142 
    84143                        infoContainer.add(infoHeader); 
    85144                        infoContainer.add(p_main); 
    86145 
    87146                        add(new OnEnterPanel(infoContainer) { 
    88                                 public void onEnter() {                                  
    89                                         doChangeInfo(); 
     147                                public void onEnter() { 
     148                                         
     149                                        try 
     150                                        { 
     151                                                doChangeInfo(); 
     152                                        } 
     153                                        catch (Exception e) 
     154                                        { 
     155                                                throw new RuntimeException(e.getMessage());                                              
     156                                        } 
    90157                                } 
    91158                        }); 
    92                 }        
    93                  
     159                } 
     160 
    94161                public void onClick(final Widget sender) { 
    95162                        if (sender == changeInfo) 
     163                                { 
     164                                try 
     165                                { 
    96166                                doChangeInfo(); 
    97                 } 
    98                  
    99                 protected void doChangeInfo() { 
     167                                } 
     168                                catch (Exception e) 
     169                                { 
     170                                        throw new RuntimeException(e.getMessage()); 
     171                                } 
     172                                } 
     173 
     174                } 
     175 
     176                 
     177                 
     178                protected void doChangeInfo() throws InvalidProfileRequestException { 
    100179                        new FormOp<User>(p_main) { 
    101                                 protected void onSubmit() { 
    102                                         MpDb.user_svc.save(u, this); 
     180                                protected void onSubmit()  { 
     181 
     182 
     183                                        CheckBox requestContributorRequest = null; 
     184 
     185                                        for (int i = 0; i < p_main.getWidgetCount(); i++) { 
     186                                                Widget currWidget = p_main.getWidget(i); 
     187 
     188                                                if (currWidget instanceof CheckBox) { 
     189                                                        requestContributorRequest = (CheckBox) currWidget; 
     190                                                        break; 
     191                                                } 
     192                                        } 
     193 
     194                                        TextArea researchInterests = (TextArea) p_main 
     195                                                        .getEditWidgets(contributorRequestAttribute)[0]; 
     196 
     197                                        if (requestContributorRequest.getValue().equals(Boolean.TRUE)) { 
     198                                                MpDb.user_svc.sendContributorCode(u, researchInterests 
     199                                                                .getText(), this); 
     200                                                 
     201                                        } 
     202                                        else 
     203                                        { 
     204                                                MpDb.user_svc.save(u, this); 
     205                                        } 
     206 
    103207                                } 
    104208                                public void onFailure(final Throwable e) { 
     
    110214                                        u = result; 
    111215                                        enable(true); 
    112                                         p_main.edit(u); 
     216                                        // p_main.edit(u); 
    113217                                        MetPetDBApplication.notice(LocaleHandler.lc_text 
    114218                                                        .notice_InfoChanged(u.getEmailAddress())); 
     219 
     220                                        // Go Home 
     221                                        History.newItem(TokenSpace.home.makeToken(null)); 
    115222                                } 
    116223                        }.begin(); 
     
    124231                                new PasswordAttribute(MpDb.doc.UserWithPassword_vrfPassword), 
    125232                }; 
    126                  
     233 
    127234                private final UserWithPassword uwp; 
    128                  
     235 
    129236                private final DetailsPanel<UserWithPassword> p_password; 
    130                  
     237 
    131238                private final FlowPanel passwordContainer = new FlowPanel(); 
    132                 private final MText passwordHeader = new MText("Change your password", "h2"); 
     239                private final MText passwordHeader = new MText("Change your password", 
     240                                "h2"); 
    133241                private final Button changePassword; 
    134                          
     242 
    135243                PasswordChanger(final User whoToEdit) { 
    136244                        uwp = new UserWithPassword(whoToEdit); 
     
    143251                                        new Button[] { 
    144252                                                changePassword 
    145                         }); 
     253                                        }); 
    146254                        p_password.edit(uwp); 
    147                          
     255 
    148256                        passwordContainer.add(passwordHeader); 
    149257                        passwordContainer.add(p_password); 
     
    151259                        add(new OnEnterPanel(passwordContainer) { 
    152260                                public void onEnter() { 
    153                                          
     261 
    154262                                        doChangePassword(); 
    155263                                } 
    156264                        }); 
    157                          
     265 
    158266                } 
    159267 
  • trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/user/UserDetails.java

    r850 r1483  
    2020                        new TextAttribute(MpDb.doc.User_postalCode),  
    2121                        new TextAttribute(MpDb.doc.User_institution),  
    22                         new TextAttribute(MpDb.doc.User_referenceEmail) 
     22                        new TextAttribute(MpDb.doc.User_professionalUrl) 
    2323        }; 
    2424 
  • trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/user/UserRegistrationPanel.java

    r883 r1483  
    11package edu.rpi.metpetdb.client.ui.user; 
    22 
     3import com.claudiushauptmann.gwt.recaptcha.client.RecaptchaWidget; 
    34import com.google.gwt.user.client.History; 
     5import com.google.gwt.user.client.Window; 
    46import com.google.gwt.user.client.ui.Button; 
    57import com.google.gwt.user.client.ui.ClickListener; 
    68import com.google.gwt.user.client.ui.Widget; 
    79 
     10import edu.rpi.metpetdb.client.error.validation.InvalidCaptchaException; 
    811import edu.rpi.metpetdb.client.locale.LocaleHandler; 
    912import edu.rpi.metpetdb.client.model.User; 
     
    1417import edu.rpi.metpetdb.client.ui.TokenSpace; 
    1518import edu.rpi.metpetdb.client.ui.commands.FormOp; 
     19import edu.rpi.metpetdb.client.ui.input.CurrentMessage; 
    1620import edu.rpi.metpetdb.client.ui.input.DetailsPanel; 
    1721import edu.rpi.metpetdb.client.ui.input.FocusSupport; 
     
    2024import edu.rpi.metpetdb.client.ui.input.attributes.GenericAttribute; 
    2125import edu.rpi.metpetdb.client.ui.input.attributes.PasswordAttribute; 
     26import edu.rpi.metpetdb.client.ui.input.attributes.TextAreaAttribute; 
    2227import edu.rpi.metpetdb.client.ui.input.attributes.TextAttribute; 
    2328import edu.rpi.metpetdb.client.ui.widgets.panels.MPagePanel; 
    2429 
    25 public class UserRegistrationPanel extends MPagePanel implements ClickListener {  
     30public class UserRegistrationPanel extends MPagePanel implements ClickListener { 
     31 
     32        private static final TextAreaAttribute contributorRequestAttribute = new TextAreaAttribute( 
     33                        MpDb.doc.User_researchInterests, "") { 
     34                protected MObject resolve(final MObject obj) { 
     35 
     36                        return ((UserWithPassword) obj).getUser(); 
     37                } 
     38 
     39        }; 
     40 
    2641        private static final GenericAttribute[] mainAttributes = { 
    2742                        new TextAttribute(MpDb.doc.User_name) { 
     
    5974                                        return ((UserWithPassword) obj).getUser(); 
    6075                                } 
    61                         }, new TextAttribute(MpDb.doc.User_referenceEmail) { 
     76                        }, 
     77 
     78                        contributorRequestAttribute 
     79 
     80                        , new TextAttribute(MpDb.doc.User_professionalUrl) { 
    6281                                protected MObject resolve(final MObject obj) { 
    6382                                        return ((UserWithPassword) obj).getUser(); 
    6483                                } 
    6584                        } 
     85 
    6686        }; 
    6787 
     
    6989        private final Button register; 
    7090        private final DetailsPanel<UserWithPassword> p_main; 
     91        private final RecaptchaWidget rw; 
    7192 
    7293        public UserRegistrationPanel() { 
     
    7798                register = new Submit(LocaleHandler.lc_text.buttonRegister(), this); 
    7899 
     100                // TODO: Externalize Recaptcha key SCB 
     101                rw = new RecaptchaWidget("6LeCaL0SAAAAAD-dKyj9t3PTOqdW8j9svbfHn9P2"); 
     102 
    79103                p_main = new DetailsPanel<UserWithPassword>(mainAttributes, 
    80                                 new Button[] { 
    81                                                 register 
     104                                new Widget[] { 
     105                                                rw, register 
    82106                                }); 
     107 
    83108                p_main.edit(newbie); 
    84                  
     109 
    85110                add(new OnEnterPanel(p_main) { 
    86111                        public void onEnter() { 
    87                                 doRegister(); 
     112 
     113                                try { 
     114                                        doRegister(); 
     115                                } catch (InvalidCaptchaException bce) { 
     116                                        bce.printStackTrace(); 
     117                                } 
    88118                        } 
    89                 });      
     119                }); 
    90120        } 
    91121 
     
    93123                super.onLoad(); 
    94124                FocusSupport.requestFocus(p_main); 
     125 
    95126        } 
    96127 
    97128        public void onClick(final Widget sender) { 
    98                 if (sender == register) 
    99                         doRegister(); 
     129                if (sender == register) { 
     130                        try { 
     131                                doRegister(); 
     132                        } catch (InvalidCaptchaException bce) { 
     133                                Window.alert("Invalid captcha entered"); 
     134 
     135                                throw new RuntimeException("Invalid captcha entered"); 
     136                        } 
     137                } 
     138 
    100139        } 
    101140 
    102         protected void doRegister() { 
     141        private CurrentMessage getCurrentMessage(final GenericAttribute attr) { 
     142 
     143                return p_main.getCurrentMessage(attr); 
     144        } 
     145 
     146        protected void doRegister() throws InvalidCaptchaException { 
    103147                new FormOp<User>(p_main) { 
     148 
    104149                        protected void onSubmit() { 
    105                                 MpDb.user_svc.registerNewUser(newbie, this); 
     150 
     151                                MpDb.user_svc.registerNewUser(newbie, rw.getChallenge(), rw 
     152                                                .getResponse(), this); 
    106153                        } 
     154 
    107155                        public void onSuccess(final User result) { 
    108156                                MpDb.setCurrentUser((User) result);