summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJani Laakso <jani.laakso@itmill.com>2008-02-08 15:09:51 +0000
committerJani Laakso <jani.laakso@itmill.com>2008-02-08 15:09:51 +0000
commit2af6fce62747adccb45b9332a0e5d8a84042ac03 (patch)
treedc85def3f99674501823628685cd135dca76205b
parent3c447bac504ddc6770e1ad15f38e4b0bec165851 (diff)
downloadvaadin-framework-2af6fce62747adccb45b9332a0e5d8a84042ac03.tar.gz
vaadin-framework-2af6fce62747adccb45b9332a0e5d8a84042ac03.zip
Deprecated Application.setFocusedComponent and Application.consumeFocus(), this design flaw will be fixed in later releases.
Upload setFocus() now works even if it is not yet attached. svn changeset:3755/svn branch:trunk
-rw-r--r--src/com/itmill/toolkit/Application.java7
-rw-r--r--src/com/itmill/toolkit/ui/AbstractField.java7
-rw-r--r--src/com/itmill/toolkit/ui/Upload.java25
-rw-r--r--src/com/itmill/toolkit/ui/Window.java28
4 files changed, 33 insertions, 34 deletions
diff --git a/src/com/itmill/toolkit/Application.java b/src/com/itmill/toolkit/Application.java
index ec9c8f8b79..e5b44542d0 100644
--- a/src/com/itmill/toolkit/Application.java
+++ b/src/com/itmill/toolkit/Application.java
@@ -1068,6 +1068,11 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
return context;
}
+ /**
+ * @deprecated Call component's focus method instead.
+ *
+ * @param focusable
+ */
public void setFocusedComponent(Focusable focusable) {
pendingFocus = focusable;
}
@@ -1075,6 +1080,8 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
/**
* Gets and nulls focused component in this window
*
+ * @deprecated This method will be replaced with focus listener in the
+ * future releases.
* @return Focused component or null if none is focused.
*/
public Component.Focusable consumeFocus() {
diff --git a/src/com/itmill/toolkit/ui/AbstractField.java b/src/com/itmill/toolkit/ui/AbstractField.java
index 9d926f0e7f..0b309ab562 100644
--- a/src/com/itmill/toolkit/ui/AbstractField.java
+++ b/src/com/itmill/toolkit/ui/AbstractField.java
@@ -11,6 +11,7 @@ import java.util.Date;
import java.util.Iterator;
import java.util.LinkedList;
+import com.itmill.toolkit.Application;
import com.itmill.toolkit.data.Buffered;
import com.itmill.toolkit.data.Property;
import com.itmill.toolkit.data.Validatable;
@@ -848,9 +849,9 @@ public abstract class AbstractField extends AbstractComponent implements Field,
* Asks the terminal to place the cursor to this field.
*/
public void focus() {
- final Window w = getWindow();
- if (w != null) {
- w.setFocusedComponent(this);
+ final Application app = getApplication();
+ if (app != null) {
+ app.setFocusedComponent(this);
} else {
delayedFocus = true;
}
diff --git a/src/com/itmill/toolkit/ui/Upload.java b/src/com/itmill/toolkit/ui/Upload.java
index 10123d3d5e..af5344c3cd 100644
--- a/src/com/itmill/toolkit/ui/Upload.java
+++ b/src/com/itmill/toolkit/ui/Upload.java
@@ -10,6 +10,7 @@ import java.io.OutputStream;
import java.lang.reflect.Method;
import java.util.Map;
+import com.itmill.toolkit.Application;
import com.itmill.toolkit.terminal.PaintException;
import com.itmill.toolkit.terminal.PaintTarget;
import com.itmill.toolkit.terminal.UploadStream;
@@ -42,6 +43,8 @@ import com.itmill.toolkit.terminal.UploadStream;
*/
public class Upload extends AbstractComponent implements Component.Focusable {
+ private boolean delayedFocus;
+
/**
* Upload buffer size.
*/
@@ -687,9 +690,11 @@ public class Upload extends AbstractComponent implements Component.Focusable {
* @see com.itmill.toolkit.ui.Component.Focusable#focus()
*/
public void focus() {
- final Window w = getWindow();
- if (w != null) {
- w.setFocusedComponent(this);
+ final Application app = getApplication();
+ if (app != null) {
+ app.setFocusedComponent(this);
+ } else {
+ delayedFocus = true;
}
}
@@ -822,4 +827,18 @@ public class Upload extends AbstractComponent implements Component.Focusable {
public void setButtonCaption(String buttonCaption) {
this.buttonCaption = buttonCaption;
}
+
+ /**
+ * Notifies the component that it is connected to an application.
+ *
+ * @see com.itmill.toolkit.ui.Component#attach()
+ */
+ public void attach() {
+ super.attach();
+ if (delayedFocus) {
+ delayedFocus = false;
+ focus();
+ }
+ }
+
}
diff --git a/src/com/itmill/toolkit/ui/Window.java b/src/com/itmill/toolkit/ui/Window.java
index a042a30776..416270f194 100644
--- a/src/com/itmill/toolkit/ui/Window.java
+++ b/src/com/itmill/toolkit/ui/Window.java
@@ -94,11 +94,6 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
private int border = BORDER_DEFAULT;
/**
- * Focused component.
- */
- private Focusable focusedComponent;
-
- /**
* Distance of Window top border in pixels from top border of the containing
* (main window) or -1 if unspecified.
*/
@@ -872,29 +867,6 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
}
/**
- * Gets the currently focused component in this window.
- *
- * @return the Focused component or null if none is focused.
- */
- public Component.Focusable getFocusedComponent() {
- return focusedComponent;
- }
-
- /**
- * Sets the currently focused component in this window.
- *
- * @param focusable
- * the Focused component or null if none is focused.
- */
- public void setFocusedComponent(Component.Focusable focusable) {
- final Application app = getApplication();
- if (app != null) {
- app.setFocusedComponent(focusable);
- focusedComponent = focusable;
- }
- }
-
- /**
* Gets the distance of Window left border in pixels from left border of the
* containing (main window).
*