diff --git a/src/main/java/core/db/DBManager.java b/src/main/java/core/db/DBManager.java
index 8182deb6d..635dcd69e 100644
--- a/src/main/java/core/db/DBManager.java
+++ b/src/main/java/core/db/DBManager.java
@@ -606,14 +606,13 @@ public void deleteSpielplanTabelle(int saison, int ligaId) {
}
/**
- * lädt alle Spielpläne aus der DB
+ * Loads all the games schedules from the database.
*
- * @param withFixtures inklusive der Paarungen ja/nein
- * @return the spielplan [ ]
+ * @param withFixtures includes fixtures if set to true
+ * @return List – List of all the {@link Spielplan}s.
*/
public List getAllSpielplaene(boolean withFixtures) {
- var ret = ((SpielplanTable) getTable(SpielplanTable.TABLENAME))
- .getAllSpielplaene();
+ var ret = ((SpielplanTable) getTable(SpielplanTable.TABLENAME)).getAllSpielplaene();
if (withFixtures) {
for (Spielplan gameSchedule : ret) {
gameSchedule.addFixtures(loadFixtures(gameSchedule));
diff --git a/src/main/java/core/file/xml/ConvertXml2Hrf.java b/src/main/java/core/file/xml/ConvertXml2Hrf.java
index 91be7bf70..0509ec9a0 100644
--- a/src/main/java/core/file/xml/ConvertXml2Hrf.java
+++ b/src/main/java/core/file/xml/ConvertXml2Hrf.java
@@ -52,7 +52,7 @@ private ConvertXml2Hrf() {
int teamId = HOVerwaltung.instance().getModel().getBasics().getTeamId();
Integer youthTeamId = HOVerwaltung.instance().getModel().getBasics().getYouthTeamId();
- String teamDetails = mc.getTeamdetails(-1);
+ String teamDetails = mc.getTeamDetails(-1);
if (teamDetails == null) {
return null;
diff --git a/src/main/java/core/file/xml/XMLManager.java b/src/main/java/core/file/xml/XMLManager.java
index e836764cc..4109c0ae2 100644
--- a/src/main/java/core/file/xml/XMLManager.java
+++ b/src/main/java/core/file/xml/XMLManager.java
@@ -112,12 +112,40 @@ public static boolean xmlBoolValue(Element ele, String xmlKey, boolean def) {
}
}
+ /**
+ * Get the content of the tag xmlKey under the XML element,
+ * and inserts it into the hash, using hashKey as the entry key.
+ *
+ *
If the element is not found in the XML element, an empty string is returned.
+ *
+ * @param hash {@link Map} into which the value of the XML element is inserted.
+ * @param element XML element from which the value is being read.
+ * @param xmlKey Name of the XML tag for which we get the value.
+ * @param hashKey Name of the key in hash when inserting the value.
+ *
+ * @return String – Value of the element xmlKey in element if present;
+ * empty string otherwise.
+ */
public static String xmlValue2Hash(Map hash, Element element, String xmlKey, String hashKey) {
- var value = xmlValue(element, xmlKey);
+ var value = xmlValue(element, xmlKey);
hash.put(hashKey, value);
return value;
}
+ /**
+ * Get the content of the tag key under the XML element,
+ * and inserts it into the hash, using key as the entry key.
+ *
+ *
If the element is not found in the XML element, an empty string is returned.
+ *
+ * @param hash {@link Map} into which the value of the XML element is inserted.
+ * @param element XML element from which the value is being read.
+ * @param key Name of the XML tag for which we get the value, and name of the key in hash
+ * when inserting the value.
+ *
+ * @return String – Value of the element key in element if present;
+ * empty string otherwise.
+ */
public static String xmlValue2Hash(Map hash, Element element, String key) {
return xmlValue2Hash(hash, element, key, key);
}
diff --git a/src/main/java/core/file/xml/XMLTeamDetailsParser.java b/src/main/java/core/file/xml/XMLTeamDetailsParser.java
index f81136973..77b022ef2 100644
--- a/src/main/java/core/file/xml/XMLTeamDetailsParser.java
+++ b/src/main/java/core/file/xml/XMLTeamDetailsParser.java
@@ -4,6 +4,8 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -60,8 +62,6 @@ private static Map parseDetails(@Nullable Document doc, int team
Element ele, root;
Map hash = new SafeInsertMap();
-// HOLogger.instance().debug(XMLTeamDetailsParser.class, "parsing teamDetails for teamID: " + teamId);
-
if (doc == null) {
return hash;
}
@@ -89,26 +89,8 @@ private static Map parseDetails(@Nullable Document doc, int team
}
hash.put("HasSupporter", supportStatus);
- // We need to find the correct team
-
- Element team = null;
- ele = (Element) doc.getDocumentElement().getElementsByTagName("Teams").item(0);
- if ( ele != null) {
- root = ele;
- NodeList list = root.getElementsByTagName("Team");
- for (int i = 0; (list != null) && (i < list.getLength()); i++) {
- team = (Element) list.item(i);
-
- ele = (Element) team.getElementsByTagName("TeamID").item(0);
- if (Integer.parseInt(XMLManager.getFirstChildNodeValue(ele)) == teamId) {
- break;
- }
- }
- }
- else {
- team = (Element)doc.getDocumentElement().getElementsByTagName("Team").item(0);
- }
-
+ // We need to find the correct team in doc
+ final Element team = selectTeamWithId(doc, teamId);
if (team == null) {
return hash;
}
@@ -140,6 +122,8 @@ private static Map parseDetails(@Nullable Document doc, int team
HOLogger.instance().log(XMLTeamDetailsParser.class, exp);
}
+ xmlValue2Hash(hash, team, "CountryName");
+
var fanclub = (Element) team.getElementsByTagName("Fanclub").item(0);
xmlValue2Hash(hash, fanclub, "FanclubSize");
@@ -152,6 +136,9 @@ private static Map parseDetails(@Nullable Document doc, int team
root = (Element) team.getElementsByTagName("Region").item(0);
xmlValue2Hash(hash, root, "RegionID");
+ xmlValue2Hash(hash, team, "IsBot");
+ xmlValue2Hash(hash, team, "BotSince");
+
// Power Rating
Element PowerRating = (Element)doc.getDocumentElement().getElementsByTagName("PowerRating").item(0);
xmlValue2Hash(hash, PowerRating, "GlobalRanking");
@@ -170,6 +157,29 @@ private static Map parseDetails(@Nullable Document doc, int team
return hash;
}
+ private static Element selectTeamWithId(Document doc, int teamId) {
+ Element team = null;
+ Element ele;
+ Element root;
+ ele = (Element) doc.getDocumentElement().getElementsByTagName("Teams").item(0);
+ if ( ele != null) {
+ root = ele;
+ NodeList list = root.getElementsByTagName("Team");
+ for (int i = 0; (list != null) && (i < list.getLength()); i++) {
+ team = (Element) list.item(i);
+
+ ele = (Element) team.getElementsByTagName("TeamID").item(0);
+ if (Integer.parseInt(XMLManager.getFirstChildNodeValue(ele)) == teamId) {
+ break;
+ }
+ }
+ }
+ else {
+ team = (Element) doc.getDocumentElement().getElementsByTagName("Team").item(0);
+ }
+ return team;
+ }
+
public static List getTeamInfoFromString(String input) {
List ret = new ArrayList<>();
if ( input.isEmpty() ) return ret;
diff --git a/src/main/java/core/gui/event/ChangeEventHandler.java b/src/main/java/core/gui/event/ChangeEventHandler.java
index 41202dcfd..c1e5b3f57 100644
--- a/src/main/java/core/gui/event/ChangeEventHandler.java
+++ b/src/main/java/core/gui/event/ChangeEventHandler.java
@@ -10,7 +10,7 @@
public class ChangeEventHandler {
/** CopyOnWriteArrayList ensures thread-safety */
- private List changeListeners = new CopyOnWriteArrayList<>();
+ private final List changeListeners = new CopyOnWriteArrayList<>();
public void addChangeListener(ChangeListener changeListener) {
changeListeners.add(changeListener);
@@ -22,7 +22,7 @@ public void removeChangeListener(ChangeListener changeListener) {
}
}
- protected void fireChangeEvent(ChangeEvent event) {
+ public void fireChangeEvent(ChangeEvent event) {
for (ChangeListener listener : changeListeners) {
listener.stateChanged(event);
}
diff --git a/src/main/java/core/gui/model/UserColumnController.java b/src/main/java/core/gui/model/UserColumnController.java
index b7e699686..93eb1cbec 100644
--- a/src/main/java/core/gui/model/UserColumnController.java
+++ b/src/main/java/core/gui/model/UserColumnController.java
@@ -95,22 +95,22 @@ public static UserColumnController instance(){
*
*/
public void load() {
- final DBManager dbZugriff = DBManager.instance();
+ final DBManager dbManager = DBManager.instance();
- dbZugriff.loadHOColumModel(getMatchesModel());
- dbZugriff.loadHOColumModel(getPlayerOverviewModel());
- dbZugriff.loadHOColumModel(getLineupModel());
- dbZugriff.loadHOColumModel(getAnalysis1Model());
- dbZugriff.loadHOColumModel(getAnalysis2Model());
- dbZugriff.loadHOColumModel(getMatchesOverview1ColumnModel());
+ dbManager.loadHOColumModel(getMatchesModel());
+ dbManager.loadHOColumModel(getPlayerOverviewModel());
+ dbManager.loadHOColumModel(getLineupModel());
+ dbManager.loadHOColumModel(getAnalysis1Model());
+ dbManager.loadHOColumModel(getAnalysis2Model());
+ dbManager.loadHOColumModel(getMatchesOverview1ColumnModel());
- dbZugriff.loadHOColumModel(getYouthTrainingViewColumnModel());
- dbZugriff.loadHOColumModel(getYouthPlayerOverviewColumnModel());
- dbZugriff.loadHOColumModel(getYouthPlayerDetailsColumnModel());
- dbZugriff.loadHOColumModel(getTeamAnalyzerRecapModell());
- dbZugriff.loadHOColumModel(getTransferTableModel());
- dbZugriff.loadHOColumModel(getPlayerTransferTableModel());
- dbZugriff.loadHOColumModel(getSpecialEventsTableModel());
+ dbManager.loadHOColumModel(getYouthTrainingViewColumnModel());
+ dbManager.loadHOColumModel(getYouthPlayerOverviewColumnModel());
+ dbManager.loadHOColumModel(getYouthPlayerDetailsColumnModel());
+ dbManager.loadHOColumModel(getTeamAnalyzerRecapModel());
+ dbManager.loadHOColumModel(getTransferTableModel());
+ dbManager.loadHOColumModel(getPlayerTransferTableModel());
+ dbManager.loadHOColumModel(getSpecialEventsTableModel());
}
public SpecialEventsTableModel getSpecialEventsTableModel() {
@@ -191,7 +191,7 @@ public Vector getAllModels() {
v.add(getLineupModel());
v.add(getAnalysis1Model());
v.add(getAnalysis2Model());
- v.add(getTeamAnalyzerRecapModell());
+ v.add(getTeamAnalyzerRecapModel());
// MatchesOverView1Model should not add in this vector, because columns should not be edit
return v;
}
@@ -216,8 +216,8 @@ public YouthPlayerDetailsTableModel getYouthPlayerDetailsColumnModel() {
return youthPlayerDetailsTableModel;
}
- public RecapPanelTableModel getTeamAnalyzerRecapModell() {
- if (teamAnalyzerRecapModel==null){
+ public RecapPanelTableModel getTeamAnalyzerRecapModel() {
+ if (teamAnalyzerRecapModel == null) {
teamAnalyzerRecapModel = new RecapPanelTableModel(ColumnModelId.TEAMANALYZERRECAP);
}
return teamAnalyzerRecapModel;
diff --git a/src/main/java/core/model/series/SerieTableEntry.java b/src/main/java/core/model/series/SerieTableEntry.java
index f115cdfe4..da791f902 100644
--- a/src/main/java/core/model/series/SerieTableEntry.java
+++ b/src/main/java/core/model/series/SerieTableEntry.java
@@ -1,6 +1,8 @@
package core.model.series;
-public class SerieTableEntry implements Comparable{
+import java.util.Arrays;
+
+public class SerieTableEntry implements Comparable {
//~ Instance fields ----------------------------------------------------------------------------
public static final byte H_SIEG = 1;
public static final byte A_SIEG = 2;
@@ -43,9 +45,7 @@ public class SerieTableEntry implements Comparable{
* Creates a new instance of LigaTabellenEintrag
*/
public SerieTableEntry() {
- for (int i = 0; i < m_aSerie.length; i++) {
- m_aSerie[i] = UNKOWN;
- }
+ Arrays.fill(m_aSerie, UNKOWN);
}
//~ Methods ------------------------------------------------------------------------------------
@@ -463,10 +463,10 @@ public final byte[] getSerie() {
}
public final String getSerieAsString() {
- final StringBuffer buffer = new StringBuffer();
+ final StringBuilder buffer = new StringBuilder();
- for (int i = 0; i < m_aSerie.length; i++) {
- switch (m_aSerie[i]) {
+ for (byte b : m_aSerie) {
+ switch (b) {
case H_SIEG:
buffer.append(core.model.HOVerwaltung.instance().getLanguageString("SerieHeimSieg"));
break;
@@ -589,14 +589,14 @@ public final void addSerienEintrag(int index, byte serienInfo) {
* vergleicht die Einträge
*/
public final int compareTo(SerieTableEntry obj) {
- if (obj instanceof SerieTableEntry) {
+ if (obj != null) {
final SerieTableEntry lte = (SerieTableEntry) obj;
if (m_iPunkte > lte.getPoints()) {
return -1;
} else if (m_iPunkte < lte.getPoints()) {
return 1;
- } else if (m_iPunkte == lte.getPoints()) {
+ } else {
if (getGoalsDiff() > lte.getGoalsDiff()) {
return -1;
} else if (getGoalsDiff() < lte.getGoalsDiff()) {
@@ -646,14 +646,12 @@ public final boolean equals(Object obj) {
if (obj instanceof SerieTableEntry) {
lte = (SerieTableEntry) obj;
- if ((lte.getAnzSpiele() == m_iAnzSpiele)
- && (lte.getPosition() == m_iPosition)
- && (lte.getPoints() == m_iPunkte)
- && (lte.getTeamName().equals(m_sTeamName))
- && (lte.getGoalsFor() == m_iToreFuer)
- && (lte.getGoalsAgainst() == m_iToreGegen)) {
- return true;
- }
+ return (lte.getAnzSpiele() == m_iAnzSpiele)
+ && (lte.getPosition() == m_iPosition)
+ && (lte.getPoints() == m_iPunkte)
+ && (lte.getTeamName().equals(m_sTeamName))
+ && (lte.getGoalsFor() == m_iToreFuer)
+ && (lte.getGoalsAgainst() == m_iToreGegen);
}
return false;
diff --git a/src/main/java/core/net/MyConnector.java b/src/main/java/core/net/MyConnector.java
index 5b585ac6c..73034fe4c 100644
--- a/src/main/java/core/net/MyConnector.java
+++ b/src/main/java/core/net/MyConnector.java
@@ -159,7 +159,7 @@ public String getHattrickXMLFile(String file){
* lädt die Tabelle
*/
public String getLeagueDetails(String leagueUnitId) {
- String url = htUrl + "?file=leaguedetails&version=1.5&leagueLevelUnitID=" + leagueUnitId;
+ String url = htUrl + "?file=leaguedetails&version=1.6&leagueLevelUnitID=" + leagueUnitId;
return getCHPPWebFile(url);
}
@@ -446,13 +446,18 @@ public String getStaff(int teamId) {
/**
* Download team details
*/
- public String getTeamdetails(int teamId) throws IOException {
- String url = htUrl + "?file=teamdetails&version=3.5";
- if (teamId > 0) {
- url += ("&teamID=" + teamId);
- }
+ public String getTeamDetails(int teamId) {
+ try {
+ String url = htUrl + "?file=teamdetails&version=3.6";
+ if (teamId > 0) {
+ url += ("&teamID=" + teamId);
+ }
- return getCHPPWebFile(url);
+ return getCHPPWebFile(url);
+ } catch (Exception e) {
+ HOLogger.instance().log(getClass(), e);
+ }
+ return "";
}
/**
@@ -571,25 +576,13 @@ public void enableProxy(ProxySettings proxySettings) {
* Get the region id for a certain team.
*/
public String fetchRegionID(int teamId) {
- String xml = fetchTeamDetails(teamId);
+ String xml = getTeamDetails(teamId);
if (!xml.isEmpty()){
return XMLTeamDetailsParser.fetchRegionID(xml);
}
return "-1";
}
-
- public String fetchTeamDetails(int teamId)
- {
- try {
- String xmlFile = htUrl + "?file=teamdetails&version=3.5&teamID=" + teamId;
- return getCHPPWebFile(xmlFile);
- } catch (Exception e) {
- HOLogger.instance().log(getClass(), e);
- }
- return "";
- }
-
public InputStream getFileFromWeb(String url, boolean displaysettingsScreen) {
if (displaysettingsScreen) {
// Show Screen
diff --git a/src/main/java/core/net/OnlineWorker.java b/src/main/java/core/net/OnlineWorker.java
index c304de499..12a9e261f 100644
--- a/src/main/java/core/net/OnlineWorker.java
+++ b/src/main/java/core/net/OnlineWorker.java
@@ -72,7 +72,7 @@ public static boolean getHrf(JDialog parent) {
if (hrf == null) {
return false;
}
-
+
} catch (IOException e) {
// Info
String msg = getLangString("Downloadfehler")
@@ -229,9 +229,23 @@ public static boolean downloadMatchData(int matchid, MatchType matchType, boolea
return downloadMatchData(info, refresh);
}
- public static boolean downloadMatchData(MatchKurzInfo info, boolean refresh)
- {
- if (info.isObsolet()){
+ /**
+ * Downloads all the data for a match whose kurzInfo is passed.
+ *
+ *
This includes:
+ *
+ *
{@link Matchdetails} for that match, incl. opponents, date, location, weather, events, etc.;
+ *
The teams' logo;
+ *
The match lineup for both teams;
+ *
The team details (for ratings) for both teams;
+ *
and {@link Matchdetails} again for highlights?
+ *
+ * @param info High level match info.
+ * @param refresh Forces a new download of the match details, even if they already exist.
+ * @return boolean – true if download is successful, false otherwise.
+ */
+ public static boolean downloadMatchData(MatchKurzInfo info, boolean refresh) {
+ if (info.isObsolet()) {
return true;
}
@@ -243,7 +257,7 @@ public static boolean downloadMatchData(MatchKurzInfo info, boolean refresh)
}
HOMainFrame.instance().setWaitInformation();
- // Only download if not present in the database, or if refresh is true or if match not oboslet
+ // Only download if not present in the database, or if refresh is true or if match not obsolete
if (refresh
|| !DBManager.instance().isMatchInDB(matchID, info.getMatchType())
|| DBManager.instance().hasUnsureWeatherForecast(matchID)
@@ -255,14 +269,14 @@ public static boolean downloadMatchData(MatchKurzInfo info, boolean refresh)
// If ids not found, download matchdetails to obtain them.
// Highlights will be missing.
// ArenaId==0 in division battles
- boolean newInfo = info.getHomeTeamID()<=0 || info.getGuestTeamID()<=0;
+ boolean incompleteInfo = info.getHomeTeamID() <= 0 || info.getGuestTeamID() <= 0;
Weather.Forecast weatherDetails = info.getWeatherForecast();
boolean bWeatherKnown = ((weatherDetails != null) && weatherDetails.isSure());
- if ( newInfo || !bWeatherKnown) {
+ if (incompleteInfo || !bWeatherKnown) {
HOMainFrame.instance().setWaitInformation();
details = downloadMatchDetails(matchID, info.getMatchType(), null);
- if ( details != null) {
+ if (details != null) {
info.setHomeTeamID(details.getHomeTeamId());
info.setGuestTeamID(details.getGuestTeamId());
info.setArenaId(details.getArenaID());
@@ -277,7 +291,7 @@ public static boolean downloadMatchData(MatchKurzInfo info, boolean refresh)
if (!info.getWeatherForecast().isSure()) {
Regiondetails regiondetails = getRegionDetails(info.getRegionId());
- if ( regiondetails != null) {
+ if (regiondetails != null) {
var matchDate = info.getMatchSchedule().toLocaleDate();
var weatherDate = regiondetails.getFetchDatum().toLocaleDate();
if (matchDate.equals(weatherDate)) {
@@ -319,12 +333,11 @@ public static boolean downloadMatchData(MatchKurzInfo info, boolean refresh)
MatchLineup lineup;
boolean success;
- if ( (info.getMatchStatus() == MatchKurzInfo.FINISHED) && (! info.isObsolet())) {
+ if ( (info.getMatchStatus() == MatchKurzInfo.FINISHED) && (!info.isObsolet())) {
lineup = downloadMatchlineup(matchID, info.getMatchType(), info.getHomeTeamID(), info.getGuestTeamID());
if (lineup == null) {
if ( !isSilentDownload()) {
- String msg = getLangString("Downloadfehler")
- + " : Error fetching Matchlineup :";
+ String msg = getLangString("Downloadfehler") + " : Error fetching Matchlineup :";
// Info
setInfoMsg(msg, InfoPanel.FEHLERFARBE);
Helper.showMessage(HOMainFrame.instance(), msg, getLangString("Fehler"),
@@ -375,7 +388,7 @@ public static boolean downloadMatchData(MatchKurzInfo info, boolean refresh)
private static void downloadTeamRatings(int matchID, MatchType matchType, int teamID) {
try {
- var xml = MyConnector.instance().getTeamdetails(teamID);
+ var xml = MyConnector.instance().getTeamDetails(teamID);
var teamrating = new MatchTeamRating(matchID, matchType, XMLTeamDetailsParser.parseTeamdetailsFromString(xml, teamID));
DBManager.instance().storeTeamRatings(teamrating);
} catch (Exception e) {
@@ -387,9 +400,8 @@ private static void downloadTeamRatings(int matchID, MatchType matchType, int te
}
}
- private static Map getTeam(int teamId)
- {
- String str = MyConnector.instance().fetchTeamDetails(teamId);
+ public static Map getTeam(int teamId) {
+ String str = MyConnector.instance().getTeamDetails(teamId);
return XMLTeamDetailsParser.parseTeamdetailsFromString(str, teamId);
}
@@ -399,8 +411,7 @@ private static int getRegionId(Map team) {
return 0;
}
- private static int getArenaId(Map team)
- {
+ private static int getArenaId(Map team) {
String str = team.get("ArenaID");
if ( str != null ) return Integer.parseInt(str);
return 0;
@@ -462,7 +473,6 @@ public static List getMatches(int teamId, HODateTime date) {
/**
* Download information about a given tournament
*/
-
public static TournamentDetails getTournamentDetails(int tournamentId) {
TournamentDetails oTournamentDetails = null;
String tournamentString = "";
@@ -614,7 +624,6 @@ private static MatchLineup downloadMatchlineup(int matchId, MatchType matchType,
int teamId2) {
MatchLineup lineUp2 = null;
- // Wait Dialog zeigen
HOMainFrame.instance().setWaitInformation();
// Lineups holen
@@ -685,7 +694,6 @@ public static Spielplan downloadLeagueFixtures(int season, int leagueID) {
* The lineup object to be uploaded
* @return A string response with any error message
*/
-
public static String uploadMatchOrder(int matchId, MatchType matchType, Lineup lineup) {
String result;
String orders = lineup.toJson();
@@ -694,7 +702,7 @@ public static String uploadMatchOrder(int matchId, MatchType matchType, Lineup l
} catch (IOException e) {
throw new RuntimeException(e);
}
-
+
return result;
}
@@ -994,10 +1002,10 @@ private static void saveHRFToFile(JDialog parent, String hrfData) {
private static String getHRFFileName() {
GregorianCalendar calendar = (GregorianCalendar) Calendar.getInstance();
StringBuilder builder = new StringBuilder();
-
+
builder.append(HOVerwaltung.instance().getModel().getBasics().getTeamId());
builder.append('-');
-
+
builder.append(calendar.get(Calendar.YEAR));
builder.append('-');
int month = calendar.get(Calendar.MONTH) + 1;
@@ -1264,4 +1272,9 @@ public static Map downloadNextMatchOrder(List mat
return new SafeInsertMap();
}
+ public static Map downloadLeagueDetails(int leagueId) {
+ String leagueDetailsXml = MyConnector.instance().getLeagueDetails(String.valueOf(leagueId));
+ return XMLLeagueDetailsParser.parseLeagueDetails(leagueDetailsXml);
+ }
+
}
diff --git a/src/main/java/module/ifa/PluginIfaUtils.java b/src/main/java/module/ifa/PluginIfaUtils.java
index f8c6284c2..725293b18 100644
--- a/src/main/java/module/ifa/PluginIfaUtils.java
+++ b/src/main/java/module/ifa/PluginIfaUtils.java
@@ -28,7 +28,7 @@
public class PluginIfaUtils {
private static String getTeamDetails(int teamID) throws Exception {
- return MyConnector.instance().getTeamdetails(teamID);
+ return MyConnector.instance().getTeamDetails(teamID);
}
private static String parseXmlElement(Document doc, String element, int i, String eleText) {
diff --git a/src/main/java/module/series/SeriesTablePanel.java b/src/main/java/module/series/SeriesTablePanel.java
index 7947e5276..34106d40f 100644
--- a/src/main/java/module/series/SeriesTablePanel.java
+++ b/src/main/java/module/series/SeriesTablePanel.java
@@ -231,13 +231,12 @@ private void initTable() {
private void populateSerieTable() {
try {
if (this.model.getCurrentSeries() != null) {
- final Vector tabelleneintraege = this.model.getCurrentSeries()
- .getTable().getEntries();
+ final Vector tableEntries = this.model.getCurrentSeries().getTable().getEntries();
final int teamid = HOVerwaltung.instance().getModel().getBasics().getTeamId();
int j;
- for (int i = 0; i < tabelleneintraege.size(); i++) {
- final SerieTableEntry entry = tabelleneintraege.get(i);
+ for (int i = 0; i < tableEntries.size(); i++) {
+ final SerieTableEntry entry = tableEntries.get(i);
if (entry.getPoints() > -1) {
j = i + 1;
diff --git a/src/main/java/module/series/promotion/DownloadCountryDetails.java b/src/main/java/module/series/promotion/DownloadCountryDetails.java
index f468fd381..008e87699 100644
--- a/src/main/java/module/series/promotion/DownloadCountryDetails.java
+++ b/src/main/java/module/series/promotion/DownloadCountryDetails.java
@@ -64,9 +64,9 @@ public Map getTeamSeries(int teamId) {
HOLogger.instance().info(DownloadCountryDetails.class, String.format("Retrieving Team details for team %d.", teamId));
try {
- String details = mc.getTeamdetails(teamId);
+ String details = mc.getTeamDetails(teamId);
return XMLTeamDetailsParser.parseTeamdetailsFromString(details, teamId);
- } catch (IOException e) {
+ } catch (Exception e) {
HOLogger.instance().log(DownloadCountryDetails.class, e);
}
@@ -85,7 +85,7 @@ private void handleDuplicateRankings(CountryTeamInfo countryTeamInfo, Map longListEntry.getValue().stream())
- .collect(Collectors.toList()); // merge all the lists of team ranks
+ .toList(); // merge all the lists of team ranks
HOLogger.instance().info(DownloadCountryDetails.class, String.format("Found %d team with duplicate ranks.", duplicateRanks.size()));
countryTeamInfo.data.clear();
diff --git a/src/main/java/module/teamAnalyzer/SystemManager.java b/src/main/java/module/teamAnalyzer/SystemManager.java
index 3c502cc9c..79345d277 100644
--- a/src/main/java/module/teamAnalyzer/SystemManager.java
+++ b/src/main/java/module/teamAnalyzer/SystemManager.java
@@ -30,6 +30,7 @@ public class SystemManager {
private final static String ISMIXEDLINEUP = "TA_mixedLineup";
private final static String ISSHOWPLAYERINFO = "TA_isShowPlayerInfo";
private final static String ISCHECKTEAMNAME = "TA_isCheckTeamName";
+ private final static String IS_SPECIAL_EVENT_VISIBLE = "TA_isSpecialEventVisible";
public static class Setting {
Boolean is;
@@ -67,6 +68,7 @@ public void set(boolean selected) {
public static Setting isMixedLineup = new Setting(ISMIXEDLINEUP, false);
public static Setting isShowPlayerInfo = new Setting(ISSHOWPLAYERINFO, false);
public static Setting isCheckTeamName = new Setting(ISCHECKTEAMNAME);
+ public static Setting isSpecialEventVisible = new Setting(IS_SPECIAL_EVENT_VISIBLE, true);
/**
* The Selected Team
@@ -204,7 +206,7 @@ public static void updateUI() {
}
public static TeamReport getTeamReport() {
- if ( teamReport == null){
+ if (teamReport == null) {
teamReport = new TeamReport(getActiveTeamId(), new ArrayList<>()); // create an empty team report
}
return teamReport;
diff --git a/src/main/java/module/teamAnalyzer/ht/HattrickManager.java b/src/main/java/module/teamAnalyzer/ht/HattrickManager.java
index e901862b9..368492e24 100644
--- a/src/main/java/module/teamAnalyzer/ht/HattrickManager.java
+++ b/src/main/java/module/teamAnalyzer/ht/HattrickManager.java
@@ -1,6 +1,7 @@
package module.teamAnalyzer.ht;
import core.db.DBManager;
+import core.file.xml.TeamStats;
import core.file.xml.XMLManager;
import core.file.xml.XMLPlayersParser;
import core.model.match.MatchKurzInfo;
@@ -8,19 +9,13 @@
import core.net.OnlineWorker;
import core.util.HODateTime;
import module.teamAnalyzer.manager.PlayerDataManager;
-import module.teamAnalyzer.vo.Filter;
-import module.teamAnalyzer.vo.Match;
-import module.teamAnalyzer.vo.PlayerInfo;
+import module.teamAnalyzer.vo.*;
import java.time.temporal.ChronoUnit;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
-import module.teamAnalyzer.vo.SquadInfo;
import org.w3c.dom.Document;
-
/**
* Hattrick Download Helper class
*
@@ -28,27 +23,31 @@
*/
public class HattrickManager {
+ private static final Map> teamDetailsCache = new HashMap<>();
+ private static final Map> seriesDetailsCache = new HashMap<>();
+
/**
- * Method that download from Hattrick the available matches for the team
- * If manual filter, the last 30 is made available.
+ * Method that downloads from Hattrick the available matches for the team teamId.
+ * If manual filter, the last 30 are made available.
* If auto filter, enough matches to supply the filter needs are available.
- * Recent tournament are added if on manual, or if they are wanted, in addition to
+ *
+ *
Recent tournament are added if on manual, or if they are wanted, in addition to
* the number specified.
*
- * @param teamId teamid to download matches for
+ * @param teamId ID of team to download matches for
* @param filter the match filter object.
*/
public static void downloadMatches(final int teamId, Filter filter) {
int limit = Math.min(filter.getNumber(), 50);
-
+
// If on manual, disable all filters, and download 30 matches.
if (!filter.isAutomatic()) {
limit = 30;
}
var start = HODateTime.now().minus(8*30, ChronoUnit.DAYS);
- List matches = OnlineWorker.getMatchArchive( teamId, start, false);
- if ( matches != null) {
+ List matches = OnlineWorker.getMatchArchive(teamId, start, false);
+ if (matches != null) {
Collections.reverse(matches); // Newest first
for (MatchKurzInfo match : matches) {
if (match.getMatchStatus() != MatchKurzInfo.FINISHED) {
@@ -68,7 +67,8 @@ public static void downloadMatches(final int teamId, Filter filter) {
}
}
}
- // Look for tournament matches if they are included in filter.
+
+ // Look for tournament matches if they are included in filter.
if (!filter.isAutomatic() || filter.isTournament()) {
// Current matches includes tournament matches
matches = OnlineWorker.getMatches(teamId, true, false, false);
@@ -84,7 +84,6 @@ public static void downloadMatches(final int teamId, Filter filter) {
if (filter.isAcceptedMatch(new Match(match))
&& match.getMatchType().isTournament()
&& DBManager.instance().matchLineupIsNotStored(match.getMatchType(), match.getMatchID())) {
-
OnlineWorker.downloadMatchData(match.getMatchID(), match.getMatchType(), false);
}
}
@@ -93,7 +92,7 @@ public static void downloadMatches(final int teamId, Filter filter) {
}
/**
- * Method that download from Hattrick the current players for the team
+ * Method that downloads from Hattrick the current players for the team
* player values are aggregated to squad info which is stored separately to get historical trends of the squad development
* @param teamId teamid to download players for
*/
@@ -119,47 +118,62 @@ public static List downloadPlayers(int teamId) {
PlayerDataManager.update(players);
if ( lastMatchDate.isAfter(HODateTime.HT_START) ) {
- var squadInfo = new SquadInfo(teamId, lastMatchDate);
- for (var player : players) {
- squadInfo.incrementPlayerCount();
- if (player.isTransferListed()) squadInfo.incrementTransferListedCount();
- if (player.getMotherClubBonus()) squadInfo.incrementHomegrownCount();
-
- squadInfo.addSalary(player.getSalary());
- squadInfo.addTsi(player.getTSI());
- var injuryLevel = player.getInjuryLevel();
- switch (injuryLevel) {
- case 0:
- squadInfo.incrementBruisedCount();
- break;
- case -1:
- break;
- default:
- squadInfo.addInjuredWeeksSum(injuryLevel);
- squadInfo.incrementInjuredCount();
- }
-
- switch (player.getBookingStatus()) {
- case PlayerDataManager.YELLOW -> squadInfo.incrementSingleYellowCards();
- case PlayerDataManager.DOUBLE_YELLOW -> squadInfo.incrementTwoYellowCards();
- case PlayerDataManager.SUSPENDED -> squadInfo.incrementSuspended();
- }
- }
+ var squadInfo = getSquadInfo(teamId, lastMatchDate, players);
PlayerDataManager.update(squadInfo);
}
return players;
}
+ private static SquadInfo getSquadInfo(int teamId, HODateTime lastMatchDate, List players) {
+ var squadInfo = new SquadInfo(teamId, lastMatchDate);
+ for (var player : players) {
+ squadInfo.incrementPlayerCount();
+ if (player.isTransferListed()) squadInfo.incrementTransferListedCount();
+ if (player.getMotherClubBonus()) squadInfo.incrementHomegrownCount();
+
+ squadInfo.addSalary(player.getSalary());
+ squadInfo.addTsi(player.getTSI());
+ var injuryLevel = player.getInjuryLevel();
+ switch (injuryLevel) {
+ case 0:
+ squadInfo.incrementBruisedCount();
+ break;
+ case -1:
+ break;
+ default:
+ squadInfo.addInjuredWeeksSum(injuryLevel);
+ squadInfo.incrementInjuredCount();
+ }
+
+ switch (player.getBookingStatus()) {
+ case PlayerDataManager.YELLOW -> squadInfo.incrementSingleYellowCards();
+ case PlayerDataManager.DOUBLE_YELLOW -> squadInfo.incrementTwoYellowCards();
+ case PlayerDataManager.SUSPENDED -> squadInfo.incrementSuspended();
+ }
+ }
+ return squadInfo;
+ }
+
+ public static Map getTeamDetails(int teamId) {
+ if (teamDetailsCache.containsKey(teamId)) {
+ return teamDetailsCache.get(teamId);
+ } else {
+ Map teamDetails = OnlineWorker.getTeam(teamId);
+ teamDetailsCache.put(teamId, teamDetails);
+ return teamDetails;
+ }
+ }
+
/**
- * Method that download from Hattrick the team name
+ * Downloads from Hattrick the team name
*
* @param teamId Teamid to download name for
*
* @return Team Name
*
*/
- public static String downloadTeam(int teamId) {
+ public static String downloadTeamName(int teamId) {
String xml = MyConnector.instance().getHattrickXMLFile("/common/chppxml.axd?file=team&teamID=" + teamId);
Document dom = XMLManager.parseString(xml);
if ( dom != null) {
@@ -169,13 +183,28 @@ public static String downloadTeam(int teamId) {
return "";
}
+ public static TeamStats downloadSeriesDetails(int seriesId, int teamId) {
+ Map teamStatsMap;
+ if (seriesDetailsCache.containsKey(seriesId)) {
+ teamStatsMap = seriesDetailsCache.get(seriesId);
+ } else {
+ teamStatsMap = OnlineWorker.downloadLeagueDetails(seriesId);
+ }
+
+ if (teamStatsMap != null) {
+ return teamStatsMap.get(String.valueOf(teamId));
+ } else {
+ return null;
+ }
+ }
+
/**
* Check if CHPP rules approve download for a match
*
* @return true if allowed
*/
public static boolean isDownloadAllowed() {
-
+
// CHPP-Teles confirms in staff message to bingeling (blaghaid) that this is not a problem
// We don't have to worry much about traffic anymore, but may want to check for new functionality.
// The team analyzer was discussed.
diff --git a/src/main/java/module/teamAnalyzer/ui/AutoFilterPanel.java b/src/main/java/module/teamAnalyzer/ui/AutoFilterPanel.java
index 2b9b008bf..baad9d682 100644
--- a/src/main/java/module/teamAnalyzer/ui/AutoFilterPanel.java
+++ b/src/main/java/module/teamAnalyzer/ui/AutoFilterPanel.java
@@ -13,24 +13,23 @@
import javax.swing.*;
+/**
+ * Panel to automatically select games to download.
+ */
public class AutoFilterPanel extends JPanel implements ActionListener, KeyListener {
- //~ Instance fields ----------------------------------------------------------------------------
- private JCheckBox awayGames = new JCheckBox();
- private JCheckBox cup = new JCheckBox();
- private JCheckBox defeat = new JCheckBox();
- private JCheckBox draw = new JCheckBox();
- private JCheckBox friendly = new JCheckBox();
- private JCheckBox tournament = new JCheckBox();
-
- // Filter filter = SystemManager.getFilter();
- private JCheckBox homeGames = new JCheckBox();
- private JCheckBox league = new JCheckBox();
- private JCheckBox qualifier = new JCheckBox();
- private JCheckBox masters = new JCheckBox();
- private JCheckBox win = new JCheckBox();
- private NumberTextField number = new NumberTextField(2);
-
- //~ Constructors -------------------------------------------------------------------------------
+ private final JCheckBox awayGames = new JCheckBox();
+ private final JCheckBox cup = new JCheckBox();
+ private final JCheckBox defeat = new JCheckBox();
+ private final JCheckBox draw = new JCheckBox();
+ private final JCheckBox friendly = new JCheckBox();
+ private final JCheckBox tournament = new JCheckBox();
+
+ private final JCheckBox homeGames = new JCheckBox();
+ private final JCheckBox league = new JCheckBox();
+ private final JCheckBox qualifier = new JCheckBox();
+ private final JCheckBox masters = new JCheckBox();
+ private final JCheckBox win = new JCheckBox();
+ private final NumberTextField number = new NumberTextField(2);
/**
* Creates a new instance of AutoFilterPanel
@@ -39,9 +38,8 @@ public AutoFilterPanel() {
jbInit();
}
- //~ Methods ------------------------------------------------------------------------------------
public void reload() {
- Filter filter = TeamAnalyzerPanel.filter;
+ final Filter filter = TeamAnalyzerPanel.filter;
filter.loadFilters();
homeGames.setSelected(filter.isHomeGames());
awayGames.setSelected(filter.isAwayGames());
@@ -58,7 +56,7 @@ public void reload() {
}
protected void setFilter() {
- Filter filter = TeamAnalyzerPanel.filter;
+ final Filter filter = TeamAnalyzerPanel.filter;
filter.setAwayGames(awayGames.isSelected());
filter.setHomeGames(homeGames.isSelected());
filter.setWin(win.isSelected());
@@ -72,9 +70,8 @@ protected void setFilter() {
filter.setMasters(masters.isSelected());
filter.setNumber(number.getValue());
filter.saveFilters();
-
}
-
+
/**
* Handle action events.
*/
@@ -94,8 +91,13 @@ private void jbInit() {
setOpaque(false);
JPanel filters = new ImagePanel();
-
filters.setLayout(new GridLayout(12, 2));
+
+ filters.add(new JLabel(HOVerwaltung.instance().getLanguageString("AutoFilterPanel.Max_Number"))); //$NON-NLS-1$
+ number.setText(filter.getNumber() + "");
+ number.addKeyListener(this);
+ filters.add(number);
+
filters.add(new JLabel(HOVerwaltung.instance().getLanguageString("AutoFilterPanel.Home_Games"))); //$NON-NLS-1$
homeGames.setSelected(filter.isHomeGames());
homeGames.setOpaque(false);
@@ -149,25 +151,19 @@ private void jbInit() {
qualifier.setOpaque(false);
qualifier.addActionListener(this);
filters.add(qualifier);
-
+
filters.add(new JLabel(HOVerwaltung.instance().getLanguageString("AutoFilterPanel.MastersGame"))); //$NON-NLS-1$
masters.setSelected(filter.isQualifier());
masters.setOpaque(false);
masters.addActionListener(this);
filters.add(masters);
-
-
+
filters.add(new JLabel(HOVerwaltung.instance().getLanguageString("AutoFilterPanel.TournamentGame"))); //$NON-NLS-1$
tournament.setSelected(filter.isTournament());
tournament.setOpaque(false);
tournament.addActionListener(this);
filters.add(tournament);
- filters.add(new JLabel(HOVerwaltung.instance().getLanguageString("AutoFilterPanel.Max_Number"))); //$NON-NLS-1$
- number.setText(filter.getNumber() + "");
- number.addKeyListener(this);
- filters.add(number);
-
main.add(filters, BorderLayout.NORTH);
JScrollPane scrollPane = new JScrollPane(main);
diff --git a/src/main/java/module/teamAnalyzer/ui/FilterPanel.java b/src/main/java/module/teamAnalyzer/ui/FilterPanel.java
index f1d7a4548..b1a9038ac 100644
--- a/src/main/java/module/teamAnalyzer/ui/FilterPanel.java
+++ b/src/main/java/module/teamAnalyzer/ui/FilterPanel.java
@@ -1,5 +1,6 @@
package module.teamAnalyzer.ui;
+import core.file.xml.TeamStats;
import core.gui.HOMainFrame;
import core.gui.comp.panel.ImagePanel;
import core.model.HOVerwaltung;
@@ -8,28 +9,34 @@
import module.teamAnalyzer.ht.HattrickManager;
import module.teamAnalyzer.manager.TeamManager;
import module.teamAnalyzer.vo.Team;
+import org.jetbrains.annotations.NotNull;
import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
import javax.swing.*;
/**
- * Panel to filter opponents matches.
+ * Panel to filter and download opponent's matches.
*/
-public class FilterPanel extends JPanel implements ActionListener {
+public class FilterPanel extends JPanel {
private static final String CARD_AUTOMATIC = "AUTOMATIC CARD";
private static final String CARD_MANUAL = "MANUAL CARD";
private static boolean teamComboUpdating = false;
private AutoFilterPanel autoPanel;
private final JButton downloadButton = new JButton(HOVerwaltung.instance().getLanguageString("ls.button.update"));
+ private final JButton analyzeButton = new JButton(HOVerwaltung.instance().getLanguageString("AutoFilterPanel.Analyze"));
private final JComboBox teamCombo = new JComboBox<>();
private final JPanel cards = new JPanel(new CardLayout());
private JRadioButton radioAutomatic;
private JRadioButton radioManual;
private ManualFilterPanel manualPanel;
+ private final TeamInfoPanel teamInfoPanel = new TeamInfoPanel();
+
/**
* Creates a new FilterPanel object.
*/
@@ -44,25 +51,6 @@ public Team getSelectedTeam() {
return (Team) teamCombo.getSelectedItem();
}
- /**
- * Handle action events.
- */
- @Override
- public void actionPerformed(ActionEvent ae) {
- Object compo = ae != null ? ae.getSource() : null;
- CardLayout cLayout = (CardLayout) (cards.getLayout());
-
- if (radioAutomatic.equals(compo)) {
- TeamAnalyzerPanel.filter.setAutomatic(true);
- autoPanel.reload();
- cLayout.show(cards, CARD_AUTOMATIC);
- } else if (radioManual.equals(compo)) {
- cLayout.show(cards, CARD_MANUAL);
- TeamAnalyzerPanel.filter.setAutomatic(false);
- manualPanel.reload();
- }
- }
-
/**
* Update GUI elements.
*/
@@ -73,6 +61,7 @@ public void reload() {
downloadButton.setEnabled(true);
downloadButton.setText(HOVerwaltung.instance().getLanguageString("ls.button.update"));
+ analyzeButton.setEnabled(true);
CardLayout cLayout = (CardLayout) (cards.getLayout());
@@ -80,8 +69,7 @@ public void reload() {
radioAutomatic.setSelected(true);
cLayout.show(cards, CARD_AUTOMATIC);
autoPanel.reload();
- }
- else {
+ } else {
radioManual.setSelected(true);
cLayout.show(cards, CARD_MANUAL);
manualPanel.reload();
@@ -122,13 +110,20 @@ private void jbInit() {
teamCombo.setOpaque(false);
teamCombo.addItemListener(e -> {
if (!teamComboUpdating) {
- SystemManager.setActiveTeam((Team)teamCombo.getSelectedItem());
+ Team selectedTeam = (Team) teamCombo.getSelectedItem();
+ SystemManager.setActiveTeam(selectedTeam);
+ assert selectedTeam != null;
+ Map teamDetails = retrieveTeamDetails(selectedTeam);
+ teamInfoPanel.setTeam(teamDetails);
SystemManager.refresh();
}
});
- JButton analyzeButton = new JButton(HOVerwaltung.instance().getLanguageString(
- "AutoFilterPanel.Analyze"));
+ if (teamCombo.getSelectedItem() != null) {
+ Team selectedTeam = (Team) teamCombo.getSelectedItem();
+ Map teamDetails = retrieveTeamDetails(selectedTeam);
+ teamInfoPanel.setTeam(teamDetails);
+ }
analyzeButton.addActionListener(e -> {
if (radioManual.isSelected()) {
@@ -139,39 +134,74 @@ private void jbInit() {
SystemManager.updateReport();
});
- downloadButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
+ downloadButton.addActionListener(e -> {
+ downloadButton.setEnabled(false);
+ // Trigger event in a separate thread to avoid Button UI from being blocked.
+ SwingUtilities.invokeLater(() -> {
+ final ExecutorService downloadExecutor = Executors.newCachedThreadPool();
+
HOLogger.instance().log(getClass(),
"UPDATE for Team " + SystemManager.getActiveTeamId());
- //HattrickManager.downloadPlayers(SystemManager.getActiveTeamId());
+
// Load squad info of all teams
- for ( var team : TeamManager.getTeams()){
- HattrickManager.downloadPlayers(team.getTeamId());
+ try {
+ for (var team : TeamManager.getTeams()) {
+ downloadExecutor.execute(() -> HattrickManager.downloadPlayers(team.getTeamId()));
+ }
+
+ downloadExecutor.execute(() ->
+ HattrickManager.downloadMatches(SystemManager.getActiveTeamId(), TeamAnalyzerPanel.filter));
+ } finally {
+ downloadExecutor.shutdown();
+ try {
+ downloadExecutor.awaitTermination(30, TimeUnit.SECONDS);
+ analyzeButton.setEnabled(true);
+ } catch (Exception ee) {
+ HOLogger.instance().error(FilterPanel.class, "Error awaiting termination: " + ee.getMessage());
+ }
}
- HattrickManager.downloadMatches(SystemManager.getActiveTeamId(), TeamAnalyzerPanel.filter);
HOMainFrame.instance().setInformationCompleted();
SystemManager.refresh();
- }
- });
+
+ HOLogger.instance().info(getClass(),
+ "Download complete for Team " + SystemManager.getActiveTeamId());
+
+ downloadButton.setEnabled(true);
+ });
+ });
+
+ JPanel mainTeamPanel = new JPanel();
+ mainTeamPanel.setLayout(new BorderLayout());
JPanel teamPanel = new ImagePanel();
teamPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
teamPanel.setLayout(new BorderLayout());
- teamPanel.add(downloadButton, BorderLayout.NORTH);
teamPanel.add(teamCombo, BorderLayout.SOUTH);
teamPanel.setOpaque(false);
+ mainTeamPanel.add(teamPanel, BorderLayout.NORTH);
+ mainTeamPanel.add(teamInfoPanel, BorderLayout.CENTER);
+
JPanel topPanel = new ImagePanel();
topPanel.setLayout(new BorderLayout());
radioAutomatic = new JRadioButton(HOVerwaltung.instance().getLanguageString("Option.Auto")); //$NON-NLS-1$
radioAutomatic.setSelected(true);
- radioAutomatic.addActionListener(this);
+ radioAutomatic.addActionListener(e -> {
+ final CardLayout cLayout = (CardLayout) cards.getLayout();
+ TeamAnalyzerPanel.filter.setAutomatic(true);
+ autoPanel.reload();
+ cLayout.show(cards, CARD_AUTOMATIC);
+ });
radioAutomatic.setOpaque(false);
radioManual = new JRadioButton(HOVerwaltung.instance().getLanguageString("Manual")); //$NON-NLS-1$
- radioManual.addActionListener(this);
+ radioManual.addActionListener(e -> {
+ final CardLayout cLayout = (CardLayout) cards.getLayout();
+ cLayout.show(cards, CARD_MANUAL);
+ TeamAnalyzerPanel.filter.setAutomatic(false);
+ manualPanel.reload();
+ });
radioManual.setOpaque(false);
ButtonGroup groupRadio = new ButtonGroup();
@@ -187,16 +217,37 @@ public void actionPerformed(ActionEvent e) {
buttonPanel.add(radioManual);
buttonPanel.add(Box.createHorizontalGlue());
- topPanel.add(teamPanel, BorderLayout.NORTH);
- topPanel.add(buttonPanel, BorderLayout.SOUTH);
+ topPanel.add(mainTeamPanel, BorderLayout.NORTH);
+
+ JPanel downloadGamesPanel = new JPanel();
+ downloadGamesPanel.setLayout(new BorderLayout());
+ downloadGamesPanel.add(buttonPanel, BorderLayout.NORTH);
+ downloadGamesPanel.setBorder(BorderFactory.createTitledBorder("Download Games"));
- main.add(topPanel, BorderLayout.NORTH);
- add(main, BorderLayout.NORTH);
autoPanel = new AutoFilterPanel();
manualPanel = new ManualFilterPanel();
cards.add(autoPanel, CARD_AUTOMATIC);
cards.add(manualPanel, CARD_MANUAL);
- add(cards, BorderLayout.CENTER);
- add(analyzeButton, BorderLayout.SOUTH);
+ downloadGamesPanel.add(cards, BorderLayout.CENTER);
+
+ JPanel buttonContainerPanel = new JPanel(new GridLayout(1, 2, 4 ,4));
+ buttonContainerPanel.setOpaque(true);
+ buttonContainerPanel.add(downloadButton);
+ buttonContainerPanel.add(analyzeButton);
+ downloadGamesPanel.add(buttonContainerPanel, BorderLayout.SOUTH);
+
+ main.add(topPanel, BorderLayout.NORTH);
+ main.add(downloadGamesPanel, BorderLayout.CENTER);
+ add(main, BorderLayout.CENTER);
+ }
+
+ @NotNull
+ private static Map retrieveTeamDetails(Team selectedTeam) {
+ Map teamDetails = HattrickManager.getTeamDetails(selectedTeam.getTeamId());
+ TeamStats teamStats = HattrickManager.downloadSeriesDetails(Integer.parseInt(teamDetails.get("LeagueLevelUnitID")), selectedTeam.getTeamId());
+ if (teamStats != null) {
+ teamDetails.put("LeaguePosition", String.valueOf(teamStats.getPosition()));
+ }
+ return teamDetails;
}
}
diff --git a/src/main/java/module/teamAnalyzer/ui/MainPanel.java b/src/main/java/module/teamAnalyzer/ui/MainPanel.java
index 5e098b228..843d03781 100644
--- a/src/main/java/module/teamAnalyzer/ui/MainPanel.java
+++ b/src/main/java/module/teamAnalyzer/ui/MainPanel.java
@@ -4,13 +4,14 @@
import java.awt.BorderLayout;
import javax.swing.JPanel;
+/**
+ * Main panel displays the lineup for both sides for a selected game
+ * in the {@link RecapPanel}.
+ */
public class MainPanel extends JPanel {
- //~ Instance fields ----------------------------------------------------------------------------
- private static final long serialVersionUID = -6374854816698657464L;
- private final RosterPanel rosterPanel = new RosterPanel();
- private final TeamPanel teamPanel = new TeamPanel();
- //~ Constructors -------------------------------------------------------------------------------
+ private final RosterPanel rosterPanel = new RosterPanel();
+ private final TeamPanel teamPanel = new TeamPanel();
/**
* Creates a new TeamPanel object.
@@ -19,7 +20,6 @@ public MainPanel() {
jbInit();
}
- //~ Methods ------------------------------------------------------------------------------------
public TeamLineupData getMyTeamLineupPanel() {
return teamPanel.getMyTeamLineupPanel();
}
diff --git a/src/main/java/module/teamAnalyzer/ui/PlayerPanel.java b/src/main/java/module/teamAnalyzer/ui/PlayerPanel.java
index d2c4cde0c..9b0bc732d 100644
--- a/src/main/java/module/teamAnalyzer/ui/PlayerPanel.java
+++ b/src/main/java/module/teamAnalyzer/ui/PlayerPanel.java
@@ -44,15 +44,13 @@ public class PlayerPanel extends JPanel {
* Creates a new PlayerPanel object.
*/
public PlayerPanel() {
- //setLayout(new BorderLayout());
-
Font nFont = new Font(nameField.getFont().getFontName(), Font.BOLD, nameField.getFont().getSize());
-
nameField.setFont(nFont);
JPanel details = new JPanel();
- details.setBorder(BorderFactory.createEtchedBorder());
+ // details.setBorder(BorderFactory.createEtchedBorder());
+ details.setBorder(BorderFactory.createLineBorder(new Color(230, 230, 230), 1));
details.setBackground(getBackGround());
details.setLayout(new BorderLayout());
@@ -71,7 +69,8 @@ public PlayerPanel() {
JPanel centerPanel = new JPanel();
- centerPanel.setBorder(BorderFactory.createEtchedBorder());
+ // centerPanel.setBorder(BorderFactory.createEtchedBorder());
+ centerPanel.setBorder(BorderFactory.createLineBorder(new Color(230, 230, 230), 1));
centerPanel.setBackground(getBackGround());
centerPanel.setLayout(new BorderLayout());
centerPanel.add(details, BorderLayout.NORTH);
@@ -81,23 +80,17 @@ public PlayerPanel() {
centerPanel.add(infoPanel, BorderLayout.SOUTH);
}
-// mainPanel = new ImagePanel();
-// mainPanel.setLayout(new BorderLayout());
-// mainPanel.setBorder(BorderFactory.createRaisedBevelBorder());
setLayout(new GridBagLayout());
var c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy = 0;
c.weightx = 1;
-// mainPanel.setBorder(BorderFactory.createRaisedBevelBorder());
-// mainPanel.setPreferredSize(getDefaultSize());
add(positionField, c);
c.gridy++;
add(centerPanel,c);
c.gridy++;
add(tacticPanel, c);
- //add(mainPanel, BorderLayout.CENTER);
}
protected Color getBackGround() {
@@ -113,7 +106,6 @@ public boolean getContainsPlayer() {
*/
public void reload(SpotLineup lineup, int week, int season) {
tacticPanel.setVisible(SystemManager.isTacticDetail.isSet());
- //mainPanel.setPreferredSize(getDefaultSize());
if (lineup != null) {
containsPlayer = true;
@@ -191,8 +183,7 @@ protected Icon getBookingStatusIcon(int bookingStatus) {
protected Icon getTransferListedStatusIcon(int transferStatus) {
if(transferStatus == PlayerDataManager.TRANSFER_LISTED) {
return ImageUtilities.getSvgIcon(TRANSFERLISTED_TINY, Map.of("foregroundColor", ThemeManager.getColor(HOColorName.PLAYER_SPECIALTY_COLOR)), 14, 14);
- }
- else{
+ } else {
return null;
}
}
diff --git a/src/main/java/module/teamAnalyzer/ui/RatingPanel.java b/src/main/java/module/teamAnalyzer/ui/RatingPanel.java
index ad30dcf56..cad4f4a6d 100644
--- a/src/main/java/module/teamAnalyzer/ui/RatingPanel.java
+++ b/src/main/java/module/teamAnalyzer/ui/RatingPanel.java
@@ -29,7 +29,7 @@ public class RatingPanel extends JPanel {
HOVerwaltung.instance().getLanguageString("Rating"),
HOVerwaltung.instance().getLanguageString("Differenz_kurz"),
HOVerwaltung.instance().getLanguageString("RatingPanel.Relative")
- };
+ };
//~ Constructors -------------------------------------------------------------------------------
diff --git a/src/main/java/module/teamAnalyzer/ui/RecapPanel.java b/src/main/java/module/teamAnalyzer/ui/RecapPanel.java
index df15a49f5..521ca4133 100644
--- a/src/main/java/module/teamAnalyzer/ui/RecapPanel.java
+++ b/src/main/java/module/teamAnalyzer/ui/RecapPanel.java
@@ -34,7 +34,7 @@ public void reload(TeamReport teamReport) {
}
private void jbInit() {
- tableModel = UserColumnController.instance().getTeamAnalyzerRecapModell();
+ tableModel = UserColumnController.instance().getTeamAnalyzerRecapModel();
tableModel.showTeamReport(null);
table = new FixedColumnsTable(2, tableModel);
table.setDefaultRenderer(Object.class, new RecapTableRenderer());
diff --git a/src/main/java/module/teamAnalyzer/ui/RecapPanelTableModel.java b/src/main/java/module/teamAnalyzer/ui/RecapPanelTableModel.java
index cdb5ceb70..c49ba1d17 100644
--- a/src/main/java/module/teamAnalyzer/ui/RecapPanelTableModel.java
+++ b/src/main/java/module/teamAnalyzer/ui/RecapPanelTableModel.java
@@ -22,7 +22,7 @@
public class RecapPanelTableModel extends HOTableModel {
- public RecapPanelTableModel( UserColumnController.ColumnModelId id) {
+ public RecapPanelTableModel(UserColumnController.ColumnModelId id) {
super(id, "TeamAnalyzerRecap");
columns = initColumns();
}
diff --git a/src/main/java/module/teamAnalyzer/ui/SpecialEventsPanel.java b/src/main/java/module/teamAnalyzer/ui/SpecialEventsPanel.java
index 8229db7ec..a2486e7dc 100644
--- a/src/main/java/module/teamAnalyzer/ui/SpecialEventsPanel.java
+++ b/src/main/java/module/teamAnalyzer/ui/SpecialEventsPanel.java
@@ -36,17 +36,15 @@ public SpecialEventsPanel(){
tableModel = new BaseTableModel(data, new Vector<>(Arrays.asList(columns)));
table = new JTable(tableModel);
setLayout(new BorderLayout());
+ setBorder(BorderFactory.createTitledBorder(hov.getLanguageString("ls.teamanalyzer.special_events")));
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- JLabel start = new JLabel(hov.getLanguageString("ls.teamanalyzer.special_events"));
- add(start, BorderLayout.PAGE_START);
add(scrollPane);
resultLabel = new JLabel( hov.getLanguageString("ls.teamanalyzer.result") + ": 0.00 - 0.00");
add(resultLabel, BorderLayout.PAGE_END);
-
}
public void reload(TeamLineup teamLineup) {
@@ -129,11 +127,12 @@ public void reload(TeamLineup teamLineup) {
this.resultLabel.setText(String.format(hov.getLanguageString("ls.teamanalyzer.result") + ": %.2f : %.2f", scores, opponentScores));
}
- private Vector