lexonomy_custom_editor/src/message/show_messages.py

79 lines
2.6 KiB
Python

from message.message import Message
from message.translation_edit import AddTranslation, EditTranslation
from message.simple_messages import ClickMessage
from model import Example, Sense, Translation
from view import modals
class ShowSenseLabelEdit(ClickMessage):
def update_model(self, model):
model.sense = self.get_arg(0, Sense)
model.sense.make_copy()
model.modal_set(lambda: modals.edit_sense_label(model.sense))
class ShowSenseDefinitionEdit(ClickMessage):
def update_model(self, model):
model.sense = self.get_arg(0, Sense)
model.modal_set(lambda: modals.edit_sense_definition(model.sense))
class ShowCommentEdit(ClickMessage):
def update_model(self, model):
model.modal_set(lambda: modals.edit_comment(model.entry.comment))
class ShowVariantsEdit(ClickMessage):
def update_model(self, model):
model.entry.make_copy()
model.modal_set(lambda: modals.edit_variants(model.entry))
class ShowRelatedEntriesEdit(ClickMessage):
def update_model(self, model):
model.entry.make_copy()
model.modal_set(lambda: modals.edit_related_entries(model.entry))
class ShowExampleEdit(ClickMessage):
def update_model(self, model):
example = self.get_arg(0, Example)
sense = self.get_arg(1, Sense)
example.make_copy()
model.modal_set(lambda: modals.edit_example(example, sense))
class ShowEditTranslation(ClickMessage):
def update_model(self, model):
translation = self.get_arg(0, Translation)
# Get translation location
(cidx, idx), (parent, cluster) = EditTranslation.get_translation_location(model.entry, translation)
translation.make_copy()
num_clusters = len(parent.translations)
model.modal_set(lambda: modals.edit_translation(
translation, cidx, num_clusters, (EditTranslation, translation, cidx)))
class ShowAddTranslation(ClickMessage):
def update_model(self, model):
chosen_sense_or_example = self.get_arg(0)
translation = Translation()
translation.make_copy()
model.modal_set(lambda: modals.edit_translation(
translation,
-1,
len(chosen_sense_or_example.translations),
(AddTranslation, translation, -1, chosen_sense_or_example)))
class ShowEntryLabelsEdit(ClickMessage):
def update_model(self, model):
model.entry.make_copy()
model.modal_set(lambda: modals.edit_entry_labels(model.entry))