summaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/tests/book/MyUploader.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/itmill/toolkit/tests/book/MyUploader.java')
-rw-r--r--src/com/itmill/toolkit/tests/book/MyUploader.java24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/com/itmill/toolkit/tests/book/MyUploader.java b/src/com/itmill/toolkit/tests/book/MyUploader.java
index a9215f09b5..2702bbf087 100644
--- a/src/com/itmill/toolkit/tests/book/MyUploader.java
+++ b/src/com/itmill/toolkit/tests/book/MyUploader.java
@@ -9,13 +9,17 @@ import java.io.FileOutputStream;
import java.io.OutputStream;
import com.itmill.toolkit.terminal.FileResource;
-import com.itmill.toolkit.ui.*;
+import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.Embedded;
+import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.Panel;
+import com.itmill.toolkit.ui.Upload;
-public class MyUploader extends CustomComponent
-implements Upload.SucceededListener, Upload.FailedListener, Upload.Receiver {
- Panel root; // Root element for contained components.
- Panel imagePanel; // Panel that contains the uploaded image.
- File file; // File to write to.
+public class MyUploader extends CustomComponent implements
+ Upload.SucceededListener, Upload.FailedListener, Upload.Receiver {
+ Panel root; // Root element for contained components.
+ Panel imagePanel; // Panel that contains the uploaded image.
+ File file; // File to write to.
MyUploader() {
root = new Panel("My Upload Component");
@@ -30,7 +34,8 @@ implements Upload.SucceededListener, Upload.FailedListener, Upload.Receiver {
upload.addListener((Upload.FailedListener) this);
root.addComponent(upload);
- root.addComponent(new Label("Click 'Browse' to select a file and then click 'Upload'."));
+ root.addComponent(new Label(
+ "Click 'Browse' to select a file and then click 'Upload'."));
// Create a panel for displaying the uploaded file (image).
imagePanel = new Panel("Uploaded image");
@@ -59,9 +64,10 @@ implements Upload.SucceededListener, Upload.FailedListener, Upload.Receiver {
// Log the upload on screen.
root.addComponent(new Label("File " + event.getFilename()
+ " of type '" + event.getMIMEType() + "' uploaded."));
-
+
// Display the uploaded file in the image panel.
- final FileResource imageResource = new FileResource(file, getApplication());
+ final FileResource imageResource = new FileResource(file,
+ getApplication());
imagePanel.removeAllComponents();
imagePanel.addComponent(new Embedded("", imageResource));
}