1 // Copyright (C) 2006-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "EditionProc.hxx"
22 #include "QtGuiContext.hxx"
23 #include "LinkInfo.hxx"
28 #include "YacsTrace.hxx"
35 using namespace YACS::HMI;
36 using namespace YACS::ENGINE;
38 EditionProc::EditionProc(Subject* subject,
41 : EditionBloc(subject, parent, name)
43 DEBTRACE("EditionProc::EditionProc");
44 _statusLog = new QTextEdit(this);
45 _wid->gridLayout1->addWidget(_statusLog);
49 if (!QtGuiContext::getQtCurrent()->isEdition())
51 QHBoxLayout* hbox = new QHBoxLayout();
52 QLabel* la = new QLabel("Shutdown level:",this);
53 QComboBox* cb = new QComboBox(this);
59 if (QtGuiContext::getQtCurrent()->getGuiExecutor())
60 level=QtGuiContext::getQtCurrent()->getGuiExecutor()->getShutdownLevel();
62 cb->setCurrentIndex(level);
63 connect(cb, SIGNAL(currentIndexChanged(int)), this, SLOT(onLevelChange(int)));
66 _wid->gridLayout1->addLayout(hbox,4,0);
70 EditionProc::~EditionProc()
72 DEBTRACE("EditionProc::~EditionProc");
75 void EditionProc::update(GuiEvent event, int type, Subject* son)
77 DEBTRACE("EditionProc::update " << GuiObserver::eventName(event));
78 EditionBloc::update(event, type, son);
79 string statusLog = "";
83 if (QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.empty())
86 _modifLog = "--- some elements are modified and not taken into account. Confirmation or annulation required ---\n";
92 if(type != YACS::FINISHED)break;
93 if (!QtGuiContext::getQtCurrent()) break;
94 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) break;
95 YACS::ENGINE::Proc* proc = QtGuiContext::getQtCurrent()->getProc();
96 _errorLog = QtGuiContext::getQtCurrent()->getGuiExecutor()->getErrorReport(proc);
97 _statusLog->setText(QString::fromStdString(_errorLog));
106 void EditionProc::synchronize()
108 DEBTRACE("EditionProc::synchronize");
109 YACS::ENGINE::Proc* proc = QtGuiContext::getQtCurrent()->getProc();
111 string statusLog = "";
113 if (!QtGuiContext::getQtCurrent()->isEdition())
115 if (!proc->isValid())
117 _errorLog = "--- YACS schema is not valid ---\n\n";
118 _errorLog += proc->getErrorReport();
123 // --- Check consistency
124 LinkInfo info(LinkInfo::ALL_DONT_STOP);
128 proc->checkConsistency(info);
129 if (info.areWarningsOrErrors())
130 _errorLog += info.getGlobalRepr();
133 _errorLog += "--- No Validity Errors ---\n";
134 _errorLog += "--- No Consistency Errors ---\n";
137 catch (Exception &ex)
139 _errorLog = "--- YACS schema has consistency errors ---\n\n";
140 _errorLog += ex.what();
144 // --- Add initial logger info
145 logger = proc->getLogger("parser");
146 if (!logger->isEmpty())
148 _errorLog += "--- Original file import log ---\n";
149 _errorLog += logger->getStr();
151 statusLog = _modifLog + _errorLog;
152 _statusLog->setText(statusLog.c_str());
155 void EditionProc::onLevelChange(int index)
157 DEBTRACE("EditionProc::onLevelChange " << index);
158 if (QtGuiContext::getQtCurrent()->getGuiExecutor())
159 QtGuiContext::getQtCurrent()->getGuiExecutor()->setShutdownLevel(index);