| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | |
|
| 101 | |
|
| 102 | |
|
| 103 | |
|
| 104 | |
|
| 105 | |
|
| 106 | |
|
| 107 | |
|
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | |
|
| 114 | |
|
| 115 | |
|
| 116 | |
|
| 117 | |
package com.buckosoft.fibs.BuckoFIBS.gui.playerList; |
| 118 | |
|
| 119 | |
import java.awt.ComponentOrientation; |
| 120 | |
import java.awt.Dimension; |
| 121 | |
import java.awt.GridBagConstraints; |
| 122 | |
import java.awt.GridBagLayout; |
| 123 | |
import java.awt.Insets; |
| 124 | |
import java.awt.Point; |
| 125 | |
import java.awt.event.ActionEvent; |
| 126 | |
import java.awt.event.ActionListener; |
| 127 | |
import java.awt.event.KeyEvent; |
| 128 | |
import java.awt.event.MouseAdapter; |
| 129 | |
import java.awt.event.MouseEvent; |
| 130 | |
|
| 131 | |
import javax.swing.ImageIcon; |
| 132 | |
import javax.swing.JLabel; |
| 133 | |
import javax.swing.JPanel; |
| 134 | |
import javax.swing.JScrollPane; |
| 135 | |
import javax.swing.JTable; |
| 136 | |
import javax.swing.JTextField; |
| 137 | |
import javax.swing.JToggleButton; |
| 138 | |
import javax.swing.JToolBar; |
| 139 | |
import javax.swing.ListSelectionModel; |
| 140 | |
import javax.swing.RowFilter; |
| 141 | |
import javax.swing.table.TableRowSorter; |
| 142 | |
|
| 143 | |
import com.buckosoft.fibs.BuckoFIBS.CommandDispatcher; |
| 144 | |
import com.buckosoft.fibs.BuckoFIBS.GroupManager; |
| 145 | |
import com.buckosoft.fibs.BuckoFIBS.gui.MainDialog; |
| 146 | |
import com.buckosoft.fibs.BuckoFIBS.gui.playerList.group.GroupSelectPane; |
| 147 | |
import com.buckosoft.fibs.domain.Player; |
| 148 | |
import java.awt.Font; |
| 149 | |
|
| 150 | |
|
| 151 | |
|
| 152 | |
|
| 153 | |
|
| 154 | |
|
| 155 | |
|
| 156 | 0 | public class PlayerListPane extends JPanel implements ActionListener { |
| 157 | |
private final static boolean DEBUG = false; |
| 158 | |
private static final long serialVersionUID = 1L; |
| 159 | 0 | private JToolBar jToolBar = null; |
| 160 | 0 | private JScrollPane playerListScrollPane = null; |
| 161 | 0 | private JToggleButton readyToggleButton = null; |
| 162 | 0 | private JToggleButton onlineToggleButton = null; |
| 163 | 0 | private JToggleButton playingToggleButton = null; |
| 164 | |
|
| 165 | 0 | private JTable playerListTable = null; |
| 166 | |
private PlayerTableModel playerTableModel; |
| 167 | |
|
| 168 | 0 | private PlayerListPopupMenu playerListPopupMenu = null; |
| 169 | 0 | private CommandDispatcher commandDispatcher = null; |
| 170 | |
private GroupManager groupManager; |
| 171 | |
private GroupSelectPane groupPane; |
| 172 | |
private MainDialog mainDialog; |
| 173 | |
|
| 174 | |
|
| 175 | 0 | private JLabel jLabelLoggedIn = null; |
| 176 | |
|
| 177 | |
|
| 178 | 0 | private boolean[] rop = new boolean[] {false, false, false}; |
| 179 | |
|
| 180 | 0 | private boolean updateLocked = false; |
| 181 | |
|
| 182 | |
|
| 183 | |
|
| 184 | |
|
| 185 | |
public PlayerListPane() { |
| 186 | 0 | super(); |
| 187 | 0 | initialize(); |
| 188 | 0 | } |
| 189 | |
|
| 190 | |
public PlayerTableModel getPlayerTableModel() { |
| 191 | 0 | return(playerTableModel); |
| 192 | |
} |
| 193 | |
|
| 194 | |
public void setCommandDispatcher(CommandDispatcher commandDispatcher) { |
| 195 | 0 | this.commandDispatcher = commandDispatcher; |
| 196 | 0 | } |
| 197 | |
|
| 198 | |
public void setGroupManager(GroupManager groupManager) { |
| 199 | 0 | this.groupManager = groupManager; |
| 200 | 0 | playerListPopupMenu.setGroupManager(groupManager); |
| 201 | 0 | this.groupManager.setPlayerListPane(this); |
| 202 | 0 | groupPaneChanged(); |
| 203 | 0 | } |
| 204 | |
|
| 205 | |
public void setMainDialog(MainDialog mainDialog) { |
| 206 | 0 | this.mainDialog = mainDialog; |
| 207 | 0 | } |
| 208 | |
|
| 209 | |
|
| 210 | |
|
| 211 | |
|
| 212 | |
|
| 213 | |
public Player getPlayer(String playerName) { |
| 214 | 0 | return(this.playerTableModel.getPlayer(playerName)); |
| 215 | |
} |
| 216 | |
|
| 217 | |
public void playerChanged(Player player) { |
| 218 | 0 | this.playerTableModel.playerChanged(player); |
| 219 | 0 | if (!this.updateLocked) { |
| 220 | 0 | updatePlayerCount(); |
| 221 | 0 | playerListTable.setRowSorter(sorter); |
| 222 | 0 | sorter.setRowFilter(rowFilter); |
| 223 | |
} |
| 224 | 0 | } |
| 225 | |
|
| 226 | |
public void playerGone(String playerName) { |
| 227 | 0 | this.playerTableModel.playerGone(playerName); |
| 228 | 0 | if (!this.updateLocked) { |
| 229 | 0 | updatePlayerCount(); |
| 230 | 0 | playerListTable.setRowSorter(sorter); |
| 231 | 0 | sorter.setRowFilter(rowFilter); |
| 232 | |
} |
| 233 | 0 | } |
| 234 | |
|
| 235 | |
|
| 236 | |
|
| 237 | |
|
| 238 | |
|
| 239 | |
public void playerInvited(String playerName) { |
| 240 | 0 | if (playerName == null) |
| 241 | 0 | playerUninvited(); |
| 242 | |
else { |
| 243 | 0 | this.playerTableModel.playerInvited(playerName); |
| 244 | 0 | if (!this.updateLocked) { |
| 245 | 0 | updatePlayerCount(); |
| 246 | 0 | playerListTable.setRowSorter(sorter); |
| 247 | 0 | sorter.setRowFilter(rowFilter); |
| 248 | |
} |
| 249 | |
} |
| 250 | 0 | } |
| 251 | |
|
| 252 | |
private void playerUninvited() { |
| 253 | 0 | if (this.playerTableModel.playerUninvited()) { |
| 254 | 0 | if (!this.updateLocked) { |
| 255 | 0 | updatePlayerCount(); |
| 256 | 0 | playerListTable.setRowSorter(sorter); |
| 257 | 0 | sorter.setRowFilter(rowFilter); |
| 258 | |
} |
| 259 | |
} |
| 260 | 0 | } |
| 261 | |
|
| 262 | |
|
| 263 | |
|
| 264 | |
public void setROP(boolean[] rop) { |
| 265 | 0 | this.readyToggleButton.setSelected(rop[0]); |
| 266 | 0 | this.onlineToggleButton.setSelected(rop[1]); |
| 267 | 0 | this.playingToggleButton.setSelected(rop[2]); |
| 268 | 0 | this.rop = rop; |
| 269 | 0 | playerListTable.setRowSorter(sorter); |
| 270 | 0 | sorter.setRowFilter(rowFilter); |
| 271 | 0 | sorter.sort(); |
| 272 | 0 | } |
| 273 | |
|
| 274 | |
|
| 275 | |
|
| 276 | |
|
| 277 | |
|
| 278 | |
|
| 279 | |
private void initialize() { |
| 280 | 0 | getPlayerListPopupMenu(); |
| 281 | 0 | GridBagConstraints gridBagConstraints5 = new GridBagConstraints(); |
| 282 | 0 | gridBagConstraints5.gridx = 1; |
| 283 | 0 | gridBagConstraints5.weightx = 0.1; |
| 284 | 0 | gridBagConstraints5.gridy = 0; |
| 285 | 0 | GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); |
| 286 | 0 | gridBagConstraints11.gridx = 2; |
| 287 | 0 | gridBagConstraints11.insets = new Insets(0, 0, 0, 13); |
| 288 | 0 | gridBagConstraints11.weightx = 0.2; |
| 289 | 0 | gridBagConstraints11.gridy = 0; |
| 290 | 0 | GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
| 291 | 0 | gridBagConstraints1.fill = GridBagConstraints.BOTH; |
| 292 | 0 | gridBagConstraints1.gridy = 1; |
| 293 | 0 | gridBagConstraints1.weightx = 1.0; |
| 294 | 0 | gridBagConstraints1.weighty = 1.0; |
| 295 | 0 | gridBagConstraints1.gridwidth = 3; |
| 296 | 0 | gridBagConstraints1.gridx = 0; |
| 297 | 0 | GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
| 298 | 0 | gridBagConstraints.fill = GridBagConstraints.BOTH; |
| 299 | 0 | gridBagConstraints.gridy = 0; |
| 300 | 0 | gridBagConstraints.weightx = 1.0; |
| 301 | 0 | gridBagConstraints.anchor = GridBagConstraints.WEST; |
| 302 | 0 | gridBagConstraints.gridx = 0; |
| 303 | 0 | this.setSize(300, 200); |
| 304 | 0 | this.setLayout(new GridBagLayout()); |
| 305 | 0 | this.add(getJToolBar(), gridBagConstraints); |
| 306 | 0 | jLabelLoggedIn = new JLabel(); |
| 307 | 0 | jLabelLoggedIn.setText("On:"); |
| 308 | 0 | this.add(getPlayerListScrollPane(), gridBagConstraints1); |
| 309 | 0 | this.add(getJPanelDummyAfterGroup(), gridBagConstraints5); |
| 310 | 0 | this.add(jLabelLoggedIn, gridBagConstraints11); |
| 311 | 0 | } |
| 312 | |
|
| 313 | |
|
| 314 | |
|
| 315 | |
|
| 316 | |
|
| 317 | |
public void actionPerformed(ActionEvent e) { |
| 318 | 0 | if (e.getActionCommand().equals(PlayerListPopupMenu.s_setVisible)) { |
| 319 | 0 | this.updateLocked = e.getModifiers() == 0 ? false : true; |
| 320 | 0 | if (!this.updateLocked) { |
| 321 | 0 | updatePlayerCount(); |
| 322 | 0 | playerListTable.setRowSorter(sorter); |
| 323 | 0 | sorter.setRowFilter(rowFilter); |
| 324 | |
} else { |
| 325 | |
|
| 326 | |
} |
| 327 | 0 | return; |
| 328 | |
} |
| 329 | 0 | Player player = playerListPopupMenu.getPlayer(); |
| 330 | |
if (DEBUG) |
| 331 | |
System.out.println("playerListTable.getSelectedRow() = " + playerListTable.getSelectedRow()); |
| 332 | |
|
| 333 | 0 | String playerName = player.getName(); |
| 334 | |
if (DEBUG) |
| 335 | |
System.out.println("Action performed: " + e.getActionCommand() + " on " + playerName); |
| 336 | 0 | if (e.getActionCommand().startsWith("inv-")) { |
| 337 | 0 | String s = e.getActionCommand().substring(4); |
| 338 | 0 | this.commandDispatcher.dispatch(CommandDispatcher.Command.INVITE, playerName, s); |
| 339 | 0 | } else if (e.getActionCommand() == "Watch") { |
| 340 | 0 | this.commandDispatcher.dispatch(CommandDispatcher.Command.WATCH, playerName); |
| 341 | 0 | } else if (e.getActionCommand().startsWith("rep")) { |
| 342 | 0 | String s = "tell repbot " + e.getActionCommand().substring(3) + " " + playerName; |
| 343 | 0 | this.commandDispatcher.dispatch(CommandDispatcher.Command.SEND_COMMAND, s); |
| 344 | |
|
| 345 | 0 | } else { |
| 346 | 0 | System.out.println("Unhandled Action: " + e.getActionCommand() + " on " + playerName); |
| 347 | |
} |
| 348 | |
|
| 349 | 0 | } |
| 350 | |
|
| 351 | |
private void onMousePressed(MouseEvent e) { |
| 352 | 0 | if (e.getButton() != MouseEvent.BUTTON1) |
| 353 | 0 | return; |
| 354 | 0 | if (e.getClickCount() != 2) |
| 355 | 0 | return; |
| 356 | 0 | Player p = (Player)playerListTable.getModel().getValueAt(playerListTable.convertRowIndexToModel(playerListTable.getSelectedRow()), 0); |
| 357 | 0 | if (p == null) |
| 358 | 0 | return; |
| 359 | 0 | String playerName = p.getName(); |
| 360 | |
if (DEBUG) |
| 361 | |
System.out.println("dblclick performed: on " + playerName); |
| 362 | 0 | this.commandDispatcher.dispatch(CommandDispatcher.Command.GET_PLAYER_REPORT, playerName); |
| 363 | 0 | } |
| 364 | |
|
| 365 | |
|
| 366 | |
|
| 367 | |
|
| 368 | |
|
| 369 | |
|
| 370 | |
private JToolBar getJToolBar() { |
| 371 | 0 | if (jToolBar == null) { |
| 372 | 0 | jToolBar = new JToolBar(); |
| 373 | 0 | jToolBar.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); |
| 374 | 0 | jToolBar.setFloatable(false); |
| 375 | 0 | jToolBar.add(getReadyToggleButton()); |
| 376 | 0 | jToolBar.add(getOnlineToggleButton()); |
| 377 | 0 | jToolBar.add(getPlayingToggleButton()); |
| 378 | 0 | jToolBar.add(new JToolBar.Separator()); |
| 379 | 0 | jToolBar.add(getJTextFieldGroup()); |
| 380 | |
} |
| 381 | 0 | return jToolBar; |
| 382 | |
} |
| 383 | |
|
| 384 | |
|
| 385 | |
|
| 386 | |
|
| 387 | |
|
| 388 | |
|
| 389 | |
private JScrollPane getPlayerListScrollPane() { |
| 390 | 0 | if (playerListScrollPane == null) { |
| 391 | 0 | playerListScrollPane = new JScrollPane(); |
| 392 | 0 | playerListScrollPane.setViewportView(getPlayerListTable()); |
| 393 | |
} |
| 394 | 0 | return playerListScrollPane; |
| 395 | |
} |
| 396 | |
|
| 397 | |
private TableRowSorter<PlayerTableModel> sorter; |
| 398 | 0 | RowFilter<PlayerTableModel,Integer> rowFilter = new RowFilter<PlayerTableModel,Integer>() { |
| 399 | |
public boolean include(Entry<? extends PlayerTableModel, ? extends Integer> entry) { |
| 400 | 0 | PlayerTableModel playerModel = entry.getModel(); |
| 401 | 0 | Player player = (Player)playerModel.getValueAt(entry.getIdentifier(), 0); |
| 402 | 0 | if (!groupManager.filter(player)) |
| 403 | 0 | return(false); |
| 404 | 0 | if (player.isPlaying()) |
| 405 | 0 | return(rop[2]); |
| 406 | 0 | if (player.isReady()) |
| 407 | 0 | return(rop[0]); |
| 408 | 0 | return(rop[1]); |
| 409 | |
} |
| 410 | |
}; |
| 411 | 0 | private JTextField jTextFieldGroup = null; |
| 412 | 0 | private JPanel jPanelDummyAfterGroup = null; |
| 413 | |
|
| 414 | |
|
| 415 | |
|
| 416 | |
|
| 417 | |
private JTable getPlayerListTable() { |
| 418 | 0 | if (playerListTable == null) { |
| 419 | 0 | playerTableModel = new PlayerTableModel(); |
| 420 | 0 | sorter = new TableRowSorter<PlayerTableModel>(playerTableModel); |
| 421 | 0 | playerListTable = new JTable(playerTableModel); |
| 422 | 0 | playerListTable.addMouseListener(new java.awt.event.MouseAdapter() { |
| 423 | |
public void mousePressed(java.awt.event.MouseEvent e) { |
| 424 | 0 | onMousePressed(e); |
| 425 | 0 | } |
| 426 | |
}); |
| 427 | 0 | playerListTable.setRowSorter(sorter); |
| 428 | 0 | sorter.setRowFilter(rowFilter); |
| 429 | 0 | playerListTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
| 430 | 0 | for (int i=0; i<playerTableModel.getColumnCount(); i++) { |
| 431 | 0 | int w = playerTableModel.getColumnWidth(i); |
| 432 | 0 | playerListTable.getColumnModel().getColumn(i).setPreferredWidth(w); |
| 433 | |
} |
| 434 | 0 | playerListTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
| 435 | 0 | playerListTable.setAutoCreateRowSorter(true); |
| 436 | |
|
| 437 | 0 | PlayerNameRenderer playerRenderer = new PlayerNameRenderer(); |
| 438 | 0 | playerListTable.setDefaultRenderer(com.buckosoft.fibs.domain.Player.class, playerRenderer); |
| 439 | 0 | playerRenderer.setBackground(playerListTable.getBackground()); |
| 440 | 0 | playerRenderer.setSelectedBackground(playerListTable.getSelectionBackground()); |
| 441 | |
|
| 442 | |
|
| 443 | 0 | PopupListener popupListener = new PopupListener(); |
| 444 | 0 | popupListener.setPlayerListPane(this); |
| 445 | 0 | playerListTable.addMouseListener(popupListener); |
| 446 | |
} |
| 447 | 0 | return playerListTable; |
| 448 | |
} |
| 449 | |
|
| 450 | |
|
| 451 | |
|
| 452 | |
|
| 453 | |
|
| 454 | |
private JToggleButton getReadyToggleButton() { |
| 455 | 0 | if (readyToggleButton == null) { |
| 456 | 0 | readyToggleButton = new JToggleButton(); |
| 457 | 0 | readyToggleButton.setIcon(new ImageIcon(getClass().getResource("/g/pready.gif"))); |
| 458 | 0 | readyToggleButton.setSelected(true); |
| 459 | 0 | readyToggleButton.setMnemonic(KeyEvent.VK_UNDEFINED); |
| 460 | 0 | readyToggleButton.addItemListener(new java.awt.event.ItemListener() { |
| 461 | |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
| 462 | 0 | changeROP(); |
| 463 | 0 | } |
| 464 | |
}); |
| 465 | |
} |
| 466 | 0 | return readyToggleButton; |
| 467 | |
} |
| 468 | |
|
| 469 | |
|
| 470 | |
|
| 471 | |
|
| 472 | |
|
| 473 | |
|
| 474 | |
private JToggleButton getOnlineToggleButton() { |
| 475 | 0 | if (onlineToggleButton == null) { |
| 476 | 0 | onlineToggleButton = new JToggleButton(); |
| 477 | 0 | onlineToggleButton.setIcon(new ImageIcon(getClass().getResource("/g/ponline.gif"))); |
| 478 | 0 | onlineToggleButton.setSelected(true); |
| 479 | 0 | onlineToggleButton.addItemListener(new java.awt.event.ItemListener() { |
| 480 | |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
| 481 | 0 | changeROP(); |
| 482 | 0 | } |
| 483 | |
}); |
| 484 | |
} |
| 485 | 0 | return onlineToggleButton; |
| 486 | |
} |
| 487 | |
|
| 488 | |
|
| 489 | |
|
| 490 | |
|
| 491 | |
|
| 492 | |
|
| 493 | |
private JToggleButton getPlayingToggleButton() { |
| 494 | 0 | if (playingToggleButton == null) { |
| 495 | 0 | playingToggleButton = new JToggleButton(); |
| 496 | 0 | playingToggleButton.setIcon(new ImageIcon(getClass().getResource("/g/pplaying.gif"))); |
| 497 | 0 | playingToggleButton.setSelected(true); |
| 498 | 0 | playingToggleButton.addItemListener(new java.awt.event.ItemListener() { |
| 499 | |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
| 500 | 0 | changeROP(); |
| 501 | 0 | } |
| 502 | |
}); |
| 503 | |
} |
| 504 | 0 | return playingToggleButton; |
| 505 | |
} |
| 506 | |
|
| 507 | |
private void changeROP() { |
| 508 | 0 | boolean[] rop = new boolean[3]; |
| 509 | 0 | rop[0] = this.readyToggleButton.getModel().isSelected(); |
| 510 | 0 | rop[1] = this.onlineToggleButton.getModel().isSelected(); |
| 511 | 0 | rop[2] = this.playingToggleButton.getModel().isSelected(); |
| 512 | 0 | this.commandDispatcher.ropChanged(rop); |
| 513 | 0 | } |
| 514 | |
|
| 515 | |
private PlayerListPopupMenu getPlayerListPopupMenu() { |
| 516 | 0 | if (playerListPopupMenu == null) { |
| 517 | 0 | playerListPopupMenu = new PlayerListPopupMenu(); |
| 518 | 0 | playerListPopupMenu.setMenuHandler(this); |
| 519 | |
} |
| 520 | 0 | return(playerListPopupMenu); |
| 521 | |
} |
| 522 | |
|
| 523 | |
private void updatePlayerCount() { |
| 524 | 0 | String s = "On: " + this.playerTableModel.getRowCount(); |
| 525 | 0 | this.jLabelLoggedIn.setText(s); |
| 526 | 0 | } |
| 527 | |
|
| 528 | 0 | class PopupListener extends MouseAdapter { |
| 529 | |
PlayerListPane plp; |
| 530 | |
|
| 531 | |
void setPlayerListPane(PlayerListPane plp) { |
| 532 | 0 | this.plp = plp; |
| 533 | 0 | } |
| 534 | |
public void mousePressed(MouseEvent e) { |
| 535 | 0 | maybeShowPopup(e); |
| 536 | 0 | } |
| 537 | |
|
| 538 | |
public void mouseReleased(MouseEvent e) { |
| 539 | 0 | maybeShowPopup(e); |
| 540 | 0 | } |
| 541 | |
|
| 542 | |
private void maybeShowPopup(MouseEvent e) { |
| 543 | 0 | if (e.isPopupTrigger()) { |
| 544 | 0 | int row = playerListTable.rowAtPoint(new Point(e.getX(), e.getY())); |
| 545 | 0 | if (row != -1) |
| 546 | 0 | playerListTable.getSelectionModel().setSelectionInterval(row, row); |
| 547 | |
|
| 548 | |
|
| 549 | 0 | Player p = (Player)this.plp.playerTableModel.getValueAt(playerListTable.convertRowIndexToModel(playerListTable.getSelectedRow()), 0); |
| 550 | 0 | playerListPopupMenu.setPlayer(p); |
| 551 | 0 | playerListPopupMenu.rebuildGroups(); |
| 552 | 0 | playerListPopupMenu.getInvitePopupSubmenu().getJMenuItemResume().setVisible( |
| 553 | 0 | p.getSavedMatch() != null); |
| 554 | 0 | playerListPopupMenu.getInvitePopupSubmenu().setEnabled(p.isReady()); |
| 555 | 0 | playerListPopupMenu.show(e.getComponent(), |
| 556 | 0 | e.getX(), e.getY()); |
| 557 | |
} |
| 558 | 0 | } |
| 559 | |
} |
| 560 | |
|
| 561 | |
|
| 562 | |
|
| 563 | |
|
| 564 | |
|
| 565 | |
|
| 566 | |
private JTextField getJTextFieldGroup() { |
| 567 | 0 | if (jTextFieldGroup == null) { |
| 568 | 0 | jTextFieldGroup = new JTextField(); |
| 569 | 0 | jTextFieldGroup.setPreferredSize(new Dimension(140, 20)); |
| 570 | 0 | jTextFieldGroup.setEnabled(true); |
| 571 | 0 | jTextFieldGroup.setFont(new Font("Dialog", Font.PLAIN, 14)); |
| 572 | 0 | jTextFieldGroup.setEditable(false); |
| 573 | 0 | jTextFieldGroup.addMouseListener(new java.awt.event.MouseAdapter() { |
| 574 | |
public void mouseClicked(java.awt.event.MouseEvent e) { |
| 575 | 0 | handleGroupPane(); |
| 576 | 0 | } |
| 577 | |
}); |
| 578 | |
} |
| 579 | 0 | return jTextFieldGroup; |
| 580 | |
} |
| 581 | |
|
| 582 | |
|
| 583 | |
|
| 584 | |
|
| 585 | |
|
| 586 | |
|
| 587 | |
private JPanel getJPanelDummyAfterGroup() { |
| 588 | 0 | if (jPanelDummyAfterGroup == null) { |
| 589 | 0 | jPanelDummyAfterGroup = new JPanel(); |
| 590 | 0 | jPanelDummyAfterGroup.setLayout(new GridBagLayout()); |
| 591 | 0 | jPanelDummyAfterGroup.setPreferredSize(new Dimension(20, 20)); |
| 592 | |
} |
| 593 | 0 | return jPanelDummyAfterGroup; |
| 594 | |
} |
| 595 | |
|
| 596 | |
private void handleGroupPane() { |
| 597 | 0 | if (groupPane == null) { |
| 598 | 0 | groupPane = createGroupPane(); |
| 599 | 0 | GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
| 600 | 0 | gridBagConstraints.gridheight = 2; |
| 601 | 0 | gridBagConstraints.anchor = GridBagConstraints.NORTH; |
| 602 | 0 | this.add(groupPane, gridBagConstraints); |
| 603 | 0 | groupPane.setVisible(true); |
| 604 | 0 | this.revalidate(); |
| 605 | 0 | } else { |
| 606 | 0 | groupPane.setVisible(false); |
| 607 | 0 | groupPane.savePaneToList(); |
| 608 | 0 | groupPane = null; |
| 609 | 0 | this.groupManager.save(); |
| 610 | |
} |
| 611 | 0 | } |
| 612 | |
|
| 613 | |
|
| 614 | |
public void groupPaneChanged() { |
| 615 | 0 | playerListTable.setRowSorter(sorter); |
| 616 | 0 | sorter.setRowFilter(rowFilter); |
| 617 | 0 | sorter.sort(); |
| 618 | 0 | getJTextFieldGroup().setText(this.groupManager.getGroupsSelectedString()); |
| 619 | 0 | } |
| 620 | |
|
| 621 | |
private GroupSelectPane createGroupPane() { |
| 622 | 0 | GroupSelectPane gsp = new GroupSelectPane(); |
| 623 | 0 | gsp.setGroupManager(this.groupManager); |
| 624 | 0 | gsp.setMainDialog(this.mainDialog); |
| 625 | 0 | gsp.populatePane(); |
| 626 | 0 | return(gsp); |
| 627 | |
} |
| 628 | |
} |