r3173 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports
Author: vsalaun Date: 2011-06-14 12:22:49 +0200 (Tue, 14 Jun 2011) New Revision: 3173 Url: http://chorem.org/repositories/revision/lima/3173 Log: #347 updating VAT view, handler, tableModel Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatViewHandler.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatTableModel.java 2011-06-10 14:05:35 UTC (rev 3172) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatTableModel.java 2011-06-14 10:22:49 UTC (rev 3173) @@ -185,6 +185,10 @@ return result; } + public FiscalPeriod getFiscalPeriod() { + return selectedFiscalPeriod; + } + public void setFiscalPeriod(FiscalPeriod fiscalPeriod){ selectedFiscalPeriod = fiscalPeriod; refresh(); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatView.jaxx 2011-06-10 14:05:35 UTC (rev 3172) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatView.jaxx 2011-06-14 10:22:49 UTC (rev 3173) @@ -33,6 +33,10 @@ editable="false"/> </cell> <cell> + <EnumEditor id='DocumentEditor' + constructorParams='org.chorem.lima.business.utils.FormatsEnum.class'/> + </cell> + <cell> <JButton id="editVatButton" text="lima.reports.vat" onActionPerformed="getHandler().editVat()"/> </cell> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatViewHandler.java 2011-06-10 14:05:35 UTC (rev 3172) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatViewHandler.java 2011-06-14 10:22:49 UTC (rev 3173) @@ -1,7 +1,19 @@ package org.chorem.lima.ui.vatreports; +import java.awt.Desktop; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.text.SimpleDateFormat; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.LimaConfig; +import org.chorem.lima.business.DocumentServiceMonitorable; +import org.chorem.lima.business.HttpServerServiceMonitorable; +import org.chorem.lima.business.utils.DocumentsEnum; +import org.chorem.lima.business.utils.FormatsEnum; +import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.vatreports.VatTable; import org.chorem.lima.ui.vatreports.VatTableModel; import org.chorem.lima.ui.vatreports.VatView; @@ -17,8 +29,22 @@ protected VatTableModel tableModel; + protected DocumentServiceMonitorable documentService; + + private static SimpleDateFormat dateFormat = + new SimpleDateFormat("yyyy-MM-dd"); + + protected int port; + protected VatViewHandler(VatView view) { this.view = view; + + port = LimaServiceFactory.getInstance().getService( + HttpServerServiceMonitorable.class).getHttpPort(); + + documentService = + LimaServiceFactory.getInstance().getService( + DocumentServiceMonitorable.class); } /** @@ -32,7 +58,23 @@ * Edit VAT document */ public void editVat() { - + if (tableModel.getFiscalPeriod() != null){ + FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem(); + String address = LimaConfig.getInstance().getHostAdress(); + + try { + String url = "http://"+address+":"+port+"/?beginDate=" + + dateFormat.format(tableModel.getFiscalPeriod().getBeginDate()) + + "&endDate="+dateFormat.format(tableModel.getFiscalPeriod().getEndDate()) + + "&format="+selectedEnum.getExtension()+"&model=" + + DocumentsEnum.VAT.getFileName(); + Desktop.getDesktop().browse(new URI(url)); + } catch (IOException e) { + log.error("Can't open browser", e); + } catch (URISyntaxException e) { + log.error("Can't create news URI", e); + } + } } /**
participants (1)
-
vsalaun@users.chorem.org