Fixed broken tables selection in lobby

This commit is contained in:
Oleg Agafonov 2018-12-22 06:21:17 +04:00
parent 66aab73cfa
commit 253c580639
6 changed files with 539 additions and 478 deletions

View file

@ -0,0 +1,40 @@
package mage.client.table;
import org.apache.log4j.Logger;
import javax.swing.*;
/**
* @author JayDi85
*/
public class TablesUtil {
private static final Logger logger = Logger.getLogger(TablesUtil.class);
public static String getSearchIdFromTable(JTable table, int row) {
// tableUUID;gameUUID
String searchId = null;
if (table.getModel() instanceof TablesTableModel) {
searchId = ((TablesTableModel) table.getModel()).findTableAndGameInfoByRow(row);
} else if (table.getModel() instanceof MatchesTableModel) {
searchId = ((MatchesTableModel) table.getModel()).findTableAndGameInfoByRow(row);
} else {
logger.error("Not supported tables model " + table.getModel().getClass().toString());
}
return searchId;
}
public static int findTableRowFromSearchId(Object tableModel, String searchId) {
// tableUUID;gameUUID
int row = -1;
if (tableModel instanceof TablesTableModel) {
row = ((TablesTableModel) tableModel).findRowByTableAndGameInfo(searchId);
} else if (tableModel instanceof MatchesTableModel) {
row = ((MatchesTableModel) tableModel).findRowByTableAndGameInfo(searchId);
} else {
logger.error("Not supported tables model " + tableModel.getClass().toString());
}
return row;
}
}