<commit_before>
Ui.Draggable.extend('Ui.Selectionable', {
	isSelected: false,
	bg: undefined,
	contentBox: undefined,
	handler: undefined,

	constructor: function(config) {
		
		this.setData(this);
		
		this.bg = new Ui.Rectangle({ fill: '#dddddd', margin: 2 });
		this.bg.hide();
		this.append(this.bg);
		
		this.contentBox = new Ui.LBox({ margin: 5 });
		this.append(this.contentBox);
		
		this.connect(this, 'press', this.onPress);
		this.connect(this, 'activate', this.onActivate);
		this.connect(this, 'dragstart', this.onSelectionableDragStart);
		this.connect(this, 'dragend', this.onSelectionableDragEnd);
	},

	getIsSelected: function() {
		return this.isSelected;
	},
	
	setIsSelected: function(isSelected) {
		this.isSelected = isSelected;
		if(this.isSelected)
			this.bg.show();
		else
			this.bg.hide();
	},
		
	// ex:
	// {
	//   delete: { text: 'Delete', icon: 'trash', callback: this.onDelete, multiple: true },
	//   edit: ...
	// }
	getSelectionActions: function() {
		return {};
	},

	getParentSelectionHandler: function() {	
		// search for the selection handler
		var parent = this.getParent();
		while(parent != undefined) {
			if('getSelectionHandler' in parent)
				break;
			parent = parent.getParent();
		}
		if(parent != undefined)
			return parent.getSelectionHandler();
		else
			return undefined;
	},
	
	onSelectionableDragStart: function() {
		this.select();
	},
	
	onSelectionableDragEnd: function() {
		 if(this.getIsSelected()) {
			var handler = this.getParentSelectionHandler();
			if(handler !== undefined)
				handler.clear();
		}
	},
		
	onActivate: function() {
		if(this.getIsLoaded()) {
			this.select();
			var handler = this.getParentSelectionHandler();
			if(handler !== undefined)
				handler.executeDefaultAction();
		}
	},

	onPress: function() {
		if(this.getIsSelected())
			this.unselect();
		else
			this.select();
	},

	select: function() {
		if(this.getIsLoaded()) {
			this.handler = this.getParentSelectionHandler();
			if(this.handler !== undefined) {
				this.handler.append(this);
				this.setIsSelected(true);
			}
		}
	},
	
	unselect: function() {
		if(this.handler !== undefined) {
			this.handler.remove(this);
			this.setIsSelected(false);
		}
	}
}, {
	setContent: function(content) {
		this.contentBox.setContent(content);	
	},
	
	onUnload: function() {
		if(this.getIsSelected())
			this.unselect();
		Ui.Selectionable.base.onUnload.call(this);
	}
});<commit_msg>provide style control for Ui.Selectionable background<commit_after>
Ui.Draggable.extend('Ui.Selectionable', {
	isSelected: false,
	bg: undefined,
	contentBox: undefined,
	handler: undefined,

	constructor: function(config) {
		
		this.setData(this);
		
		this.bg = new Ui.Rectangle({ margin: 2 });
		this.bg.hide();
		this.append(this.bg);
		
		this.contentBox = new Ui.LBox({ margin: 5 });
		this.append(this.contentBox);
		
		this.connect(this, 'press', this.onPress);
		this.connect(this, 'activate', this.onActivate);
		this.connect(this, 'dragstart', this.onSelectionableDragStart);
		this.connect(this, 'dragend', this.onSelectionableDragEnd);
	},

	getIsSelected: function() {
		return this.isSelected;
	},
	
	setIsSelected: function(isSelected) {
		this.isSelected = isSelected;
		if(this.isSelected)
			this.bg.show();
		else
			this.bg.hide();
	},
		
	// ex:
	// {
	//   delete: { text: 'Delete', icon: 'trash', callback: this.onDelete, multiple: true },
	//   edit: ...
	// }
	getSelectionActions: function() {
		return {};
	},

	getParentSelectionHandler: function() {	
		// search for the selection handler
		var parent = this.getParent();
		while(parent != undefined) {
			if('getSelectionHandler' in parent)
				break;
			parent = parent.getParent();
		}
		if(parent != undefined)
			return parent.getSelectionHandler();
		else
			return undefined;
	},
	
	onSelectionableDragStart: function() {
		this.select();
	},
	
	onSelectionableDragEnd: function() {
		 if(this.getIsSelected()) {
			var handler = this.getParentSelectionHandler();
			if(handler !== undefined)
				handler.clear();
		}
	},
		
	onActivate: function() {
		if(this.getIsLoaded()) {
			this.select();
			var handler = this.getParentSelectionHandler();
			if(handler !== undefined)
				handler.executeDefaultAction();
		}
	},

	onPress: function() {
		if(this.getIsSelected())
			this.unselect();
		else
			this.select();
	},

	select: function() {
		if(this.getIsLoaded()) {
			this.handler = this.getParentSelectionHandler();
			if(this.handler !== undefined) {
				this.handler.append(this);
				this.setIsSelected(true);
			}
		}
	},
	
	unselect: function() {
		if(this.handler !== undefined) {
			this.handler.remove(this);
			this.setIsSelected(false);
		}
	}
}, {
	onStyleChange: function() {
		this.bg.setFill(this.getStyleProperty('shadow'));
	},

	setContent: function(content) {
		this.contentBox.setContent(content);	
	},
	
	onUnload: function() {
		if(this.getIsSelected())
			this.unselect();
		Ui.Selectionable.base.onUnload.call(this);
	}
}, {
	style: {
		shadow: '#dddddd'
	}
});
{'fraction_non_alphanumeric': 0.16250748652425634, 'fraction_numerical': 0.000798562587342783, 'mean_word_length': 3.7668886774500474, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3792096', 'n_tokens_mistral': 1920, 'n_tokens_neox': 1671, 'n_words': 293}