1 /** 2 * UGENE - Integrated Bioinformatics Tools. 3 * Copyright (C) 2008-2021 UniPro <ugene@unipro.ru> 4 * http://ugene.net 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 * MA 02110-1301, USA. 20 */ 21 22 #ifndef _U2_GT_UTILS_WORKFLOW_DESIGNER_H_ 23 #define _U2_GT_UTILS_WORKFLOW_DESIGNER_H_ 24 25 #include <GTGlobals.h> 26 27 #include <QGraphicsItem> 28 #include <QTreeWidget> 29 30 class QTableView; 31 class QTableWidget; 32 33 namespace U2 { 34 using namespace HI; 35 class WorkflowProcessItem; 36 class WorkflowPortItem; 37 class WorkflowBusItem; 38 39 class GTUtilsWorkflowDesigner { 40 public: 41 enum tab { algorithms, 42 samples }; 43 enum valueType { 44 spinValue, 45 doubleSpinValue, 46 comboValue, 47 textValue, 48 ComboChecks, 49 comboWithFileSelector, 50 lineEditWithFileSelector, 51 customDialogSelector 52 }; 53 54 // returns algorithms or samples 55 static tab currentTab(HI::GUITestOpStatus &os); 56 57 // activates the tab t 58 static void setCurrentTab(HI::GUITestOpStatus &os, tab t); 59 60 // opens WorkflowDesigner 61 static void openWorkflowDesigner(HI::GUITestOpStatus &os); 62 63 /** Returns active WD window or fails if no active WD window is found. */ 64 static QWidget *getActiveWorkflowDesignerWindow(HI::GUITestOpStatus &os); 65 66 /** Checks that WD window is active. */ 67 static void checkWorkflowDesignerWindowIsActive(HI::GUITestOpStatus &os); 68 69 static void loadWorkflow(HI::GUITestOpStatus &os, const QString &fileUrl); 70 static void saveWorkflow(HI::GUITestOpStatus &os); 71 static void saveWorkflowAs(HI::GUITestOpStatus &os, const QString &fileUrl, const QString &workflowName); 72 73 static void validateWorkflow(HI::GUITestOpStatus &os); 74 static void runWorkflow(HI::GUITestOpStatus &os); 75 static void stopWorkflow(HI::GUITestOpStatus &os); 76 static void returnToWorkflow(HI::GUITestOpStatus &os); 77 78 // returns item from samples or algorithms tab 79 static QTreeWidgetItem *findTreeItem(HI::GUITestOpStatus &os, const QString &itemName, tab t, bool exactMatch = false, bool failIfNULL = true); 80 81 // returns item from samples or algorithms tab 82 static QList<QTreeWidgetItem *> getVisibleSamples(HI::GUITestOpStatus &os); 83 84 // expands samples/Elements tabwidget if collapsed 85 static void expandTabs(HI::GUITestOpStatus &os, QWidget *parentWidget = nullptr); 86 87 static void findByNameFilter(HI::GUITestOpStatus &os, const QString &elementName); 88 89 static void cleanNameFilter(HI::GUITestOpStatus &os); 90 91 static void clickOnPalette(HI::GUITestOpStatus &os, const QString &itemName, Qt::MouseButton mouseButton = Qt::LeftButton); 92 93 static QTreeWidgetItem *getPaletteGroup(HI::GUITestOpStatus &os, const QString &groupName); 94 static QList<QTreeWidgetItem *> getPaletteGroups(HI::GUITestOpStatus &os); 95 static QStringList getPaletteGroupNames(HI::GUITestOpStatus &os); 96 static QList<QTreeWidgetItem *> getPaletteGroupEntries(HI::GUITestOpStatus &os, QTreeWidgetItem *groupItem); 97 static QList<QTreeWidgetItem *> getPaletteGroupEntries(HI::GUITestOpStatus &os, const QString &groupName); 98 static QStringList getPaletteGroupEntriesNames(HI::GUITestOpStatus &os, const QString &groupName); 99 100 // add to scene 101 static void addSample(HI::GUITestOpStatus &os, const QString &sampName, QWidget *parentWidget = nullptr); 102 static void addAlgorithm(HI::GUITestOpStatus &os, const QString &algName, bool exactMatch = false, bool useDragAndDrop = false); 103 static WorkflowProcessItem *addElement(HI::GUITestOpStatus &os, const QString &algName, bool exactMatch = false); 104 static WorkflowProcessItem *addElementByUsingNameFilter(HI::GUITestOpStatus &os, const QString &elementName, bool exactMatch = false); 105 106 // returns center of worker on workflow scene in global coordinates 107 static QPoint getItemCenter(HI::GUITestOpStatus &os, const QString &itemName); 108 109 static void removeItem(HI::GUITestOpStatus &os, const QString &itemName); 110 111 static void click(HI::GUITestOpStatus &os, const QString &itemName, QPoint p = QPoint(0, 0), Qt::MouseButton button = Qt::LeftButton); 112 static void click(HI::GUITestOpStatus &os, QGraphicsItem *item, QPoint p = QPoint(0, 0), Qt::MouseButton button = Qt::LeftButton); 113 114 // returs worker placed on workflow scene which contains item name 115 static WorkflowProcessItem *getWorker(HI::GUITestOpStatus &os, const QString &itemName, const GTGlobals::FindOptions &options = GTGlobals::FindOptions()); 116 117 static QString getWorkerText(HI::GUITestOpStatus &os, const QString &itemName, const GTGlobals::FindOptions &options = GTGlobals::FindOptions()); 118 119 static void clickLink(HI::GUITestOpStatus &os, const QString &itemName, Qt::MouseButton button = Qt::LeftButton, int step = 10); 120 121 static bool isWorkerExtended(HI::GUITestOpStatus &os, const QString &itemName); 122 123 // returns WorkflowPortItem of worker which with ID "id" 124 static WorkflowPortItem *getPortById(HI::GUITestOpStatus &os, WorkflowProcessItem *worker, QString id); 125 126 static QList<WorkflowPortItem *> getPorts(HI::GUITestOpStatus &os, WorkflowProcessItem *worker); 127 128 // connects worker "from" with worker "to" 129 static void connect(HI::GUITestOpStatus &os, WorkflowProcessItem *from, WorkflowProcessItem *to); 130 static void disconect(HI::GUITestOpStatus &os, WorkflowProcessItem *from, WorkflowProcessItem *to); 131 132 static QList<WorkflowBusItem *> getAllConnectionArrows(HI::GUITestOpStatus &os); 133 134 static WorkflowBusItem *getConnectionArrow(HI::GUITestOpStatus &os, WorkflowProcessItem *from, WorkflowProcessItem *to); 135 static QGraphicsTextItem *getArrowHint(HI::GUITestOpStatus &os, WorkflowBusItem *arrow); 136 137 // returns all workers placed on workflow scene 138 static QList<WorkflowProcessItem *> getWorkers(HI::GUITestOpStatus &os); 139 140 static QWidget *getDatasetsListWidget(HI::GUITestOpStatus &os); 141 static QWidget *getCurrentDatasetWidget(HI::GUITestOpStatus &os); 142 143 static void createDataset(HI::GUITestOpStatus &os, QString datasetName = ""); 144 145 /** 146 * Sets input file with path "filePath" to the current dataset. 147 * This method should be called after selecting worker which contains dataset on scene. 148 * If datasetWidget is not provided it is looked up the current WD window. 149 */ 150 static void setDatasetInputFile(HI::GUITestOpStatus &os, const QString &filePath, bool pastePath = false, QWidget *datasetWidget = nullptr); 151 152 /** 153 * Adds input files with path "filePaths" to the current dataset. 154 * This method should be called after selecting worker which contains dataset on scene. 155 * If datasetWidget is not provided it is looked up the current WD window. 156 */ 157 158 static void setDatasetInputFiles(HI::GUITestOpStatus &os, const QStringList &filePaths, QWidget *datasetWidget = nullptr); 159 160 static void addInputFile(HI::GUITestOpStatus &os, const QString &elementName, const QString &url); 161 162 /** 163 * Sets input folder with path "filePath" to dataset. 164 * If datasetWidget is not provided it is looked up the current WD window. 165 */ 166 static void setDatasetInputFolder(HI::GUITestOpStatus &os, const QString &filePath, QWidget *datasetWidget = nullptr); 167 168 /** 169 * Adds all folders the to the dataset widget. 170 * If datasetWidget is not provided it is looked up the current WD window. 171 */ 172 static void setDatasetInputFolders(HI::GUITestOpStatus &os, const QStringList &dirPaths, QWidget *datasetWidget = nullptr); 173 174 // sets oneparameter worker parameter 175 static void setParameter(HI::GUITestOpStatus &os, QString parameter, QVariant value, valueType type, GTGlobals::UseMethod method = GTGlobals::UseMouse); 176 static void setTableValue(HI::GUITestOpStatus &os, QString parameter, QVariant value, valueType type, QTableWidget *table, GTGlobals::UseMethod method = GTGlobals::UseMouse); 177 static QString getCellValue(HI::GUITestOpStatus &os, QString parameter, QTableWidget *table); 178 static void setCellValue(HI::GUITestOpStatus &os, QWidget *parent, QVariant value, valueType type, GTGlobals::UseMethod method); 179 static QStringList getAllParameters(HI::GUITestOpStatus &os); 180 static QStringList getComboBoxParameterValues(HI::GUITestOpStatus &os, QString parameter); 181 static QList<QPair<QString, bool>> getCheckableComboboxValuesFromInputPortTable(HI::GUITestOpStatus &os, int tableIndex, const QString &slotName); 182 183 static QTableWidget *getInputPortsTable(HI::GUITestOpStatus &os, int index); 184 static QTableWidget *getOutputPortsTable(HI::GUITestOpStatus &os, int index); 185 186 static void scrollInputPortsWidgetToTableRow(HI::GUITestOpStatus &os, int tableIndex, const QString &slotName); 187 188 // gets oneparameter worker parameter 189 static QString getParameter(HI::GUITestOpStatus &os, QString parameter, bool exactMatch = false); 190 static bool isParameterEnabled(HI::GUITestOpStatus &os, QString parameter); 191 static bool isParameterRequired(HI::GUITestOpStatus &os, const QString ¶meter); 192 static bool isParameterVisible(HI::GUITestOpStatus &os, const QString ¶meter); 193 static void clickParameter(HI::GUITestOpStatus &os, const QString ¶meter); 194 static QTableView *getParametersTable(HI::GUITestOpStatus &os); 195 196 static void setParameterScripting(HI::GUITestOpStatus &os, QString parameter, QString scriptMode, bool exactMatch = false); 197 198 // returns number of items in error list which contain "error" 199 static int checkErrorList(HI::GUITestOpStatus &os, QString error); 200 static QStringList getErrors(HI::GUITestOpStatus &os); 201 202 static int getItemLeft(HI::GUITestOpStatus &os, const QString &itemName); 203 static int getItemRight(HI::GUITestOpStatus &os, const QString &itemName); 204 static int getItemTop(HI::GUITestOpStatus &os, const QString &itemName); 205 static int getItemBottom(HI::GUITestOpStatus &os, const QString &itemName); 206 207 // breakpoints 208 static void toggleDebugMode(HI::GUITestOpStatus &os, bool enable = true); 209 static void toggleBreakpointManager(HI::GUITestOpStatus &os); 210 static void setBreakpoint(HI::GUITestOpStatus &os, const QString &itemName); 211 static QStringList getBreakpointList(HI::GUITestOpStatus &os); 212 213 static void removeCmdlineWorkerFromPalette(HI::GUITestOpStatus &os, const QString &workerName); 214 215 static void changeInputPortBoxHeight(HI::GUITestOpStatus &os, int offset); 216 217 // custom elements 218 static void importCmdlineBasedElement(HI::GUITestOpStatus &os, const QString &path); 219 220 private: 221 static void selectAlgorithm(HI::GUITestOpStatus &os, QTreeWidgetItem *algorithm); 222 static void selectSample(HI::GUITestOpStatus &os, QTreeWidgetItem *sample, QWidget *parentWidget = nullptr); 223 static QRect getItemRect(HI::GUITestOpStatus &os, const QString &itemName); 224 static QTreeWidget *getCurrentTabTreeWidget(HI::GUITestOpStatus &os); 225 226 static const int verticalShift; 227 }; 228 229 } // namespace U2 230 Q_DECLARE_METATYPE(QAction *) 231 #endif // _U2_GT_UTILS_WORKFLOW_DESIGNER_H_ 232