| 1 | /* |
| 2 | * File: Dasdcat.cpp |
| 3 | * |
| 4 | * Author: Jacob Dekel |
| 5 | * Created on: Aug 7, 2009 |
| 6 | * |
| 7 | * Copyright (c) 2009-2013 Jacob Dekel |
| 8 | * $Id$ |
| 9 | * |
| 10 | * This program is free software: you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation, either version 3 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include "Dasdcat.h" |
| 26 | #include "HerculesStudio.h" |
| 27 | #include "UtilityRunner.h" |
| 28 | #include "Preferences.h" |
| 29 | |
| 30 | #include <QFileDialog> |
| 31 | #include <QMessageBox> |
| 32 | |
| 33 | #include <csignal> |
| 34 | |
| 35 | |
| 36 | Dasdcat::Dasdcat(QWidget *parent) |
| 37 | : GenericUtility("dasdcat",parent) |
| 38 | { |
| 39 | ui.setupUi(this); |
| 40 | ui.listRadioButton->setChecked(true); |
| 41 | ui.memberName->setDisabled(true); |
| 42 | |
| 43 | connect(ui.runButton, SIGNAL(clicked()), this, SLOT(runClicked())); |
| 44 | connect(ui.exitButton, SIGNAL(clicked()), this, SLOT(exitClicked())); |
| 45 | connect(ui.browseFileButton, SIGNAL(clicked()), this, SLOT(browseFileClicked())); |
| 46 | connect(ui.browseSfButton, SIGNAL(clicked()), this, SLOT(browseSfClicked())); |
| 47 | connect(ui.specificRadioButton, SIGNAL(toggled(bool)), this, SLOT(specificToggeled(bool))); |
| 48 | } |
| 49 | |
| 50 | Dasdcat::~Dasdcat() |
| 51 | { |
| 52 | |
| 53 | } |
| 54 | |
| 55 | void Dasdcat::runClicked() |
| 56 | { |
| 57 | if (!runOrStopClicked()) |
| 58 | { |
| 59 | ui.runButton->setText("Run"); |
| 60 | return; |
| 61 | } |
| 62 | |
| 63 | if (ui.filename->text().isEmpty()) |
| 64 | { |
| 65 | QMessageBox::warning(this, "dasdcat", "Please specify ckd file to process", |
| 66 | QMessageBox::Ok, QMessageBox::NoButton); |
| 67 | return; |
| 68 | } |
| 69 | if (ui.dsname->text().isEmpty()) |
| 70 | { |
| 71 | QMessageBox::warning(this, "dasdcat", "Please specify PDS name", |
| 72 | QMessageBox::Ok, QMessageBox::NoButton); |
| 73 | return; |
| 74 | } |
| 75 | std::vector<std::string> parameters; |
| 76 | |
| 77 | parameters.push_back("-i"); |
| 78 | parameters.push_back(ui.filename->text().toStdString()); |
| 79 | |
| 80 | if (!ui.shadowFile->text().isEmpty()) |
| 81 | { |
| 82 | std::string sf = "sf="; |
| 83 | sf += ui.shadowFile->text().toStdString(); |
| 84 | parameters.push_back(sf); |
| 85 | } |
| 86 | std::string dsnameSpec = ui.dsname->text().toStdString(); |
| 87 | dsnameSpec += "/"; |
| 88 | if (ui.listRadioButton->isChecked()) |
| 89 | { |
| 90 | dsnameSpec+= "?"; |
| 91 | } |
| 92 | else if (ui.specificRadioButton->isChecked()) |
| 93 | { |
| 94 | if (ui.memberName->text().isEmpty()) |
| 95 | { |
| 96 | QMessageBox::warning(this, "dasdcat", "Member name must be provided when selecting\n'show specific member content'", |
| 97 | QMessageBox::Ok, QMessageBox::NoButton); |
| 98 | return; |
| 99 | } |
| 100 | dsnameSpec += ui.memberName->text().toStdString(); |
| 101 | dsnameSpec += ":c"; // make it readable on log |
| 102 | } |
| 103 | else if (ui.allRadioButton) |
| 104 | { |
| 105 | dsnameSpec += "*:c"; |
| 106 | } |
| 107 | parameters.push_back(dsnameSpec); |
| 108 | std::string command = "dasdcat"; |
| 109 | |
| 110 | execute(command, Preferences::getInstance().hercDir(), parameters); |
| 111 | ui.runButton->setText("Stop"); |
| 112 | } |
| 113 | |
| 114 | |
| 115 | void Dasdcat::exitClicked() |
| 116 | { |
| 117 | deleteLater(); |
| 118 | } |
| 119 | |
| 120 | void Dasdcat::browseFileClicked() |
| 121 | { |
| 122 | QString s = QFileDialog::getOpenFileName(this,"Browse for disk to update",ui.filename->text()); |
| 123 | ui.filename->setText(s); |
| 124 | } |
| 125 | |
| 126 | void Dasdcat::browseSfClicked() |
| 127 | { |
| 128 | QString s = QFileDialog::getOpenFileName(this,"Browse for shadow file",ui.shadowFile->text()); |
| 129 | ui.shadowFile->setText(s); |
| 130 | } |
| 131 | |
| 132 | void Dasdcat::specificToggeled(bool checked) |
| 133 | { |
| 134 | ui.memberName->setEnabled(checked); |
| 135 | } |
| 136 | |
| 137 | void Dasdcat::finishedSlot() |
| 138 | { |
| 139 | } |