return icon;
}
+ /**
+ * An Action that implements this interface can be added to an
+ * Action.Notifier (or NotifierProxy) via the <code>addAction()</code>
+ * -method, which in many cases is easier than implementing the
+ * Action.Handler interface.<br/>
+ *
+ */
public interface Listener {
public void handleAction(Object sender, Object target);
}
+ /**
+ * Action.Containers implementing this support an easier way of adding
+ * single Actions than the more involved Action.Handler. The added actions
+ * must be Action.Listeners, thus handling the action themselves.
+ *
+ */
public interface Notifier extends Container {
public <T extends Action & Action.Listener> void addAction(T action);
public <T extends Action & Action.Listener> void removeAction(T action);
}
- public interface NotifierProxy {
- public <T extends Action & Action.Listener> void addAction(T action);
+ public interface ShortcutNotifier {
+ public void addShortcutListener(ShortcutListener shortcut);
- public <T extends Action & Action.Listener> void removeAction(T action);
+ public void removeShortcutListener(ShortcutListener shortcut);
}
/**
*/
@SuppressWarnings("serial")
public abstract class AbstractField extends AbstractComponent implements Field,
- Property.ReadOnlyStatusChangeNotifier, Action.NotifierProxy {
+ Property.ReadOnlyStatusChangeNotifier, Action.ShortcutNotifier {
/* Private members */
* Keeps track of the Actions added to this component; the actual
* handling/notifying is delegated, usually to the containing window.
*/
- protected ActionManager actionManager;
+ private ActionManager actionManager;
/* Component basics */
if (delayedFocus) {
focus();
}
- if (actionManager != null && !(this instanceof Action.Container)) {
- // Only for non Action.Containers because those want to paint
- // actions themselves - e.g Form
+ if (actionManager != null) {
actionManager.setViewer(getWindow());
}
}
@Override
public void detach() {
super.detach();
- if (actionManager != null && !(this instanceof Action.Container)) {
- // Only for non Action.Containers because those want to paint
- // actions themselves - e.g Form
+ if (actionManager != null) {
actionManager.setViewer((Window) null);
}
}
return actionManager;
}
- public <T extends Action & Action.Listener> void addAction(T action) {
- getActionManager().addAction(action);
+ public void addShortcutListener(ShortcutListener shortcut) {
+ getActionManager().addAction(shortcut);
}
- public <T extends Action & Action.Listener> void removeAction(T action) {
+ public void removeShortcutListener(ShortcutListener shortcut) {
if (actionManager == null) {
- actionManager.removeAction(action);
+ actionManager.removeAction(shortcut);
}
}
public ClickShortcut setClickShortcut(int keyCode, int... modifiers) {
ClickShortcut old = clickShortcut;
if (old != null) {
- removeAction(old);
+ removeShortcutListener(old);
}
clickShortcut = new ClickShortcut(this, keyCode, modifiers);
- addAction(clickShortcut);
+ addShortcutListener(clickShortcut);
return old;
}
public void removeClickShortcut() {
if (clickShortcut != null) {
- removeAction(clickShortcut);
+ removeShortcutListener(clickShortcut);
clickShortcut = null;
}
}
import com.vaadin.event.Action;
import com.vaadin.event.ActionManager;
import com.vaadin.event.Action.Handler;
+import com.vaadin.event.Action.ShortcutNotifier;
import com.vaadin.terminal.CompositeErrorMessage;
import com.vaadin.terminal.ErrorMessage;
import com.vaadin.terminal.PaintException;
@SuppressWarnings("serial")
@ClientWidget(VForm.class)
public class Form extends AbstractField implements Item.Editor, Buffered, Item,
- Validatable, Action.Container {
+ Validatable, Action.Notifier {
private Object propertyValue;
/**
* Keeps track of the Actions added to this component, and manages the
- * painting and handling as well.
+ * painting and handling as well. Note that the extended AbstractField is a
+ * {@link ShortcutNotifier} and has a actionManager that delegates actions
+ * to the containing window. This one does not delegate.
*/
- ActionManager actionManager = new ActionManager(this);
+ ActionManager ownActionManager = new ActionManager(this);
/**
* Contructs a new form with default layout.
formFooter.paint(target);
}
- if (actionManager != null) {
- actionManager.paintActions(null, target);
+ if (ownActionManager != null) {
+ ownActionManager.paintActions(null, target);
}
}
super.changeVariables(source, variables);
// Actions
- if (actionManager != null) {
- actionManager.handleActions(variables, this);
+ if (ownActionManager != null) {
+ ownActionManager.handleActions(variables, this);
}
}
* ACTIONS
*/
- protected ActionManager getActionManager() {
- if (actionManager == null) {
- actionManager = new ActionManager(this);
+ protected ActionManager getOwnActionManager() {
+ if (ownActionManager == null) {
+ ownActionManager = new ActionManager(this);
}
- return actionManager;
+ return ownActionManager;
}
public void addActionHandler(Handler actionHandler) {
- getActionManager().addActionHandler(actionHandler);
+ getOwnActionManager().addActionHandler(actionHandler);
}
public void removeActionHandler(Handler actionHandler) {
- if (actionManager != null) {
- actionManager.removeActionHandler(actionHandler);
+ if (ownActionManager != null) {
+ ownActionManager.removeActionHandler(actionHandler);
}
}
* Removes all action handlers
*/
public void removeAllActionHandlers() {
- if (actionManager != null) {
- actionManager.removeAllActionHandlers();
+ if (ownActionManager != null) {
+ ownActionManager.removeAllActionHandlers();
+ }
+ }
+
+ public <T extends Action & com.vaadin.event.Action.Listener> void addAction(
+ T action) {
+ getOwnActionManager().addAction(action);
+ }
+
+ public <T extends Action & com.vaadin.event.Action.Listener> void removeAction(
+ T action) {
+ if (ownActionManager == null) {
+ ownActionManager.removeAction(action);
}
}
@ClientWidget(VPanel.class)
public class Panel extends AbstractComponentContainer implements Scrollable,
ComponentContainer.ComponentAttachListener,
- ComponentContainer.ComponentDetachListener, Action.Container,
- Action.Notifier {
+ ComponentContainer.ComponentDetachListener, Action.Notifier {
private static final String CLICK_EVENT = VPanel.CLICK_EVENT_IDENTIFIER;