add session counter. resolves #17
This commit is contained in:
parent
55788f58b5
commit
8679a556ca
|
@ -1,5 +1,6 @@
|
||||||
package org.fenix.llanfair;
|
package org.fenix.llanfair;
|
||||||
|
|
||||||
|
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||||
import org.fenix.llanfair.config.Settings;
|
import org.fenix.llanfair.config.Settings;
|
||||||
import org.fenix.utils.TableModelSupport;
|
import org.fenix.utils.TableModelSupport;
|
||||||
import org.fenix.utils.config.Configuration;
|
import org.fenix.utils.config.Configuration;
|
||||||
|
@ -181,6 +182,9 @@ public class Run implements TableModel, Serializable {
|
||||||
|
|
||||||
private int numberOfCompletedAttempts;
|
private int numberOfCompletedAttempts;
|
||||||
|
|
||||||
|
@XStreamOmitField
|
||||||
|
private int sessionAttempts;
|
||||||
|
|
||||||
// ----------------------------------------------------------- CONSTRUCTORS
|
// ----------------------------------------------------------- CONSTRUCTORS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -575,6 +579,8 @@ public class Run implements TableModel, Serializable {
|
||||||
return numberOfCompletedAttempts;
|
return numberOfCompletedAttempts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSessionAttempts() { return sessionAttempts; }
|
||||||
|
|
||||||
// ---------------------------------------------------------------- SETTERS
|
// ---------------------------------------------------------------- SETTERS
|
||||||
|
|
||||||
public<T> T getSetting( String key ) {
|
public<T> T getSetting( String key ) {
|
||||||
|
@ -709,6 +715,7 @@ public class Run implements TableModel, Serializable {
|
||||||
segments.get(current).setStartTime(startTime);
|
segments.get(current).setStartTime(startTime);
|
||||||
|
|
||||||
numberOfAttempts += 1;
|
numberOfAttempts += 1;
|
||||||
|
sessionAttempts += 1;
|
||||||
|
|
||||||
pcSupport.firePropertyChange(ATTEMPT_COUNTER_PROPERTY, numberOfAttempts - 1, numberOfAttempts);
|
pcSupport.firePropertyChange(ATTEMPT_COUNTER_PROPERTY, numberOfAttempts - 1, numberOfAttempts);
|
||||||
pcSupport.firePropertyChange(STATE_PROPERTY, State.READY, state);
|
pcSupport.firePropertyChange(STATE_PROPERTY, State.READY, state);
|
||||||
|
@ -1120,6 +1127,7 @@ public class Run implements TableModel, Serializable {
|
||||||
state = getRowCount() > 0 ? State.READY : State.NULL;
|
state = getRowCount() > 0 ? State.READY : State.NULL;
|
||||||
current = -1;
|
current = -1;
|
||||||
startTime = 0L;
|
startTime = 0L;
|
||||||
|
sessionAttempts = 0;
|
||||||
|
|
||||||
if (subTitle == null) {
|
if (subTitle == null) {
|
||||||
subTitle = "";
|
subTitle = "";
|
||||||
|
|
|
@ -97,6 +97,11 @@ public class RunPane extends JPanel {
|
||||||
*/
|
*/
|
||||||
private JLabel attemptCounter;
|
private JLabel attemptCounter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Label displaying the number of attempts the user has made of this run in this session only.
|
||||||
|
*/
|
||||||
|
private JLabel sessionAttemptCounter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list containing empty labels serving as separators.
|
* A list containing empty labels serving as separators.
|
||||||
*/
|
*/
|
||||||
|
@ -140,6 +145,7 @@ public class RunPane extends JPanel {
|
||||||
title = new JLabel();
|
title = new JLabel();
|
||||||
subTitle = new JLabel();
|
subTitle = new JLabel();
|
||||||
attemptCounter = new JLabel();
|
attemptCounter = new JLabel();
|
||||||
|
sessionAttemptCounter = new JLabel();
|
||||||
core = new Core(run);
|
core = new Core(run);
|
||||||
graph = new Graph(run);
|
graph = new Graph(run);
|
||||||
history = new History(run);
|
history = new History(run);
|
||||||
|
@ -288,13 +294,14 @@ public class RunPane extends JPanel {
|
||||||
* Places the sub-components within this component.
|
* Places the sub-components within this component.
|
||||||
*/
|
*/
|
||||||
private void placeComponents() {
|
private void placeComponents() {
|
||||||
add(title, GBC.grid(0, 0).insets(3, 0, 1, 0).fill(GBC.BOTH));
|
add(title, GBC.grid(0, 0, 2, 1).insets(3, 0, 1, 0).fill(GBC.BOTH));
|
||||||
add(subTitle, GBC.grid(0, 1).insets(3, 0, 0, 0).fill(GBC.BOTH));
|
add(subTitle, GBC.grid(0, 1, 2, 1).insets(3, 0, 0, 0).fill(GBC.BOTH));
|
||||||
add(attemptCounter, GBC.grid(0, 2).insets(1, 0, 1, 3).anchor(GBC.LINE_END));
|
add(sessionAttemptCounter, GBC.grid(0, 2, 1, 1).insets(1, 3, 1, 0).anchor(GBC.LINE_START));
|
||||||
add(createSeparator(), GBC.grid(0, 3).insets(3, 0).fill(GBC.HORIZONTAL));
|
add(attemptCounter, GBC.grid(1, 2, 1, 1).insets(1, 0, 1, 3).anchor(GBC.LINE_END));
|
||||||
add(history, GBC.grid(0, 4).fill(GBC.HORIZONTAL).anchor(GBC.NORTH).insets(0, 5));
|
add(createSeparator(), GBC.grid(0, 3, 2, 1).insets(3, 0).fill(GBC.HORIZONTAL));
|
||||||
add(createSeparator(), GBC.grid(0, 5).insets(3, 0).fill(GBC.HORIZONTAL));
|
add(history, GBC.grid(0, 4, 2, 1).fill(GBC.HORIZONTAL).anchor(GBC.NORTH).insets(0, 5));
|
||||||
add(createSeparator(), GBC.grid(0, 7).insets(3, 0, 0, 0).fill(GBC.HORIZONTAL));
|
add(createSeparator(), GBC.grid(0, 5, 2, 1).insets(3, 0).fill(GBC.HORIZONTAL));
|
||||||
|
add(createSeparator(), GBC.grid(0, 7, 2, 1).insets(3, 0, 0, 0).fill(GBC.HORIZONTAL));
|
||||||
|
|
||||||
updateVisibility(ALL);
|
updateVisibility(ALL);
|
||||||
}
|
}
|
||||||
|
@ -319,6 +326,9 @@ public class RunPane extends JPanel {
|
||||||
attemptCounter.setText(String.format("%d", attempts));
|
attemptCounter.setText(String.format("%d", attempts));
|
||||||
else
|
else
|
||||||
attemptCounter.setText(String.format("%d / %d", completedAttempts, attempts));
|
attemptCounter.setText(String.format("%d / %d", completedAttempts, attempts));
|
||||||
|
|
||||||
|
int sessionAttempts = run.getSessionAttempts();
|
||||||
|
sessionAttemptCounter.setText(String.format("%d", sessionAttempts));
|
||||||
}
|
}
|
||||||
if ((identifier & SEPARATOR) == SEPARATOR) {
|
if ((identifier & SEPARATOR) == SEPARATOR) {
|
||||||
boolean hdTitle = Settings.headerShowSubtitle.get();
|
boolean hdTitle = Settings.headerShowSubtitle.get();
|
||||||
|
@ -354,6 +364,7 @@ public class RunPane extends JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
attemptCounter.setForeground(Color.WHITE);
|
attemptCounter.setForeground(Color.WHITE);
|
||||||
|
sessionAttemptCounter.setForeground(Color.WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -369,6 +380,7 @@ public class RunPane extends JPanel {
|
||||||
}
|
}
|
||||||
if ((identifier & ATTEMPTS) == ATTEMPTS) {
|
if ((identifier & ATTEMPTS) == ATTEMPTS) {
|
||||||
attemptCounter.setFont(Settings.coreFont.get());
|
attemptCounter.setFont(Settings.coreFont.get());
|
||||||
|
sessionAttemptCounter.setFont(Settings.coreFont.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,19 +394,19 @@ public class RunPane extends JPanel {
|
||||||
if ((identifier & GRAPH) == GRAPH) {
|
if ((identifier & GRAPH) == GRAPH) {
|
||||||
if (Settings.graphDisplay.get()) {
|
if (Settings.graphDisplay.get()) {
|
||||||
remove(core);
|
remove(core);
|
||||||
add(core, GBC.grid(0, 6).insets(0, 5).fill(GBC.HORIZONTAL));
|
add(core, GBC.grid(0, 6, 2, 1).insets(0, 5).fill(GBC.HORIZONTAL));
|
||||||
add(graph, GBC.grid(0, 8).fill(GBC.BOTH).insets(0, 0, 3, 0)
|
add(graph, GBC.grid(0, 8, 2, 1).fill(GBC.BOTH).insets(0, 0, 3, 0)
|
||||||
.weight(1.0, 1.0));
|
.weight(1.0, 1.0));
|
||||||
} else {
|
} else {
|
||||||
remove(graph);
|
remove(graph);
|
||||||
remove(core);
|
remove(core);
|
||||||
add(core, GBC.grid(0, 6).insets(0, 5).fill(GBC.HORIZONTAL)
|
add(core, GBC.grid(0, 6, 2, 1).insets(0, 5).fill(GBC.HORIZONTAL)
|
||||||
.weight(1.0, 1.0));
|
.weight(1.0, 1.0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((identifier & FOOTER) == FOOTER) {
|
if ((identifier & FOOTER) == FOOTER) {
|
||||||
if (Settings.footerDisplay.get()) {
|
if (Settings.footerDisplay.get()) {
|
||||||
add(footer, GBC.grid(0, 9).insets(0, 3).fill(GBC.HORIZONTAL));
|
add(footer, GBC.grid(0, 9, 2, 1).insets(0, 3).fill(GBC.HORIZONTAL));
|
||||||
} else {
|
} else {
|
||||||
remove(footer);
|
remove(footer);
|
||||||
}
|
}
|
||||||
|
@ -402,9 +414,9 @@ public class RunPane extends JPanel {
|
||||||
if ((identifier & SUBTITLE) == SUBTITLE) {
|
if ((identifier & SUBTITLE) == SUBTITLE) {
|
||||||
if (Settings.headerShowSubtitle.get()) {
|
if (Settings.headerShowSubtitle.get()) {
|
||||||
if (Settings.headerShowTitle.get()) {
|
if (Settings.headerShowTitle.get()) {
|
||||||
add(subTitle, GBC.grid(0, 1));
|
add(subTitle, GBC.grid(0, 1, 2, 1));
|
||||||
} else {
|
} else {
|
||||||
add(subTitle, GBC.grid(0, 1).insets(3, 0, 0, 0));
|
add(subTitle, GBC.grid(0, 1, 2, 1).insets(3, 0, 0, 0));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
remove(subTitle);
|
remove(subTitle);
|
||||||
|
@ -415,6 +427,7 @@ public class RunPane extends JPanel {
|
||||||
}
|
}
|
||||||
if ((identifier & ATTEMPTS) == ATTEMPTS) {
|
if ((identifier & ATTEMPTS) == ATTEMPTS) {
|
||||||
attemptCounter.setVisible(Settings.headerShowAttempts.get());
|
attemptCounter.setVisible(Settings.headerShowAttempts.get());
|
||||||
|
sessionAttemptCounter.setVisible(Settings.headerShowAttempts.get());
|
||||||
}
|
}
|
||||||
revalidate();
|
revalidate();
|
||||||
repaint();
|
repaint();
|
||||||
|
|
Reference in a new issue