Beispiel #1
0
    def get_interactive_query(self):
        l=helper.get_id(self.controller.package.queries, '_interactive')
        if l:
            q=SimpleQuery()
            q.from_xml(l.content.stream)
            q.container=l
            return l, q
        else:
            # Create the query
            el=self.controller.package.createQuery(ident='_interactive')
            el.author=config.data.userid
            el.date=helper.get_timestamp()
            el.title=_("Interactive query")

            # Create a basic query
            q=SimpleQuery(sources=self.sources,
                          rvalue="element")
            q.add_condition(Condition(lhs="element/content/data",
                                      operator="contains",
                                      rhs="string:a"))

            el.content.mimetype='application/x-advene-simplequery'
            el.content.data=q.xml_repr()

            self.controller.package.queries.append(el)

            self.controller.notify('QueryCreate', query=el)
            q.container=el
            return el, q
Beispiel #2
0
 def AnnotationMute(self, context, parameters):
     """Zero the volume for the duration of the annotation."""
     annotation=context.evaluateValue('annotation')
     if annotation is None:
         return True
     self.SoundOff(context, parameters)
     # We create a new internal rule which will match the end of the
     # current annotation :
     cond=Condition(lhs='annotation/id',
                    operator='equals',
                    rhs="string:%s" % annotation.id)
     self.controller.event_handler.internal_rule(event='AnnotationEnd',
                                                 condition=cond,
                                                 method=self.SoundOn)
     return True
Beispiel #3
0
    def create_follow_dynamic_view(self, rt):
        """Create a dynamic view for the given relation-type.
        """
        p = self.controller.package
        ident = 'v_follow_%s' % rt.id
        if p.get_element_by_id(ident) is not None:
            dialog.message_dialog(
                _("A follow dynamic view for %s already seems to exist.") %
                self.get_title(rt))
            return True
        v = p.createView(ident=ident,
                         author=config.data.userid,
                         date=self.controller.get_timestamp(),
                         clazz='package',
                         content_mimetype='application/x-advene-ruleset')
        v.title = _("Follow %s relation-type") % self.get_title(rt)

        # Build the ruleset
        r = RuleSet()
        catalog = self.controller.event_handler.catalog

        ra = catalog.get_action("PlayerGoto")
        action = Action(registeredaction=ra, catalog=catalog)
        action.add_parameter(
            'position',
            'annotation/typedRelatedOut/%s/first/fragment/begin' % rt.id)
        rule = Rule(name=_("Follow the relation"),
                    event=Event("AnnotationEnd"),
                    condition=Condition(lhs='annotation/typedRelatedOut/%s' %
                                        rt.id,
                                        operator='value'),
                    action=action)
        r.add_rule(rule)

        v.content.data = r.xml_repr()

        p.views.append(v)
        self.controller.notify('ViewCreate', view=v)
        self.controller.activate_stbv(v)
        return True
Beispiel #4
0
    def create_dynamic_view(self, at):
        """Create a caption dynamic view for the given annotation-type.
        """
        p = self.controller.package
        ident = 'v_caption_%s' % at.id
        if p.get_element_by_id(ident) is not None:
            dialog.message_dialog(
                _("A caption dynamic view for %s already seems to exist.") %
                self.get_title(at))
            return True
        v = p.createView(ident=ident,
                         author=config.data.userid,
                         date=self.controller.get_timestamp(),
                         clazz='package',
                         content_mimetype='application/x-advene-ruleset')
        v.title = _("Caption %s annotations") % self.get_title(at)

        # Build the ruleset
        r = RuleSet()
        catalog = self.controller.event_handler.catalog

        ra = catalog.get_action("AnnotationCaption")
        action = Action(registeredaction=ra, catalog=catalog)
        action.add_parameter('message', 'annotation/content/data')

        rule = Rule(name=_("Caption the annotation"),
                    event=Event("AnnotationBegin"),
                    condition=Condition(lhs='annotation/type/id',
                                        operator='equals',
                                        rhs='string:%s' % at.id),
                    action=action)
        r.add_rule(rule)

        v.content.data = r.xml_repr()

        p.views.append(v)
        self.controller.notify('ViewCreate', view=v)
        self.controller.activate_stbv(v)
        return True
Beispiel #5
0
 def add_condition(self, widget, conditionsbox):
     cond = Condition(lhs="annotation/type/id",
                      operator="equals",
                      rhs="string:???")
     self.add_condition_widget(cond, conditionsbox)
     return True
Beispiel #6
0
 def add_condition(self, widget, conditionsbox):
     cond = Condition(lhs="element/content/data",
                      operator="contains",
                      rhs="string:???")
     self.add_condition_widget(cond, conditionsbox)
     return True