<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 com.itmill.toolkit.event.Action;
import com.itmill.toolkit.ui.*;

public class FeatureTable extends Feature implements Action.Handler {

	private static final String[] firstnames = new String[] { "John", "Mary",
			"Joe", "Sarah", "Jeff", "Jane", "Peter", "Marc", "Josie", "Linus" };

	private static final String[] lastnames = new String[] { "Torvalds",
			"Smith", "Jones", "Beck", "Sheridan", "Picard", "Hill", "Fielding",
			"Einstein" };

	private static final String[] eyecolors = new String[] { "Blue", "Green",
			"Brown" };

	private static final String[] haircolors = new String[] { "Brown", "Black",
			"Red", "Blonde" };

	private Table t;

	private boolean actionsActive = false;

	private Button actionHandlerSwitch = new Button("Activate actions", this,
			"toggleActions");

	public void toggleActions() {
		if (actionsActive) {
			t.removeActionHandler(this);
			actionsActive = false;
			actionHandlerSwitch.setCaption("Activate Actions");
		} else {
			t.addActionHandler(this);
			actionsActive = true;
			actionHandlerSwitch.setCaption("Deactivate Actions");
		}
	}

	protected Component getDemoComponent() {

		OrderedLayout l = new OrderedLayout();

		// Sample table
		t = new Table("Most Wanted Persons List");
		t.setPageLength(10);
		l.addComponent(t);

		// Add columns to table
		t.addContainerProperty("Firstname", String.class, "");
		t.addContainerProperty("Lastname", String.class, "");
		t.addContainerProperty("Age", String.class, "");
		t.addContainerProperty("Eyecolor", String.class, "");
		t.addContainerProperty("Haircolor", String.class, "");

		// Add random rows to table
		for (int j = 0; j < 500; j++) {
			Object id = t
					.addItem(
							new Object[] {
									firstnames[(int) (Math.random() * (firstnames.length - 1))],
									lastnames[(int) (Math.random() * (lastnames.length - 1))],
									new Integer((int) (Math.random() * 80)),
									eyecolors[(int) (Math.random() * 3)],
									haircolors[(int) (Math.random() * 4)] },
							new Integer(j));
		}

		// Actions
		l.addComponent(this.actionHandlerSwitch);

		// Properties
		propertyPanel = new PropertyPanel(t);
		Form ap = propertyPanel.createBeanPropertySet(new String[] {
				"pageLength", "rowHeaderMode", "selectable",
				"columnHeaderMode", "columnCollapsingAllowed",
				"columnReorderingAllowed" });
		ap.replaceWithSelect("columnHeaderMode", new Object[] {
				new Integer(Table.COLUMN_HEADER_MODE_EXPLICIT),
				new Integer(Table.COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID),
				new Integer(Table.COLUMN_HEADER_MODE_HIDDEN),
				new Integer(Table.COLUMN_HEADER_MODE_ID) }, new Object[] {
				"Explicit", "Explicit defaults ID", "Hidden", "ID" });
		ap.replaceWithSelect("rowHeaderMode", new Object[] {
				new Integer(Table.ROW_HEADER_MODE_EXPLICIT),
				new Integer(Table.ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID),
				new Integer(Table.ROW_HEADER_MODE_HIDDEN),
				new Integer(Table.ROW_HEADER_MODE_ICON_ONLY),
				new Integer(Table.ROW_HEADER_MODE_ID),
				new Integer(Table.ROW_HEADER_MODE_INDEX),
				new Integer(Table.ROW_HEADER_MODE_ITEM),<commit_msg>Table width / height set<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 com.itmill.toolkit.event.Action;
import com.itmill.toolkit.terminal.Sizeable;
import com.itmill.toolkit.ui.*;

public class FeatureTable extends Feature implements Action.Handler {

	private static final String[] firstnames = new String[] { "John", "Mary",
			"Joe", "Sarah", "Jeff", "Jane", "Peter", "Marc", "Josie", "Linus" };

	private static final String[] lastnames = new String[] { "Torvalds",
			"Smith", "Jones", "Beck", "Sheridan", "Picard", "Hill", "Fielding",
			"Einstein" };

	private static final String[] eyecolors = new String[] { "Blue", "Green",
			"Brown" };

	private static final String[] haircolors = new String[] { "Brown", "Black",
			"Red", "Blonde" };

	private Table t;

	private boolean actionsActive = false;

	private Button actionHandlerSwitch = new Button("Activate actions", this,
			"toggleActions");

	public void toggleActions() {
		if (actionsActive) {
			t.removeActionHandler(this);
			actionsActive = false;
			actionHandlerSwitch.setCaption("Activate Actions");
		} else {
			t.addActionHandler(this);
			actionsActive = true;
			actionHandlerSwitch.setCaption("Deactivate Actions");
		}
	}

	protected Component getDemoComponent() {

		OrderedLayout l = new OrderedLayout();

		// Sample table
		t = new Table("Most Wanted Persons List");
		t.setPageLength(10);
		l.addComponent(t);

		// Add columns to table
		t.addContainerProperty("Firstname", String.class, "");
		t.addContainerProperty("Lastname", String.class, "");
		t.addContainerProperty("Age", String.class, "");
		t.addContainerProperty("Eyecolor", String.class, "");
		t.addContainerProperty("Haircolor", String.class, "");
		t.setHeight(250);
		t.setWidth(400);

		// Add random rows to table
		for (int j = 0; j < 300; j++) {
			Object id = t
					.addItem(
							new Object[] {
									firstnames[(int) (Math.random() * (firstnames.length - 1))],
									lastnames[(int) (Math.random() * (lastnames.length - 1))],
									new Integer((int) (Math.random() * 80)),
									eyecolors[(int) (Math.random() * 3)],
									haircolors[(int) (Math.random() * 4)] },
							new Integer(j));
		}

		// Actions
		l.addComponent(this.actionHandlerSwitch);

		// Properties
		propertyPanel = new PropertyPanel(t);
		Form ap = propertyPanel.createBeanPropertySet(new String[] {
				"pageLength", "rowHeaderMode", "selectable",
				"columnHeaderMode", "columnCollapsingAllowed",
				"columnReorderingAllowed", "width", "height" });
		ap.replaceWithSelect("columnHeaderMode", new Object[] {
				new Integer(Table.COLUMN_HEADER_MODE_EXPLICIT),
				new Integer(Table.COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID),
				new Integer(Table.COLUMN_HEADER_MODE_HIDDEN),
				new Integer(Table.COLUMN_HEADER_MODE_ID) }, new Object[] {
				"Explicit", "Explicit defaults ID", "Hidden", "ID" });
		ap.replaceWithSelect("rowHeaderMode", new Object[] {
				new Integer(Table.ROW_HEADER_MODE_EXPLICIT),
				new Integer(Table.ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID),
				new Integer(Table.ROW_HEADER_MODE_HIDDEN),
				new Integer(Table.ROW_HEADER_MODE_ICON_ONLY),
				new Integer(Table.ROW_HEADER_MODE_ID),
				new Integer(Table.ROW_HEADER_MODE_INDEX),
				new Integer(Table.ROW_HEADER_MODE_ITEM),
{'fraction_non_alphanumeric': 0.18607954545454544, 'fraction_numerical': 0.01278409090909091, 'mean_word_length': 4.035160905840286, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '3104265', 'n_tokens_mistral': 2913, 'n_tokens_neox': 2385, 'n_words': 622}