christmo / macwidgets

Automatically exported from code.google.com/p/macwidgets
0 stars 0 forks source link

Allow SourceListItem in SourceList to provide a context menu #21

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
A SourceList should allow a SourceListItem to provide a custom context menu.

Original issue reported on code.google.com by kenneth....@gmail.com on 29 Oct 2008 at 11:44

GoogleCodeExporter commented 8 years ago
Or perhaps allow a sourcelist to have a mouse listener, so that I can detect 
right
mouse clicks, and create the context menu.

Or perhaps the SourceListSelectionListener can supply additional information 
than
just the selected SourceListItem as an event.

Original comment by steve.mc...@gmail.com on 30 Oct 2008 at 6:15

GoogleCodeExporter commented 8 years ago
Good feedback...thanks Steve.

Original comment by kenneth....@gmail.com on 30 Oct 2008 at 6:33

GoogleCodeExporter commented 8 years ago
This component is awesome, we just need more control, the idea of having a
mouselistener is great, we really need that, we need to know when the user 
double
click it an item, when he used a right click, etc. With that we could create a
context menu, but it would be awesome if we had an easy method just to plug an
JpopupMenu too. But in my point of view the mouselistener comes first in an 
priority
order.

Original comment by alexandr...@gmail.com on 31 Oct 2008 at 1:46

GoogleCodeExporter commented 8 years ago
Thanks for the feedback Alexandre. It's developer feedback that will drive the 
API forward. I'll work on adding 
the facilities requested this weekend.

Original comment by kenneth....@gmail.com on 31 Oct 2008 at 2:43

GoogleCodeExporter commented 8 years ago
Would the following interfaces (installable on SourceList) be sufficient?

+ SourceListClickListener
    - sourceListItemClicked(SourceListItem item, MouseEvent event)

+ SourceListContextMenuProvider
    - PopupMenuCustomizer provideContextMenu(SourceListItem item)

Original comment by kenneth....@gmail.com on 31 Oct 2008 at 2:55

GoogleCodeExporter commented 8 years ago
the SourceListClickListener, I understood and I think it will be great, when a 
mouse
event occurs you will give me the item and the mouse event itself. Awesome. I 
didn't
understand the second one(SourceListContextMenuProvider). How I will install a
Jpopupmemu on the sourcelist, because seems that you will provide me the item 
the
user right clicked, but where is the Jpopupmenu? I can use the first one to 
open a
JPopupMenu, since you are gaving me the MouseEvent, but just would like to 
understand
the second one.

Thanks a lot for the help on this. You did a great work and still helping 
developers
in implementing more features for the community.

Original comment by alexandr...@gmail.com on 31 Oct 2008 at 4:47

GoogleCodeExporter commented 8 years ago
Hi Alexandre,

The SourceListContextMenuProvider's would actually look like this:

void provideContextMenu(JPopupMenu menu, SourceListItem item)

So you'd always be asked to provide the menut items for the given item just 
before the menu was shown. This 
is a nice technique for supporting dynamic menus. A sample implementation might 
look like this:

mySourceList.setContextMenuProvider(new SourceListContextMenuProvider() {
    public void  provideContextMenu(JPopupMenu menu, SourceListItem item) {
        // clear the menu first.
        menu.removeAll();
        // add your menu items here.
    }
});

Original comment by kenneth....@gmail.com on 31 Oct 2008 at 5:24

GoogleCodeExporter commented 8 years ago
this would work for me like a charm :-).

looking forward to that implementation.

Thank you very much

Ken

Original comment by alexandr...@gmail.com on 31 Oct 2008 at 5:35

GoogleCodeExporter commented 8 years ago
I've added the following interface, which can be installed on a SourceList:

SourceListContextMenuProvider

If you're able to checkout the code from subversion, can you do an update and 
let me know if this meets your 
needs?

Original comment by kenneth....@gmail.com on 1 Nov 2008 at 2:10

GoogleCodeExporter commented 8 years ago
I downloaded the code, builded already. I'll test now. Sorry just to be able to 
test it today, I was oncall on IBM this 
weekend. Busy weekend :-(.
I'll let you know as soon as I finish the tests.
Really appreciated Ken thank you very much

Original comment by alexandr...@gmail.com on 3 Nov 2008 at 11:43

GoogleCodeExporter commented 8 years ago
Alexandre suggested that he would like to return his own JPopupMenu from the 
SourceListContextMenuProivder 
rather than populate a supplied menu. This seems reasonable to me as currently 
the JPopupMenu is being 
created just prior to being passed to the interface. 

This will be slightly more flexible in that it will allow implementors to 
return a custom implementation of 
JPoupMenu.

Does this sound reasonable Alexandre?

Original comment by kenneth....@gmail.com on 4 Nov 2008 at 12:11

GoogleCodeExporter commented 8 years ago
This would be great Ken, I tested the code that you implemented, and works 
perfectly,
I'm using JpopupMenu in my software already. This new feature will make the api 
more
flexible, I'm really glad that you think the same way. 

Original comment by alexandr...@gmail.com on 4 Nov 2008 at 12:21

GoogleCodeExporter commented 8 years ago
The changes are in. Let me know how it works for you.

Original comment by kenneth....@gmail.com on 4 Nov 2008 at 12:38

GoogleCodeExporter commented 8 years ago
I just tested, it is working perfectly. Thanks Ken.

Original comment by alexandr...@gmail.com on 4 Nov 2008 at 1:13

GoogleCodeExporter commented 8 years ago

Original comment by kenneth....@gmail.com on 4 Nov 2008 at 1:14

GoogleCodeExporter commented 8 years ago
I keen to try this out but haven't had a chance yet. Perhaps this evening. Is 
there a
jar I can try, or will I need to download the source tree?

Original comment by steve.mc...@gmail.com on 4 Nov 2008 at 1:14

GoogleCodeExporter commented 8 years ago
Hi Steve,

It's only available via Subversion right now, but I could jar it up for you 
when I get home tonight if you like.

-Ken

Original comment by kenneth....@gmail.com on 4 Nov 2008 at 1:20

GoogleCodeExporter commented 8 years ago
Hi Ken,

That would be nice!

Thanks

Steve

Original comment by steve.mc...@gmail.com on 4 Nov 2008 at 1:23

GoogleCodeExporter commented 8 years ago
I just sent the jar to steve Ken :-)

Original comment by alexandr...@gmail.com on 4 Nov 2008 at 2:02