29 #include <PyEditor_Editor.h>
30 #include <PyEditor_Settings.h>
33 #include <QToolButton>
35 #include <QTemporaryFile>
36 #include <QTextStream>
47 using namespace YACS::HMI;
49 EditionScript::EditionScript(
Subject* subject,
60 QSplitter *splitter =
new QSplitter(
this);
61 splitter->setOrientation(Qt::Vertical);
62 _wid->gridLayout1->addWidget(splitter);
68 splitter->addWidget(widg);
74 splitter->addWidget(window);
77 QHBoxLayout* hboxLayout =
new QHBoxLayout();
78 hboxLayout->setMargin(0);
79 QToolButton* tb_options =
new QToolButton();
80 tb_options->setCheckable(
true);
82 icon.addFile(
"icons:icon_down.png");
83 icon.addFile(
"icons:icon_up.png", QSize(), QIcon::Normal, QIcon::On);
84 tb_options->setIcon(icon);
85 hboxLayout->addWidget(tb_options);
87 QLabel* label =
new QLabel(
"Execution Mode");
92 hboxLayout->addWidget(label);
97 QHBoxLayout* hboxLayout1 =
new QHBoxLayout(
fr_options);
98 hboxLayout1->setMargin(0);
107 QHBoxLayout* hboxLayout2 =
new QHBoxLayout(
fr_container);
108 hboxLayout2->setMargin(0);
109 QLabel* laContainer =
new QLabel(
"Container:");
110 hboxLayout2->addWidget(laContainer);
128 _sci =
new PyEditor_Editor(
this);
130 _sci =
new QTextEdit(
this);
132 _wid->gridLayout->removeItem(
_wid->spacerItem);
134 _editor =
new QPushButton(
"External Editor",
this);
143 _sci->setReadOnly(
true);
183 bool scriptEdited =
false;
185 PyEditor_Settings settings =
_sci->settings();
187 _sci->setSettings(settings);
204 if (
_sci->document()->isModified())
207 std::string text=
_sci->document()->toPlainText().toStdString();
208 if(text[text.length()-1] !=
'\n')
211 if (ret) scriptEdited =
false;
215 bool containerEdited =
true;
218 containerEdited =
false;
239 DEBTRACE(
"EditionScript::onScriptModified");
247 QTemporaryFile outFile;
250 QString fileName = outFile.fileName();
251 QTextStream out(&outFile);
252 out <<
_sci->toPlainText();
256 QString prog=options.takeAt(0);
257 QProcess::execute(prog, QStringList() << options << fileName);
259 QFile inFile(fileName);
260 if (!inFile.open(QIODevice::ReadOnly))
262 QTextStream in(&inFile);
263 _sci->setPlainText(in.readAll());
269 DEBTRACE(
"EditionScript::on_tb_options_toggled " << checked);
290 DEBTRACE(
"EditionScript::on_remote_toggled " << checked);
317 DEBTRACE(
"EditionScript::fillContainerPanel ");
321 std::map<string,YACS::ENGINE::Container*>::const_iterator it = proc->
containerMap.begin();
341 DEBTRACE(
"EditionScript::changeContainer ");
342 string contName =
cb_container->itemText(index).toStdString();
353 DEBTRACE(
"-------------> not found : " << contName);
385 else if(mode ==
"local")