25 #include <ArmarXGui/libraries/ArmarXGuiBase/ui_IceProxyFinder.h>
32 #include <IceStorm/IceStorm.h>
33 #include <Ice/Initialize.h>
57 if (
impl->refreshProxyListTask)
59 impl->refreshProxyListTask->stop(
true);
66 this->
impl->icemanager = icemanager;
75 return ui->cbProxyName->currentText();
80 ui->cbProxyName->setEditText(proxyName);
85 impl->defaultItem = proxyName;
90 ui->edtSearchMask->setText(searchMask);
95 ui->edtSearchMask->setVisible(show);
96 ui->labelMask->setVisible(show);
101 ui->labelMask->setVisible(show);
102 ui->labelProxy->setVisible(show);
112 return ui->cbProxyName;
117 if (searchMask.length() == 0)
122 Ice::StringSeq proxyList;
123 QStringList qProxyList;
124 if (!
impl->icemanager)
126 throw LocalException(
"IceManager must not be NULL");
128 auto searchMasks =
Split(searchMask.toStdString(),
"|");
129 for (
auto& subSearchMasks : searchMasks)
131 if (
impl->icemanager &&
impl->icemanager->getIceGridSession())
135 IceGrid::AdminPrx admin = iceGridSession->getAdmin();
136 Ice::AsyncResultPtr localBegin_getAllObjectInfos = admin->begin_getAllObjectInfos(subSearchMasks);
137 while (!localBegin_getAllObjectInfos->isCompleted())
139 if (
impl->refreshProxyListTask->isStopped())
145 IceGrid::ObjectInfoSeq objects = admin->end_getAllObjectInfos(localBegin_getAllObjectInfos);
146 Ice::StringSeq tempProxyList;
148 for (
auto&
object : objects)
153 if (
impl->refreshProxyListTask->isStopped())
158 if (!typedName.empty())
160 tempProxyList.push_back(typedName);
169 proxyList.insert(proxyList.end(), tempProxyList.begin(), tempProxyList.end());
175 for (
unsigned int i = 0; i < proxyList.size(); ++i)
177 qProxyList << QString::fromStdString(proxyList.at(i));
179 qProxyList.removeDuplicates();
185 if (
impl->refreshProxyListTask &&
impl->refreshProxyListTask->isRunning())
190 ui->btnRefresh->setEnabled(
false);
191 ui->btnRefresh->setToolTip(
"Refreshing proxy list with mask '" +
ui->edtSearchMask->text() +
"'. Please wait...");
193 impl->refreshProxyListTask->start();
203 ui->cbProxyName->clear();
204 if (not
impl->defaultItem.isEmpty())
206 ui->cbProxyName->addItem(
impl->defaultItem);
207 ui->cbProxyName->setCurrentIndex(0);
211 for (; i < proxyList.size(); ++i)
213 if (proxyList.at(i) !=
impl->defaultItem)
215 ui->cbProxyName->addItem(proxyList.at(i));
219 ui->btnRefresh->setEnabled(
true);
220 ui->btnRefresh->setToolTip(
"Press to refetch all available Kinematic Units with the given mask");
228 IceGrid::AdminPrx admin = this->
impl->icemanager->getIceGridSession()->getAdmin();
229 Ice::Identity objectIceId = Ice::stringToIdentity(proxyName.toStdString());
230 Ice::ObjectPrx objPrx = admin->getObjectInfo(objectIceId).proxy;
247 if (!
impl->refreshProxyListTask->isStopped())
255 this->
ui->setupUi(
this);
273 ui->labelProxy->setText(
"Topic");
278 if (searchMask.length() == 0)
283 IceStorm::TopicDict topicList;
285 if (!
impl->icemanager)
287 throw LocalException(
"IceManager must not be NULL");
290 if (
impl->icemanager &&
impl->icemanager->getIceGridSession())
292 topicList =
impl->icemanager->getTopicManager()->retrieveAll();
295 QStringList qProxyList;
297 for (
auto& e : topicList)
299 auto name = QString::fromStdString(e.first);
300 QRegExp rex(searchMask, Qt::CaseInsensitive, QRegExp::Wildcard);
302 if (name.contains(rex))