public static <T> ContextAwareAction context( ContextAction.Performer<? super T> perf, ContextSelection selectionType, Lookup context, Class<T> dataType ) { return new ContextAction<T>(perf, selectionType, context, dataType, false); }
void updateState() { PropertyChangeSupport s; synchronized (this) { s = support; } boolean prev = previousEnabled; if (s != null && prev != isEnabled()) { s.firePropertyChange("enabled", Boolean.valueOf(prev), Boolean.valueOf(!prev)); // NOI18N } }
public Object getValue(String key) { if ("enabler".equals(key)) { // NOI18N // special API to support re-enablement assert EventQueue.isDispatchThread(); updateState(); } return null; }
/** Clones itself with given context. */ public Action createContextAwareInstance(Lookup actionContext) { return new ContextAction<T>(performer, selectMode, actionContext, type, global.isSurvive()); }
@Override public void run() { ContextAction[] arr; synchronized (CACHE) { arr = toArray(new ContextAction[0]); } long now = 0; assert (now = System.currentTimeMillis()) >= 0; for (ContextAction a : arr) { a.updateState(); } long took = 0; assert (took = System.currentTimeMillis() - now) >= 0; if (took > 2000) { LOG.log(Level.WARNING, "Updating state of {1} actions took {0} ms. here is the action list:", new Object[] { took, arr.length }); for (ContextAction a : arr) { LOG.log(Level.INFO, " {0}", a); } } } }
private static <T> ContextAwareAction _context(Map map, Class<T> dataType, Lookup context) { ContextSelection sel = readSelection(map.get("selectionType")); // NOI18N Performer<T> perf = new Performer<T>(map); boolean survive = Boolean.TRUE.equals(map.get("surviveFocusChange")); // NOI18N return new ContextAction<T>( perf, sel, context, dataType, survive ); }