Beispiel #1
0
 def __init__(self, app, change):
     save_button = mywid.FixedButton('Propose Change')
     cancel_button = mywid.FixedButton('Cancel')
     urwid.connect_signal(save_button, 'click',
                          lambda button: self._emit('save'))
     urwid.connect_signal(cancel_button, 'click',
                          lambda button: self._emit('cancel'))
     button_widgets = [('pack', save_button), ('pack', cancel_button)]
     button_columns = urwid.Columns(button_widgets, dividechars=2)
     rows = []
     self.entry = mywid.MyEdit(edit_text=change.revisions[-1].message,
                               multiline=True,
                               ring=app.ring)
     self.branch_buttons = []
     rows.append(urwid.Text(u"Branch:"))
     for branch in change.project.branches:
         b = mywid.FixedRadioButton(self.branch_buttons,
                                    branch.name,
                                    state=(branch.name == change.branch))
         rows.append(b)
     rows.append(urwid.Divider())
     rows.append(urwid.Text(u"Commit message:"))
     rows.append(self.entry)
     rows.append(urwid.Divider())
     rows.append(button_columns)
     pile = urwid.Pile(rows)
     fill = urwid.Filler(pile, valign='top')
     super(CherryPickDialog,
           self).__init__(urwid.LineBox(fill, 'Propose Change to Branch'))
Beispiel #2
0
 def __init__(self, app, context, oldnew, key=None, comment=u''):
     super(UnifiedDiffCommentEdit, self).__init__([])
     self.context = context
     self.oldnew = oldnew
     # If we save a comment, the resulting key will be stored here
     self.key = key
     self.comment = mywid.MyEdit(edit_text=comment, multiline=True,
                                 ring=app.ring)
     self.contents.append((urwid.Text(u''), ('given', 8, False)))
     self.contents.append((urwid.AttrMap(self.comment, 'draft-comment'),
                           ('weight', 1, False)))
     self.focus_position = 1
Beispiel #3
0
 def __init__(self,
              app,
              context,
              old_key=None,
              new_key=None,
              old=u'',
              new=u''):
     super(SideDiffCommentEdit, self).__init__([])
     self.app = app
     self.context = context
     # If we save a comment, the resulting key will be stored here
     self.old_key = old_key
     self.new_key = new_key
     self.old = mywid.MyEdit(edit_text=old, multiline=True, ring=app.ring)
     self.new = mywid.MyEdit(edit_text=new, multiline=True, ring=app.ring)
     self.contents.append((urwid.Text(u''), ('given', LN_COL_WIDTH, False)))
     if context.old_file_key and (context.old_ln is not None
                                  or context.header):
         self.contents.append(
             (urwid.AttrMap(self.old,
                            'draft-comment'), ('weight', 1, False)))
     else:
         self.contents.append((urwid.Text(u''), ('weight', 1, False)))
     self.contents.append((urwid.Text(u''), ('given', LN_COL_WIDTH, False)))
     if context.new_file_key and (context.new_ln is not None
                                  or context.header):
         self.contents.append(
             (urwid.AttrMap(self.new,
                            'draft-comment'), ('weight', 1, False)))
         new_editable = True
     else:
         self.contents.append((urwid.Text(u''), ('weight', 1, False)))
         new_editable = False
     if new_editable:
         self.focus_position = 3
     else:
         self.focus_position = 1
Beispiel #4
0
    def __init__(self, app, revision_key):
        self.revision_key = revision_key
        self.app = app
        save_button = mywid.FixedButton(u'Save')
        submit_button = mywid.FixedButton(u'Save and Submit')
        cancel_button = mywid.FixedButton(u'Cancel')
        urwid.connect_signal(save_button, 'click',
                             lambda button: self._emit('save'))
        urwid.connect_signal(submit_button, 'click',
                             lambda button: self._emit('submit'))
        urwid.connect_signal(cancel_button, 'click',
                             lambda button: self._emit('cancel'))

        rows = []
        categories = []
        values = {}
        descriptions = {}
        self.button_groups = {}
        message = ''
        with self.app.db.getSession() as session:
            revision = session.getRevision(self.revision_key)
            change = revision.change
            buttons = [('pack', save_button)]
            if revision.can_submit:
                buttons.append(('pack', submit_button))
            buttons.append(('pack', cancel_button))
            buttons = urwid.Columns(buttons, dividechars=2)
            if revision == change.revisions[-1]:
                for label in change.labels:
                    d = descriptions.setdefault(label.category, {})
                    d[label.value] = label.description
                    vmin = d.setdefault('min', label.value)
                    if label.value < vmin:
                        d['min'] = label.value
                    vmax = d.setdefault('max', label.value)
                    if label.value > vmax:
                        d['max'] = label.value
                for label in change.permitted_labels:
                    if label.category not in categories:
                        categories.append(label.category)
                        values[label.category] = []
                    values[label.category].append(label.value)
                draft_approvals = {}
                for approval in change.draft_approvals:
                    draft_approvals[approval.category] = approval
                for category in categories:
                    rows.append(urwid.Text(category))
                    group = []
                    self.button_groups[category] = group
                    current = draft_approvals.get(category)
                    if current is None:
                        current = 0
                    else:
                        current = current.value
                    for value in sorted(values[category], reverse=True):
                        if value > 0:
                            strvalue = '+%s' % value
                        elif value == 0:
                            strvalue = ' 0'
                        else:
                            strvalue = str(value)
                        strvalue += '  ' + descriptions[category][value]
                        b = urwid.RadioButton(group,
                                              strvalue,
                                              state=(value == current))
                        b._value = value
                        if value > 0:
                            if value == descriptions[category]['max']:
                                b = urwid.AttrMap(b, 'max-label')
                            else:
                                b = urwid.AttrMap(b, 'positive-label')
                        elif value < 0:
                            if value == descriptions[category]['min']:
                                b = urwid.AttrMap(b, 'min-label')
                            else:
                                b = urwid.AttrMap(b, 'negative-label')
                        rows.append(b)
                    rows.append(urwid.Divider())
            m = revision.getPendingMessage()
            if not m:
                m = revision.getDraftMessage()
            if m:
                message = m.message
        self.message = mywid.MyEdit("Message: \n",
                                    edit_text=message,
                                    multiline=True,
                                    ring=app.ring)
        rows.append(self.message)
        rows.append(urwid.Divider())
        rows.append(buttons)
        pile = urwid.Pile(rows)
        fill = urwid.Filler(pile, valign='top')
        super(ReviewDialog, self).__init__(urwid.LineBox(fill, 'Review'))