Changeset 1483
- Timestamp:
- 10/15/10 14:52:00 (3 years ago)
- Location:
- trunk/mpdb-client/src/edu/rpi/metpetdb
- Files:
-
- 6 added
- 15 modified
-
MetPetDBApplication.gwt.xml (modified) (4 diffs)
-
client/service/RecaptchaRemoteService.java (added)
-
client/service/RecaptchaRemoteServiceAsync.java (added)
-
client/service/UserService.java (modified) (5 diffs)
-
client/service/UserServiceAsync.java (modified) (3 diffs)
-
client/ui/MetPetDBApplication.java (modified) (1 diff)
-
client/ui/MpDb.java (modified) (3 diffs)
-
client/ui/TokenSpace.java (modified) (3 diffs)
-
client/ui/input/CurrentMessage.java (added)
-
client/ui/input/DetailsPanel.java (modified) (6 diffs)
-
client/ui/input/DetailsPanelEntry.java (modified) (4 diffs)
-
client/ui/input/attributes/CheckBoxAttribute.java (added)
-
client/ui/input/attributes/GenericAttribute.java (modified) (8 diffs)
-
client/ui/input/attributes/LabelAttribute.java (added)
-
client/ui/input/attributes/TextAreaAttribute.java (modified) (4 diffs)
-
client/ui/input/attributes/TextAttribute.java (modified) (1 diff)
-
client/ui/user/Confirmation.java (modified) (4 diffs)
-
client/ui/user/Contribution.java (added)
-
client/ui/user/EditUserProfile.java (modified) (8 diffs)
-
client/ui/user/UserDetails.java (modified) (1 diff)
-
client/ui/user/UserRegistrationPanel.java (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/mpdb-client/src/edu/rpi/metpetdb/MetPetDBApplication.gwt.xml
r1402 r1483 3 3 4 4 <inherits name="com.google.gwt.user.User"/> 5 <inherits name="com.claudiushauptmann.gwt.recaptcha.gwt-recaptcha"/> 5 6 <!-- <inherits name="rocket.User" />--> 6 7 <inherits name="com.google.gwt.i18n.I18N"/> … … 14 15 <inherits name="com.google.gwt.http.HTTP"/> 15 16 <inherits name="com.objetdirect.tatami.Tatami"/> 16 17 17 18 18 <entry-point class='edu.rpi.metpetdb.client.ui.MetPetDBApplication'/> … … 21 21 22 22 <source path="client" /> 23 23 24 <extend-property name="locale" values="en_US"></extend-property> 24 25 … … 54 55 <servlet path="/searchIPhone1_1.scv" class= "edu.rpi.metpetdb.server.search.SearchIPhone1_1"/> 55 56 57 58 <servlet class="edu.rpi.metpetdb.server.recaptcha.RecaptchaRemoteServiceImpl" path="/recaptcha"/> 56 59 <!-- <replace-with class="com.google.gwt.dom.client.DOMImplMozillaFix"> 57 60 <when-type-is class="com.google.gwt.dom.client.DOMImpl"/> -
trunk/mpdb-client/src/edu/rpi/metpetdb/client/service/UserService.java
r1366 r1483 5 5 import java.util.Set; 6 6 7 import com.google.gwt.user.client.rpc.AsyncCallback;8 7 import com.google.gwt.user.client.rpc.RemoteService; 8 9 9 10 10 import edu.rpi.metpetdb.client.error.LoginRequiredException; … … 12 12 import edu.rpi.metpetdb.client.error.UnableToSendEmailException; 13 13 import edu.rpi.metpetdb.client.error.ValidationException; 14 import edu.rpi.metpetdb.client.error.validation.InvalidProfileRequestException; 14 15 import edu.rpi.metpetdb.client.error.validation.LoginFailureException; 15 16 import edu.rpi.metpetdb.client.model.ResumeSessionResponse; … … 75 76 * the welcome message could not be sent to the user's account. 76 77 */ 77 User registerNewUser(UserWithPassword newbie ) throws ValidationException,78 User registerNewUser(UserWithPassword newbie, String challenge, String response) throws ValidationException, 78 79 MpDbException, UnableToSendEmailException; 79 80 … … 139 140 User confirmUser(String confirmationCode) throws MpDbException, 140 141 LoginRequiredException; 142 143 User confirmContributor(String contributionCode) throws MpDbException, 144 LoginRequiredException; 145 141 146 142 147 User save(User user) throws MpDbException, ValidationException; … … 146 151 public void sendConfirmationCode(User u) throws ValidationException, 147 152 MpDbException, UnableToSendEmailException; 153 154 public User sendContributorCode(User u, String explanationText) throws ValidationException, 155 MpDbException, UnableToSendEmailException, InvalidProfileRequestException; 156 148 157 149 158 Collection<User> getEligableSponsors(Role e) throws MpDbException; -
trunk/mpdb-client/src/edu/rpi/metpetdb/client/service/UserServiceAsync.java
r1366 r1483 25 25 void beginEditMyProfile(AsyncCallback<User> ac); 26 26 27 void registerNewUser(UserWithPassword newbie, AsyncCallback<User> ac);27 void registerNewUser(UserWithPassword newbie, String challenge, String response, AsyncCallback<User> ac); 28 28 29 29 void changePassword(UserWithPassword uwp, AsyncCallback<MObject> ac); … … 34 34 35 35 void confirmUser(String confirmationCode, AsyncCallback<User> ac); 36 37 void confirmContributor(String confirmationCode, AsyncCallback<User> ac); 36 38 37 39 void allNames(AsyncCallback<Set<String>> ac); … … 44 46 45 47 public void sendConfirmationCode(User u, AsyncCallback<Void> ac); 48 49 public void sendContributorCode(User u, String explanationText, AsyncCallback<User> ac); 46 50 47 51 public void getEligableSponsors(Role e, AsyncCallback<Collection<User>> ac); -
trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/MetPetDBApplication.java
r1355 r1483 491 491 }); 492 492 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 495 499 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 497 504 hdrnav.addItem("Wiki", new Command() { 498 505 public void execute() { -
trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/MpDb.java
r1272 r1483 27 27 import edu.rpi.metpetdb.client.service.ProjectService; 28 28 import edu.rpi.metpetdb.client.service.ProjectServiceAsync; 29 import edu.rpi.metpetdb.client.service.RecaptchaRemoteService; 30 import edu.rpi.metpetdb.client.service.RecaptchaRemoteServiceAsync; 29 31 import edu.rpi.metpetdb.client.service.ReferenceService; 30 32 import edu.rpi.metpetdb.client.service.ReferenceServiceAsync; … … 103 105 104 106 public static final GeoReferenceServiceAsync geoReference_svc; 107 108 public static final RecaptchaRemoteServiceAsync recaptcha_svc; 105 109 106 110 public static DatabaseObjectConstraints doc; … … 191 195 geoReference_svc = (GeoReferenceServiceAsync) bindService(GWT 192 196 .create(GeoReferenceService.class), "geoReference"); 197 198 recaptcha_svc = (RecaptchaRemoteServiceAsync) bindService(GWT.create(RecaptchaRemoteService.class), "recaptcha"); 193 199 194 200 // factory = (HtmlFactory) GWT.create(HtmlFactory.class); -
trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/TokenSpace.java
r1383 r1483 45 45 import edu.rpi.metpetdb.client.ui.search.Search; 46 46 import edu.rpi.metpetdb.client.ui.user.Confirmation; 47 import edu.rpi.metpetdb.client.ui.user.Contribution; 47 48 import edu.rpi.metpetdb.client.ui.user.EditUserProfile; 48 49 import edu.rpi.metpetdb.client.ui.user.ProjectSamplesList; … … 411 412 } 412 413 }; 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 413 426 public static final Screen requestRoleChange = new Screen( 414 427 "RequestRoleChange") { … … 497 510 register(createImageMap); 498 511 register(confirmation); 512 register(contribution); 499 513 register(rebuildSearchIndex); 500 514 register(requestRoleChange); -
trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/input/DetailsPanel.java
r1398 r1483 115 115 } 116 116 } 117 dpEntries.put(atts[row], new DetailsPanelEntry(atts[row], newRow)); 117 118 dpEntries.put(atts[row], new DetailsPanelEntry(atts[row], newRow)); 118 119 } 119 120 … … 154 155 final Element label = DOM.createLabel(); 155 156 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) { 159 163 final Element em = DOM.createElement("em"); 160 164 DOM.setInnerText(em, "(required)"); … … 162 166 } 163 167 168 169 164 170 final Element valueTD = DOM.createTD(); 171 172 165 173 DOM.appendChild(tr, valueTD); 166 174 175 176 177 167 178 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); 170 182 } 171 183 … … 260 272 final DetailsPanelEntry dpEntry = 261 273 (DetailsPanelEntry) dpEntries.get(attr); 262 showEditWidget(dpEntry, attr); 274 275 showEditWidget(dpEntry, attr); 276 277 263 278 final CurrentError err = new CurrentError(); 264 279 dpEntry.setCurrentError(err); … … 363 378 } 364 379 365 p rivateWidget[] getEditWidgets(final GenericAttribute attr) {380 public Widget[] getEditWidgets(final GenericAttribute attr) { 366 381 if (!isEditMode()) 367 382 throw new IllegalStateException(); … … 376 391 return ((DetailsPanelEntry) dpEntries.get(attr)).getCurrentError(); 377 392 } 393 394 395 396 public CurrentMessage getCurrentMessage(final GenericAttribute attr) { 397 398 return ((DetailsPanelEntry) dpEntries.get(attr)).getCurrentMessage(); 399 } 400 378 401 379 402 protected boolean isEditMode() { -
trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/input/DetailsPanelEntry.java
r521 r1483 4 4 import java.util.Iterator; 5 5 6 import com.google.gwt.user.client.DOM; 7 import com.google.gwt.user.client.Element; 6 8 import com.google.gwt.user.client.ui.Widget; 7 9 10 import edu.rpi.metpetdb.client.ui.CSS; 8 11 import edu.rpi.metpetdb.client.ui.input.attributes.GenericAttribute; 12 import edu.rpi.metpetdb.client.ui.input.attributes.TextAreaAttribute; 9 13 10 14 /** … … 20 24 private Widget[] currentEditWidgets; 21 25 private Widget[] currentDisplayWidgets; 22 26 private CurrentMessage currentMessage = new CurrentMessage(); 27 23 28 /** 24 29 * Creates a new DetailsPanelEntry, all of them need to have atleast 1 row … … 35 40 this.entryRows.add(row); 36 41 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 37 67 } 38 68 … … 113 143 this.currentError = currentError; 114 144 } 145 146 public CurrentMessage getCurrentMessage() { 147 return currentMessage; 148 } 149 150 public void setCurrentMessage(CurrentMessage currentMessage) { 151 this.currentMessage = currentMessage; 152 } 115 153 } -
trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/input/attributes/GenericAttribute.java
r1335 r1483 17 17 import edu.rpi.metpetdb.client.ui.CSS; 18 18 import edu.rpi.metpetdb.client.ui.input.CurrentError; 19 import edu.rpi.metpetdb.client.ui.input.CurrentMessage; 19 20 import edu.rpi.metpetdb.client.ui.input.DetailsPanel; 20 21 import edu.rpi.metpetdb.client.ui.input.DetailsPanelTableLoc; … … 39 40 * that are a part of this attribute 40 41 */ 42 43 protected GenericAttribute(final String labelString) 44 { 45 labels = new String[] {labelString, null}; 46 } 47 41 48 protected GenericAttribute(final PropertyConstraint[] pcs) { 42 49 if (pcs.length == 1) { … … 93 100 }); 94 101 } 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 } 95 112 96 113 /** … … 158 175 */ 159 176 public PropertyConstraint getConstraint() { 160 return constraints[0]; 177 if (constraints != null && constraints.length > 0) 178 return constraints[0]; 179 else 180 return null; 161 181 } 162 182 /** … … 190 210 } 191 211 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]; 193 216 } 194 217 protected HashMap<PropertyConstraint, Object> mGetAll(final DataType obj) { … … 235 258 236 259 protected void applyStyle(final Widget editWidget, final boolean valid) { 260 261 if (constraints == null || constraints.length == 0) 262 return; 263 237 264 if (constraints[0].required) 238 265 editWidget.addStyleName(CSS.REQUIRED); … … 247 274 public void commitEdit(final DataType obj, final Widget[] editWidget, 248 275 final CurrentError err, final Command r) { 276 277 if (constraints == null || constraints.length == 0) 278 return; 279 249 280 for (int i = 0; i < constraints.length; ++i) { 250 281 try { … … 268 299 err.setText(whybad.format()); 269 300 } 270 301 271 302 protected Object get(final Widget[] editWidgets, 272 303 final PropertyConstraint constraint, final int i) -
trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/input/attributes/TextAreaAttribute.java
r809 r1483 4 4 import com.google.gwt.user.client.ui.HTML; 5 5 import com.google.gwt.user.client.ui.HasText; 6 import com.google.gwt.user.client.ui.Label; 6 7 import com.google.gwt.user.client.ui.TextArea; 7 8 import com.google.gwt.user.client.ui.Widget; … … 15 16 protected int visibleLength; 16 17 18 private String description; 19 public TextAreaAttribute(final StringConstraint sc, String description) 20 { 21 super(sc); 22 this.description = description; 23 } 24 17 25 public TextAreaAttribute(final StringConstraint sc) { 18 26 super(sc); … … 38 46 b.setVisibleLines(3); 39 47 applyStyle(b, true); 48 49 Label descriptionLabel = new Label(description); 50 51 DOM.setElementAttribute(descriptionLabel.getElement(), "label" , "label"); 52 40 53 return new Widget[] { 41 54 b … … 58 71 mSet(obj, v != null && ((String) v).length() > 0 ? v : null); 59 72 } 73 74 public String getDescription() { 75 return description; 76 } 77 78 public void setDescription(String description) { 79 this.description = description; 80 } 60 81 } -
trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/input/attributes/TextAttribute.java
r1473 r1483 23 23 protected boolean negative = false; 24 24 25 public TextAttribute(final String labelString) 26 { 27 super(labelString); 28 } 29 30 25 31 public TextAttribute(final StringConstraint sc) { 26 32 super(sc); -
trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/user/Confirmation.java
r850 r1483 1 1 package edu.rpi.metpetdb.client.ui.user; 2 2 3 import com.google.gwt.user.client.History; 3 4 import com.google.gwt.user.client.ui.Button; 4 5 import com.google.gwt.user.client.ui.ClickListener; … … 10 11 import edu.rpi.metpetdb.client.model.User; 11 12 import edu.rpi.metpetdb.client.ui.MpDb; 13 import edu.rpi.metpetdb.client.ui.TokenSpace; 12 14 import edu.rpi.metpetdb.client.ui.commands.ServerOp; 13 15 … … 24 26 confirm = new Button("Confirm", this); 25 27 add(instructions); 28 26 29 if (!MpDb.currentUser().getEnabled()) { 27 30 add(confirmationCode); 28 31 add(confirm); 32 29 33 } else { 30 34 instructions 31 35 .setText("Your account is already enabled - you cannot confirm it."); 32 36 } 37 38 33 39 } 34 40 … … 50 56 MpDb.setCurrentUser(result); 51 57 instructions.setText("Your account is now enabled"); 58 History.newItem(TokenSpace.editProfile.makeToken(null)); 59 52 60 } 53 61 }.begin(); 54 62 } 63 55 64 } 56 65 -
trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/user/EditUserProfile.java
r1366 r1483 1 1 package edu.rpi.metpetdb.client.ui.user; 2 2 3 import com.google.gwt.user.client.DOM; 4 import com.google.gwt.user.client.History; 3 5 import com.google.gwt.user.client.ui.Button; 6 import com.google.gwt.user.client.ui.CheckBox; 4 7 import com.google.gwt.user.client.ui.ClickListener; 5 8 import com.google.gwt.user.client.ui.FlowPanel; 9 import com.google.gwt.user.client.ui.Label; 10 import com.google.gwt.user.client.ui.TextArea; 6 11 import com.google.gwt.user.client.ui.Widget; 7 12 8 13 import edu.rpi.metpetdb.client.error.LoginRequiredException; 14 import edu.rpi.metpetdb.client.error.validation.InvalidProfileRequestException; 9 15 import edu.rpi.metpetdb.client.locale.LocaleHandler; 10 16 import edu.rpi.metpetdb.client.model.User; … … 18 24 import edu.rpi.metpetdb.client.ui.input.OnEnterPanel; 19 25 import edu.rpi.metpetdb.client.ui.input.Submit; 26 import edu.rpi.metpetdb.client.ui.input.attributes.CheckBoxAttribute; 20 27 import edu.rpi.metpetdb.client.ui.input.attributes.GenericAttribute; 21 28 import edu.rpi.metpetdb.client.ui.input.attributes.PasswordAttribute; 29 import edu.rpi.metpetdb.client.ui.input.attributes.TextAreaAttribute; 22 30 import edu.rpi.metpetdb.client.ui.input.attributes.TextAttribute; 23 import edu.rpi.metpetdb.client.ui.widgets.MLink;24 31 import edu.rpi.metpetdb.client.ui.widgets.MText; 25 32 import edu.rpi.metpetdb.client.ui.widgets.panels.MPagePanel; … … 28 35 private static User user; 29 36 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 30 43 public EditUserProfile(final User whoToEdit) { 31 44 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 32 63 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)) { 36 68 add(new PasswordChanger(user)); 37 69 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")); 38 80 } 39 81 } … … 44 86 throw new LoginRequiredException(); 45 87 } 46 47 private static void setUser(User u) {88 89 private static void setUser(User u) { 48 90 user = u; 49 91 } 50 51 static class InfoChanger extends FlowPanel implements ClickListener {92 93 static class InfoChanger extends FlowPanel implements ClickListener { 52 94 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 62 106 }; 63 107 private User u; 64 108 private final DetailsPanel<User> p_main; 65 109 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"); 67 112 private final Button changeInfo; 68 69 private void setUser(User u){ 113 114 115 private void setUser(User u) { 70 116 this.u = u; 71 117 } 72 118 73 119 InfoChanger(final User whoToEdit) { 74 120 u = whoToEdit; 75 changeInfo = new Submit(LocaleHandler.lc_text 76 .buttonUpdateInfo()); 121 changeInfo = new Submit(LocaleHandler.lc_text.buttonUpdateInfo()); 122 77 123 changeInfo.addClickListener(this); 78 p_main = new DetailsPanel<User>(userAttributes, 79 new Button[] {80 changeInfo124 125 p_main = new DetailsPanel<User>(userAttributes, new Button[] { 126 changeInfo 81 127 }); 82 128 83 129 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 84 143 infoContainer.add(infoHeader); 85 144 infoContainer.add(p_main); 86 145 87 146 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 } 90 157 } 91 158 }); 92 } 93 159 } 160 94 161 public void onClick(final Widget sender) { 95 162 if (sender == changeInfo) 163 { 164 try 165 { 96 166 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 { 100 179 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 103 207 } 104 208 public void onFailure(final Throwable e) { … … 110 214 u = result; 111 215 enable(true); 112 p_main.edit(u);216 // p_main.edit(u); 113 217 MetPetDBApplication.notice(LocaleHandler.lc_text 114 218 .notice_InfoChanged(u.getEmailAddress())); 219 220 // Go Home 221 History.newItem(TokenSpace.home.makeToken(null)); 115 222 } 116 223 }.begin(); … … 124 231 new PasswordAttribute(MpDb.doc.UserWithPassword_vrfPassword), 125 232 }; 126 233 127 234 private final UserWithPassword uwp; 128 235 129 236 private final DetailsPanel<UserWithPassword> p_password; 130 237 131 238 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"); 133 241 private final Button changePassword; 134 242 135 243 PasswordChanger(final User whoToEdit) { 136 244 uwp = new UserWithPassword(whoToEdit); … … 143 251 new Button[] { 144 252 changePassword 145 });253 }); 146 254 p_password.edit(uwp); 147 255 148 256 passwordContainer.add(passwordHeader); 149 257 passwordContainer.add(p_password); … … 151 259 add(new OnEnterPanel(passwordContainer) { 152 260 public void onEnter() { 153 261 154 262 doChangePassword(); 155 263 } 156 264 }); 157 265 158 266 } 159 267 -
trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/user/UserDetails.java
r850 r1483 20 20 new TextAttribute(MpDb.doc.User_postalCode), 21 21 new TextAttribute(MpDb.doc.User_institution), 22 new TextAttribute(MpDb.doc.User_ referenceEmail)22 new TextAttribute(MpDb.doc.User_professionalUrl) 23 23 }; 24 24 -
trunk/mpdb-client/src/edu/rpi/metpetdb/client/ui/user/UserRegistrationPanel.java
r883 r1483 1 1 package edu.rpi.metpetdb.client.ui.user; 2 2 3 import com.claudiushauptmann.gwt.recaptcha.client.RecaptchaWidget; 3 4 import com.google.gwt.user.client.History; 5 import com.google.gwt.user.client.Window; 4 6 import com.google.gwt.user.client.ui.Button; 5 7 import com.google.gwt.user.client.ui.ClickListener; 6 8 import com.google.gwt.user.client.ui.Widget; 7 9 10 import edu.rpi.metpetdb.client.error.validation.InvalidCaptchaException; 8 11 import edu.rpi.metpetdb.client.locale.LocaleHandler; 9 12 import edu.rpi.metpetdb.client.model.User; … … 14 17 import edu.rpi.metpetdb.client.ui.TokenSpace; 15 18 import edu.rpi.metpetdb.client.ui.commands.FormOp; 19 import edu.rpi.metpetdb.client.ui.input.CurrentMessage; 16 20 import edu.rpi.metpetdb.client.ui.input.DetailsPanel; 17 21 import edu.rpi.metpetdb.client.ui.input.FocusSupport; … … 20 24 import edu.rpi.metpetdb.client.ui.input.attributes.GenericAttribute; 21 25 import edu.rpi.metpetdb.client.ui.input.attributes.PasswordAttribute; 26 import edu.rpi.metpetdb.client.ui.input.attributes.TextAreaAttribute; 22 27 import edu.rpi.metpetdb.client.ui.input.attributes.TextAttribute; 23 28 import edu.rpi.metpetdb.client.ui.widgets.panels.MPagePanel; 24 29 25 public class UserRegistrationPanel extends MPagePanel implements ClickListener { 30 public 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 26 41 private static final GenericAttribute[] mainAttributes = { 27 42 new TextAttribute(MpDb.doc.User_name) { … … 59 74 return ((UserWithPassword) obj).getUser(); 60 75 } 61 }, new TextAttribute(MpDb.doc.User_referenceEmail) { 76 }, 77 78 contributorRequestAttribute 79 80 , new TextAttribute(MpDb.doc.User_professionalUrl) { 62 81 protected MObject resolve(final MObject obj) { 63 82 return ((UserWithPassword) obj).getUser(); 64 83 } 65 84 } 85 66 86 }; 67 87 … … 69 89 private final Button register; 70 90 private final DetailsPanel<UserWithPassword> p_main; 91 private final RecaptchaWidget rw; 71 92 72 93 public UserRegistrationPanel() { … … 77 98 register = new Submit(LocaleHandler.lc_text.buttonRegister(), this); 78 99 100 // TODO: Externalize Recaptcha key SCB 101 rw = new RecaptchaWidget("6LeCaL0SAAAAAD-dKyj9t3PTOqdW8j9svbfHn9P2"); 102 79 103 p_main = new DetailsPanel<UserWithPassword>(mainAttributes, 80 new Button[] {81 r egister104 new Widget[] { 105 rw, register 82 106 }); 107 83 108 p_main.edit(newbie); 84 109 85 110 add(new OnEnterPanel(p_main) { 86 111 public void onEnter() { 87 doRegister(); 112 113 try { 114 doRegister(); 115 } catch (InvalidCaptchaException bce) { 116 bce.printStackTrace(); 117 } 88 118 } 89 }); 119 }); 90 120 } 91 121 … … 93 123 super.onLoad(); 94 124 FocusSupport.requestFocus(p_main); 125 95 126 } 96 127 97 128 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 100 139 } 101 140 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 { 103 147 new FormOp<User>(p_main) { 148 104 149 protected void onSubmit() { 105 MpDb.user_svc.registerNewUser(newbie, this); 150 151 MpDb.user_svc.registerNewUser(newbie, rw.getChallenge(), rw 152 .getResponse(), this); 106 153 } 154 107 155 public void onSuccess(final User result) { 108 156 MpDb.setCurrentUser((User) result);
