<commit_before>/* *************************************************************************
 
 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:  <EMAIL>
 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 a file:", null);
		up.addListener(this);

		status.setVisible(false);

		l.addComponent(up);
		l.addComponent(status);

		// Properties
		propertyPanel = new PropertyPanel(up);

		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 example-tab on the other hand stores the file to disk and binds the link to that file.<br/>"
				+ "<br/>On the demo tab you can try out how the different properties affect the presentation of the component.";
	}
<commit_msg>fixed various upload bugs<commit_after>/* *************************************************************************
 
 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:  <EMAIL>
 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 a file:", buffer);
		up.addListener(this);

		status.setVisible(false);

		l.addComponent(up);
		l.addComponent(status);

		// Properties
		propertyPanel = new PropertyPanel(up);

		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 example-tab on the other hand stores the file to disk and binds the link to that file.<br/>"
				+ "<br/>On the demo tab you can try out how the different properties affect the presentation of the component.";
	}

{'fraction_non_alphanumeric': 0.18178682304242844, 'fraction_numerical': 0.013452914798206279, 'mean_word_length': 3.75327868852459, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6957101', 'n_tokens_mistral': 1708, 'n_tokens_neox': 1469, 'n_words': 519}