Пример #1
0
    def update_ui_state(self):
        show_advanced_options = self.check_show_advanced_options.isChecked()

        # flavor
        flavor_api_name = self.program.cast_custom_option_value('javascript.flavor', str, '<unknown>')
        flavor          = Constants.get_javascript_flavor(flavor_api_name)
        flavor_browser  = flavor == Constants.JAVASCRIPT_FLAVOR_BROWSER
        flavor_nodejs   = flavor == Constants.JAVASCRIPT_FLAVOR_NODEJS

        if flavor_browser:
            self.label_flavor.setText('Client-Side')
        elif flavor_nodejs:
            def cb_nodejs_versions(versions):
                for version in versions:
                    if version.executable == self.program.executable:
                        self.label_flavor.setText('Server-Side (Node.js {0})'.format(version.version))
                        return

                self.label_flavor.setText('Server-Side (Node.js)')

            self.get_executable_versions('nodejs', cb_nodejs_versions)

        self.check_show_advanced_options.setVisible(flavor_nodejs)
        self.line.setVisible(flavor_nodejs)

        # start mode
        start_mode_api_name    = self.program.cast_custom_option_value('javascript.start_mode', str, '<unknown>')
        start_mode             = Constants.get_javascript_start_mode(start_mode_api_name)
        start_mode_script_file = start_mode == Constants.JAVASCRIPT_START_MODE_SCRIPT_FILE
        start_mode_command     = start_mode == Constants.JAVASCRIPT_START_MODE_COMMAND

        self.label_start_mode_title.setVisible(flavor_nodejs)
        self.label_start_mode.setVisible(flavor_nodejs)
        self.label_start_mode.setText(Constants.javascript_start_mode_display_names[start_mode])

        # script file
        self.label_script_file_title.setVisible(flavor_nodejs and start_mode_script_file)
        self.label_script_file.setVisible(flavor_nodejs and start_mode_script_file)
        self.label_script_file.setText(self.program.cast_custom_option_value('javascript.script_file', str, '<unknown>'))

        # command
        self.label_command_title.setVisible(flavor_nodejs and start_mode_command)
        self.label_command.setVisible(flavor_nodejs and start_mode_command)
        self.label_command.setText(self.program.cast_custom_option_value('javascript.command', str, '<unknown>'))

        # working directory
        self.label_working_directory_title.setVisible(flavor_nodejs and show_advanced_options)
        self.label_working_directory.setVisible(flavor_nodejs and show_advanced_options)
        self.label_working_directory.setText(self.program.working_directory)

        # options
        self.label_options_title.setVisible(flavor_nodejs and show_advanced_options)
        self.label_options.setVisible(flavor_nodejs and show_advanced_options)
        self.label_options.setText('\n'.join(self.program.cast_custom_option_value_list('javascript.options', str, [])))
Пример #2
0
    def update_ui_state(self):
        show_advanced_options = self.check_show_advanced_options.isChecked()

        # flavor
        flavor_api_name = self.program.cast_custom_option_value('javascript.flavor', unicode, '<unknown>')
        flavor          = Constants.get_javascript_flavor(flavor_api_name)
        flavor_browser  = flavor == Constants.JAVASCRIPT_FLAVOR_BROWSER
        flavor_nodejs   = flavor == Constants.JAVASCRIPT_FLAVOR_NODEJS

        if flavor_browser:
            self.label_flavor.setText('Client-Side')
        elif flavor_nodejs:
            def cb_nodejs_versions(versions):
                for version in versions:
                    if version.executable == self.program.executable:
                        self.label_flavor.setText('Server-Side (Node.js {0})'.format(version.version))
                        return

                self.label_flavor.setText('Server-Side (Node.js)')

            self.get_executable_versions('nodejs', cb_nodejs_versions)

        self.label_start_mode_title.setVisible(flavor_nodejs)
        self.label_start_mode.setVisible(flavor_nodejs)
        self.check_show_advanced_options.setVisible(flavor_nodejs)
        self.line.setVisible(flavor_nodejs)
        self.label_working_directory_title.setVisible(flavor_nodejs and show_advanced_options)
        self.label_working_directory.setVisible(flavor_nodejs and show_advanced_options)
        self.label_options_title.setVisible(flavor_nodejs and show_advanced_options)
        self.label_options.setVisible(flavor_nodejs and show_advanced_options)

        # start mode
        start_mode_api_name    = self.program.cast_custom_option_value('javascript.start_mode', unicode, '<unknown>')
        start_mode             = Constants.get_javascript_start_mode(start_mode_api_name)
        start_mode_script_file = start_mode == Constants.JAVASCRIPT_START_MODE_SCRIPT_FILE
        start_mode_command     = start_mode == Constants.JAVASCRIPT_START_MODE_COMMAND

        self.label_start_mode.setText(Constants.javascript_start_mode_display_names[start_mode])
        self.label_script_file_title.setVisible(flavor_nodejs and start_mode_script_file)
        self.label_script_file.setVisible(flavor_nodejs and start_mode_script_file)
        self.label_command_title.setVisible(flavor_nodejs and start_mode_command)
        self.label_command.setVisible(flavor_nodejs and start_mode_command)

        # script file
        self.label_script_file.setText(self.program.cast_custom_option_value('javascript.script_file', unicode, '<unknown>'))

        # command
        self.label_command.setText(self.program.cast_custom_option_value('javascript.command', unicode, '<unknown>'))

        # working directory
        self.label_working_directory.setText(self.program.working_directory)

        # options
        self.label_options.setText('\n'.join(self.program.cast_custom_option_value_list('javascript.options', unicode, [])))
Пример #3
0
    def initializePage(self):
        self.set_formatted_sub_title(
            'Specify how the {language} program [{name}] should be executed.')

        def cb_nodejs_versions(versions):
            if versions[0].version != None:
                node_version_str = ' ' + versions[0].version
            else:
                node_version_str = ''

            self.combo_flavor.clear()
            self.combo_flavor.addItem('Client-Side (Browser)', '/bin/false')
            self.combo_flavor.addItem(
                'Server-Side (Node.js{0})'.format(node_version_str),
                versions[0].executable)

            # if a program exists then this page is used in an edit wizard
            if self.wizard().program != None:
                program = self.wizard().program
                flavor_api_name = program.cast_custom_option_value(
                    'javascript.flavor', str, '<unknown>')
                flavor = Constants.get_javascript_flavor(flavor_api_name)

                if flavor == Constants.JAVASCRIPT_FLAVOR_BROWSER:
                    executable = '/bin/false'
                else:
                    executable = program.executable

                set_current_combo_index_from_data(self.combo_flavor,
                                                  executable)

            self.combo_flavor.setEnabled(True)
            self.completeChanged.emit()

        self.get_executable_versions('nodejs', cb_nodejs_versions)

        self.combo_start_mode.setCurrentIndex(
            Constants.DEFAULT_JAVASCRIPT_START_MODE)
        self.combo_script_file_selector.reset()
        self.check_show_advanced_options.setChecked(False)
        self.combo_working_directory_selector.reset()
        self.option_list_editor.reset()

        # if a program exists then this page is used in an edit wizard
        program = self.wizard().program

        if program != None:
            # start mode
            start_mode_api_name = program.cast_custom_option_value(
                'javascript.start_mode', str, '<unknown>')
            start_mode = Constants.get_javascript_start_mode(
                start_mode_api_name)

            self.combo_start_mode.setCurrentIndex(start_mode)

            # script file
            self.combo_script_file_selector.set_current_text(
                program.cast_custom_option_value('javascript.script_file', str,
                                                 ''))

            # command
            self.edit_command.setText(
                program.cast_custom_option_value('javascript.command', str,
                                                 ''))

            # working directory
            self.combo_working_directory_selector.set_current_text(
                program.working_directory)

            # options
            self.option_list_editor.clear()

            for option in program.cast_custom_option_value_list(
                    'javascript.options', str, []):
                self.option_list_editor.add_item(option)

        self.update_ui_state()