diff options
author | Jani Laakso <jani.laakso@itmill.com> | 2007-10-18 11:48:52 +0000 |
---|---|---|
committer | Jani Laakso <jani.laakso@itmill.com> | 2007-10-18 11:48:52 +0000 |
commit | e426fde1d12a0baaa9786048d85591dfcd701ee3 (patch) | |
tree | 55085d61638a21736f96404c25e610a324e365b6 /src/com/itmill/toolkit/demo/features/FeatureUpload.java | |
parent | 09d0f5071efeed61ad85c6cb3b3d4c2513d87e62 (diff) | |
download | vaadin-framework-e426fde1d12a0baaa9786048d85591dfcd701ee3.tar.gz vaadin-framework-e426fde1d12a0baaa9786048d85591dfcd701ee3.zip |
Removed old Feature Browser from demo package, simpler but better functioning demo will be added soon.
svn changeset:2549/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/demo/features/FeatureUpload.java')
-rw-r--r-- | src/com/itmill/toolkit/demo/features/FeatureUpload.java | 168 |
1 files changed, 0 insertions, 168 deletions
diff --git a/src/com/itmill/toolkit/demo/features/FeatureUpload.java b/src/com/itmill/toolkit/demo/features/FeatureUpload.java deleted file mode 100644 index a01296a4fd..0000000000 --- a/src/com/itmill/toolkit/demo/features/FeatureUpload.java +++ /dev/null @@ -1,168 +0,0 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ - -package com.itmill.toolkit.demo.features; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.io.OutputStream; - -import com.itmill.toolkit.terminal.StreamResource; -import com.itmill.toolkit.ui.Component; -import com.itmill.toolkit.ui.Label; -import com.itmill.toolkit.ui.Link; -import com.itmill.toolkit.ui.OrderedLayout; -import com.itmill.toolkit.ui.Panel; -import com.itmill.toolkit.ui.Upload; -import com.itmill.toolkit.ui.Upload.FinishedEvent; - -public class FeatureUpload extends Feature implements Upload.FinishedListener { - Buffer buffer = new Buffer(); - - Panel status = new Panel("Uploaded file:"); - - public FeatureUpload() { - super(); - } - - protected Component getDemoComponent() { - - OrderedLayout l = new OrderedLayout(); - - Upload up = new Upload("Upload", buffer); - up.setImmediate(true); - up.addListener(this); - - status.setVisible(false); - - l.addComponent(up); - l.addComponent(status); - - // Properties - propertyPanel = new PropertyPanel(up); - - setJavadocURL("ui/Upload.html"); - - return l; - } - - protected String getExampleSrc() { - return "Upload u = new Upload(\"Upload a file:\", uploadReceiver);\n\n" - + "public class uploadReceiver \n" - + "implements Upload.receiver, Upload.FinishedListener { \n" - + "\n" + " java.io.File file;\n" - + " java.io.FileOutputStream fos;\n" - + " public uploadReceiver() {\n" + " }"; - - } - - protected String getDescriptionXHTML() { - return "This demonstrates the use of the Upload component together with the Link component. " - + "This implementation does not actually store the file to disk, it only keeps it in a buffer. " - + "The example given on the <em>Code Sample</em>-tab on the other hand stores the file to disk and binds the link to that file."; - } - - protected String getImage() { - return "icon_demo.png"; - } - - protected String getTitle() { - return "Upload"; - } - - public void uploadFinished(FinishedEvent event) { - status.removeAllComponents(); - if (buffer.getStream() == null) - status.addComponent(new Label( - "Upload finished, but output buffer is null!!")); - else { - status - .addComponent(new Label("<b>Name:</b> " - + event.getFilename(), Label.CONTENT_XHTML)); - status.addComponent(new Label("<b>Mimetype:</b> " - + event.getMIMEType(), Label.CONTENT_XHTML)); - status.addComponent(new Label("<b>Size:</b> " + event.getLength() - + " bytes.", Label.CONTENT_XHTML)); - - status.addComponent(new Link("Download " + buffer.getFileName(), - new StreamResource(buffer, buffer.getFileName(), - getApplication()))); - - status.setVisible(true); - } - } - - public class Buffer implements StreamResource.StreamSource, Upload.Receiver { - ByteArrayOutputStream outputBuffer = null; - - String mimeType; - - String fileName; - - public Buffer() { - - } - - public InputStream getStream() { - if (outputBuffer == null) - return null; - return new ByteArrayInputStream(outputBuffer.toByteArray()); - } - - /** - * @see com.itmill.toolkit.ui.Upload.Receiver#receiveUpload(String, - * String) - */ - public OutputStream receiveUpload(String filename, String MIMEType) { - fileName = filename; - mimeType = MIMEType; - outputBuffer = new ByteArrayOutputStream(); - return outputBuffer; - } - - /** - * Returns the fileName. - * - * @return String - */ - public String getFileName() { - return fileName; - } - - /** - * Returns the mimeType. - * - * @return String - */ - public String getMimeType() { - return mimeType; - } - - } -}
\ No newline at end of file |