Added multi-select support for the lists.

This commit is contained in:
Jonathan Bernard 2010-08-25 09:31:36 -05:00
parent 06864ccb36
commit 1dc9bb2a4a
3 changed files with 25 additions and 13 deletions

View File

@ -1,4 +1,4 @@
log4j.rootLogger=INFO,stdout log4j.rootLogger=TRACE,stdout
log4j.com.jdbernard.teammaker=TRACE,file log4j.com.jdbernard.teammaker=TRACE,file
log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout=org.apache.log4j.ConsoleAppender

View File

@ -1,7 +1,7 @@
#Wed, 25 Aug 2010 08:14:14 -0500 #Wed, 25 Aug 2010 09:05:51 -0500
#Mon Jul 05 23:10:39 CDT 2010 #Mon Jul 05 23:10:39 CDT 2010
app.version=0.4.0 app.version=0.4.0
build.number=0 build.number=2
src.dir=src src.dir=src
lib.dir=lib lib.dir=lib
build.dir=build build.dir=build

View File

@ -40,7 +40,7 @@ public class TeamMaker {
@Bindable List sittingPlayers = [] @Bindable List sittingPlayers = []
@Bindable boolean inGame = false @Bindable boolean inGame = false
@Bindable int teamSize = 4 @Bindable int teamSize = 4
@Bindable Player popupPlayer = null @Bindable List popupPlayers = null
@Bindable int popupTeam; @Bindable int popupTeam;
} }
@ -77,19 +77,22 @@ public class TeamMaker {
inGamePlayerDropMenu = swing.popupMenu(/*'Player Options'*/) { inGamePlayerDropMenu = swing.popupMenu(/*'Player Options'*/) {
menuItem('Bench Player',/* enabled: bind { !model.inGame },*/ menuItem('Bench Player',/* enabled: bind { !model.inGame },*/
actionPerformed: { benchPlayer(model.popupPlayer, actionPerformed: { benchPlayer(model.popupPlayers,
model.popupTeam) }) model.popupTeam) })
} }
sittingPlayerDropMenu = swing.popupMenu(/*'Player Options'*/) { sittingPlayerDropMenu = swing.popupMenu(/*'Player Options'*/) {
menuItem('Assign to Team A', /*enabled: bind { !model.inGame },*/ menuItem('Assign to Team A', /*enabled: bind { !model.inGame },*/
actionPerformed: { assignPlayer(model.popupPlayer, 1) }) actionPerformed: {
model.popupPlayers.each { assignPlayer(it, 1) }})
menuItem('Assign to Team B', /*enabled: bind { !model.inGame },*/ menuItem('Assign to Team B', /*enabled: bind { !model.inGame },*/
actionPerformed: { assignPlayer(model.popupPlayer, 2) }) actionPerformed: {
model.popupPlayers.each { assignPlayer(it, 2) }})
menuItem('Set Games Sat', menuItem('Set Games Sat',
actionPerformed: { setGamesSat(model.popupPlayer) }) actionPerformed: {
model.popupPlayers.each { setGamesSat(it) }})
} }
frame = swing.frame(title: "JDB TeamMaker v$version", frame = swing.frame(title: "JDB TeamMaker v$version",
@ -172,7 +175,7 @@ public class TeamMaker {
constraints: gbc(gridx: 2, gridy: 1, anchor: GBC.CENTER, constraints: gbc(gridx: 2, gridy: 1, anchor: GBC.CENTER,
insets: [5, 5, 5, 5]), insets: [5, 5, 5, 5]),
actionPerformed: { actionPerformed: {
model.sittingPlayers.remove(sittingList.selectedValue) model.sittingPlayers.remove(sittingList.selectedValues)
refreshGUI() }) refreshGUI() })
} }
@ -301,8 +304,12 @@ public class TeamMaker {
private void showSittingPlayerDropMenu(def evt) { private void showSittingPlayerDropMenu(def evt) {
int index = sittingList.locationToIndex(evt.point) int index = sittingList.locationToIndex(evt.point)
sittingList.selectedIndex = index if (sittingList.isSelectedIndex(index))
this.model.popupPlayer = sittingList.model.getElementAt(index) this.model.popupPlayers = sittingList.selectedValues
else {
sittingList.selectedIndex = index
this.model.popupPlayers = [sittingList.model.getElementAt(index)]
}
sittingPlayerDropMenu.show(sittingList, evt.point.@x, evt.point.@y) sittingPlayerDropMenu.show(sittingList, evt.point.@x, evt.point.@y)
} }
@ -310,8 +317,13 @@ public class TeamMaker {
private void showInGamePlayerDropMenu(def evt) { private void showInGamePlayerDropMenu(def evt) {
def teamList = evt.source def teamList = evt.source
int index = teamList.locationToIndex(evt.point) int index = teamList.locationToIndex(evt.point)
teamList.selectedIndex = index if (teamList.isSelectedIndex(index))
this.model.popupPlayer = teamList.model.getElementAt(index) this.model.popupPlayers = teamList.selectedValues
else {
teamList.selectedIndex = index
model.popupPlayers = [teamList.model.getElementAt(index)]
}
this.model.popupTeam = (teamList == team1List ? 1 : 2) this.model.popupTeam = (teamList == team1List ? 1 : 2)
inGamePlayerDropMenu.show(teamList, evt.point.@x, evt.point.@y) inGamePlayerDropMenu.show(teamList, evt.point.@x, evt.point.@y)