[virtualcommons-svn] commit/foraging: alllee: replacing VotingForm with results with data injected
Status: Beta
Brought to you by:
alllee
From: Bitbucket <com...@bi...> - 2012-01-28 00:19:18
|
1 new commit in foraging: https://bitbucket.org/virtualcommons/foraging/changeset/1f6bea9050a9/ changeset: 1f6bea9050a9 user: alllee date: 2012-01-28 01:18:57 summary: replacing VotingForm with results with data injected into the nomination results template affected #: 6 files diff -r f851afbbd24854dfdedb3b5fdbe8ae1370874d60 -r 1f6bea9050a9581fbf93618fa9f2499e7535a8e1 src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java --- a/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java +++ b/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.TreeMap; import java.util.concurrent.TimeUnit; import org.stringtemplate.v4.ST; @@ -723,9 +724,11 @@ return getProperty("submitted-vote-instructions", "<h1>Submitted</h1><hr><p>Your nomination has been recorded. The final results of the nomination will be shown once all the nominations in your group have been received.</p>"); } - public String getVotingResults(List<ForagingRule> selectedRules) { + public String generateVotingResults(List<ForagingRule> selectedRules, Map<ForagingRule, Integer> nominations) { + TreeMap<ForagingRule, Integer> sortedNominations = new TreeMap<ForagingRule, Integer>(nominations); setSelectedRules(selectedRules); ST template = createStringTemplate(getVotingResultsTemplate()); + template.add("nominations", sortedNominations); template.add("tiebreaker", selectedRules.size() > 1); template.add("selectedRules", selectedRules); return template.render(); diff -r f851afbbd24854dfdedb3b5fdbe8ae1370874d60 -r 1f6bea9050a9581fbf93618fa9f2499e7535a8e1 src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java --- a/src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java +++ b/src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java @@ -1,6 +1,7 @@ package edu.asu.commons.foraging.conf; import java.text.NumberFormat; +import java.util.Locale; import org.stringtemplate.v4.ST; @@ -33,7 +34,7 @@ private static final String SAME_ROUND_AS_PREVIOUS_INSTRUCTIONS = "<h3>Round {self.roundNumber} Instructions</h3><hr><p>Round {self.roundNumber} is the same as the previous round.</p><p>The length of this round is {duration}.</p><p>If you have any questions please raise your hand. <b>Do you have any questions so far?</b></p>"; private static final String DEFAULT_LOG_FILE_DESTINATION = "foraging-server.log"; private static final double DEFAULT_DOLLARS_PER_TOKEN = .02d; - + public ServerConfiguration() { super(); } diff -r f851afbbd24854dfdedb3b5fdbe8ae1370874d60 -r 1f6bea9050a9581fbf93618fa9f2499e7535a8e1 src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java --- a/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java +++ b/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java @@ -59,8 +59,6 @@ private JLabel timeLeftLabel; - private JMenuItem copyToClipboardMenuItem; - private JMenuItem showInstructionsMenuItem; private JMenuItem startRoundMenuItem; @@ -216,7 +214,8 @@ }); menu.add(menuItem); - copyToClipboardMenuItem = createMenuItem(menu, "Copy to clipboard", new ActionListener() { + // create copy to clipboard menu item + createMenuItem(menu, "Copy to clipboard", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String text = informationEditorPane.getSelectedText(); diff -r f851afbbd24854dfdedb3b5fdbe8ae1370874d60 -r 1f6bea9050a9581fbf93618fa9f2499e7535a8e1 src/main/java/edu/asu/commons/foraging/server/ForagingServer.java --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java @@ -109,13 +109,11 @@ private Identifier facilitatorId; - // FIXME: use java.util.concurrent constructs instead? CountDownLatch / CyclicBarrier? + // FIXME: investigate using java.util.concurrent constructs instead, e.g., CountDownLatch / CyclicBarrier private final Object roundSignal = new Object(); private final Object quizSignal = new Object(); private final Object facilitatorSignal = new Object(); private final Object agentDesignSignal = new Object(); - // FIXME: these latches don't quite do what we want. We need a way to reset them at each round. - // private CountDownLatch postRoundSanctionLatch; private StateMachine stateMachine = new ForagingStateMachine(); diff -r f851afbbd24854dfdedb3b5fdbe8ae1370874d60 -r 1f6bea9050a9581fbf93618fa9f2499e7535a8e1 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 @@ -119,6 +119,7 @@ private JPanel votingPanel; private VotingForm votingForm; private HtmlEditorPane votingInstructionsEditorPane; + private JScrollPane votingInstructionsScrollPane; // private EnergyLevel energyLevel; @@ -742,9 +743,9 @@ votingPanel = new JPanel(); votingPanel.setLayout(new BoxLayout(votingPanel, BoxLayout.Y_AXIS)); votingInstructionsEditorPane = UserInterfaceUtils.createInstructionsEditorPane(); - JScrollPane scrollPane = new JScrollPane(votingInstructionsEditorPane); + votingInstructionsScrollPane = new JScrollPane(votingInstructionsEditorPane); votingInstructionsEditorPane.setText(client.getCurrentRoundConfiguration().getVotingInstructions()); - votingPanel.add(scrollPane); + votingPanel.add(votingInstructionsScrollPane); votingForm = new VotingForm(client); votingPanel.add(votingForm); votingPanel.setName(VotingForm.NAME); @@ -756,12 +757,11 @@ public void showVotingResults(final List<ForagingRule> selectedRules, final Map<ForagingRule, Integer> votingResults) { SwingUtilities.invokeLater(new Runnable() { public void run() { - VotingForm resultsForm = new VotingForm(client, votingResults); - votingPanel.remove(votingForm); - votingPanel.add(resultsForm); + votingPanel.removeAll(); + votingPanel.add(votingInstructionsScrollPane); votingPanel.revalidate(); RoundConfiguration currentRoundConfiguration = client.getCurrentRoundConfiguration(); - votingInstructionsEditorPane.setText(currentRoundConfiguration.getVotingResults(selectedRules)); + votingInstructionsEditorPane.setText(currentRoundConfiguration.generateVotingResults(selectedRules, votingResults)); showPanel(VotingForm.NAME); } }); diff -r f851afbbd24854dfdedb3b5fdbe8ae1370874d60 -r 1f6bea9050a9581fbf93618fa9f2499e7535a8e1 src/main/resources/configuration/iu/2011/vote-punish/server.xml --- a/src/main/resources/configuration/iu/2011/vote-punish/server.xml +++ b/src/main/resources/configuration/iu/2011/vote-punish/server.xml @@ -260,7 +260,14 @@ <entry key='voting-results'><![CDATA[ <h1>Nomination Results</h1> - <h2>Selected Strategy</h2> + <hr> + <table border=3 cellspacing=3 cellpadding=3> + <tr><th>Strategy</th><th>Nominations</th></tr> + {nominations.keys: { rule | + <tr bgcolor="#{if (rule.equals(first(selectedRules)))}FFFFCC{else}CCCCCC{endif}"><td>{rule}</td><td>{nominations.(rule)}</td></tr> + }} + </table> + <h1>Selected Strategy</h1><hr> {if (tiebreaker)} <p><b>NOTE:</b> There was a tie and the selected strategy listed here was randomly selected as the winner.</p> 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. |