16 #include <sigc++/signal.h>
17 #include <boost/bind.hpp>
23 #include "TGTextEntry.h"
67 static const std::string s_blank;
104 std::vector<std::string> returnValue;
106 returnValue.push_back(
"Purpose");
107 returnValue.push_back(
"Module Label");
108 returnValue.push_back(
"Product Instance Label");
109 returnValue.push_back(
"Process Name");
110 returnValue.push_back(
"C++ Class");
137 virtual const std::string
title()
const {
138 return "Viewable Collections";
181 std::string
remove(str);
184 size_t found = source.find(
remove);
185 if (found == std::string::npos)
187 source.erase(found,
remove.
size());
211 SortAndFilter(
const char *
filter,
int column,
bool order,
212 const std::vector<FWJobMetadataManager::Data> &
data)
219 m_weights.resize(data.size());
224 for (
size_t i = 0,
e = m_weights.size();
i !=
e; ++
i)
225 m_weights[
i] = matchesFilter(m_data[
i]);
231 static void simplify(std::string &str)
236 strip(str,
"vector<");
237 strip(str,
"clonepolicy");
238 strip(str,
"ownvector");
239 strip(str,
"rangemap<");
240 strip(str,
"strictweakordering<");
241 strip(str,
"sortedcollection<");
242 strip(str,
"reco::");
243 strip(str,
"edmnew::");
246 unsigned int matches(
const std::string &str)
const
250 const char *
begin = up.c_str();
256 if ((!m_filter.empty()) && str.empty())
262 if (strstr(begin, m_filter.c_str()))
275 std::vector<unsigned int> scores;
277 scores.push_back(matches(data.
purpose_));
278 scores.push_back(matches(data.
type_));
283 return scores.back();
289 bool operator()(
const int &aIndex,
const int &bIndex)
294 return m_weights[aIndex] >= m_weights[bIndex];
305 std::string m_filter;
309 const std::vector<FWJobMetadataManager::Data> &m_data;
310 std::vector<unsigned int> m_weights;
313 void doSort(
int column,
316 const std::vector<FWJobMetadataManager::Data>& iData,
317 std::vector<int>& oRowToIndex)
319 std::vector<int> ordered;
320 ordered.reserve(iData.size());
322 for (
size_t i = 0,
e = iData.size();
i !=
e; ++
i)
323 ordered.push_back(
i);
325 SortAndFilter
sorter(filter, column, descentSort, iData);
327 std::stable_sort(ordered.begin(), ordered.end(),
sorter);
330 oRowToIndex.reserve(ordered.size());
332 for (
size_t i = 0,
e = ordered.size();
i !=
e; ++
i)
333 if (
sorter.matchesFilter(iData[ordered[
i]]) != 0)
334 oRowToIndex.push_back(ordered[i]);
359 m_metadataManager(iMetadataManager),
360 m_parentFrame(iParent)
402 TClass* theClass = TClass::GetClass(
m_type.c_str());
407 if(moduleLabel.empty()) {
417 TString
msg(
"Event item '");
419 msg +=
"' is already registered. Please use another name.";
421 new TGMsgBox(gClient->GetDefaultRoot(),
m_frame,
422 "Error - Name conflict",
msg, kMBIconExclamation, kMBOk);
435 if((*it) && largest < (*it)->layer()) {
436 largest = (*it)->layer();
502 m_frame->Connect(
"CloseWindow()",
"FWGUIEventDataAdder",
this,
"windowIsClosing()");
505 TGTextButton *cancelButton, *resetButton;
512 .
addLabel(
"Viewable Collections", 8)
520 "instead only get this data "
521 "from the most recent Process",
530 m_search->Connect(
"TextChanged(const char *)",
"FWGUIEventDataAdder",
531 this,
"updateFilterString(const char *)");
536 m_tableWidget->Connect(
"rowClicked(Int_t,Int_t,Int_t,Int_t,Int_t)",
537 "FWGUIEventDataAdder",
this,
538 "rowClicked(Int_t,Int_t,Int_t,Int_t,Int_t)");
542 resetButton->SetEnabled(
true);
543 resetButton->Connect(
"Clicked()",
"FWGUIEventDataAdder",
this,
"resetNameEntry()");
545 cancelButton->Connect(
"Clicked()",
"FWGUIEventDataAdder",
this,
"windowIsClosing()");
546 cancelButton->SetEnabled(
true);
547 m_apply->Connect(
"Clicked()",
"FWGUIEventDataAdder",
this,
"addNewItem()");
548 m_applyAndClose->Connect(
"Clicked()",
"FWGUIEventDataAdder",
this,
"addNewItemAndClose()");
550 m_frame->SetWindowName(
"Add Collection");
575 if(-1 != iSelectedIndex) {
577 m_purpose = metadata[iSelectedIndex].purpose_;
578 m_type = metadata[iSelectedIndex].type_;
584 if(strlen(
m_name->GetText())==0 || oldModuleLabel ==
m_name->GetText()) {
594 bool isMostRecentProcess =
true;
596 for(std::vector<FWJobMetadataManager::Data>::iterator it = metadata.begin(), itEnd = metadata.end();
597 it != itEnd && isMostRecentProcess;
599 if(index == iSelectedIndex) {
continue;}
613 if(it->processName_ == processName)
615 isMostRecentProcess =
false;
621 if(isMostRecentProcess) {
636 if(iButton==kButton1) {
FWDialogBuilder & spaceUp(size_t spacing=3)
FWTextTableCellRenderer m_renderer
TGTextButton * m_applyAndClose
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 & addLabel(const char *text, size_t fontSize=12, size_t weight=0, TGLabel **out=0)
std::vector< int > m_row_to_index
virtual std::vector< std::string > getTitles() const
returns the title names for each column
void metadataUpdatedSlot(void)
virtual void implSort(int col, bool sortOrder)
Called by 'sort' method to actually handle the sorting of the rows. Arguments are the same as 'sort'...
void sort(int iCol, bool iSortOrder)
Call to have table sorted on values in column iCol with the sort order being descending if iSortOrder...
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 & addTable(FWTableManagerBase *manager, FWTableWidget **out=0)
static const FWDisplayProperties defaultProperties
virtual int numberOfRows() const
Number of rows in the table.
FWJobMetadataManager * m_metadataManager
virtual ~FWGUIEventDataAdder()
std::string m_productInstanceLabel
virtual FWTableCellRendererBase * cellRenderer(int iSortedRowNumber, int iCol) const
FWDialogBuilder & frameSpaceDown(size_t spacing=3)
FWGUIEventDataAdder(UInt_t w, UInt_t, FWEventItemsManager *, TGFrame *, FWJobMetadataManager *)
void updateFilterString(const char *str)
FWDialogBuilder & addTextButton(const char *text, TGTextButton **out=0)
FWDialogBuilder & frameSpaceUpDown(size_t spacing=3)
virtual void sortWithFilter(const char *filter)
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)
FWDialogBuilder & expand(size_t expandX=true, size_t expandY=false)
static const std::string & dataForColumn(const FWJobMetadataManager::Data &iData, int iCol)
virtual int numberOfColumns() const
Number of columns in the table.
char data[epos_bytes_allocation]
sigc::signal< void, int > indexSelected_
void visualPropertiesChanged()
Classes which inherit from FWTableManagerBase must call this when how the data is shown (e...
const FWEventItem * add(const FWPhysicsObjectDesc &iItem, const FWConfiguration *pbConf=0)
FWTableWidget * m_tableWidget
DataAdderTableManager * m_tableManager
void rowClicked(Int_t iRow, Int_t iButton, Int_t iKeyMod, Int_t, Int_t)
virtual int unsortedRowNumber(int iSortedRowNumber) const
when passed the index to the sorted order of the rows it returns the original row number from the und...
FWDialogBuilder & addCheckbox(const char *text, TGCheckButton **out=0)
DataAdderTableManager(FWJobMetadataManager *manager)
FWDialogBuilder & indent(int left=2, int right=-1)
std::vector< FWEventItem * >::const_iterator const_iterator
void newIndexSelected(int)
tuple size
Write out results.
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