108 lines
3.6 KiB
Groovy
108 lines
3.6 KiB
Groovy
|
import groovy.swing.SwingBuilder
|
||
|
import java.awt.GridBagConstraints as GBC
|
||
|
import javax.swing.ListCellRenderer
|
||
|
|
||
|
public class TeamMaker {
|
||
|
|
||
|
/* ======== MODEL ======== */
|
||
|
|
||
|
public static def swing = new SwingBuilder()
|
||
|
public static final String version = "0.2"
|
||
|
|
||
|
def frame
|
||
|
def team1List
|
||
|
def team2List
|
||
|
def sittingList
|
||
|
|
||
|
class Player {
|
||
|
String name
|
||
|
int gamesSat
|
||
|
}
|
||
|
|
||
|
/* ======== VIEW ======== */
|
||
|
|
||
|
/*
|
||
|
+--------------------------------------------------+
|
||
|
| JDB TeamMaker v0.2 _[]X |
|
||
|
+--------------------------------------------------+
|
||
|
| |
|
||
|
| +-Current-Game--------------+ +-Sitting-Players+ |
|
||
|
| | | | | |
|
||
|
| | Team 1 Team 2 | | Jeptha 3 | |
|
||
|
| | Derrick Eric | | Jack 2 | |
|
||
|
| | Shane Brandon | | Sam 2 | |
|
||
|
| | Shane Darren | | Greg 2 | |
|
||
|
| | Christian Brett | | Frank 1 | |
|
||
|
| +---------------------------+ | Chris D 1 | |
|
||
|
| | Joshua 1 | |
|
||
|
| | | |
|
||
|
| | | |
|
||
|
| | | |
|
||
|
| | | |
|
||
|
| | | |
|
||
|
| +----------------+ |
|
||
|
+--------------------------------------------------+
|
||
|
|
||
|
*/
|
||
|
|
||
|
private void init() {
|
||
|
frame = swing.frame(title: "JDB TeamMaker v$version",
|
||
|
size: [600, 400], locationRelativeTo: null) {
|
||
|
|
||
|
panel() {
|
||
|
gridBagLayout()
|
||
|
|
||
|
panel(constraints: gbc(gridx: 0, gridy: 0,
|
||
|
insets: [5, 5, 5, 5]),
|
||
|
border: titleBorder(title: 'Current Game')) {
|
||
|
|
||
|
gridBagLayout()
|
||
|
|
||
|
label('Team A', constraints: gbc(gridx: 0, gridy: 0,
|
||
|
fill: GBC.BOTH, insets: [5, 5, 0, 0]))
|
||
|
|
||
|
label('Team B', constraints: gbc(gridx: 1, gridy: 0,
|
||
|
fill: GBC.BOTH, insets: [5, 5, 0, 5]))
|
||
|
|
||
|
def teamListRenderer = new PlayerRenderer(showStats: false
|
||
|
colored: false)
|
||
|
|
||
|
team1List = list(cellRenderer: teamListRenderer,
|
||
|
constraints: gbc(gridx: 0, gridy: 0, fill: GBC.BOTH,
|
||
|
insets: [5, 5, 5, 0], weightx: 2, weighty: 2))
|
||
|
|
||
|
team2List = list(cellRenderer: teamListRenderer,
|
||
|
constraints: gbc(gridx: 1, gridy: 1, fill: GBC.BOTH,
|
||
|
insets: [5, 5, 5, 5], weightx: 2, weighty: 2))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
sittingList = list(
|
||
|
cellRenderer: new PlayerRenderer(
|
||
|
showStats: true, colored: true),
|
||
|
constraints: gbc(gridx: 1, gridy: 0, gridheight: 2) {
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
class PlayerRenderer implements ListCellRenderer extends JLabel {
|
||
|
|
||
|
boolean showStats
|
||
|
boolean colored
|
||
|
|
||
|
PlayerRenderer
|
||
|
}
|
||
|
|
||
|
/* ======== CONTROLLER ======== */
|
||
|
|
||
|
public static void main(String[] args) {
|
||
|
def inst = new TeamMaker()
|
||
|
inst.frame.show()
|
||
|
}
|
||
|
|
||
|
TeamMaker() {
|
||
|
|
||
|
}
|
||
|
}
|