Lines 21-28
Link Here
|
21 |
import javax.swing.Icon; |
21 |
import javax.swing.Icon; |
22 |
import javax.swing.JCheckBoxMenuItem; |
22 |
import javax.swing.JCheckBoxMenuItem; |
23 |
import javax.swing.JMenuItem; |
23 |
import javax.swing.JMenuItem; |
24 |
import javax.swing.KeyStroke; |
|
|
25 |
import javax.swing.text.Keymap; |
26 |
import org.netbeans.modules.openide.util.ActionsBridge; |
24 |
import org.netbeans.modules.openide.util.ActionsBridge; |
27 |
import org.netbeans.modules.openide.util.ActionsBridge.ActionRunnable; |
25 |
import org.netbeans.modules.openide.util.ActionsBridge.ActionRunnable; |
28 |
import org.openide.util.ContextAwareAction; |
26 |
import org.openide.util.ContextAwareAction; |
Lines 43-72
Link Here
|
43 |
// -J-Dorg.openide.awt.AlwaysEnabledAction.level=FINE |
41 |
// -J-Dorg.openide.awt.AlwaysEnabledAction.level=FINE |
44 |
private static final Logger LOG = Logger.getLogger(AlwaysEnabledAction.class.getName()); |
42 |
private static final Logger LOG = Logger.getLogger(AlwaysEnabledAction.class.getName()); |
45 |
|
43 |
|
46 |
/** |
44 |
private static final String PREFERENCES_NODE = "preferencesNode"; // NOI18N |
47 |
* Action property for key in {@link java.util.prefs.Preferences}. |
|
|
48 |
* <code> |
49 |
* String key = (String) action.getValue("PreferencesKey"); |
50 |
* boolean selected = preferencesNode.getBoolean(key, false); |
51 |
* </code> |
52 |
*/ |
53 |
private static final String PREFERENCES_KEY = "PreferencesKey"; // NOI18N |
54 |
|
45 |
|
55 |
/** |
46 |
private static final String PREFERENCES_KEY = "preferencesKey"; // NOI18N |
56 |
* Action property for retrieving {@link java.util.prefs.Preferences} node. |
|
|
57 |
* Its value can be a String: |
58 |
* <ul> |
59 |
* <li>"system:/path" for {@link java.util.prefs.Preferences#systemRoot() }.</li> |
60 |
* <li>"user:/key" for {@link java.util.prefs.Preferences#userRoot() }.</li> |
61 |
* <li>"nb:/key" for {@link org.openide.util.NbPreferences#root() }.</li> |
62 |
* </ul> |
63 |
* or a method value returning one of the following: |
64 |
* <ul> |
65 |
* <li>{@link java.util.prefs.Preferences } instance.</li> |
66 |
* <li>{@link org.openide.util.Lookup }.</li> |
67 |
* </ul> |
68 |
*/ |
69 |
private static final String PREFERENCES_NODE = "PreferencesNode"; // NOI18N |
70 |
|
47 |
|
71 |
static AlwaysEnabledAction create(Map m) { |
48 |
static AlwaysEnabledAction create(Map m) { |
72 |
return (m.containsKey(PREFERENCES_KEY)) ? new CheckBox(m) : new AlwaysEnabledAction(m); |
49 |
return (m.containsKey(PREFERENCES_KEY)) ? new CheckBox(m) : new AlwaysEnabledAction(m); |
Lines 101-107
Link Here
|
101 |
return a; |
78 |
return a; |
102 |
} |
79 |
} |
103 |
|
80 |
|
104 |
private ActionListener getDelegate() { |
81 |
protected ActionListener getDelegate() { |
105 |
if (delegate == null) { |
82 |
if (delegate == null) { |
106 |
Object listener = map.get("delegate"); // NOI18N |
83 |
Object listener = map.get("delegate"); // NOI18N |
107 |
if (!(listener instanceof ActionListener)) { |
84 |
if (!(listener instanceof ActionListener)) { |
Lines 283-288
Link Here
|
283 |
|
260 |
|
284 |
private static final long serialVersionUID = 1L; |
261 |
private static final long serialVersionUID = 1L; |
285 |
|
262 |
|
|
|
263 |
private static final ActionListener EMPTY = new ActionListener() { |
264 |
public void actionPerformed(ActionEvent ae) { |
265 |
// Do nothing |
266 |
} |
267 |
}; |
268 |
|
286 |
private JCheckBoxMenuItem menuItem; |
269 |
private JCheckBoxMenuItem menuItem; |
287 |
|
270 |
|
288 |
private JCheckBoxMenuItem popupItem; |
271 |
private JCheckBoxMenuItem popupItem; |
Lines 332-337
Link Here
|
332 |
} |
315 |
} |
333 |
|
316 |
|
334 |
@Override |
317 |
@Override |
|
|
318 |
protected ActionListener getDelegate() { |
319 |
return EMPTY; |
320 |
} |
321 |
|
322 |
@Override |
335 |
public Action createContextAwareInstance(Lookup actionContext) { |
323 |
public Action createContextAwareInstance(Lookup actionContext) { |
336 |
return new CheckBox(map, delegate, actionContext, equals); |
324 |
return new CheckBox(map, delegate, actionContext, equals); |
337 |
} |
325 |
} |
Lines 389-406
Link Here
|
389 |
preferencesNode = null; |
377 |
preferencesNode = null; |
390 |
} |
378 |
} |
391 |
} |
379 |
} |
392 |
} else if (nodeName.startsWith("nb:")) { |
380 |
} else { |
393 |
preferencesNode = NbPreferences.root(); |
381 |
preferencesNode = NbPreferences.root(); |
394 |
if (preferencesNode != null) { |
382 |
if (preferencesNode != null) { |
395 |
nodeName = nodeName.substring("nb:".length());; |
|
|
396 |
try { |
383 |
try { |
397 |
preferencesNode = preferencesNode.nodeExists(nodeName) ? preferencesNode.node(nodeName) : null; |
384 |
preferencesNode = preferencesNode.nodeExists(nodeName) ? preferencesNode.node(nodeName) : null; |
398 |
} catch (BackingStoreException ex) { |
385 |
} catch (BackingStoreException ex) { |
399 |
preferencesNode = null; |
386 |
preferencesNode = null; |
400 |
} |
387 |
} |
401 |
} |
388 |
} |
402 |
} else { |
|
|
403 |
preferencesNode = null; |
404 |
} |
389 |
} |
405 |
|
390 |
|
406 |
} else if (prefsNodeOrLookup instanceof Preferences) { |
391 |
} else if (prefsNodeOrLookup instanceof Preferences) { |