Skip to content

Commit

Permalink
getting id for table column management
Browse files Browse the repository at this point in the history
  • Loading branch information
nicol authored and nicol committed Jan 20, 2025
1 parent f967356 commit ce979ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/main/java/org/magic/gui/abstracts/GenericTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.logging.log4j.Logger;
import org.magic.services.logging.MTGLogger;

import nl.basjes.parse.useragent.yauaa.shaded.org.apache.commons.lang3.ArrayUtils;


public class GenericTableModel<T> extends AbstractTableModel {

private static final long serialVersionUID = 1L;
Expand All @@ -37,6 +39,10 @@ public GenericTableModel(String...columnName) {
changed=false;
}

public String getId()
{
return String.valueOf(Math.abs(ArrayUtils.toString(columns).toString().hashCode()));
}

public void setDefaultHiddenComlumns(int... nums)
{
Expand Down Expand Up @@ -236,5 +242,6 @@ public boolean isCellEditable(int row, int column) {





}
7 changes: 6 additions & 1 deletion src/main/java/org/magic/services/tools/UITools.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ public static JXTable createNewTable(TableModel mod, boolean enableFilter)
var table = new JXTable();
if(mod!=null)
table.setModel(mod);


if(mod instanceof GenericTableModel gtm)
table.setName(gtm.getId());


table.setDefaultRenderer(Boolean.class, new BooleanCellEditorRenderer());
table.setDefaultRenderer(Double.class, new DoubleCellEditorRenderer());
Expand Down Expand Up @@ -312,7 +317,7 @@ public void columnPropertyChange(PropertyChangeEvent event) {
if(event.getPropertyName().equals("visible") && MTGControler.getInstance().isLoaded())
{
var tce = (TableColumnExt)event.getSource();
logger.trace("{} {} {}",tce.getModelIndex(),tce.getIdentifier(),Boolean.valueOf(event.getNewValue().toString()));
logger.trace("{} {} {} {}",table.getName(),tce.getModelIndex(),tce.getIdentifier(),Boolean.valueOf(event.getNewValue().toString()));
}
}
});
Expand Down

0 comments on commit ce979ca

Please sign in to comment.