void DownloadRemoteFileDialog::accept()
{
    defaultDB = getDBId();
    
    QString resourceId = getResourceId();
    if( resourceId.isEmpty() ) {
        QMessageBox::critical(this, L10N::errorTitle(), tr("Resource id is empty!"));
        ui->idLineEdit->setFocus();
        return;
    }
    QString fullPath = getFullpath();
    if( ui->saveFilenameLineEdit->text().isEmpty() ) {
        QMessageBox::critical(this, L10N::errorTitle(), tr("No folder selected for saving file!"));
        ui->saveFilenameLineEdit->setFocus();
        return;
    }

    U2OpStatus2Log os;
    fullPath = GUrlUtils::prepareDirLocation(fullPath, os);

    if (fullPath.isEmpty()) {
        QMessageBox::critical(this, L10N::errorTitle(), os.getError());
        ui->saveFilenameLineEdit->setFocus();
        return;
    }        
    
    QString dbId = getDBId();
    QStringList resIds = resourceId.split(QRegExp("[\\s,;]+"));
    QList<Task*> tasks;

    QString fileFormat;
    if (ui->formatBox->count() > 0) {
        fileFormat = ui->formatBox->currentText();
    }

    QVariantMap hints;
    hints.insert(FORCE_DOWNLOAD_SEQUENCE_HINT, ui->chbForceDownloadSequence->isVisible() && ui->chbForceDownloadSequence->isChecked());

    int taskCount = 0;
    bool addToProject = ui->chbAddToProjectCheck->isChecked();
    if (addToProject && resIds.size() >= 100) {
        QString message =  tr("There are more than 100 files found for download.\nAre you sure you want to open all of them?");
        int button = QMessageBox::question(QApplication::activeWindow(), tr("Warning"), message, 
                                           tr("Cancel"), tr("Open anyway"), tr("Don't open"));
        if (button == 0) {
            return; // return to dialog
        } else if (button == 2) {
            addToProject = false;
        }
    }
    bool hasLoadOnlyDocuments = false;
    foreach (const QString &resId, resIds) {
        LoadRemoteDocumentMode mode = LoadRemoteDocumentMode_LoadOnly;
        if (addToProject) {
            mode = taskCount < OpenViewTask::MAX_DOC_NUMBER_TO_OPEN_VIEWS ? LoadRemoteDocumentMode_OpenView : LoadRemoteDocumentMode_AddToProject;
        }
        hasLoadOnlyDocuments = hasLoadOnlyDocuments || mode == LoadRemoteDocumentMode_LoadOnly;
        tasks.append(new LoadRemoteDocumentAndAddToProjectTask(resId, dbId, fullPath, fileFormat, hints, mode));
        taskCount++;
    }
void ExportProjectDialogController::accept(){
    QString dirPath = exportFolderEdit->text();
    projectFile = fixProjectFile(projectFileEdit->text());
    
    U2OpStatus2Log os;
    exportDir = GUrlUtils::prepareDirLocation(dirPath, os);
    if (exportDir.isEmpty()) {
        assert(os.hasError());
        QMessageBox::critical(this, this->windowTitle(), os.getError());
        return;
    }
	QDialog::accept();
}
Task *ConservationPlotWorker::tick() {
    U2OpStatus2Log os;

    while (inChannel->hasMessage()) {

        Message m = getMessageAndSetupScriptValues(inChannel);
        QVariantMap data = m.getData().toMap();

        if (!data.contains(ANNOT_SLOT_ID)) {
            os.setError("Annotations slot is empty");
            return new FailTask(os.getError());
        }

        plotData = StorageUtils::getAnnotationTableHandlers(data[ANNOT_SLOT_ID]);
    }

    if (!inChannel->isEnded()) {
        return NULL;
    }

    ConservationPlotSettings settings = createConservationPlotSettings(os);
    if (os.hasError()) {
        return new FailTask(os.getError());
    }

    ConservationPlotTask* t = new ConservationPlotTask(settings, context->getDataStorage(), plotData);
    t->addListeners(createLogListeners());
    connect(t, SIGNAL(si_stateChanged()), SLOT(sl_taskFinished()));
    return t;

    if (inChannel->isEnded()) {
        setDone();
    }

    return NULL;
}
示例#4
0
Task* CAP3Worker::tick() {
    U2OpStatus2Log os;

    if (input->hasMessage()) {
        Message inputMessage = getMessageAndSetupScriptValues(input);
        SAFE_POINT(!inputMessage.isEmpty(), "NULL message!", NULL);

        QVariantMap data = inputMessage.getData().toMap();
        if (!data.contains(IN_URL_SLOT_ID)) {
            os.setError("CAP3 input slot is empty!");
            return new FailTask(os.getError());
        }

        QString dataset = data[BaseSlots::DATASET_SLOT().getId()].toString();
        bool runCapForPreviousDataset = false;

        if (dataset != currentDatasetName) {
            if (!currentDatasetName.isEmpty()) {
                runCapForPreviousDataset = true;
            }

            settings.inputFiles = inputSeqUrls;
            inputSeqUrls.clear();
            currentDatasetName = dataset;
        }

        inputSeqUrls << data.value(IN_URL_SLOT_ID).value<QString>();

        if (runCapForPreviousDataset) {
            return runCap3();
        }

        settings.inputFiles = inputSeqUrls;
    }
    else if (input->isEnded()) {
        if (!settings.inputFiles.isEmpty()) {
            return runCap3();
        }
        else {
            datasetNumber = 0;
            setDone();
        }
    }

    return NULL;
}
void CreateDocumentFromTextDialogController::accept() {
    QString validationError = w->validate();
    if(!validationError.isEmpty()){
        QMessageBox::critical(this, this->windowTitle(), validationError);
        return;
    }

    const QString url = saveController->getSaveFileName();
    QFileInfo fi(url);

    if(fi.baseName().isEmpty()){
        QMessageBox::critical(this, this->windowTitle(), tr("Filename is empty"));
        return;
    }

    if(url.isEmpty()){
        QMessageBox::critical(this, this->windowTitle(), tr("No path specified"));
        return;
    }

    U2OpStatus2Log os;
    QString fullPath = GUrlUtils::prepareFileLocation(url, os);

    if (fullPath.isEmpty()) {
        QMessageBox::critical(this, L10N::errorTitle(), os.getError());
        return;
    }
    
    if(ui->nameEdit->text().isEmpty()) {
        QMessageBox::critical(this, this->windowTitle(), tr("Sequence name is empty"));
        return;
    }    

    CHECK_OP(os, );

    Task *task = new CreateSequenceFromTextAndOpenViewTask(prepareSequences(), saveController->getFormatIdToSave(), GUrl(fullPath), ui->saveImmediatelyBox->isChecked());
    AppContext::getTaskScheduler()->registerTopLevelTask(task);
    QDialog::accept();
}
示例#6
0
void ADVClipboard::copySequenceSelection(bool complement, bool amino) {
    ADVSequenceObjectContext* seqCtx = getSequenceContext();
    if (seqCtx == NULL) {
        QMessageBox::critical(QApplication::activeWindow(), L10N::errorTitle(), "No sequence selected!");
        return;
    }

    QString res;
    QVector<U2Region> regions = seqCtx->getSequenceSelection()->getSelectedRegions();
#ifdef UGENE_X86
    int totalLen = 0;
    foreach (const U2Region& r, regions) {
        totalLen += r.length;
    }
    if (totalLen > MAX_COPY_SIZE_FOR_X86) {
        QMessageBox::critical(QApplication::activeWindow(), L10N::errorTitle(), COPY_FAILED_MESSAGE);
        return;
    }
 #endif

    if (!regions.isEmpty()) {
        U2SequenceObject* seqObj = seqCtx->getSequenceObject();
        DNATranslation* complTT = complement ? seqCtx->getComplementTT() : NULL;
        DNATranslation* aminoTT = amino ? seqCtx->getAminoTT() : NULL;
        U2OpStatus2Log os;
        QList<QByteArray> seqParts = U2SequenceUtils::extractRegions(seqObj->getSequenceRef(), regions, complTT, aminoTT, false, os);
        if (os.hasError()) {
            QMessageBox::critical(QApplication::activeWindow(), L10N::errorTitle(), tr("An error occurred during getting sequence data: %1").arg(os.getError()));
            return;
        }
        if (seqParts.size() == 1) {
            putIntoClipboard(seqParts.first());
            return;
        }
        res = U1SequenceUtils::joinRegions(seqParts);
    }
    putIntoClipboard(res);
}
bool CreatePhyTreeDialogController::checkFileName() {
    const QString fileName = saveController->getSaveFileName();
    if (fileName.isEmpty()) {
        QMessageBox::warning(this, tr("Warning"), tr("Please, input the file name."));
        ui->fileNameEdit->setFocus();
        return false;
    }
    settings.fileUrl = fileName;

    U2OpStatus2Log os;
    GUrlUtils::validateLocalFileUrl(GUrl(fileName), os);
    if (os.hasError()) {
        QMessageBox::warning(this, tr("Error"), tr("Please, change the output file.") + "\n" + os.getError());
        ui->fileNameEdit->setFocus(Qt::MouseFocusReason);
        return false;
    }

    return true;
}