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.
Currently these actions are implemented in the Ant module. It would be desirable to let the Maven core module also hook into them. Would need some kind of generic stub actions in the projectui module with an SPI in projectuiapi. An impl should probably be able to list running builds (with a listener), each of which could be stop()'d or rerun()'d.
*** Issue 109745 has been marked as a duplicate of this issue. ***
Are there any plans on this? It is possible we will need this to implement issue #132165.
ok, I'll see what can be done. It should not be hard to do, just requires some API changes..
Created attachment 71962 [details] api and generic impl patch
Created attachment 71964 [details] ant module rewrite
Created attachment 71965 [details] maven module rewrite
please review the following minor api change that allows the plugging of Rerun/Stop build actions.
Generally looks good. [JG01] Casting the result of lookup to an impl class is fragile. Rather make runningItems, lastFinishedItem, register*Item, listeners, add/removeChangeListener static. Keep a WeakSet of instances of the class, and have fireChange use this set to fire to all. [JG02] RunLastBuildAction should perhaps not be using AntIcon.gif any more. Also check its Javadoc, and fix Utilities.loadImage. [JG03] org-netbeans-modules-project-ui-actions.StopBuildingAction.instance should be org-netbeans-modules-project-ui-actions-StopBuildingAction.instance. The second occurrence should be a .shadow to the first.
JG02, JG03 - done. JG01 - I don't agree with your assesment of stability. If I make the methods static and avoid the cast, I cannot avoiding someone registering a different impl, but then the actions will fail to work anyway as they will listen and get t heir data from this instance. Therefore the eventuall ClassCastException is IMHO good early warning of something being messed up.
To JG01 - there would be no such risk (all the state would be static and the actions would work with any instance of BuildExecutionSupportImpl interchangeably); but then again I think the situation cannot occur to begin with, as the only point where a BuildExecutionSupportImpl would be created is by calling lookup on BuildExecutionSupportImplementation and this interface is not visible publicly. If the SPI interface were made visible publicly then the cast could really fail under legitimate use cases, e.g. in case some other impl were registered first but some client iterated all impls. The safest idiom for that general case would actually be to remove the getInstance() method, and then from actions write e.g. public boolean isEnabled() { for (BuildExecutionSupportImplementation impl : Lookup.getDefault().lookupAll(BuildExecutionSupportImplementation.class)) { if (i instanceof BuildExecutionSupportImpl) { return ((BuildExecutionSupportImpl) i).getLastItem() != null; } } return false; }
JG01: well, since the BESImplementation interface is effectively private and can only be implemented by a module that has implementation dependency on projectuiapi, I've added the 2 methods that were the cause for the class cast into the interface.
pushed to main. implemented for ant and maven projects. Other project types should consider using the new api as well.
Integrated into 'main-golden', will be available in build *200810240201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/c3194bac610e User: Milos Kleint <mkleint@netbeans.org> Log: #110465 add api and impl for plugging into the Rerun build/Stop build actions. Move the actions from ant module to a more general area.