Skip to content

Commit

Permalink
remove old code (commented)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsbrenk committed Nov 2, 2024
1 parent afacfa5 commit ee9b83c
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 176 deletions.
38 changes: 30 additions & 8 deletions src/main/java/core/gui/comp/table/UserColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import javax.swing.*;
import javax.swing.table.TableColumn;

/**
* User configuration of table columns
*/
public abstract class UserColumn {

//~ Instance fields ----------------------------------------------------------------------------
Expand All @@ -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);
}
Expand All @@ -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
Expand Down
56 changes: 0 additions & 56 deletions src/main/java/module/matches/MatchesTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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();
// }
}
79 changes: 14 additions & 65 deletions src/main/java/module/matches/statistics/MatchesOverviewTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,88 +10,37 @@
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 {
tableModel.setValues(DBManager.instance().getMatchesOverviewValues(iMatchType, UserParameter.instance().matchLocation));
}

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();
}
}

}
48 changes: 1 addition & 47 deletions src/main/java/module/playerOverview/PlayerOverviewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
*/
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -232,4 +186,4 @@ private void addTableSelectionListeners() {
public void storeUserSettings() {
playerOverviewTable.getPlayerTableModel().storeUserSettings();
}
}
}

0 comments on commit ee9b83c

Please sign in to comment.