summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2011-11-22 12:26:53 +0200
committerArtur Signell <artur@vaadin.com>2011-11-22 13:18:40 +0200
commita28763d2b933ab9f07e1b6faa4705b16b8d197ba (patch)
treeeb2e5534ead422878417cad84b2e6b24f1d2f482 /src
parent9a36668a93e3eec4607d76ba837bca729565b04e (diff)
downloadvaadin-framework-a28763d2b933ab9f07e1b6faa4705b16b8d197ba.tar.gz
vaadin-framework-a28763d2b933ab9f07e1b6faa4705b16b8d197ba.zip
#7963 Moved ActionManager from AbstractField to AbstractComponent to
enable Button to extend AbstractComponent
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/ui/AbstractComponent.java44
-rw-r--r--src/com/vaadin/ui/AbstractField.java58
2 files changed, 44 insertions, 58 deletions
diff --git a/src/com/vaadin/ui/AbstractComponent.java b/src/com/vaadin/ui/AbstractComponent.java
index eda2fd64ad..b9fffac35f 100644
--- a/src/com/vaadin/ui/AbstractComponent.java
+++ b/src/com/vaadin/ui/AbstractComponent.java
@@ -19,8 +19,10 @@ import java.util.regex.Matcher;
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;
@@ -145,6 +147,12 @@ public abstract class AbstractComponent implements Component, MethodEventSource
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 */
/**
@@ -635,6 +643,9 @@ public abstract class AbstractComponent implements Component, MethodEventSource
if (delayedFocus) {
focus();
}
+ if (actionManager != null) {
+ actionManager.setViewer(getWindow());
+ }
}
/*
@@ -642,6 +653,9 @@ public abstract class AbstractComponent implements Component, MethodEventSource
* we use the default documentation from implemented interface.
*/
public void detach() {
+ if (actionManager != null) {
+ actionManager.setViewer((Window) null);
+ }
}
/**
@@ -1517,4 +1531,34 @@ public abstract class AbstractComponent implements Component, MethodEventSource
}
+ /*
+ * 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
diff --git a/src/com/vaadin/ui/AbstractField.java b/src/com/vaadin/ui/AbstractField.java
index 7899569ea8..fe61d2a86c 100644
--- a/src/com/vaadin/ui/AbstractField.java
+++ b/src/com/vaadin/ui/AbstractField.java
@@ -18,7 +18,6 @@ import com.vaadin.data.Validatable;
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;
@@ -131,12 +130,6 @@ public abstract class AbstractField extends AbstractComponent implements Field,
*/
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 */
@@ -1111,27 +1104,6 @@ public abstract class AbstractField extends AbstractComponent implements Field,
}
/**
- * 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.
*
* If the field is required, it is visually indicated in the user interface.
@@ -1244,36 +1216,6 @@ public abstract class AbstractField extends AbstractComponent implements Field,
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