Exemplo n.º 1
0
class Exporter():

    def __init__(self):
        self.__export_keyword_model = ExportKeywordModel()

    def runExport(self, values):
        keyword = values["keyword"]
        file_name = self.createExportFileNameMask(keyword, values["selected_case"], values["report_step"], values["path"])

        if self.__export_keyword_model.isFieldKw(keyword):
            self.exportField(keyword, file_name, values["iactive"], values["file_type_key"], values["report_step"], values["state"], values["selected_case"])
        elif self.__export_keyword_model.isGenKw(keyword):
            self.exportGenKw(keyword, file_name, values["iactive"], values["file_type_key"], values["report_step"], values["state"], values["selected_case"])
        elif self.__export_keyword_model.isGenParamKw(keyword):
            self.exportGenData(keyword, file_name, values["iactive"], values["file_type_key"], values["report_step"], values["state"], values["selected_case"])
        elif self.__export_keyword_model.isGenDataKw(keyword):
            self.exportGenData(keyword, file_name, values["iactive"], values["file_type_key"], values["report_step"], values["state"], values["selected_case"])

    def exportField(self, keyword, file_name, iactive, file_type_key, report_step, state, selected_case):
        if file_type_key == "Eclipse GRDECL":
            file_type = EnkfFieldFileFormatEnum.ECL_GRDECL_FILE
        else:
            file_type = EnkfFieldFileFormatEnum.RMS_ROFF_FILE

        result = ExportModel().exportField(keyword, file_name, iactive, file_type, report_step, state, selected_case)
        if not result:
            QMessageBox.warning(self, "Warning",'''Something did not work!''',QMessageBox.Ok);

    def exportGenData(self, keyword, file_name, iactive, file_type_key, report_step, state, selected_case):
        ExportModel().exportGenData(keyword, file_name, iactive, file_type_key, report_step, state, selected_case)

    def exportGenKw(self, keyword, file_name, iactive, file_type_key, report_step, state, selected_case):
        ExportModel().exportGenKw(keyword, file_name, iactive, file_type_key, report_step, state, selected_case)

    def createExportFileNameMask(self, keyword, current_case, report_step, path):
        impl_type = None

        if self.__export_keyword_model.isFieldKw(keyword):
            impl_type = self.__export_keyword_model.getImplementationType(keyword)
        elif self.__export_keyword_model.isGenDataKw(keyword):
            impl_type = "Gen_Data"
        elif self.__export_keyword_model.isGenKw(keyword):
            impl_type = "Gen_Kw"
        elif self.__export_keyword_model.isGenParamKw(keyword):
            impl_type = "Gen_Param"

        path = os.path.join(str(path), str(current_case), str(impl_type), str(keyword))

        if self.__export_keyword_model.isGenDataKw(keyword):
            path = path + "_" + str(report_step)

        if not QDir(path).exists():
            os.makedirs(path)

        return path
Exemplo n.º 2
0
class Exporter():

    def __init__(self):
        self.__export_keyword_model = ExportKeywordModel()

    def runExport(self, values):
        keyword = values["keyword"]
        file_name = self.createExportFileNameMask(keyword, values["selected_case"], values["report_step"], values["path"])

        if self.__export_keyword_model.isFieldKw(keyword):
            self.exportField(keyword, file_name, values["iactive"], values["file_type_key"], values["report_step"], values["selected_case"])
        elif self.__export_keyword_model.isGenKw(keyword):
            self.exportGenKw(keyword, file_name, values["iactive"], values["file_type_key"], values["report_step"], values["selected_case"])
        elif self.__export_keyword_model.isGenParamKw(keyword) or self.__export_keyword_model.isGenDataKw(keyword):
            self.exportGenData(keyword, file_name, values["iactive"], values["file_type_key"], values["report_step"], values["selected_case"])

    def exportField(self, keyword, file_name, iactive, file_type_key, report_step, selected_case):
        if file_type_key == "Eclipse GRDECL":
            file_type = EnkfFieldFileFormatEnum.ECL_GRDECL_FILE
        else:
            file_type = EnkfFieldFileFormatEnum.RMS_ROFF_FILE

        result = ExportModel().exportField(keyword, file_name, iactive, file_type, report_step, selected_case)
        if not result:
            QMessageBox.warning(self, "Warning",'''Something did not work!''', QMessageBox.Ok)

    def exportGenData(self, keyword, file_name, iactive, file_type_key, report_step, selected_case):
        ExportModel().exportGenData(keyword, file_name, iactive, file_type_key, report_step, selected_case)

    def exportGenKw(self, keyword, file_name, iactive, file_type_key, report_step, selected_case):
        ExportModel().exportGenKw(keyword, file_name, iactive, file_type_key, report_step, selected_case)

    def createExportFileNameMask(self, keyword, current_case, report_step, path):
        impl_type = None

        if self.__export_keyword_model.isFieldKw(keyword):
            impl_type = self.__export_keyword_model.getImplementationType(keyword)
        elif self.__export_keyword_model.isGenDataKw(keyword):
            impl_type = "Gen_Data"
        elif self.__export_keyword_model.isGenKw(keyword):
            impl_type = "Gen_Kw"
        elif self.__export_keyword_model.isGenParamKw(keyword):
            impl_type = "Gen_Param"

        path = os.path.join(str(path), str(current_case), str(impl_type), str(keyword))

        if self.__export_keyword_model.isGenDataKw(keyword):
            path = path + "_" + str(report_step)

        if not QDir(path).exists():
            os.makedirs(path)

        return path
Exemplo n.º 3
0
 def __init__(self):
     super(ExportTool, self).__init__("Export Data", "tools/export",
                                      util.resourceIcon("ide/table_export"))
     self.__export_widget = None
     self.__dialog = None
     self.__exporter = None
     self.setEnabled(ExportKeywordModel().hasKeywords())
Exemplo n.º 4
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.setMinimumWidth(500)
        self.setMinimumHeight(200)
        self.__dynamic = False

        self.setWindowTitle("Export data")
        self.activateWindow()

        layout = QFormLayout()
        current_case = CaseSelectorModel().getCurrentChoice()

        self.__case_model = AllCasesModel()
        self.__case_combo = QComboBox()
        self.__case_combo.setSizeAdjustPolicy(
            QComboBox.AdjustToMinimumContentsLength)
        self.__case_combo.setMinimumContentsLength(20)
        self.__case_combo.setModel(self.__case_model)
        self.__case_combo.setCurrentIndex(
            self.__case_model.indexOf(current_case))
        layout.addRow("Select case:", self.__case_combo)

        self.__export_keyword_model = ExportKeywordModel()

        self.__kw_model = self.__export_keyword_model.getKeyWords()
        self.__keywords = QComboBox()
        self.__keywords.addItems(self.__kw_model)
        layout.addRow("Select keyword:", self.__keywords)

        self.__active_realizations_model = ExportRealizationsModel(
            EnsembleSizeModel().getValue())
        self.__active_realizations_field = StringBox(
            self.__active_realizations_model, "Active realizations",
            "config/simulation/active_realizations")
        self.__active_realizations_field.setValidator(RangeStringArgument())
        self.__active_realizations_field.validationChanged.connect(
            self.validateExportDialog)
        layout.addRow(self.__active_realizations_field.getLabel(),
                      self.__active_realizations_field)

        file_name_button = QToolButton()
        file_name_button.setText("Browse")
        file_name_button.clicked.connect(self.selectFileDirectory)

        self.__defaultPath = QDir.currentPath() + "/export"
        self.__file_name = QLineEdit()
        self.__file_name.setEnabled(False)
        self.__file_name.setText(self.__defaultPath)
        self.__file_name.textChanged.connect(self.validateExportDialog)
        self.__file_name.setMinimumWidth(250)

        file_name_layout = QHBoxLayout()
        file_name_layout.addWidget(self.__file_name)
        file_name_layout.addWidget(file_name_button)
        layout.addRow("Select directory to save files to:", file_name_layout)

        self.__gen_kw_file_types = ["Parameter list", "Template based"]
        self.__field_kw_file_types = ["Eclipse GRDECL", "RMS roff"]
        self.__gen_data_file_types = ["Gen data"]

        self.__file_type_model = self.__field_kw_file_types
        self.__file_type_combo = QComboBox()
        self.__file_type_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
        self.__file_type_combo.addItems(self.__file_type_model)
        layout.addRow("Select file format:", self.__file_type_combo)

        self.__report_step = QLineEdit()
        layout.addRow("Report step:", self.__report_step)

        self.__gen_data_report_step_model = []
        self.__gen_data_report_step = QComboBox()
        layout.addRow("Report step:", self.__gen_data_report_step)

        self.setLayout(layout)
        self.__keywords.currentIndexChanged.connect(self.keywordSelected)
        self.keywordSelected()
Exemplo n.º 5
0
class ExportPanel(QWidget):

    updateExportButton = pyqtSignal(str, bool)
    runExport = pyqtSignal(dict)

    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.setMinimumWidth(500)
        self.setMinimumHeight(200)
        self.__dynamic = False

        self.setWindowTitle("Export data")
        self.activateWindow()

        layout = QFormLayout()
        current_case = CaseSelectorModel().getCurrentChoice()

        self.__case_model = AllCasesModel()
        self.__case_combo = QComboBox()
        self.__case_combo.setSizeAdjustPolicy(
            QComboBox.AdjustToMinimumContentsLength)
        self.__case_combo.setMinimumContentsLength(20)
        self.__case_combo.setModel(self.__case_model)
        self.__case_combo.setCurrentIndex(
            self.__case_model.indexOf(current_case))
        layout.addRow("Select case:", self.__case_combo)

        self.__export_keyword_model = ExportKeywordModel()

        self.__kw_model = self.__export_keyword_model.getKeyWords()
        self.__keywords = QComboBox()
        self.__keywords.addItems(self.__kw_model)
        layout.addRow("Select keyword:", self.__keywords)

        self.__active_realizations_model = ExportRealizationsModel(
            EnsembleSizeModel().getValue())
        self.__active_realizations_field = StringBox(
            self.__active_realizations_model, "Active realizations",
            "config/simulation/active_realizations")
        self.__active_realizations_field.setValidator(RangeStringArgument())
        self.__active_realizations_field.validationChanged.connect(
            self.validateExportDialog)
        layout.addRow(self.__active_realizations_field.getLabel(),
                      self.__active_realizations_field)

        file_name_button = QToolButton()
        file_name_button.setText("Browse")
        file_name_button.clicked.connect(self.selectFileDirectory)

        self.__defaultPath = QDir.currentPath() + "/export"
        self.__file_name = QLineEdit()
        self.__file_name.setEnabled(False)
        self.__file_name.setText(self.__defaultPath)
        self.__file_name.textChanged.connect(self.validateExportDialog)
        self.__file_name.setMinimumWidth(250)

        file_name_layout = QHBoxLayout()
        file_name_layout.addWidget(self.__file_name)
        file_name_layout.addWidget(file_name_button)
        layout.addRow("Select directory to save files to:", file_name_layout)

        self.__gen_kw_file_types = ["Parameter list", "Template based"]
        self.__field_kw_file_types = ["Eclipse GRDECL", "RMS roff"]
        self.__gen_data_file_types = ["Gen data"]

        self.__file_type_model = self.__field_kw_file_types
        self.__file_type_combo = QComboBox()
        self.__file_type_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
        self.__file_type_combo.addItems(self.__file_type_model)
        layout.addRow("Select file format:", self.__file_type_combo)

        self.__report_step = QLineEdit()
        layout.addRow("Report step:", self.__report_step)

        self.__gen_data_report_step_model = []
        self.__gen_data_report_step = QComboBox()
        layout.addRow("Report step:", self.__gen_data_report_step)

        self.setLayout(layout)
        self.__keywords.currentIndexChanged.connect(self.keywordSelected)
        self.keywordSelected()

    def selectFileDirectory(self):
        directory = QFileDialog().getExistingDirectory(
            self, "Directory", self.__file_name.text(),
            QFileDialog.ShowDirsOnly)
        if str(directory).__len__() > 0:
            self.__file_name.setText(str(directory))

    def updateFileExportType(self, keyword):
        self.__file_type_combo.clear()
        if self.__export_keyword_model.isGenKw(keyword):
            self.__file_type_model = self.__gen_kw_file_types
        elif self.__export_keyword_model.isGenParamKw(keyword):
            self.__file_type_model = self.__gen_data_file_types
        elif self.__export_keyword_model.isGenDataKw(keyword):
            self.__file_type_model = self.__gen_data_file_types
        else:
            self.__file_type_model = self.__field_kw_file_types

        self.__file_type_combo.addItems(self.__file_type_model)

    def export(self):
        keyword = self.__kw_model[self.__keywords.currentIndex()]
        report_step = self.getReportStep(keyword)
        all_cases = self.__case_model.getAllItems()
        selected_case = all_cases[self.__case_combo.currentIndex()]
        path = self.__file_name.text()
        iactive = self.__active_realizations_model.getActiveRealizationsMask()
        file_type_key = self.__file_type_model[
            self.__file_type_combo.currentIndex()]
        values = {
            "keyword": keyword,
            "report_step": report_step,
            "iactive": iactive,
            "file_type_key": file_type_key,
            "path": path,
            "selected_case": selected_case
        }
        self.runExport.emit(values)

    def getReportStep(self, key):
        report_step = 0
        if self.__dynamic:
            report_step = self.__report_step.text()

        if self.__export_keyword_model.isGenParamKw(key):
            return report_step

        if self.__export_keyword_model.isGenDataKw(key):
            report_step = self.__gen_data_report_step_model[
                self.__gen_data_report_step.currentIndex()]

        return report_step

    def keywordSelected(self):
        key = self.__kw_model[self.__keywords.currentIndex()]
        self.updateFileExportType(key)
        self.__dynamic = False
        if self.__export_keyword_model.isFieldKw(key):
            self.__dynamic = self.__export_keyword_model.isDynamicField(key)

        self.__report_step.setVisible(self.__dynamic)
        self.layout().labelForField(self.__report_step).setVisible(
            self.__dynamic)

        self.__gen_data_report_step.setVisible(
            self.__export_keyword_model.isGenDataKw(key))
        self.layout().labelForField(self.__gen_data_report_step).setVisible(
            self.__export_keyword_model.isGenDataKw(key))

        if self.__export_keyword_model.isGenDataKw(key):
            data = self.__export_keyword_model.getGenDataReportSteps(key)
            self.__gen_data_report_step_model = data
            self.__gen_data_report_step.clear()
            self.__gen_data_report_step.addItems(
                self.__gen_data_report_step_model)

    def setSelectedCase(self, selected_case):
        self.__case_combo.setCurrentIndex(
            self.__case_model.indexOf(selected_case))

    def validateExportDialog(self):
        validRealizations = False
        if self.__active_realizations_field.isValid():
            validRealizations = True

        path = str(self.__file_name.text())
        validPath = len(path) > 0

        if validRealizations and validPath:
            self.updateExportButton.emit("export", True)
        else:
            self.updateExportButton.emit("export", False)
Exemplo n.º 6
0
 def __init__(self):
     self.__export_keyword_model = ExportKeywordModel()
Exemplo n.º 7
0
    def __init__(self):
        QWidget.__init__(self)

        self.setMinimumWidth(500)
        self.setMinimumHeight(200)
        self.__dynamic = False

        self.setWindowTitle("Export data")
        self.activateWindow()

        layout = QFormLayout()
        current_case = CaseSelectorModel().getCurrentChoice()

        self.__case_model = AllCasesModel()
        self.__case_combo = QComboBox()
        self.__case_combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength)
        self.__case_combo.setMinimumContentsLength(20)
        self.__case_combo.setModel(self.__case_model)
        self.__case_combo.setCurrentIndex(self.__case_model.indexOf(current_case))
        layout.addRow("Select case:",self.__case_combo)

        self.__export_keyword_model = ExportKeywordModel()

        self.__kw_model = self.__export_keyword_model.getKeyWords()
        self.__keywords = QComboBox()
        self.__keywords.addItems(self.__kw_model)
        layout.addRow("Select keyword:",self.__keywords)

        self.__active_realizations_model = ExportRealizationsModel(EnsembleSizeModel().getValue())
        self.__active_realizations_field = StringBox(self.__active_realizations_model, "Active realizations", "config/simulation/active_realizations")
        self.__active_realizations_field.setValidator(RangeStringArgument())
        layout.addRow(self.__active_realizations_field.getLabel(), self.__active_realizations_field)

        file_name_button= QToolButton()
        file_name_button.setText("Browse")
        file_name_button.clicked.connect(self.selectFileDirectory)

        self.__file_name = QLineEdit()
        self.__file_name.setEnabled(False)
        self.__file_name.setText(QDir.currentPath()+"/export")
        self.__file_name.setMinimumWidth(250)

        file_name_layout = QHBoxLayout()
        file_name_layout.addWidget(self.__file_name)
        file_name_layout.addWidget(file_name_button)
        layout.addRow("Select directory to save files to:", file_name_layout)

        self.__gen_kw_file_types = ["Parameter list", "Template based"]
        self.__field_kw_file_types = ["Eclipse GRDECL", "RMS roff"]

        self.__file_type_model = self.__field_kw_file_types
        self.__file_type_combo = QComboBox()
        self.__file_type_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
        self.__file_type_combo.addItems(self.__file_type_model)
        layout.addRow("Select file format:",self.__file_type_combo)

        self.__report_step = QLineEdit()
        layout.addRow("Report step:", self.__report_step)

        self.setLayout(layout)
        self.__keywords.currentIndexChanged.connect(self.keywordSelected)
        self.keywordSelected()
Exemplo n.º 8
0
class ExportPanel(QWidget):

    def __init__(self):
        QWidget.__init__(self)

        self.setMinimumWidth(500)
        self.setMinimumHeight(200)
        self.__dynamic = False

        self.setWindowTitle("Export data")
        self.activateWindow()

        layout = QFormLayout()
        current_case = CaseSelectorModel().getCurrentChoice()

        self.__case_model = AllCasesModel()
        self.__case_combo = QComboBox()
        self.__case_combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength)
        self.__case_combo.setMinimumContentsLength(20)
        self.__case_combo.setModel(self.__case_model)
        self.__case_combo.setCurrentIndex(self.__case_model.indexOf(current_case))
        layout.addRow("Select case:",self.__case_combo)

        self.__export_keyword_model = ExportKeywordModel()

        self.__kw_model = self.__export_keyword_model.getKeyWords()
        self.__keywords = QComboBox()
        self.__keywords.addItems(self.__kw_model)
        layout.addRow("Select keyword:",self.__keywords)

        self.__active_realizations_model = ExportRealizationsModel(EnsembleSizeModel().getValue())
        self.__active_realizations_field = StringBox(self.__active_realizations_model, "Active realizations", "config/simulation/active_realizations")
        self.__active_realizations_field.setValidator(RangeStringArgument())
        layout.addRow(self.__active_realizations_field.getLabel(), self.__active_realizations_field)

        file_name_button= QToolButton()
        file_name_button.setText("Browse")
        file_name_button.clicked.connect(self.selectFileDirectory)

        self.__file_name = QLineEdit()
        self.__file_name.setEnabled(False)
        self.__file_name.setText(QDir.currentPath()+"/export")
        self.__file_name.setMinimumWidth(250)

        file_name_layout = QHBoxLayout()
        file_name_layout.addWidget(self.__file_name)
        file_name_layout.addWidget(file_name_button)
        layout.addRow("Select directory to save files to:", file_name_layout)

        self.__gen_kw_file_types = ["Parameter list", "Template based"]
        self.__field_kw_file_types = ["Eclipse GRDECL", "RMS roff"]

        self.__file_type_model = self.__field_kw_file_types
        self.__file_type_combo = QComboBox()
        self.__file_type_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
        self.__file_type_combo.addItems(self.__file_type_model)
        layout.addRow("Select file format:",self.__file_type_combo)

        self.__report_step = QLineEdit()
        layout.addRow("Report step:", self.__report_step)

        self.setLayout(layout)
        self.__keywords.currentIndexChanged.connect(self.keywordSelected)
        self.keywordSelected()

    def selectFileDirectory(self):
        directory = QFileDialog().getExistingDirectory(self, "Directory", QDir.currentPath(), QFileDialog.ShowDirsOnly)
        self.__file_name.setText(str(directory))

    def updateFileExportType(self):
        keyword = self.__kw_model[self.__keywords.currentIndex()]
        self.__file_type_combo.clear()
        if self.__export_keyword_model.isGenKw(keyword):
            self.__file_type_model = self.__gen_kw_file_types
        else:
            self.__file_type_model = self.__field_kw_file_types

        self.__file_type_combo.addItems(self.__file_type_model)

    def export(self):
        report_step = 0
        if self.__dynamic:
            report_step = self.__report_step.text()
        keyword = self.__kw_model[self.__keywords.currentIndex()]
        all_cases = self.__case_model.getAllItems()
        selected_case  = all_cases[self.__case_combo.currentIndex()]

        file_name = self.createExportFilNameMask(keyword, selected_case)

        iactive = self.__active_realizations_model.getActiveRealizationsMask()

        file_type_key = self.__file_type_model[self.__file_type_combo.currentIndex()]
        state = EnkfStateType.FORECAST

        if self.__export_keyword_model.isFieldKw(keyword):
            self.exportField(keyword, file_name, iactive, file_type_key, report_step, state, selected_case)
        elif self.__export_keyword_model.isGenKw(keyword):
            self.exportGenKw(keyword, file_name, iactive, file_type_key, report_step, state, selected_case)


    def exportGenKw(self, keyword, file_name, iactive, file_type_key, report_step, state, selected_case):
        ExportModel().exportGenKw(keyword, file_name, iactive, file_type_key, report_step, state, selected_case)


    def exportField(self, keyword, file_name, iactive, file_type_key, report_step, state, selected_case):
        if file_type_key == "Eclipse GRDECL":
            file_type = EnkfFieldFileFormatEnum.ECL_GRDECL_FILE
        else:
            file_type = EnkfFieldFileFormatEnum.RMS_ROFF_FILE

        result = ExportModel().exportField(keyword, file_name, iactive, file_type, report_step, state, selected_case)
        if not result:
            QMessageBox.warning(self, "Warning",'''Something did not work!''',QMessageBox.Ok);

    def createExportFilNameMask(self, keyword, current_case):
        path = self.__file_name.text()
        impl_type = None

        if self.__export_keyword_model.isFieldKw(keyword):
            impl_type = ExportKeywordModel().getImplementationType(keyword)
        elif self.__export_keyword_model.isGenKw(keyword):
            impl_type = "Gen_Kw"

        path = str(path) + "/" + str(current_case) + "/" + str(impl_type) + "/" + str(keyword)

        if not QDir(path).exists():
            os.makedirs(path);

        return path

    def keywordSelected(self):
        self.updateFileExportType()
        key = self.__kw_model[self.__keywords.currentIndex()]
        if self.__export_keyword_model.isFieldKw(key):
            self.__dynamic = ExportKeywordModel().isDynamicField(key)
        else:
            self.__dynamic = False

        self.__report_step.setVisible(self.__dynamic)
        self.layout().labelForField(self.__report_step).setVisible(self.__dynamic)
Exemplo n.º 9
0
 def __init__(self):
     self.__export_keyword_model = ExportKeywordModel()
Exemplo n.º 10
0
class ExportPanel(QWidget):

    updateExportButton = pyqtSignal(str, bool)
    runExport = pyqtSignal(dict)

    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.setMinimumWidth(500)
        self.setMinimumHeight(200)
        self.__dynamic = False

        self.setWindowTitle("Export data")
        self.activateWindow()

        layout = QFormLayout()
        current_case = CaseSelectorModel().getCurrentChoice()

        self.__case_model = AllCasesModel()
        self.__case_combo = QComboBox()
        self.__case_combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength)
        self.__case_combo.setMinimumContentsLength(20)
        self.__case_combo.setModel(self.__case_model)
        self.__case_combo.setCurrentIndex(self.__case_model.indexOf(current_case))
        layout.addRow("Select case:",self.__case_combo)

        self.__export_keyword_model = ExportKeywordModel()

        self.__kw_model = self.__export_keyword_model.getKeyWords()
        self.__keywords = QComboBox()
        self.__keywords.addItems(self.__kw_model)
        layout.addRow("Select keyword:",self.__keywords)

        self.__active_realizations_model = ExportRealizationsModel(EnsembleSizeModel().getValue())
        self.__active_realizations_field = StringBox(self.__active_realizations_model, "Active realizations", "config/simulation/active_realizations")
        self.__active_realizations_field.setValidator(RangeStringArgument())
        self.__active_realizations_field.validationChanged.connect(self.validateExportDialog)
        layout.addRow(self.__active_realizations_field.getLabel(), self.__active_realizations_field)

        file_name_button= QToolButton()
        file_name_button.setText("Browse")
        file_name_button.clicked.connect(self.selectFileDirectory)

        self.__defaultPath = QDir.currentPath()+"/export"
        self.__file_name = QLineEdit()
        self.__file_name.setEnabled(False)
        self.__file_name.setText(self.__defaultPath)
        self.__file_name.textChanged.connect(self.validateExportDialog)
        self.__file_name.setMinimumWidth(250)

        file_name_layout = QHBoxLayout()
        file_name_layout.addWidget(self.__file_name)
        file_name_layout.addWidget(file_name_button)
        layout.addRow("Select directory to save files to:", file_name_layout)

        self.__gen_kw_file_types = ["Parameter list", "Template based"]
        self.__field_kw_file_types = ["Eclipse GRDECL", "RMS roff"]
        self.__gen_data_file_types = ["Gen data"]

        self.__file_type_model = self.__field_kw_file_types
        self.__file_type_combo = QComboBox()
        self.__file_type_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
        self.__file_type_combo.addItems(self.__file_type_model)
        layout.addRow("Select file format:",self.__file_type_combo)

        self.__report_step = QLineEdit()
        layout.addRow("Report step:", self.__report_step)

        self.__gen_data_report_step_model=[]
        self.__gen_data_report_step = QComboBox()
        layout.addRow("Report step:", self.__gen_data_report_step)

        self.setLayout(layout)
        self.__keywords.currentIndexChanged.connect(self.keywordSelected)
        self.keywordSelected()

    def selectFileDirectory(self):
        directory = QFileDialog().getExistingDirectory(self, "Directory", self.__file_name.text(), QFileDialog.ShowDirsOnly)
        if str(directory).__len__() > 0:
            self.__file_name.setText(str(directory))

    def updateFileExportType(self, keyword):
        self.__file_type_combo.clear()
        if self.__export_keyword_model.isGenKw(keyword):
            self.__file_type_model = self.__gen_kw_file_types
        elif self.__export_keyword_model.isGenParamKw(keyword):
            self.__file_type_model = self.__gen_data_file_types
        elif self.__export_keyword_model.isGenDataKw(keyword):
            self.__file_type_model = self.__gen_data_file_types
        else:
            self.__file_type_model = self.__field_kw_file_types

        self.__file_type_combo.addItems(self.__file_type_model)

    def export(self):
        keyword = self.__kw_model[self.__keywords.currentIndex()]
        report_step = self.getReportStep(keyword)
        all_cases = self.__case_model.getAllItems()
        selected_case  = all_cases[self.__case_combo.currentIndex()]
        path = self.__file_name.text()
        iactive = self.__active_realizations_model.getActiveRealizationsMask()
        file_type_key = self.__file_type_model[self.__file_type_combo.currentIndex()]
        values = {"keyword":keyword, "report_step":report_step, "iactive":iactive,"file_type_key":file_type_key, "path":path , "selected_case" : selected_case}
        self.runExport.emit(values)
        
    

    def getReportStep(self, key):
        report_step = 0
        if self.__dynamic:
            report_step = self.__report_step.text()

        if self.__export_keyword_model.isGenParamKw(key):
            return report_step

        if self.__export_keyword_model.isGenDataKw(key):
            report_step = self.__gen_data_report_step_model[self.__gen_data_report_step.currentIndex()]

        return report_step


    def keywordSelected(self):
        key = self.__kw_model[self.__keywords.currentIndex()]
        self.updateFileExportType(key)
        self.__dynamic = False
        if self.__export_keyword_model.isFieldKw(key):
            self.__dynamic = self.__export_keyword_model.isDynamicField(key)

        self.__report_step.setVisible(self.__dynamic)
        self.layout().labelForField(self.__report_step).setVisible(self.__dynamic)

        self.__gen_data_report_step.setVisible(self.__export_keyword_model.isGenDataKw(key))
        self.layout().labelForField(self.__gen_data_report_step).setVisible(self.__export_keyword_model.isGenDataKw(key))

        if self.__export_keyword_model.isGenDataKw(key):
            data = self.__export_keyword_model.getGenDataReportSteps(key)
            self.__gen_data_report_step_model = data
            self.__gen_data_report_step.clear()
            self.__gen_data_report_step.addItems(self.__gen_data_report_step_model)

    def setSelectedCase(self, selected_case):
        self.__case_combo.setCurrentIndex(self.__case_model.indexOf(selected_case))

    def validateExportDialog(self):
        validRealizations = False
        if self.__active_realizations_field.isValid():
            validRealizations = True

        path = str(self.__file_name.text())
        validPath = len(path) > 0

        if validRealizations and validPath:
            self.updateExportButton.emit("export", True)
        else:
            self.updateExportButton.emit("export", False)