*/
private int tabIndex = 0;
- /**
- * Unique focusable id.
- */
- private long focusableId = -1;
-
/**
* Required field.
*/
/* Component basics ************************************************ */
- public AbstractField() {
- focusableId = Window.getNewFocusableId(this);
- }
-
/*
* Paints the field. Don't add a JavaDoc comment here, we use the default
* documentation from the implemented interface.
*/
public void paintContent(PaintTarget target) throws PaintException {
- // Focus control id
- if (focusableId > 0) {
- target.addAttribute("focusid", focusableId);
- }
-
// The tab ordering number
if (tabIndex > 0) {
target.addAttribute("tabindex", tabIndex);
value = newValue;
}
- /**
- * Gets the unique ID of focusable
- *
- * @see com.itmill.toolkit.ui.Component.Focusable#getFocusableId()
- */
- public long getFocusableId() {
- return focusableId;
- }
-
/**
* Notifies the component that it is connected to an application.
*
this.required = required;
}
- /**
- * Free used resources.
- *
- * @see java.lang.Object#finalize()
- */
- public void finalize() throws Throwable {
- if (focusableId > -1) {
- Window.removeFocusableId(focusableId);
- }
- super.finalize();
- }
}
\ No newline at end of file
*/
public void setTabIndex(int tabIndex);
- /**
- * Gets the unique ID of focusable. This will be used to move input
- * focus directly to this component.
- *
- * @return the Unique id of focusable.
- */
- public long getFocusableId();
-
}
}
// clear caption change listeners
getCaptionChangeListener().clear();
- // Focus control id
- if (getFocusableId() > 0) {
- target.addAttribute("focusid", getFocusableId());
- }
-
// The tab ordering number
if (getTabIndex() > 0) {
target.addAttribute("tabindex", getTabIndex());
*/
public void paintContent(PaintTarget target) throws PaintException {
- // Focus control id
- if (getFocusableId() > 0) {
- target.addAttribute("focusid", getFocusableId());
- }
-
// The tab ordering number
if (getTabIndex() > 0) {
target.addAttribute("tabindex", getTabIndex());
} else {
getCaptionChangeListener().clear();
- // Focus control id
- if (getFocusableId() > 0) {
- target.addAttribute("focusid", getFocusableId());
- }
-
// The tab ordering number
if (getTabIndex() > 0) {
target.addAttribute("tabindex", getTabIndex());
target.addAttribute("key", key);
if (isSelected(itemId)) {
target.addAttribute("selected", true);
- selectedKeys[keyIndex++] = key;
+ try {
+ selectedKeys[keyIndex++] = key;
+ } catch (Exception e) {
+ // TODO Fix, see TreeExample (featurebrowser)
+ e.printStackTrace();
+ }
}
if (areChildrenAllowed(itemId) && isExpanded(itemId)) {
target.addAttribute("expanded", true);
/**
* Component for uploading files from client to server.
*
- * The visible component consists of a file name input box and a browse
- * button and an upload submit button to start uploading.
+ * The visible component consists of a file name input box and a browse button
+ * and an upload submit button to start uploading.
*
- * The Upload component needs a java.io.OutputStream to write the uploaded
- * data. You need to implement the Upload.Receiver interface and return
- * the output stream in the receiveUpload() method.
+ * The Upload component needs a java.io.OutputStream to write the uploaded data.
+ * You need to implement the Upload.Receiver interface and return the output
+ * stream in the receiveUpload() method.
*
- * You can get an event regarding starting (StartedEvent),
- * progress (ProgressEvent), and finishing (FinishedEvent) of upload by
- * implementing StartedListener, ProgressListener, and FinishedListener,
- * respectively. The FinishedListener is called for both failed and
- * succeeded uploads. If you wish to separate between these two cases,
- * you can use SucceededListener (SucceededEvenet) and FailedListener
- * (FailedEvent).
+ * You can get an event regarding starting (StartedEvent), progress
+ * (ProgressEvent), and finishing (FinishedEvent) of upload by implementing
+ * StartedListener, ProgressListener, and FinishedListener, respectively. The
+ * FinishedListener is called for both failed and succeeded uploads. If you wish
+ * to separate between these two cases, you can use SucceededListener
+ * (SucceededEvenet) and FailedListener (FailedEvent).
*
- * The upload component does not itself show upload progress, but
- * you can use the ProgressIndicator for providing progress feedback
- * by implementing ProgressListener and updating the indicator in
- * updateProgress().
+ * The upload component does not itself show upload progress, but you can use
+ * the ProgressIndicator for providing progress feedback by implementing
+ * ProgressListener and updating the indicator in updateProgress().
*
* @author IT Mill Ltd.
* @version
*/
private Receiver receiver;
- private long focusableId = -1;
-
private boolean isUploading;
private long contentLength = -1;
* stream given by the Receiver.
*
* @param caption
- * Normal component caption. You can set the caption of the
- * upload submit button with setButtonCaption().
+ * Normal component caption. You can set the caption of the
+ * upload submit button with setButtonCaption().
* @param uploadReceiver
- * Receiver to call to retrieve output stream when upload
- * starts.
+ * Receiver to call to retrieve output stream when upload
+ * starts.
*/
public Upload(String caption, Receiver uploadReceiver) {
- focusableId = Window.getNewFocusableId(this);
setCaption(caption);
receiver = uploadReceiver;
}
}
/**
- * Interface that must be implemented by the upload receivers to provide
- * the Upload component an output stream to write the uploaded data.
+ * Interface that must be implemented by the upload receivers to provide the
+ * Upload component an output stream to write the uploaded data.
*
* @author IT Mill Ltd.
* @version
this.tabIndex = tabIndex;
}
- /**
- * Gets the unique ID of focusable.
- *
- * @see com.itmill.toolkit.ui.Component.Focusable#getFocusableId()
- */
- public long getFocusableId() {
- return focusableId;
- }
-
/**
* Sets the size of the file currently being uploaded.
*
* Go into upload state. This is to prevent double uploading on same
* component.
*
- * Warning: this is an internal method used by the framework and should
- * not be used by user of the Upload component. Using it results
- * in the Upload component going in wrong state and not working.
- * It is currently public because it is used by another class.
+ * Warning: this is an internal method used by the framework and should not
+ * be used by user of the Upload component. Using it results in the Upload
+ * component going in wrong state and not working. It is currently public
+ * because it is used by another class.
*/
public void startUpload() {
if (isUploading) {
/**
* Go into state where new uploading can begin.
*
- * Warning: this is an internal method used by the framework and should
- * not be used by user of the Upload component.
+ * Warning: this is an internal method used by the framework and should not
+ * be used by user of the Upload component.
*/
public void endUpload() {
isUploading = false;
package com.itmill.toolkit.ui;
-import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
// Window closing
target.addVariable(this, "close", false);
- // Sets the focused component
- if (focusedComponent != null) {
- target.addVariable(this, "focused", ""
- + focusedComponent.getFocusableId());
- } else {
- target.addVariable(this, "focused", "");
- }
-
// Paint subwindows
for (final Iterator i = subwindows.iterator(); i.hasNext();) {
final Window w = (Window) i.next();
public void changeVariables(Object source, Map variables) {
super.changeVariables(source, variables);
- // Gets the focused component
- final String focusedId = (String) variables.get("focused");
- if (focusedId != null) {
- try {
- final long id = Long.parseLong(focusedId);
- focusedComponent = Window.getFocusableById(id);
- } catch (final NumberFormatException ignored) {
- // We ignore invalid focusable ids
- }
- }
-
// Positioning
final Integer positionx = (Integer) variables.get("positionx");
if (positionx != null) {
}
}
- /* Focusable id generator ****************************************** */
-
- private static long lastUsedFocusableId = 0;
-
- private static Map focusableComponents = new HashMap();
-
- /**
- * Gets an id for focusable component.
- *
- * @param focusable
- * the focused component.
- */
- public static long getNewFocusableId(Component.Focusable focusable) {
- final long newId = ++lastUsedFocusableId;
- final WeakReference ref = new WeakReference(focusable);
- focusableComponents.put(new Long(newId), ref);
- return newId;
- }
-
- /**
- * Maps the focusable id back to focusable component.
- *
- * @param focusableId
- * the Focused Id.
- * @return the focusable Id.
- */
- public static Component.Focusable getFocusableById(long focusableId) {
- final WeakReference ref = (WeakReference) focusableComponents
- .get(new Long(focusableId));
- if (ref != null) {
- final Object o = ref.get();
- if (o != null) {
- return (Component.Focusable) o;
- }
- }
- return null;
- }
-
- /**
- * Releases the focusable component id when not used anymore.
- *
- * @param focusableId
- * the focusable Id to remove.
- */
- public static void removeFocusableId(long focusableId) {
- final Long id = new Long(focusableId);
- final WeakReference ref = (WeakReference) focusableComponents.get(id);
- ref.clear();
- focusableComponents.remove(id);
- }
-
/**
* Gets the distance of Window left border in pixels from left border of the
* containing (main window).