def update_meta_data_for_port(graphical_editor_view, item, handle):
    """This method updates the meta data of the states ports if they changed.

    :param graphical_editor_view: Graphical Editor the change occurred in
    :param item: State the port was moved in
    :param handle: Handle of moved port or None if all ports are to be updated
    """
    from rafcon.gui.mygaphas.items.ports import IncomeView, OutcomeView, InputPortView, OutputPortView, ScopedVariablePortView
    for port in item.get_all_ports():
        if not handle or handle is port.handle:
            rel_pos = port.handle.pos.x.value, port.handle.pos.y.value
            if isinstance(port, (IncomeView, OutcomeView, InputPortView,
                OutputPortView, ScopedVariablePortView)):
                port_m = port.model
                cur_rel_pos = port_m.get_meta_data_editor()['rel_pos']
                if rel_pos != cur_rel_pos:
                    port_m.set_meta_data_editor('rel_pos', rel_pos)
                    if handle:
                        graphical_editor_view.emit('meta_data_changed',
                            port_m, 'position', True)
            else:
                continue
            if handle:
                break
