*/
private Locale locale;
+ /**
+ * The component should receive focus (if {@link Focusable}) when attached.
+ */
+ private boolean delayedFocus;
+
/**
* List of repaint request listeners or null if not listened at all.
*/
*/
public void attach() {
requestRepaint();
+ if (delayedFocus) {
+ focus();
+ }
}
/*
public void detach() {
}
+ /**
+ * Sets the focus for this component if the component is {@link Focusable}.
+ */
+ protected void focus() {
+ if (this instanceof Focusable) {
+ final Application app = getApplication();
+ if (app != null) {
+ getWindow().setFocusedComponent((Focusable) this);
+ delayedFocus = false;
+ } else {
+ delayedFocus = true;
+ }
+ }
+ }
+
/*
* Gets the parent application of the component. Don't add a JavaDoc comment
* here, we use the default documentation from implemented interface.
import java.util.LinkedList;
import java.util.Map;
-import com.vaadin.Application;
import com.vaadin.data.Buffered;
import com.vaadin.data.Property;
import com.vaadin.data.Validatable;
/* Private members */
- private boolean delayedFocus;
-
/**
* Value of the abstract field.
*/
}
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.ui.Component.Focusable#focus()
+ /**
+ * {@inheritDoc}
*/
+ @Override
public void focus() {
- final Application app = getApplication();
- if (app != null) {
- getWindow().setFocusedComponent(this);
- delayedFocus = false;
- } else {
- delayedFocus = true;
- }
+ super.focus();
}
/**
@Override
public void attach() {
super.attach();
- if (delayedFocus) {
- focus();
- }
if (actionManager != null) {
actionManager.setViewer(getWindow());
}
@ClientWidget(VUpload.class)
public class Upload extends AbstractComponent implements Component.Focusable {
- private boolean delayedFocus;
-
/**
* Upload buffer size.
*/
this.receiver = receiver;
}
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.ui.Component.Focusable#focus()
+ /**
+ * {@inheritDoc}
*/
+ @Override
public void focus() {
- final Application app = getApplication();
- if (app != null) {
- getWindow().setFocusedComponent(this);
- delayedFocus = false;
- } else {
- delayedFocus = true;
- }
+ super.focus();
}
/**
this.buttonCaption = buttonCaption;
}
- /**
- * Notifies the component that it is connected to an application.
- *
- * @see com.vaadin.ui.Component#attach()
- */
- @Override
- public void attach() {
- super.attach();
- if (delayedFocus) {
- focus();
- }
- }
-
}