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.

Bug 159069 - Introduce ContextAwareAction support
Summary: Introduce ContextAwareAction support
Status: RESOLVED WORKSFORME
Alias: None
Product: platform
Classification: Unclassified
Component: Actions (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jaroslav Tulach
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-24 15:51 UTC by Jan Pokorsky
Modified: 2010-10-08 04:12 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Pokorsky 2009-02-24 15:51:55 UTC
Motivation:
I would like to simplify creation of actions that implement org.openide.util.ContextAwareAction. In repository you can
find several places where modules c&p NodeAction implementation in order to access the context. As NodeAction subclasses
SharedClassedObject it is necessary to have 2 classes and a lot of delegating code.

Solution:
I propose to introduce new helper method 

Action org.openide.awt.Actions.contextAwareAction(
    ContextActionHandler delegate,
    String displayName,
    String iconBase,
    boolean noIconInMenu)

and interface org.openide.awt.ContextActionHandler that clients would implement to handle particular action with a given
context.

public interface ContextActionHandler {
    public boolean isEnabled(Lookup context);
    public void perform(ActionEvent e, Lookup context);
}
Comment 1 Jaroslav Tulach 2010-01-18 09:39:29 UTC
There are org.openide.awt.ContextEnabler and ContextPerformer. However they have problems with delivering changes when the enabled state is changed. Your interface suffers similar problem too.
Comment 2 Jaroslav Tulach 2010-10-08 04:12:02 UTC
There is @ActionRegistration and it supports some for of context sensitivity.