This is an automated email from the git hooks/post-receive script. New commit to branch feature/7614 in repository observe. See http://git.codelutin.com/observe.git commit 5cb90e690f27b086b8ebda25b133d6e302492917 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Fri Oct 23 09:43:56 2015 +0200 migration de la composition globale de la ligne (refs #7614) --- .../impl/longline/LonglineGlobalCompositionUI.css | 6 +- .../impl/longline/LonglineGlobalCompositionUI.jaxx | 11 +-- .../LonglineGlobalCompositionUIHandler.java | 92 ++++++++++++--------- .../longline/LonglineGlobalCompositionUIModel.java | 6 +- .../table/impl/longline/BaitsCompositionUI.css | 2 +- .../table/impl/longline/BaitsCompositionUI.jaxx | 4 +- .../impl/longline/BaitsCompositionUIHandler.java | 31 ++----- .../impl/longline/BaitsCompositionUIModel.java | 38 +++++---- .../impl/longline/BranchlinesCompositionUI.css | 3 +- .../impl/longline/BranchlinesCompositionUI.jaxx | 4 +- .../longline/BranchlinesCompositionUIHandler.java | 45 ++++------ .../longline/BranchlinesCompositionUIModel.java | 25 +++++- .../impl/longline/FloatlinesCompositionUI.css | 2 +- .../impl/longline/FloatlinesCompositionUI.jaxx | 17 ++-- .../longline/FloatlinesCompositionUIHandler.java | 50 ++++------- .../longline/FloatlinesCompositionUIModel.java | 34 ++++++-- .../table/impl/longline/HooksCompositionUI.css | 3 +- .../table/impl/longline/HooksCompositionUI.jaxx | 23 +++--- .../impl/longline/HooksCompositionUIHandler.java | 51 ++++-------- .../impl/longline/HooksCompositionUIModel.java | 34 ++++++-- ...LonglineGlobalCompositionServiceController.java | 3 +- .../SetLonglineGlobalCompositionService.java | 3 +- .../longline/SetLonglineGlobalCompositionDto.java | 90 ++++++++++++++++++++ .../main/xmi/observe-services-dto-longline.zargo | Bin 63139 -> 63218 bytes .../services/dto/ObserveDtosInitializer.java | 1 + .../SetLonglineGlobalCompositionServiceTopia.java | 6 +- 26 files changed, 343 insertions(+), 241 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUI.css b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUI.css index 20825f8..bd7fb4a 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUI.css +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUI.css @@ -53,10 +53,8 @@ #mitigationType { bean:{bean}; - //FIXME - //property: {SetLonglineDto.PROPERTY_MITIGATION_TYPE}; - //FIXME - //selected:{bean.getMitigationType()}; + property: {SetLonglineGlobalCompositionDto.PROPERTY_MITIGATION_TYPE}; + selected:{bean.getMitigationType()}; _validatorLabel: {t("observe.longlineGlobalComposition.mitigationType")}; showListLabel: true; universeLabel:{t("observe.longlineGlobalComposition.availableMitigationType")}; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUI.jaxx index eb9c810..c017aa1 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUI.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUI.jaxx @@ -20,13 +20,14 @@ #L% --> -<fr.ird.observe.ui.content.ContentUI superGenericType='SetLonglineDto' +<fr.ird.observe.ui.content.ContentUI superGenericType='SetLonglineGlobalCompositionDto' contentTitle='{n("observe.longlineGlobalComposition.title")}'> <import> fr.ird.observe.ObserveSwingApplicationContext fr.ird.observe.services.dto.CommentableDto - fr.ird.observe.services.dto.longline.SetLonglineDto + fr.ird.observe.services.dto.referential.ReferentialReferenceDto + fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto fr.ird.observe.services.dto.referential.longline.MitigationTypeDto fr.ird.observe.ui.actions.shared.ResetEditUIAction fr.ird.observe.ui.actions.shared.SaveEditUIAction @@ -58,10 +59,10 @@ <LonglineGlobalCompositionUIModel id='model'/> <!-- edit bean --> - <SetLonglineDto id='bean'/> + <SetLonglineGlobalCompositionDto id='bean'/> <!-- validator --> - <BeanValidator id='validator' autoField='true' beanClass='fr.ird.observe.services.dto.longline.SetLonglineDto' + <BeanValidator id='validator' autoField='true' beanClass='fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto' errorTableModel='{getErrorTableModel()}' context='n1-update-globalComposition'> </BeanValidator> @@ -112,7 +113,7 @@ <Table fill='both' constraints='BorderLayout.NORTH'> <row> <cell weighty="1" weightx="1"> - <FilterableDoubleList id='mitigationType' genericType='MitigationTypeDto'/> + <FilterableDoubleList id='mitigationType' genericType='ReferentialReferenceDto<MitigationTypeDto>' _entityClass='MitigationTypeDto.class'/> </cell> </row> </Table> diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUIHandler.java index 3f3d0b8..96833e2 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUIHandler.java @@ -22,17 +22,26 @@ package fr.ird.observe.ui.content.impl.longline; * #L% */ +import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.business.db.DataContext; import fr.ird.observe.business.db.constants.DataContextType; import fr.ird.observe.db.ObserveSwingDataSource; +import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.longline.ActivityLonglineDto; -import fr.ird.observe.services.dto.longline.SetLonglineDto; +import fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto; +import fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDtos; +import fr.ird.observe.services.dto.result.SaveResultDto; +import fr.ird.observe.services.service.longline.SetLonglineGlobalCompositionService; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.ContentUIHandler; import fr.ird.observe.ui.content.table.impl.longline.BaitsCompositionUI; +import fr.ird.observe.ui.content.table.impl.longline.BaitsCompositionUIModel; import fr.ird.observe.ui.content.table.impl.longline.BranchlinesCompositionUI; +import fr.ird.observe.ui.content.table.impl.longline.BranchlinesCompositionUIModel; import fr.ird.observe.ui.content.table.impl.longline.FloatlinesCompositionUI; +import fr.ird.observe.ui.content.table.impl.longline.FloatlinesCompositionUIModel; import fr.ird.observe.ui.content.table.impl.longline.HooksCompositionUI; +import fr.ird.observe.ui.content.table.impl.longline.HooksCompositionUIModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.validator.NuitonValidatorScope; @@ -45,7 +54,7 @@ import static org.nuiton.i18n.I18n.t; * @author Tony Chemit - chemit@codelutin.com * @since 3.8 */ -public class LonglineGlobalCompositionUIHandler extends ContentUIHandler<SetLonglineDto> { +public class LonglineGlobalCompositionUIHandler extends ContentUIHandler<SetLonglineGlobalCompositionDto> { /** Logger */ static private Log log = LogFactory.getLog(LonglineGlobalCompositionUIHandler.class); @@ -67,7 +76,9 @@ public class LonglineGlobalCompositionUIHandler extends ContentUIHandler<SetLong @Override protected ContentMode getContentMode(DataContext dataContext) { - if (dataContext.isSelectedOpen(ActivityLonglineDto.class)) { + String activityId = dataContext.getSelectedActivityLonglineId(); + + if (getOpenDataManager().isOpenActivityLongline(activityId)) { // l'activité est ouverte, mode édition return ContentMode.UPDATE; @@ -131,14 +142,10 @@ public class LonglineGlobalCompositionUIHandler extends ContentUIHandler<SetLong } ContentMode mode = computeContentMode(); - //FIXME -// DataService dataService = getDataService(); - - ObserveSwingDataSource source = getDataSource(); - // update mode - //FIXME -// dataService.loadEditEntity(source, setId, getLoadExecutor()); + FormDto<SetLonglineGlobalCompositionDto> formDto = getSetLonglineGlobalCompositionService().loadToEdit(setId); + getModel().setFormDto(formDto); + SetLonglineGlobalCompositionDtos.copySetLonglineGlobalCompositionDto(formDto.getForm(), getBean()); // utilisation du mode requis setContentMode(mode); @@ -149,26 +156,46 @@ public class LonglineGlobalCompositionUIHandler extends ContentUIHandler<SetLong { // open floatlinesComposition tab + FloatlinesCompositionUIModel floatlinesCompositionModel = getUi().getFloatlinesCompositionModel(); + floatlinesCompositionModel.setFormDto(formDto); + SetLonglineGlobalCompositionDtos.copySetLonglineGlobalCompositionDto(formDto.getForm(), floatlinesCompositionModel.getBean()); + FloatlinesCompositionUI compositionUI = getUi().getFloatlinesCompositionUI(); compositionUI.open(); + } { // open branchlinesComposition tab + BranchlinesCompositionUIModel branchlinesCompositionModel = getUi().getBranchlinesCompositionModel(); + branchlinesCompositionModel.setFormDto(formDto); + SetLonglineGlobalCompositionDtos.copySetLonglineGlobalCompositionDto(formDto.getForm(), branchlinesCompositionModel.getBean()); + BranchlinesCompositionUI compositionUI = getUi().getBranchlinesCompositionUI(); compositionUI.open(); + } { // open hooksComposition tab + HooksCompositionUIModel hooksCompositionModel = getUi().getHooksCompositionModel(); + hooksCompositionModel.setFormDto(formDto); + SetLonglineGlobalCompositionDtos.copySetLonglineGlobalCompositionDto(formDto.getForm(), hooksCompositionModel.getBean()); + HooksCompositionUI compositionUI = getUi().getHooksCompositionUI(); compositionUI.open(); + } { // open baitsComposition tab + BaitsCompositionUIModel baitsCompositionModel = getUi().getBaitsCompositionModel(); + baitsCompositionModel.setFormDto(formDto); + SetLonglineGlobalCompositionDtos.copySetLonglineGlobalCompositionDto(formDto.getForm(), baitsCompositionModel.getBean()); + BaitsCompositionUI compositionUI = getUi().getBaitsCompositionUI(); compositionUI.open(); + } } @@ -182,33 +209,20 @@ public class LonglineGlobalCompositionUIHandler extends ContentUIHandler<SetLong model.setModified(false); } - //FIXME -// @Override -// protected boolean doSave(SetLongline bean, -// DataService dataService, -// DataSource dataSource, -// TopiaEntityBinder<SetLongline> binder) throws Exception { -// -// dataService.update(dataSource, null, bean, getUpdateExecutor()); -// -// return true; -// } - - //FIXME -// @Override -// protected SetLongline onUpdate(TopiaContext tx, Object parentBean, SetLongline beanToSave) throws TopiaException { -// -// beanToSave.setComment(getBean().getComment()); -// beanToSave.clearMitigationType(); -// beanToSave.addAllMitigationType(getBean().getMitigationType()); -// -// getUi().getFloatlinesCompositionUI().getHandler().onUpdate(tx, parentBean, beanToSave); -// getUi().getBranchlinesCompositionUI().getHandler().onUpdate(tx, parentBean, beanToSave); -// getUi().getHooksCompositionUI().getHandler().onUpdate(tx, parentBean, beanToSave); -// getUi().getBaitsCompositionUI().getHandler().onUpdate(tx, parentBean, beanToSave); -// -// return beanToSave; -// } + @Override + protected boolean doSave(SetLonglineGlobalCompositionDto bean) throws Exception { + + bean.setFloatlinesComposition(getUi().getFloatlinesCompositionModel().getBean().getFloatlinesComposition()); + bean.setBranchlinesComposition(getUi().getBranchlinesCompositionModel().getBean().getBranchlinesComposition()); + bean.setHooksComposition(getUi().getHooksCompositionModel().getBean().getHooksComposition()); + bean.setBaitsComposition(getUi().getBaitsCompositionModel().getBean().getBaitsComposition()); + + SaveResultDto saveResult = getSetLonglineGlobalCompositionService().save(bean); + bean.setId(saveResult.getId()); + bean.setLastUpdate(saveResult.getLastUpdate()); + + return true; + } @Override protected void afterSave(boolean refresh) { @@ -220,4 +234,8 @@ public class LonglineGlobalCompositionUIHandler extends ContentUIHandler<SetLong getUi().getBaitsCompositionUI().getHandler().afterSave(refresh); } + protected SetLonglineGlobalCompositionService getSetLonglineGlobalCompositionService() { + return ObserveSwingApplicationContext.get().newService(SetLonglineGlobalCompositionService.class); + } + } \ No newline at end of file diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUIModel.java index 83418a5..4b1995d 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUIModel.java @@ -22,7 +22,7 @@ package fr.ird.observe.ui.content.impl.longline; * #L% */ -import fr.ird.observe.services.dto.longline.SetLonglineDto; +import fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto; import fr.ird.observe.ui.content.ContentUIModel; /** @@ -31,12 +31,12 @@ import fr.ird.observe.ui.content.ContentUIModel; * @author Tony Chemit - chemit@codelutin.com * @since 3.8 */ -public class LonglineGlobalCompositionUIModel extends ContentUIModel<SetLonglineDto> { +public class LonglineGlobalCompositionUIModel extends ContentUIModel<SetLonglineGlobalCompositionDto> { private static final long serialVersionUID = 1L; public LonglineGlobalCompositionUIModel() { - super(SetLonglineDto.class); + super(SetLonglineGlobalCompositionDto.class); } } \ No newline at end of file diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUI.css b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUI.css index 644dd50..66367d8 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUI.css +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUI.css @@ -84,7 +84,7 @@ } #baitsCompositionProportionSum { - text:{getStringValue(model.getBaitsCompositionProportionSum())}; + text:{getStringValue(bean.getBaitsCompositionProportionSum())}; _validatorLabel:{t("observe.baitsComposition.proportionSum")}; font-weight:bold; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUI.jaxx index 02be4d3..d54fb7e 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUI.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUI.jaxx @@ -24,9 +24,7 @@ superGenericType='SetLonglineGlobalCompositionDto, BaitsCompositionDto' contentTitle='{n("observe.baitsComposition.title")}' saveNewEntryText='{n("observe.baitsComposition.action.create")}' - saveNewEntryTip='{n("observe.baitsComposition.action.create.tip")}' - - > + saveNewEntryTip='{n("observe.baitsComposition.action.create.tip")}'> <style source="../../CommonTable.css"/> diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java index df4d179..5819a58 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java @@ -22,21 +22,18 @@ package fr.ird.observe.ui.content.table.impl.longline; * #L% */ -import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.business.db.constants.DataContextType; -import fr.ird.observe.services.dto.FormDto; +import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.longline.BaitsCompositionDto; import fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto; -import fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDtos; import fr.ird.observe.services.dto.referential.longline.BaitSettingStatusDto; import fr.ird.observe.services.dto.referential.longline.BaitTypeDto; -import fr.ird.observe.services.service.longline.SetLonglineGlobalCompositionService; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.content.table.ContentTableUIHandler; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import javax.swing.*; +import javax.swing.JTable; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableCellRenderer; @@ -93,8 +90,8 @@ public class BaitsCompositionUIHandler extends ContentTableUIHandler<SetLongline n("observe.baitsComposition.table.proportion"), n("observe.baitsComposition.table.proportion.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, BaitTypeDto.class)); - UIHelper.setTableColumnRenderer(table, 1, UIHelper.newDecorateTableCellRenderer(renderer, BaitSettingStatusDto.class)); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, BaitTypeDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 1, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, BaitSettingStatusDto.class.getSimpleName())); UIHelper.setTableColumnRenderer(table, 2, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 3, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 4, UIHelper.newEmptyNumberTableCellRenderer(renderer)); @@ -103,9 +100,8 @@ public class BaitsCompositionUIHandler extends ContentTableUIHandler<SetLongline table.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { - //FIXME -// int proportionSum = getBean().getBaitsCompositionProportionSum(); -// getBean().setBaitsCompositionProportionSum(proportionSum); + int proportionSum = getBean().getBaitsCompositionProportionSum(); + getBean().setBaitsCompositionProportionSum(proportionSum); } }); @@ -118,28 +114,17 @@ public class BaitsCompositionUIHandler extends ContentTableUIHandler<SetLongline @Override protected void doPersist(SetLonglineGlobalCompositionDto bean) { - getSetLonglineGlobalCompositionService().save(bean); + // fait par le doSave de LonglineGlobalCompositionUIHandler } @Override protected void loadEditBean(String beanId) { - FormDto<SetLonglineGlobalCompositionDto> formDto = getSetLonglineGlobalCompositionService().loadToEdit(beanId); - getModel().setFormDto(formDto); - SetLonglineGlobalCompositionDtos.copySetLonglineGlobalCompositionDto(formDto.getForm(), getBean()); + // fait par le loadEditBean de LonglineGlobalCompositionUIHandler } - //FIXME -// @Override -// public SetLongline onUpdate(TopiaContext tx, Object parentBean, SetLongline beanToSave) throws TopiaException { -// return super.onUpdate(tx, parentBean, beanToSave); -// } - @Override public void afterSave(boolean refresh) { super.afterSave(refresh); } - protected SetLonglineGlobalCompositionService getSetLonglineGlobalCompositionService() { - return ObserveSwingApplicationContext.get().newService(SetLonglineGlobalCompositionService.class); - } } \ No newline at end of file diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIModel.java index 7b74ca8..0e9797e 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIModel.java @@ -24,12 +24,14 @@ package fr.ird.observe.ui.content.table.impl.longline; import com.google.common.collect.Lists; import fr.ird.observe.services.dto.longline.BaitsCompositionDto; +import fr.ird.observe.services.dto.longline.BaitsCompositionDtos; import fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto; import fr.ird.observe.ui.content.table.ContentTableMeta; import fr.ird.observe.ui.content.table.ContentTableModel; import fr.ird.observe.ui.content.table.ContentTableUIModel; import fr.ird.observe.ui.content.table.ObserveContentTableUI; +import java.util.Collection; import java.util.List; /** @@ -65,22 +67,26 @@ public class BaitsCompositionUIModel extends ContentTableUIModel<SetLonglineGlob } - public int getBaitsCompositionProportionSum() { - int sum = 0; - //FIXME -// if (!isBaitsCompositionEmpty()) { -// for (BaitsComposition composition : baitsComposition) { -// if (composition.getProportion() != null) { -// sum += composition.getProportion(); -// } -// } -// } - return sum; - } - @Override - protected ContentTableModel<SetLonglineGlobalCompositionDto, BaitsCompositionDto> createTableModel(ObserveContentTableUI<SetLonglineGlobalCompositionDto, BaitsCompositionDto> ui, List<ContentTableMeta<BaitsCompositionDto>> contentTableMetas) { - //FIXME - return null; + protected ContentTableModel<SetLonglineGlobalCompositionDto, BaitsCompositionDto> createTableModel( + ObserveContentTableUI<SetLonglineGlobalCompositionDto, BaitsCompositionDto> ui, + List<ContentTableMeta<BaitsCompositionDto>> contentTableMetas) { + + return new ContentTableModel<SetLonglineGlobalCompositionDto, BaitsCompositionDto>(ui, contentTableMetas) { + @Override + protected Collection<BaitsCompositionDto> getChilds(SetLonglineGlobalCompositionDto bean) { + return bean.getBaitsComposition(); + } + + @Override + protected void load(BaitsCompositionDto source, BaitsCompositionDto target) { + BaitsCompositionDtos.copyBaitsCompositionDto(source, target); + } + + @Override + protected void setChilds(SetLonglineGlobalCompositionDto parent, List<BaitsCompositionDto> childs) { + parent.setBaitsComposition(childs); + } + }; } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUI.css b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUI.css index 9be1155..53be763 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUI.css +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUI.css @@ -72,8 +72,7 @@ } #branchlinesCompositionProportionSum { - //FIXME - //text:{getStringValue(bean.getBranchlinesCompositionProportionSum())}; + text:{getStringValue(bean.getBranchlinesCompositionProportionSum())}; _validatorLabel:{t("observe.branchlinesComposition.proportionSum")}; font-weight:bold; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUI.jaxx index 348c309..7fc0ecd 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUI.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUI.jaxx @@ -24,9 +24,7 @@ superGenericType='SetLonglineGlobalCompositionDto, BranchlinesCompositionDto' contentTitle='{n("observe.branchlinesComposition.title")}' saveNewEntryText='{n("observe.branchlinesComposition.action.create")}' - saveNewEntryTip='{n("observe.branchlinesComposition.action.create.tip")}' - - > + saveNewEntryTip='{n("observe.branchlinesComposition.action.create.tip")}'> <style source="../../CommonTable.css"/> diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java index b21c9e4..2011d06 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java @@ -22,22 +22,20 @@ package fr.ird.observe.ui.content.table.impl.longline; * #L% */ -import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.business.db.constants.DataContextType; -import fr.ird.observe.services.dto.FormDto; +import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.longline.BranchlinesCompositionDto; import fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto; -import fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDtos; import fr.ird.observe.services.dto.referential.longline.HookSizeDto; import fr.ird.observe.services.dto.referential.longline.HookTypeDto; -import fr.ird.observe.services.service.longline.SetLonglineGlobalCompositionService; -import fr.ird.observe.services.service.longline.SetLonglineService; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.content.table.ContentTableUIHandler; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import javax.swing.*; +import javax.swing.JTable; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableCellRenderer; import static org.nuiton.i18n.I18n.n; @@ -90,20 +88,19 @@ public class BranchlinesCompositionUIHandler extends ContentTableUIHandler<SetLo n("observe.branchlinesComposition.table.proportion"), n("observe.branchlinesComposition.table.proportion.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, HookTypeDto.class)); - UIHelper.setTableColumnRenderer(table, 1, UIHelper.newDecorateTableCellRenderer(renderer, HookSizeDto.class)); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, HookTypeDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 1, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, HookSizeDto.class.getSimpleName())); UIHelper.setTableColumnRenderer(table, 2, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 3, UIHelper.newEmptyNumberTableCellRenderer(renderer)); // when model change in table, let's recompute the proportion sum - //FIXME -// table.getModel().addTableModelListener(new TableModelListener() { -// @Override -// public void tableChanged(TableModelEvent e) { -// int proportionSum = getBean().getBranchlinesCompositionProportionSum(); -// getBean().setBranchlinesCompositionProportionSum(proportionSum); -// } -// }); + table.getModel().addTableModelListener(new TableModelListener() { + @Override + public void tableChanged(TableModelEvent e) { + int proportionSum = getBean().getBranchlinesCompositionProportionSum(); + getBean().setBranchlinesCompositionProportionSum(proportionSum); + } + }); } @@ -112,12 +109,6 @@ public class BranchlinesCompositionUIHandler extends ContentTableUIHandler<SetLo return getDataContext().getSelectedSetId(); } - //FIXME -// @Override -// public SetLongline onUpdate(TopiaContext tx, Object parentBean, SetLongline beanToSave) throws TopiaException { -// return super.onUpdate(tx, parentBean, beanToSave); -// } - @Override public void afterSave(boolean refresh) { super.afterSave(refresh); @@ -125,18 +116,12 @@ public class BranchlinesCompositionUIHandler extends ContentTableUIHandler<SetLo @Override protected void doPersist(SetLonglineGlobalCompositionDto bean) { - getSetLonglineGlobalCompositionService().save(bean); + // fait par le doSave de LonglineGlobalCompositionUIHandler } @Override protected void loadEditBean(String beanId) { - FormDto<SetLonglineGlobalCompositionDto> formDto = getSetLonglineGlobalCompositionService().loadToEdit(beanId); - getModel().setFormDto(formDto); - SetLonglineGlobalCompositionDtos.copySetLonglineGlobalCompositionDto(formDto.getForm(), getBean()); - } - - protected SetLonglineGlobalCompositionService getSetLonglineGlobalCompositionService() { - return ObserveSwingApplicationContext.get().newService(SetLonglineGlobalCompositionService.class); + // fait par le loadEditBean de LonglineGlobalCompositionUIHandler } } \ No newline at end of file diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIModel.java index ec23581..94e0f0a 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIModel.java @@ -24,12 +24,14 @@ package fr.ird.observe.ui.content.table.impl.longline; import com.google.common.collect.Lists; import fr.ird.observe.services.dto.longline.BranchlinesCompositionDto; +import fr.ird.observe.services.dto.longline.BranchlinesCompositionDtos; import fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto; import fr.ird.observe.ui.content.table.ContentTableMeta; import fr.ird.observe.ui.content.table.ContentTableModel; import fr.ird.observe.ui.content.table.ContentTableUIModel; import fr.ird.observe.ui.content.table.ObserveContentTableUI; +import java.util.Collection; import java.util.List; /** @@ -65,8 +67,25 @@ public class BranchlinesCompositionUIModel extends ContentTableUIModel<SetLongli @Override - protected ContentTableModel<SetLonglineGlobalCompositionDto, BranchlinesCompositionDto> createTableModel(ObserveContentTableUI<SetLonglineGlobalCompositionDto, BranchlinesCompositionDto> ui, List<ContentTableMeta<BranchlinesCompositionDto>> contentTableMetas) { - //FIXME - return null; + protected ContentTableModel<SetLonglineGlobalCompositionDto, BranchlinesCompositionDto> createTableModel( + ObserveContentTableUI<SetLonglineGlobalCompositionDto, BranchlinesCompositionDto> ui, + List<ContentTableMeta<BranchlinesCompositionDto>> contentTableMetas) { + + return new ContentTableModel<SetLonglineGlobalCompositionDto, BranchlinesCompositionDto>(ui, contentTableMetas) { + @Override + protected Collection<BranchlinesCompositionDto> getChilds(SetLonglineGlobalCompositionDto bean) { + return bean.getBranchlinesComposition(); + } + + @Override + protected void load(BranchlinesCompositionDto source, BranchlinesCompositionDto target) { + BranchlinesCompositionDtos.copyBranchlinesCompositionDto(source, target); + } + + @Override + protected void setChilds(SetLonglineGlobalCompositionDto parent, List<BranchlinesCompositionDto> childs) { + parent.setBranchlinesComposition(childs); + } + }; } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUI.css b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUI.css index b6ac1f6..6b368a9 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUI.css +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUI.css @@ -61,7 +61,7 @@ } #floatlinesCompositionProportionSum { - //text:{getStringValue(bean.getFloatlinesCompositionProportionSum())}; + text:{getStringValue(bean.getFloatlinesCompositionProportionSum())}; _validatorLabel:{t("observe.floatlinesComposition.proportionSum")}; font-weight:bold; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUI.jaxx index fd8a649..8e67564 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUI.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUI.jaxx @@ -21,18 +21,16 @@ --> <fr.ird.observe.ui.content.table.ContentTableUI - superGenericType='SetLonglineDto, FloatlinesCompositionDto' + superGenericType='SetLonglineGlobalCompositionDto, FloatlinesCompositionDto' contentTitle='{n("observe.floatlinesComposition.title")}' saveNewEntryText='{n("observe.floatlinesComposition.action.create")}' - saveNewEntryTip='{n("observe.floatlinesComposition.action.create.tip")}' - - > + saveNewEntryTip='{n("observe.floatlinesComposition.action.create.tip")}'> <style source="../../CommonTable.css"/> <import> fr.ird.observe.services.dto.ReferenceDto - fr.ird.observe.services.dto.longline.SetLonglineDto + fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto fr.ird.observe.services.dto.longline.FloatlinesCompositionDto fr.ird.observe.services.dto.referential.longline.LineTypeDto fr.ird.observe.ui.content.table.* @@ -51,7 +49,7 @@ <FloatlinesCompositionUIModel id='model'/> <!-- edit bean --> - <SetLonglineDto id='bean'/> + <SetLonglineGlobalCompositionDto id='bean'/> <!-- table edit bean --> <FloatlinesCompositionDto id='tableEditBean'/> @@ -61,11 +59,10 @@ <!-- le validateur de l'écran --> <BeanValidator id='validator' context='n1-update-floatlinesComposition' - beanClass='fr.ird.observe.services.dto.longline.SetLonglineDto' + beanClass='fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto' errorTableModel='{getErrorTableModel()}'> - <!--FIXME--> - <!--<field name="floatlinesCompositionProportionSum" component="floatlinesCompositionProportionSum"/>--> - <!--<field name="floatlinesComposition" component="editorPanel"/>--> + <field name="floatlinesCompositionProportionSum" component="floatlinesCompositionProportionSum"/> + <field name="floatlinesComposition" component="editorPanel"/> </BeanValidator> <!-- le validateur d'une entrée de tableau --> diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java index 86f49c0..4820794 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java @@ -22,20 +22,19 @@ package fr.ird.observe.ui.content.table.impl.longline; * #L% */ -import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.business.db.constants.DataContextType; -import fr.ird.observe.services.dto.FormDto; +import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.longline.FloatlinesCompositionDto; -import fr.ird.observe.services.dto.longline.SetLonglineDto; -import fr.ird.observe.services.dto.longline.SetLonglineDtos; +import fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto; import fr.ird.observe.services.dto.referential.longline.LineTypeDto; -import fr.ird.observe.services.service.longline.SetLonglineService; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.content.table.ContentTableUIHandler; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import javax.swing.*; +import javax.swing.JTable; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableCellRenderer; import static org.nuiton.i18n.I18n.n; @@ -46,7 +45,7 @@ import static org.nuiton.i18n.I18n.n; * @author Tony Chemit - chemit@codelutin.com * @since 3.9 */ -public class FloatlinesCompositionUIHandler extends ContentTableUIHandler<SetLonglineDto, FloatlinesCompositionDto> { +public class FloatlinesCompositionUIHandler extends ContentTableUIHandler<SetLonglineGlobalCompositionDto, FloatlinesCompositionDto> { /** Logger */ static private Log log = LogFactory.getLog(FloatlinesCompositionUIHandler.class); @@ -86,20 +85,19 @@ public class FloatlinesCompositionUIHandler extends ContentTableUIHandler<SetLon n("observe.floatlinesComposition.table.proportion"), n("observe.floatlinesComposition.table.proportion.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, LineTypeDto.class)); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, LineTypeDto.class.getSimpleName())); UIHelper.setTableColumnRenderer(table, 1, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 2, UIHelper.newEmptyNumberTableCellRenderer(renderer)); // when model change in table, let's recompute the proportion sum - //FIXME -// table.getModel().addTableModelListener(new TableModelListener() { -// @Override -// public void tableChanged(TableModelEvent e) { -// -// int proportionSum = getBean().getFloatlinesCompositionProportionSum(); -// getBean().setFloatlinesCompositionProportionSum(proportionSum); -// } -// }); + table.getModel().addTableModelListener(new TableModelListener() { + @Override + public void tableChanged(TableModelEvent e) { + + int proportionSum = getBean().getFloatlinesCompositionProportionSum(); + getBean().setFloatlinesCompositionProportionSum(proportionSum); + } + }); } @@ -108,30 +106,18 @@ public class FloatlinesCompositionUIHandler extends ContentTableUIHandler<SetLon return getDataContext().getSelectedSetId(); } - //FIXME -// @Override -// public SetLongline onUpdate(TopiaContext tx, Object parentBean, SetLongline beanToSave) throws TopiaException { -// return super.onUpdate(tx, parentBean, beanToSave); -// } - @Override public void afterSave(boolean refresh) { super.afterSave(refresh); } @Override - protected void doPersist(SetLonglineDto bean) { - getSetLonglineService().save(getSelectedParentId(), bean); + protected void doPersist(SetLonglineGlobalCompositionDto bean) { + // fait par le doSave de LonglineGlobalCompositionUIHandler } @Override protected void loadEditBean(String beanId) { - FormDto<SetLonglineDto> formDto = getSetLonglineService().loadToEdit(beanId); - getModel().setFormDto(formDto); - SetLonglineDtos.copySetLonglineDto(formDto.getForm(), getBean()); - } - - protected SetLonglineService getSetLonglineService() { - return ObserveSwingApplicationContext.get().newService(SetLonglineService.class); + // fait par le loadEditBean de LonglineGlobalCompositionUIHandler } } \ No newline at end of file diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIModel.java index af421fd..0a2f9ed 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIModel.java @@ -24,12 +24,14 @@ package fr.ird.observe.ui.content.table.impl.longline; import com.google.common.collect.Lists; import fr.ird.observe.services.dto.longline.FloatlinesCompositionDto; -import fr.ird.observe.services.dto.longline.SetLonglineDto; +import fr.ird.observe.services.dto.longline.FloatlinesCompositionDtos; +import fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto; import fr.ird.observe.ui.content.table.ContentTableMeta; import fr.ird.observe.ui.content.table.ContentTableModel; import fr.ird.observe.ui.content.table.ContentTableUIModel; import fr.ird.observe.ui.content.table.ObserveContentTableUI; +import java.util.Collection; import java.util.List; /** @@ -38,16 +40,15 @@ import java.util.List; * @author Tony Chemit - chemit@codelutin.com * @since 3.9 */ -public class FloatlinesCompositionUIModel extends ContentTableUIModel<SetLonglineDto, FloatlinesCompositionDto> { +public class FloatlinesCompositionUIModel extends ContentTableUIModel<SetLonglineGlobalCompositionDto, FloatlinesCompositionDto> { private static final long serialVersionUID = 1L; public FloatlinesCompositionUIModel(FloatlinesCompositionUI ui) { - super(SetLonglineDto.class, + super(SetLonglineGlobalCompositionDto.class, FloatlinesCompositionDto.class, new String[]{ - //FIXME -// SetLonglineDto.PROPERTY_FLOATLINES_COMPOSITION + SetLonglineGlobalCompositionDto.PROPERTY_FLOATLINES_COMPOSITION }, new String[]{FloatlinesCompositionDto.PROPERTY_LINE_TYPE, FloatlinesCompositionDto.PROPERTY_LENGTH, @@ -64,8 +65,25 @@ public class FloatlinesCompositionUIModel extends ContentTableUIModel<SetLonglin @Override - protected ContentTableModel<SetLonglineDto, FloatlinesCompositionDto> createTableModel(ObserveContentTableUI<SetLonglineDto, FloatlinesCompositionDto> ui, List<ContentTableMeta<FloatlinesCompositionDto>> contentTableMetas) { - // FIXME - return null; + protected ContentTableModel<SetLonglineGlobalCompositionDto, FloatlinesCompositionDto> createTableModel( + ObserveContentTableUI<SetLonglineGlobalCompositionDto, FloatlinesCompositionDto> ui, + List<ContentTableMeta<FloatlinesCompositionDto>> contentTableMetas) { + + return new ContentTableModel<SetLonglineGlobalCompositionDto, FloatlinesCompositionDto>(ui, contentTableMetas) { + @Override + protected Collection<FloatlinesCompositionDto> getChilds(SetLonglineGlobalCompositionDto bean) { + return bean.getFloatlinesComposition(); + } + + @Override + protected void load(FloatlinesCompositionDto source, FloatlinesCompositionDto target) { + FloatlinesCompositionDtos.copyFloatlinesCompositionDto(source, target); + } + + @Override + protected void setChilds(SetLonglineGlobalCompositionDto parent, List<FloatlinesCompositionDto> childs) { + parent.setFloatlinesComposition(childs); + } + }; } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUI.css b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUI.css index 29e05a6..be9847a 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUI.css +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUI.css @@ -73,8 +73,7 @@ } #hooksCompositionProportionSum { - //FIXME - //text:{getStringValue(bean.getHooksCompositionProportionSum())}; + text:{getStringValue(bean.getHooksCompositionProportionSum())}; _validatorLabel:{t("observe.hooksComposition.proportionSum")}; font-weight:bold; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUI.jaxx index 3b846eb..bcc0558 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUI.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUI.jaxx @@ -21,18 +21,16 @@ --> <fr.ird.observe.ui.content.table.ContentTableUI - superGenericType='SetLonglineDto, HooksCompositionDto' + superGenericType='SetLonglineGlobalCompositionDto, HooksCompositionDto' contentTitle='{n("observe.hooksComposition.title")}' saveNewEntryText='{n("observe.hooksComposition.action.create")}' - saveNewEntryTip='{n("observe.hooksComposition.action.create.tip")}' - - > + saveNewEntryTip='{n("observe.hooksComposition.action.create.tip")}'> <style source="../../CommonTable.css"/> <import> fr.ird.observe.services.dto.ReferenceDto - fr.ird.observe.services.dto.longline.SetLonglineDto + fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto fr.ird.observe.services.dto.longline.HooksCompositionDto fr.ird.observe.services.dto.referential.longline.HookTypeDto fr.ird.observe.services.dto.referential.longline.HookSizeDto @@ -52,7 +50,7 @@ <HooksCompositionUIModel id='model'/> <!-- edit bean --> - <SetLonglineDto id='bean'/> + <SetLonglineGlobalCompositionDto id='bean'/> <!-- table edit bean --> <HooksCompositionDto id='tableEditBean'/> @@ -62,10 +60,9 @@ <!-- le validateur de l'écran --> <BeanValidator id='validator' autoField='true' context='n1-update-hooksComposition' - beanClass='fr.ird.observe.services.dto.longline.SetLonglineDto' + beanClass='fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto' errorTableModel='{getErrorTableModel()}'> - <!--FIXME--> - <!--<field name="hooksComposition" component="editorPanel"/>--> + <field name="hooksComposition" component="editorPanel"/> </BeanValidator> <!-- le validateur d'une entrée de tableau --> @@ -78,20 +75,20 @@ <!-- HookType --> <row> <cell> - <JLabel id='HookTypeLabel'/> + <JLabel id='hookTypeLabel'/> </cell> <cell weightx='1' anchor='east'> - <BeanComboBox id='HookType' constructorParams='this' genericType='ReferenceDto<HookTypeDto>' _entityClass='HookTypeDto.class'/> + <BeanComboBox id='hookType' constructorParams='this' genericType='ReferenceDto<HookTypeDto>' _entityClass='HookTypeDto.class'/> </cell> </row> <!-- HookSize --> <row> <cell> - <JLabel id='HookSizeLabel'/> + <JLabel id='hookSizeLabel'/> </cell> <cell weightx='1' anchor='east'> - <BeanComboBox id='HookSize' constructorParams='this' genericType='ReferenceDto<HookSizeDto>' _entityClass='HookSizeDto.class'/> + <BeanComboBox id='hookSize' constructorParams='this' genericType='ReferenceDto<HookSizeDto>' _entityClass='HookSizeDto.class'/> </cell> </row> diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java index 91fd1c6..b24a929 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java @@ -22,22 +22,20 @@ package fr.ird.observe.ui.content.table.impl.longline; * #L% */ -import fr.ird.observe.ObserveSwingApplicationContext; -import fr.ird.observe.business.db.DataContext; import fr.ird.observe.business.db.constants.DataContextType; -import fr.ird.observe.services.dto.FormDto; +import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.longline.HooksCompositionDto; -import fr.ird.observe.services.dto.longline.SetLonglineDto; -import fr.ird.observe.services.dto.longline.SetLonglineDtos; +import fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto; import fr.ird.observe.services.dto.referential.longline.HookSizeDto; import fr.ird.observe.services.dto.referential.longline.HookTypeDto; -import fr.ird.observe.services.service.longline.SetLonglineService; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.content.table.ContentTableUIHandler; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import javax.swing.*; +import javax.swing.JTable; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableCellRenderer; import static org.nuiton.i18n.I18n.n; @@ -48,7 +46,7 @@ import static org.nuiton.i18n.I18n.n; * @author Tony Chemit - chemit@codelutin.com * @since 3.9 */ -public class HooksCompositionUIHandler extends ContentTableUIHandler<SetLonglineDto, HooksCompositionDto> { +public class HooksCompositionUIHandler extends ContentTableUIHandler<SetLonglineGlobalCompositionDto, HooksCompositionDto> { /** Logger */ static private Log log = LogFactory.getLog(HooksCompositionUIHandler.class); @@ -90,20 +88,19 @@ public class HooksCompositionUIHandler extends ContentTableUIHandler<SetLongline n("observe.hooksComposition.table.proportion"), n("observe.hooksComposition.table.proportion.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, HookTypeDto.class)); - UIHelper.setTableColumnRenderer(table, 1, UIHelper.newDecorateTableCellRenderer(renderer, HookSizeDto.class)); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, HookTypeDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 1, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, HookSizeDto.class.getSimpleName())); UIHelper.setTableColumnRenderer(table, 2, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 3, UIHelper.newEmptyNumberTableCellRenderer(renderer)); // when model change in table, let's recompute the proportion sum - //FIXME -// table.getModel().addTableModelListener(new TableModelListener() { -// @Override -// public void tableChanged(TableModelEvent e) { -// int proportionSum = getBean().getHooksCompositionProportionSum(); -// getBean().setHooksCompositionProportionSum(proportionSum); -// } -// }); + table.getModel().addTableModelListener(new TableModelListener() { + @Override + public void tableChanged(TableModelEvent e) { + int proportionSum = getBean().getHooksCompositionProportionSum(); + getBean().setHooksCompositionProportionSum(proportionSum); + } + }); } @@ -112,30 +109,18 @@ public class HooksCompositionUIHandler extends ContentTableUIHandler<SetLongline return getDataContext().getSelectedSetId(); } - //FIXME -// @Override -// public SetLongline onUpdate(TopiaContext tx, Object parentBean, SetLongline beanToSave) throws TopiaException { -// return super.onUpdate(tx, parentBean, beanToSave); -// } - @Override public void afterSave(boolean refresh) { super.afterSave(refresh); } @Override - protected void doPersist(SetLonglineDto bean) { - getSetLonglineService().save(getSelectedParentId(), bean); + protected void doPersist(SetLonglineGlobalCompositionDto bean) { + // fait par le doSave de LonglineGlobalCompositionUIHandler } @Override protected void loadEditBean(String beanId) { - FormDto<SetLonglineDto> formDto = getSetLonglineService().loadToEdit(beanId); - getModel().setFormDto(formDto); - SetLonglineDtos.copySetLonglineDto(formDto.getForm(), getBean()); - } - - protected SetLonglineService getSetLonglineService() { - return ObserveSwingApplicationContext.get().newService(SetLonglineService.class); + // fait par le loadEditBean de LonglineGlobalCompositionUIHandler } } \ No newline at end of file diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIModel.java index 2ede5d8..e14ca52 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIModel.java @@ -24,12 +24,14 @@ package fr.ird.observe.ui.content.table.impl.longline; import com.google.common.collect.Lists; import fr.ird.observe.services.dto.longline.HooksCompositionDto; -import fr.ird.observe.services.dto.longline.SetLonglineDto; +import fr.ird.observe.services.dto.longline.HooksCompositionDtos; +import fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto; import fr.ird.observe.ui.content.table.ContentTableMeta; import fr.ird.observe.ui.content.table.ContentTableModel; import fr.ird.observe.ui.content.table.ContentTableUIModel; import fr.ird.observe.ui.content.table.ObserveContentTableUI; +import java.util.Collection; import java.util.List; /** @@ -38,16 +40,15 @@ import java.util.List; * @author Tony Chemit - chemit@codelutin.com * @since 3.9 */ -public class HooksCompositionUIModel extends ContentTableUIModel<SetLonglineDto, HooksCompositionDto> { +public class HooksCompositionUIModel extends ContentTableUIModel<SetLonglineGlobalCompositionDto, HooksCompositionDto> { private static final long serialVersionUID = 1L; public HooksCompositionUIModel(HooksCompositionUI ui) { - super(SetLonglineDto.class, + super(SetLonglineGlobalCompositionDto.class, HooksCompositionDto.class, new String[]{ - //FIXME -// SetLonglineDto.PROPERTY_HOOKS_COMPOSITION + SetLonglineGlobalCompositionDto.PROPERTY_HOOKS_COMPOSITION }, new String[]{HooksCompositionDto.PROPERTY_HOOK_TYPE, HooksCompositionDto.PROPERTY_HOOK_SIZE, @@ -66,8 +67,25 @@ public class HooksCompositionUIModel extends ContentTableUIModel<SetLonglineDto, @Override - protected ContentTableModel<SetLonglineDto, HooksCompositionDto> createTableModel(ObserveContentTableUI<SetLonglineDto, HooksCompositionDto> ui, List<ContentTableMeta<HooksCompositionDto>> contentTableMetas) { - // FIXME - return null; + protected ContentTableModel<SetLonglineGlobalCompositionDto, HooksCompositionDto> createTableModel( + ObserveContentTableUI<SetLonglineGlobalCompositionDto, HooksCompositionDto> ui, + List<ContentTableMeta<HooksCompositionDto>> contentTableMetas) { + + return new ContentTableModel<SetLonglineGlobalCompositionDto, HooksCompositionDto>(ui, contentTableMetas) { + @Override + protected Collection<HooksCompositionDto> getChilds(SetLonglineGlobalCompositionDto bean) { + return bean.getHooksComposition(); + } + + @Override + protected void load(HooksCompositionDto source, HooksCompositionDto target) { + HooksCompositionDtos.copyHooksCompositionDto(source, target); + } + + @Override + protected void setChilds(SetLonglineGlobalCompositionDto parent, List<HooksCompositionDto> childs) { + parent.setHooksComposition(childs); + } + }; } } diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/SetLonglineGlobalCompositionServiceController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/SetLonglineGlobalCompositionServiceController.java index 8af13a2..0addcc9 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/SetLonglineGlobalCompositionServiceController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/longline/SetLonglineGlobalCompositionServiceController.java @@ -25,6 +25,7 @@ package fr.ird.observe.application.web.controller.v1.longline; import fr.ird.observe.application.web.controller.v1.ObserveAuthenticatedServiceControllerSupport; import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto; +import fr.ird.observe.services.dto.result.SaveResultDto; import fr.ird.observe.services.service.longline.SetLonglineGlobalCompositionService; /** @@ -47,7 +48,7 @@ public class SetLonglineGlobalCompositionServiceController extends ObserveAuthen } @Override - public String save(SetLonglineGlobalCompositionDto dto) { + public SaveResultDto save(SetLonglineGlobalCompositionDto dto) { return service.save(dto); } } diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/SetLonglineGlobalCompositionService.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/SetLonglineGlobalCompositionService.java index fbac7ec..f6c9fc7 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/SetLonglineGlobalCompositionService.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/longline/SetLonglineGlobalCompositionService.java @@ -25,6 +25,7 @@ package fr.ird.observe.services.service.longline; import fr.ird.observe.services.ObserveService; import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto; +import fr.ird.observe.services.dto.result.SaveResultDto; import fr.ird.observe.services.spi.PostRequest; import fr.ird.observe.services.spi.ReadDataPermission; import fr.ird.observe.services.spi.Write; @@ -44,6 +45,6 @@ public interface SetLonglineGlobalCompositionService extends ObserveService { @Write @WriteDataPermission @PostRequest - String save(SetLonglineGlobalCompositionDto dto); + SaveResultDto save(SetLonglineGlobalCompositionDto dto); } diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/longline/SetLonglineGlobalCompositionDto.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/longline/SetLonglineGlobalCompositionDto.java new file mode 100644 index 0000000..2c83aaa --- /dev/null +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/longline/SetLonglineGlobalCompositionDto.java @@ -0,0 +1,90 @@ +package fr.ird.observe.services.dto.longline; + +import javax.annotation.Generated; + +@Generated(value = "org.nuiton.eugene.java.SimpleJavaBeanWithNoInterfaceTransformer", date = "Thu Oct 22 14:47:01 CEST 2015") +public class SetLonglineGlobalCompositionDto extends AbstractSetLonglineGlobalCompositionDto { + + private static final long serialVersionUID = 3473510292736074595L; + + public static final String PROPERTY_FLOATLINES_COMPOSITION_PROPORTION_SUM = "floatlinesCompositionProportionSum"; + + public static final String PROPERTY_BRANCHLINES_COMPOSITION_PROPORTION_SUM = "branchlinesCompositionProportionSum"; + + public static final String PROPERTY_HOOKS_COMPOSITION_PROPORTION_SUM = "hooksCompositionProportionSum"; + + public static final String PROPERTY_BAITS_COMPOSITION_PROPORTION_SUM = "baitsCompositionProportionSum"; + + public int getFloatlinesCompositionProportionSum() { + int sum = 0; + if (!isFloatlinesCompositionEmpty()) { + for (FloatlinesCompositionDto composition : floatlinesComposition) { + if (composition.getProportion() != null) { + sum += composition.getProportion(); + } + } + } + return sum; + } + + public int getBranchlinesCompositionProportionSum() { + int sum = 0; + if (!isBranchlinesCompositionEmpty()) { + for (BranchlinesCompositionDto composition : branchlinesComposition) { + if (composition.getProportion() != null) { + sum += composition.getProportion(); + } + } + } + return sum; + } + + public int getHooksCompositionProportionSum() { + int sum = 0; + if (!isHooksCompositionEmpty()) { + for (HooksCompositionDto composition : hooksComposition) { + if (composition.getProportion() != null) { + sum += composition.getProportion(); + } + } + } + return sum; + } + + public int getBaitsCompositionProportionSum() { + int sum = 0; + if (!isBaitsCompositionEmpty()) { + for (BaitsCompositionDto composition : baitsComposition) { + if (composition.getProportion() != null) { + sum += composition.getProportion(); + } + } + } + return sum; + } + + public void setFloatlinesCompositionProportionSum(int sum) { + // not used but required by validation + // just fire the given value + firePropertyChange(PROPERTY_FLOATLINES_COMPOSITION_PROPORTION_SUM, 0, sum); + } + + public void setBranchlinesCompositionProportionSum(int sum) { + // not used but required by validation + // just fire the given value + firePropertyChange(PROPERTY_BRANCHLINES_COMPOSITION_PROPORTION_SUM, 0, sum); + } + + public void setHooksCompositionProportionSum(int sum) { + // not used but required by validation + // just fire the given value + firePropertyChange(PROPERTY_HOOKS_COMPOSITION_PROPORTION_SUM, 0, sum); + } + + public void setBaitsCompositionProportionSum(int sum) { + // not used but required by validation + // just fire the given value + firePropertyChange(PROPERTY_BAITS_COMPOSITION_PROPORTION_SUM, 0, sum); + } + +} diff --git a/observe-services-model/src/main/xmi/observe-services-dto-longline.zargo b/observe-services-model/src/main/xmi/observe-services-dto-longline.zargo index f085a22..89aef58 100644 Binary files a/observe-services-model/src/main/xmi/observe-services-dto-longline.zargo and b/observe-services-model/src/main/xmi/observe-services-dto-longline.zargo differ diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/dto/ObserveDtosInitializer.java b/observe-services-topia/src/main/java/fr/ird/observe/services/dto/ObserveDtosInitializer.java index fdb88cc..5f2d2e9 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/dto/ObserveDtosInitializer.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/dto/ObserveDtosInitializer.java @@ -647,6 +647,7 @@ public class ObserveDtosInitializer implements ObserveModelInitializer { @Override public void initSetLonglineGlobalCompositionDto() { registerDto(SetLonglineGlobalCompositionDto.class, SetLongline.class, + SetLonglineGlobalCompositionDto.PROPERTY_COMMENT, SetLonglineGlobalCompositionDto.PROPERTY_FLOATLINES_COMPOSITION, SetLonglineGlobalCompositionDto.PROPERTY_BRANCHLINES_COMPOSITION, SetLonglineGlobalCompositionDto.PROPERTY_HOOKS_COMPOSITION, diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/SetLonglineGlobalCompositionServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/SetLonglineGlobalCompositionServiceTopia.java index 88f423f..d8c5333 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/SetLonglineGlobalCompositionServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/SetLonglineGlobalCompositionServiceTopia.java @@ -37,6 +37,8 @@ import fr.ird.observe.services.dto.referential.longline.HookSizeDto; import fr.ird.observe.services.dto.referential.longline.HookTypeDto; import fr.ird.observe.services.dto.referential.longline.LineTypeDto; import fr.ird.observe.services.dto.referential.longline.MitigationTypeDto; +import fr.ird.observe.services.dto.result.SaveResultDto; +import fr.ird.observe.services.dto.result.SaveResultDtos; /** * @author Sylvain Bavencoff - bavencoff@codelutin.com @@ -78,12 +80,12 @@ public class SetLonglineGlobalCompositionServiceTopia extends ObserveServiceTopi } @Override - public String save(SetLonglineGlobalCompositionDto setLonglineGlobalCompositionDto) { + public SaveResultDto save(SetLonglineGlobalCompositionDto setLonglineGlobalCompositionDto) { SetLongline setLongline = dtoToEntity(SetLonglineGlobalCompositionDto.class, SetLongline.class, setLonglineGlobalCompositionDto); setLongline = saveEntity(SetLongline.class, setLongline); - return setLongline.getTopiaId(); + return SaveResultDtos.newSaveResult(setLongline.getTopiaId(), setLongline.getLastUpdate()); } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.