row selection by right click

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

row selection by right click

Postby Falko » Tue Oct 14, 2014 4:20 am

hi,

can you pleas help me to select one row on right click in row header table.

the use case is to click right on the row header table than to
select the row in row header table and data table
and edit the row in data table.


Code: Select all
rowHeaderTable.addMouseListener(new MouseAdapter() {
           

            @Override
            public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e) ) {
            final PivotTablePane pivotTablePane = activePivotTable.getPivotTablePane();
                        final JideTable rowHeaderTable = (JideTable) activePivotTable.getPivotTablePane().getRowHeaderTable();
                        final JTable dataTable = pivotTablePane.getDataTable();
                  //this works, listener get invoked
                        //rowHeaderTable.selectAll();
                        //dataTable.selectAll();
                  // this works, listener get invoked
                        //rowHeaderTable.clearSelection();
                        //dataTable.clearSelection();
                  
                  // depends on previous clear or selectAll
                  int[] rowsd0 = dataTable.getSelectedRows();
                  
                  // allways empty
                        int[] rowsh0 = rowHeaderTable.getSelectedRows();
               
               // find out clicked row
                        int rowcount = pivotTablePane.getRowHeaderTable().getRowCount();
                        int rowHeight = e.getComponent().getHeight() / rowcount;
                        int componentHeight = e.getY();
                        final int clickedRow = componentHeight / rowHeight;
               
               
               // this all doesn't work, listener not invoked
               dataTable.setRowSelectionInterval(clickedRow, clickedRow);
                        dataTable.setColumnSelectionInterval(clickedRow, clickedRow);
                        dataTable.getSelectionModel().setSelectionInterval(clickedRow, clickedRow);
                        dataTable.getColumnModel().getSelectionModel().setSelectionInterval(clickedRow, clickedRow);

                        rowHeaderTable.setRowSelectionInterval(clickedRow, clickedRow);
                        rowHeaderTable.setColumnSelectionInterval(clickedRow, clickedRow);
                        rowHeaderTable.getSelectionModel().setSelectionInterval(clickedRow, clickedRow);
                        rowHeaderTable.getColumnModel().getSelectionModel().setSelectionInterval(clickedRow, clickedRow);
                       
                  
                  // nothing changed
                  int[] rowsd1 = dataTable.getSelectedRows();
                        int[] rowsh1 = rowHeaderTable.getSelectedRows();
               
            }
         }
         
}


by the way. the other listener methods don't get invoked. this is strange.

Code: Select all
rowHeaderTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                System.out.println("invoked");
            }
        });
      
      
      rowHeaderTable.getTableSelectionModel().addTableSelectionListener(new TableSelectionListener() {
            @Override
            public void valueChanged(TableSelectionEvent e) {
               System.out.println("invoked");
            }

        });



cheers
Falko
 
Posts: 24
Joined: Tue Mar 26, 2013 4:19 am

Re: row selection by right click

Postby JIDE Support » Tue Oct 14, 2014 7:18 am

This forum is for the open source JIDE Common Layer, not for the JIDE Pivot Grid. Please use the pivot grid forum instead. It also looks like the maintenance for your company expired in 2013. We would appreciate if you can renew your maintenance before asking technical questions on the forums.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 11 guests

cron