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);
});
}
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");
}
}
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");
}
}
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));
}
Aggregations