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_WORKFLOW_FORMAT_H_ 23 #define _U2_WORKFLOW_FORMAT_H_ 24 25 #include <QStringList> 26 27 #include <U2Core/DocumentModel.h> 28 #include <U2Core/GObject.h> 29 30 #include <U2Formats/TextDocumentFormat.h> 31 32 #include <U2Gui/ObjectViewModel.h> 33 #include <U2Gui/ObjectViewTasks.h> 34 35 #include "WorkflowDesignerPlugin.h" 36 37 class QDomDocument; 38 39 namespace U2 { 40 41 class WorkflowView; 42 43 class WorkflowDocFormat : public TextDocumentFormatDeprecated { 44 Q_OBJECT 45 public: 46 WorkflowDocFormat(QObject *p); 47 48 static const DocumentFormatId FORMAT_ID; 49 50 virtual Document *createNewLoadedDocument(IOAdapterFactory *io, const GUrl &url, U2OpStatus &os, const QVariantMap &fs = QVariantMap()); 51 52 virtual void storeDocument(Document *d, IOAdapter *io, U2OpStatus &os); 53 54 protected: 55 virtual FormatCheckResult checkRawTextData(const QByteArray &rawData, const GUrl &url = GUrl()) const; 56 57 virtual Document *loadTextDocument(IOAdapter *io, const U2DbiRef &targetDb, const QVariantMap &hints, U2OpStatus &os); 58 }; 59 60 class WorkflowGObject : public GObject { 61 Q_OBJECT 62 public: 63 static const GObjectType TYPE; 64 WorkflowGObject(const QString &objectName, const QString &s, const QVariantMap &map = QVariantMap()) GObject(TYPE,objectName)65 : GObject(TYPE, objectName), serializedScene(s), view(nullptr) { 66 Q_UNUSED(map); 67 } 68 getSceneRawData()69 QString getSceneRawData() const { 70 return serializedScene; 71 } 72 void setSceneRawData(const QString &data); 73 virtual GObject *clone(const U2DbiRef &dbiRef, U2OpStatus &os, const QVariantMap &hints = QVariantMap()) const; 74 virtual bool isTreeItemModified() const; 75 void setView(WorkflowView *view); getView()76 WorkflowView *getView() const { 77 return view; 78 } 79 80 protected: 81 QString serializedScene; 82 WorkflowView *view; 83 }; 84 85 class WorkflowViewFactory : public GObjectViewFactory { 86 Q_OBJECT 87 public: 88 static const GObjectViewFactoryId ID; 89 WorkflowViewFactory(QObject *p = nullptr) 90 : GObjectViewFactory(ID, tr("Workflow Designer"), p) { 91 } 92 93 virtual bool canCreateView(const MultiGSelection &multiSelection); 94 virtual Task *createViewTask(const MultiGSelection &multiSelection, bool single = false); 95 }; 96 97 class OpenWorkflowViewTask : public ObjectViewTask { 98 Q_OBJECT 99 public: 100 OpenWorkflowViewTask(Document *doc); 101 virtual void open(); 102 }; 103 104 } // namespace U2 105 106 #endif 107