Lines 90-123
Link Here
|
90 |
|
90 |
|
91 |
/* @return name |
91 |
/* @return name |
92 |
*/ |
92 |
*/ |
|
|
93 |
@Override |
93 |
public String getName() { |
94 |
public String getName() { |
94 |
return getActionName(); |
95 |
return getActionName(); |
95 |
} |
96 |
} |
96 |
|
97 |
|
97 |
/* @return help for this action |
98 |
/* @return help for this action |
98 |
*/ |
99 |
*/ |
|
|
100 |
@Override |
99 |
public HelpCtx getHelpCtx() { |
101 |
public HelpCtx getHelpCtx() { |
100 |
return new HelpCtx(ToolsAction.class); |
102 |
return new HelpCtx(ToolsAction.class); |
101 |
} |
103 |
} |
102 |
|
104 |
|
103 |
/* @return menu presenter for the action |
105 |
/* @return menu presenter for the action |
104 |
*/ |
106 |
*/ |
|
|
107 |
@Override |
105 |
public JMenuItem getMenuPresenter() { |
108 |
public JMenuItem getMenuPresenter() { |
106 |
return new Inline(this); |
109 |
return new Inline(this); |
107 |
} |
110 |
} |
108 |
|
111 |
|
109 |
/* @return menu presenter for the action |
112 |
/* @return menu presenter for the action |
110 |
*/ |
113 |
*/ |
|
|
114 |
@Override |
111 |
public JMenuItem getPopupPresenter() { |
115 |
public JMenuItem getPopupPresenter() { |
112 |
return new Popup(this); |
116 |
return new Popup(this); |
113 |
} |
117 |
} |
114 |
|
118 |
|
115 |
/* Does nothing. |
119 |
/* Does nothing. |
116 |
*/ |
120 |
*/ |
|
|
121 |
@Override |
117 |
public void actionPerformed(java.awt.event.ActionEvent ev) { |
122 |
public void actionPerformed(java.awt.event.ActionEvent ev) { |
118 |
assert false; |
123 |
assert false; |
119 |
} |
124 |
} |
120 |
|
125 |
|
|
|
126 |
@Override |
121 |
public Action createContextAwareInstance(Lookup actionContext) { |
127 |
public Action createContextAwareInstance(Lookup actionContext) { |
122 |
return new DelegateAction(this, actionContext); |
128 |
return new DelegateAction(this, actionContext); |
123 |
} |
129 |
} |
Lines 136-143
Link Here
|
136 |
*/ |
142 |
*/ |
137 |
private static List<JMenuItem> generate(Action toolsAction, boolean forMenu) { |
143 |
private static List<JMenuItem> generate(Action toolsAction, boolean forMenu) { |
138 |
ActionManager am = ActionManager.getDefault(); |
144 |
ActionManager am = ActionManager.getDefault(); |
139 |
SystemAction[] actions = am.getContextActions(); |
145 |
List<Action> actions = am.getToolsActions(); |
140 |
List<JMenuItem> list = new ArrayList<JMenuItem>(actions.length); |
146 |
List<JMenuItem> list = new ArrayList<JMenuItem>(actions.size()); |
141 |
|
147 |
|
142 |
boolean separator = false; |
148 |
boolean separator = false; |
143 |
boolean firstItemAdded = false; // flag to prevent adding separator before actual menu items |
149 |
boolean firstItemAdded = false; // flag to prevent adding separator before actual menu items |
Lines 211-217
Link Here
|
211 |
/** @deprecated Useless, see {@link ActionManager}. */ |
217 |
/** @deprecated Useless, see {@link ActionManager}. */ |
212 |
@Deprecated |
218 |
@Deprecated |
213 |
public static interface Model { |
219 |
public static interface Model { |
214 |
public SystemAction[] getActions(); |
220 |
public Action[] getActions(); |
215 |
|
221 |
|
216 |
public void addChangeListener(javax.swing.event.ChangeListener l); |
222 |
public void addChangeListener(javax.swing.event.ChangeListener l); |
217 |
|
223 |
|
Lines 235-240
Link Here
|
235 |
|
241 |
|
236 |
|
242 |
|
237 |
|
243 |
|
|
|
244 |
@Override |
238 |
public JComponent[] synchMenuPresenters(JComponent[] items) { |
245 |
public JComponent[] synchMenuPresenters(JComponent[] items) { |
239 |
if (timestamp == gl().getTimestamp()) { |
246 |
if (timestamp == gl().getTimestamp()) { |
240 |
return items; |
247 |
return items; |
Lines 246-251
Link Here
|
246 |
} |
253 |
} |
247 |
|
254 |
|
248 |
|
255 |
|
|
|
256 |
@Override |
249 |
public JComponent[] getMenuPresenters() { |
257 |
public JComponent[] getMenuPresenters() { |
250 |
return synchMenuPresenters(new JComponent[0]); |
258 |
return synchMenuPresenters(new JComponent[0]); |
251 |
} |
259 |
} |
Lines 271-281
Link Here
|
271 |
} |
279 |
} |
272 |
|
280 |
|
273 |
|
281 |
|
|
|
282 |
@Override |
274 |
public JComponent[] synchMenuPresenters(JComponent[] items) { |
283 |
public JComponent[] synchMenuPresenters(JComponent[] items) { |
275 |
return gl().isPopupEnabled(toolsAction) ? new JMenuItem[] { menu } : new JMenuItem[0]; |
284 |
return gl().isPopupEnabled(toolsAction) ? new JMenuItem[] { menu } : new JMenuItem[0]; |
276 |
} |
285 |
} |
277 |
|
286 |
|
278 |
|
287 |
|
|
|
288 |
@Override |
279 |
public JComponent[] getMenuPresenters() { |
289 |
public JComponent[] getMenuPresenters() { |
280 |
return synchMenuPresenters(new JComponent[0]); |
290 |
return synchMenuPresenters(new JComponent[0]); |
281 |
} |
291 |
} |
Lines 291-296
Link Here
|
291 |
super(getActionName()); |
301 |
super(getActionName()); |
292 |
} |
302 |
} |
293 |
|
303 |
|
|
|
304 |
@Override |
294 |
public JPopupMenu getPopupMenu() { |
305 |
public JPopupMenu getPopupMenu() { |
295 |
JPopupMenu popup = super.getPopupMenu(); |
306 |
JPopupMenu popup = super.getPopupMenu(); |
296 |
fillSubmenu(popup); |
307 |
fillSubmenu(popup); |
Lines 326-337
Link Here
|
326 |
} |
337 |
} |
327 |
} |
338 |
} |
328 |
|
339 |
|
|
|
340 |
@Override |
329 |
public void popupMenuCanceled(PopupMenuEvent e) { |
341 |
public void popupMenuCanceled(PopupMenuEvent e) { |
330 |
} |
342 |
} |
331 |
|
343 |
|
|
|
344 |
@Override |
332 |
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { |
345 |
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { |
333 |
} |
346 |
} |
334 |
|
347 |
|
|
|
348 |
@Override |
335 |
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { |
349 |
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { |
336 |
lastPopup.removePopupMenuListener(this); |
350 |
lastPopup.removePopupMenuListener(this); |
337 |
lastPopup = null; // clear the status and stop listening |
351 |
lastPopup = null; // clear the status and stop listening |
Lines 344-350
Link Here
|
344 |
private static class G implements PropertyChangeListener { |
358 |
private static class G implements PropertyChangeListener { |
345 |
public static final String PROP_STATE = "actionsState"; // NOI18N |
359 |
public static final String PROP_STATE = "actionsState"; // NOI18N |
346 |
private int timestamp = 1; |
360 |
private int timestamp = 1; |
347 |
private SystemAction[] actions = null; |
361 |
private Action[] actions = null; |
348 |
private PropertyChangeSupport supp = new PropertyChangeSupport(this); |
362 |
private PropertyChangeSupport supp = new PropertyChangeSupport(this); |
349 |
|
363 |
|
350 |
public G() { |
364 |
public G() { |
Lines 369-379
Link Here
|
369 |
timestamp++; |
383 |
timestamp++; |
370 |
|
384 |
|
371 |
// deregister all actions listeners |
385 |
// deregister all actions listeners |
372 |
SystemAction[] copy = actions; |
386 |
Action[] copy = actions; |
373 |
|
387 |
|
374 |
if (copy != null) { |
388 |
if (copy != null) { |
375 |
for (int i = 0; i < copy.length; i++) { |
389 |
for (int i = 0; i < copy.length; i++) { |
376 |
SystemAction act = copy[i]; |
390 |
Action act = copy[i]; |
377 |
|
391 |
|
378 |
if (act != null) { |
392 |
if (act != null) { |
379 |
act.removePropertyChangeListener(this); |
393 |
act.removePropertyChangeListener(this); |
Lines 385-391
Link Here
|
385 |
copy = am.getContextActions(); |
399 |
copy = am.getContextActions(); |
386 |
|
400 |
|
387 |
for (int i = 0; i < copy.length; i++) { |
401 |
for (int i = 0; i < copy.length; i++) { |
388 |
SystemAction act = copy[i]; |
402 |
Action act = copy[i]; |
389 |
|
403 |
|
390 |
if (act != null) { |
404 |
if (act != null) { |
391 |
act.addPropertyChangeListener(this); |
405 |
act.addPropertyChangeListener(this); |
Lines 402-413
Link Here
|
402 |
firePropertyChange(PROP_STATE, null, null); // tell the world |
416 |
firePropertyChange(PROP_STATE, null, null); // tell the world |
403 |
} |
417 |
} |
404 |
|
418 |
|
|
|
419 |
@Override |
405 |
public void propertyChange(PropertyChangeEvent ev) { |
420 |
public void propertyChange(PropertyChangeEvent ev) { |
406 |
String prop = ev.getPropertyName(); |
421 |
String prop = ev.getPropertyName(); |
407 |
|
422 |
|
408 |
if ((prop == null) || prop.equals(ActionManager.PROP_CONTEXT_ACTIONS)) { |
423 |
if ((prop == null) || prop.equals(ActionManager.PROP_CONTEXT_ACTIONS)) { |
409 |
actionsListChanged(); |
424 |
actionsListChanged(); |
410 |
} else if (prop.equals(SystemAction.PROP_ENABLED)) { |
425 |
} else if (prop.equals("enabled")) { |
411 |
actionStateChanged(); |
426 |
actionStateChanged(); |
412 |
} |
427 |
} |
413 |
} |
428 |
} |
Lines 417-423
Link Here
|
417 |
*/ |
432 |
*/ |
418 |
private boolean isPopupEnabled(Action toolsAction) { |
433 |
private boolean isPopupEnabled(Action toolsAction) { |
419 |
boolean en = false; |
434 |
boolean en = false; |
420 |
SystemAction[] copy = actions; |
435 |
Action[] copy = actions; |
421 |
|
436 |
|
422 |
// Get action conext. |
437 |
// Get action conext. |
423 |
Lookup lookup; |
438 |
Lookup lookup; |
Lines 470-517
Link Here
|
470 |
} |
485 |
} |
471 |
|
486 |
|
472 |
/** Overrides superclass method, adds delegate description. */ |
487 |
/** Overrides superclass method, adds delegate description. */ |
|
|
488 |
@Override |
473 |
public String toString() { |
489 |
public String toString() { |
474 |
return super.toString() + "[delegate=" + delegate + "]"; // NOI18N |
490 |
return super.toString() + "[delegate=" + delegate + "]"; // NOI18N |
475 |
} |
491 |
} |
476 |
|
492 |
|
477 |
/** Implements <code>Lookup.Provider</code>. */ |
493 |
/** Implements <code>Lookup.Provider</code>. */ |
|
|
494 |
@Override |
478 |
public Lookup getLookup() { |
495 |
public Lookup getLookup() { |
479 |
return lookup; |
496 |
return lookup; |
480 |
} |
497 |
} |
481 |
|
498 |
|
|
|
499 |
@Override |
482 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
500 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
483 |
} |
501 |
} |
484 |
|
502 |
|
|
|
503 |
@Override |
485 |
public void putValue(String key, Object o) { |
504 |
public void putValue(String key, Object o) { |
486 |
} |
505 |
} |
487 |
|
506 |
|
|
|
507 |
@Override |
488 |
public Object getValue(String key) { |
508 |
public Object getValue(String key) { |
489 |
return delegate.getValue(key); |
509 |
return delegate.getValue(key); |
490 |
} |
510 |
} |
491 |
|
511 |
|
|
|
512 |
@Override |
492 |
public boolean isEnabled() { |
513 |
public boolean isEnabled() { |
493 |
// Irrelevant see G#isPopupEnabled(..). |
514 |
// Irrelevant see G#isPopupEnabled(..). |
494 |
return delegate.isEnabled(); |
515 |
return delegate.isEnabled(); |
495 |
} |
516 |
} |
496 |
|
517 |
|
|
|
518 |
@Override |
497 |
public void setEnabled(boolean b) { |
519 |
public void setEnabled(boolean b) { |
498 |
// Irrelevant see G#isPopupEnabled(..). |
520 |
// Irrelevant see G#isPopupEnabled(..). |
499 |
} |
521 |
} |
500 |
|
522 |
|
|
|
523 |
@Override |
501 |
public void addPropertyChangeListener(PropertyChangeListener listener) { |
524 |
public void addPropertyChangeListener(PropertyChangeListener listener) { |
502 |
support.addPropertyChangeListener(listener); |
525 |
support.addPropertyChangeListener(listener); |
503 |
} |
526 |
} |
504 |
|
527 |
|
|
|
528 |
@Override |
505 |
public void removePropertyChangeListener(PropertyChangeListener listener) { |
529 |
public void removePropertyChangeListener(PropertyChangeListener listener) { |
506 |
support.removePropertyChangeListener(listener); |
530 |
support.removePropertyChangeListener(listener); |
507 |
} |
531 |
} |
508 |
|
532 |
|
509 |
/** Implements <code>Presenter.Menu</code>. */ |
533 |
/** Implements <code>Presenter.Menu</code>. */ |
|
|
534 |
@Override |
510 |
public javax.swing.JMenuItem getMenuPresenter() { |
535 |
public javax.swing.JMenuItem getMenuPresenter() { |
511 |
return new Inline(this); |
536 |
return new Inline(this); |
512 |
} |
537 |
} |
513 |
|
538 |
|
514 |
/** Implements <code>Presenter.Popup</code>. */ |
539 |
/** Implements <code>Presenter.Popup</code>. */ |
|
|
540 |
@Override |
515 |
public javax.swing.JMenuItem getPopupPresenter() { |
541 |
public javax.swing.JMenuItem getPopupPresenter() { |
516 |
return new ToolsAction.Popup(this); |
542 |
return new ToolsAction.Popup(this); |
517 |
} |
543 |
} |