How to use the pyecore.notification.Notification function in pyecore

To help you get started, we’ve selected a few pyecore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyecore / pyecore / pyecore / valuecontainer.py View on Github external
def add(self, value, update_opposite=True):
        self.check(value)
        if self.is_ref:
            self._update_container(value)
            if update_opposite:
                self._update_opposite(value, self.owner)
        super().add(value)
        self.owner.notify(Notification(new=value,
                                       feature=self.feature,
                                       kind=Kind.ADD))
        self.owner._isset.add(self.feature)
github pyecore / pyecore / pyecore / valuecontainer.py View on Github external
def remove(self, value, update_opposite=True):
        if self.is_ref:
            self._update_container(None, previous_value=value)
            if update_opposite:
                self._update_opposite(value, self.owner, remove=True)
        super().remove(value)
        self.owner.notify(Notification(old=value,
                                       feature=self.feature,
                                       kind=Kind.REMOVE))
github pyecore / pyecore / pyecore / valuecontainer.py View on Github external
def append(self, value, update_opposite=True):
        self.check(value)
        if self.is_ref:
            self._update_container(value)
            if update_opposite:
                self._update_opposite(value, self.owner)
        super().append(value)
        self.owner.notify(Notification(new=value,
                                       feature=self.feature,
                                       kind=Kind.ADD))
        self.owner._isset.add(self.feature)
github pyecore / pyecore / pyecore / valuecontainer.py View on Github external
def pop(self, index=None):
        if index is None:
            value = super().pop()
        else:
            value = super().pop(index)
        if self.is_ref:
            self._update_container(None, previous_value=value)
            self._update_opposite(value, self.owner, remove=True)
        self.owner.notify(Notification(old=value,
                                       feature=self.feature,
                                       kind=Kind.REMOVE))
        return value
github pyecore / pyecore / pyecore / valuecontainer.py View on Github external
def extend(self, sublist):
        check = self.check
        if self.is_ref:
            _update_container = self._update_container
            _update_opposite = self._update_opposite
            owner = self.owner
            for value in sublist:
                check(value)
                _update_container(value)
                _update_opposite(value, owner)
        else:
            for value in sublist:
                check(value)

        super().extend(sublist)
        self.owner.notify(Notification(new=sublist,
                                       feature=self.feature,
                                       kind=Kind.ADD_MANY))
        self.owner._isset.add(self.feature)
github pyecore / pyecore / pyecore / valuecontainer.py View on Github external
if isinstance(i, slice) and is_collection:
            sliced_elements = self.__getitem__(i)
            if self.is_ref:
                for element in y:
                    self.check(element)
                    self._update_container(element)
                    self._update_opposite(element, self.owner)
                # We remove (not really) all element from the slice
                for element in sliced_elements:
                    self._update_container(None, previous_value=element)
                    self._update_opposite(element, self.owner, remove=True)
            else:
                for element in y:
                    self.check(element)
            if sliced_elements and len(sliced_elements) > 1:
                self.owner.notify(Notification(old=sliced_elements,
                                               feature=self.feature,
                                               kind=Kind.REMOVE_MANY))
            elif sliced_elements:
                self.owner.notify(Notification(old=sliced_elements[0],
                                               feature=self.feature,
                                               kind=Kind.REMOVE))

        else:
            self.check(y)
            if self.is_ref:
                self._update_container(y)
                self._update_opposite(y, self.owner)
        super().__setitem__(i, y)
        kind = Kind.ADD
        if is_collection and len(y) > 1:
            kind = Kind.ADD_MANY
github pyecore / pyecore / pyecore / valuecontainer.py View on Github external
def _set(self, value, update_opposite=True):
        self.check(value)
        previous_value = self._value
        self._value = value
        owner = self.owner
        efeature = self.feature
        notif = Notification(old=previous_value,
                             new=value,
                             feature=efeature,
                             kind=Kind.UNSET if value is None else Kind.SET)
        owner.notify(notif)
        owner._isset.add(efeature)

        if not self.is_ref:
            return
        self._update_container(value, previous_value)
        if not update_opposite:
            return

        # if there is no opposite, we set inverse relation and return
        if not efeature.eOpposite:
            couple = (owner, efeature)
            if hasattr(value, '_inverse_rels'):