summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelgroupnotices.cpp
blob: 483c6876ed8f615c4983cf1fce444a38cd365e57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
/**
 * @file llpanelgroupnotices.cpp
 * @brief A panel to display group notices.
 *
 * $LicenseInfo:firstyear=2006&license=viewerlgpl$
 * Second Life Viewer Source Code
 * Copyright (C) 2010, Linden Research, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation;
 * version 2.1 of the License only.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 * $/LicenseInfo$
 */

#include "llviewerprecompiledheaders.h"

#include "llpanelgroupnotices.h"

#include "llview.h"

#include "llavatarnamecache.h"
#include "llinventory.h"
#include "llviewerinventory.h"
#include "llinventorydefines.h"
#include "llinventoryfunctions.h"
#include "llinventoryicon.h"
#include "llinventorymodel.h"
#include "llagent.h"
#include "llagentui.h"

#include "lllineeditor.h"
#include "lltexteditor.h"
#include "llbutton.h"
#include "lliconctrl.h"
#include "llcheckboxctrl.h"
#include "llscrolllistctrl.h"
#include "llscrolllistitem.h"
#include "lltextbox.h"
#include "lltrans.h"

#include "roles_constants.h"
#include "llviewerwindow.h"
#include "llviewermessage.h"
#include "llnotificationsutil.h"
#include "llgiveinventory.h"

static LLPanelInjector<LLPanelGroupNotices> t_panel_group_notices("panel_group_notices");


/////////////////////////
// LLPanelGroupNotices //
/////////////////////////
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLDropTarget
//
// This handy class is a simple way to drop something on another
// view. It handles drop events, always setting itself to the size of
// its parent.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLGroupDropTarget : public LLView
{
public:
    struct Params : public LLInitParam::Block<Params, LLView::Params>
    {
        // *NOTE: These parameters logically Mandatory, but are not
        // specified in XML files, hence Optional
        Optional<LLPanelGroupNotices*> panel;
        Optional<LLUUID>    group_id;
        Params()
        :   panel("panel"),
            group_id("group_id")
        {
            changeDefault(mouse_opaque, false);
            changeDefault(follows.flags, FOLLOWS_ALL);
        }
    };
    LLGroupDropTarget(const Params&);
    ~LLGroupDropTarget() {};

    //
    // LLView functionality
    virtual bool handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop,
                                   EDragAndDropType cargo_type,
                                   void* cargo_data,
                                   EAcceptance* accept,
                                   std::string& tooltip_msg);
    void setPanel (LLPanelGroupNotices* panel) {mGroupNoticesPanel = panel;};
    void setGroup (LLUUID group) {mGroupID = group;};

protected:
    LLPanelGroupNotices* mGroupNoticesPanel;
    LLUUID  mGroupID;
};

static LLDefaultChildRegistry::Register<LLGroupDropTarget> r("group_drop_target");

LLGroupDropTarget::LLGroupDropTarget(const LLGroupDropTarget::Params& p)
:   LLView(p),
    mGroupNoticesPanel(p.panel),
    mGroupID(p.group_id)
{}

bool LLGroupDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop,
                                     EDragAndDropType cargo_type,
                                     void* cargo_data,
                                     EAcceptance* accept,
                                     std::string& tooltip_msg)
{
    bool handled = false;

    if (!gAgent.hasPowerInGroup(mGroupID,GP_NOTICES_SEND))
    {
        *accept = ACCEPT_NO;
        return true;
    }

    if(getParent())
    {
        // check if inside
        //LLRect parent_rect = mParentView->getRect();
        //getRect().set(0, parent_rect.getHeight(), parent_rect.getWidth(), 0);
        handled = true;

        // check the type
        switch(cargo_type)
        {
        case DAD_TEXTURE:
        case DAD_SOUND:
        case DAD_LANDMARK:
        case DAD_SCRIPT:
        case DAD_OBJECT:
        case DAD_NOTECARD:
        case DAD_CLOTHING:
        case DAD_BODYPART:
        case DAD_ANIMATION:
        case DAD_GESTURE:
        case DAD_CALLINGCARD:
        case DAD_MESH:
        case DAD_SETTINGS:
        case DAD_MATERIAL:
        {
            LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data;
            if(gInventory.getItem(inv_item->getUUID())
                && LLGiveInventory::isInventoryGroupGiveAcceptable(inv_item))
            {
                // *TODO: get multiple object transfers working
                *accept = ACCEPT_YES_COPY_SINGLE;
                if(drop)
                {
                    mGroupNoticesPanel->setItem(inv_item);
                }
            }
            else
            {
                // It's not in the user's inventory (it's probably
                // in an object's contents), so disallow dragging
                // it here.  You can't give something you don't
                // yet have.
                *accept = ACCEPT_NO;
            }
            break;
        }
        case DAD_CATEGORY:
        default:
            *accept = ACCEPT_NO;
            break;
        }
    }
    return handled;
}

//-----------------------------------------------------------------------------
// LLPanelGroupNotices
//-----------------------------------------------------------------------------
std::string build_notice_date(const U32& the_time)
{
    // ISO 8601 date format

    time_t t = (time_t)the_time;

    if (!t)
    {
        time(&t);
    }

    std::string dateStr = "["+ LLTrans::getString("LTimeYear") + "]/["
                                + LLTrans::getString("LTimeMthNum") + "]/["
                                + LLTrans::getString("LTimeDay") + "] ["
                                + LLTrans::getString("LTimeHour") + "]:["
                                + LLTrans::getString("LTimeMin") + "]:["
                                + LLTrans::getString("LTimeSec") + "]";
    LLSD substitution;
    substitution["datetime"] = (S32) t;
    LLStringUtil::format (dateStr, substitution);
    return dateStr;
}

LLPanelGroupNotices::LLPanelGroupNotices() :
    LLPanelGroupTab(),
    mInventoryItem(NULL),
    mInventoryOffer(NULL)
{


}

LLPanelGroupNotices::~LLPanelGroupNotices()
{
    sInstances.erase(mGroupID);

    if (mInventoryOffer)
    {
        // Cancel the inventory offer.
        mInventoryOffer->forceResponse(IOR_DECLINE);

        mInventoryOffer = NULL;
    }
}


bool LLPanelGroupNotices::isVisibleByAgent(LLAgent* agentp)
{
    return mAllowEdit &&
        agentp->hasPowerInGroup(mGroupID, GP_NOTICES_SEND | GP_NOTICES_RECEIVE);
}

bool LLPanelGroupNotices::postBuild()
{
    constexpr bool recurse = true;

    mNoticesList = getChild<LLScrollListCtrl>("notice_list",recurse);
    mNoticesList->setCommitOnSelectionChange(true);
    mNoticesList->setCommitCallback(onSelectNotice, this);
    mNoticesList->sortByColumn("date", false);

    mBtnNewMessage = getChild<LLButton>("create_new_notice",recurse);
    mBtnNewMessage->setClickedCallback(onClickNewMessage, this);
    mBtnNewMessage->setEnabled(gAgent.hasPowerInGroup(mGroupID, GP_NOTICES_SEND));

    mBtnGetPastNotices = getChild<LLButton>("refresh_notices",recurse);
    mBtnGetPastNotices->setClickedCallback(onClickRefreshNotices, this);

    // Create
    mCreateSubject = getChild<LLLineEditor>("create_subject",recurse);
    mCreateMessage = getChild<LLTextEditor>("create_message",recurse);

    mCreateInventoryName =  getChild<LLLineEditor>("create_inventory_name",recurse);
    mCreateInventoryName->setTabStop(false);
    mCreateInventoryName->setEnabled(false);

    mCreateInventoryIcon = getChild<LLIconCtrl>("create_inv_icon",recurse);
    mCreateInventoryIcon->setVisible(false);

    mBtnSendMessage = getChild<LLButton>("send_notice",recurse);
    mBtnSendMessage->setClickedCallback(onClickSendMessage, this);

    mBtnRemoveAttachment = getChild<LLButton>("remove_attachment",recurse);
    mBtnRemoveAttachment->setClickedCallback(onClickRemoveAttachment, this);
    mBtnRemoveAttachment->setEnabled(false);

    // View
    mViewSubject = getChild<LLLineEditor>("view_subject",recurse);
    mViewMessage = getChild<LLTextEditor>("view_message",recurse);

    mViewInventoryName =  getChild<LLLineEditor>("view_inventory_name",recurse);
    mViewInventoryName->setTabStop(false);
    mViewInventoryName->setEnabled(false);

    mViewInventoryIcon = getChild<LLIconCtrl>("view_inv_icon",recurse);
    mViewInventoryIcon->setVisible(false);

    mBtnOpenAttachment = getChild<LLButton>("open_attachment",recurse);
    mBtnOpenAttachment->setClickedCallback(onClickOpenAttachment, this);

    mNoNoticesStr = getString("no_notices_text");

    mPanelCreateNotice = getChild<LLPanel>("panel_create_new_notice",recurse);
    mPanelViewNotice = getChild<LLPanel>("panel_view_past_notice",recurse);

    LLGroupDropTarget* target = getChild<LLGroupDropTarget> ("drop_target");
    target->setPanel (this);
    target->setGroup (mGroupID);

    arrangeNoticeView(VIEW_PAST_NOTICE);

    return LLPanelGroupTab::postBuild();
}

void LLPanelGroupNotices::activate()
{
    if (mNoticesList)
    {
        mNoticesList->deleteAllItems();
        mKnownNoticeIds.clear();
    }

    mPrevSelectedNotice = LLUUID();

    bool can_send = gAgent.hasPowerInGroup(mGroupID,GP_NOTICES_SEND);
    bool can_receive = gAgent.hasPowerInGroup(mGroupID,GP_NOTICES_RECEIVE);

    mPanelViewNotice->setEnabled(can_receive);
    mPanelCreateNotice->setEnabled(can_send);

    // Always disabled to stop direct editing of attachment names
    mCreateInventoryName->setEnabled(false);
    mViewInventoryName->setEnabled(false);

    // If we can receive notices, grab them right away.
    if (can_receive)
    {
        onClickRefreshNotices(this);
    }
}

void LLPanelGroupNotices::setItem(LLPointer<LLInventoryItem> inv_item)
{
    mInventoryItem = inv_item;

    bool item_is_multi = false;
    if ( inv_item->getFlags() & LLInventoryItemFlags::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS )
    {
        item_is_multi = true;
    };

    std::string icon_name = LLInventoryIcon::getIconName(inv_item->getType(),
                                        inv_item->getInventoryType(),
                                        inv_item->getFlags(),
                                        item_is_multi );

    mCreateInventoryIcon->setValue(icon_name);
    mCreateInventoryIcon->setVisible(true);

    std::stringstream ss;
    ss << "        " << mInventoryItem->getName();

    mCreateInventoryName->setText(ss.str());
    mBtnRemoveAttachment->setEnabled(true);
}

void LLPanelGroupNotices::onClickRemoveAttachment(void* data)
{
    LLPanelGroupNotices* self = (LLPanelGroupNotices*)data;
    self->mInventoryItem = NULL;
    self->mCreateInventoryName->clear();
    self->mCreateInventoryIcon->setVisible(false);
    self->mBtnRemoveAttachment->setEnabled(false);
}

//static
void LLPanelGroupNotices::onClickOpenAttachment(void* data)
{
    LLPanelGroupNotices* self = (LLPanelGroupNotices*)data;

    self->mInventoryOffer->forceResponse(IOR_ACCEPT);
    self->mInventoryOffer = NULL;
    self->mBtnOpenAttachment->setEnabled(false);
}

void LLPanelGroupNotices::onClickSendMessage(void* data)
{
    LLPanelGroupNotices* self = (LLPanelGroupNotices*)data;

    if (self->mCreateSubject->getText().empty())
    {
        // Must supply a subject
        LLNotificationsUtil::add("MustSpecifyGroupNoticeSubject");
        return;
    }
    send_group_notice(
            self->mGroupID,
            self->mCreateSubject->getText(),
            self->mCreateMessage->getText(),
            self->mInventoryItem);


    //instantly add new notice. actual notice will be added after ferreshNotices call
    LLUUID id = LLUUID::generateNewID();
    std::string subj = self->mCreateSubject->getText();
    std::string name ;
    LLAgentUI::buildFullname(name);
    U32 timestamp = 0;

    LLSD row;
    row["id"] = id;

    row["columns"][0]["column"] = "icon";

    row["columns"][1]["column"] = "subject";
    row["columns"][1]["value"] = subj;

    row["columns"][2]["column"] = "from";
    row["columns"][2]["value"] = name;

    row["columns"][3]["column"] = "date";
    row["columns"][3]["value"] = build_notice_date(timestamp);

    row["columns"][4]["column"] = "sort";
    row["columns"][4]["value"] = llformat( "%u", timestamp);

    self->mNoticesList->addElement(row, ADD_BOTTOM);
    self->mKnownNoticeIds.insert(id);

    self->mCreateMessage->clear();
    self->mCreateSubject->clear();
    onClickRemoveAttachment(data);

    self->arrangeNoticeView(VIEW_PAST_NOTICE);
}

//static
void LLPanelGroupNotices::onClickNewMessage(void* data)
{
    LLPanelGroupNotices* self = (LLPanelGroupNotices*)data;

    self->arrangeNoticeView(CREATE_NEW_NOTICE);

    if (self->mInventoryOffer)
    {
        self->mInventoryOffer->forceResponse(IOR_DECLINE);
        self->mInventoryOffer = NULL;
    }

    self->mCreateSubject->clear();
    self->mCreateMessage->clear();
    if (self->mInventoryItem) onClickRemoveAttachment(self);
    self->mNoticesList->deselectAllItems(true); // true == don't commit on chnage
}

void LLPanelGroupNotices::refreshNotices()
{
    onClickRefreshNotices(this);
}

void LLPanelGroupNotices::clearNoticeList()
{
    mPrevSelectedNotice = mNoticesList->getStringUUIDSelectedItem();
    mNoticesList->deleteAllItems();
    mKnownNoticeIds.clear();
}

void LLPanelGroupNotices::onClickRefreshNotices(void* data)
{
    LL_DEBUGS() << "LLPanelGroupNotices::onClickGetPastNotices" << LL_ENDL;
    LLPanelGroupNotices* self = (LLPanelGroupNotices*)data;

    self->clearNoticeList();

    LLMessageSystem* msg = gMessageSystem;
    msg->newMessage("GroupNoticesListRequest");
    msg->nextBlock("AgentData");
    msg->addUUID("AgentID",gAgent.getID());
    msg->addUUID("SessionID",gAgent.getSessionID());
    msg->nextBlock("Data");
    msg->addUUID("GroupID",self->mGroupID);
    gAgent.sendReliableMessage();
}

//static
std::map<LLUUID,LLPanelGroupNotices*> LLPanelGroupNotices::sInstances;

// static
void LLPanelGroupNotices::processGroupNoticesListReply(LLMessageSystem* msg, void** data)
{
    LLUUID group_id;
    msg->getUUID("AgentData", "GroupID", group_id);

    std::map<LLUUID,LLPanelGroupNotices*>::iterator it = sInstances.find(group_id);
    if (it == sInstances.end())
    {
        LL_INFOS() << "Group Panel Notices " << group_id << " no longer in existence."
                << LL_ENDL;
        return;
    }

    LLPanelGroupNotices* selfp = it->second;
    if(!selfp)
    {
        LL_INFOS() << "Group Panel Notices " << group_id << " no longer in existence."
                << LL_ENDL;
        return;
    }

    selfp->processNotices(msg);
}

void LLPanelGroupNotices::processNotices(LLMessageSystem* msg)
{
    LLUUID id;
    std::string subj;
    std::string name;
    U32 timestamp;
    bool has_attachment;
    U8 asset_type;

    S32 i=0;
    S32 count = msg->getNumberOfBlocks("Data");

    mNoticesList->setEnabled(true);

    //save sort state and set unsorted state to prevent unnecessary
    //sorting while adding notices
    bool save_sort = mNoticesList->isSorted();
    mNoticesList->setNeedsSort(false);

    for (;i<count;++i)
    {
        msg->getUUID("Data","NoticeID",id,i);
        if (1 == count && id.isNull())
        {
            // Only one entry, the dummy entry.
            mNoticesList->setCommentText(mNoNoticesStr);
            mNoticesList->setEnabled(false);
            return;
        }

        // Due to some network delays we can receive notice list more than once...
        // So add only unique notices
        if (mKnownNoticeIds.find(id) != mKnownNoticeIds.end())
        {
            // If items with this ID already in the list - skip it
            continue;
        }

        msg->getString("Data","Subject",subj,i);
        msg->getString("Data","FromName",name,i);
        msg->getBOOL("Data","HasAttachment",has_attachment,i);
        msg->getU8("Data","AssetType",asset_type,i);
        msg->getU32("Data","Timestamp",timestamp,i);

        // we only have the legacy name here, convert it to a username
        name = LLCacheName::buildUsername(name);

        LLSD row;
        row["id"] = id;
        row["columns"][0]["column"] = "icon";
        if (has_attachment)
        {
            std::string icon_name = LLInventoryIcon::getIconName(
                                    (LLAssetType::EType)asset_type,
                                    LLInventoryType::IT_NONE);
            row["columns"][0]["type"] = "icon";
            row["columns"][0]["value"] = icon_name;
        }

        row["columns"][1]["column"] = "subject";
        row["columns"][1]["value"] = subj;

        row["columns"][2]["column"] = "from";
        row["columns"][2]["value"] = name;

        row["columns"][3]["column"] = "date";
        row["columns"][3]["value"] = build_notice_date(timestamp);

        row["columns"][4]["column"] = "sort";
        row["columns"][4]["value"] = llformat( "%u", timestamp);

        mNoticesList->addElement(row, ADD_BOTTOM);
        mKnownNoticeIds.insert(id);
    }

    mNoticesList->setNeedsSort(save_sort);
    mNoticesList->updateSort();
    if (mPanelViewNotice->getVisible())
    {
        if (!mNoticesList->selectByID(mPrevSelectedNotice))
        {
            mNoticesList->selectFirstItem();
        }
    }
}

void LLPanelGroupNotices::onSelectNotice(LLUICtrl* ctrl, void* data)
{
    LLPanelGroupNotices* self = (LLPanelGroupNotices*)data;

    if(!self) return;
    LLScrollListItem* item = self->mNoticesList->getFirstSelected();
    if (!item) return;

    LLMessageSystem* msg = gMessageSystem;
    msg->newMessage("GroupNoticeRequest");
    msg->nextBlock("AgentData");
    msg->addUUID("AgentID",gAgent.getID());
    msg->addUUID("SessionID",gAgent.getSessionID());
    msg->nextBlock("Data");
    msg->addUUID("GroupNoticeID",item->getUUID());
    gAgent.sendReliableMessage();

    LL_DEBUGS() << "Item " << item->getUUID() << " selected." << LL_ENDL;
}

void LLPanelGroupNotices::showNotice(const std::string& subject,
                                     const std::string& message,
                                     const bool& has_inventory,
                                     const std::string& inventory_name,
                                     LLOfferInfo* inventory_offer)
{
    arrangeNoticeView(VIEW_PAST_NOTICE);

    if(mViewSubject) mViewSubject->setText(subject);
    if(mViewMessage) mViewMessage->setText(message);

    if (mInventoryOffer)
    {
        // Cancel the inventory offer for the previously viewed notice
        mInventoryOffer->forceResponse(IOR_DECLINE);
        mInventoryOffer = NULL;
    }

    if (inventory_offer)
    {
        mInventoryOffer = inventory_offer;

        std::string icon_name = LLInventoryIcon::getIconName(mInventoryOffer->mType,
                                                LLInventoryType::IT_TEXTURE);

        mViewInventoryIcon->setValue(icon_name);
        mViewInventoryIcon->setVisible(true);

        std::stringstream ss;
        ss << "        " << inventory_name;

        mViewInventoryName->setText(ss.str());
        mBtnOpenAttachment->setEnabled(true);
    }
    else
    {
        mViewInventoryName->clear();
        mViewInventoryIcon->setVisible(false);
        mBtnOpenAttachment->setEnabled(false);
    }
}

void LLPanelGroupNotices::arrangeNoticeView(ENoticeView view_type)
{
    if (CREATE_NEW_NOTICE == view_type)
    {
        mPanelCreateNotice->setVisible(true);
        mPanelViewNotice->setVisible(false);
    }
    else
    {
        mPanelCreateNotice->setVisible(false);
        mPanelViewNotice->setVisible(true);
        mBtnOpenAttachment->setEnabled(false);
    }
}
void LLPanelGroupNotices::setGroupID(const LLUUID& id)
{
    sInstances.erase(mGroupID);
    LLPanelGroupTab::setGroupID(id);
    sInstances[mGroupID] = this;

    mBtnNewMessage->setEnabled(gAgent.hasPowerInGroup(mGroupID, GP_NOTICES_SEND));

    LLGroupDropTarget* target = getChild<LLGroupDropTarget> ("drop_target");
    target->setPanel (this);
    target->setGroup (mGroupID);

    if(mViewMessage)
        mViewMessage->clear();

    if(mViewInventoryName)
        mViewInventoryName->clear();

    activate();
}