<commit_before><?xml version="1.0" encoding="utf-8"?>
<!--
/*
    Weave (Web-based Analysis and Visualization Environment)
    Copyright (C) 2008-2011 University of Massachusetts Lowell

    This file is a part of Weave.

    Weave is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License, Version 3,
    as published by the Free Software Foundation.

    Weave is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Weave.  If not, see <http://www.gnu.org/licenses/>.
*/
-->
<!---
@author abaumann
@author skolman
@author adufilie
-->
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" 
		 xmlns="weave.ui.*"
		 width="100%" height="30"
		 verticalAlign="middle" implements="weave.api.core.ILinkableObject"
		 horizontalGap="4">
	<mx:Label text="{label}" fontWeight="bold" minWidth="64"/>
	<LinkableObjectList id="internalList" 
						variableRowHeight="false"
			 
		 				doubleClickEnabled="true" 
		 				doubleClick="openAttributeSelector()"
		 				width="100%" rowCount="1" height="24"/>
	<CenteredImage source="@Embed(source='/weave/resources/images/folder.png')" buttonMode="true" height="24"
		       toolTip="Click here to select the column used for this property."
			   click="openAttributeSelector()"/>
	<CenteredImage source="@Embed(source='/weave/resources/images/trashCan.png')" buttonMode="true" height="24"
			   click="clearAttribute()"
			   toolTip="Click here to remove the column used for this property."/>
	<CenteredImage id="linkImage" buttonMode="true" height="24"
				 
				 visible="false" includeInLayout="false"
				 
				 mouseDown="updateLinkDropDown(!linkDropDown.parent);"/>
	
	<mx:VBox id="linkDropDown" verticalGap="0" horizontalAlign="right" borderStyle="outset" backgroundAlpha="1" backgroundColor="0xFFFFFF">
		<mx:HBox horizontalGap="0">
			<TextInputWithPrompt id="linkName" prompt="Enter a name" toolTip="Enter the name of a new or existing global object to link."
								 enter="linkTo(StringUtil.trim(linkName.text));"/>
			<mx:Button label="Link" enabled="{linkName.text ? true : false}" click="linkTo(StringUtil.trim(linkName.text));"/>
			<mx:Button id="unlinkButton" label="Unlink" click="linkTo(null);"/>
		</mx:HBox>
		<mx:List id="linkList" borderStyle="outset" width="100%"
				 change="if (linkDropDown.parent) linkTo(linkList.selectedItem as String);"/>
	</mx:VBox>
	<mx:Script>
		<![CDATA[
			import mx.core.UIComponent;
			import mx.events.DragEvent;
			import mx.managers.DragManager;
			import mx.managers.PopUpManager;
			import mx.utils.StringUtil;
			
			import weave.Weave;
			import weave.api.core.ILinkableDynamicObject;
			import weave.api.core.ILinkableHashMap;
			import weave.api.data.IAttributeColumn;
			import weave.api.getCallbackCollection;
			import weave.core.SessionManager;
			import weave.data.AttributeColumns.DynamicColumn;
			import weave.visualization.tools.SimpleVisTool;
			
			[Embed(source='/weave/resources/images/plug-connected.png')]
			private static const icon_connected:Class;
			[Embed(source='/weave/resources/images/plug-disconnected.png')]
			private static const icon_disconnected:Class;
			
			override protected function createChildren():void
			{
				super.createChildren();
				linkDropDown.parent.removeChild(linkDropDown);
			}
			
			[Inspectable]
			public function set dynamicObject(value:ILinkableDynamicObject):void
			{
				if (internalList.dynamicObject)
					getCallbackCollection(internalList.dynamicObject).removeCallback(updateLinkDropDown);
				
				internalList.dynamicObject = value;
				
				if (value)
					getCallbackCollection(value).addImmediateCallback(this, updateLinkDropDown, null, true);
			}
			
			private var _visTool:SimpleVisTool = null;
			[Inspectable]
			public function set visTool(value:SimpleVisTool):void
			{
				_visTool = value;
			}
			
			private function openAttributeSelector():void
			{
				if (_visTool)
					AttributeSelectorPanel.openToolSelector(_visTool, internalList.dynamicObject);
				else
					AttributeSelectorPanel.openDefaultSelector(internalList.dynamicObject, label);
			}
			
			private function clearAttribute():void
			{
				var dc:DynamicColumn = AttributeSelectorPanel.hack_findInternalDynamicColumn(internalList.dynamicObject as DynamicColumn);
				if (dc)
					dc.removeObject();
			}
			
			private function updateLinkDropDown(show:Boolean = false):void
			{
				if (internalList.dynamicObject.globalName)
					linkImage.source = icon_connected;
				else
					linkImage.source = icon_disconnected;
				
				if (show)
				{
					if (!linkDropDown.parent)
						PopUpManager.addPopUp(linkDropDown, this);
					var globalBottomRight:Point = linkImage.parent.localToGlobal(new Point(linkImage.x + linkImage.width, linkImage.y + linkImage.height));
					var localPoint:Point = linkDropDown.parent.globalToLocal(globalBottomRight);
					linkDropDown.x = localPoint.x - linkDropDown.width;
					linkDropDown.y = localPoint.y;
					
					var globalName:String = internalList.dynamicObject.globalName;
					linkList.dataProvider = Weave.root.getNames(IAttributeColumn);
					linkList.selectedItem = globalName;
					linkName.text = internalList.dynamicObject.globalName;
					unlinkButton.enabled = globalName ? true : false;
				}
				else
				{
					if (linkDropDown.parent)
						PopUpManager.removePopUp(linkDropDown);
				}
			}
			
			private function linkTo(globalName:String):void
			{
				internalList.dynamicObject.globalName = globalName;
				updateLinkDropDown();
			}
		]]>
	</mx:Script>
</mx:HBox>
<commit_msg>Improved linking controls popup, added tooltip and help component.<commit_after><?xml version="1.0" encoding="utf-8"?>
<!--
/*
    Weave (Web-based Analysis and Visualization Environment)
    Copyright (C) 2008-2011 University of Massachusetts Lowell

    This file is a part of Weave.

    Weave is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License, Version 3,
    as published by the Free Software Foundation.

    Weave is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Weave.  If not, see <http://www.gnu.org/licenses/>.
*/
-->
<!---
@author abaumann
@author skolman
@author adufilie
-->
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" 
		 xmlns="weave.ui.*"
		 width="100%" height="30"
		 verticalAlign="middle" implements="weave.api.core.ILinkableObject"
		 horizontalGap="4">
	<mx:Label text="{label}" fontWeight="bold" minWidth="64"/>
	<LinkableObjectList id="internalList" 
						variableRowHeight="false"
			 
		 				doubleClickEnabled="true" 
		 				doubleClick="openAttributeSelector()"
		 				width="100%" rowCount="1" height="24"/>
	<CenteredImage source="@Embed(source='/weave/resources/images/folder.png')" buttonMode="true" height="24"
		       toolTip="Click here to select the column used for this property."
			   click="openAttributeSelector()"/>
	<CenteredImage source="@Embed(source='/weave/resources/images/trashCan.png')" buttonMode="true" height="24"
			   click="clearAttribute()"
			   toolTip="Click here to remove the column used for this property."/>
	<CenteredImage id="linkImage" buttonMode="true" height="24"
				 mouseDown="toggleLinkDropDown(!linkDropDown.parent);"/>
	
	<mx:TitleWindow id="linkDropDown"
					title="Linking controls for {label}"
					showCloseButton="true"
					verticalGap="{linkControlsPadding}"
					borderThicknessTop="{linkControlsPadding}" borderThicknessRight="{linkControlsPadding}"
					borderThicknessLeft="{linkControlsPadding}" borderThicknessBottom="{linkControlsPadding}"
					paddingTop="{0}" paddingRight="{0}"
					paddingLeft="{0}" paddingBottom="{0}"
					backgroundColor="0xCCCCCC" headerHeight="20"
					horizontalAlign="right" borderStyle="outset" backgroundAlpha="1"
					close="toggleLinkDropDown();">
		<mx:HBox horizontalGap="{linkControlsPadding}">
			<HelpComponent>You can link two or more attributes together so that changing one will change the rest.  Click on the name of an existing linked group or type the name of a new one.</HelpComponent>
			<TextInputWithPrompt id="linkName" prompt="Enter a new group name"
								 enter="linkTo(StringUtil.trim(linkName.text));"/>
			<mx:Button label="Link" enabled="{linkName.text ? true : false}" click="linkTo(StringUtil.trim(linkName.text));"/>
			<mx:Button id="unlinkButton" label="Unlink" click="linkTo(null);"/>
		</mx:HBox>
		<mx:List id="linkList" width="100%"
				 change="if (linkDropDown.parent) linkTo(linkList.selectedItem as String);"/>
	</mx:TitleWindow>
	<mx:Script>
		<![CDATA[
			import mx.core.UIComponent;
			import mx.events.DragEvent;
			import mx.managers.DragManager;
			import mx.managers.PopUpManager;
			import mx.utils.StringUtil;
			
			import weave.Weave;
			import weave.api.core.ILinkableDynamicObject;
			import weave.api.core.ILinkableHashMap;
			import weave.api.data.IAttributeColumn;
			import weave.api.getCallbackCollection;
			import weave.core.SessionManager;
			import weave.data.AttributeColumns.DynamicColumn;
			import weave.visualization.tools.SimpleVisTool;
			
			[Embed(source='/weave/resources/images/plug-connected.png')]
			private static const icon_connected:Class;
			[Embed(source='/weave/resources/images/plug-disconnected.png')]
			private static const icon_disconnected:Class;
			
			private const linkControlsPadding:int = 2;
			
			override protected function createChildren():void
			{
				super.createChildren();
				linkDropDown.parent.removeChild(linkDropDown);
			}
			
			[Inspectable]
			public function set dynamicObject(value:ILinkableDynamicObject):void
			{
				if (internalList.dynamicObject)
					getCallbackCollection(internalList.dynamicObject).removeCallback(toggleLinkDropDown);
				
				internalList.dynamicObject = value;
				
				if (value)
					getCallbackCollection(value).addImmediateCallback(this, toggleLinkDropDown, null, true);
			}
			
			private var _visTool:SimpleVisTool = null;
			[Inspectable]
			public function set visTool(value:SimpleVisTool):void
			{
				_visTool = value;
			}
			
			private function openAttributeSelector():void
			{
				if (_visTool)
					AttributeSelectorPanel.openToolSelector(_visTool, internalList.dynamicObject);
				else
					AttributeSelectorPanel.openDefaultSelector(internalList.dynamicObject, label);
			}
			
			private function clearAttribute():void
			{
				var dc:DynamicColumn = AttributeSelectorPanel.hack_findInternalDynamicColumn(internalList.dynamicObject as DynamicColumn);
				if (dc)
					dc.removeObject();
			}
			
			private function toggleLinkDropDown(show:Boolean = false):void
			{
				var globalName:String = internalList.dynamicObject.globalName;
				if (globalName)
				{
					linkImage.source = icon_connected;
					unlinkButton.enabled = true;
					linkImage.toolTip = "Linked to " + globalName;
				}
				else
				{
					linkImage.source = icon_disconnected;
					unlinkButton.enabled = false;
					linkImage.toolTip = "Open linking controls";
				}
				
				if (show)
				{
					if (!linkDropDown.parent)
						PopUpManager.addPopUp(linkDropDown, this);
					var globalBottomRight:Point = linkImage.parent.localToGlobal(new Point(linkImage.x + linkImage.width, linkImage.y + linkImage.height));
					var localPoint:Point = linkDropDown.parent.globalToLocal(globalBottomRight);
					linkDropDown.x = localPoint.x - linkDropDown.width;
					linkDropDown.y = localPoint.y;
					
					linkList.dataProvider = Weave.root.getNames(IAttributeColumn);
					linkList.selectedItem = globalName;
					linkName.text = globalName;
					linkName.setFocus();
				}
				else
				{
					if (linkDropDown.parent)
						PopUpManager.removePopUp(linkDropDown);
				}
			}
			
			private function linkTo(globalName:String):void
			{
				internalList.dynamicObject.globalName = globalName;
				toggleLinkDropDown();
			}
		]]>
	</mx:Script>
</mx:HBox>

{'fraction_non_alphanumeric': 0.11101335679436936, 'fraction_numerical': 0.0072782532192273855, 'mean_word_length': 3.8559223300970875, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 2, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 8}, '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': '1362833', 'n_tokens_mistral': 4506, 'n_tokens_neox': 3614, 'n_words': 792}