foul-magics/Mage.Client/src/main/java/mage/client/table/TablesUtil.java
Oleg Agafonov fef37cdc73 admin tools improves (#5388):
* added game ids and created time to tables list;
* added popup hints support to tables list;
* fixed wrong sorting and columns resizing in tables list;
* refactored some modules to share table related code between client and admin console;
2024-03-22 16:56:29 +04:00

47 lines
1.8 KiB
Java

package mage.client.table;
import org.apache.log4j.Logger;
import javax.swing.*;
/**
* GUI related
*
* @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 if (table.getModel() instanceof TournamentMatchesTableModel) {
searchId = ((TournamentMatchesTableModel) 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 (searchId != null) {
if (tableModel instanceof TablesTableModel) {
row = ((TablesTableModel) tableModel).findRowByTableAndGameInfo(searchId);
} else if (tableModel instanceof MatchesTableModel) {
row = ((MatchesTableModel) tableModel).findRowByTableAndGameInfo(searchId);
} else if (tableModel instanceof TournamentMatchesTableModel) {
row = ((TournamentMatchesTableModel) tableModel).findRowByTableAndGameInfo(searchId);
} else {
logger.error("Not supported tables model " + tableModel.getClass().toString());
}
}
return row;
}
}