[virtualcommons-svn] commit/foraging: 2 new changesets
Status: Beta
Brought to you by:
alllee
From: Bitbucket <com...@bi...> - 2012-01-20 07:00:03
|
2 new commits in foraging: https://bitbucket.org/virtualcommons/foraging/changeset/6e92fdb8f8d1/ changeset: 6e92fdb8f8d1 user: alllee date: 2012-01-20 07:59:16 summary: adding continue button to survey instructions + ActionListener that simply jumps to the regular round instructions and a SurveyCompletedEvent that the client will use to signal to the server + facilitator that the survey has been "completed". Still need to wire up the server / facilitator handling of SurveyCompletedEvent. affected #: 2 files diff -r 6702907cf392ccab3c5914b489a1c086f1c4bb9d -r 6e92fdb8f8d1cb836a19c972c70f964fe86277ff src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java --- a/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java +++ b/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java @@ -53,6 +53,7 @@ import edu.asu.commons.foraging.event.QuizResponseEvent; import edu.asu.commons.foraging.event.RealTimeSanctionRequest; import edu.asu.commons.foraging.event.ResetTokenDistributionRequest; +import edu.asu.commons.foraging.event.SurveyCompletedEvent; import edu.asu.commons.foraging.event.TrustGameResultsClientEvent; import edu.asu.commons.foraging.model.ClientData; import edu.asu.commons.foraging.model.Direction; @@ -65,34 +66,25 @@ /** * $Id$ * - * The client-side view for forager - can be used by standalone Java - * applications or Applets. + * Primary client-side view for foraging experiment that can be used by standalone Java applications or Applets. * * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Revision$ */ public class GameWindow2D implements GameWindow { - - private final ClientDataModel dataModel; - - // instructions panel private final static String INSTRUCTIONS_PANEL_NAME = "instructions screen panel"; - // game board panel private final static String GAME_PANEL_NAME = "foraging game panel"; private final static String TRUST_GAME_PANEL_NAME = "trust game panel"; - // standalone chat panel private final static String CHAT_PANEL_NAME = "standalone chat panel"; - // survey id panel + private final static String POST_ROUND_SANCTIONING_PANEL_NAME = "post round sanctioning panel"; private final static String SURVEY_ID_PANEL_NAME = "survey id panel"; - - protected static final String POST_ROUND_SANCTIONING_PANEL_NAME = null; - private String currentCardPanel = INSTRUCTIONS_PANEL_NAME; - - // private Component currentCenterComponent; + + private final StringBuilder instructionsBuilder = new StringBuilder(); + private final ClientDataModel dataModel; + private EventChannel channel; private JPanel mainPanel; - // instructions components. private JScrollPane instructionsScrollPane; private HtmlEditorPane instructionsEditorPane; @@ -105,9 +97,6 @@ private JPanel surveyIdPanel; - // FIXME: this shouldn't be public - public static Duration duration; - private ChatPanel chatPanel; private JLabel informationLabel; @@ -120,15 +109,16 @@ private SubjectView subjectView; - public Timer timer; - - private final StringBuilder instructionsBuilder = new StringBuilder(); - - private EventChannel channel; - private CardLayout cardLayout; private ChatPanel inRoundChatPanel; + + private Timer timer; + + // voting components + private JPanel votingPanel; + private VotingForm votingForm; + private HtmlEditorPane votingInstructionsEditorPane; // private EnergyLevel energyLevel; @@ -198,6 +188,17 @@ styleSheet.addRule(styleString); } } + + private ActionListener createSurveyFinishedListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + client.transmit(new SurveyCompletedEvent(client.getId())); + showInstructions(); + instructionsEditorPane.setActionListener(null); + } + }; + } private ActionListener createQuizListener(final RoundConfiguration configuration) { return new ActionListener() { @@ -670,7 +671,7 @@ } public void showTrustGame() { - RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); + final RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); if (roundConfiguration.isTrustGameEnabled()) { SwingUtilities.invokeLater(new Runnable() { public void run() { @@ -678,17 +679,12 @@ panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); JEditorPane trustGameInstructionsEditorPane = UserInterfaceUtils.createInstructionsEditorPane(); JScrollPane scrollPane = new JScrollPane(trustGameInstructionsEditorPane); - trustGameInstructionsEditorPane.setText(client.getCurrentRoundConfiguration().getTrustGameInstructions()); + trustGameInstructionsEditorPane.setText(roundConfiguration.getTrustGameInstructions()); panel.add(scrollPane); - TrustGamePanel trustGamePanel = new TrustGamePanel(client); - // trustGamePanel.setPreferredSize(new Dimension(300, 400)); JScrollPane trustGameScrollPane = new JScrollPane(trustGamePanel); panel.add(trustGameScrollPane); panel.setName(TRUST_GAME_PANEL_NAME); - // addCenterComponent(panel); - // panel.revalidate(); - // panel.repaint(); add(panel); showPanel(TRUST_GAME_PANEL_NAME); } @@ -697,7 +693,8 @@ } public void trustGameSubmitted() { - instructionsBuilder.append("<h1>Submission successful</h1><hr><p>Please wait while the rest of the submissions are gathered.</p>"); + // FIXME: replace HTML strings with configuration template + instructionsBuilder.append("<h3>Submission successful</h3><hr><p>Please wait while the rest of the submissions are gathered.</p>"); setInstructions(instructionsBuilder.toString()); switchInstructionsPane(); } @@ -730,11 +727,6 @@ }); } - private JPanel votingPanel; - - private VotingForm votingForm; - - private HtmlEditorPane votingInstructionsEditorPane; private JPanel getVotingPanel() { if (votingPanel == null) { @@ -775,13 +767,15 @@ public void showSurveyInstructions() { SwingUtilities.invokeLater(new Runnable() { public void run() { + instructionsEditorPane.setActionListener(null); + instructionsEditorPane.setActionListener(createSurveyFinishedListener()); setInstructions(dataModel.getRoundConfiguration().getSurveyInstructions(dataModel.getId())); + switchInstructionsPane(); } }); } - public void switchInstructionsPane() { showPanel(INSTRUCTIONS_PANEL_NAME); } diff -r 6702907cf392ccab3c5914b489a1c086f1c4bb9d -r 6e92fdb8f8d1cb836a19c972c70f964fe86277ff src/main/resources/configuration/iu/2011/vote-punish/round4.xml --- a/src/main/resources/configuration/iu/2011/vote-punish/round4.xml +++ b/src/main/resources/configuration/iu/2011/vote-punish/round4.xml @@ -156,6 +156,10 @@ <p> If you encounter any problems with the survey <b>please inform the experimenter</b>. </p> + <br> + <form> + <input type="submit" value="Continue" name="continue"> + </form> ]]></entry><entry key='survey-url'> https://bitbucket.org/virtualcommons/foraging/changeset/a21112c697c5/ changeset: a21112c697c5 user: alllee date: 2012-01-20 07:59:43 summary: adding continue button to survey instructions + ActionListener that simply jumps to the regular round instructions and a SurveyCompletedEvent that the client will use to signal to the server + facilitator that the survey has been "completed". Still need to wire up the server / facilitator handling of SurveyCompletedEvent. affected #: 1 file diff -r 6e92fdb8f8d1cb836a19c972c70f964fe86277ff -r a21112c697c5ebc09975aab27491bb6498471dac src/main/java/edu/asu/commons/foraging/event/SurveyCompletedEvent.java --- /dev/null +++ b/src/main/java/edu/asu/commons/foraging/event/SurveyCompletedEvent.java @@ -0,0 +1,29 @@ +package edu.asu.commons.foraging.event; + +import edu.asu.commons.event.AbstractPersistableEvent; +import edu.asu.commons.event.ClientRequest; +import edu.asu.commons.net.Identifier; + +/** + * $Id: QuizResponseEvent.java 522 2010-06-30 19:17:48Z alllee $ + * + * Signals that a client has completed the survey for the given round. + * + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Rev: 522 $ + */ +public class SurveyCompletedEvent extends AbstractPersistableEvent implements ClientRequest { + + private static final long serialVersionUID = -7081410122722056083L; + + public SurveyCompletedEvent(Identifier id) { + super(id); + } + + @Override + public String toString() { + return String.format("Survey completed by %s", id); + } + +} Repository URL: https://bitbucket.org/virtualcommons/foraging/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |