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 getRow(String kind, Player player, Player opponentPlayer, ArrayList involved, double probability, Double scores, Double scoresOpponent) { + private Vector getRow(String kind, Player player, Player opponentPlayer, ArrayList involved, + double probability, Double scores, Double scoresOpponent) { ArrayList involvedPlayerNames = new ArrayList<>(); - for ( Player p : involved){ - if ( p == null){ + for (Player p : involved) { + if (p == null) { continue; } involvedPlayerNames.add(p.getFullName()); diff --git a/src/main/java/module/teamAnalyzer/ui/TeamAnalyzerPanel.java b/src/main/java/module/teamAnalyzer/ui/TeamAnalyzerPanel.java index 394ace657..31f3d9859 100644 --- a/src/main/java/module/teamAnalyzer/ui/TeamAnalyzerPanel.java +++ b/src/main/java/module/teamAnalyzer/ui/TeamAnalyzerPanel.java @@ -8,18 +8,26 @@ import module.teamAnalyzer.ui.controller.SimButtonListener; import module.teamAnalyzer.vo.Filter; import module.training.ui.comp.DividerListener; + import java.awt.BorderLayout; -import java.io.Serial; import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.JSplitPane; +/** + * Base panel of the module. + * + *

It is composed of: + *

    + *
  • {@link MainPanel}, which displays the team lineup for the selected team, and the user's team;
  • + *
  • {@link RecapPanel} at the bottom, which displays the x last matches for the selected team;
  • + *
  • simButton, {@link FilterPanel}, {@link RatingPanel} and {@link SpecialEventsPanel} on the left.
  • + *
+ */ public class TeamAnalyzerPanel extends LazyPanel { /** The filters */ public static Filter filter = new Filter(); - @Serial - private static final long serialVersionUID = 1L; private JButton simButton; private RecapPanel recapPanel; private MainPanel mainPanel; @@ -61,35 +69,42 @@ private void initComponents() { simButton = new JButton(HOVerwaltung.instance().getLanguageString("Simulate")); - JSplitPane splitPaneSub = new JSplitPane(JSplitPane.VERTICAL_SPLIT, ratingPanel, specialEventsPanel); - splitPaneSub.setDividerLocation(UserParameter.instance().teamAnalyzer_RatingPanelSplitPane); - splitPaneSub.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, - new DividerListener(DividerListener.teamAnalyzer_RatingPanelSplitPane)); - - JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, filterPanel, splitPaneSub); - splitPane.setDividerLocation(UserParameter.instance().teamAnalyzer_FilterPanelSplitPane); - splitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, - new DividerListener(DividerListener.teamAnalyzer_FilterPanelSplitPane)); + JSplitPane splitPane = createTopSplitPane(); JPanel mainLeftPanel = new JPanel(); mainLeftPanel.setLayout(new BorderLayout()); mainLeftPanel.add(splitPane, BorderLayout.CENTER); mainLeftPanel.add(simButton, BorderLayout.SOUTH); - JSplitPane splitPaneUpper = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mainLeftPanel, - mainPanel); + JSplitPane splitPaneUpper = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mainLeftPanel, mainPanel); splitPaneUpper.setDividerLocation(UserParameter.instance().teamAnalyzer_MainPanelSplitPane); splitPaneUpper.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new DividerListener(DividerListener.teamAnalyzer_MainPanelSplitPane)); - JSplitPane splitPaneMain = new JSplitPane(JSplitPane.VERTICAL_SPLIT, splitPaneUpper, - recapPanel); + JSplitPane splitPaneMain = new JSplitPane(JSplitPane.VERTICAL_SPLIT, splitPaneUpper, recapPanel); splitPaneMain.setDividerLocation(UserParameter.instance().teamAnalyzer_BottomSplitPane); splitPaneMain.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new DividerListener(DividerListener.teamAnalyzer_BottomSplitPane)); add(splitPaneMain, BorderLayout.CENTER); } + private JSplitPane createTopSplitPane() { + JSplitPane splitPane; + if (SystemManager.isSpecialEventVisible.isSet()) { + JSplitPane splitPaneSub = new JSplitPane(JSplitPane.VERTICAL_SPLIT, ratingPanel, specialEventsPanel); + splitPaneSub.setDividerLocation(UserParameter.instance().teamAnalyzer_RatingPanelSplitPane); + splitPaneSub.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, + new DividerListener(DividerListener.teamAnalyzer_RatingPanelSplitPane)); + splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, filterPanel, splitPaneSub); + } else { + splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, filterPanel, ratingPanel); + } + splitPane.setDividerLocation(UserParameter.instance().teamAnalyzer_FilterPanelSplitPane); + splitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, + new DividerListener(DividerListener.teamAnalyzer_FilterPanelSplitPane)); + return splitPane; + } + public MainPanel getMainPanel() { return mainPanel; } @@ -122,17 +137,17 @@ RecapPanel getRecapPanel() { public void reload() { getFilterPanel().reload(); TeamReport teamReport = SystemManager.getTeamReport(); + getMainPanel().reload(teamReport.getSelectedLineup(), 0, 0); getRecapPanel().reload(teamReport); getRatingPanel().reload(teamReport.getSelectedLineup()); - getSpecialEventsPanel().reload(teamReport.getSelectedLineup()); this.simButton.setVisible(SystemManager.isLineup.isSet()); } public void storeUserSettings() { - if ( this.recapPanel != null) { + if (this.recapPanel != null) { this.recapPanel.storeUserSettings(); } } diff --git a/src/main/java/module/teamAnalyzer/ui/TeamInfoPanel.kt b/src/main/java/module/teamAnalyzer/ui/TeamInfoPanel.kt new file mode 100644 index 000000000..790b0eaf5 --- /dev/null +++ b/src/main/java/module/teamAnalyzer/ui/TeamInfoPanel.kt @@ -0,0 +1,95 @@ +package module.teamAnalyzer.ui + +import core.model.HOVerwaltung +import core.util.HODateTime +import java.awt.Font +import java.awt.GridBagConstraints +import java.awt.GridBagLayout +import javax.swing.BorderFactory +import javax.swing.ImageIcon +import javax.swing.JLabel +import javax.swing.JPanel + +/** + * Displays information about the team currently selected in the dropdown in + * [module.teamAnalyzer.ui.FilterPanel]. + */ +class TeamInfoPanel : JPanel() { + + private fun isBot(details: Map):Boolean { + val isBot = details.getOrDefault("IsBot", "False") + return isBot.equals("True", ignoreCase = true) + } + + fun setTeam(details: Map) { + removeAll() + val hoVerwaltung = HOVerwaltung.instance(); + val isBot = isBot(details) + + // Column 1 + val infoLabel = JLabel() + infoLabel.icon = ImageIcon(details["LogoURL"]) + infoLabel.text = hoVerwaltung.getLanguageString("ls.teamanalyzer.info") + border = BorderFactory.createTitledBorder("Info") + val gbc = GridBagConstraints() + layout = GridBagLayout() + + gbc.fill = GridBagConstraints.NONE + gbc.weightx = 1.0 + gbc.anchor = GridBagConstraints.WEST + gbc.gridx = 0 + gbc.gridy = 0 + val managerLabel = JLabel(hoVerwaltung.getLanguageString("ls.teamanalyzer.manager")) + val boldFont = managerLabel.font.deriveFont(Font.BOLD) + managerLabel.font = boldFont + add(managerLabel, gbc) + gbc.gridy++ + val lastLoginLabel = JLabel(hoVerwaltung.getLanguageString("ls.teamanalyzer.last_login")) + lastLoginLabel.font = boldFont + add(lastLoginLabel, gbc) + + if (isBot) { + gbc.gridy++ + val botStatusLabel = JLabel(hoVerwaltung.getLanguageString("ls.teamanalyzer.bot")) + botStatusLabel.font = boldFont + add(botStatusLabel, gbc) + } + + if (details.containsKey("LeaguePosition")) { + gbc.gridy++ + val leaguePositionLabel = JLabel(hoVerwaltung.getLanguageString("ls.teamanalyzer.league_position")) + leaguePositionLabel.font = boldFont + add(leaguePositionLabel, gbc) + } + + // Column 2 + gbc.gridx = 1 + gbc.gridy = 0 + gbc.anchor = GridBagConstraints.EAST + val loginValueLabel = JLabel() + loginValueLabel.text = if (details["Loginname"].isNullOrBlank()) hoVerwaltung.getLanguageString("ls.teamanalyzer.na") else details["Loginname"] + add(loginValueLabel, gbc) + gbc.gridy++ + val lastLoginDateLabel = JLabel() + val lastLoginDate = HODateTime.fromHT(details["LastLoginDate"]) + lastLoginDateLabel.text = if (details["Loginname"].isNullOrBlank()) hoVerwaltung.getLanguageString("ls.teamanalyzer.na") else lastLoginDate.toLocaleDateTime() + add(lastLoginDateLabel, gbc) + + if (isBot) { + gbc.gridy++ + val botStatusValueLabel = JLabel() + val boStatusDate = details["BotSince"] + botStatusValueLabel.text = hoVerwaltung.getLanguageString("ls.teamanalyzer.bot_since", HODateTime.fromHT(boStatusDate).toLocaleDate()) + add(botStatusValueLabel, gbc) + } + + if (details.containsKey("LeaguePosition")) { + gbc.gridy++ + val leaguePosText = hoVerwaltung.getLanguageString("ls.teamanalyzer.league_position_val", + details["LeaguePosition"], details["LeagueLevelUnitName"], details["CountryName"]) + val leaguePositionValue = JLabel(leaguePosText) + add(leaguePositionValue, gbc) + } + + } +} diff --git a/src/main/java/module/teamAnalyzer/ui/TeamPanel.java b/src/main/java/module/teamAnalyzer/ui/TeamPanel.java index 775361d85..90a5cc233 100644 --- a/src/main/java/module/teamAnalyzer/ui/TeamPanel.java +++ b/src/main/java/module/teamAnalyzer/ui/TeamPanel.java @@ -208,27 +208,7 @@ private void setMyTeam() { spotLineup.setPosition(lineup.getEffectivePos4PositionID(spot)); spotLineup.setRating(ratingPredictionModel.getPlayerMatchAverageRating(player, lineup.getEffectivePos4PositionID(spot))); - int cards = player.getTotalCards(); - int injury = player.getInjuryWeeks(); - - int injuryStatus, bookingStatus; - - switch (cards) { - case 1 -> bookingStatus = PlayerDataManager.YELLOW; - case 2 -> bookingStatus = PlayerDataManager.DOUBLE_YELLOW; - case 3 -> bookingStatus = PlayerDataManager.SUSPENDED; - default -> bookingStatus = 0; - } - - switch (injury) { - case -1 -> injuryStatus = 0; - case 0 -> injuryStatus = PlayerDataManager.BRUISED; - default -> injuryStatus = PlayerDataManager.INJURED; - } - - int transferListedStatus = player.getTransferListed() * PlayerDataManager.TRANSFER_LISTED; - - int status = injuryStatus + 10 * bookingStatus + 100 * transferListedStatus; + int status = getPlayerStatus(player); spotLineup.setStatus(status); spotLineup.setSpot(spot); spotLineup.setTactics(new ArrayList<>()); @@ -266,6 +246,30 @@ private void setMyTeam() { lineupPanel.getMyTeam().setMidfield(convertRating(ratingPredictionModel.getAverageRating(lineup, RatingPredictionModel.RatingSector.MIDFIELD, 90))); } + private static int getPlayerStatus(Player player) { + int cards = player.getTotalCards(); + int injury = player.getInjuryWeeks(); + + int injuryStatus, bookingStatus; + + switch (cards) { + case 1 -> bookingStatus = PlayerDataManager.YELLOW; + case 2 -> bookingStatus = PlayerDataManager.DOUBLE_YELLOW; + case 3 -> bookingStatus = PlayerDataManager.SUSPENDED; + default -> bookingStatus = 0; + } + + switch (injury) { + case -1 -> injuryStatus = 0; + case 0 -> injuryStatus = PlayerDataManager.BRUISED; + default -> injuryStatus = PlayerDataManager.INJURED; + } + + int transferListedStatus = player.getTransferListed() * PlayerDataManager.TRANSFER_LISTED; + + return injuryStatus + 10 * bookingStatus + 100 * transferListedStatus; + } + private int convertRating(double rating) { return RatingUtil.getIntValue4Rating(rating); } @@ -275,7 +279,6 @@ private void fillPanel(JPanel panel, PlayerPanel playerPanel) { // Don't add the panel of an empty position. if (playerPanel.getContainsPlayer()) { -// playerPanel.setPreferredSize(playerPanel.getDefaultSize()); panel.setLayout(new GridBagLayout()); var constraints = new GridBagConstraints(); constraints.gridy=0; @@ -286,12 +289,6 @@ private void fillPanel(JPanel panel, PlayerPanel playerPanel) { constraints.fill = GridBagConstraints.BOTH; panel.add(playerPanel, constraints); } -// else { -// // But leave a box the size of a player panel... -// Box box = new Box(BoxLayout.X_AXIS); -//// box.setPreferredSize(playerPanel.getDefaultSize()); -// panel.add(box); -// } } public Lineup getOwnLineup() { diff --git a/src/main/java/module/teamAnalyzer/ui/component/AddPanel.java b/src/main/java/module/teamAnalyzer/ui/component/AddPanel.java index c5e153314..a9f90b029 100644 --- a/src/main/java/module/teamAnalyzer/ui/component/AddPanel.java +++ b/src/main/java/module/teamAnalyzer/ui/component/AddPanel.java @@ -101,7 +101,7 @@ public void actionPerformed(ActionEvent e) { } try { - String teamName = HattrickManager.downloadTeam(teamId.getValue()); + String teamName = HattrickManager.downloadTeamName(teamId.getValue()); team.setName(teamName); } catch (Exception e1) { diff --git a/src/main/java/module/teamAnalyzer/ui/component/SettingPanel.java b/src/main/java/module/teamAnalyzer/ui/component/SettingPanel.java index b040f0ce7..f305680cb 100644 --- a/src/main/java/module/teamAnalyzer/ui/component/SettingPanel.java +++ b/src/main/java/module/teamAnalyzer/ui/component/SettingPanel.java @@ -20,27 +20,18 @@ * @author Massimiliano Amato */ public class SettingPanel extends JPanel { - //~ Instance fields ---------------------------------------------------------------------------- - private final JCheckBox checkName = new JCheckBox(); private final JCheckBox descRating = new JCheckBox(); -// private JCheckBox loddarStats = new JCheckBox(); private final JCheckBox mixedLineup = new JCheckBox(); private final JCheckBox myLineup = new JCheckBox(); private final JCheckBox numberRating = new JCheckBox(); private final JCheckBox playerInfo = new JCheckBox(); -// private JCheckBox smartSquad = new JCheckBox(); -// private JCheckBox squad = new JCheckBox(); -// private JCheckBox stars = new JCheckBox(); + private final JCheckBox tacticDetail = new JCheckBox(); -// private JCheckBox totalStrength = new JCheckBox(); private final JCheckBox unavailable = new JCheckBox(); - //~ Constructors ------------------------------------------------------------------------------- + private final JCheckBox specialEventsVisible = new JCheckBox(); - /** - * Constructs a new instance. - */ public SettingPanel() { super(); numberRating.setSelected(SystemManager.isNumericRating.isSet()); @@ -57,23 +48,13 @@ public SettingPanel() { playerInfo.setOpaque(false); mixedLineup.setSelected(SystemManager.isMixedLineup.isSet()); mixedLineup.setOpaque(false); -// stars.setSelected(SystemManager.isStars.isSet()); -// stars.setOpaque(false); -// smartSquad.setSelected(SystemManager.isSmartSquad.isSet()); -// smartSquad.setOpaque(false); -// loddarStats.setSelected(SystemManager.isLoddarStats.isSet()); -// loddarStats.setOpaque(false); -// squad.setSelected(SystemManager.isSquad.isSet()); -// squad.setOpaque(false); -// totalStrength.setSelected(SystemManager.isTotalStrength.isSet()); -// totalStrength.setOpaque(false); checkName.setSelected(SystemManager.isCheckTeamName.isSet()); checkName.setOpaque(false); + specialEventsVisible.setSelected(SystemManager.isSpecialEventVisible.isSet()); + specialEventsVisible.setOpaque(false); jbInit(); } - //~ Methods ------------------------------------------------------------------------------------ - /** * Create a new Panel * @@ -90,7 +71,6 @@ private JPanel createPanel(String string, JComponent checkBox) { JPanel innerPanel = new ImagePanel(); - //innerPanel.setLayout(new BorderLayout()); innerPanel.add(checkBox); innerPanel.add(new JLabel(string, SwingConstants.LEFT)); innerPanel.setOpaque(false); @@ -121,39 +101,11 @@ private void initListeners() { } }); -// stars.addActionListener(e -> { -// SystemManager.isStars.set(stars.isSelected()); -// SystemManager.updateUI(); -// -// }); -// totalStrength.addActionListener(e -> { -// SystemManager.isTotalStrength.set(totalStrength.isSelected()); -// SystemManager.updateUI(); -// -// }); checkName.addActionListener(e -> { SystemManager.isCheckTeamName.set(checkName.isSelected()); SystemManager.updateUI(); - }); -// squad.addActionListener(e -> { -// SystemManager.isSquad.set(squad.isSelected()); -// SystemManager.updateUI(); -// -// }); -// smartSquad.addActionListener(e -> { -// SystemManager.isSmartSquad.set(smartSquad.isSelected()); -// SystemManager.updateUI(); -// -// }); -// -// loddarStats.addActionListener(e -> { -// SystemManager.isLoddarStats.set(loddarStats.isSelected()); -// SystemManager.updateUI(); -// -// }); - myLineup.addActionListener(e -> { SystemManager.isLineup.set(myLineup.isSelected()); SystemManager.updateUI(); @@ -176,6 +128,10 @@ private void initListeners() { SystemManager.isMixedLineup.set(mixedLineup.isSelected()); SystemManager.updateUI(); }); + specialEventsVisible.addActionListener(e -> { + SystemManager.isSpecialEventVisible.set(specialEventsVisible.isSelected()); + SystemManager.updateUI(); + }); } /** @@ -193,16 +149,10 @@ private void jbInit() { mainPanel.add(createPanel(HOVerwaltung.instance().getLanguageString("SettingPanel.MixedLineup"), mixedLineup)); mainPanel.add(createPanel(HOVerwaltung.instance().getLanguageString("SettingPanel.NumericRatings"), numberRating)); mainPanel.add(createPanel(HOVerwaltung.instance().getLanguageString("SettingPanel.DescriptionRatings"), descRating)); - mainPanel.add(createPanel(HOVerwaltung.instance().getLanguageString("SettingPanel.ShowUnavailable"), unavailable)); - -// mainPanel.add(createPanel(HOVerwaltung.instance().getLanguageString("RecapPanel.Stars"), stars)); -// mainPanel.add(createPanel(HOVerwaltung.instance().getLanguageString("ls.match.ratingtype.hatstats"), totalStrength)); -// mainPanel.add(createPanel(HOVerwaltung.instance().getLanguageString("ls.match.ratingtype.squad"), squad)); -// mainPanel.add(createPanel(HOVerwaltung.instance().getLanguageString("ls.match.ratingtype.smartsquad"), smartSquad)); -// mainPanel.add(createPanel(HOVerwaltung.instance().getLanguageString("ls.match.ratingtype.loddarstats"), loddarStats)); mainPanel.add(createPanel(HOVerwaltung.instance().getLanguageString("SettingPanel.Playerinformations"), playerInfo)); mainPanel.add(createPanel(HOVerwaltung.instance().getLanguageString("SettingPanel.CheckName"), checkName)); + mainPanel.add(createPanel(HOVerwaltung.instance().getLanguageString("SettingPanel.SpecialEventVisible"), specialEventsVisible)); setLayout(new BorderLayout()); setOpaque(false); diff --git a/src/main/java/module/training/ui/comp/DividerListener.java b/src/main/java/module/training/ui/comp/DividerListener.java index 4d72a0305..6c112d309 100644 --- a/src/main/java/module/training/ui/comp/DividerListener.java +++ b/src/main/java/module/training/ui/comp/DividerListener.java @@ -1,4 +1,3 @@ -// %1126721451182:hoplugins.trainingExperience.ui.component% package module.training.ui.comp; import core.model.UserParameter; @@ -7,7 +6,7 @@ import java.beans.PropertyChangeListener; /** - * Dividend Listener that store in the Database the position of the varous + * Divider Listener that store in the Database the position of the various * SplitPane * * @author Massimiliano Amato diff --git a/src/main/resources/release_notes.md b/src/main/resources/release_notes.md index 4ef9cfbf7..cd5912db2 100644 --- a/src/main/resources/release_notes.md +++ b/src/main/resources/release_notes.md @@ -26,6 +26,7 @@ ### Team Analyzer * Restore size of match prediction dialog box (#1898) +* Improve layout of Team Analyzer a bit, add option to hide Special Events, and add info about selected team (#2020) * Fix Home/Away setup in Simulator panel (#1885) ### Rating diff --git a/src/main/resources/sprache/English.properties b/src/main/resources/sprache/English.properties index 95a72f6e2..aa72bb380 100644 --- a/src/main/resources/sprache/English.properties +++ b/src/main/resources/sprache/English.properties @@ -786,7 +786,7 @@ HRFDownload=XML Download Benutzername=Username NO_HRF_Spiel=Your club is playing a match NO_HRF_ERROR=Cannot retrieve HRF Data from Internet -XML_PARSE_ERRROR=Cannot parse xml data (you will have more informations in log file).\nThe problem may come from your security policy. +XML_PARSE_ERRROR=Cannot parse xml data (you will have more information in log file).\nThe problem may come from your security policy. FileExport=Export overwrite=Overwrite existing file? ProxyPort=Proxy Port @@ -1004,7 +1004,7 @@ tt_Ligatabelle_SpielAnzeigen=display match tt_Ligatabelle_SpielDownloaden=download match tt_Ligatabelle_SpielNochnichtgespielt=match has not been played yet tt_Login_Proxy=Proxy in use? In the case of doubt leave deactivated -tt_Login_ProxyHost=name of the computer or IP-adress of the proxy +tt_Login_ProxyHost=name of the computer or IP address of the proxy tt_Login_ProxyPort=port of the proxy, usually 80 or 8080 tt_Login_ProxyAuth=does the proxy require an user authentication? tt_Login_ProxyAuthName=username for proxy authentication @@ -1012,8 +1012,8 @@ tt_Login_ProxyAuthPassword=password for proxy authentication tt_Login_Anmelden=Hattrick login and starting download tt_Login_Abbrechen=cancel login tt_Optionen_TransferWecker=how many minutes before expiring of the deadline should the bell ring? -tt_Optionen_MinStaerkeIdealPos=how good should the rating of best position be, for line-up assistent consider best position -tt_Optionen_Wettereffekt=how important (in %) should the weather event be for rating of the player? (line-up assistent only) +tt_Optionen_MinStaerkeIdealPos=how good should the rating of best position be, for line-up assistant consider best position +tt_Optionen_Wettereffekt=how important (in %) should the weather event be for rating of the player? (line-up assistant only) tt_Optionen_Schriftgroesse=character size in HO!. for the resolutions 1024x768 or smaller the size 10 is preferred. tt_Optionen_Sprachdatei=language used in HO! tt_Optionen_Defaultsortierung=starting HO! sorts tables by column. @@ -1076,11 +1076,11 @@ highlight_penalty=Penalty highlight_middle=Attack In middle highlight_links=Attack on left wing highlight_rechts=Attack on right wing -highlight_special=Specialevent +highlight_special=Special event highlight_counter=Counter #V1.3 -OffsetTitle=Subskilladjustment for +OffsetTitle=Subskill adjustment for tt_Spieler_offset=You can adjust manually the subskills of that player #V1.35 @@ -1262,7 +1262,7 @@ download.teamdata=Team data download.teamdata.tt=Download of your team data (no matches, no series data) download.Filter=Download Filter download.currentmatches=Current matches -download.currentmatches.tt=Download of your recently played and upcoming matches (including match informations) +download.currentmatches.tt=Download of your recently played and upcoming matches (including match information) download.OfficialMatches=Official Matches download.IntegratedMatches=Integrated Matches download.SingleMatches=Single Matches @@ -1275,7 +1275,7 @@ download.seriesdata.tt=Download of your current series table and its fixtures download.oldseriesdata=Old series data download.currentseriesdata=Current series data download.oldmatches=Old matches -download.oldmatches.tt=Download of all your played matches (including match informations) since the selected date +download.oldmatches.tt=Download of all your played matches (including match information) since the selected date update.languages.installed=Installed update.languages.available=Available @@ -1291,7 +1291,7 @@ FiredPlayer=Fired Player Transfers=Transfers In=In Out=Out -UpdConfirmMsg.0=This will redownload the entire transfer history for your team! +UpdConfirmMsg.0=This will re-download the entire transfer history for your team! UpdConfirmMsg.1=You should only need to use this function if the current data in HO is incorrect or incomplete. UpdConfirmMsg.2=It is recommended to use this function off peak hours. UpdConfirmMsg.3=Do you want to continue? @@ -1390,7 +1390,7 @@ SettingPanel.DescriptionRatings=Textual Rating SettingPanel.MixedLineup=Show mixed Lineup SettingPanel.MyLineup=Compare Lineup SettingPanel.NumericRatings=Numeric Ratings -SettingPanel.Playerinformations=Player informations +SettingPanel.Playerinformations=Player information SettingPanel.ShowUnavailable=Show Unavailable SettingPanel.TacticDetail=Show Details SpecialEvent=SE @@ -1423,6 +1423,15 @@ ls.teamanalyzer.WINGER_SCORER=Winger scorer ls.teamanalyzer.WINGER_HEAD=Winger head ls.teamanalyzer.Adjusted=Adjusted ls.teamanalyzer.manmarking=Man marking +ls.teamanalyzer.info=Info +ls.teamanalyzer.manager=Manager: +ls.teamanalyzer.last_login=Last Login: +ls.teamanalyzer.bot=Bot: +ls.teamanalyzer.bot_since=since {0} +ls.teamanalyzer.league_position=League Position: +ls.teamanalyzer.na=- +ls.teamanalyzer.league_position_val={0} in {1} ({2}) + #PlayerCompare PlayerCompare=PlayerCompare @@ -1532,7 +1541,7 @@ ttok=Jump directly to the chosen date btLoadFile=Load hrf files ttLoadFile=Choose and show details from hrf files on your disk btDeleteFile=Delete hrf files -ttDeleteFile=Delete selected files from your harddisk +ttDeleteFile=Delete selected files from your hard disk btImport=Create importlist ttImport=Create a list of files to be imported ttReset=Clear tables @@ -1565,7 +1574,7 @@ ifa.imageBuilder.visited=Visited Countries ifa.imageBuilder.hosted=Hosted Countries ifa.imageBuilder.showHeader=Show Header ifa.imageBuilder.animGif=Animated GIF -ifa.imageBuilder.delay=Imagechange after (sec.): +ifa.imageBuilder.delay=Image change after (sec.): ifa.imageBuilder.flagsPerRow=Flags/Row: ifa.imageBuilder.brightness=Brightness: ifa.imageBuilder.grey=Grey