private void initModel(int matchtyp) { setOpaque(false); if (m_clTableModel == null) { m_clTableModel = UserColumnController.instance().getMatchesModel(); m_clTableModel.setValues( DBManager.instance() .getMatchesKurzInfo( HOVerwaltung.instance().getModel().getBasics().getTeamId(), matchtyp, false)); m_clTableSorter = new TableSorter(m_clTableModel, m_clTableModel.getDisplayedColumns().length - 1, -1); final ToolTipHeader header = new ToolTipHeader(getColumnModel()); header.setToolTipStrings(m_clTableModel.getTooltips()); header.setToolTipText(""); setTableHeader(header); setModel(m_clTableSorter); final TableColumnModel tableColumnModel = getColumnModel(); for (int i = 0; i < m_clTableModel.getColumnCount(); i++) { tableColumnModel.getColumn(i).setIdentifier(new Integer(i)); } int[][] targetColumn = m_clTableModel.getColumnOrder(); // Reihenfolge -> nach [][1] sortieren targetColumn = Helper.sortintArray(targetColumn, 1); if (targetColumn != null) { for (int i = 0; i < targetColumn.length; i++) { this.moveColumn( getColumnModel().getColumnIndex(Integer.valueOf(targetColumn[i][0])), targetColumn[i][1]); } } m_clTableSorter.addMouseListenerToHeaderInTable(this); m_clTableModel.setColumnsSize(getColumnModel()); } else { // Werte neu setzen m_clTableModel.setValues( DBManager.instance() .getMatchesKurzInfo( HOVerwaltung.instance().getModel().getBasics().getTeamId(), matchtyp, false)); m_clTableSorter.reallocateIndexes(); } setAutoResizeMode(JTable.AUTO_RESIZE_OFF); setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); setRowSelectionAllowed(true); m_clTableSorter.initsort(); }
private JPanel createTablePanel(boolean away) { JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); JLabel headerLabel = new JLabel(); if (away) { headerLabel.setText( HOVerwaltung.instance().getLanguageString("ifa.statisticsTable.header.away")); } else { headerLabel.setText( HOVerwaltung.instance().getLanguageString("ifa.statisticsTable.header.home")); } Font boldFont = headerLabel.getFont().deriveFont(headerLabel.getFont().getStyle() ^ Font.BOLD); headerLabel.setFont(boldFont); gbc.anchor = GridBagConstraints.NORTHWEST; gbc.insets = new Insets(10, 10, 3, 10); panel.add(headerLabel, gbc); final IfaTableModel tblModel = new IfaTableModel(); tblModel.setData(this.model, away); JTable table = new JTable(tblModel); IfaTableCellRenderer renderer = new IfaTableCellRenderer(); table.getColumnModel().getColumn(0).setCellRenderer(renderer); table.getColumnModel().getColumn(1).setCellRenderer(renderer); table.getColumnModel().getColumn(2).setCellRenderer(renderer); table.getColumnModel().getColumn(3).setCellRenderer(renderer); table.getColumnModel().getColumn(4).setCellRenderer(renderer); table.getColumnModel().getColumn(5).setCellRenderer(renderer); table.getColumnModel().getColumn(6).setCellRenderer(renderer); TableRowSorter<TableModel> sorter = new SummaryTableSorter<TableModel>(table.getModel()); table.setRowSorter(sorter); sorter.setComparator( 0, new Comparator<Country>() { @Override public int compare(Country o1, Country o2) { return o1.getName().compareTo(o2.getName()); } }); List<SortKey> list = new ArrayList<SortKey>(); list.add(new SortKey(5, SortOrder.DESCENDING)); sorter.setSortKeys(list); gbc.fill = GridBagConstraints.BOTH; gbc.gridy = 1; gbc.weightx = 1; gbc.weighty = 1; gbc.insets = new Insets(3, 10, 10, 10); panel.add(new JScrollPane(table), gbc); return panel; }
/** Gibt den Namen zu einer Bewertungzurück */ public static String getNameForTaktik(int taktikTyp) { switch (taktikTyp) { case TAKTIK_NORMAL: return ho.core.model.HOVerwaltung.instance().getLanguageString("ls.team.tactic.normal"); case TAKTIK_PRESSING: return ho.core.model.HOVerwaltung.instance().getLanguageString("ls.team.tactic.pressing"); case TAKTIK_KONTER: return ho.core.model.HOVerwaltung.instance() .getLanguageString("ls.team.tactic.counter-attacks"); case TAKTIK_MIDDLE: return ho.core.model.HOVerwaltung.instance() .getLanguageString("ls.team.tactic.attackinthemiddle"); case TAKTIK_WINGS: return ho.core.model.HOVerwaltung.instance() .getLanguageString("ls.team.tactic.attackonwings"); case TAKTIK_CREATIVE: return ho.core.model.HOVerwaltung.instance() .getLanguageString("ls.team.tactic.playcreatively"); case TAKTIK_LONGSHOTS: return ho.core.model.HOVerwaltung.instance().getLanguageString("ls.team.tactic.longshots"); default: return ho.core.model.HOVerwaltung.instance().getLanguageString("Unbestimmt"); } }
public static Transfer getTransfer(int playerId) { int teamId = HOVerwaltung.instance().getModel().getBasics().getTeamId(); String query = "Select price, BUYERID, sellerid, date from transfer WHERE PLAYERID=" + playerId + " and (BUYERID=" + teamId + " OR SELLERID=" + teamId + ")"; ResultSet rs = DBManager.instance().getAdapter().executeQuery(query); Transfer t = new Transfer(); try { while (rs.next()) { // TODO player might by bought/sold multiple times by the same team if (rs.getInt("BUYERID") == teamId) { t.purchasePrice = rs.getInt("price"); t.purchaseDate = rs.getDate("date"); } if (rs.getInt("sellerid") == teamId) { t.sellingPrice = rs.getInt("price"); t.sellingDate = rs.getDate("date"); } } } catch (SQLException e) { e.printStackTrace(); } return t; }
/** Gibt den Namen zu einer Bewertungzurück */ public static String getNameForEinstellung(int einstellung) { switch (einstellung) { case EINSTELLUNG_PIC: return ho.core.model.HOVerwaltung.instance() .getLanguageString("ls.team.teamattitude.playitcool"); case EINSTELLUNG_NORMAL: return ho.core.model.HOVerwaltung.instance() .getLanguageString("ls.team.teamattitude.normal"); case EINSTELLUNG_MOTS: return ho.core.model.HOVerwaltung.instance() .getLanguageString("ls.team.teamattitude.matchoftheseason"); default: return ho.core.model.HOVerwaltung.instance().getLanguageString("Unbestimmt"); } }
private void updatePenaltyTakersInLineup() { List<PenaltyTaker> takers = this.penaltyTakersView.getPenaltyTakers(); List<SpielerPosition> list = new ArrayList<SpielerPosition>(takers.size()); for (int i = 0; i < takers.size(); i++) { list.add( new SpielerPosition( ISpielerPosition.penaltyTaker1 + i, takers.get(i).getPlayer().getSpielerID(), ISpielerPosition.NORMAL)); } HOVerwaltung.instance().getModel().getAufstellung().setPenaltyTakers(list); }
private void initComponents() { this.tabbedPane = new JTabbedPane(); HOVerwaltung hov = HOVerwaltung.instance(); this.lineupPanel = new LineupPanel(); this.tabbedPane.addTab(hov.getLanguageString("Aufstellung"), this.lineupPanel); this.substitutionOverview = new SubstitutionOverview(hov.getModel().getAufstellung()); this.tabbedPane.addTab(hov.getLanguageString("subs.Title"), this.substitutionOverview); this.penaltyTakersView = new PenaltyTakersView(); this.penaltyTakersView.setPlayers(hov.getModel().getAllSpieler()); this.penaltyTakersView.setLineup(hov.getModel().getAufstellung()); this.tabbedPane.addTab( hov.getLanguageString("lineup.penaltytakers.tab.title"), this.penaltyTakersView); this.tabbedPane.addTab( hov.getLanguageString("lineup.upload.tab.title"), new UploadDownloadPanel()); setLayout(new BorderLayout()); add(this.tabbedPane, BorderLayout.CENTER); }
public final void refresh(MatchLineup lineup, MatchLineupPlayer player) { m_clMatchLineup = lineup; m_clMatchPlayer = player; if (player != null) { // Make sure this is on screen, we got a player to display if (m_bOnScreen == false) { addPanel(); } m_jbSpieler.setText( player.getSpielerName().substring(0, 1) + "." + player.getSpielerName().substring(player.getSpielerName().indexOf(" ") + 1)); int trickotnummer = 0; final ho.core.model.player.Spieler spieler = ho.core.model.HOVerwaltung.instance().getModel().getSpieler(player.getSpielerId()); if (spieler != null) { trickotnummer = spieler.getTrikotnummer(); m_jlSpecial.setIcon(ThemeManager.getIcon(HOIconName.SPECIAL[spieler.getSpezialitaet()])); } else { m_jlSpecial.setIcon(null); } m_jbSpieler.setIcon( ImageUtilities.getImage4Position(player.getId(), player.getTaktik(), trickotnummer)); m_jbSpieler.setEnabled(player.getSpielerId() > 0); m_jpSterne.setRating((float) player.getRating() * 2f, true); initLabel(player.getId(), player.getTaktik()); } else { clear(); } repaint(); }
public void setAway(boolean away) { this.away = away; FlagDisplayModel flagDisplayModel = new FlagDisplayModel(); int flagWidth; int brightness; String emblemPath; String headerText; boolean roundly; boolean grey; boolean showHeader; if (this.away) { flagWidth = ModuleConfig.instance() .getInteger(Config.VISITED_FLAG_WIDTH.toString(), Integer.valueOf(8)); emblemPath = ModuleConfig.instance().getString(Config.VISITED_EMBLEM_PATH.toString(), ""); headerText = ModuleConfig.instance() .getString( Config.VISITED_HEADER_TEXT.toString(), HOVerwaltung.instance().getLanguageString("ifa.visitedHeader.defaultText")); brightness = ModuleConfig.instance() .getInteger(Config.VISITED_BRIGHTNESS.toString(), Integer.valueOf(50)) .intValue(); grey = ModuleConfig.instance() .getBoolean(Config.VISITED_GREY.toString(), Boolean.FALSE) .booleanValue(); roundly = ModuleConfig.instance() .getBoolean(Config.VISITED_ROUNDLY.toString(), Boolean.FALSE) .booleanValue(); showHeader = ModuleConfig.instance() .getBoolean(Config.SHOW_VISITED_HEADER.toString(), Boolean.TRUE) .booleanValue(); } else { flagWidth = ModuleConfig.instance() .getInteger(Config.HOSTED_FLAG_WIDTH.toString(), Integer.valueOf(8)); emblemPath = ModuleConfig.instance().getString(Config.HOSTED_EMBLEM_PATH.toString(), ""); headerText = ModuleConfig.instance() .getString( Config.HOSTED_HEADER_TEXT.toString(), HOVerwaltung.instance().getLanguageString("ifa.hostedHeader.defaultText")); brightness = ModuleConfig.instance() .getInteger(Config.HOSTED_BRIGHTNESS.toString(), Integer.valueOf(50)) .intValue(); grey = ModuleConfig.instance() .getBoolean(Config.HOSTED_GREY.toString(), Boolean.FALSE) .booleanValue(); roundly = ModuleConfig.instance() .getBoolean(Config.HOSTED_ROUNDLY.toString(), Boolean.FALSE) .booleanValue(); showHeader = ModuleConfig.instance() .getBoolean(Config.SHOW_HOSTED_HEADER.toString(), Boolean.TRUE) .booleanValue(); } flagDisplayModel.setRoundFlag(roundly); flagDisplayModel.setGrey(grey); flagDisplayModel.setFlagWidth(flagWidth); flagDisplayModel.setBrightness(brightness); if (this.emblemPanel != null) { this.scrollPane.getViewport().remove(this.emblemPanel); } this.emblemPanel = new EmblemPanel(away, this.model, flagDisplayModel); if (!emblemPath.equals("")) { File file = new File(emblemPath); if (file.exists()) { ImageIcon imageIcon = new ImageIcon(emblemPath); if (imageIcon != null) { this.emblemPanel.setLogo(imageIcon); this.emblemPanel.setImagePath(emblemPath); } } } this.roundlyCheckBox.setSelected(roundly); this.greyColoredCheckBox.setSelected(grey); this.sizeSpinner.setValue(Integer.valueOf(flagWidth)); this.headerYesNoCheckBox.setSelected(showHeader); this.brightnessSlider.setValue(brightness); this.emblemPanel.setHeaderVisible(showHeader); this.emblemPanel.setHeaderText(headerText); this.headerTextField.setText(headerText); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridy = 1; gbc.weighty = 0.2; gbc.anchor = GridBagConstraints.NORTH; this.scrollPane.getViewport().add(this.emblemPanel, gbc); validate(); repaint(); }
/** * Convenience method * * @param key * @return */ private static String getLangString(String key) { return HOVerwaltung.instance().getLanguageString(key); }
private void refreshView() { this.substitutionOverview.setLineup(HOVerwaltung.instance().getModel().getAufstellung()); this.penaltyTakersView.setPlayers(HOVerwaltung.instance().getModel().getAllSpieler()); this.penaltyTakersView.setLineup(HOVerwaltung.instance().getModel().getAufstellung()); }
protected final void initLabel(int posid, byte taktik) { switch (posid) { case ISpielerPosition.setPieces: { m_jlPosition.setText(HOVerwaltung.instance().getLanguageString("match.setpiecestaker")); break; } case ISpielerPosition.captain: { m_jlPosition.setText(HOVerwaltung.instance().getLanguageString("Spielfuehrer")); break; } case ISpielerPosition.substDefender: { m_jlPosition.setText( HOVerwaltung.instance().getLanguageString("Reserve") + " " + HOVerwaltung.instance().getLanguageString("defender")); break; } case ISpielerPosition.substForward: { m_jlPosition.setText( HOVerwaltung.instance().getLanguageString("Reserve") + " " + HOVerwaltung.instance().getLanguageString("ls.player.position.forward")); break; } case ISpielerPosition.substWinger: { m_jlPosition.setText( HOVerwaltung.instance().getLanguageString("Reserve") + " " + HOVerwaltung.instance().getLanguageString("ls.player.position.winger")); break; } case ISpielerPosition.substInnerMidfield: { m_jlPosition.setText( HOVerwaltung.instance().getLanguageString("Reserve") + " " + HOVerwaltung.instance() .getLanguageString("ls.player.position.innermidfielder")); break; } case ISpielerPosition.substKeeper: { m_jlPosition.setText( HOVerwaltung.instance().getLanguageString("Reserve") + " " + HOVerwaltung.instance().getLanguageString("ls.player.position.keeper")); break; } default: { // Special check here for the replaced players, we got a range of at // least 3... if ((posid >= ISpielerPosition.ausgewechselt) && (posid <= ISpielerPosition.ausgewechseltEnd)) { m_jlPosition.setText(HOVerwaltung.instance().getLanguageString("Ausgewechselt")); break; } else { m_jlPosition.setText( ho.core.model.player.SpielerPosition.getNameForPosition( ho.core.model.player.SpielerPosition.getPosition(posid, taktik))); } } } }
/** Erzeugt die Komponenten */ private final void initComponents() { final GridBagLayout layout = new GridBagLayout(); final GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 1; constraints.weighty = 0; constraints.insets = new Insets(1, 1, 1, 1); setLayout(layout); setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); constraints.gridx = 0; constraints.gridy = 0; m_jlPosition.setPreferredSize(new Dimension(100, 10)); layout.setConstraints(m_jlPosition, constraints); add(m_jlPosition); final JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createLineBorder(Color.GRAY)); panel.setBackground(ColorLabelEntry.BG_STANDARD); panel.setOpaque(true); m_jbSpieler.setToolTipText( ho.core.model.HOVerwaltung.instance().getLanguageString("tt_Spiel_Spielerdetails")); m_jbSpieler.setHorizontalAlignment(SwingConstants.LEFT); m_jbSpieler.setMargin(new Insets(0, 1, 0, 1)); m_jbSpieler.setPreferredSize(new Dimension(125, 15)); m_jbSpieler.setFocusPainted(false); m_jbSpieler.setEnabled(false); m_jbSpieler.addActionListener(this); m_jbSpieler.setBackground(ColorLabelEntry.BG_STANDARD); m_jbSpieler.setOpaque(true); m_jbSpieler.setBorder(BorderFactory.createEmptyBorder()); panel.add(m_jbSpieler, BorderLayout.CENTER); panel.add(m_jlSpecial, BorderLayout.EAST); constraints.gridx = 0; constraints.gridy = 1; constraints.weighty = 0.5; // Give extra vertical space to the player // button constraints.gridwidth = 1; layout.setConstraints(panel, constraints); add(panel); switch (m_iPositionsID) { case ISpielerPosition.keeper: case ISpielerPosition.rightBack: case ISpielerPosition.leftBack: case ISpielerPosition.rightCentralDefender: case ISpielerPosition.middleCentralDefender: case ISpielerPosition.leftCentralDefender: case ISpielerPosition.rightInnerMidfield: case ISpielerPosition.centralInnerMidfield: case ISpielerPosition.leftInnerMidfield: case ISpielerPosition.leftWinger: case ISpielerPosition.rightWinger: case ISpielerPosition.rightForward: case ISpielerPosition.centralForward: case ISpielerPosition.leftForward: case ISpielerPosition.ausgewechselt: { constraints.gridx = 0; constraints.gridy = 2; constraints.weighty = 0; // No vertical stretch for this one final JComponent component = m_jpSterne.getComponent(false); layout.setConstraints(component, constraints); add(component); setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT)); break; } default: setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT_REDUCED)); } }
/** Initializes the state of this instance. */ private void jbInit() { jLabel1.setText(HOVerwaltung.instance().getLanguageString("ls.match.id")); setLayout(new GridBagLayout()); final GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 1.0; constraints.weighty = 1.0; constraints.gridx = 1; constraints.gridy = 1; add(jLabel1, constraints); constraints.gridx = 2; add(matchId, constraints); constraints.gridx = 1; constraints.gridy = 3; normal.setSelected(true); radioGroup.add(normal); add(normal, constraints); constraints.gridy = 4; radioGroup.add(tournament); add(tournament, constraints); constraints.gridy = 6; add(downloadButton, constraints); constraints.gridy = 7; add(status, constraints); downloadButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int id = matchId.getValue(); MatchType type = MatchType.LEAGUE; if (tournament.isSelected()) { type = MatchType.TOURNAMENTGROUP; } // if (id == 0) { // // status.setText(HOVerwaltung.instance().getLanguageString("ImportError")); // // return; // } if (OnlineWorker.downloadMatchData(id, type, false)) { Matchdetails md = DBManager.instance().getMatchDetails(id); if (md.getFetchDatum() != null) { status.setText(HOVerwaltung.instance().getLanguageString("ImportOK")); matchId.setText(""); } else { status.setText(HOVerwaltung.instance().getLanguageString("ImportError")); } } } }); }
/** * A panel that allows the user to download a new match from HO * * @author <a href=mailto:[email protected]>Massimiliano Amato</a> */ public class DownloadPanel extends JPanel { // ~ Instance fields ---------------------------------------------------------------------------- /** */ private static final long serialVersionUID = -3212179990708350342L; String[] matchTypes = { HOVerwaltung.instance().getLanguageString("NormalMatch"), HOVerwaltung.instance().getLanguageString("TournamentMatch") }; /** Download Button */ JButton downloadButton = new JButton(HOVerwaltung.instance().getLanguageString("ls.button.download")); /** Description label */ JLabel jLabel1 = new JLabel(); /** Status label */ JLabel status = new JLabel(); /** The matchid text field */ NumberTextField matchId = new NumberTextField(10); JRadioButton normal = new JRadioButton(HOVerwaltung.instance().getLanguageString("NormalMatch")); JRadioButton tournament = new JRadioButton(HOVerwaltung.instance().getLanguageString("TournamentMatch")); ButtonGroup radioGroup = new ButtonGroup(); // ~ Constructors ------------------------------------------------------------------------------- /** Constructs a new instance. */ public DownloadPanel() { jbInit(); } // ~ Methods ------------------------------------------------------------------------------------ /** Initializes the state of this instance. */ private void jbInit() { jLabel1.setText(HOVerwaltung.instance().getLanguageString("ls.match.id")); setLayout(new GridBagLayout()); final GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 1.0; constraints.weighty = 1.0; constraints.gridx = 1; constraints.gridy = 1; add(jLabel1, constraints); constraints.gridx = 2; add(matchId, constraints); constraints.gridx = 1; constraints.gridy = 3; normal.setSelected(true); radioGroup.add(normal); add(normal, constraints); constraints.gridy = 4; radioGroup.add(tournament); add(tournament, constraints); constraints.gridy = 6; add(downloadButton, constraints); constraints.gridy = 7; add(status, constraints); downloadButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int id = matchId.getValue(); MatchType type = MatchType.LEAGUE; if (tournament.isSelected()) { type = MatchType.TOURNAMENTGROUP; } // if (id == 0) { // // status.setText(HOVerwaltung.instance().getLanguageString("ImportError")); // // return; // } if (OnlineWorker.downloadMatchData(id, type, false)) { Matchdetails md = DBManager.instance().getMatchDetails(id); if (md.getFetchDatum() != null) { status.setText(HOVerwaltung.instance().getLanguageString("ImportOK")); matchId.setText(""); } else { status.setText(HOVerwaltung.instance().getLanguageString("ImportError")); } } } }); } }