This commit is contained in:
dragonmacher 2023-01-03 12:46:26 -05:00
parent cde6a910a1
commit 38cd70f400

View File

@ -132,6 +132,7 @@ public class GTable extends JTable {
*/
public GTable() {
// default constructor
addMouseListener(selectRowListener);
}
/**
@ -140,12 +141,13 @@ public class GTable extends JTable {
*/
public GTable(TableModel dm) {
super(dm);
addMouseListener(selectRowListener);
}
@Override
public void setUI(TableUI ui) {
super.setUI(ui);
init();
initUi();
}
public void setVisibleRowCount(int visibleRowCount) {
@ -209,7 +211,7 @@ public class GTable extends JTable {
/**
* Allows subclasses to change the type of {@link AutoLookup} created by this table
* @return the auto lookup
* @return the auto lookup
*/
protected AutoLookup createAutoLookup() {
return new GTableAutoLookup(this);
@ -278,7 +280,7 @@ public class GTable extends JTable {
/**
* Returns the {@link SelectionManager} in use by this GTable. <code>null</code> is returned
* if the user has installed their own {@link ListSelectionModel}.
*
*
* @return the selection manager
*/
public SelectionManager getSelectionManager() {
@ -340,11 +342,11 @@ public class GTable extends JTable {
/**
* Sets the column in which auto-lookup will be enabled.
*
*
* <p>Note: calling this method with a valid column index will disable key binding support
* of actions. See {@link #setActionsEnabled(boolean)}. Passing an invalid column index
* will disable the auto-lookup feature.
*
*
* @param lookupColumn the column in which auto-lookup will be enabled
*/
public void setAutoLookupColumn(int lookupColumn) {
@ -382,9 +384,9 @@ public class GTable extends JTable {
* Ctrl-C</code>, will work at all times. Finally, if true is passed to this
* method, then the {@link #setAutoLookupColumn(int) auto lookup} feature is
* disabled.
*
*
* <p>The default state is for actions to be disabled.
*
*
* @param b true allows keyboard actions to pass up the component hierarchy.
*/
public void setActionsEnabled(boolean b) {
@ -392,12 +394,12 @@ public class GTable extends JTable {
}
/**
* Returns true if key strokes are used to trigger actions.
*
* <p>This method has a relationship with {@link #setAutoLookupColumn(int)}. If this method
* returns <code>true</code>, then the auto-lookup feature is disabled. If this method
* Returns true if key strokes are used to trigger actions.
*
* <p>This method has a relationship with {@link #setAutoLookupColumn(int)}. If this method
* returns <code>true</code>, then the auto-lookup feature is disabled. If this method
* returns <code>false</code>, then the auto-lookup may or may not be enabled.
*
*
* @return true if key strokes are used to trigger actions
* @see #setActionsEnabled(boolean)
* @see #setAutoLookupColumn(int)
@ -409,7 +411,7 @@ public class GTable extends JTable {
/**
* Enables or disables auto-edit. When enabled, the user can start typing to trigger an
* edit of an editable table cell.
*
*
* @param allowAutoEdit true for auto-editing
*/
public void setAutoEditEnabled(boolean allowAutoEdit) {
@ -435,7 +437,10 @@ public class GTable extends JTable {
KeyBindingUtils.registerAction(this, ks, action, JComponent.WHEN_FOCUSED);
}
private void init() {
// note: this is called *before* this object's instance fields have been initialized
private void initUi() {
isInitialized = false;
setBackground(Colors.BACKGROUND);
@ -455,9 +460,6 @@ public class GTable extends JTable {
setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
removeMouseListener(selectRowListener);
addMouseListener(selectRowListener);
removeActionKeyStrokes();
// updating the row height requires the 'isInitialized' to be set, so do it first
@ -470,10 +472,10 @@ public class GTable extends JTable {
}
private void removeActionKeyStrokes() {
//
//
// We remove these keybindings as we have replaced Java's version with our own. To be
// thorough, we should really clear all table keybindings, which would ensure that any
// user-provided key stroke would not get blocked by the table. At the time of writing,
// user-provided key stroke would not get blocked by the table. At the time of writing,
// there are alternate key bindings for copy that do not use this table's copy action.
// Also, there are many other built-in keybindings for table navigation, which we do not
// wish to override. For now, just clear these. We can clear others if they become
@ -618,12 +620,12 @@ public class GTable extends JTable {
@Override
public TableCellRenderer getDefaultRenderer(Class<?> columnClass) {
if (columnClass == null) {
//
//
// Unusual Code Alert!
// Normally we would like to do as the JTable and just return null here. However,
// Normally we would like to do as the JTable and just return null here. However,
// some client code (JTable.AccessibleJTable) does not check for null in this case.
// Prevent that code from exploding by returning a suitable non-null default.
//
//
return super.getDefaultRenderer(String.class);
}
@ -678,10 +680,6 @@ public class GTable extends JTable {
setIntercellSpacing(new Dimension(0, 0));
}
/**
* Overridden in order to set the column header renderer on newly created columns.
* @see javax.swing.JTable#createDefaultColumnsFromModel()
*/
@Override
public void createDefaultColumnsFromModel() {
@ -890,11 +888,11 @@ public class GTable extends JTable {
}
/**
* Performs custom work to locate renderers for special table model types. This method allows
* clients to bypass the {@link #getCellRenderer(int, int)}, which is sometimes overridden by
* subclasses to return a hard-coded renderer. In that case, some clients still want a way to
* Performs custom work to locate renderers for special table model types. This method allows
* clients to bypass the {@link #getCellRenderer(int, int)}, which is sometimes overridden by
* subclasses to return a hard-coded renderer. In that case, some clients still want a way to
* perform normal cell renderer lookup.
*
*
* @param row the row
* @param col the column
* @return the cell renderer
@ -914,7 +912,7 @@ public class GTable extends JTable {
/**
* Performs custom work to locate header renderers for special table model types. The headers
* are located and installed at the time the table's model is set.
*
*
* @param col the column
* @return the header cell renderer
*/
@ -931,8 +929,8 @@ public class GTable extends JTable {
}
/**
* If you just begin typing into an editable cell in a JTable, then the cell editor will be
* displayed. However, the editor component will not have a focus. This method has been
* If you just begin typing into an editable cell in a JTable, then the cell editor will be
* displayed. However, the editor component will not have a focus. This method has been
* overridden to request focus on the editor component.
*
* @see javax.swing.JTable#editCellAt(int, int)
@ -1091,13 +1089,13 @@ public class GTable extends JTable {
}
/**
* Maintain a {@link docking.widgets.table.GTableCellRenderingData} object associated with each
* column that maintains some state and references to useful data. These objects are created as
* needed, stored by the table for convenient re-use and to prevent per-cell creation, and
* Maintain a {@link docking.widgets.table.GTableCellRenderingData} object associated with each
* column that maintains some state and references to useful data. These objects are created as
* needed, stored by the table for convenient re-use and to prevent per-cell creation, and
* cleared when columns are removed from the table.
* <p>
* Row and cell state is cleared before returning to the caller to ensure consistent state;
* when the client is done rendering a cell, row and cell state should also be cleared to
* Row and cell state is cleared before returning to the caller to ensure consistent state;
* when the client is done rendering a cell, row and cell state should also be cleared to
* minimize references.
*
* @param viewColumn the columns' view index
@ -1130,9 +1128,9 @@ public class GTable extends JTable {
//==================================================================================================
/**
* A method that subclasses can override to signal that they wish not to have this table's
* A method that subclasses can override to signal that they wish not to have this table's
* built-in popup actions. Subclasses will almost never need to override this method.
*
*
* @return true if popup actions are supported
*/
protected boolean supportsPopupActions() {
@ -1422,7 +1420,7 @@ public class GTable extends JTable {
//==================================================================================================
// Inner Classes
//==================================================================================================
//==================================================================================================
private class MyTableColumnModelListener implements TableColumnModelListener {
@Override