[virtualcommons-svn] commit/foraging: alllee: stubs for survey and voting instructions in place.
Status: Beta
Brought to you by:
alllee
From: Bitbucket <com...@bi...> - 2011-09-30 11:28:06
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/b34467980dc6/ changeset: b34467980dc6 user: alllee date: 2011-09-30 13:27:57 summary: stubs for survey and voting instructions in place. affected #: 3 files (-1 bytes) --- a/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Fri Sep 30 04:12:39 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java Fri Sep 30 04:27:57 2011 -0700 @@ -32,7 +32,10 @@ import edu.asu.commons.foraging.event.ResetTokenDistributionRequest; import edu.asu.commons.foraging.event.RoundStartedEvent; import edu.asu.commons.foraging.event.ShowInstructionsRequest; +import edu.asu.commons.foraging.event.ShowSurveyInstructionsRequest; import edu.asu.commons.foraging.event.ShowTrustGameRequest; +import edu.asu.commons.foraging.event.ShowVoteScreenRequest; +import edu.asu.commons.foraging.event.ShowVotingInstructionsRequest; import edu.asu.commons.foraging.event.SurveyIdSubmissionRequest; import edu.asu.commons.foraging.event.SynchronizeClientEvent; import edu.asu.commons.foraging.event.TrustGameSubmissionRequest; @@ -95,6 +98,7 @@ @Override protected void postConnect() { + // FIXME: this is hacky.. using the client side socket as the "authoritative" id. SocketIdentifier socketId = (SocketIdentifier) getId(); transmit(new SocketIdentifierUpdateRequest(socketId, socketId.getStationNumber())); state = ClientState.WAITING; @@ -156,6 +160,21 @@ getGameWindow().showTrustGame(); } }); + addEventProcessor(new EventTypeProcessor<ShowVotingInstructionsRequest>(ShowVotingInstructionsRequest.class) { + public void handle(ShowVotingInstructionsRequest request) { + getGameWindow2D().showVotingInstructions(); + } + }); + addEventProcessor(new EventTypeProcessor<ShowVoteScreenRequest>(ShowVoteScreenRequest.class) { + public void handle(ShowVoteScreenRequest request) { + getGameWindow2D().showVoteScreen(); + } + }); + addEventProcessor(new EventTypeProcessor<ShowSurveyInstructionsRequest>(ShowSurveyInstructionsRequest.class) { + public void handle(ShowSurveyInstructionsRequest request) { + getGameWindow2D().showSurveyInstructions(); + } + }); addEventProcessor(new EventTypeProcessor<RoundStartedEvent>(RoundStartedEvent.class) { public void handle(RoundStartedEvent event) { System.err.println("client starting round: " + dataModel.is2dExperiment()); @@ -404,6 +423,7 @@ } public void sendSurveyId(String surveyId) { + getId().setSurveyId(surveyId); transmit(new SurveyIdSubmissionRequest(getId(), surveyId)); getGameWindow2D().surveyIdSubmitted(); } --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Fri Sep 30 04:12:39 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Fri Sep 30 04:27:57 2011 -0700 @@ -539,13 +539,13 @@ addEventProcessor(new EventTypeProcessor<ShowRequest>(ShowRequest.class, true) { public void handle(ShowRequest request) { if (request.getId().equals(facilitatorId)) { - logger.info("handling request " + request + " from facilitator"); for (Identifier id: clients.keySet()) { transmit(request.copy(id)); } + sendFacilitatorMessage("Received " + request + " from facilitator, copied & broadcastto all clients."); } else { - sendFacilitatorMessage("Ignoring show request from id: " + request.getId()); + sendFacilitatorMessage("Ignoring show request from non facilitator id: " + request.getId()); } } }); @@ -610,7 +610,6 @@ ClientData clientData = clients.get(request.getId()); clientData.getId().setSurveyId(request.getSurveyId()); sendFacilitatorMessage(String.format("Storing survey id %s for client %s", request.getSurveyId(), clientData)); - } }); addEventProcessor(new EventTypeProcessor<TrustGameSubmissionRequest>(TrustGameSubmissionRequest.class) { --- a/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Fri Sep 30 04:12:39 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java Fri Sep 30 04:27:57 2011 -0700 @@ -712,25 +712,35 @@ public void showTrustGame() { RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); if (roundConfiguration.isTrustGameEnabled()) { - JPanel panel = new JPanel(); - panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); - JEditorPane trustGameInstructionsEditorPane = ForagingInterface.createInstructionsEditorPane(); - JScrollPane scrollPane = new JScrollPane(trustGameInstructionsEditorPane); - trustGameInstructionsEditorPane.setText(client.getCurrentRoundConfiguration().getTrustGameInstructions()); - panel.add(scrollPane); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); + JEditorPane trustGameInstructionsEditorPane = ForagingInterface.createInstructionsEditorPane(); + JScrollPane scrollPane = new JScrollPane(trustGameInstructionsEditorPane); + trustGameInstructionsEditorPane.setText(client.getCurrentRoundConfiguration().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); + 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); + } + }); } } + + public void trustGameSubmitted() { + instructionsBuilder.append("<h1>Submission successful</h1><hr><p>Please wait while the rest of the submissions are gathered.</p>"); + setInstructions(instructionsBuilder.toString()); + switchInstructionsPane(); + } public void showInstructions() { final RoundConfiguration roundConfiguration = dataModel.getRoundConfiguration(); @@ -750,13 +760,31 @@ }); } - public void trustGameSubmitted() { - instructionsBuilder.append("<h1>Submission successful</h1><hr><p>Please wait while the rest of the submissions are gathered.</p>"); - setInstructions(instructionsBuilder.toString()); - switchInstructionsPane(); - + + public void showVotingInstructions() { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + setInstructions(dataModel.getRoundConfiguration().getVotingInstructions()); + switchInstructionsPane(); + } + }); } + public void showVoteScreen() { + // implement vote screen + + } + + public void showSurveyInstructions() { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + setInstructions(dataModel.getRoundConfiguration().getSurveyInstructions(dataModel.getId())); + switchInstructionsPane(); + } + }); + } + + public void switchInstructionsPane() { showPanel(INSTRUCTIONS_PANEL_NAME); } @@ -852,4 +880,5 @@ setInstructions(dataModel.getRoundConfiguration().getWelcomeInstructions()); switchInstructionsPane(); } + } 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. |