Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
378ce590
by Tony Chemit at 2022-10-17T13:59:11+02:00
-
f773b97b
by Tony Chemit at 2022-10-17T13:59:11+02:00
-
ae528a49
by Tony Chemit at 2022-10-17T13:59:11+02:00
8 changed files:
- client/core/src/main/java/fr/ird/observe/client/datasource/validation/ContentMessageTableModel.java
- client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/observation/SetDetailCompositionUIHandler.java
- client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/observation/composition/LonglineCompositionTableModel.java
- client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/observation/composition/section/SectionTableModel.java
- + client/datasource/editor/ps/.mvn/i18n/parse-validation-messages
- + client/datasource/editor/ps/src/main/i18n/getters/validation-messages.getter
- + client/datasource/editor/ps/src/main/resources/fr/ird/observe/dto/data/ps/dcp/FloatingObjectPreset-create-error-validation.xml
- core/api/validation/src/main/filtered-resources/fr/ird/observe/dto/data/ps/dcp/FloatingObjectPreset-create-warning-validation.xml → client/datasource/editor/ps/src/main/resources/fr/ird/observe/dto/data/ps/dcp/FloatingObjectPreset-create-warning-validation.xml
Changes:
| ... | ... | @@ -23,14 +23,10 @@ package fr.ird.observe.client.datasource.validation; |
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | 25 | import org.nuiton.jaxx.validator.swing.SwingValidator;
|
| 26 | -import org.nuiton.jaxx.validator.swing.SwingValidatorMessage;
|
|
| 27 | 26 | import org.nuiton.jaxx.validator.swing.SwingValidatorMessageTableModel;
|
| 28 | 27 | import org.nuiton.validator.NuitonValidatorScope;
|
| 29 | 28 | |
| 30 | 29 | import javax.swing.JComponent;
|
| 31 | -import java.util.Collection;
|
|
| 32 | -import java.util.Collections;
|
|
| 33 | -import java.util.function.Predicate;
|
|
| 34 | 30 | |
| 35 | 31 | /**
|
| 36 | 32 | * Created on 07/12/2020.
|
| ... | ... | @@ -75,23 +71,4 @@ public class ContentMessageTableModel extends SwingValidatorMessageTableModel { |
| 75 | 71 | super.removeMessages(editor, scope);
|
| 76 | 72 | }
|
| 77 | 73 | }
|
| 78 | - |
|
| 79 | - public void removeMessages(Predicate<SwingValidatorMessage> predicate) {
|
|
| 80 | - for (int i = getRowCount() - 1; i > -1; i--) {
|
|
| 81 | - SwingValidatorMessage error = data.get(i);
|
|
| 82 | - if (predicate.test(error)) {
|
|
| 83 | - // remove the message
|
|
| 84 | - data.remove(i);
|
|
| 85 | - fireTableRowsDeleted(i, i);
|
|
| 86 | - }
|
|
| 87 | - }
|
|
| 88 | - }
|
|
| 89 | - |
|
| 90 | - public <M extends SwingValidatorMessage> void addMessages(Collection<M> messages) {
|
|
| 91 | - data.addAll(messages);
|
|
| 92 | - // resort datas
|
|
| 93 | - Collections.sort(data);
|
|
| 94 | - // notify
|
|
| 95 | - fireTableDataChanged();
|
|
| 96 | - }
|
|
| 97 | 74 | } |
| ... | ... | @@ -37,7 +37,6 @@ import fr.ird.observe.dto.data.ll.observation.SectionTemplateDto; |
| 37 | 37 | import fr.ird.observe.dto.data.ll.observation.SetDetailCompositionDto;
|
| 38 | 38 | import fr.ird.observe.dto.form.Form;
|
| 39 | 39 | import io.ultreia.java4all.i18n.I18n;
|
| 40 | -import io.ultreia.java4all.jaxx.widgets.combobox.FilterableComboBox;
|
|
| 41 | 40 | import io.ultreia.java4all.lang.Strings;
|
| 42 | 41 | import org.apache.logging.log4j.LogManager;
|
| 43 | 42 | import org.apache.logging.log4j.Logger;
|
| ... | ... | @@ -273,11 +272,10 @@ public class SetDetailCompositionUIHandler extends GeneratedSetDetailComposition |
| 273 | 272 | if (previousIndex == 0) {
|
| 274 | 273 | if (getModel().getStates().isCanGenerate()) {
|
| 275 | 274 | // update section templates list
|
| 276 | - List<SectionTemplateDto> sectionTemplates = getModel().getStates().getSectionTemplatesTableModel().getNotEmptyData();
|
|
| 277 | - @SuppressWarnings("unchecked") FilterableComboBox<SectionTemplateDto> comboBox = (FilterableComboBox<SectionTemplateDto>) getUi().getSectionsTable().getClientProperty(SECTION_TEMPLATES_EDITOR);
|
|
| 278 | - comboBox.setData(sectionTemplates);
|
|
| 279 | - //2014-FIXME See why templates are not well reselect in cell editor
|
|
| 280 | - //2014-FIXME See cell editor does not loose focus and empty selection when losing focus
|
|
| 275 | + List<SectionTemplateDto> sectionTemplates = getModel().getStates().getSectionTemplatesTableModel().getValidData();
|
|
| 276 | + getModel().getStates().getSectionsTableModel().setSectionTemplates(sectionTemplates.isEmpty() ? null : sectionTemplates);
|
|
| 277 | + } else {
|
|
| 278 | + getModel().getStates().getSectionsTableModel().setSectionTemplates(null);
|
|
| 281 | 279 | }
|
| 282 | 280 | }
|
| 283 | 281 | break;
|
| ... | ... | @@ -129,10 +129,6 @@ public abstract class LonglineCompositionTableModel<D extends ObserveDto & JavaB |
| 129 | 129 | return model.getStates().isGenerateHaulingIds();
|
| 130 | 130 | }
|
| 131 | 131 | |
| 132 | - protected boolean isCanGenerate() {
|
|
| 133 | - return model.getStates().isCanGenerate();
|
|
| 134 | - }
|
|
| 135 | - |
|
| 136 | 132 | @Override
|
| 137 | 133 | public void fireTableDataChanged() {
|
| 138 | 134 | // rearrange ids when data has changed
|
| ... | ... | @@ -29,16 +29,20 @@ import fr.ird.observe.client.datasource.editor.ll.data.observation.composition.b |
| 29 | 29 | import fr.ird.observe.dto.data.ll.observation.BasketDto;
|
| 30 | 30 | import fr.ird.observe.dto.data.ll.observation.SectionDto;
|
| 31 | 31 | import fr.ird.observe.dto.data.ll.observation.SectionTemplateDto;
|
| 32 | +import io.ultreia.java4all.jaxx.widgets.combobox.FilterableComboBox;
|
|
| 33 | +import io.ultreia.java4all.jaxx.widgets.combobox.FilterableComboBoxCellEditor;
|
|
| 32 | 34 | import org.apache.logging.log4j.LogManager;
|
| 33 | 35 | import org.apache.logging.log4j.Logger;
|
| 34 | 36 | |
| 35 | 37 | import javax.swing.event.TableModelListener;
|
| 36 | 38 | import java.beans.PropertyChangeListener;
|
| 37 | 39 | import java.util.ArrayList;
|
| 40 | +import java.util.Collections;
|
|
| 38 | 41 | import java.util.Date;
|
| 39 | 42 | import java.util.LinkedHashSet;
|
| 40 | 43 | import java.util.List;
|
| 41 | 44 | import java.util.Objects;
|
| 45 | +import java.util.stream.Collectors;
|
|
| 42 | 46 | |
| 43 | 47 | /**
|
| 44 | 48 | * Created on 12/11/14.
|
| ... | ... | @@ -53,6 +57,14 @@ public class SectionTableModel extends LonglineCompositionTableModel<SectionDto> |
| 53 | 57 | private static final Logger log = LogManager.getLogger(SectionTableModel.class);
|
| 54 | 58 | private FilterableComboBoxCellEditor sectionTemplateEditor;
|
| 55 | 59 | private SetDetailCompositionUIValidationHelper validationHelper;
|
| 60 | + /**
|
|
| 61 | + * All section templates available (may be changed when selecting another section (to just get the possible compliant one (matching basket count)
|
|
| 62 | + */
|
|
| 63 | + private List<SectionTemplateDto> sectionTemplates;
|
|
| 64 | + /**
|
|
| 65 | + * Available section templates for the selected section (all are compliant with the section basket count)
|
|
| 66 | + */
|
|
| 67 | + private List<SectionTemplateDto> availableSectionTemplates;
|
|
| 56 | 68 | |
| 57 | 69 | public SectionTableModel(SetDetailCompositionUIModel model) {
|
| 58 | 70 | super(model);
|
| ... | ... | @@ -150,7 +162,7 @@ public class SectionTableModel extends LonglineCompositionTableModel<SectionDto> |
| 150 | 162 | break;
|
| 151 | 163 | case 2:
|
| 152 | 164 | // can change template if in generate mode
|
| 153 | - result = isCanGenerate();
|
|
| 165 | + result = isCanUseTemplate();
|
|
| 154 | 166 | break;
|
| 155 | 167 | default:
|
| 156 | 168 | throw new IllegalStateException("Can't come here");
|
| ... | ... | @@ -159,6 +171,10 @@ public class SectionTableModel extends LonglineCompositionTableModel<SectionDto> |
| 159 | 171 | return result;
|
| 160 | 172 | }
|
| 161 | 173 | |
| 174 | + protected boolean isCanUseTemplate() {
|
|
| 175 | + return getModel().getStates().isCanGenerate() && availableSectionTemplates != null && !availableSectionTemplates.isEmpty();
|
|
| 176 | + }
|
|
| 177 | + |
|
| 162 | 178 | public void init() {
|
| 163 | 179 | validationHelper = getModel().getStates().getValidationHelper();
|
| 164 | 180 | PropertyChangeListener selectedSectionChanged = evt -> {
|
| ... | ... | @@ -228,6 +244,7 @@ public class SectionTableModel extends LonglineCompositionTableModel<SectionDto> |
| 228 | 244 | } finally {
|
| 229 | 245 | validationHelper.setObjectValueAdjusting(false);
|
| 230 | 246 | }
|
| 247 | + initSectionTemplates(newSection);
|
|
| 231 | 248 | }
|
| 232 | 249 | |
| 233 | 250 | public void setSectionTemplateEditor(FilterableComboBoxCellEditor sectionTemplateEditor) {
|
| ... | ... | @@ -265,4 +282,25 @@ public class SectionTableModel extends LonglineCompositionTableModel<SectionDto> |
| 265 | 282 | validationHelper.whenBasketChanged();
|
| 266 | 283 | }
|
| 267 | 284 | }
|
| 285 | + |
|
| 286 | + public void setSectionTemplates(List<SectionTemplateDto> sectionTemplates) {
|
|
| 287 | + this.sectionTemplates = sectionTemplates;
|
|
| 288 | + SectionDto selectedRow = getSelectedRow();
|
|
| 289 | + initSectionTemplates(selectedRow);
|
|
| 290 | + }
|
|
| 291 | + |
|
| 292 | + private void initSectionTemplates(SectionDto section) {
|
|
| 293 | + if (sectionTemplates != null) {
|
|
| 294 | + if (section == null) {
|
|
| 295 | + availableSectionTemplates = Collections.emptyList();
|
|
| 296 | + } else {
|
|
| 297 | + int basketSize = section.getBasketSize();
|
|
| 298 | + availableSectionTemplates = sectionTemplates.stream().filter(t -> t.isCompliantWithBasketCount(basketSize)).collect(Collectors.toList());
|
|
| 299 | + }
|
|
| 300 | + @SuppressWarnings("unchecked") FilterableComboBox<SectionTemplateDto> comboBox = (FilterableComboBox<SectionTemplateDto>) sectionTemplateEditor.getComponent();
|
|
| 301 | + comboBox.setData(availableSectionTemplates);
|
|
| 302 | + //2014-FIXME See why templates are not well reselect in cell editor
|
|
| 303 | + //2014-FIXME See cell editor does not loose focus and empty selection when losing focus
|
|
| 304 | + }
|
|
| 305 | + }
|
|
| 268 | 306 | } |
| 1 | +observe.data.ps.logbook.Route.validation.date.after.currentPsCommonTrip.startDate
|
|
| 2 | +observe.data.ps.logbook.Route.validation.date.before.currentPsCommonTrip.endDate
|
|
| 3 | +observe.referential.Referential.validation.label1.untranslated
|
|
| 4 | +observe.referential.Referential.validation.label3.untranslated |
| 1 | +<?xml version="1.0" encoding="UTF-8"?>
|
|
| 2 | +<!--
|
|
| 3 | + #%L
|
|
| 4 | + ObServe Client :: DataSource :: Editor :: PS
|
|
| 5 | + %%
|
|
| 6 | + Copyright (C) 2008 - 2022 IRD, Ultreia.io
|
|
| 7 | + %%
|
|
| 8 | + This program is free software: you can redistribute it and/or modify
|
|
| 9 | + it under the terms of the GNU General Public License as
|
|
| 10 | + published by the Free Software Foundation, either version 3 of the
|
|
| 11 | + License, or (at your option) any later version.
|
|
| 12 | + |
|
| 13 | + This program is distributed in the hope that it will be useful,
|
|
| 14 | + but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 15 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 16 | + GNU General Public License for more details.
|
|
| 17 | + |
|
| 18 | + You should have received a copy of the GNU General Public
|
|
| 19 | + License along with this program. If not, see
|
|
| 20 | + <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 21 | + #L%
|
|
| 22 | + -->
|
|
| 23 | + |
|
| 24 | +<!DOCTYPE validators PUBLIC
|
|
| 25 | + "-//Apache Struts//XWork Validator 1.0.3//EN"
|
|
| 26 | + "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
|
|
| 27 | +<validators>
|
|
| 28 | + <field name="label1">
|
|
| 29 | + <field-validator type="mandatoryString" short-circuit="true">
|
|
| 30 | + <message/>
|
|
| 31 | + </field-validator>
|
|
| 32 | + </field>
|
|
| 33 | + <field name="label2">
|
|
| 34 | + <field-validator type="mandatoryString" short-circuit="true">
|
|
| 35 | + <message/>
|
|
| 36 | + </field-validator>
|
|
| 37 | + </field>
|
|
| 38 | + <field name="label3">
|
|
| 39 | + <field-validator type="mandatoryString" short-circuit="true">
|
|
| 40 | + <message/>
|
|
| 41 | + </field-validator>
|
|
| 42 | + </field>
|
|
| 43 | +</validators> |
| 1 | 1 | <?xml version="1.0" encoding="UTF-8"?>
|
| 2 | 2 | <!--
|
| 3 | 3 | #%L
|
| 4 | - ObServe Core :: API :: Validation
|
|
| 4 | + ObServe Client :: DataSource :: Editor :: PS
|
|
| 5 | 5 | %%
|
| 6 | 6 | Copyright (C) 2008 - 2022 IRD, Ultreia.io
|
| 7 | 7 | %%
|
| 8 | 8 | This program is free software: you can redistribute it and/or modify
|
| 9 | 9 | it under the terms of the GNU General Public License as
|
| 10 | 10 | published by the Free Software Foundation, either version 3 of the
|
| 11 | - License, or (at your option) any later version. This program is distributed in the hope that it will be useful,
|
|
| 11 | + License, or (at your option) any later version.
|
|
| 12 | + |
|
| 13 | + This program is distributed in the hope that it will be useful,
|
|
| 12 | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 | - GNU General Public License for more details. You should have received a copy of the GNU General Public
|
|
| 16 | + GNU General Public License for more details.
|
|
| 17 | + |
|
| 18 | + You should have received a copy of the GNU General Public
|
|
| 15 | 19 | License along with this program. If not, see
|
| 16 | 20 | <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| 17 | 21 | #L%
|
| 18 | - --><!DOCTYPE validators PUBLIC
|
|
| 22 | + -->
|
|
| 23 | + |
|
| 24 | +<!DOCTYPE validators PUBLIC
|
|
| 19 | 25 | "-//Apache Struts//XWork Validator 1.0.3//EN"
|
| 20 | 26 | "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
|
| 21 | 27 | <validators>
|