This is an automated email from the git hooks/post-receive script. New commit to branch feature/7017 in repository observe. See http://git.codelutin.com/observe.git commit 89032218320002c3eb42cb5d29f91ff3ff28ab64 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat May 2 15:50:00 2015 +0200 revue des écrans de type list (refs #7017) --- .../ui/content/list/ContentListUIHandler.java | 84 ++++++++++++---------- .../impl/longline/ActivityLonglinesUIHandler.java | 18 ++--- .../list/impl/longline/TripLonglinesUIHandler.java | 24 ++----- .../list/impl/seine/ActivitySeinesUIHandler.java | 23 +++--- .../content/list/impl/seine/RoutesUIHandler.java | 19 +++-- .../list/impl/seine/TripSeinesUIHandler.java | 23 ++---- .../ui/content/open/ContentOpenableUIHandler.java | 2 +- 7 files changed, 83 insertions(+), 110 deletions(-) diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/list/ContentListUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/list/ContentListUIHandler.java index c086ec2..2a4e811 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/list/ContentListUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/list/ContentListUIHandler.java @@ -54,21 +54,24 @@ import static org.nuiton.i18n.I18n.t; public abstract class ContentListUIHandler<E extends TopiaEntity, C extends TopiaEntity> extends ContentUIHandler<E> { /** Logger */ - static private Log log = LogFactory.getLog(ContentListUIHandler.class); + public static final Log log = LogFactory.getLog(ContentListUIHandler.class); - public ContentListUIHandler(ContentListUI<E, C> ui, - DataContextType parentType, - DataContextType type) { + public ContentListUIHandler(ContentListUI<E, C> ui, DataContextType parentType, DataContextType type) { super(ui, parentType, type); } /** - * Load data (the main bean + the data list) in model. + * Méthode invoquée à chaque ouverture de l'écran. * - * @param selectedId id of the entity to load + * Il faut dans cette méthode charger le bean d'édition et retourner la liste gérée par l'écran. + * + * La méthode est invoquée par {@link #openUI()}. + * + * @param selectedId l'id de l'entité de l'écran. + * @return la liste à gérer par l'écran * @since 4.0 */ - protected abstract void loadDataInModel(String selectedId); + protected abstract List<C> onOpenUI(String selectedId); @Override protected boolean computeCanWrite(DataSource source) { @@ -85,19 +88,20 @@ public abstract class ContentListUIHandler<E extends TopiaEntity, C extends Topi return (ContentListUIModel<E, C>) super.getModel(); } + @SuppressWarnings("unchecked") @Override - public void initUI() throws Exception { + public final void initUI() throws Exception { + super.initUI(); - // on installe un renderer sur la liste pour afficher les couleurs + - // icones comme dans l'arbre + // on installe un renderer sur la liste pour afficher les couleurs + icones comme dans l'arbre ListCellRenderer renderer = getUi().getList().getCellRenderer(); ObserveTreeHelper treeHelper = getTreeHelper(getUi()); - ListCellRenderer renderer2 = - new EntityListCellRenderer(renderer, treeHelper); + ListCellRenderer renderer2 = new EntityListCellRenderer(renderer, treeHelper); getUi().getList().setCellRenderer(renderer2); + } @Override @@ -106,8 +110,7 @@ public abstract class ContentListUIHandler<E extends TopiaEntity, C extends Topi super.openUI(); // init renderer - EntityListCellRenderer renderer = (EntityListCellRenderer) - getUi().getList().getCellRenderer(); + EntityListCellRenderer renderer = (EntityListCellRenderer) getUi().getList().getCellRenderer(); renderer.init(); ContentListUIModel<E, C> model = getModel(); @@ -125,13 +128,18 @@ public abstract class ContentListUIHandler<E extends TopiaEntity, C extends Topi } model.setMode(mode); - boolean canReopen = mode == ContentMode.CREATE; + boolean canReopen = ContentMode.CREATE == mode; if (log.isInfoEnabled()) { log.info(prefix + "canReopen = " + canReopen); } model.setCanReopen(canReopen); - loadDataInModel(selectedId); + List<C> childs = onOpenUI(selectedId); + model.setData(childs); + + if (log.isDebugEnabled()) { + log.debug("Will use " + childs.size() + " child(s)."); + } if (!model.isEmpty()) { @@ -140,8 +148,6 @@ public abstract class ContentListUIHandler<E extends TopiaEntity, C extends Topi } - // finalize openUI with specified code - finalizeOpenUI(); } public void addChild() { @@ -154,37 +160,37 @@ public abstract class ContentListUIHandler<E extends TopiaEntity, C extends Topi * @param event the mouse event fired */ public void onDataSelected(MouseEvent event) { + C selectedData = getUi().getSelectedData(); if (event.getClickCount() > 1) { + gotoChild(selectedData); - return; - } - ObserveNode node = null; - if (selectedData != null) { - - // obtain the node corresponding to the selected data - String id = selectedData.getTopiaId(); - ObserveTreeHelper helper = getTreeHelper(getUi()); - ObserveNode selectedNode = helper.getSelectedNode(); - node = helper.findNode(selectedNode, id); + + } else { + + ObserveNode node = null; + if (selectedData != null) { + + // obtain the node corresponding to the selected data + String id = selectedData.getTopiaId(); + ObserveTreeHelper helper = getTreeHelper(getUi()); + ObserveNode selectedNode = helper.getSelectedNode(); + node = helper.findNode(selectedNode, id); + } + + // attach the node to action + JButton button = getUi().getGotoSelectedChild(); + button.putClientProperty(SelectNodeUIAction.NODE, node); + } - // attach the node to action - JButton button = getUi().getGotoSelectedChild(); - button.putClientProperty(SelectNodeUIAction.NODE, node); } - public <E> List<E> updateList(BeanListHeader<E> list, List<E> data) { + public <EE> List<EE> updateList(BeanListHeader<EE> list, List<EE> data) { + String message = t(getUi().getEmptyListMessage()); return updateList(list, data, message); - } - /** - * Pour effectuer un traitement supplémantaire à la fin de la méthode - * {@link #openUI()}. - */ - protected void finalizeOpenUI() { - // rien par default } /** diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/longline/ActivityLonglinesUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/longline/ActivityLonglinesUIHandler.java index 8e46976..060b74d 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/longline/ActivityLonglinesUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/longline/ActivityLonglinesUIHandler.java @@ -31,8 +31,6 @@ import fr.ird.observe.services.data.longline.ActivityLonglineService; import fr.ird.observe.services.data.longline.TripLonglineService; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.list.ContentListUIHandler; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import java.util.List; @@ -46,9 +44,6 @@ import static org.nuiton.i18n.I18n.n; */ public class ActivityLonglinesUIHandler extends ContentListUIHandler<TripLongline, ActivityLongline> { - /** Logger */ - static private Log log = LogFactory.getLog(ActivityLonglinesUIHandler.class); - public ActivityLonglinesUIHandler(ActivityLonglinesUI ui) { super(ui, DataContextType.TripLongline, DataContextType.ActivityLongline); } @@ -63,6 +58,7 @@ public class ActivityLonglinesUIHandler extends ContentListUIHandler<TripLonglin // pas de marée ouverte, donc on ne peut pas ouvrir une activité addInfoMessage(n("observe.tripLongline.message.no.active.found")); return ContentMode.READ; + } // @@ -83,11 +79,13 @@ public class ActivityLonglinesUIHandler extends ContentListUIHandler<TripLonglin // il existe une activite d'ouverte dans la maree courante addInfoMessage(n("observe.activityLongline.message.active.found")); return ContentMode.UPDATE; + } // pas d'activité ouverte, on peut en ouvrir une addInfoMessage(n("observe.activityLongline.message.no.active.found")); return ContentMode.CREATE; + } // @@ -98,10 +96,12 @@ public class ActivityLonglinesUIHandler extends ContentListUIHandler<TripLonglin // il existe une activité ouverte dans la marée ouverte addInfoMessage(n("observe.activityLongline.message.active.found.for.other.trip")); + } else { // il n'existe pas d'activité ouverte dans la marée ouverte addInfoMessage(n("observe.activityLongline.message.no.active.found.for.other.trip")); + } return ContentMode.READ; @@ -109,7 +109,7 @@ public class ActivityLonglinesUIHandler extends ContentListUIHandler<TripLonglin } @Override - protected void loadDataInModel(String selectedId) { + protected List<ActivityLongline> onOpenUI(String selectedId) { TripLonglineService tripService = getService(TripLonglineService.class); TripLongline loaded = tripService.getTripLonglineStub(selectedId); @@ -120,13 +120,9 @@ public class ActivityLonglinesUIHandler extends ContentListUIHandler<TripLonglin ActivityLonglineService routeService = getService(ActivityLonglineService.class); List<ActivityLongline> activityLonglines = routeService.getActivityLonglineStubByTrip(selectedId); - if (log.isDebugEnabled()) { - log.debug("Will use " + activityLonglines.size() + " activities."); - } - bean.setActivityLongline(activityLonglines); - getModel().setData(activityLonglines); + return activityLonglines; } diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/longline/TripLonglinesUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/longline/TripLonglinesUIHandler.java index a431838..877368e 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/longline/TripLonglinesUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/longline/TripLonglinesUIHandler.java @@ -31,8 +31,6 @@ import fr.ird.observe.services.data.longline.TripLonglineService; import fr.ird.observe.services.referential.ReferentialService; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.list.ContentListUIHandler; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import java.util.List; @@ -46,9 +44,6 @@ import static org.nuiton.i18n.I18n.n; */ public class TripLonglinesUIHandler extends ContentListUIHandler<Program, TripLongline> { - /** Logger */ - static private final Log log = LogFactory.getLog(TripLonglinesUIHandler.class); - public TripLonglinesUIHandler(TripLonglinesUI ui) { super(ui, DataContextType.Program, DataContextType.TripLongline); } @@ -86,28 +81,21 @@ public class TripLonglinesUIHandler extends ContentListUIHandler<Program, TripLo } @Override - protected void finalizeOpenUI() { - String title = getDecoratorService().decorate(getBean()); - getUi().setContentTitle(title); - } - - @Override - protected void loadDataInModel(String selectedId) { + protected List<TripLongline> onOpenUI(String selectedId) { ReferentialService service = getService(ReferentialService.class); Program loaded = service.loadAndDecorate(Program.class, selectedId); Program bean = getBean(); - copy(Program.class, BinderService.DISPLAY,loaded, bean); + copy(Program.class, BinderService.DISPLAY, loaded, bean); + + String title = getDecoratorService().decorate(getBean()); + getUi().setContentTitle(title); TripLonglineService tripService = getService(TripLonglineService.class); List<TripLongline> tripLonglines = tripService.getTripLonglineStubByProgram(bean.getTopiaId()); - if (log.isDebugEnabled()) { - log.debug("Will use " + tripLonglines.size() + " trips."); - } - - getModel().setData(tripLonglines); + return tripLonglines; } diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/ActivitySeinesUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/ActivitySeinesUIHandler.java index 5b80eeb..d9661a8 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/ActivitySeinesUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/ActivitySeinesUIHandler.java @@ -30,8 +30,6 @@ import fr.ird.observe.services.data.seine.ActivitySeineService; import fr.ird.observe.services.data.seine.RouteService; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.list.ContentListUIHandler; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import java.util.List; @@ -43,9 +41,6 @@ import static org.nuiton.i18n.I18n.n; */ public class ActivitySeinesUIHandler extends ContentListUIHandler<Route, ActivitySeine> { - /** Logger */ - static private Log log = LogFactory.getLog(ActivitySeinesUIHandler.class); - public ActivitySeinesUIHandler(ActivitySeinesUI ui) { super(ui, DataContextType.Route, DataContextType.ActivitySeine); } @@ -60,6 +55,7 @@ public class ActivitySeinesUIHandler extends ContentListUIHandler<Route, Activit // pas de route ouverte, donc on ne peut pas ouvrir une activité addInfoMessage(n("observe.route.message.no.active.found")); return ContentMode.READ; + } // @@ -68,7 +64,6 @@ public class ActivitySeinesUIHandler extends ContentListUIHandler<Route, Activit boolean openActivity = dataContext.isOpenActivity(); - if (dataContext.isSelectedOpen(Route.class)) { // @@ -81,11 +76,13 @@ public class ActivitySeinesUIHandler extends ContentListUIHandler<Route, Activit // il existe une activité ouverte dans la route courante addInfoMessage(n("observe.activitySeine.message.active.found")); return ContentMode.UPDATE; + } // pas d'activité ouverte, on peut en ouvrir une addInfoMessage(n("observe.activitySeine.message.no.active.found")); return ContentMode.CREATE; + } // @@ -96,10 +93,12 @@ public class ActivitySeinesUIHandler extends ContentListUIHandler<Route, Activit // il existe une activité ouverte dans la route ouverte addInfoMessage(n("observe.activitySeine.message.active.found.for.other.route")); + } else { // il n'existe pas d'activité ouverte dans la route ouverte addInfoMessage(n("observe.activitySeine.message.no.active.found.for.other.route")); + } return ContentMode.READ; @@ -107,24 +106,20 @@ public class ActivitySeinesUIHandler extends ContentListUIHandler<Route, Activit } @Override - protected void loadDataInModel(String selectedId) { + protected List<ActivitySeine> onOpenUI(String routeId) { RouteService routeService = getService(RouteService.class); - Route loaded = routeService.getRouteStub(selectedId); + Route loaded = routeService.getRouteStub(routeId); Route bean = getBean(); copy(Route.class, BinderService.DISPLAY, loaded, bean); ActivitySeineService activityService = getService(ActivitySeineService.class); - List<ActivitySeine> activitySeines = activityService.getActivitySeineStubByRoute(selectedId); - - if (log.isDebugEnabled()) { - log.debug("Will use " + activitySeines.size() + " activities."); - } + List<ActivitySeine> activitySeines = activityService.getActivitySeineStubByRoute(routeId); bean.setActivitySeine(activitySeines); - getModel().setData(activitySeines); + return activitySeines; } diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/RoutesUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/RoutesUIHandler.java index f24e760..285ea24 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/RoutesUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/RoutesUIHandler.java @@ -30,8 +30,6 @@ import fr.ird.observe.services.data.seine.RouteService; import fr.ird.observe.services.data.seine.TripSeineService; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.list.ContentListUIHandler; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import java.util.List; @@ -43,9 +41,6 @@ import static org.nuiton.i18n.I18n.n; */ public class RoutesUIHandler extends ContentListUIHandler<TripSeine, Route> { - /** Logger */ - static private Log log = LogFactory.getLog(RoutesUIHandler.class); - public RoutesUIHandler(RoutesUI ui) { super(ui, DataContextType.TripSeine, DataContextType.Route); } @@ -62,6 +57,7 @@ public class RoutesUIHandler extends ContentListUIHandler<TripSeine, Route> { // pas de marée d'ouverte, donc on ne peut pas ouvrir une route addInfoMessage(n("observe.tripSeine.message.no.active.found")); return ContentMode.READ; + } // @@ -79,11 +75,13 @@ public class RoutesUIHandler extends ContentListUIHandler<TripSeine, Route> { // il existe une route ouverte dans la marée courante addInfoMessage(n("observe.route.message.active.found")); return ContentMode.UPDATE; + } // pas de route ouverte, on peut en ouvrir une addInfoMessage(n("observe.route.message.no.active.found")); return ContentMode.CREATE; + } // @@ -94,17 +92,20 @@ public class RoutesUIHandler extends ContentListUIHandler<TripSeine, Route> { //il existe une route existe dans la maree ouverte addInfoMessage(n("observe.route.message.active.found.for.other.trip")); + } else { // pas de route ouverte dans la maree ouverte addInfoMessage(n("observe.route.message.no.active.found.for.other.trip")); + } return ContentMode.READ; + } @Override - protected void loadDataInModel(String selectedId) { + protected List<Route> onOpenUI(String selectedId) { TripSeineService tripService = getService(TripSeineService.class); TripSeine loaded = tripService.getTripSeineStub(selectedId); @@ -114,13 +115,9 @@ public class RoutesUIHandler extends ContentListUIHandler<TripSeine, Route> { RouteService routeService = getService(RouteService.class); List<Route> routes = routeService.getRouteStubByTrip(selectedId); - if (log.isDebugEnabled()) { - log.debug("Will use " + routes.size() + " routes."); - } - bean.setRoute(routes); - getModel().setData(routes); + return routes; } diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/TripSeinesUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/TripSeinesUIHandler.java index dfece7f..7a4558e 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/TripSeinesUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/TripSeinesUIHandler.java @@ -30,8 +30,6 @@ import fr.ird.observe.services.data.seine.TripSeineService; import fr.ird.observe.services.referential.ReferentialService; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.list.ContentListUIHandler; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import java.util.List; @@ -43,9 +41,6 @@ import static org.nuiton.i18n.I18n.n; */ public class TripSeinesUIHandler extends ContentListUIHandler<Program, TripSeine> { - /** Logger */ - static private final Log log = LogFactory.getLog(TripSeinesUIHandler.class); - public TripSeinesUIHandler(TripSeinesUI ui) { super(ui, DataContextType.Program, DataContextType.TripSeine); } @@ -61,6 +56,7 @@ public class TripSeinesUIHandler extends ContentListUIHandler<Program, TripSeine // on peut reouvrir une maree addInfoMessage(n("observe.tripSeine.message.no.active.found")); return ContentMode.CREATE; + } // @@ -72,6 +68,7 @@ public class TripSeinesUIHandler extends ContentListUIHandler<Program, TripSeine // le program courant a une maree ouverte addInfoMessage(n("observe.tripSeine.message.active.found")); return ContentMode.UPDATE; + } // @@ -80,30 +77,24 @@ public class TripSeinesUIHandler extends ContentListUIHandler<Program, TripSeine addInfoMessage(n("observe.tripSeine.message.active.found.for.other.program")); return ContentMode.READ; - } - @Override - protected void finalizeOpenUI() { - String title = getDecoratorService().decorate(getBean()); - getUi().setContentTitle(title); } @Override - protected void loadDataInModel(String selectedId) { + protected List<TripSeine> onOpenUI(String selectedId) { ReferentialService service = getService(ReferentialService.class); Program loaded = service.loadAndDecorate(Program.class, selectedId); Program bean = getBean(); copy(Program.class, BinderService.DISPLAY, loaded, bean); + String title = getDecoratorService().decorate(getBean()); + getUi().setContentTitle(title); + TripSeineService tripService = getService(TripSeineService.class); List<TripSeine> tripSeines = tripService.getTripSeineStubByProgram(bean.getTopiaId()); - if (log.isDebugEnabled()) { - log.debug("Will use " + tripSeines.size() + " trips."); - } - - getModel().setData(tripSeines); + return tripSeines; } diff --git a/observe-swing/src/main/java/fr/ird/observe/ui/content/open/ContentOpenableUIHandler.java b/observe-swing/src/main/java/fr/ird/observe/ui/content/open/ContentOpenableUIHandler.java index 7aafb12..db307a5 100644 --- a/observe-swing/src/main/java/fr/ird/observe/ui/content/open/ContentOpenableUIHandler.java +++ b/observe-swing/src/main/java/fr/ird/observe/ui/content/open/ContentOpenableUIHandler.java @@ -100,7 +100,7 @@ public abstract class ContentOpenableUIHandler<E extends TopiaEntity & OpenableE } @Override - public void openUI() throws Exception { + public final void openUI() throws Exception { super.openUI(); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.