module('apps.ActivityStream').requires().toRun(function() {

TextMorph.subclass('TagMorph', {
	contentData: undefined,

	tagType: "unknown",

	copyToHand: function($super, hand, evt, optCopier) {
		var copy = $super(hand, evt, optCopier);
		copy.setPosition(pt(0,0));
		return copy;
	},

	handlesMouseDown: function($super, evt) {
		if (this.owner && !(this.owner instanceof TagContainer))
			return $super(evt);

		if (evt.isLeftMouseButtonDown() && !evt.isShiftDown()) {
			if (this.contentData) {
				infoWindow = WorldMorph.current().addTextWindow(
					typeof this.contentData == 'string' ? this.contentData : JSON.serialize(this.contentData));
				infoWindow.owner.setTitle('Info window');
			}
			return true;
		} else
			return false;
	},

	onMouseDown: function($super, evt) {
		if (this.owner && !(this.owner instanceof TagContainer))
			return $super(evt);
		return;
	},

	onBlur: function($super, hand) {
		$super(hand);
		if (this.tagType == TagMorph.OBJECT) {
			var iconImg = this.submorphs[1];
			var txt = this.textString.trim();
			var url = URL.codeBase.withFilename('media/activitystream/' + txt + '.png');
			var exists = new WebResource(url).exists();
			console.log('Now look for icon for ' + txt + '... ' + iconImg);
			if (exists) {
				iconImg.setURL(url);
			}
		}
	},
});

Object.extend(TagMorph, {
	UNKNOWN: 'unknown',
	ACTOR: 'actor',
	VERB: 'verb',
	OBJECT: 'object',
	OPERATION: 'operation',
});

BoxMorph.subclass('TagContainer', {
	tagInfo: null,
});

}) // end of module