PivotTablePane popupmenu problems

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.

PivotTablePane popupmenu problems

Postby michaelb88 » Thu Jul 21, 2011 5:05 am

Hi,

I'm using a PivotTablePane and I'm having problems with the popup on the data table.

The pop up gives you the ability to sort ascending and decending and hide and show columns when you right click. However, I want to add a new option to this but extending it and I'm not sure how to do this. I have looked though the api for PivotTablePane.getDataTable() but am having no luck any ideas.

Thanks
Mike
michaelb88
 
Posts: 35
Joined: Thu Jul 21, 2011 1:21 am

Re: PivotTablePane popupmenu problems

Postby JIDE Support » Thu Jul 21, 2011 6:59 am

Please override DataTable#createContextMenu() to achieve your goal. A better solution is to invoke PivotTablePane#setDataTablePopupMenuCustomizer() to add your menu customizer.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: PivotTablePane popupmenu problems

Postby michaelb88 » Thu Jul 21, 2011 7:21 am

Thanks for the reply.

I tried using the PivotTablePane#setDataTablePopupMenuCustomizer() but I was not sure how to write the customiser code as all I want to do is add an extra item to the popup menu and retain the current functinallity. Is this possibe?
michaelb88
 
Posts: 35
Joined: Thu Jul 21, 2011 1:21 am

Re: PivotTablePane popupmenu problems

Postby JIDE Support » Thu Jul 21, 2011 7:27 am

Please give the following code a try.
Code: Select all
        _pivotTablePane.setDataTablePopupMenuCustomizer(new PivotTablePane.PopupMenuCustomizer() {
            public void customize(JPopupMenu menu, Component target) {
                menu.add(new JMenuItem("test"));
            }
        });

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: PivotTablePane popupmenu problems

Postby michaelb88 » Thu Jul 21, 2011 7:41 am

Thanks that does the trick.

One last question is it possible to have the data cell in the datafield highlight when you right click. I noticed you can only do this on the left click. This is becuase I would like to use the data in the cell that is clicked on when the popup menu appears.

Currently I'm using a private class PivotTableMouseListener which extends MouseAdapter. However the following code:

public void mousePressed(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON2) {

fails to allows me to access the data that is selected with the right mouse button. The goal to use this information when the user press the option in the popup menu.

Thanks again
Mike
michaelb88
 
Posts: 35
Joined: Thu Jul 21, 2011 1:21 am

Re: PivotTablePane popupmenu problems

Postby JIDE Support » Thu Jul 21, 2011 8:39 am

If you give plain JTable a try, you will see that right click on the table cell won't make selection. JIDE PivotTablePane follows the pattern. Please try to make selection in your mouse listener.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: PivotTablePane popupmenu problems

Postby michaelb88 » Thu Jul 21, 2011 10:11 am

Thanks for the fast responses.

I've been trying to use the following code, so that when the right mouse button is pressed I can get a print out of the row and column for the location the right mouse button was pressed over. This would be good enough, as I can highlight it from the listener with these details.

However, my problem is that when I right click it brings up the popup window, but I don't recieve and event in the listener. Do you know how I can right click to get the pop up but also get the corrodiantes of the click in the listener.

Thanks
Mike

Code: Select all

   table.getDataTable().addMouseListener( new MouseAdapter()
      {
         public void mouseClicked( MouseEvent e )
         {
            if ( SwingUtilities.isLeftMouseButton( e ) )
            {

            }
            else if ( SwingUtilities.isRightMouseButton( e ) )
            {
               System.exit(0);
               Point p = e.getPoint();
                     
               int rowNumber = table.getDataTable().rowAtPoint( p );
               int colNumber = table.getDataTable().columnAtPoint( p );

log.out(rowNumber + " : " + colNumber);




                  }
         }
      });

michaelb88
 
Posts: 35
Joined: Thu Jul 21, 2011 1:21 am

Re: PivotTablePane popupmenu problems

Postby JIDE Support » Thu Jul 21, 2011 10:18 am

Please try to invoke PivotTablePane#setDataTablePopupMenuCustomizer() with the following customizer class.
Code: Select all
    class Customizer implements PivotTablePane.PopupMenuCustomizer, PivotTablePane.TablePopupMenuCustomizer {
        public void customize(JPopupMenu menu, Component target) {

        }

        public void customize(JPopupMenu menu, Component target, int rowIndex, int columnIndex) {
                // this method will have row and column information.
        }
    }

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: PivotTablePane popupmenu problems

Postby michaelb88 » Fri Jul 22, 2011 1:27 am

Thanks again.

I still have a few problems with the below code.

Your correct that it has the location of the popup which is ideal, but when it comes to highlighting the cell it is not doing it in the same manner as you have set up the left click. Also it does not not apear to highlight the cell when you click on the mouse and the popup apears but only when you hold the mosue button down before the popup appear and also after you have selected you options. Do you have any ideas how to get the cell to hightlight in the same manner as you have the left click set up and how to make the cell appear highlight while the popup menu is actived. Note the first first problem may solve the second problem.

Thanks
Mike

Code: Select all

    class Customizer implements PivotTablePane.PopupMenuCustomizer, PivotTablePane.TablePopupMenuCustomizer {
        public void customize(JPopupMenu menu, Component target) {

        }

        public void customize(JPopupMenu menu, Component target, int rowIndex, int columnIndex) {
           JMenuItem item = new JMenuItem();
           item.setText("Item");
           menu.add(item);
     

         table.getDataTable().setCellSelectionEnabled(true);
         table.getDataTable().getSelectionModel().setSelectionInterval(rowIndex, rowIndex);
         table.getDataTable().getColumnModel().getSelectionModel().setSelectionInterval(columnIndex, columnIndex);

         
           }
    }

michaelb88
 
Posts: 35
Joined: Thu Jul 21, 2011 1:21 am

Re: PivotTablePane popupmenu problems

Postby JIDE Support » Fri Jul 22, 2011 11:18 am

As mentioned in previous post, you have to add your mouse listener to the table to make cell selection as you wish. The popup menu customizer is not supposed to perform the job and that's why you encounter those issues.

Thanks,
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 7 guests

cron