Sorted list after loaded into the table not in proper order as expected in InteliJ IDE 2020 versions

Answered

Our plugin uses table to show the results. when click on the table header according to the column which is clicked by user the results on the table get sorted. Sorting the results working perfectly. After sorted the outcome in the table differs from actual results in IntellIJ IDE 2020 version.Before IntelliJ IDE 2020 version[2019,2018,..] the table renders sorted results without any issue but After 2020 version the results are not shows in proper order.

class RenderTable{

JXTable table;

table.getTableHeader().addMouseListener(new MouseAdapter() {
   @Override
  public void mouseClicked(MouseEvent e) {
       //Using comparator for sorting
      refresh();
  }
}

public void refresh() {
    table.setModel(new DataModel(headerList, sortedList));
    for (TableColumn column : table.getColumns()) {
          column.setCellRenderer(new TextCellRenderer());
    }
}

private class TextCellRenderer extends DefaultTableCellRenderer {

private JLabel label;

public FlawTextCellRenderer() {
     label = new JLabel();
}

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

       //adding some attributes to label

       return label;

   }
}

}

public class DataModel extends AbstractTableModel {

    List headerList;

    List resultList;

    DataModel(List headerList, List resultList){

       this.headerList = resultList;

       this.resultList = resultList;

    }

}

 

Result in 2019 IntelliJ version sorting without any issues[Order: Ascending, descending]

Ascending order

Desending order

 

Results in 2020 intelliJ version

click on the header column [ID] the column not in sorted order but behind the scene the results are sorted in Ascending order.

 

0
10 comments

This might or might not be an issue with JXTable. Please create a fully working minimal sample to reproduce and link it.

0

Thanks Yann. i'll try to attach a demo project.

0

Here is the link for the demo project. It has the exact problem we are facing now

in IntelliJ 2020.1

https://drive.google.com/file/d/16zMAbjEjOhgaAXMyemseGrnM54FBJXj-/view?usp=drivesdk 

0

Thanks for providing the sample, I reproduced the problem occurs in 2020.1 but not in 2019.3

But looking at the sample project, it seems sorting should be done different as described in https://pirlwww.lpl.arizona.edu/resources/guide/software/SwingX/org/jdesktop/swingx/JXTable.html "Sorting and Filtering" section. It seems it's using String instead of BigInteger for comparing values, so maybe setting explicit Comparator(s) is necessary.

0

The comparator producing expected results. I checked the model as well. It contains sorted list but the results in the table not updated in sorted order. Do i need to update sorting function mention in the posted? .But our implementation working other than the IntelliJ 2020.* versions.

0
Avatar
Permanently deleted user

JXTable provides its own alphanumeric sorting (do you see sorting marker in table header?) and ignores your sorting. Please try JBTable or even standard JTable instead.

1

Thank you for your suggestion. Currently migrating to JBTable. While migrating we are facing some difficulties .The major problem is columncontrol(new ColumnControlButton(table)) not available in the JBTable. In the table there are more than 30 columns so we are hiding most of them. If the user need to see the column they can select necessary column through the ColumnControlButton and that column becomes visible. Is there any workaround for this issue?

0

There is no feature like that built-in into the JBTable to control visible columns. However, such functionality is usually handled by the View icon on the toolbar:

 

You can spy on the existing UI implementations of the IDE using the UI Inspector.

0

HI Team,

We are also running into the same issue mentioned for IntelliJ v2020.2 and above versions up to latest available version which is v2021.3. We are using the JXTable to show results to the customers and most of our plugin functionalities are implemented based on that results table. We are highly dependent on this JXTable implementations since these functionalities are been used by every user of our plugin and it impacts the quality of the plugin.

Since this JXTable implementation is working fine until IntelliJ v2019.3, when can we expect a fix for this from IDE side?

0

@... Please see previous messages. The IDE itself has no influence on what JXTable does or doesn't.

1

Please sign in to leave a comment.