This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | Allow intercepting of creation of action presenters | ||
---|---|---|---|
Product: | platform | Reporter: | David Strupl <dstrupl> |
Component: | Window System | Assignee: | David Strupl <dstrupl> |
Status: | RESOLVED FIXED | ||
Severity: | blocker | CC: | apireviews, jtulach |
Priority: | P3 | Keywords: | API, API_REVIEW_FAST |
Version: | 5.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | ENHANCEMENT | Exception Reporter: | |
Attachments: |
First attempt on a patch
Revised patch |
Description
David Strupl
2007-01-30 10:00:21 UTC
I would like to solve this for 6.0 as it has very high priority for our team. Hello Jarda, Just to make sure I understand your proposal, did you mean something like: package org.openide.awt; class Actions { public static interface ButtonUIProvider { public JMenuItem createMenuPresenter (Action action); public JMenuItem createPopupPresenter(Action action); public Component createToolbarPresenter(Action action); } } Otherwise I don't understand how would we alter the behaviour of the menu item from the connect method. Thanks, David I thought it is enough to change the setEnabled/Disabled state which I believe is handled by Actions.connect. My proposal was to create an interface and as first line in Actions.connect do if (Lookup.getD().lookup(TheInterface.class)) { theInterface.connect(...); return }. Imho it should be enough. If it not, then sorry. And our implementation would do our checks and either call the original connect (via looking up the default impl) or my new code? I think I should be able to call the original connect code in order to do the old behaviour even in case my provider is registered (for actions that are e.g. authorized for the user). Without the original connect I am not able to properly set the text, icon, enablement etc. Hello, one last refinement before I will implement it: package org.openide.awt; class Actions { public static interface ButtonUIProvider { public boolean connect(Action, AbstractButton); } } The return value would be success of the connection. If false is returned the original connect would be called after this call. Ok? D. Created attachment 37915 [details]
First attempt on a patch
Please check the patch and comment on the patch. I think that the change is really simple. VS1: I am not sure if I should be asking, but what if there is more ButtonActionConnectors registered in the lookup? Shouldn't you try to use all of them? Of course the first one that 'connects' wins, but in your impl if the first one does not connect no others get a chance. VS1: Of course any comments are welcome. You are right that my impl doesn't care about more registered objects. I was thinking about our use case that will put there just one. I have no problem in changing the patch to handle more instances. I will try to gather all feedback first and then post refined patch. Keep the comments coming ;-) BTW please use cvs diff -u for patches for review; the patches generated by the IDE are hard to read. (Yes, it's filed.) Generally looks good. Minor things: "successfull" - typo. 'static' is meaningless on an interface, as is 'public' on interface methods. @see org.openide.util.Lookup#getDefault(); has an extraneous semicolon. You should have Javadoc link to the .connect(...) methods which are affected by the SPI. spec.version.base should end in a .0, please restore that, it is intentional; cf. http://wiki.netbeans.org/wiki/view/DevFaqImplementationDependency In arch.xml it is best to put the whole <p> inside <api>. Working on the revised patch. Created attachment 38478 [details]
Revised patch
Reassigning back to apireviews with the revised patch attached to the issue. As the changes are minor and according to all the comments so far if there are no objections I will apply the patch tomorrow. As there were no complaints I will integrate the change. If some more changes are required please file bugs against me, I will fix them. IDE: [15.2.07 13:49] Committing started Checking in test/unit/src/org/openide/awt/ActionsTest.java; /cvs/openide/awt/test/unit/src/org/openide/awt/ActionsTest.java,v <-- ActionsTest.java new revision: 1.4; previous revision: 1.3 done Checking in src/org/openide/awt/Actions.java; /cvs/openide/awt/src/org/openide/awt/Actions.java,v <-- Actions.java new revision: 1.15; previous revision: 1.14 done Checking in nbproject/project.properties; /cvs/openide/awt/nbproject/project.properties,v <-- project.properties new revision: 1.9; previous revision: 1.8 done Checking in apichanges.xml; /cvs/openide/awt/apichanges.xml,v <-- apichanges.xml new revision: 1.9; previous revision: 1.8 done Checking in arch.xml; /cvs/openide/awt/arch.xml,v <-- arch.xml new revision: 1.10; previous revision: 1.9 done IDE: [15.2.07 13:49] Committing finished |