PageRenderTime 146ms CodeModel.GetById 49ms app.highlight 86ms RepoModel.GetById 1ms app.codeStats 1ms

/indra/newview/llsidepaneltaskinfo.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 1266 lines | 984 code | 152 blank | 130 comment | 178 complexity | 2bace816b3f7cb00d1da4e2e284c53f2 MD5 | raw file
   1/** 
   2 * @file llsidepaneltaskinfo.cpp
   3 * @brief LLSidepanelTaskInfo class implementation
   4 * This class represents the panel in the build view for
   5 * viewing/editing object names, owners, permissions, etc.
   6 *
   7 * $LicenseInfo:firstyear=2002&license=viewerlgpl$
   8 * Second Life Viewer Source Code
   9 * Copyright (C) 2010, Linden Research, Inc.
  10 * 
  11 * This library is free software; you can redistribute it and/or
  12 * modify it under the terms of the GNU Lesser General Public
  13 * License as published by the Free Software Foundation;
  14 * version 2.1 of the License only.
  15 * 
  16 * This library is distributed in the hope that it will be useful,
  17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  19 * Lesser General Public License for more details.
  20 * 
  21 * You should have received a copy of the GNU Lesser General Public
  22 * License along with this library; if not, write to the Free Software
  23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  24 * 
  25 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  26 * $/LicenseInfo$
  27 */
  28
  29#include "llviewerprecompiledheaders.h"
  30
  31#include "llsidepaneltaskinfo.h"
  32
  33#include "lluuid.h"
  34#include "llpermissions.h"
  35#include "llcategory.h"
  36#include "llclickaction.h"
  37#include "llfocusmgr.h"
  38#include "llnotificationsutil.h"
  39#include "llstring.h"
  40
  41#include "llviewerwindow.h"
  42#include "llresmgr.h"
  43#include "lltextbox.h"
  44#include "llbutton.h"
  45#include "llcheckboxctrl.h"
  46#include "llviewerobject.h"
  47#include "llselectmgr.h"
  48#include "llagent.h"
  49#include "llstatusbar.h"		// for getBalance()
  50#include "lllineeditor.h"
  51#include "llcombobox.h"
  52#include "lluiconstants.h"
  53#include "lldbstrings.h"
  54#include "llfloatergroups.h"
  55#include "llfloaterreg.h"
  56#include "llavataractions.h"
  57#include "llnamebox.h"
  58#include "llviewercontrol.h"
  59#include "llviewermenu.h"
  60#include "lluictrlfactory.h"
  61#include "llspinctrl.h"
  62#include "roles_constants.h"
  63#include "llgroupactions.h"
  64
  65///----------------------------------------------------------------------------
  66/// Class llsidepaneltaskinfo
  67///----------------------------------------------------------------------------
  68
  69LLSidepanelTaskInfo* LLSidepanelTaskInfo::sActivePanel = NULL;
  70
  71static LLRegisterPanelClassWrapper<LLSidepanelTaskInfo> t_task_info("sidepanel_task_info");
  72
  73// Default constructor
  74LLSidepanelTaskInfo::LLSidepanelTaskInfo()
  75{
  76	setMouseOpaque(FALSE);
  77	LLSelectMgr::instance().mUpdateSignal.connect(boost::bind(&LLSidepanelTaskInfo::refreshAll, this));
  78}
  79
  80
  81LLSidepanelTaskInfo::~LLSidepanelTaskInfo()
  82{
  83	if (sActivePanel == this)
  84		sActivePanel = NULL;
  85}
  86
  87// virtual
  88BOOL LLSidepanelTaskInfo::postBuild()
  89{
  90	LLSidepanelInventorySubpanel::postBuild();
  91
  92	mOpenBtn = getChild<LLButton>("open_btn");
  93	mOpenBtn->setClickedCallback(boost::bind(&LLSidepanelTaskInfo::onOpenButtonClicked, this));
  94	mPayBtn = getChild<LLButton>("pay_btn");
  95	mPayBtn->setClickedCallback(boost::bind(&LLSidepanelTaskInfo::onPayButtonClicked, this));
  96	mBuyBtn = getChild<LLButton>("buy_btn");
  97	mBuyBtn->setClickedCallback(boost::bind(&LLSidepanelTaskInfo::onBuyButtonClicked, this));
  98	mDetailsBtn = getChild<LLButton>("details_btn");
  99	mDetailsBtn->setClickedCallback(boost::bind(&LLSidepanelTaskInfo::onDetailsButtonClicked, this));
 100
 101	mLabelGroupName = getChild<LLNameBox>("Group Name Proxy");
 102
 103	childSetCommitCallback("Object Name",						LLSidepanelTaskInfo::onCommitName,this);
 104	getChild<LLLineEditor>("Object Name")->setPrevalidate(LLTextValidate::validateASCIIPrintableNoPipe);
 105	childSetCommitCallback("Object Description",				LLSidepanelTaskInfo::onCommitDesc,this);
 106	getChild<LLLineEditor>("Object Description")->setPrevalidate(LLTextValidate::validateASCIIPrintableNoPipe);
 107	getChild<LLUICtrl>("button set group")->setCommitCallback(boost::bind(&LLSidepanelTaskInfo::onClickGroup,this));
 108	childSetCommitCallback("checkbox share with group",			&LLSidepanelTaskInfo::onCommitGroupShare,this);
 109	childSetAction("button deed",								&LLSidepanelTaskInfo::onClickDeedToGroup,this);
 110	childSetCommitCallback("checkbox allow everyone move",		&LLSidepanelTaskInfo::onCommitEveryoneMove,this);
 111	childSetCommitCallback("checkbox allow everyone copy",		&LLSidepanelTaskInfo::onCommitEveryoneCopy,this);
 112	childSetCommitCallback("checkbox for sale",					&LLSidepanelTaskInfo::onCommitSaleInfo,this);
 113	childSetCommitCallback("sale type",							&LLSidepanelTaskInfo::onCommitSaleType,this);
 114	childSetCommitCallback("Edit Cost", 						&LLSidepanelTaskInfo::onCommitSaleInfo, this);
 115	childSetCommitCallback("checkbox next owner can modify",	&LLSidepanelTaskInfo::onCommitNextOwnerModify,this);
 116	childSetCommitCallback("checkbox next owner can copy",		&LLSidepanelTaskInfo::onCommitNextOwnerCopy,this);
 117	childSetCommitCallback("checkbox next owner can transfer",	&LLSidepanelTaskInfo::onCommitNextOwnerTransfer,this);
 118	childSetCommitCallback("clickaction",						&LLSidepanelTaskInfo::onCommitClickAction,this);
 119	childSetCommitCallback("search_check",						&LLSidepanelTaskInfo::onCommitIncludeInSearch,this);
 120	
 121	mDAPermModify = getChild<LLUICtrl>("perm_modify");
 122	mDACreator = getChildView("Creator:");
 123	mDACreatorName = getChild<LLUICtrl>("Creator Name");
 124	mDAOwner = getChildView("Owner:");
 125	mDAOwnerName = getChild<LLUICtrl>("Owner Name");
 126	mDAGroup = getChildView("Group:");
 127	mDAGroupName = getChild<LLUICtrl>("Group Name");
 128	mDAButtonSetGroup = getChildView("button set group");
 129	mDAObjectName = getChild<LLUICtrl>("Object Name");
 130	mDAName = getChildView("Name:");
 131	mDADescription = getChildView("Description:");
 132	mDAObjectDescription = getChild<LLUICtrl>("Object Description");
 133	mDAPermissions = getChildView("Permissions:");
 134	mDACheckboxShareWithGroup = getChild<LLUICtrl>("checkbox share with group");
 135	mDAButtonDeed = getChildView("button deed");
 136	mDACheckboxAllowEveryoneMove = getChild<LLUICtrl>("checkbox allow everyone move");
 137	mDACheckboxAllowEveryoneCopy = getChild<LLUICtrl>("checkbox allow everyone copy");
 138	mDANextOwnerCan = getChildView("Next owner can:");
 139	mDACheckboxNextOwnerCanModify = getChild<LLUICtrl>("checkbox next owner can modify");
 140	mDACheckboxNextOwnerCanCopy = getChild<LLUICtrl>("checkbox next owner can copy");
 141	mDACheckboxNextOwnerCanTransfer = getChild<LLUICtrl>("checkbox next owner can transfer");
 142	mDACheckboxForSale = getChild<LLUICtrl>("checkbox for sale");
 143	mDASearchCheck = getChild<LLUICtrl>("search_check");
 144	mDAComboSaleType = getChild<LLComboBox>("sale type");
 145	mDACost = getChild<LLUICtrl>("Cost");
 146	mDAEditCost = getChild<LLUICtrl>("Edit Cost");
 147	mDALabelClickAction = getChildView("label click action");
 148	mDAComboClickAction = getChild<LLComboBox>("clickaction");
 149	mDAB = getChildView("B:");
 150	mDAO = getChildView("O:");
 151	mDAG = getChildView("G:");
 152	mDAE = getChildView("E:");
 153	mDAN = getChildView("N:");
 154	mDAF = getChildView("F:");
 155	
 156	return TRUE;
 157}
 158
 159/*virtual*/ void LLSidepanelTaskInfo::handleVisibilityChange ( BOOL visible )
 160{
 161	if (visible)
 162	{
 163		sActivePanel = this;
 164		mObject = getFirstSelectedObject();
 165	}
 166	else
 167	{
 168		sActivePanel = NULL;
 169		// drop selection reference
 170		mObjectSelection = NULL;
 171	}
 172}
 173
 174
 175void LLSidepanelTaskInfo::disableAll()
 176{
 177	mDAPermModify->setEnabled(FALSE);
 178	mDAPermModify->setValue(LLStringUtil::null);
 179
 180	mDACreator->setEnabled(FALSE);
 181	mDACreatorName->setValue(LLStringUtil::null);
 182	mDACreatorName->setEnabled(FALSE);
 183
 184	mDAOwner->setEnabled(FALSE);
 185	mDAOwnerName->setValue(LLStringUtil::null);
 186	mDAOwnerName->setEnabled(FALSE);
 187
 188	mDAGroup->setEnabled(FALSE);
 189	mDAGroupName->setValue(LLStringUtil::null);
 190	mDAGroupName->setEnabled(FALSE);
 191	mDAButtonSetGroup->setEnabled(FALSE);
 192
 193	mDAObjectName->setValue(LLStringUtil::null);
 194	mDAObjectName->setEnabled(FALSE);
 195	mDAName->setEnabled(FALSE);
 196	mDAGroupName->setValue(LLStringUtil::null);
 197	mDAGroupName->setEnabled(FALSE);
 198	mDADescription->setEnabled(FALSE);
 199	mDAObjectDescription->setValue(LLStringUtil::null);
 200	mDAObjectDescription->setEnabled(FALSE);
 201
 202	mDAPermissions->setEnabled(FALSE);
 203		
 204	mDACheckboxShareWithGroup->setValue(FALSE);
 205	mDACheckboxShareWithGroup->setEnabled(FALSE);
 206	mDAButtonDeed->setEnabled(FALSE);
 207
 208	mDACheckboxAllowEveryoneMove->setValue(FALSE);
 209	mDACheckboxAllowEveryoneMove->setEnabled(FALSE);
 210	mDACheckboxAllowEveryoneCopy->setValue(FALSE);
 211	mDACheckboxAllowEveryoneCopy->setEnabled(FALSE);
 212
 213	//Next owner can:
 214	mDANextOwnerCan->setEnabled(FALSE);
 215	mDACheckboxNextOwnerCanModify->setValue(FALSE);
 216	mDACheckboxNextOwnerCanModify->setEnabled(FALSE);
 217	mDACheckboxNextOwnerCanCopy->setValue(FALSE);
 218	mDACheckboxNextOwnerCanCopy->setEnabled(FALSE);
 219	mDACheckboxNextOwnerCanTransfer->setValue(FALSE);
 220	mDACheckboxNextOwnerCanTransfer->setEnabled(FALSE);
 221
 222	//checkbox for sale
 223	mDACheckboxForSale->setValue(FALSE);
 224	mDACheckboxForSale->setEnabled(FALSE);
 225
 226	//checkbox include in search
 227	mDASearchCheck->setValue(FALSE);
 228	mDASearchCheck->setEnabled(FALSE);
 229		
 230	mDAComboSaleType->setValue(LLSaleInfo::FS_COPY);
 231	mDAComboSaleType->setEnabled(FALSE);
 232		
 233	mDACost->setEnabled(FALSE);
 234	mDACost->setValue(getString("Cost Default"));
 235	mDAEditCost->setValue(LLStringUtil::null);
 236	mDAEditCost->setEnabled(FALSE);
 237		
 238	mDALabelClickAction->setEnabled(FALSE);
 239	if (mDAComboClickAction)
 240	{
 241		mDAComboClickAction->setEnabled(FALSE);
 242		mDAComboClickAction->clear();
 243	}
 244
 245	mDAB->setVisible(FALSE);
 246	mDAO->setVisible(FALSE);
 247	mDAG->setVisible(FALSE);
 248	mDAE->setVisible(FALSE);
 249	mDAN->setVisible(FALSE);
 250	mDAF->setVisible(FALSE);
 251	
 252	mOpenBtn->setEnabled(FALSE);
 253	mPayBtn->setEnabled(FALSE);
 254	mBuyBtn->setEnabled(FALSE);
 255}
 256
 257void LLSidepanelTaskInfo::refresh()
 258{
 259	LLButton* btn_deed_to_group = getChild<LLButton>("button deed");
 260	if (btn_deed_to_group)
 261	{	
 262		std::string deedText;
 263		if (gWarningSettings.getBOOL("DeedObject"))
 264		{
 265			deedText = getString("text deed continued");
 266		}
 267		else
 268		{
 269			deedText = getString("text deed");
 270		}
 271		btn_deed_to_group->setLabelSelected(deedText);
 272		btn_deed_to_group->setLabelUnselected(deedText);
 273	}
 274
 275	BOOL root_selected = TRUE;
 276	LLSelectNode* nodep = mObjectSelection->getFirstRootNode();
 277	S32 object_count = mObjectSelection->getRootObjectCount();
 278	if (!nodep || (object_count == 0))
 279	{
 280		nodep = mObjectSelection->getFirstNode();
 281		object_count = mObjectSelection->getObjectCount();
 282		root_selected = FALSE;
 283	}
 284
 285	LLViewerObject* objectp = NULL;
 286	if (nodep)
 287	{
 288		objectp = nodep->getObject();
 289	}
 290
 291	// ...nothing selected
 292	if (!nodep || !objectp)
 293	{
 294		disableAll();
 295		return;
 296	}
 297
 298	// figure out a few variables
 299	const BOOL is_one_object = (object_count == 1);
 300	
 301	// BUG: fails if a root and non-root are both single-selected.
 302	const BOOL is_perm_modify = (mObjectSelection->getFirstRootNode() && LLSelectMgr::getInstance()->selectGetRootsModify()) ||
 303		LLSelectMgr::getInstance()->selectGetModify();
 304
 305	S32 string_index = 0;
 306	std::string MODIFY_INFO_STRINGS[] =
 307		{
 308			getString("text modify info 1"),
 309			getString("text modify info 2"),
 310			getString("text modify info 3"),
 311			getString("text modify info 4")
 312		};
 313	if (!is_perm_modify)
 314	{
 315		string_index += 2;
 316	}
 317	if (!is_one_object)
 318	{
 319		++string_index;
 320	}
 321	getChildView("perm_modify")->setEnabled(TRUE);
 322	getChild<LLUICtrl>("perm_modify")->setValue(MODIFY_INFO_STRINGS[string_index]);
 323
 324	getChildView("Permissions:")->setEnabled(TRUE);
 325	
 326	// Update creator text field
 327	getChildView("Creator:")->setEnabled(TRUE);
 328	BOOL creators_identical;
 329	std::string creator_name;
 330	creators_identical = LLSelectMgr::getInstance()->selectGetCreator(mCreatorID,
 331																	  creator_name);
 332
 333	getChild<LLUICtrl>("Creator Name")->setValue(creator_name);
 334	getChildView("Creator Name")->setEnabled(TRUE);
 335
 336	// Update owner text field
 337	getChildView("Owner:")->setEnabled(TRUE);
 338
 339	std::string owner_name;
 340	const BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(mOwnerID, owner_name);
 341	if (mOwnerID.isNull())
 342	{
 343		if (LLSelectMgr::getInstance()->selectIsGroupOwned())
 344		{
 345			// Group owned already displayed by selectGetOwner
 346		}
 347		else
 348		{
 349			// Display last owner if public
 350			std::string last_owner_name;
 351			LLSelectMgr::getInstance()->selectGetLastOwner(mLastOwnerID, last_owner_name);
 352
 353			// It should never happen that the last owner is null and the owner
 354			// is null, but it seems to be a bug in the simulator right now. JC
 355			if (!mLastOwnerID.isNull() && !last_owner_name.empty())
 356			{
 357				owner_name.append(", last ");
 358				owner_name.append(last_owner_name);
 359			}
 360		}
 361	}
 362	getChild<LLUICtrl>("Owner Name")->setValue(owner_name);
 363	getChildView("Owner Name")->setEnabled(TRUE);
 364
 365	// update group text field
 366	getChildView("Group:")->setEnabled(TRUE);
 367	getChild<LLUICtrl>("Group Name")->setValue(LLStringUtil::null);
 368	LLUUID group_id;
 369	BOOL groups_identical = LLSelectMgr::getInstance()->selectGetGroup(group_id);
 370	if (groups_identical)
 371	{
 372		if (mLabelGroupName)
 373		{
 374			mLabelGroupName->setNameID(group_id,TRUE);
 375			mLabelGroupName->setEnabled(TRUE);
 376		}
 377	}
 378	else
 379	{
 380		if (mLabelGroupName)
 381		{
 382			mLabelGroupName->setNameID(LLUUID::null, TRUE);
 383			mLabelGroupName->refresh(LLUUID::null, std::string(), true);
 384			mLabelGroupName->setEnabled(FALSE);
 385		}
 386	}
 387	
 388	getChildView("button set group")->setEnabled(owners_identical && (mOwnerID == gAgent.getID()));
 389
 390	getChildView("Name:")->setEnabled(TRUE);
 391	LLLineEditor* LineEditorObjectName = getChild<LLLineEditor>("Object Name");
 392	getChildView("Description:")->setEnabled(TRUE);
 393	LLLineEditor* LineEditorObjectDesc = getChild<LLLineEditor>("Object Description");
 394
 395	if (is_one_object)
 396	{
 397		if (!LineEditorObjectName->hasFocus())
 398		{
 399			getChild<LLUICtrl>("Object Name")->setValue(nodep->mName);
 400		}
 401
 402		if (LineEditorObjectDesc)
 403		{
 404			if (!LineEditorObjectDesc->hasFocus())
 405			{
 406				LineEditorObjectDesc->setText(nodep->mDescription);
 407			}
 408		}
 409	}
 410	else
 411	{
 412		getChild<LLUICtrl>("Object Name")->setValue(LLStringUtil::null);
 413		LineEditorObjectDesc->setText(LLStringUtil::null);
 414	}
 415
 416	// figure out the contents of the name, description, & category
 417	BOOL edit_name_desc = FALSE;
 418	if (is_one_object && objectp->permModify())
 419	{
 420		edit_name_desc = TRUE;
 421	}
 422	if (edit_name_desc)
 423	{
 424		getChildView("Object Name")->setEnabled(TRUE);
 425		getChildView("Object Description")->setEnabled(TRUE);
 426	}
 427	else
 428	{
 429		getChildView("Object Name")->setEnabled(FALSE);
 430		getChildView("Object Description")->setEnabled(FALSE);
 431	}
 432
 433	S32 total_sale_price = 0;
 434	S32 individual_sale_price = 0;
 435	BOOL is_for_sale_mixed = FALSE;
 436	BOOL is_sale_price_mixed = FALSE;
 437	U32 num_for_sale = FALSE;
 438    LLSelectMgr::getInstance()->selectGetAggregateSaleInfo(num_for_sale,
 439														   is_for_sale_mixed,
 440														   is_sale_price_mixed,
 441														   total_sale_price,
 442														   individual_sale_price);
 443
 444	const BOOL self_owned = (gAgent.getID() == mOwnerID);
 445	const BOOL group_owned = LLSelectMgr::getInstance()->selectIsGroupOwned() ;
 446	const BOOL public_owned = (mOwnerID.isNull() && !LLSelectMgr::getInstance()->selectIsGroupOwned());
 447	const BOOL can_transfer = LLSelectMgr::getInstance()->selectGetRootsTransfer();
 448	const BOOL can_copy = LLSelectMgr::getInstance()->selectGetRootsCopy();
 449
 450	if (!owners_identical)
 451	{
 452		getChildView("Cost")->setEnabled(FALSE);
 453		getChild<LLUICtrl>("Edit Cost")->setValue(LLStringUtil::null);
 454		getChildView("Edit Cost")->setEnabled(FALSE);
 455	}
 456	// You own these objects.
 457	else if (self_owned || (group_owned && gAgent.hasPowerInGroup(group_id,GP_OBJECT_SET_SALE)))
 458	{
 459		// If there are multiple items for sale then set text to PRICE PER UNIT.
 460		if (num_for_sale > 1)
 461		{
 462			getChild<LLUICtrl>("Cost")->setValue(getString("Cost Per Unit"));
 463		}
 464		else
 465		{
 466			getChild<LLUICtrl>("Cost")->setValue(getString("Cost Default"));
 467		}
 468		
 469		LLSpinCtrl *edit_price = getChild<LLSpinCtrl>("Edit Cost");
 470		if (!edit_price->hasFocus())
 471		{
 472			// If the sale price is mixed then set the cost to MIXED, otherwise
 473			// set to the actual cost.
 474			if ((num_for_sale > 0) && is_for_sale_mixed)
 475			{
 476				edit_price->setTentative(TRUE);
 477			}
 478			else if ((num_for_sale > 0) && is_sale_price_mixed)
 479			{
 480				edit_price->setTentative(TRUE);
 481			}
 482			else 
 483			{
 484				edit_price->setValue(individual_sale_price);
 485			}
 486		}
 487		// The edit fields are only enabled if you can sell this object
 488		// and the sale price is not mixed.
 489		BOOL enable_edit = (num_for_sale && can_transfer) ? !is_for_sale_mixed : FALSE;
 490		getChildView("Cost")->setEnabled(enable_edit);
 491		getChildView("Edit Cost")->setEnabled(enable_edit);
 492	}
 493	// Someone, not you, owns these objects.
 494	else if (!public_owned)
 495	{
 496		getChildView("Cost")->setEnabled(FALSE);
 497		getChildView("Edit Cost")->setEnabled(FALSE);
 498		
 499		// Don't show a price if none of the items are for sale.
 500		if (num_for_sale)
 501			getChild<LLUICtrl>("Edit Cost")->setValue(llformat("%d",total_sale_price));
 502		else
 503			getChild<LLUICtrl>("Edit Cost")->setValue(LLStringUtil::null);
 504
 505		// If multiple items are for sale, set text to TOTAL PRICE.
 506		if (num_for_sale > 1)
 507			getChild<LLUICtrl>("Cost")->setValue(getString("Cost Total"));
 508		else
 509			getChild<LLUICtrl>("Cost")->setValue(getString("Cost Default"));
 510	}
 511	// This is a public object.
 512	else
 513	{
 514		getChildView("Cost")->setEnabled(FALSE);
 515		getChild<LLUICtrl>("Cost")->setValue(getString("Cost Default"));
 516		
 517		getChild<LLUICtrl>("Edit Cost")->setValue(LLStringUtil::null);
 518		getChildView("Edit Cost")->setEnabled(FALSE);
 519	}
 520
 521	// Enable and disable the permissions checkboxes
 522	// based on who owns the object.
 523	// TODO: Creator permissions
 524
 525	U32 base_mask_on 			= 0;
 526	U32 base_mask_off		 	= 0;
 527	U32 owner_mask_off			= 0;
 528	U32 owner_mask_on 			= 0;
 529	U32 group_mask_on 			= 0;
 530	U32 group_mask_off 			= 0;
 531	U32 everyone_mask_on 		= 0;
 532	U32 everyone_mask_off 		= 0;
 533	U32 next_owner_mask_on 		= 0;
 534	U32 next_owner_mask_off		= 0;
 535
 536	BOOL valid_base_perms 		= LLSelectMgr::getInstance()->selectGetPerm(PERM_BASE,
 537																			&base_mask_on,
 538																			&base_mask_off);
 539	//BOOL valid_owner_perms =//
 540	LLSelectMgr::getInstance()->selectGetPerm(PERM_OWNER,
 541											  &owner_mask_on,
 542											  &owner_mask_off);
 543	BOOL valid_group_perms 		= LLSelectMgr::getInstance()->selectGetPerm(PERM_GROUP,
 544																			&group_mask_on,
 545																			&group_mask_off);
 546	
 547	BOOL valid_everyone_perms 	= LLSelectMgr::getInstance()->selectGetPerm(PERM_EVERYONE,
 548																			&everyone_mask_on,
 549																			&everyone_mask_off);
 550	
 551	BOOL valid_next_perms 		= LLSelectMgr::getInstance()->selectGetPerm(PERM_NEXT_OWNER,
 552																			&next_owner_mask_on,
 553																			&next_owner_mask_off);
 554
 555	
 556	if (gSavedSettings.getBOOL("DebugPermissions") )
 557	{
 558		if (valid_base_perms)
 559		{
 560			getChild<LLUICtrl>("B:")->setValue("B: " + mask_to_string(base_mask_on));
 561			getChildView("B:")->setVisible(							TRUE);
 562			
 563			getChild<LLUICtrl>("O:")->setValue("O: " + mask_to_string(owner_mask_on));
 564			getChildView("O:")->setVisible(							TRUE);
 565			
 566			getChild<LLUICtrl>("G:")->setValue("G: " + mask_to_string(group_mask_on));
 567			getChildView("G:")->setVisible(							TRUE);
 568			
 569			getChild<LLUICtrl>("E:")->setValue("E: " + mask_to_string(everyone_mask_on));
 570			getChildView("E:")->setVisible(							TRUE);
 571			
 572			getChild<LLUICtrl>("N:")->setValue("N: " + mask_to_string(next_owner_mask_on));
 573			getChildView("N:")->setVisible(							TRUE);
 574		}
 575
 576		U32 flag_mask = 0x0;
 577		if (objectp->permMove()) 		flag_mask |= PERM_MOVE;
 578		if (objectp->permModify()) 		flag_mask |= PERM_MODIFY;
 579		if (objectp->permCopy()) 		flag_mask |= PERM_COPY;
 580		if (objectp->permTransfer()) 	flag_mask |= PERM_TRANSFER;
 581
 582		getChild<LLUICtrl>("F:")->setValue("F:" + mask_to_string(flag_mask));
 583		getChildView("F:")->setVisible(								TRUE);
 584	}
 585	else
 586	{
 587		getChildView("B:")->setVisible(								FALSE);
 588		getChildView("O:")->setVisible(								FALSE);
 589		getChildView("G:")->setVisible(								FALSE);
 590		getChildView("E:")->setVisible(								FALSE);
 591		getChildView("N:")->setVisible(								FALSE);
 592		getChildView("F:")->setVisible(								FALSE);
 593	}
 594
 595	BOOL has_change_perm_ability = FALSE;
 596	BOOL has_change_sale_ability = FALSE;
 597
 598	if (valid_base_perms &&
 599		(self_owned || (group_owned && gAgent.hasPowerInGroup(group_id, GP_OBJECT_MANIPULATE))))
 600	{
 601		has_change_perm_ability = TRUE;
 602	}
 603	if (valid_base_perms &&
 604	   (self_owned || (group_owned && gAgent.hasPowerInGroup(group_id, GP_OBJECT_SET_SALE))))
 605	{
 606		has_change_sale_ability = TRUE;
 607	}
 608
 609	if (!has_change_perm_ability && !has_change_sale_ability && !root_selected)
 610	{
 611		// ...must select root to choose permissions
 612		getChild<LLUICtrl>("perm_modify")->setValue(getString("text modify warning"));
 613	}
 614
 615	if (has_change_perm_ability)
 616	{
 617		getChildView("checkbox share with group")->setEnabled(TRUE);
 618		getChildView("checkbox allow everyone move")->setEnabled(owner_mask_on & PERM_MOVE);
 619		getChildView("checkbox allow everyone copy")->setEnabled(owner_mask_on & PERM_COPY && owner_mask_on & PERM_TRANSFER);
 620	}
 621	else
 622	{
 623		getChildView("checkbox share with group")->setEnabled(FALSE);
 624		getChildView("checkbox allow everyone move")->setEnabled(FALSE);
 625		getChildView("checkbox allow everyone copy")->setEnabled(FALSE);
 626	}
 627
 628	if (has_change_sale_ability && (owner_mask_on & PERM_TRANSFER))
 629	{
 630		getChildView("checkbox for sale")->setEnabled(can_transfer || (!can_transfer && num_for_sale));
 631		// Set the checkbox to tentative if the prices of each object selected
 632		// are not the same.
 633		getChild<LLUICtrl>("checkbox for sale")->setTentative( 				is_for_sale_mixed);
 634		getChildView("sale type")->setEnabled(num_for_sale && can_transfer && !is_sale_price_mixed);
 635
 636		getChildView("Next owner can:")->setEnabled(TRUE);
 637		getChildView("checkbox next owner can modify")->setEnabled(base_mask_on & PERM_MODIFY);
 638		getChildView("checkbox next owner can copy")->setEnabled(base_mask_on & PERM_COPY);
 639		getChildView("checkbox next owner can transfer")->setEnabled(next_owner_mask_on & PERM_COPY);
 640	}
 641	else 
 642	{
 643		getChildView("checkbox for sale")->setEnabled(FALSE);
 644		getChildView("sale type")->setEnabled(FALSE);
 645
 646		getChildView("Next owner can:")->setEnabled(FALSE);
 647		getChildView("checkbox next owner can modify")->setEnabled(FALSE);
 648		getChildView("checkbox next owner can copy")->setEnabled(FALSE);
 649		getChildView("checkbox next owner can transfer")->setEnabled(FALSE);
 650	}
 651
 652	if (valid_group_perms)
 653	{
 654		if ((group_mask_on & PERM_COPY) && (group_mask_on & PERM_MODIFY) && (group_mask_on & PERM_MOVE))
 655		{
 656			getChild<LLUICtrl>("checkbox share with group")->setValue(TRUE);
 657			getChild<LLUICtrl>("checkbox share with group")->setTentative(	FALSE);
 658			getChildView("button deed")->setEnabled(gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (owner_mask_on & PERM_TRANSFER) && !group_owned && can_transfer);
 659		}
 660		else if ((group_mask_off & PERM_COPY) && (group_mask_off & PERM_MODIFY) && (group_mask_off & PERM_MOVE))
 661		{
 662			getChild<LLUICtrl>("checkbox share with group")->setValue(FALSE);
 663			getChild<LLUICtrl>("checkbox share with group")->setTentative(	FALSE);
 664			getChildView("button deed")->setEnabled(FALSE);
 665		}
 666		else
 667		{
 668			getChild<LLUICtrl>("checkbox share with group")->setValue(TRUE);
 669			getChild<LLUICtrl>("checkbox share with group")->setTentative(	TRUE);
 670			getChildView("button deed")->setEnabled(gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (group_mask_on & PERM_MOVE) && (owner_mask_on & PERM_TRANSFER) && !group_owned && can_transfer);
 671		}
 672	}			
 673
 674	if (valid_everyone_perms)
 675	{
 676		// Move
 677		if (everyone_mask_on & PERM_MOVE)
 678		{
 679			getChild<LLUICtrl>("checkbox allow everyone move")->setValue(TRUE);
 680			getChild<LLUICtrl>("checkbox allow everyone move")->setTentative( 	FALSE);
 681		}
 682		else if (everyone_mask_off & PERM_MOVE)
 683		{
 684			getChild<LLUICtrl>("checkbox allow everyone move")->setValue(FALSE);
 685			getChild<LLUICtrl>("checkbox allow everyone move")->setTentative( 	FALSE);
 686		}
 687		else
 688		{
 689			getChild<LLUICtrl>("checkbox allow everyone move")->setValue(TRUE);
 690			getChild<LLUICtrl>("checkbox allow everyone move")->setTentative( 	TRUE);
 691		}
 692
 693		// Copy == everyone can't copy
 694		if (everyone_mask_on & PERM_COPY)
 695		{
 696			getChild<LLUICtrl>("checkbox allow everyone copy")->setValue(TRUE);
 697			getChild<LLUICtrl>("checkbox allow everyone copy")->setTentative( 	!can_copy || !can_transfer);
 698		}
 699		else if (everyone_mask_off & PERM_COPY)
 700		{
 701			getChild<LLUICtrl>("checkbox allow everyone copy")->setValue(FALSE);
 702			getChild<LLUICtrl>("checkbox allow everyone copy")->setTentative(	FALSE);
 703		}
 704		else
 705		{
 706			getChild<LLUICtrl>("checkbox allow everyone copy")->setValue(TRUE);
 707			getChild<LLUICtrl>("checkbox allow everyone copy")->setTentative(	TRUE);
 708		}
 709	}
 710
 711	if (valid_next_perms)
 712	{
 713		// Modify == next owner canot modify
 714		if (next_owner_mask_on & PERM_MODIFY)
 715		{
 716			getChild<LLUICtrl>("checkbox next owner can modify")->setValue(TRUE);
 717			getChild<LLUICtrl>("checkbox next owner can modify")->setTentative(	FALSE);
 718		}
 719		else if (next_owner_mask_off & PERM_MODIFY)
 720		{
 721			getChild<LLUICtrl>("checkbox next owner can modify")->setValue(FALSE);
 722			getChild<LLUICtrl>("checkbox next owner can modify")->setTentative(	FALSE);
 723		}
 724		else
 725		{
 726			getChild<LLUICtrl>("checkbox next owner can modify")->setValue(TRUE);
 727			getChild<LLUICtrl>("checkbox next owner can modify")->setTentative(	TRUE);
 728		}
 729
 730		// Copy == next owner cannot copy
 731		if (next_owner_mask_on & PERM_COPY)
 732		{			
 733			getChild<LLUICtrl>("checkbox next owner can copy")->setValue(TRUE);
 734			getChild<LLUICtrl>("checkbox next owner can copy")->setTentative(	!can_copy);
 735		}
 736		else if (next_owner_mask_off & PERM_COPY)
 737		{
 738			getChild<LLUICtrl>("checkbox next owner can copy")->setValue(FALSE);
 739			getChild<LLUICtrl>("checkbox next owner can copy")->setTentative(	FALSE);
 740		}
 741		else
 742		{
 743			getChild<LLUICtrl>("checkbox next owner can copy")->setValue(TRUE);
 744			getChild<LLUICtrl>("checkbox next owner can copy")->setTentative(	TRUE);
 745		}
 746
 747		// Transfer == next owner cannot transfer
 748		if (next_owner_mask_on & PERM_TRANSFER)
 749		{
 750			getChild<LLUICtrl>("checkbox next owner can transfer")->setValue(TRUE);
 751			getChild<LLUICtrl>("checkbox next owner can transfer")->setTentative( !can_transfer);
 752		}
 753		else if (next_owner_mask_off & PERM_TRANSFER)
 754		{
 755			getChild<LLUICtrl>("checkbox next owner can transfer")->setValue(FALSE);
 756			getChild<LLUICtrl>("checkbox next owner can transfer")->setTentative( FALSE);
 757		}
 758		else
 759		{
 760			getChild<LLUICtrl>("checkbox next owner can transfer")->setValue(TRUE);
 761			getChild<LLUICtrl>("checkbox next owner can transfer")->setTentative( TRUE);
 762		}
 763	}
 764
 765	// reflect sale information
 766	LLSaleInfo sale_info;
 767	BOOL valid_sale_info = LLSelectMgr::getInstance()->selectGetSaleInfo(sale_info);
 768	LLSaleInfo::EForSale sale_type = sale_info.getSaleType();
 769
 770	LLComboBox* combo_sale_type = getChild<LLComboBox>("sale type");
 771	if (valid_sale_info)
 772	{
 773		combo_sale_type->setValue(					sale_type == LLSaleInfo::FS_NOT ? LLSaleInfo::FS_COPY : sale_type);
 774		combo_sale_type->setTentative(				FALSE); // unfortunately this doesn't do anything at the moment.
 775	}
 776	else
 777	{
 778		// default option is sell copy, determined to be safest
 779		combo_sale_type->setValue(					LLSaleInfo::FS_COPY);
 780		combo_sale_type->setTentative(				TRUE); // unfortunately this doesn't do anything at the moment.
 781	}
 782
 783	getChild<LLUICtrl>("checkbox for sale")->setValue((num_for_sale != 0));
 784
 785	// HACK: There are some old objects in world that are set for sale,
 786	// but are no-transfer.  We need to let users turn for-sale off, but only
 787	// if for-sale is set.
 788	bool cannot_actually_sell = !can_transfer || (!can_copy && sale_type == LLSaleInfo::FS_COPY);
 789	if (cannot_actually_sell)
 790	{
 791		if (num_for_sale && has_change_sale_ability)
 792		{
 793			getChildView("checkbox for sale")->setEnabled(true);
 794		}
 795	}
 796	
 797	// Check search status of objects
 798	const BOOL all_volume = LLSelectMgr::getInstance()->selectionAllPCode( LL_PCODE_VOLUME );
 799	bool include_in_search;
 800	const BOOL all_include_in_search = LLSelectMgr::getInstance()->selectionGetIncludeInSearch(&include_in_search);
 801	getChildView("search_check")->setEnabled(has_change_sale_ability && all_volume);
 802	getChild<LLUICtrl>("search_check")->setValue(include_in_search);
 803	getChild<LLUICtrl>("search_check")->setTentative( 				!all_include_in_search);
 804
 805	// Click action (touch, sit, buy)
 806	U8 click_action = 0;
 807	if (LLSelectMgr::getInstance()->selectionGetClickAction(&click_action))
 808	{
 809		LLComboBox*	ComboClickAction = getChild<LLComboBox>("clickaction");
 810		if (ComboClickAction)
 811		{
 812			ComboClickAction->setCurrentByIndex((S32)click_action);
 813		}
 814	}
 815	getChildView("label click action")->setEnabled(is_perm_modify && all_volume);
 816	getChildView("clickaction")->setEnabled(is_perm_modify && all_volume);
 817
 818	if (!getIsEditing())
 819	{
 820		const std::string no_item_names[] = 
 821			{
 822				"Object Name",
 823				"Object Description",
 824				"button set group",
 825				"checkbox share with group",
 826				"button deed",
 827				"checkbox allow everyone move",
 828				"checkbox allow everyone copy",
 829				"checkbox for sale",
 830				"sale type",
 831				"Edit Cost",
 832				"checkbox next owner can modify",
 833				"checkbox next owner can copy",
 834				"checkbox next owner can transfer",
 835				"clickaction",
 836				"search_check",
 837				"perm_modify",
 838				"Group Name",
 839			};
 840		for (size_t t=0; t<LL_ARRAY_SIZE(no_item_names); ++t)
 841		{
 842			getChildView(no_item_names[t])->setEnabled(	FALSE);
 843		}
 844	}
 845	updateVerbs();
 846}
 847
 848
 849// static
 850void LLSidepanelTaskInfo::onClickClaim(void*)
 851{
 852	// try to claim ownership
 853	LLSelectMgr::getInstance()->sendOwner(gAgent.getID(), gAgent.getGroupID());
 854}
 855
 856// static
 857void LLSidepanelTaskInfo::onClickRelease(void*)
 858{
 859	// try to release ownership
 860	LLSelectMgr::getInstance()->sendOwner(LLUUID::null, LLUUID::null);
 861}
 862
 863void LLSidepanelTaskInfo::onClickGroup()
 864{
 865	LLUUID owner_id;
 866	std::string name;
 867	BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(owner_id, name);
 868	LLFloater* parent_floater = gFloaterView->getParentFloater(this);
 869
 870	if (owners_identical && (owner_id == gAgent.getID()))
 871	{
 872		LLFloaterGroupPicker* fg = LLFloaterReg::showTypedInstance<LLFloaterGroupPicker>("group_picker", LLSD(gAgent.getID()));
 873		if (fg)
 874		{
 875			fg->setSelectGroupCallback( boost::bind(&LLSidepanelTaskInfo::cbGroupID, this, _1) );
 876			if (parent_floater)
 877			{
 878				LLRect new_rect = gFloaterView->findNeighboringPosition(parent_floater, fg);
 879				fg->setOrigin(new_rect.mLeft, new_rect.mBottom);
 880				parent_floater->addDependentFloater(fg);
 881			}
 882		}
 883	}
 884}
 885
 886void LLSidepanelTaskInfo::cbGroupID(LLUUID group_id)
 887{
 888	if (mLabelGroupName)
 889	{
 890		mLabelGroupName->setNameID(group_id, TRUE);
 891	}
 892	LLSelectMgr::getInstance()->sendGroup(group_id);
 893}
 894
 895static bool callback_deed_to_group(const LLSD& notification, const LLSD& response)
 896{
 897	const S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
 898	if (option == 0)
 899	{
 900		LLUUID group_id;
 901		const BOOL groups_identical = LLSelectMgr::getInstance()->selectGetGroup(group_id);
 902		if (group_id.notNull() && groups_identical && (gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED)))
 903		{
 904			LLSelectMgr::getInstance()->sendOwner(LLUUID::null, group_id, FALSE);
 905//			LLViewerStats::getInstance()->incStat(LLViewerStats::ST_RELEASE_COUNT);
 906		}
 907	}
 908	return FALSE;
 909}
 910
 911void LLSidepanelTaskInfo::onClickDeedToGroup(void *data)
 912{
 913	LLNotificationsUtil::add("DeedObjectToGroup", LLSD(), LLSD(), callback_deed_to_group);
 914}
 915
 916///----------------------------------------------------------------------------
 917/// Permissions checkboxes
 918///----------------------------------------------------------------------------
 919
 920// static
 921void LLSidepanelTaskInfo::onCommitPerm(LLUICtrl *ctrl, void *data, U8 field, U32 perm)
 922{
 923	LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject();
 924	if(!object) return;
 925
 926	// Checkbox will have toggled itself
 927	// LLSidepanelTaskInfo* self = (LLSidepanelTaskInfo*)data;
 928	LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl;
 929	BOOL new_state = check->get();
 930	
 931	LLSelectMgr::getInstance()->selectionSetObjectPermissions(field, new_state, perm);
 932}
 933
 934// static
 935void LLSidepanelTaskInfo::onCommitGroupShare(LLUICtrl *ctrl, void *data)
 936{
 937	onCommitPerm(ctrl, data, PERM_GROUP, PERM_MODIFY | PERM_MOVE | PERM_COPY);
 938}
 939
 940// static
 941void LLSidepanelTaskInfo::onCommitEveryoneMove(LLUICtrl *ctrl, void *data)
 942{
 943	onCommitPerm(ctrl, data, PERM_EVERYONE, PERM_MOVE);
 944}
 945
 946
 947// static
 948void LLSidepanelTaskInfo::onCommitEveryoneCopy(LLUICtrl *ctrl, void *data)
 949{
 950	onCommitPerm(ctrl, data, PERM_EVERYONE, PERM_COPY);
 951}
 952
 953// static
 954void LLSidepanelTaskInfo::onCommitNextOwnerModify(LLUICtrl* ctrl, void* data)
 955{
 956	//llinfos << "LLSidepanelTaskInfo::onCommitNextOwnerModify" << llendl;
 957	onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_MODIFY);
 958}
 959
 960// static
 961void LLSidepanelTaskInfo::onCommitNextOwnerCopy(LLUICtrl* ctrl, void* data)
 962{
 963	//llinfos << "LLSidepanelTaskInfo::onCommitNextOwnerCopy" << llendl;
 964	onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_COPY);
 965}
 966
 967// static
 968void LLSidepanelTaskInfo::onCommitNextOwnerTransfer(LLUICtrl* ctrl, void* data)
 969{
 970	//llinfos << "LLSidepanelTaskInfo::onCommitNextOwnerTransfer" << llendl;
 971	onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_TRANSFER);
 972}
 973
 974// static
 975void LLSidepanelTaskInfo::onCommitName(LLUICtrl*, void* data)
 976{
 977	//llinfos << "LLSidepanelTaskInfo::onCommitName()" << llendl;
 978	LLSidepanelTaskInfo* self = (LLSidepanelTaskInfo*)data;
 979	LLLineEditor*	tb = self->getChild<LLLineEditor>("Object Name");
 980	if(tb)
 981	{
 982		LLSelectMgr::getInstance()->selectionSetObjectName(tb->getText());
 983//		LLSelectMgr::getInstance()->selectionSetObjectName(self->mLabelObjectName->getText());
 984	}
 985}
 986
 987
 988// static
 989void LLSidepanelTaskInfo::onCommitDesc(LLUICtrl*, void* data)
 990{
 991	//llinfos << "LLSidepanelTaskInfo::onCommitDesc()" << llendl;
 992	LLSidepanelTaskInfo* self = (LLSidepanelTaskInfo*)data;
 993	LLLineEditor*	le = self->getChild<LLLineEditor>("Object Description");
 994	if(le)
 995	{
 996		LLSelectMgr::getInstance()->selectionSetObjectDescription(le->getText());
 997	}
 998}
 999
1000// static
1001void LLSidepanelTaskInfo::onCommitSaleInfo(LLUICtrl*, void* data)
1002{
1003	LLSidepanelTaskInfo* self = (LLSidepanelTaskInfo*)data;
1004	self->setAllSaleInfo();
1005}
1006
1007// static
1008void LLSidepanelTaskInfo::onCommitSaleType(LLUICtrl*, void* data)
1009{
1010	LLSidepanelTaskInfo* self = (LLSidepanelTaskInfo*)data;
1011	self->setAllSaleInfo();
1012}
1013
1014
1015void LLSidepanelTaskInfo::setAllSaleInfo()
1016{
1017	LLSaleInfo::EForSale sale_type = LLSaleInfo::FS_NOT;
1018
1019	LLCheckBoxCtrl *checkPurchase = getChild<LLCheckBoxCtrl>("checkbox for sale");
1020	
1021	// Set the sale type if the object(s) are for sale.
1022	if(checkPurchase && checkPurchase->get())
1023	{
1024		sale_type = static_cast<LLSaleInfo::EForSale>(getChild<LLComboBox>("sale type")->getValue().asInteger());
1025	}
1026
1027	S32 price = -1;
1028	
1029	LLSpinCtrl *edit_price = getChild<LLSpinCtrl>("Edit Cost");
1030	price = (edit_price->getTentative()) ? DEFAULT_PRICE : edit_price->getValue().asInteger();
1031
1032	// If somehow an invalid price, turn the sale off.
1033	if (price < 0)
1034		sale_type = LLSaleInfo::FS_NOT;
1035
1036	LLSaleInfo old_sale_info;
1037	LLSelectMgr::getInstance()->selectGetSaleInfo(old_sale_info);
1038
1039	LLSaleInfo new_sale_info(sale_type, price);
1040	LLSelectMgr::getInstance()->selectionSetObjectSaleInfo(new_sale_info);
1041	
1042	U8 old_click_action = 0;
1043	LLSelectMgr::getInstance()->selectionGetClickAction(&old_click_action);
1044
1045	if (old_sale_info.isForSale()
1046		&& !new_sale_info.isForSale()
1047		&& old_click_action == CLICK_ACTION_BUY)
1048	{
1049		// If turned off for-sale, make sure click-action buy is turned
1050		// off as well
1051		LLSelectMgr::getInstance()->
1052			selectionSetClickAction(CLICK_ACTION_TOUCH);
1053	}
1054	else if (new_sale_info.isForSale()
1055		&& !old_sale_info.isForSale()
1056		&& old_click_action == CLICK_ACTION_TOUCH)
1057	{
1058		// If just turning on for-sale, preemptively turn on one-click buy
1059		// unless user have a different click action set
1060		LLSelectMgr::getInstance()->
1061			selectionSetClickAction(CLICK_ACTION_BUY);
1062	}
1063}
1064
1065struct LLSelectionPayable : public LLSelectedObjectFunctor
1066{
1067	virtual bool apply(LLViewerObject* obj)
1068	{
1069		// can pay if you or your parent has money() event in script
1070		LLViewerObject* parent = (LLViewerObject*)obj->getParent();
1071		return (obj->flagTakesMoney() ||
1072				(parent && parent->flagTakesMoney()));
1073	}
1074};
1075
1076static U8 string_value_to_click_action(std::string p_value)
1077{
1078	if (p_value == "Touch")
1079		return CLICK_ACTION_TOUCH;
1080	if (p_value == "Sit")
1081		return CLICK_ACTION_SIT;
1082	if (p_value == "Buy")
1083		return CLICK_ACTION_BUY;
1084	if (p_value == "Pay")
1085		return CLICK_ACTION_PAY;
1086	if (p_value == "Open")
1087		return CLICK_ACTION_OPEN;
1088	if (p_value == "Zoom")
1089		return CLICK_ACTION_ZOOM;
1090	return CLICK_ACTION_TOUCH;
1091}
1092
1093// static
1094void LLSidepanelTaskInfo::onCommitClickAction(LLUICtrl* ctrl, void*)
1095{
1096	LLComboBox* box = (LLComboBox*)ctrl;
1097	if (!box) return;
1098	std::string value = box->getValue().asString();
1099	U8 click_action = string_value_to_click_action(value);
1100	doClickAction(click_action);
1101}
1102
1103// static
1104void LLSidepanelTaskInfo::doClickAction(U8 click_action)
1105{
1106	if (click_action == CLICK_ACTION_BUY)
1107	{
1108		LLSaleInfo sale_info;
1109		LLSelectMgr::getInstance()->selectGetSaleInfo(sale_info);
1110		if (!sale_info.isForSale())
1111		{
1112			LLNotificationsUtil::add("CantSetBuyObject");
1113
1114			// Set click action back to its old value
1115			U8 click_action = 0;
1116			LLSelectMgr::getInstance()->selectionGetClickAction(&click_action);
1117//			box->setCurrentByIndex((S32)click_action);
1118
1119			return;
1120		}
1121	}
1122	else if (click_action == CLICK_ACTION_PAY)
1123	{
1124		// Verify object has script with money() handler
1125		LLSelectionPayable payable;
1126		bool can_pay = LLSelectMgr::getInstance()->getSelection()->applyToObjects(&payable);
1127		if (!can_pay)
1128		{
1129			// Warn, but do it anyway.
1130			LLNotificationsUtil::add("ClickActionNotPayable");
1131		}
1132	}
1133	LLSelectMgr::getInstance()->selectionSetClickAction(click_action);
1134}
1135
1136// static
1137void LLSidepanelTaskInfo::onCommitIncludeInSearch(LLUICtrl* ctrl, void* data)
1138{
1139	LLCheckBoxCtrl* box = (LLCheckBoxCtrl*)ctrl;
1140	llassert(box);
1141	LLSelectMgr::getInstance()->selectionSetIncludeInSearch(box->get());
1142}
1143
1144// virtual
1145void LLSidepanelTaskInfo::updateVerbs()
1146{
1147	LLSidepanelInventorySubpanel::updateVerbs();
1148
1149	/*
1150	mOpenBtn->setVisible(!getIsEditing());
1151	mPayBtn->setVisible(!getIsEditing());
1152	mBuyBtn->setVisible(!getIsEditing());
1153	//const LLViewerObject *obj = getFirstSelectedObject();
1154	//mEditBtn->setEnabled(obj && obj->permModify());
1155	*/
1156
1157	LLSafeHandle<LLObjectSelection> object_selection = LLSelectMgr::getInstance()->getSelection();
1158	const BOOL any_selected = (object_selection->getNumNodes() > 0);
1159
1160	mOpenBtn->setVisible(true);
1161	mPayBtn->setVisible(true);
1162	mBuyBtn->setVisible(true);
1163	mDetailsBtn->setVisible(true);
1164
1165	mOpenBtn->setEnabled(enable_object_open());
1166	mPayBtn->setEnabled(enable_pay_object());
1167	mBuyBtn->setEnabled(enable_buy_object());
1168	mDetailsBtn->setEnabled(any_selected);
1169}
1170
1171void LLSidepanelTaskInfo::onOpenButtonClicked()
1172{
1173	if (enable_object_open())
1174	{
1175		handle_object_open();
1176	}
1177}
1178
1179void LLSidepanelTaskInfo::onPayButtonClicked()
1180{
1181	doClickAction(CLICK_ACTION_PAY);
1182}
1183
1184void LLSidepanelTaskInfo::onBuyButtonClicked()
1185{
1186	doClickAction(CLICK_ACTION_BUY);
1187}
1188
1189void LLSidepanelTaskInfo::onDetailsButtonClicked()
1190{
1191	LLFloaterReg::showInstance("inspect", LLSD());
1192}
1193
1194// virtual
1195void LLSidepanelTaskInfo::save()
1196{
1197	onCommitGroupShare(getChild<LLCheckBoxCtrl>("checkbox share with group"), this);
1198	onCommitEveryoneMove(getChild<LLCheckBoxCtrl>("checkbox allow everyone move"), this);
1199	onCommitEveryoneCopy(getChild<LLCheckBoxCtrl>("checkbox allow everyone copy"), this);
1200	onCommitNextOwnerModify(getChild<LLCheckBoxCtrl>("checkbox next owner can modify"), this);
1201	onCommitNextOwnerCopy(getChild<LLCheckBoxCtrl>("checkbox next owner can copy"), this);
1202	onCommitNextOwnerTransfer(getChild<LLCheckBoxCtrl>("checkbox next owner can transfer"), this);
1203	onCommitName(getChild<LLLineEditor>("Object Name"), this);
1204	onCommitDesc(getChild<LLLineEditor>("Object Description"), this);
1205	onCommitSaleInfo(NULL, this);
1206	onCommitSaleType(NULL, this);
1207	onCommitIncludeInSearch(getChild<LLCheckBoxCtrl>("search_check"), this);
1208}
1209
1210// removes keyboard focus so that all fields can be updated
1211// and then restored focus
1212void LLSidepanelTaskInfo::refreshAll()
1213{
1214	// update UI as soon as we have an object
1215	// but remove keyboard focus first so fields are free to update
1216	LLFocusableElement* focus = NULL;
1217	if (hasFocus())
1218	{
1219		focus = gFocusMgr.getKeyboardFocus();
1220		setFocus(FALSE);
1221	}
1222	refresh();
1223	if (focus)
1224	{
1225		focus->setFocus(TRUE);
1226	}
1227}
1228
1229
1230void LLSidepanelTaskInfo::setObjectSelection(LLObjectSelectionHandle selection)
1231{
1232	mObjectSelection = selection;
1233	refreshAll();
1234}
1235
1236LLSidepanelTaskInfo* LLSidepanelTaskInfo::getActivePanel()
1237{
1238	return sActivePanel;
1239}
1240
1241LLViewerObject* LLSidepanelTaskInfo::getObject()
1242{
1243	if (!mObject->isDead())
1244		return mObject;
1245	return NULL;
1246}
1247
1248LLViewerObject* LLSidepanelTaskInfo::getFirstSelectedObject()
1249{
1250	LLSelectNode *node = mObjectSelection->getFirstRootNode();
1251	if (node)
1252	{
1253		return node->getObject();
1254	}
1255	return NULL;
1256}
1257
1258const LLUUID& LLSidepanelTaskInfo::getSelectedUUID()
1259{
1260	const LLViewerObject* obj = getFirstSelectedObject();
1261	if (obj)
1262	{
1263		return obj->getID();
1264	}
1265	return LLUUID::null;
1266}