From 5827730776a124218ab40daddd32c25925758c79 Mon Sep 17 00:00:00 2001 From: Nicolas Micoud Date: Mon, 30 Jul 2012 16:51:09 +0200 Subject: [PATCH] IDEMPIERE-319 - Enhancement for Map and Route buttons --- .../org/compiere/grid/ed/VLocationDialog.java | 25 +++++++++++++++++-- .../webui/window/WLocationDialog.java | 23 +++++++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocationDialog.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocationDialog.java index 81435b0e81..a2c1bcea76 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocationDialog.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocationDialog.java @@ -498,7 +498,7 @@ public class VLocationDialog extends CDialog //BEGIN fernandinho/ricardo else if (e.getSource() == toLink) { - String urlString = MLocation.LOCATION_MAPS_URL_PREFIX + m_location.getMapsLocation(); + String urlString = MLocation.LOCATION_MAPS_URL_PREFIX + getFullAdress(); String message = null; try @@ -520,7 +520,7 @@ public class VLocationDialog extends CDialog String urlString = MLocation.LOCATION_MAPS_ROUTE_PREFIX + MLocation.LOCATION_MAPS_SOURCE_ADDRESS + orgLocation.getMapsLocation() + //org - MLocation.LOCATION_MAPS_DESTINATION_ADDRESS + m_location.getMapsLocation(); //partner + MLocation.LOCATION_MAPS_DESTINATION_ADDRESS + getFullAdress(); //partner String message = null; try { @@ -803,4 +803,25 @@ public class VLocationDialog extends CDialog } + /** returns a string that contains all fields of current form */ + String getFullAdress() + { + MRegion region = null; + + if (fRegion.getSelectedItem()!=null) + region = new MRegion(Env.getCtx(), ((MRegion)fRegion.getSelectedItem()).getC_Region_ID(), null); + + MCountry c = (MCountry)fCountry.getSelectedItem(); + + String address = ""; + address = address + (fAddress1.getText() != null ? fAddress1.getText() + ", " : ""); + address = address + (fAddress2.getText() != null ? fAddress2.getText() + ", " : ""); + address = address + (fCity.getText() != null ? fCity.getText() + ", " : ""); + if (region != null) + address = address + (region.getName() != null ? region.getName() + ", " : ""); + + address = address + (c.getName() != null ? c.getName() : ""); + return address.replace(" ", "+"); + } + } // VLocationDialog diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java index 2dbacd733f..f1ad945e2b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java @@ -540,7 +540,7 @@ public class WLocationDialog extends Window implements EventListener } else if (toLink.equals(event.getTarget())) { - String urlString = MLocation.LOCATION_MAPS_URL_PREFIX + m_location.getMapsLocation(); + String urlString = MLocation.LOCATION_MAPS_URL_PREFIX + getFullAdress(); String message = null; try { Executions.getCurrent().sendRedirect(urlString, "_blank"); @@ -559,7 +559,7 @@ public class WLocationDialog extends Window implements EventListener String urlString = MLocation.LOCATION_MAPS_ROUTE_PREFIX + MLocation.LOCATION_MAPS_SOURCE_ADDRESS + orgLocation.getMapsLocation() + //org - MLocation.LOCATION_MAPS_DESTINATION_ADDRESS + m_location.getMapsLocation(); //partner + MLocation.LOCATION_MAPS_DESTINATION_ADDRESS + getFullAdress(); //partner String message = null; try { Executions.getCurrent().sendRedirect(urlString, "_blank"); @@ -700,5 +700,24 @@ public class WLocationDialog extends Window implements EventListener } super.dispose(); } + /** returns a string that contains all fields of current form */ + String getFullAdress() + { + MRegion region = null; + if (lstRegion.getSelectedItem()!=null) + region = new MRegion(Env.getCtx(), ((MRegion)lstRegion.getSelectedItem().getValue()).getC_Region_ID(), null); + + MCountry c = (MCountry)lstCountry.getSelectedItem().getValue(); + + String address = ""; + address = address + (txtAddress1.getText() != null ? txtAddress1.getText() + ", " : ""); + address = address + (txtAddress2.getText() != null ? txtAddress2.getText() + ", " : ""); + address = address + (txtCity.getText() != null ? txtCity.getText() + ", " : ""); + if (region != null) + address = address + (region.getName() != null ? region.getName() + ", " : ""); + + address = address + (c.getName() != null ? c.getName() : ""); + return address.replace(" ", "+"); + } }