15 #include <sigc++/signal.h> 16 #include <boost/bind.hpp> 22 #include "TGTextEntry.h" 90 std::vector<std::string>
getTitles()
const override {
91 std::vector<std::string> returnValue;
93 returnValue.push_back(
"Purpose");
94 returnValue.push_back(
"Module Label");
95 returnValue.push_back(
"Product Instance Label");
96 returnValue.push_back(
"Process Name");
97 returnValue.push_back(
"C++ Class");
162 size_t found = source.find(
remove);
163 if (found == std::string::npos)
165 source.erase(found,
remove.
size());
186 class SortAndFilter {
188 SortAndFilter(
const char *
filter,
int column,
bool order,
const std::vector<FWJobMetadataManager::Data> &
data)
189 :
m_filter(filter), m_column(column), m_order(order), m_data(data) {
191 m_weights.resize(data.size());
196 for (
size_t i = 0,
e = m_weights.size();
i !=
e; ++
i)
197 m_weights[
i] = matchesFilter(m_data[
i]);
207 strip(str,
"vector<");
208 strip(str,
"clonepolicy");
209 strip(str,
"ownvector");
210 strip(str,
"rangemap<");
211 strip(str,
"strictweakordering<");
212 strip(str,
"sortedcollection<");
213 strip(str,
"reco::");
214 strip(str,
"edmnew::");
220 const char *
begin = up.c_str();
226 if ((!
m_filter.empty()) && str.empty())
232 if (strstr(begin,
m_filter.c_str()))
244 std::vector<unsigned int> scores;
251 std::sort(scores.begin(), scores.end());
252 return scores.back();
258 bool operator()(
const int &aIndex,
const int &bIndex) {
262 return m_weights[aIndex] >= m_weights[bIndex];
278 const std::vector<FWJobMetadataManager::Data> &m_data;
279 std::vector<unsigned int> m_weights;
282 void doSort(
int column,
285 const std::vector<FWJobMetadataManager::Data> &iData,
286 std::vector<int> &oRowToIndex) {
287 std::vector<int> ordered;
288 ordered.reserve(iData.size());
290 for (
size_t i = 0,
e = iData.size();
i !=
e; ++
i)
291 ordered.push_back(
i);
293 SortAndFilter
sorter(filter, column, descentSort, iData);
295 std::stable_sort(ordered.begin(), ordered.end(),
sorter);
298 oRowToIndex.reserve(ordered.size());
300 for (
size_t i = 0,
e = ordered.size();
i !=
e; ++
i)
301 if (sorter.matchesFilter(iData[ordered[
i]]) != 0)
302 oRowToIndex.push_back(ordered[i]);
323 :
m_manager(iManager), m_metadataManager(iMetadataManager), m_parentFrame(iParent) {
361 TClass *theClass = TClass::GetClass(
m_type.c_str());
362 if (
nullptr == theClass) {
366 if (moduleLabel.empty()) {
376 TString
msg(
"Event item '");
378 msg +=
"' is already registered. Please use another name.";
380 new TGMsgBox(gClient->GetDefaultRoot(),
m_frame,
"Error - Name conflict",
msg, kMBIconExclamation, kMBOk);
390 if ((*it) && largest < (*it)->layer()) {
391 largest = (*it)->layer();
449 m_frame->Connect(
"CloseWindow()",
"FWGUIEventDataAdder",
this,
"windowIsClosing()");
452 TGTextButton *cancelButton, *resetButton;
463 .
addLabel(
"Viewable Collections", 8)
478 "Do not use Process Name and " 479 "instead only get this data " 480 "from the most recent Process",
496 m_search->Connect(
"TextChanged(const char *)",
"FWGUIEventDataAdder",
this,
"updateFilterString(const char *)");
501 m_tableWidget->Connect(
"rowClicked(Int_t,Int_t,Int_t,Int_t,Int_t)",
502 "FWGUIEventDataAdder",
504 "rowClicked(Int_t,Int_t,Int_t,Int_t,Int_t)");
508 resetButton->SetEnabled(
true);
509 resetButton->Connect(
"Clicked()",
"FWGUIEventDataAdder",
this,
"resetNameEntry()");
511 cancelButton->Connect(
"Clicked()",
"FWGUIEventDataAdder",
this,
"windowIsClosing()");
512 cancelButton->SetEnabled(
true);
513 m_apply->Connect(
"Clicked()",
"FWGUIEventDataAdder",
this,
"addNewItem()");
514 m_applyAndClose->Connect(
"Clicked()",
"FWGUIEventDataAdder",
this,
"addNewItemAndClose()");
516 m_frame->SetWindowName(
"Add Collection");
535 if (-1 != iSelectedIndex) {
537 m_purpose = metadata[iSelectedIndex].purpose_;
538 m_type = metadata[iSelectedIndex].type_;
544 if (strlen(
m_name->GetText()) == 0 || oldModuleLabel ==
m_name->GetText()) {
554 bool isMostRecentProcess =
true;
556 for (std::vector<FWJobMetadataManager::Data>::iterator it = metadata.begin(), itEnd = metadata.end();
557 it != itEnd && isMostRecentProcess;
559 if (index == iSelectedIndex) {
571 if (it->processName_ == processName) {
572 isMostRecentProcess =
false;
578 if (isMostRecentProcess) {
591 if (iButton == kButton1) {
FWDialogBuilder & spaceUp(size_t spacing=3)
FWTextTableCellRenderer m_renderer
int unsortedRowNumber(int iSortedRowNumber) const override
when passed the index to the sorted order of the rows it returns the original row number from the und...
TGTextButton * m_applyAndClose
void implSort(int col, bool sortOrder) override
Called by 'sort' method to actually handle the sorting of the rows. Arguments are the same as 'sort'...
bool sortOrder(void)
The current sort order for the table.
virtual bool rowIsSelected(int row) const
void setSelection(int row, int mask)
FWEventItemsManager * m_manager
FWDialogBuilder & addTextButton(const char *text, TGTextButton **out=nullptr)
std::vector< int > m_row_to_index
void metadataUpdatedSlot(void)
void sort(int iCol, bool iSortOrder)
Call to have table sorted on values in column iCol with the sort order being descending if iSortOrder...
int numberOfRows() const override
Number of rows in the table.
int numberOfColumns() const override
Number of columns in the table.
void dataChanged()
Classes which inherit from FWTableManagerBase must call this when their underlying data changes...
std::string m_processName
virtual const std::string title() const
FWDialogBuilder & addLabel(const char *text, size_t fontSize=12, size_t weight=0, TGLabel **out=nullptr)
static const FWDisplayProperties defaultProperties
FWDialogBuilder & addCheckbox(const char *text, TGCheckButton **out=nullptr)
std::vector< std::string > getTitles() const override
returns the title names for each column
FWJobMetadataManager * m_metadataManager
virtual ~FWGUIEventDataAdder()
std::string m_productInstanceLabel
FWDialogBuilder & frameSpaceDown(size_t spacing=3)
FWGUIEventDataAdder(UInt_t w, UInt_t, FWEventItemsManager *, TGFrame *, FWJobMetadataManager *)
void updateFilterString(const char *str)
FWDialogBuilder & frameSpaceUpDown(size_t spacing=3)
sigc::signal< void, int > indexSelected_
virtual void sortWithFilter(const char *filter)
FWEventItem * add(const FWPhysicsObjectDesc &iItem, const FWConfiguration *pbConf=nullptr, bool doSetEvent=true)
TGCheckButton * m_doNotUseProcessName
TGTransientFrame * m_frame
const FWEventItem * find(const std::string &iName) const
void changeSelection(int iRow)
FWDialogBuilder & hSpacer(size_t size=0)
FWDialogBuilder & addTextEntry(const char *defaultText, TGTextEntry **out)
void setData(const std::string &, bool isSelected)
const_iterator begin() const
NOTE: iterator is allowed to return a null object for items that have been removed.
FWDialogBuilder & floatLeft(size_t spacing=3)
FWTableCellRendererBase * cellRenderer(int iSortedRowNumber, int iCol) const override
FWDialogBuilder & addTable(FWTableManagerBase *manager, FWTableWidget **out=nullptr)
FWDialogBuilder & expand(size_t expandX=true, size_t expandY=false)
static const std::string & dataForColumn(const FWJobMetadataManager::Data &iData, int iCol)
char data[epos_bytes_allocation]
void visualPropertiesChanged()
Classes which inherit from FWTableManagerBase must call this when how the data is shown (e...
FWTableWidget * m_tableWidget
DataAdderTableManager * m_tableManager
void rowClicked(Int_t iRow, Int_t iButton, Int_t iKeyMod, Int_t, Int_t)
DataAdderTableManager(FWJobMetadataManager *manager)
FWDialogBuilder & indent(int left=2, int right=-1)
std::vector< FWEventItem * >::const_iterator const_iterator
static std::string const source
void newIndexSelected(int)
FWDialogBuilder & spaceDown(size_t spacing=3)
FWJobMetadataManager * m_manager
static const unsigned int kNColumns
const_iterator end() const
void addNewItemAndClose()
FWDialogBuilder & spaceRight(size_t spacing=3)
std::string m_moduleLabel