Skip to content

Commit

Permalink
gwt: Display team for which the user is submitting.
Browse files Browse the repository at this point in the history
  • Loading branch information
calin-iorgulescu committed Mar 10, 2015
1 parent 372ba67 commit b7df5b6
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

public interface UploadConstants extends Constants {

String teamMsg();

String md5sumInvalid();
String md5sumIncomplete();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
teamMsg = You are submitting on behalf of team:

md5sumInvalid = Invalid md5 sum
md5sumIncomplete = Incomplete md5 sum (must be exactly 32 characters long)

Expand Down Expand Up @@ -61,4 +63,4 @@ md5SumDesc = Archive MD5 sum:
archiveTitle = Archive selection
archiveDesc = Choose the archive file:
fileListEmpty = No files were found on the storage server.
evaluationButton = Evaluate
evaluationButton = Evaluate
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
teamMsg = Rendez le projet pour le compte de l'équipe:
md5sumInvalid = Somme md5 invalide
md5sumIncomplete = Somme md5 incomplète (doit contenir exactement 32 caractères)
Expand Down Expand Up @@ -61,4 +63,4 @@ md5SumDesc = Somme md5 de l'archive:
archiveTitle = Selection de l'archive
archiveDesc = Choisissez l'archive:
fileListEmpty = Aucun fichier trouvé sur le serveur de stockage.
evaluationButton = Lancer l'évalation
evaluationButton = Lancer l'évalation
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
teamMsg = Veți trimite această soluție din partea echipei:

md5sumInvalid = Sumă md5 invalidă
md5sumIncomplete = Sumă md5 incompletă (trebuie să conțină fix 32 de caractere)

Expand Down Expand Up @@ -62,4 +64,4 @@ md5SumDesc = Suma MD5 a arhivei:
archiveTitle = Alegere arhivă
archiveDesc = Alegeți fișierul arhivă:
fileListEmpty = Nu a fost găsit nici un fișier pe serverul de stocare.
evaluationButton = Evaluează
evaluationButton = Evaluează
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ public enum StorageType {
public String storageBasepath;
public String deadline;
public String statementLink;
public boolean hasTeam;
public String team;

public Assignment(String id, String title, StorageType storageType,
String storageHost, String storageBasepath,
String deadline, String statementLink) {
String deadline, String statementLink,
boolean hasTeam, String team) {
this.id = id;
this.title = title;
this.storageType = storageType;
Expand All @@ -25,6 +28,8 @@ public Assignment(String id, String title, StorageType storageType,
this.storageType = storageType;
this.deadline = deadline;
this.statementLink = statementLink;
this.hasTeam = hasTeam;
this.team = team;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public interface UploadWidget {
HasClickHandlers getSubmitButton();
FormPanel getUploadForm();
void setUploadType(Assignment.StorageType type);
void setParameters(String courseId, String assignmentId);
void populateFileList(Assignment assignment, String[] files);
void updateWidget(String courseId, Assignment assignment);
void populateFileList(String[] files);
}

private EventBus eventBus;
Expand Down Expand Up @@ -226,7 +226,7 @@ public void onFailure(Throwable caught) {
public void onSuccess(FileList fileList) {
uploadWidget.setFileListEmptyLabelVisible(true);
if(fileList.Files != null) {
uploadWidget.populateFileList(assignment, fileList.Files);
uploadWidget.populateFileList(fileList.Files);
uploadWidget.setFileListEmptyLabelVisible(false);
} else
uploadWidget.setFileListEmptyLabelVisible(true);
Expand Down Expand Up @@ -285,7 +285,7 @@ public void clearEventHandlers() {
public void setParameters(String courseId, Assignment assignment) {
this.courseId = courseId;
this.assignment = assignment;
uploadWidget.setParameters(courseId, assignment.id);
uploadWidget.updateWidget(courseId, assignment);
}

public void displayView(com.google.gwt.user.client.ui.Widget widget) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public final class AssignmentsListDecoder extends JSONDecoder<Assignment[]> {
private static final String storageBasepathKey = "assignmentStorageBasepath";
private static final String deadlineKey = "deadline";
private static final String statementLinkKey = "statementLink";
private static final String teamKey = "team";

@Override
protected Assignment[] decode(String text) {
Expand All @@ -37,12 +38,17 @@ private Assignment parseAssignment(JSONObject jsonObj) {
Assignment.StorageType.valueOf(jsonObj.get(storageTypeKey).isString().stringValue().toUpperCase());
String deadline = jsonObj.get(deadlineKey).isString().stringValue();
String statementLink = jsonObj.get(statementLinkKey).isString().stringValue();
boolean hasTeam = jsonObj.keySet().contains(teamKey);
String team = null;
if (hasTeam) {
team = jsonObj.get(teamKey).isString().stringValue();
}
if (storageType == Assignment.StorageType.NORMAL) {
return new Assignment(id, title, storageType, null, null, deadline, statementLink);
return new Assignment(id, title, storageType, null, null, deadline, statementLink, hasTeam, team);
} else {
String storageHost = jsonObj.get(storageHostKey).isString().stringValue();
String storageBasepath = jsonObj.get(storageBasepathKey).isString().stringValue();
return new Assignment(id, title, storageType, storageHost, storageBasepath, deadline, statementLink);
return new Assignment(id, title, storageType, storageHost, storageBasepath, deadline, statementLink, hasTeam, team);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FileUpload;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Hidden;
Expand Down Expand Up @@ -49,6 +50,15 @@ public class UploadWidget extends Composite
interface UploadWidgetUiBinder extends UiBinder<Widget, UploadWidget> {
}

@UiField
HorizontalPanel teamContainer;

@UiField
Label teamMsg;

@UiField
Label teamName;

@UiField
HTML uploadHeader;

Expand Down Expand Up @@ -140,10 +150,14 @@ interface UploadWidgetUiBinder extends UiBinder<Widget, UploadWidget> {
Button uploadFileButton;


private Assignment assignment;


public UploadWidget() {
initWidget(uiBinder.createAndBindUi(this));

teamMsg.setText(constants.teamMsg());

md5Title.setText(constants.md5Title());
md5SumOldDesc.setText(constants.md5SumOldDesc());
md5SumTimeCommentLabel.setText(constants.md5SumTimeComment());
Expand Down Expand Up @@ -298,17 +312,27 @@ public void setUploadType(Assignment.StorageType type) {
}

@Override
public void setParameters(String courseId, String assignmentId) {
public void updateWidget(String courseId, Assignment assignment) {

this.assignment = assignment;

md5CourseIdField.setValue(courseId);
md5AssignmentIdField.setValue(assignmentId);
md5AssignmentIdField.setValue(assignment.id);
evalCourseIdField.setValue(courseId);
evalAssignmentIdField.setValue(assignmentId);
evalAssignmentIdField.setValue(assignment.id);
courseIdField.setValue(courseId);
assignmentIdField.setValue(assignmentId);
assignmentIdField.setValue(assignment.id);

if (assignment.hasTeam) {
teamName.setText(assignment.team);
teamContainer.setVisible(true);
} else {
teamContainer.setVisible(false);
}
}

@Override
public void populateFileList(Assignment assignment, String[] files) {
public void populateFileList(String[] files) {

/* Define the image strings */
String folderImage = AbstractImagePrototype.create(images.folder()).getHTML();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
padding: 10px;
border: 3px solid #EEEEEE;
margin-top: 20px;
margin-bottom: 20px;
}

.inputField {
Expand Down Expand Up @@ -45,14 +46,20 @@
cursor: pointer;
}

.bold {
font-weight: bold;
}

.errorComment {
color: #990000;
font-weight: bold;
}

.okComment {
color: #007F00;
font-weight: bold;
}

.teamName {
padding-left: 10px;
}

.help {
Expand All @@ -69,13 +76,17 @@
</ui:style>
<g:HTMLPanel styleName="{style.container}">
<g:HTML ui:field="uploadHeader"></g:HTML>
<g:HorizontalPanel ui:field="teamContainer" styleName="{style.formContainer}">
<g:Label ui:field="teamMsg"></g:Label>
<g:Label ui:field="teamName" styleName="{style.teamName} {style.bold}"></g:Label>
</g:HorizontalPanel>
<g:FormPanel ui:field="md5Form" styleName="{style.formContainer}">
<g:VerticalPanel>
<g:Label ui:field="md5Title" styleName="{style.formTitle}"></g:Label>
<g:HorizontalPanel>
<g:Label ui:field="md5SumOldDesc" styleName="{style.fieldComment} {style.help}"></g:Label>
<g:Label ui:field="md5SumEmptyLabel" styleName="{style.fieldComment} {style.errorComment}"></g:Label>
<g:Label ui:field="md5SumValueLabel" styleName="{style.fieldComment} {style.okComment}" visible="false"></g:Label>
<g:Label ui:field="md5SumEmptyLabel" styleName="{style.fieldComment} {style.errorComment} {style.bold}"></g:Label>
<g:Label ui:field="md5SumValueLabel" styleName="{style.fieldComment} {style.okComment} {style.bold}" visible="false"></g:Label>
</g:HorizontalPanel>
<g:HorizontalPanel>
<g:Label ui:field="md5SumTimeCommentLabel" styleName="{style.fieldComment} {style.help}" visible="false"></g:Label>
Expand All @@ -85,7 +96,7 @@
<g:Label ui:field="md5SumDesc" styleName="{style.fieldComment} {style.help}"></g:Label>
<g:TextBox ui:field="md5SumInputField" name="md5Sum" styleName="{style.inputField}"></g:TextBox>
</g:HorizontalPanel>
<g:Label ui:field="md5SumInputCommentLabel" styleName="{style.fieldComment} {style.errorComment}"></g:Label>
<g:Label ui:field="md5SumInputCommentLabel" styleName="{style.fieldComment} {style.errorComment} {style.bold}"></g:Label>
<g:Button ui:field="uploadMd5Button" enabled="true"></g:Button>
<g:Hidden ui:field="md5CourseIdField" name="courseId"></g:Hidden>
<g:Hidden ui:field="md5AssignmentIdField" name="assignmentId"></g:Hidden>
Expand All @@ -95,7 +106,7 @@
<g:VerticalPanel>
<g:Label ui:field="archiveTitle" styleName="{style.formTitle}"></g:Label>
<g:Label ui:field="archiveDesc" styleName="{style.fieldComment} {style.help}"></g:Label>
<g:Label ui:field="fileListEmptyLabel" styleName="{style.fieldComment} {style.errorComment}" visible="false"></g:Label>
<g:Label ui:field="fileListEmptyLabel" styleName="{style.fieldComment} {style.errorComment} {style.bold}" visible="false"></g:Label>
<g:ScrollPanel styleName="{style.scrollPanel}">
<g:Tree ui:field="fileListTree"></g:Tree>
</g:ScrollPanel>
Expand Down

0 comments on commit b7df5b6

Please sign in to comment.