def closeEvent(self, event):
        event.accept()

        # resetting changes to server presets
        env_server.server_presets = None
        env_server.get_server_presets_defaults()
        env_server.get_server_presets()
    def add_new_preset(self):

        new_preset_name = self.line_edit.text()

        exclude_list = ['environment_config']
        presets = env_server.get_server_presets()
        exclude_list.extend(presets['presets_list'])

        if new_preset_name and new_preset_name not in exclude_list:
            self.line_edit.setText('')
            root_item = QtGui.QTreeWidgetItem()
            root_item.setText(0, new_preset_name)

            env_server.add_server_preset(new_preset_name)

            self.presets_tree_widget.addTopLevelItem(root_item)
        elif new_preset_name in exclude_list:
            message_box = QtGui.QMessageBox(
                QtGui.QMessageBox.Information,
                'Already exists',
                '<p>Server Preset named <b>{0}</b> already in Presets List.</p><p>Choose another Name.</p>'.format(new_preset_name),
                QtGui.QMessageBox.StandardButton,
                self,
            )
            message_box.exec_()
    def fill_presets_tree(self):

        presets = env_server.get_server_presets()
        if presets:
            for preset in presets['presets_list']:
                root_item = QtGui.QTreeWidgetItem()
                root_item.setText(0, preset)
                self.presets_tree_widget.addTopLevelItem(root_item)