Search in sources :

Example 1 with RulesWidgetRequestedEvent

use of org.archcnl.ui.inputview.rulesormappingeditorview.events.RulesWidgetRequestedEvent in project ArchCNL by Mari-Wie.

the class RuleCreatorView method initializeLayout.

private void initializeLayout(Optional<String> ruleString) {
    subject = new SubjectComponent();
    subject.addListener(RelationListUpdateRequestedEvent.class, this::fireEvent);
    subject.addListener(ConceptListUpdateRequestedEvent.class, this::fireEvent);
    subject.addListener(DetermineStatementComponentEvent.class, event -> verb.determineVerbComponent(event.getSource().getFirstModifierValue()));
    verb = new StatementComponent();
    verb.addListener(RelationListUpdateRequestedEvent.class, this::fireEvent);
    verb.addListener(ConceptListUpdateRequestedEvent.class, this::fireEvent);
    buttonsLayout = new HorizontalLayout();
    saveButton = new Button("Save Rule", e -> saveRule());
    cancelButton = new Button("Cancel", click -> fireEvent(new RulesWidgetRequestedEvent(this, true)));
    expertmodeCheckbox = new Checkbox("Activate Expertmode");
    expertmodeCheckbox.addClickListener(e -> activateExpertMode(expertmodeCheckbox.getValue()));
    buttonsLayout.setVerticalComponentAlignment(Alignment.CENTER, expertmodeCheckbox);
    buttonsLayout.setPadding(true);
    buttonsLayout.add(saveButton, cancelButton, expertmodeCheckbox);
    archRuleTextArea = new TextArea("Create new architecture rule");
    archRuleTextArea.setWidthFull();
    add(subject, verb, buttonsLayout);
    ruleString.ifPresent(rule -> {
        archRuleTextArea.setValue(rule);
        expertmodeCheckbox.setValue(true);
        activateExpertMode(true);
    });
}
Also used : ComponentEventListener(com.vaadin.flow.component.ComponentEventListener) ConceptListUpdateRequestedEvent(org.archcnl.ui.common.andtriplets.triplet.events.ConceptListUpdateRequestedEvent) RulesWidgetRequestedEvent(org.archcnl.ui.inputview.rulesormappingeditorview.events.RulesWidgetRequestedEvent) TextArea(com.vaadin.flow.component.textfield.TextArea) Registration(com.vaadin.flow.shared.Registration) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) StatementComponent(org.archcnl.ui.inputview.rulesormappingeditorview.architectureruleeditor.components.verbcomponents.StatementComponent) SubjectComponent(org.archcnl.ui.inputview.rulesormappingeditorview.architectureruleeditor.components.subjectcomponents.SubjectComponent) ComponentEvent(com.vaadin.flow.component.ComponentEvent) RelationListUpdateRequestedEvent(org.archcnl.ui.common.andtriplets.triplet.events.RelationListUpdateRequestedEvent) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) Button(com.vaadin.flow.component.button.Button) DetermineStatementComponentEvent(org.archcnl.ui.inputview.rulesormappingeditorview.architectureruleeditor.events.DetermineStatementComponentEvent) SaveRuleButtonPressedEvent(org.archcnl.ui.inputview.rulesormappingeditorview.architectureruleeditor.events.SaveRuleButtonPressedEvent) RulesOrMappingEditorView(org.archcnl.ui.inputview.rulesormappingeditorview.RulesOrMappingEditorView) Optional(java.util.Optional) Button(com.vaadin.flow.component.button.Button) TextArea(com.vaadin.flow.component.textfield.TextArea) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) SubjectComponent(org.archcnl.ui.inputview.rulesormappingeditorview.architectureruleeditor.components.subjectcomponents.SubjectComponent) RulesWidgetRequestedEvent(org.archcnl.ui.inputview.rulesormappingeditorview.events.RulesWidgetRequestedEvent) StatementComponent(org.archcnl.ui.inputview.rulesormappingeditorview.architectureruleeditor.components.verbcomponents.StatementComponent) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 2 with RulesWidgetRequestedEvent

use of org.archcnl.ui.inputview.rulesormappingeditorview.events.RulesWidgetRequestedEvent in project ArchCNL by Mari-Wie.

the class ConceptEditorPresenter method updateMapping.

@Override
protected void updateMapping() {
    if (concept.isPresent()) {
        try {
            concept.get().setDescription(view.getDescription());
            final ConceptMapping mapping = new ConceptMapping(view.getThenTripletSubject(), getAndTripletsList(), concept.get());
            concept.get().setMapping(mapping);
            fireEvent(new AddCustomConceptRequestedEvent(this, true, concept.get()));
            fireEvent(new RulesWidgetRequestedEvent(this, true));
        } catch (UnrelatedMappingException e) {
            // not possible/fatal
            throw new RuntimeException(e.getMessage());
        } catch (final SubjectOrObjectNotDefinedException e) {
            view.showThenSubjectErrorMessage("Setting a subject is required");
        }
    } else {
        view.showNameFieldErrorMessage("A name is required");
    }
}
Also used : UnrelatedMappingException(org.archcnl.domain.common.exceptions.UnrelatedMappingException) AddCustomConceptRequestedEvent(org.archcnl.ui.inputview.rulesormappingeditorview.mappingeditor.concepteditor.events.AddCustomConceptRequestedEvent) SubjectOrObjectNotDefinedException(org.archcnl.ui.common.andtriplets.triplet.exceptions.SubjectOrObjectNotDefinedException) RulesWidgetRequestedEvent(org.archcnl.ui.inputview.rulesormappingeditorview.events.RulesWidgetRequestedEvent) ConceptMapping(org.archcnl.domain.input.model.mappings.ConceptMapping)

Example 3 with RulesWidgetRequestedEvent

use of org.archcnl.ui.inputview.rulesormappingeditorview.events.RulesWidgetRequestedEvent in project ArchCNL by Mari-Wie.

the class RelationEditorPresenter method updateMapping.

@Override
protected void updateMapping() {
    if (relation.isPresent()) {
        try {
            relation.get().setDescription(view.getDescription());
            final Triplet thenTriplet = new Triplet(view.getThenTripletSubject(), relation.get(), view.getThenTripletObject());
            final RelationMapping mapping = new RelationMapping(thenTriplet, getAndTripletsList());
            fireEvent(new AddCustomRelationRequestedEvent(this, true, relation.get(), mapping));
            fireEvent(new RulesWidgetRequestedEvent(this, true));
        } catch (final SubjectOrObjectNotDefinedException e) {
            view.showThenSubjectOrObjectErrorMessage("Setting this is required");
        }
    } else {
        view.showNameFieldErrorMessage("A name is required");
    }
}
Also used : RelationMapping(org.archcnl.domain.input.model.mappings.RelationMapping) Triplet(org.archcnl.domain.common.conceptsandrelations.andtriplets.triplet.Triplet) AddCustomRelationRequestedEvent(org.archcnl.ui.inputview.rulesormappingeditorview.mappingeditor.relationeditor.events.AddCustomRelationRequestedEvent) SubjectOrObjectNotDefinedException(org.archcnl.ui.common.andtriplets.triplet.exceptions.SubjectOrObjectNotDefinedException) RulesWidgetRequestedEvent(org.archcnl.ui.inputview.rulesormappingeditorview.events.RulesWidgetRequestedEvent)

Example 4 with RulesWidgetRequestedEvent

use of org.archcnl.ui.inputview.rulesormappingeditorview.events.RulesWidgetRequestedEvent in project ArchCNL by Mari-Wie.

the class RuleCreatorView method saveRule.

private void saveRule() {
    if (!archRuleTextArea.isEmpty()) {
        fireEvent(new SaveRuleButtonPressedEvent(this, true, createTextareaRule(archRuleTextArea.getValue())));
        fireEvent(new RulesWidgetRequestedEvent(this, true));
        return;
    }
    fireEvent(new SaveRuleButtonPressedEvent(this, true, (subject.getRuleString() + verb.getRuleString().stripTrailing() + ".")));
    fireEvent(new RulesWidgetRequestedEvent(this, true));
}
Also used : SaveRuleButtonPressedEvent(org.archcnl.ui.inputview.rulesormappingeditorview.architectureruleeditor.events.SaveRuleButtonPressedEvent) RulesWidgetRequestedEvent(org.archcnl.ui.inputview.rulesormappingeditorview.events.RulesWidgetRequestedEvent)

Aggregations

RulesWidgetRequestedEvent (org.archcnl.ui.inputview.rulesormappingeditorview.events.RulesWidgetRequestedEvent)4 SubjectOrObjectNotDefinedException (org.archcnl.ui.common.andtriplets.triplet.exceptions.SubjectOrObjectNotDefinedException)2 SaveRuleButtonPressedEvent (org.archcnl.ui.inputview.rulesormappingeditorview.architectureruleeditor.events.SaveRuleButtonPressedEvent)2 ComponentEvent (com.vaadin.flow.component.ComponentEvent)1 ComponentEventListener (com.vaadin.flow.component.ComponentEventListener)1 Button (com.vaadin.flow.component.button.Button)1 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)1 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)1 TextArea (com.vaadin.flow.component.textfield.TextArea)1 Registration (com.vaadin.flow.shared.Registration)1 Optional (java.util.Optional)1 Triplet (org.archcnl.domain.common.conceptsandrelations.andtriplets.triplet.Triplet)1 UnrelatedMappingException (org.archcnl.domain.common.exceptions.UnrelatedMappingException)1 ConceptMapping (org.archcnl.domain.input.model.mappings.ConceptMapping)1 RelationMapping (org.archcnl.domain.input.model.mappings.RelationMapping)1 ConceptListUpdateRequestedEvent (org.archcnl.ui.common.andtriplets.triplet.events.ConceptListUpdateRequestedEvent)1 RelationListUpdateRequestedEvent (org.archcnl.ui.common.andtriplets.triplet.events.RelationListUpdateRequestedEvent)1 RulesOrMappingEditorView (org.archcnl.ui.inputview.rulesormappingeditorview.RulesOrMappingEditorView)1 SubjectComponent (org.archcnl.ui.inputview.rulesormappingeditorview.architectureruleeditor.components.subjectcomponents.SubjectComponent)1 StatementComponent (org.archcnl.ui.inputview.rulesormappingeditorview.architectureruleeditor.components.verbcomponents.StatementComponent)1