TreePopupMenuInstaller

This forum is used by users to request and discuss new product features. Please do not use this forum for technical support including bug reports.

Moderator: JIDE Support

Forum rules
Product suggestions only. Please do not use this forum for technical support including bug reports.

TreePopupMenuInstaller

Postby Skjalg » Wed Apr 28, 2010 6:11 am

I was wondering if you guys could implement something similar to TablePopupMenuInstaller (and customizer) that would work with JTree ?

something like
Code: Select all
public interface TreePopupMenuCustomizer {

    public void customizePopupMenu(JTree tree, JPopupMenu popup, TreePath clickingPath);
}


You guys probably have a lot more code than this, but heres what I got so far at least:
Code: Select all
public class TreePopupMenuInstaller extends MouseAdapter {

    private final JTree tree;
    private List<TreePopupMenuCustomizer> treePopupMenuCustomizers;

    public TreePopupMenuInstaller(JTree tree) {
        this.tree = tree;
        this.treePopupMenuCustomizers = new ArrayList<TreePopupMenuCustomizer>();
    }

    public void installListeners() {
        tree.addMouseListener(this);
        tree.addMouseMotionListener(this);
        tree.addMouseWheelListener(this);
    }

    public void uninstallListeners() {
        tree.removeMouseListener(this);
        tree.removeMouseMotionListener(this);
        tree.removeMouseWheelListener(this);
    }

    public boolean addTreePopupMenuCustomizer(TreePopupMenuCustomizer treePopupMenuCustomizer) {
        return treePopupMenuCustomizers.add(treePopupMenuCustomizer);
    }

    @Override
    public void mouseReleased(MouseEvent event) {
        TreePath path = tree.getSelectionPath();
        if (event.isPopupTrigger() && path != null) {
            JidePopupMenu popup = new JidePopupMenu();
            for (TreePopupMenuCustomizer treePopupMenuCustomizer : treePopupMenuCustomizers) {
                treePopupMenuCustomizer.customizePopupMenu(tree, popup, path);
            }
            popup.show(tree, event.getPoint().x, event.getPoint().y);
        }
    }
}


That way I could standarize the way I add menus (actions) to both tables and trees.

This would probably also be a good idea for JList...
Skjalg
 
Posts: 51
Joined: Tue May 12, 2009 6:45 am

Re: TreePopupMenuInstaller

Postby JIDE Support » Wed Apr 28, 2010 8:35 am

Thanks for your code. Will include them in 2.9.1.

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

Re: TreePopupMenuInstaller

Postby Skjalg » Wed Apr 28, 2010 10:18 am

Will you add something similar for JList as I briefly mentioned as well?
Skjalg
 
Posts: 51
Joined: Tue May 12, 2009 6:45 am

Re: TreePopupMenuInstaller

Postby JIDE Support » Wed Apr 28, 2010 10:28 am

Will do so as well.

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

Re: TreePopupMenuInstaller

Postby JIDE Support » Thu May 06, 2010 11:50 am

Just so you know, these two classes are added in 2.9.1 just released.

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

Re: TreePopupMenuInstaller

Postby Skjalg » Thu May 06, 2010 11:59 pm

We've had some unfortunate accidents with the Jide beta before, so we gotta keep to the stable release I'm afraid. Any idea when that will be released and if these classes will be included in 2.8.7 ?
Skjalg
 
Posts: 51
Joined: Tue May 12, 2009 6:45 am

Re: TreePopupMenuInstaller

Postby JIDE Support » Fri May 07, 2010 8:21 am

Sorry for the prior accidents. I'm afraid we will not add these to 2.8.7. We will claim 2.9.x as stable release maybe two to three months later.

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

Re: TreePopupMenuInstaller

Postby Skjalg » Sun May 09, 2010 11:44 pm

I downloaded 2.9.1 to check it out, but I'm lacking TreePopupMenuInstaller.addSeparatorIfNecessary(JPopupMenu popup). and ListPopupMenuInstaller.addSeparatorIfNecessary(JPopupMenu popup) Is that by choice?

I'm just using TablePopupMenuInstaller.addSeparatorIfNecessary(JPopupMenu popup) in the meantime..
Skjalg
 
Posts: 51
Joined: Tue May 12, 2009 6:45 am

Re: TreePopupMenuInstaller

Postby JIDE Support » Mon May 10, 2010 8:34 am

Thanks. We will add both. Yes, for now you can use the one in TablePopupMenuInstaller as it is static method anyway.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: TreePopupMenuInstaller

Postby JIDE Support » Fri May 21, 2010 9:45 am

Just so you know, this is fixed in 2.9.2 just released.

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


Return to Product Suggestions

Who is online

Users browsing this forum: No registered users and 11 guests