Author: bleny Date: 2011-04-06 17:50:38 +0000 (Wed, 06 Apr 2011) New Revision: 1151 Log: forgot file Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java 2011-04-06 17:49:48 UTC (rev 1150) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java 2011-04-06 17:50:38 UTC (rev 1151) @@ -63,6 +63,7 @@ import org.apache.tapestry5.annotations.Import; import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.annotations.InjectPage; +import org.apache.tapestry5.annotations.Log; import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.annotations.SessionState; @@ -104,9 +105,6 @@ @Property private ConnectedUser user; - @InjectComponent - private BoatFilterComponent filterComponent; - @Inject private ServiceReferential serviceReferential; @@ -122,54 +120,25 @@ @Inject private PropertyAccess propertyAccess; -// @Property -// private String sampleRowContextId; - - /** Selected boat immatriculation for showing boatInfos */ - //@Persist(PersistenceConstants.FLASH) - @Persist - private Integer boatSelectedImmatriculation; - - @Persist - private BoatFilterManager filterManager; - - public BoatFilterManager getFilterManager() { - if (filterManager == null) { - filterManager = new BoatFilterManager(user, serviceBoat); - } - return filterManager; - } - - public void setFilterManager(BoatFilterManager filterManager) { - this.filterManager = filterManager; - } - - public Integer getBoatSelectedImmatriculation() { - return boatSelectedImmatriculation; - } - - public void setBoatSelectedImmatriculation(Integer boatSelectedImmatriculation) { - this.boatSelectedImmatriculation = boatSelectedImmatriculation; - } - void setupRender() throws WaoException { - if (boatSelectedImmatriculation != null && getBoatSelected() == null) { - layout.addFatal("L'immatriculation " + boatSelectedImmatriculation + - " ne correspond à aucun navire affichable. " + - "Veuillez à enlever cette immatriculation de l'url puis" + - " rechargez la page."); - boatSelectedImmatriculation = null; - } +// if (boatSelectedImmatriculation != null && getBoatSelected() == null) { +// layout.addFatal("L'immatriculation " + boatSelectedImmatriculation + +// " ne correspond à aucun navire affichable. " + +// "Veuillez à enlever cette immatriculation de l'url puis" + +// " rechargez la page."); +// boatSelectedImmatriculation = null; +// } // Initialize filters using AbstractFilteredPage superclass // initSelectFilters(false, false, false); // // The company of connected user will be contributed to abstractFilteredPage // initCompanyFilter(); + boats = null; + boatSelectedImmatriculation = null; companyBoatInfos = null; } - // void onActivate(EventContext ec) { // sampleRowContextId = ec.get(String.class, 0); // if (ec.getCount() > 1) { @@ -186,143 +155,52 @@ // return sampleRowContextId; // } - /**************************** Import Forms ********************************/ + StreamResponse onActionFromExportShowBoats() { + return new ExportStreamResponse("wao-navires") { -// /** Csv file for boats import */ + @Override + public InputStream getStream() throws IOException { + InputStream result = null; + try { + if (log.isDebugEnabled()) { + log.debug("Filter sampleRow : " + getFilter().getSampleRow()); + } + result = serviceBoat.exportBoatCsv(getBoatFilter()); + } catch (WaoException eee) { + throw new IOException(eee); + } + return result; + } + }; + } + + /******************** FILTERS *******************/ + + @InjectComponent + private BoatFilterComponent filterComponent; + // @Property -// private UploadedFile boatsCsvFile; -// -// /** Csv file for activityCalendar import, can be a Gzip file */ -// @Property -// private UploadedFile activityCalendarsCsvFile; -// -// private InputStream activityCalendarLogFile; -// -// private InputStream activityCalendarLogAccessFile; -// -// protected static final String GZIP_MIMETYPE = "application/x-gzip"; -// -// public boolean canImportReferentials() { -// return user.isAdmin() && !user.isReadOnly(); -// } -// -// @Log -// void onSuccessFromImportBoatsForm() { -// if (canImportReferentials()) { -// try { -// int[] result = serviceBoat.importBoatCsv( -// boatsCsvFile.getStream()); -// // Suppress persitant list of boats -// boats = null; -// layout.addInfo(result[0] + " navires importés dont " + -// result[1] + " nouveaux"); -// } catch (WaoBusinessException eee) { -// layout.addError(eee.getMessage()); -// } -// } -// } -// -// InputStream getActivityCalendarLogFile() throws FileNotFoundException { -// if (activityCalendarLogFile == null) { -// activityCalendarLogFile = serviceBoat.getActivityCalendarLogFile(); -// } -// return activityCalendarLogFile; -// } -// -// public boolean isLogFileExists() { -// try { -// getActivityCalendarLogFile(); -// return true; -// } catch (FileNotFoundException eee) { -// if (log.isInfoEnabled()) { -// log.info("Aucun fichier de log existant pour les calendriers d'activité"); -// } -// return false; -// } -// } -// -// InputStream getActivityCalendarLogAccessFile() throws FileNotFoundException { -// if (activityCalendarLogAccessFile == null) { -// activityCalendarLogAccessFile = -// serviceBoat.getActivityCalendarLogAccessFile(); -// } -// return activityCalendarLogAccessFile; -// } -// -// public boolean isLogAccessFileExists() { -// try { -// getActivityCalendarLogAccessFile(); -// return true; -// } catch (FileNotFoundException eee) { -// if (log.isInfoEnabled()) { -// log.info("Aucun fichier de log existant pour les accès " + -// "utilisateurs aux calendriers d'activité"); -// } -// return false; -// } -// } -// -// @Log -// void onSuccessFromImportActivityCalendarsForm() -// throws WaoException, IOException { -// if (canImportReferentials()) { -// InputStream input = activityCalendarsCsvFile.getStream(); -// if (log.isDebugEnabled()) { -// log.debug("Content type : " + -// activityCalendarsCsvFile.getContentType()); -// } -// if (activityCalendarsCsvFile.getContentType(). -// equals(GZIP_MIMETYPE)) { -// if (log.isDebugEnabled()) { -// log.debug("Gzip file"); -// } -// input = new GZIPInputStream(input); -// } -// serviceBoat.importActivityCalendarCsv(input); -// companyBoatInfos = null; -// } -// } -// -// public StreamResponse onActionFromShowActivityCalendarLogFile() { -// return new StreamResponse() { -// -// @Override -// public String getContentType() { -// return "text/plain;charset=utf-8"; -// } -// -// @Override -// public InputStream getStream() throws IOException { -// return getActivityCalendarLogFile(); -// } -// -// @Override -// public void prepareResponse(Response response) { -// } -// }; -// } -// -// public StreamResponse onActionFromShowActivityCalendarLogAccessFile() { -// return new StreamResponse() { -// -// @Override -// public String getContentType() { -// return "text/plain;charset=utf-8"; -// } -// -// @Override -// public InputStream getStream() throws IOException { -// return getActivityCalendarLogAccessFile(); -// } -// -// @Override -// public void prepareResponse(Response response) { -// } -// }; -// } +// private String sampleRowContextId; - /**************************** Filters Form *****************************************/ + /** Selected boat immatriculation for showing boatInfos */ + @Persist + private Integer boatSelectedImmatriculation; + @Persist + private BoatFilterManager filterManager; + + public BoatFilterManager getFilterManager() { + if (filterManager == null) { + filterManager = new BoatFilterManager(user, serviceBoat); + } + return filterManager; + } + + public void setFilterManager(BoatFilterManager filterManager) { + this.filterManager = filterManager; + } + + /** Filters to apply on boats list */ // @Persist // private BoatFilter boatFilter; @@ -374,16 +252,12 @@ // return professionSelectModel; // } - /**************************** FILTERS *************************************/ - public boolean isFiltersVisible() { return filterComponent.getFiltersVisible(); } Object onActionFromShowFilters() { - filterComponent.switchFiltersVisible(); - if (isFiltersVisible()) { return filterComponent; } else { @@ -405,7 +279,7 @@ * Other filters are managed by AbstractFilteredPage superclass. * * @throws WaoException for business errors - * @see AbstractFilteredPage#onSelectedFromSearch() + * @see AbstractFilteredPage#onSelectedFromSearch() */ // @Override // public void onSelectedFromSearch() throws WaoException { @@ -442,9 +316,29 @@ // companyBoatInfos = null; // return this; // } + @Log + Object onSuccessFromFiltersForm() throws WaoException { + // Suppress persistant boats list to get new one with filter + boats = null; + // Suppress persistant immatriculation for boat selected + boatSelectedImmatriculation = null; + // Suppress persistant boat informations for boat selected + companyBoatInfos = null; + return boatsZone; + } - /**************************** Boats List *****************************************/ + /*************** RIGHT PANEL ****************/ + public Integer getBoatSelectedImmatriculation() { + return boatSelectedImmatriculation; + } + + public void setBoatSelectedImmatriculation(Integer boatSelectedImmatriculation) { + this.boatSelectedImmatriculation = boatSelectedImmatriculation; + } + + /*************** Boats List (left panel) ****************/ + /** DataSource containing the boats */ @Persist private BoatDataSource boats; @@ -509,25 +403,6 @@ return false; } - StreamResponse onActionFromExportShowBoats() { - return new ExportStreamResponse("wao-navires") { - - @Override - public InputStream getStream() throws IOException { - InputStream result = null; - try { - if (log.isDebugEnabled()) { - log.debug("Filter sampleRow : " + getFilter().getSampleRow()); - } - result = serviceBoat.exportBoatCsv(getBoatFilter()); - } catch (WaoException eee) { - throw new IOException(eee); - } - return result; - } - }; - } - Block onActionFromShowBoatInfos(Integer boatImma) throws WaoException { boatSelectedImmatriculation = boatImma; // Suppress persistant boat informations @@ -755,8 +630,6 @@ return condition1 || isElligibleBoatCompanyActiveFalse() ? "line-through" : ""; } - /** /////////////////////// ACTIONS //////////////////////////////////// **/ - /** * Only user with no readOnly rights can edit BoatInfos. * @@ -777,19 +650,14 @@ getCompanyBoatInfos(); return boatInfosZone.getBody(); } -// -// Block onActionFromEditBoatInfos() throws WaoException { -// if (canEditBoatInfos()) { -// boatInfosEditable = true; -// // WARNING :: Reset sampleRow select for edition mode, no limit for -// // showing sampleRows instead of filters -// getFilter().setNbMonthFinishedFromToday(null); -// resetSampleRowSelect(); -// getFilter().setNbMonthFinishedFromToday(-1); -// } -// return boatInfosZone.getBody(); -// } + Block onActionFromEditBoatInfos() throws WaoException { + if (canEditBoatInfos()) { + boatInfosEditable = true; + } + return boatInfosZone.getBody(); + } + Block onActionFromCancelEditBoatInfos() throws WaoException { /*if (propertyChange.isChanged()) { if (log.isDebugEnabled()) { @@ -866,32 +734,24 @@ /**************************** Go to last ActivityCalendar *****************/ -// @InjectPage -// private BoatActivityCalendar calendarPage; +//// @InjectPage +//// private BoatActivityCalendar calendarPage; +// +// @Inject +// private PageRenderLinkSource renderLink; +// +// public boolean hasActivityCalendar() throws WaoException { +// return getBoatSelected() != null && +// getBoatSelected().sizeActivityCalendar() != 0; +// } +// +// Link onActionFromShowLastActivityCalendar() throws WaoException { +// Link result = renderLink.createPageRenderLinkWithContext( +// BoatActivityCalendar.class, +// getBoatSelected().getImmatriculation()); +// return result; +//// calendarPage.setBoat(getBoatSelected()); +//// return calendarPage; +// } - @Inject - private PageRenderLinkSource renderLink; - - public boolean hasActivityCalendar() throws WaoException { - return getBoatSelected() != null && - getBoatSelected().sizeActivityCalendar() != 0; - } - - Link onActionFromShowLastActivityCalendar() throws WaoException { - Link result = renderLink.createPageRenderLinkWithContext( - BoatActivityCalendar.class, - getBoatSelected().getImmatriculation()); - return result; -// calendarPage.setBoat(getBoatSelected()); -// return calendarPage; - } - - /*************************************** I18N ****************************/ - - @Inject - private Messages messages; - - public String getLabelForEnum(Enum value) { - return messages.get(value.getDeclaringClass().getSimpleName() + "." + value.name()); - } }