| 1 |  | #include "xmltoolsinterface.h" | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 2 |  | #include "ui_xmltoolsinterface.h" | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 3 |  |  | 
 
 
 
 
 
 
 
 
 
 
 | 4 | < | XmlToolsInterface::XmlToolsInterface(Logger *myLogger, QWidget *parent) : | 
 
 
 
 
 
 
 
 
 | 4 | > | XmlToolsInterface::XmlToolsInterface(QWidget *parent) : | 
 
 
 
 
 
 
 
 
 
 
 | 5 |  | QMainWindow(parent), | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 6 |  | ui(new Ui::XmlToolsInterface), | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 7 |  | xmlProcessor() | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 8 |  | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 9 |  | ui->setupUi(this); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 10 |  | this->setAttribute(Qt::WA_DeleteOnClose, true); //destroy itself once finished. | 
 
 
 
 
 
 
 
 
 
 
 | 11 | < | this->myLogger = myLogger; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 12 | < | this->xmlProcessor = new XmlProcessor(UtilVago::getAppPath(), this->myLogger, &this->listToProccess); | 
 
 
 
 
 
 
 
 
 | 11 | > | this->xmlProcessor = new XmlProcessor(UtilVago::getAppPath(), &this->listToProccess); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 12 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 13 |  | // setup the correct input options for the current selection | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 14 |  | on_rbFilterRelativeElements_clicked(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 160 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 161 |  | if(oldFile.exists()){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 162 |  | if(!oldFile.remove()){ | 
 
 
 
 
 
 
 
 
 
 
 | 163 | < | UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 165 | < | "Couldn't remove old temporary file to preview XML patch! Existing file:\n" | 
 
 
 
 
 
 
 
 
 | 163 | > | UtilVago::showAndLogErrorPopUpLogButton("Couldn't remove old temporary file to preview XML patch! Existing file:\n" | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 164 |  | + previewFileLocation | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 165 |  | ); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 166 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 167 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 168 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 169 |  | if(!QFile::copy(currentFileLocation, previewFileLocation)){ | 
 
 
 
 
 
 
 
 
 
 
 | 170 | < | UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 173 | < | "Couldn't create temporary file to preview the XML patch!\nFrom: " + | 
 
 
 
 
 
 
 
 
 | 170 | > | UtilVago::showAndLogErrorPopUpLogButton("Couldn't create temporary file to preview the XML patch!\nFrom: " + | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 171 |  | currentFileLocation + | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 172 |  | "\nTo: " + previewFileLocation | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 173 |  | ); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 200 |  | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 201 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 202 |  | if(ui->leInputInputFiles->text().trimmed().isEmpty()){ | 
 
 
 
 
 
 
 
 
 
 
 | 203 | < | Util::showErrorPopUp("You must provide an Input File!"); | 
 
 
 
 
 
 
 
 
 | 203 | > | Util::Dialogs::showError("You must provide an Input File!"); | 
 
 
 
 
 
 
 
 
 
 
 | 204 |  | return false; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 205 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 206 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 207 |  | if(ui->rbFilterRelativeElements->isChecked() && ui->leFilterElement->text().trimmed().isEmpty()){ | 
 
 
 
 
 
 
 
 
 
 
 | 208 | < | Util::showErrorPopUp("With Relative Elements checked you must provide a Element Name!"); | 
 
 
 
 
 
 
 
 
 | 208 | > | Util::Dialogs::showError("With Relative Elements checked you must provide a Element Name!"); | 
 
 
 
 
 
 
 
 
 
 
 | 209 |  | return false; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 210 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 211 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 212 |  | if(ui->cbFilterParentElement->isChecked() && ui->leFilterParentElement->text().trimmed().isEmpty()){ | 
 
 
 
 
 
 
 
 
 
 
 | 213 | < | Util::showErrorPopUp("Parent Element is checked but none was provided!"); | 
 
 
 
 
 
 
 
 
 | 213 | > | Util::Dialogs::showError("Parent Element is checked but none was provided!"); | 
 
 
 
 
 
 
 
 
 
 
 | 214 |  | return false; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 215 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 216 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 217 |  | if(ui->cbFilterAttributeName->isChecked()){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 218 |  | if(ui->leFilterAttributeName->text().trimmed().isEmpty()) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 219 |  | { | 
 
 
 
 
 
 
 
 
 
 
 | 220 | < | Util::showErrorPopUp("Attribute Name is checked but none was provided!"); | 
 
 
 
 
 
 
 
 
 | 220 | > | Util::Dialogs::showError("Attribute Name is checked but none was provided!"); | 
 
 
 
 
 
 
 
 
 
 
 | 221 |  | return false; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 222 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 223 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 224 |  | if(ui->leFilterAttributeValue->text().trimmed().isEmpty()) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 225 |  | { | 
 
 
 
 
 
 
 
 
 
 
 | 226 | < | Util::showErrorPopUp("With Attribute Name checked you must provide a Attribute Value!"); | 
 
 
 
 
 
 
 
 
 | 226 | > | Util::Dialogs::showError("With Attribute Name checked you must provide a Attribute Value!"); | 
 
 
 
 
 
 
 
 
 
 
 | 227 |  | return false; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 228 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 229 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 230 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 231 |  | if(ui->rbFilterXPathExpression->isChecked() && ui->leFilterXPathExpression->text().trimmed().isEmpty()) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 232 |  | { | 
 
 
 
 
 
 
 
 
 
 
 | 233 | < | Util::showErrorPopUp("X-Path Expression is checked but none was provided!"); | 
 
 
 
 
 
 
 
 
 | 233 | > | Util::Dialogs::showError("X-Path Expression is checked but none was provided!"); | 
 
 
 
 
 
 
 
 
 
 
 | 234 |  | return false; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 235 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 236 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 237 |  | if(ui->cbXmlToolsOperation->currentText() == "Add Values" && ui->leInputNewValues->text().isEmpty()){ | 
 
 
 
 
 
 
 
 
 
 
 | 238 | < | Util::showErrorPopUp(R"|(With "Add Values" operation selected you must provide the "New Value(s)" to be added.)|"); | 
 
 
 
 
 
 
 
 
 | 238 | > | Util::Dialogs::showError(R"|(With "Add Values" operation selected you must provide the "New Value(s)" to be added.)|"); | 
 
 
 
 
 
 
 
 
 
 
 | 239 |  | return false; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 240 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 241 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 242 |  | if(ui->cbXmlToolsOperation->currentText() == "Remove Values" && ui->leInputCurrentValues->text().isEmpty()){ | 
 
 
 
 
 
 
 
 
 
 
 | 243 | < | Util::showErrorPopUp(R"|(With "Remove Value" operation selected you must provide the "Current Value(s)" to be removed.)|"); | 
 
 
 
 
 
 
 
 
 | 243 | > | Util::Dialogs::showError(R"|(With "Remove Value" operation selected you must provide the "Current Value(s)" to be removed.)|"); | 
 
 
 
 
 
 
 
 
 
 
 | 244 |  | return false; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 245 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 246 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 265 |  | else if(numErrors == 0){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 266 |  | // if there's a preview in progress don't display the message below | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 267 |  | if(!this->previewInProgress){ | 
 
 
 
 
 
 
 
 
 
 
 | 268 | < | Util::showPopUp("File(s) processed with sucess!"); | 
 
 
 
 
 
 
 
 
 | 268 | > | Util::Dialogs::showInfo("File(s) processed with sucess!"); | 
 
 
 
 
 
 
 
 
 
 
 | 269 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 270 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 271 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 301 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 302 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 303 |  | if(ui->leInputNewValues->isEnabled()){ | 
 
 
 
 
 
 
 
 
 
 
 | 304 | < | currCommand += "--new-val " + Util::insertQuotes(ui->leInputNewValues->text()) + " "; | 
 
 
 
 
 
 
 
 
 | 304 | > | currCommand += "--new-val " + Util::String::insertQuotes(ui->leInputNewValues->text()) + " "; | 
 
 
 
 
 
 
 
 
 
 
 | 305 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 306 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 307 |  | if(ui->leInputCurrentValues->isEnabled()){ | 
 
 
 
 
 
 
 
 
 
 
 | 308 | < | currCommand += "--current-val " + Util::insertQuotes(ui->leInputCurrentValues->text()) + " "; | 
 
 
 
 
 
 
 
 
 | 308 | > | currCommand += "--current-val " + Util::String::insertQuotes(ui->leInputCurrentValues->text()) + " "; | 
 
 
 
 
 
 
 
 
 
 
 | 309 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 310 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 311 |  | if(ui->leInputPositions->isEnabled() && !ui->leInputPositions->text().trimmed().isEmpty()){ | 
 
 
 
 
 
 
 
 
 
 
 | 312 | < | currCommand += "--positions " + Util::insertQuotes(ui->leInputPositions->text()) + " "; | 
 
 
 
 
 
 
 
 
 | 312 | > | currCommand += "--positions " + Util::String::insertQuotes(ui->leInputPositions->text()) + " "; | 
 
 
 
 
 
 
 
 
 
 
 | 313 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 314 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 315 |  | if(ui->leInputDiffOldNewValue->isEnabled()){ | 
 
 
 
 
 
 
 
 
 
 
 | 316 | < | currCommand += "--diff-old-new-val " + Util::insertQuotes(ui->leInputDiffOldNewValue->text()) + " "; | 
 
 
 
 
 
 
 
 
 | 316 | > | currCommand += "--diff-old-new-val " + Util::String::insertQuotes(ui->leInputDiffOldNewValue->text()) + " "; | 
 
 
 
 
 
 
 
 
 
 
 | 317 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 318 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 319 |  | if(ui->rbFilterRelativeElements->isChecked()){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 320 |  | if(ui->leFilterElement->isEnabled()){ | 
 
 
 
 
 
 
 
 
 
 
 | 321 | < | currCommand += "--element-name " + Util::insertQuotes(ui->leFilterElement->text()) + " "; | 
 
 
 
 
 
 
 
 
 | 321 | > | currCommand += "--element-name " + Util::String::insertQuotes(ui->leFilterElement->text()) + " "; | 
 
 
 
 
 
 
 
 
 
 
 | 322 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 323 |  | if(ui->leFilterParentElement->isEnabled()){ | 
 
 
 
 
 
 
 
 
 
 
 | 324 | < | currCommand += "--parent-element-name " + Util::insertQuotes(ui->leFilterParentElement->text()) + " "; | 
 
 
 
 
 
 
 
 
 | 324 | > | currCommand += "--parent-element-name " + Util::String::insertQuotes(ui->leFilterParentElement->text()) + " "; | 
 
 
 
 
 
 
 
 
 
 
 | 325 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 326 |  | if(ui->leFilterAttributeName->isEnabled()){ | 
 
 
 
 
 
 
 
 
 
 
 | 327 | < | currCommand += "--attribute-name " + Util::insertQuotes(ui->leFilterAttributeName->text()) + " "; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 328 | < | currCommand += "--attribute-value " + Util::insertQuotes(ui->leFilterAttributeValue->text()) + " "; | 
 
 
 
 
 
 
 
 
 | 327 | > | currCommand += "--attribute-name " + Util::String::insertQuotes(ui->leFilterAttributeName->text()) + " "; | 
 
 
 
 
 | 328 | > | currCommand += "--attribute-value " + Util::String::insertQuotes(ui->leFilterAttributeValue->text()) + " "; | 
 
 
 
 
 
 
 
 
 
 
 | 329 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 330 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 331 |  | else{ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 332 |  | if(ui->leFilterXPathExpression->isEnabled()){ | 
 
 
 
 
 
 
 
 
 
 
 | 333 | < | currCommand += "--xpath-expression " + Util::insertQuotes(ui->leFilterXPathExpression->text()) + " "; | 
 
 
 
 
 
 
 
 
 | 333 | > | currCommand += "--xpath-expression " + Util::String::insertQuotes(ui->leFilterXPathExpression->text()) + " "; | 
 
 
 
 
 
 
 
 
 
 
 | 334 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 335 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 336 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 337 |  | if(alternativeFileLocation.isEmpty()){ | 
 
 
 
 
 
 
 
 
 
 
 | 338 | < | currCommand += "--files " + Util::insertQuotes(ui->leInputInputFiles->text()); | 
 
 
 
 
 
 
 
 
 | 338 | > | currCommand += "--files " + Util::String::insertQuotes(ui->leInputInputFiles->text()); | 
 
 
 
 
 
 
 
 
 
 
 | 339 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 340 |  | else{ | 
 
 
 
 
 
 
 
 
 
 
 | 341 | < | currCommand += "--files " + Util::insertQuotes(alternativeFileLocation); | 
 
 
 
 
 
 
 
 
 | 341 | > | currCommand += "--files " + Util::String::insertQuotes(alternativeFileLocation); | 
 
 
 
 
 
 
 
 
 
 
 | 342 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 343 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 344 |  |  |