-
Notifications
You must be signed in to change notification settings - Fork 1
/
MPOLnchListBoxObserver.cpp
185 lines (141 loc) · 4.44 KB
/
MPOLnchListBoxObserver.cpp
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
//========================================================================================
//
// $File: //depot/indesign_6.0/highprofile/source/sdksamples/wlistboxcomposite/MPOLnchListBoxObserver.cpp $
//
// Owner: Adobe Developer Technologies
//
// $Author: pmbuilder $
//
// $DateTime: 2008/08/19 04:03:07 $
//
// $Revision: #1 $
//
// $Change: 643572 $
//
// Copyright 1997-2008 Adobe Systems Incorporated. All rights reserved.
//
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
// with the terms of the Adobe license agreement accompanying it. If you have received
// this file from a source other than Adobe, then your use, modification, or
// distribution of it requires the prior written permission of Adobe.
//
//========================================================================================
#include "VCPlugInHeaders.h"
// Implementation includes
#include "widgetid.h"
// Interface includes
#include "ISubject.h"
#include "IControlView.h"
#include "ITreeViewController.h"
// Implem includes
#include "CAlert.h"
#include "CObserver.h"
#include "K2Vector.tpp" // For NodeIDList to compile
#include "MPOLnchNodeID.h"
#include "MPOLnchID.h"
// Scripting includes
#include "FileUtils.h"
#include "IScriptRunner.h"
#include "IScriptUtils.h"
/**
Observes the listbox via IID_ITREEVIEWCONTROLLER.
@ingroup mpolauncher
*/
class MPOLnchListBoxObserver : public CObserver
{
public:
/**
Constructor for MPOLnchListBoxObserver class.
@param interface ptr from boss object on which this interface is aggregated.
*/
MPOLnchListBoxObserver(IPMUnknown *boss);
/**
Destructor for MPOLnchListBoxObserver class
*/
~MPOLnchListBoxObserver();
/**
AutoAttach is only called for registered observers
of widgets. This method is called by the application
core when the widget is shown.
*/
virtual void AutoAttach();
/**
AutoDetach is only called for registered observers
of widgets. Called when widget hidden.
*/
virtual void AutoDetach();
/**
This class is interested in changes along IID_ILISTCONTROLDATA protocol with classID of
kListSelectionChangedMessage. This message is sent when a user clicks on an element
in the list-box.
@param theChange this is specified by the agent of change; it can be the class ID of the agent,
or it may be some specialised message ID.
@param theSubject this provides a reference to the object which has changed; in this case, the button
widget boss object that is being observed.
@param protocol the protocol along which the change occurred.
@param changedBy this can be used to provide additional information about the change or a reference
to the boss object that caused the change.
*/
virtual void Update(const ClassID& theChange, ISubject* theSubject, const PMIID &protocol, void* changedBy);
};
CREATE_PMINTERFACE(MPOLnchListBoxObserver, kMPOLnchListBoxObserverImpl)
MPOLnchListBoxObserver::MPOLnchListBoxObserver(IPMUnknown* boss)
: CObserver(boss)
{
}
MPOLnchListBoxObserver::~MPOLnchListBoxObserver()
{
}
void MPOLnchListBoxObserver::AutoAttach()
{
InterfacePtr<ISubject> subject(this, UseDefaultIID());
if (subject != nil)
{
subject->AttachObserver(this, IID_ITREEVIEWCONTROLLER);
}
}
void MPOLnchListBoxObserver::AutoDetach()
{
InterfacePtr<ISubject> subject(this, UseDefaultIID());
if (subject != nil)
{
subject->DetachObserver(this, IID_ITREEVIEWCONTROLLER);
}
}
void MPOLnchListBoxObserver::Update
(
const ClassID& theChange,
ISubject* theSubject,
const PMIID &protocol,
void* changedBy
)
{
if ((protocol == IID_ITREEVIEWCONTROLLER) && (theChange == kListSelectionChangedMessage) ) {
do {
InterfacePtr<ITreeViewController> controller(this, UseDefaultIID());
ASSERT(controller);
if(!controller)
{
break;
}
NodeIDList selectedItems;
controller->GetSelectedItems(selectedItems);
const int kSelectionLength = selectedItems.size() ;
if (kSelectionLength> 0 )
{
PMString nodeName("");
K2Vector<NodeID>::const_iterator iter, startIter, endIter;
startIter = selectedItems.begin();
endIter = selectedItems.end();
for(iter = startIter; iter != endIter; ++iter)
{
const MPOLnchNodeID* oneNode = static_cast<const MPOLnchNodeID*>(iter->Get());
PMString item = oneNode->GetName();
item.Translate();
nodeName.Append(item);
//dbgInfoString += ", ";
}
} // end of --> if (kSelectionLength> 0 )
} while(0);
}
}