import java.util.regex.Pattern;
import com.vaadin.Application;
+import com.vaadin.event.ActionManager;
import com.vaadin.event.EventRouter;
import com.vaadin.event.MethodEventSource;
+import com.vaadin.event.ShortcutListener;
import com.vaadin.terminal.ErrorMessage;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
private ComponentErrorHandler errorHandler = null;
+ /**
+ * Keeps track of the Actions added to this component; the actual
+ * handling/notifying is delegated, usually to the containing window.
+ */
+ private ActionManager actionManager;
+
/* Constructor */
/**
if (delayedFocus) {
focus();
}
+ if (actionManager != null) {
+ actionManager.setViewer(getWindow());
+ }
}
/*
* we use the default documentation from implemented interface.
*/
public void detach() {
+ if (actionManager != null) {
+ actionManager.setViewer((Window) null);
+ }
}
/**
}
+ /*
+ * Actions
+ */
+
+ /**
+ * Gets the {@link ActionManager} used to manage the
+ * {@link ShortcutListener}s added to this {@link Field}.
+ *
+ * @return the ActionManager in use
+ */
+ protected ActionManager getActionManager() {
+ if (actionManager == null) {
+ actionManager = new ActionManager();
+ if (getWindow() != null) {
+ actionManager.setViewer(getWindow());
+ }
+ }
+ return actionManager;
+ }
+
+ public void addShortcutListener(ShortcutListener shortcut) {
+ getActionManager().addAction(shortcut);
+ }
+
+ public void removeShortcutListener(ShortcutListener shortcut) {
+ if (actionManager != null) {
+ actionManager.removeAction(shortcut);
+ }
+ }
+
}
\ No newline at end of file
import com.vaadin.data.Validator;
import com.vaadin.data.Validator.InvalidValueException;
import com.vaadin.event.Action;
-import com.vaadin.event.ActionManager;
import com.vaadin.event.ShortcutAction;
import com.vaadin.event.ShortcutListener;
import com.vaadin.terminal.CompositeErrorMessage;
*/
private boolean validationVisible = true;
- /**
- * Keeps track of the Actions added to this component; the actual
- * handling/notifying is delegated, usually to the containing window.
- */
- private ActionManager actionManager;
-
private boolean valueWasModifiedByDataSourceDuringCommit;
/* Component basics */
}
}
- /**
- * Notifies the component that it is connected to an application.
- *
- * @see com.vaadin.ui.Component#attach()
- */
- @Override
- public void attach() {
- super.attach();
- if (actionManager != null) {
- actionManager.setViewer(getWindow());
- }
- }
-
- @Override
- public void detach() {
- super.detach();
- if (actionManager != null) {
- actionManager.setViewer((Window) null);
- }
- }
-
/**
* Is this field required. Required fields must filled by the user.
*
requestRepaint();
}
- /*
- * Actions
- */
-
- /**
- * Gets the {@link ActionManager} used to manage the
- * {@link ShortcutListener}s added to this {@link Field}.
- *
- * @return the ActionManager in use
- */
- protected ActionManager getActionManager() {
- if (actionManager == null) {
- actionManager = new ActionManager();
- if (getWindow() != null) {
- actionManager.setViewer(getWindow());
- }
- }
- return actionManager;
- }
-
- public void addShortcutListener(ShortcutListener shortcut) {
- getActionManager().addAction(shortcut);
- }
-
- public void removeShortcutListener(ShortcutListener shortcut) {
- if (actionManager != null) {
- actionManager.removeAction(shortcut);
- }
- }
-
/**
* A ready-made {@link ShortcutListener} that focuses the given
* {@link Focusable} (usually a {@link Field}) when the keyboard shortcut is