Exemplo n.º 1
0
def change_address_main(self):
    self.new_address_entry = gui_ut.Entry(self.top_bar, width=40)
    self.new_address_entry.insert(0, string=self.model.GOST_address)
    self.view_elements.append({
        "item": self.new_address_entry,
        "row": 0,
        "column": 1,
        "name": "new_address_entry"
    })

    self.confirm_address_button = gui_ut.Button(
        self.top_bar,
        text="Confirm changes",
        command=lambda: try_address(self))
    self.view_elements.append({
        "item": self.confirm_address_button,
        "row": 0,
        "column": 2,
        "name": "new_address_button"
    })

    self.keep_old_address_button = gui_ut.Button(
        self.top_bar,
        text="Keep old address",
        command=lambda: keep_address(self))
    self.view_elements.append({
        "item": self.keep_old_address_button,
        "row": 0,
        "column": 3,
        "name": "keep_old_address_button"
    })
    self.new_address_entry.grid(row=0, column=1)
    self.confirm_address_button.grid(row=0, column=2)
    self.keep_old_address_button.grid(row=0, column=4)
    gui_ut.populate(self.view_elements, self.main_area)
Exemplo n.º 2
0
    def __init__(self, main_view):
        self.view_elements = []
        self.create_values = {}
        self.create_entries = []
        self.selected_type = None
        self.save_btn = None
        self.save_and_post_btn = None
        self.number_to_create = None
        self.result = None
        self.main_view = main_view
        self.created_items = []
        self.selected_items = []
        self.post_btn = None
        self.storage_file = None
        self.post_from_file_btn = None
        self.error_message = ""

        main_view.current_command_view = self

        types_menu_description = gui_ut.Label(
            self.main_view.main_area,
            text="Select OGC entity type of the items\n"
            "you are going to create or post\n"
            "(mandatory field)")
        self.view_elements.append({
            "item": types_menu_description,
            "row": 1,
            "column": 0
        })

        self.selected_type = gui_ut.StringVar(self.main_view.main_area)
        types = gui_ut.get_ogc_types()
        self.selected_type.set("Select an OGC type")

        self.selected_type.trace("w", self.show_options)

        types_menu = gui_ut.OptionMenu(self.main_view.main_area,
                                       self.selected_type, *types)
        self.view_elements.append({"item": types_menu, "row": 1, "column": 1})

        number_to_create_description = gui_ut.Label(
            self.main_view.main_area, text="Select how many items create")

        self.view_elements.append({
            "item": number_to_create_description,
            "row": 2,
            "column": 0
        })
        self.number_to_create = gui_ut.Entry(self.main_view.main_area,
                                             width=10)
        self.view_elements.append({
            "item": self.number_to_create,
            "row": 2,
            "column": 1
        })

        gui_ut.populate(self.view_elements, self.main_view.main_area)
Exemplo n.º 3
0
def change_port_number(self):
    self.port_button.grid_forget()
    indexes_to_delete = []
    for index, val in enumerate(self.view_elements):
        if "name" in val:
            if val["name"] in [
                    "new_address_entry", "new_address_button",
                    "keep_old_address_button"
            ]:
                indexes_to_delete.append(index)
    for i in sorted(indexes_to_delete, reverse=True):
        self.view_elements[i]["item"].grid_forget()
        del self.view_elements[i]
    self.new_port_entry = gui_ut.Entry(self.top_bar, width=40)
    self.new_port_entry.insert(0, string=try_port(take=1))
    self.view_elements.append({
        "item": self.new_port_entry,
        "row": 0,
        "column": 1,
        "name": "new_port_entry"
    })

    self.confirm_port_button = gui_ut.Button(
        self.top_bar,
        text="Confirm changes",
        command=lambda: try_port(self, self.new_port_entry.get()))
    self.view_elements.append({
        "item": self.confirm_port_button,
        "row": 0,
        "column": 2,
        "name": "new_port_button"
    })
    self.keep_old_port_button = gui_ut.Button(
        self.top_bar, text="Keep old port", command=lambda: keep_address(self))
    self.view_elements.append({
        "item": self.keep_old_port_button,
        "row": 0,
        "column": 3,
        "name": "old_port_button"
    })
    self.new_port_entry.grid(row=0, column=1)
    self.confirm_port_button.grid(row=0, column=2)
    self.keep_old_port_button.grid(row=0, column=3)
    self.address_preview.configure(
        text=f"Current GOST address: {self.model.GOST_address} "
        f"\nclick here to change address")
Exemplo n.º 4
0
def set_patches_fields(self):
    row = 7
    field_names = gui_ut.get_fields_names(self.selected_type.get(),
                                          needed_for_editing=True)
    for item in field_names:
        temp_label = gui_ut.Label(self.main_view.main_area, text=item)
        self.view_elements.append({
            "item": temp_label,
            "row": row,
            "column": 0,
            "name": "patch_field_name"
        })
        temp_entry = gui_ut.Entry(self.main_view.main_area, width=50)
        self.view_elements.append({
            "item": temp_entry,
            "row": row,
            "column": 1,
            "name": "patch_field_value"
        })
        row += 1
        self.patch_values.append({
            "field_name": item,
            "field_entry": temp_entry
        })
Exemplo n.º 5
0
    def __init__(self, main_view):
        self.view_elements = []
        self.selected_type = None
        self.selected_boolean_expression = None
        self.selected_identifiers = None
        self.result = None
        self.result_info = None
        self.main_view = main_view
        self.show_fields = "all"
        self.selected_items = None
        self.delete_btn = None
        self.result = None

        main_view.current_command_view = self

        types_menu_description = gui_ut.Label(
            main_view.main_area,
            borderwidth=2,
            relief="solid",
            text="Select OGC entity type (mandatory field)")
        self.view_elements.append({
            "item": types_menu_description,
            "row": 0,
            "column": 0
        })

        self.selected_type = gui_ut.StringVar(main_view.main_area)
        types = gui_ut.get_ogc_types()
        self.selected_type.set("Select an OGC type")

        self.selected_type.trace("w", self.show_options)

        types_menu = gui_ut.OptionMenu(main_view.main_area, self.selected_type,
                                       *types)
        self.view_elements.append({"item": types_menu, "row": 0, "column": 1})

        selected_identifiers_description = gui_ut.Label(
            main_view.main_area,
            borderwidth=2,
            relief="solid",
            text=gui_ut.select_id_text)

        self.view_elements.append({
            "item": selected_identifiers_description,
            "row": 1,
            "column": 0
        })
        self.selected_identifiers = gui_ut.Entry(main_view.main_area, width=10)
        self.view_elements.append({
            "item": self.selected_identifiers,
            "row": 1,
            "column": 1
        })

        selected_boolean_expression_description = gui_ut.Label(
            main_view.main_area,
            borderwidth=2,
            relief="solid",
            text=gui_ut.select_conditions_text)

        self.view_elements.append({
            "item": selected_boolean_expression_description,
            "row": 2,
            "column": 0
        })
        self.selected_boolean_expression = gui_ut.Entry(main_view.main_area,
                                                        width=50)

        self.view_elements.append({
            "item": self.selected_boolean_expression,
            "row": 2,
            "column": 1
        })

        types_menu_description = gui_ut.Label(
            main_view.main_area,
            borderwidth=2,
            relief="solid",
            text="Select Related OGC entity type (optional field)")
        self.view_elements.append({
            "item": types_menu_description,
            "row": 3,
            "column": 0
        })

        self.related_type = gui_ut.StringVar(main_view.main_area)
        types = gui_ut.get_ogc_types(True)
        self.related_type.set("No related OGC type")

        self.related_type.trace("w", self.show_options)

        types_menu = gui_ut.OptionMenu(main_view.main_area, self.related_type,
                                       *types)
        self.view_elements.append({"item": types_menu, "row": 3, "column": 1})

        fields_menu_description = gui_ut.Label(
            main_view.main_area,
            borderwidth=2,
            relief="solid",
            text="Select fields to show (default: all)")
        self.view_elements.append({
            "item": fields_menu_description,
            "row": 4,
            "column": 0
        })

        gui_ut.populate(self.view_elements, self.main_view.main_area)
Exemplo n.º 6
0
    def __init__(self, main_view):
        self.view_elements = []
        self.selected_type = None
        self.selected_boolean_expression = None
        self.selected_identifiers = None
        self.result = None
        self.main_view = main_view
        self.show_fields = None
        self.selected_items = None
        self.patch_btn = None
        self.abort_patch_btn = None
        self.result = None
        self.patch_values = []
        self.error_message = ""

        main_view.current_command_view = self

        types_menu_description = gui_ut.Label(
            main_view.main_area,
            text="Select OGC entity type (mandatory field)")
        self.view_elements.append({
            "item": types_menu_description,
            "row": 0,
            "column": 0
        })

        self.selected_type = gui_ut.StringVar(main_view.main_area)
        types = gui_ut.get_ogc_types()
        self.selected_type.set("Select an OGC type")

        self.selected_type.trace("w", self.show_options)

        types_menu = gui_ut.OptionMenu(main_view.main_area, self.selected_type,
                                       *types)
        self.view_elements.append({"item": types_menu, "row": 0, "column": 1})

        select_introduction = gui_ut.Label(main_view.main_area,
                                           text="Select the items to Patch")
        self.view_elements.append({
            "item": select_introduction,
            "row": 1,
            "column": 1,
            "name": "select_introduction"
        })

        selected_identifiers_description = gui_ut.Label(
            main_view.main_area, text=gui_ut.select_id_text)

        self.view_elements.append({
            "item": selected_identifiers_description,
            "row": 2,
            "column": 0,
            "name": "selected_identifiers_description"
        })
        self.selected_identifiers = gui_ut.Entry(main_view.main_area, width=10)
        self.view_elements.append({
            "item": self.selected_identifiers,
            "row": 2,
            "column": 1,
            "name": "selected_identifiers"
        })

        selected_boolean_expression_description = gui_ut.Label(
            main_view.main_area, text=gui_ut.select_conditions_text)
        self.view_elements.append({
            "item":
            selected_boolean_expression_description,
            "row":
            3,
            "column":
            0,
            "name":
            "selected_boolean_expression_description"
        })
        self.selected_boolean_expression = gui_ut.Entry(main_view.main_area,
                                                        width=50)
        self.view_elements.append({
            "item": self.selected_boolean_expression,
            "row": 3,
            "column": 1,
            "name": "selected_boolean_expression"
        })

        gui_ut.populate(self.view_elements, self.main_view.main_area)
Exemplo n.º 7
0
    def show_options(
        self, a, b, c
    ):  # additional parameters a b c needed because it is called by Trace function
        if not (self.selected_type.get() == "Select an OGC type"
                ):  # needed to avoid the restoring of action
            # buttons before action execution
            indexes_to_delete = []  # clearing the previously set patch options
            for index, val in enumerate(self.view_elements):
                if "name" in val:
                    if val["name"] in [
                            "create_field_name", "create_field_value",
                            "mandatory_field"
                    ]:
                        indexes_to_delete.append(index)
            for i in sorted(indexes_to_delete, reverse=True):
                self.view_elements[i]["item"].grid_forget()
                del self.view_elements[i]

            field_names = gui_ut.get_fields_names(self.selected_type.get(),
                                                  needed_for_editing=True)

            row = 11

            for item in field_names:
                temp_label = gui_ut.Label(self.main_view.main_area, text=item)
                self.view_elements.append({
                    "item": temp_label,
                    "row": row,
                    "column": 0,
                    "name": "create_field_name"
                })
                temp_entry = gui_ut.Entry(self.main_view.main_area, width=50)
                self.view_elements.append({
                    "item": temp_entry,
                    "row": row,
                    "column": 1,
                    "name": "create_field_value"
                })
                row += 1
                self.create_entries.append({
                    "field_name": item,
                    "field_entry": temp_entry
                })

            self.save_btn = gui_ut.Button(self.main_view.main_area,
                                          text="Save to a file",
                                          command=lambda: save(self))
            self.view_elements.append({
                "item": self.save_btn,
                "row": 10,
                "column": 0,
                "name": "save_button"
            })

            self.post_btn = gui_ut.Button(self.main_view.main_area,
                                          text="Post to GOST",
                                          command=lambda: direct_post(self))
            self.view_elements.append({
                "item": self.post_btn,
                "row": 10,
                "column": 1,
                "name": "post_button"
            })

            self.save_and_post_btn = gui_ut.Button(
                self.main_view.main_area,
                text="Save to a file\nand Post to GOST",
                command=lambda: save_and_post(self))
            self.view_elements.append({
                "item": self.save_and_post_btn,
                "row": 10,
                "column": 2,
                "name": "save_and_post_button"
            })
            self.post_from_file_btn = gui_ut.Button(
                self.main_view.main_area,
                text="POST records \ndefined in a file",
                command=lambda: post_from_file(self))
            self.view_elements.append({
                "item": self.post_from_file_btn,
                "row": 11,
                "column": 2,
                "name": "post_from_file_button"
            })
            if self.selected_type.get() == "Datastreams":
                red_label = gui_ut.Label(
                    self.main_view.main_area,
                    text="* Fields Things_id, ObservedProperty_id, "
                    "Sensor_id are mandatory",
                    fg="#FF0000",
                    font=(None, 15),
                    width=60)
                self.view_elements.append({
                    "item": red_label,
                    "row": row,
                    "column": 0,
                    "name": "mandatory_field"
                })
            elif self.selected_type.get() == "Observations":
                red_label = gui_ut.Label(
                    self.main_view.main_area,
                    text="* Fields Datastream_id and FeatureOfInterest(id) "
                    "are mandatory",
                    fg="#FF0000",
                    font=(None, 15),
                    width=60)
                self.view_elements.append({
                    "item": red_label,
                    "row": row,
                    "column": 0,
                    "name": "mandatory_field"
                })
            gui_ut.populate(self.view_elements, self.main_view.main_area)