diff --git a/src/main/java/core/gui/comp/table/UserColumn.java b/src/main/java/core/gui/comp/table/UserColumn.java index d5140249b..ef620fc8a 100644 --- a/src/main/java/core/gui/comp/table/UserColumn.java +++ b/src/main/java/core/gui/comp/table/UserColumn.java @@ -5,6 +5,9 @@ import javax.swing.*; import javax.swing.table.TableColumn; +/** + * User configuration of table columns + */ public abstract class UserColumn { //~ Instance fields ---------------------------------------------------------------------------- @@ -14,30 +17,49 @@ public abstract class UserColumn { /** columnName properties representation, not display!! **/ protected String columnName; - /** tooltip properties representation, not display!! **/ + /** tooltip properties representation **/ protected String tooltip; - /** mininmum width of the column **/ + /** minimum width of the column **/ protected int minWidth; /** preferred width of the column **/ protected int preferredWidth; - /** index of the column in the JTable. position**/ + /** index of the column in the table **/ protected int index = 0; - /** if a column is shown in the jtable. Only displayed columns are saved in db. **/ + /** if a column is shown in the table. Only displayed columns are saved in db. **/ protected boolean display = false; + /** + * Sort order of the column + */ SortOrder sortOrder; + + /** + * Sort priority + * Defines the order of the sort keys if more than one column are sorted + */ Integer sortPriority; + /** + * Constructor of an user column + * @param id column identifier has to be unique in one table + * @param name Column name is displayed in the column header + * @param tooltip Column header tool tip + */ protected UserColumn(int id,String name, String tooltip){ this.id = id; columnName = name; this.tooltip = tooltip; } + /** + * Constructor of an user column + * @param id column identifier has to be unique in one table + * @param name Column name and tool tip + */ protected UserColumn(int id,String name){ this(id,name,name); } @@ -56,16 +78,16 @@ public final String getColumnName() { } /** - * return id + * Return id * @return int */ public final int getId() { return id; } - public void setId(int v){ - this.id = v; - } +// public void setId(int v){ +// this.id = v; +// } /** * returns the language dependency tooltip of the column diff --git a/src/main/java/module/matches/MatchesTable.java b/src/main/java/module/matches/MatchesTable.java index 6764ddae0..874da6da0 100644 --- a/src/main/java/module/matches/MatchesTable.java +++ b/src/main/java/module/matches/MatchesTable.java @@ -21,24 +21,11 @@ final class MatchesTable extends JTable { var matches = DBManager.instance().getMatchesKurzInfo(HOVerwaltung.instance().getModel().getBasics().getTeamId(), matchtyp, UserParameter.instance().matchLocation).toArray(new MatchKurzInfo[0]); m_clTableModel.setValues(matches); m_clTableModel.initTable(this); -// initModel(matchtyp, UserParameter.instance().matchLocation); -// getTableHeader().setDefaultRenderer(new TableHeaderRenderer1(this)); -// getTableHeader().setFont(getTableHeader().getFont().deriveFont(Font.BOLD)); -// setSelectionBackground(HODefaultTableCellRenderer.SELECTION_BG); setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } public void storeUserSettings() { m_clTableModel.storeUserSettings(); -// final UserColumn[] columns = m_clTableModel.getDisplayedColumns(); -// final TableColumnModel tableColumnModel = getColumnModel(); -// for (int i = 0; i < columns.length; i++) { -// columns[i].setIndex(convertColumnIndexToView(i)); -// columns[i].setPreferredWidth(tableColumnModel.getColumn(convertColumnIndexToView(i)) -// .getWidth()); -// } -// m_clTableModel.setCurrentValueToColumns(columns); -// DBManager.instance().saveHOColumnModel(m_clTableModel); } public void refresh(int iMatchType, MatchLocation matchLocation) { @@ -47,10 +34,6 @@ public void refresh(int iMatchType, MatchLocation matchLocation) { m_clTableModel.fireTableDataChanged(); } -// protected TableSorter getSorter() { -// return m_clTableSorter; -// } - void markiereMatch(int matchid) { final int row = m_clTableModel.getRowIndexOfMatch(matchid); if (row > -1) { @@ -63,43 +46,4 @@ void markiereMatch(int matchid) { public MatchKurzInfo getMatchAtRow(int selectedRowNumber) { return m_clTableModel.getMatchAtRow(selectedRowNumber); } - -// private void initModel(int iMatchType, MatchLocation matchLocation) { -// setOpaque(false); -// -// if (m_clTableModel == null) { -// m_clTableModel = UserColumnController.instance().getMatchesModel(); -// var matches = DBManager.instance().getMatchesKurzInfo(HOVerwaltung.instance().getModel().getBasics().getTeamId(), iMatchType, matchLocation).toArray(new MatchKurzInfo[0]); -// m_clTableModel.setValues(matches); -// 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(i); -//// } -// -// m_clTableModel.initColumnOrder(this); -// m_clTableSorter.addMouseListenerToHeaderInTable(this); -// m_clTableModel.setColumnsSize(getColumnModel()); -// } else { -// // Reset Values of the matches table in matches module after selection change -// m_clTableModel.setValues(DBManager.instance().getMatchesKurzInfo( -// HOVerwaltung.instance().getModel().getBasics().getTeamId(), iMatchType, matchLocation).toArray(new MatchKurzInfo[0])); -// m_clTableSorter.reallocateIndexes(); -// } -// -// setAutoResizeMode(JTable.AUTO_RESIZE_OFF); -// setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); -// setRowSelectionAllowed(true); -// -// m_clTableSorter.initsort(); -// } } diff --git a/src/main/java/module/matches/statistics/MatchesOverviewTable.java b/src/main/java/module/matches/statistics/MatchesOverviewTable.java index ef0a2c821..40fd95265 100644 --- a/src/main/java/module/matches/statistics/MatchesOverviewTable.java +++ b/src/main/java/module/matches/statistics/MatchesOverviewTable.java @@ -10,14 +10,14 @@ import javax.swing.ListSelectionModel; public class MatchesOverviewTable extends JTable { - - private final MatchesOverviewColumnModel tableModel; - - public MatchesOverviewTable(int iMatchType){ - super(); + + private final MatchesOverviewColumnModel tableModel; + + public MatchesOverviewTable(int iMatchType) { + super(); setOpaque(false); tableModel = UserColumnController.instance().getMatchesOverview1ColumnModel(); - if(iMatchType == MatchesPanel.ALL_GAMES || iMatchType == MatchesPanel.OTHER_TEAM_GAMES){ + if (iMatchType == MatchesPanel.ALL_GAMES || iMatchType == MatchesPanel.OTHER_TEAM_GAMES) { MatchesOverviewRow[] tmp = new MatchesOverviewRow[0]; tableModel.setValues(tmp); } else { @@ -25,73 +25,22 @@ public MatchesOverviewTable(int iMatchType){ } tableModel.initTable(this); - - - setDefaultRenderer(Object.class,new MatchesOverviewRenderer()); - setDefaultRenderer(Integer.class,new MatchesOverviewRenderer()); -// getTableHeader().setDefaultRenderer(new TableHeaderRenderer1(this)); -// getTableHeader().setFont(getTableHeader().getFont().deriveFont(Font.BOLD)); + setDefaultRenderer(Object.class, new MatchesOverviewRenderer()); + setDefaultRenderer(Integer.class, new MatchesOverviewRenderer()); setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - } -// -// private void initModel(int iMatchType, MatchLocation matchLocation) { -// setOpaque(false); -// -// if (tableModel == null) { -// tableModel = UserColumnController.instance().getMatchesOverview1ColumnModel(); -// if(iMatchType == MatchesPanel.ALL_GAMES || iMatchType == MatchesPanel.OTHER_TEAM_GAMES){ -// MatchesOverviewRow[] tmp = new MatchesOverviewRow[0]; -// tableModel.setValues(tmp); -// } else { -// tableModel.setValues(DBManager.instance().getMatchesOverviewValues(iMatchType, matchLocation)); -// } -// -// final ToolTipHeader header = new ToolTipHeader(getColumnModel()); -// header.setToolTipStrings(tableModel.getTooltips()); -// header.setToolTipText(""); -// setTableHeader(header); -// setModel(tableModel); -// -//// final TableColumnModel tableColumnModel = getColumnModel(); -//// -//// for (int i = 0; i < tableModel.getColumnCount(); i++) { -//// tableColumnModel.getColumn(i).setIdentifier(i); -//// } -// -// tableModel.initColumnOrder(this); -// //m_clTableSorter.addMouseListenerToHeaderInTable(this); -// tableModel.setColumnsSize(getColumnModel()); -// } else { -// tableModel.setValues(DBManager.instance().getMatchesOverviewValues(iMatchType, matchLocation)); -// } -// -// setAutoResizeMode(JTable.AUTO_RESIZE_OFF); -// setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); -// setRowSelectionAllowed(true); -// -// //m_clTableSorter.initsort(); -// } + } - public final void storeUserSettings(){ + public final void storeUserSettings() { tableModel.storeUserSettings(); -// final UserColumn[] columns = tableModel.getDisplayedColumns(); -// final TableColumnModel tableColumnModel = getColumnModel(); -// for (int i = 0; i < columns.length; i++) { -// columns[i].setIndex(convertColumnIndexToView(i)); -// columns[i].setPreferredWidth(tableColumnModel.getColumn(convertColumnIndexToView(i)).getWidth()); -// } -// tableModel.setCurrentValueToColumns(columns); -// DBManager.instance().saveHOColumnModel(tableModel); } - + public void refresh(int iMatchType, MatchLocation matchLocation) { - if(iMatchType == MatchesPanel.ALL_GAMES || iMatchType == MatchesPanel.OTHER_TEAM_GAMES){ - MatchesOverviewRow[] tmp = new MatchesOverviewRow[0]; - tableModel.setValues(tmp); + if (iMatchType == MatchesPanel.ALL_GAMES || iMatchType == MatchesPanel.OTHER_TEAM_GAMES) { + MatchesOverviewRow[] tmp = new MatchesOverviewRow[0]; + tableModel.setValues(tmp); } else { tableModel.setValues(DBManager.instance().getMatchesOverviewValues(iMatchType, matchLocation)); tableModel.fireTableDataChanged(); } } - } diff --git a/src/main/java/module/playerOverview/PlayerOverviewPanel.java b/src/main/java/module/playerOverview/PlayerOverviewPanel.java index edb49c367..794877ec9 100644 --- a/src/main/java/module/playerOverview/PlayerOverviewPanel.java +++ b/src/main/java/module/playerOverview/PlayerOverviewPanel.java @@ -38,7 +38,6 @@ public PlayerOverviewPanel() { * the id of the player to select. */ public void setPlayer(Player player) { -// playerOverviewTableName.setPlayer(player.getPlayerId()); playerOverviewTable.selectPlayer(player.getPlayerId()); playerDetailsPanel.setPlayer(player); spielerTrainingsSimulatorPanel.setSpieler(player); @@ -55,12 +54,6 @@ public final int[] getDividerLocations() { return locations; } -// public final void saveColumnOrder() { -// playerOverviewTable.saveColumnOrder(); -// } - - // ----------------------Refresh-- - /** * Refresh, if a player is changed in the lineup */ @@ -158,50 +151,11 @@ private Component initPlayersTable() { // table with the player's details playerOverviewTable = new PlayerOverviewTable(); - -// // table with the player's name -// playerOverviewTableName = new LineupPlayersTableNameColumn(playerOverviewTable.getPlayerTableModel()); -// -// JScrollPane scrollpane = new JScrollPane(playerOverviewTableName); -// scrollpane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); -// scrollpane.setPreferredSize(new Dimension(170, 100)); -// -// JScrollPane scrollpane2 = new JScrollPane(playerOverviewTable); -// scrollpane2.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE); -// scrollpane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); -// -// final JScrollBar bar = scrollpane.getVerticalScrollBar(); -// final JScrollBar bar2 = scrollpane2.getVerticalScrollBar(); -// -// // setVisible(false) does not have an effect, so we set the size to -// // false. We can't disable the scrollbar with VERTICAL_SCROLLBAR_NEVER -// // because this will disable mouse wheel scrolling. -// bar.setPreferredSize(new Dimension(0, 0)); -// -// // Synchronize vertical scrolling -// AdjustmentListener adjustmentListener = e -> { -// if (e.getSource() == bar2) { -// bar.setValue(e.getValue()); -// } else { -// bar2.setValue(e.getValue()); -// } -// }; -// bar.addAdjustmentListener(adjustmentListener); -// bar2.addAdjustmentListener(adjustmentListener); -// -// JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false); -// splitPane.setLeftComponent(scrollpane); -// splitPane.setRightComponent(scrollpane2); -// splitPane.setOneTouchExpandable(true); -// splitPane.setDividerLocation(UserParameter.instance().playerTablePanel_horizontalSplitPane); - overviewPanel.add(playerOverviewTable.getContainerComponent(), BorderLayout.CENTER); - TeamSummaryModel teamSummaryModel = new TeamSummaryModel(); teamSummaryModel.setPlayers(HOVerwaltung.instance().getModel().getCurrentPlayers()); teamSummaryPanel = new TeamSummaryPanel(teamSummaryModel); overviewPanel.add(teamSummaryPanel, BorderLayout.SOUTH); - return overviewPanel; } @@ -232,4 +186,4 @@ private void addTableSelectionListeners() { public void storeUserSettings() { playerOverviewTable.getPlayerTableModel().storeUserSettings(); } -} +} \ No newline at end of file