From 36b7d1a0c53c50746fca5c6a34abeec8bc982133 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 12 Feb 2014 09:31:33 -0500 Subject: [PATCH] IDEMPIERE-1749 Add window event validator for AD_Window / Integrate sample test case provided by hengsin --- .../META-INF/MANIFEST.MF | 5 ++++- .../OSGI-INF/paymentwindowvalidator.xml | 8 +++++++ org.adempiere.ui.zk.example/build.properties | 1 + .../validator/PaymentWindowValidator.java | 21 +++++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 org.adempiere.ui.zk.example/OSGI-INF/paymentwindowvalidator.xml create mode 100644 org.adempiere.ui.zk.example/src/org/adempiere/window/payment/validator/PaymentWindowValidator.java diff --git a/org.adempiere.ui.zk.example/META-INF/MANIFEST.MF b/org.adempiere.ui.zk.example/META-INF/MANIFEST.MF index a9d3a4632c..f6edfc3db7 100644 --- a/org.adempiere.ui.zk.example/META-INF/MANIFEST.MF +++ b/org.adempiere.ui.zk.example/META-INF/MANIFEST.MF @@ -10,8 +10,10 @@ Import-Package: org.adempiere.base, org.adempiere.base.equinox, org.adempiere.exceptions, org.adempiere.plugin.utils, + org.adempiere.util, org.adempiere.webui.action, org.adempiere.webui.adwindow, + org.adempiere.webui.adwindow.validator, org.adempiere.webui.apps, org.adempiere.webui.component, org.adempiere.webui.window, @@ -24,5 +26,6 @@ Import-Package: org.adempiere.base, org.zkoss.zul, org.zkoss.zul.event, org.zkoss.zul.impl -Service-Component: OSGI-INF/export.xml +Service-Component: OSGI-INF/export.xml, + OSGI-INF/paymentwindowvalidator.xml Export-Package: action.images diff --git a/org.adempiere.ui.zk.example/OSGI-INF/paymentwindowvalidator.xml b/org.adempiere.ui.zk.example/OSGI-INF/paymentwindowvalidator.xml new file mode 100644 index 0000000000..0ee90dd3c8 --- /dev/null +++ b/org.adempiere.ui.zk.example/OSGI-INF/paymentwindowvalidator.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/org.adempiere.ui.zk.example/build.properties b/org.adempiere.ui.zk.example/build.properties index 9bc7499535..ed46f7cd6d 100644 --- a/org.adempiere.ui.zk.example/build.properties +++ b/org.adempiere.ui.zk.example/build.properties @@ -2,5 +2,6 @@ output.. = bin/ bin.includes = META-INF/,\ .,\ OSGI-INF/export.xml,\ + OSGI-INF/paymentwindowvalidator.xml,\ OSGI-INF/ source.. = src/ diff --git a/org.adempiere.ui.zk.example/src/org/adempiere/window/payment/validator/PaymentWindowValidator.java b/org.adempiere.ui.zk.example/src/org/adempiere/window/payment/validator/PaymentWindowValidator.java new file mode 100644 index 0000000000..84ce91ca52 --- /dev/null +++ b/org.adempiere.ui.zk.example/src/org/adempiere/window/payment/validator/PaymentWindowValidator.java @@ -0,0 +1,21 @@ +package org.adempiere.window.payment.validator; + +import org.adempiere.util.Callback; +import org.adempiere.webui.adwindow.validator.WindowValidator; +import org.adempiere.webui.adwindow.validator.WindowValidatorEvent; +import org.adempiere.webui.adwindow.validator.WindowValidatorEventType; +import org.adempiere.webui.window.FDialog; + +public class PaymentWindowValidator implements WindowValidator { + + @Override + public void onWindowEvent(WindowValidatorEvent event, + Callback callback) { + if (event.getName().equals(WindowValidatorEventType.BEFORE_PRINT.getName())) { + FDialog.ask(event.getWindow().getADWindowContent().getWindowNo(), + event.getWindow().getComponent(), "Print ?", callback); + } else { + callback.onCallback(Boolean.TRUE); + } + } +} \ No newline at end of file