@Test public void testSetContext() { new ContextAwareButton(action).setContext(context); Mockito.verify(action).canHandle(context); Mockito.verify(action, Mockito.atLeastOnce()).isEnabled(); }
public void setContext(ActionContext context) { if (context != null) { Action a = getAction(); if (a instanceof ContextAwareAction) { ContextAwareAction action = (ContextAwareAction) a; setVisible(action.canHandle(context)); setEnabled(action.isEnabled()); } } else { setVisible(false); setEnabled(false); } }
ContextAwareButton extends JButton { public void setContext(ActionContext context) { if (context != null) { Action a = getAction(); if (a instanceof ContextAwareAction) { ContextAwareAction action = (ContextAwareAction) a; setVisible(action.canHandle(context)); setEnabled(action.isEnabled()); } } else { setVisible(false); setEnabled(false); } } }
ContextAwareButton extends JButton { public void setContext(ActionContext context) { if (context != null) { Action a = getAction(); if (a instanceof ContextAwareAction) { ContextAwareAction action = (ContextAwareAction) a; setVisible(action.canHandle(context)); setEnabled(action.isEnabled()); } } else { setVisible(false); setEnabled(false); } } ContextAwareButton(ContextAwareAction action);  ContextAwareButton(ContextAwareAction action, ActionContext context); }
ContextAwareButton extends JButton { public void setContext(ActionContext context) { if (context != null) { Action a = getAction(); if (a instanceof ContextAwareAction) { ContextAwareAction action = (ContextAwareAction) a; setVisible(action.canHandle(context)); setEnabled(action.isEnabled()); } } else { setVisible(false); setEnabled(false); } } ContextAwareButton(ContextAwareAction action);  ContextAwareButton(ContextAwareAction action, ActionContext context); @Override void setIcon(Icon icon); @Override void setText(String text); void setContext(ActionContext context); }
ContextAwareButton extends JButton { public void setContext(ActionContext context) { if (context != null) { Action a = getAction(); if (a instanceof ContextAwareAction) { ContextAwareAction action = (ContextAwareAction) a; setVisible(action.canHandle(context)); setEnabled(action.isEnabled()); } } else { setVisible(false); setEnabled(false); } } ContextAwareButton(ContextAwareAction action);  ContextAwareButton(ContextAwareAction action, ActionContext context); @Override void setIcon(Icon icon); @Override void setText(String text); void setContext(ActionContext context);  }