From f5dc3ba2c8ce273f2b8d0df82a861ad79caa75bf Mon Sep 17 00:00:00 2001 From: hengsin Date: Mon, 26 Jul 2021 20:42:29 +0800 Subject: [PATCH] IDEMPIERE-4059 Print format editor (#794) --- .../oracle/202107260400_IDEMPIERE-4059.sql | 14 + .../202107260400_IDEMPIERE-4059.sql | 11 + .../server.product.launch | 1 + org.adempiere.ui.zk-feature/feature.xml | 15 + .../org/adempiere/webui/action/Actions.java | 64 +- .../org/adempiere/webui/action/IAction.java | 10 +- .../webui/adwindow/ADWindowToolbar.java | 36 +- .../adempiere/webui/adwindow/DetailPane.java | 10 +- ...intformat.editor.action.EditorAction24.png | Bin 0 -> 3621 bytes org.idempiere.printformat.editor/.project | 39 + .../.settings/org.eclipse.pde.core.prefs | 3 + .../META-INF/MANIFEST.MF | 27 + ...printformat.editor.action.EditorAction.xml | 7 + .../build.properties | 5 + org.idempiere.printformat.editor/pom.xml | 12 + ...intformat.editor.action.EditorAction24.png | Bin 0 -> 3621 bytes .../printformat/editor/Activator.java | 35 + .../printformat/editor/FieldPosition.java | 86 + .../printformat/editor/PrintAreaBean.java | 115 ++ .../editor/action/EditorAction.java | 65 + .../editor/ui/PrintFormatEditorUtil.java | 147 ++ .../editor/ui/WPrintFormatEditor.java | 1391 +++++++++++++++++ .../editor/ui/WPrintFormatEditorForm.java | 670 ++++++++ pom.xml | 1 + 24 files changed, 2746 insertions(+), 18 deletions(-) create mode 100644 migration/i8.2z/oracle/202107260400_IDEMPIERE-4059.sql create mode 100644 migration/i8.2z/postgresql/202107260400_IDEMPIERE-4059.sql create mode 100644 org.adempiere.ui.zk/WEB-INF/src/web/theme/default/images/org.idempiere.printformat.editor.action.EditorAction24.png create mode 100644 org.idempiere.printformat.editor/.project create mode 100644 org.idempiere.printformat.editor/.settings/org.eclipse.pde.core.prefs create mode 100644 org.idempiere.printformat.editor/META-INF/MANIFEST.MF create mode 100644 org.idempiere.printformat.editor/OSGI-INF/org.idempiere.printformat.editor.action.EditorAction.xml create mode 100644 org.idempiere.printformat.editor/build.properties create mode 100644 org.idempiere.printformat.editor/pom.xml create mode 100644 org.idempiere.printformat.editor/src/action/images/org.idempiere.printformat.editor.action.EditorAction24.png create mode 100644 org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/Activator.java create mode 100644 org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/FieldPosition.java create mode 100644 org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/PrintAreaBean.java create mode 100644 org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/action/EditorAction.java create mode 100644 org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/ui/PrintFormatEditorUtil.java create mode 100644 org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/ui/WPrintFormatEditor.java create mode 100644 org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/ui/WPrintFormatEditorForm.java diff --git a/migration/i8.2z/oracle/202107260400_IDEMPIERE-4059.sql b/migration/i8.2z/oracle/202107260400_IDEMPIERE-4059.sql new file mode 100644 index 0000000000..d8bc81a966 --- /dev/null +++ b/migration/i8.2z/oracle/202107260400_IDEMPIERE-4059.sql @@ -0,0 +1,14 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Jul 25, 2021, 12:17:29 PM MYT +INSERT INTO AD_Message (MsgType,MsgText,MsgTip,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Print Format Editor','Visual editor for print format',0,0,'Y',TO_DATE('2021-07-25 12:17:28','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-07-25 12:17:28','YYYY-MM-DD HH24:MI:SS'),100,200713,'org.idempiere.printformat.editor.action.EditorAction.label','D','8c59d7b9-d69a-49a2-9031-e62696efc8ff') +; + +-- Jul 25, 2021, 12:22:16 PM MYT +INSERT INTO AD_ToolBarButton (AD_Client_ID,AD_Org_ID,Created,CreatedBy,ComponentName,IsActive,AD_ToolBarButton_ID,Name,Updated,UpdatedBy,IsCustomization,ActionClassName,KeyStroke_KeyCode,KeyStroke_Modifiers,AD_ToolBarButton_UU,Action,DisplayLogic,SeqNo,IsAdvancedButton,IsAddSeparator,EntityType,IsShowMore) VALUES (0,0,TO_DATE('2021-07-25 12:22:15','YYYY-MM-DD HH24:MI:SS'),100,'PrintFormatEditor','Y',200115,'Print Format Editor',TO_DATE('2021-07-25 12:22:15','YYYY-MM-DD HH24:MI:SS'),100,'Y','org.idempiere.printformat.editor.action.EditorAction',0,0,'cc75241b-291f-4a05-8719-5a245b4ff943','W','@_WinInfo_AD_Window_ID@=240 & @AD_Client_ID@=@#AD_Client_ID@ & @AD_PrintFormat_ID@>0',0,'N','N','D','N') +; + +SELECT register_migration_script('202107260400_IDEMPIERE-4059.sql') FROM dual +; + diff --git a/migration/i8.2z/postgresql/202107260400_IDEMPIERE-4059.sql b/migration/i8.2z/postgresql/202107260400_IDEMPIERE-4059.sql new file mode 100644 index 0000000000..b17da3c032 --- /dev/null +++ b/migration/i8.2z/postgresql/202107260400_IDEMPIERE-4059.sql @@ -0,0 +1,11 @@ +-- Jul 25, 2021, 12:17:29 PM MYT +INSERT INTO AD_Message (MsgType,MsgText,MsgTip,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Print Format Editor','Visual editor for print format',0,0,'Y',TO_TIMESTAMP('2021-07-25 12:17:28','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-07-25 12:17:28','YYYY-MM-DD HH24:MI:SS'),100,200713,'org.idempiere.printformat.editor.action.EditorAction.label','D','8c59d7b9-d69a-49a2-9031-e62696efc8ff') +; + +-- Jul 25, 2021, 12:22:16 PM MYT +INSERT INTO AD_ToolBarButton (AD_Client_ID,AD_Org_ID,Created,CreatedBy,ComponentName,IsActive,AD_ToolBarButton_ID,Name,Updated,UpdatedBy,IsCustomization,ActionClassName,KeyStroke_KeyCode,KeyStroke_Modifiers,AD_ToolBarButton_UU,"action",DisplayLogic,SeqNo,IsAdvancedButton,IsAddSeparator,EntityType,IsShowMore) VALUES (0,0,TO_TIMESTAMP('2021-07-25 12:22:15','YYYY-MM-DD HH24:MI:SS'),100,'PrintFormatEditor','Y',200115,'Print Format Editor',TO_TIMESTAMP('2021-07-25 12:22:15','YYYY-MM-DD HH24:MI:SS'),100,'Y','org.idempiere.printformat.editor.action.EditorAction',0,0,'cc75241b-291f-4a05-8719-5a245b4ff943','W','@_WinInfo_AD_Window_ID@=240 & @AD_Client_ID@=@#AD_Client_ID@ & @AD_PrintFormat_ID@>0',0,'N','N','D','N') +; + +SELECT register_migration_script('202107260400_IDEMPIERE-4059.sql') FROM dual +; + diff --git a/org.adempiere.server-feature/server.product.launch b/org.adempiere.server-feature/server.product.launch index 1e5552d179..b91ab275be 100644 --- a/org.adempiere.server-feature/server.product.launch +++ b/org.adempiere.server-feature/server.product.launch @@ -412,6 +412,7 @@ + diff --git a/org.adempiere.ui.zk-feature/feature.xml b/org.adempiere.ui.zk-feature/feature.xml index 86c3ecf65f..302585c2c8 100644 --- a/org.adempiere.ui.zk-feature/feature.xml +++ b/org.adempiere.ui.zk-feature/feature.xml @@ -42,4 +42,19 @@ fragment="true" unpack="false"/> + + + + diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/Actions.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/Actions.java index 7809b53c0e..f0da9f5834 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/Actions.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/Actions.java @@ -15,9 +15,12 @@ package org.adempiere.webui.action; import java.io.IOException; import java.io.InputStream; +import java.net.URL; import org.adempiere.base.IServiceHolder; import org.adempiere.base.Service; +import org.adempiere.webui.theme.ITheme; +import org.adempiere.webui.theme.ThemeManager; import org.compiere.util.CCache; import org.zkoss.image.AImage; @@ -32,6 +35,11 @@ public class Actions { private static CCache> trackerCache = new CCache>(null, "ActionsServiceTracker", 5, false); private static CCache imageCache = new CCache(null, "ActionsImages",5, false); + /** + * + * @param actionId + * @return {@link IServiceHolder} + */ public static IServiceHolder getAction(String actionId) { IServiceHolder action = null; synchronized (trackerCache) { @@ -49,6 +57,11 @@ public class Actions { return action; } + /** + * + * @param actionId + * @return {@link AImage} + */ public static AImage getActionImage(String actionId) { AImage aImage = null; synchronized (imageCache) { @@ -57,21 +70,66 @@ public class Actions { if (aImage != null) return aImage; + String imageName = actionId+ "24.png"; IServiceHolder action = getAction(actionId); if (action.getService() != null) { - String path = ACTION_IMAGES_PATH + actionId + "24.png"; - InputStream inputStream = action.getService().getClass().getClassLoader().getResourceAsStream(path); + InputStream inputStream = null; + //try current theme + String themePath = ThemeManager.getThemeResource(imageName); + URL themeURL = ThemeManager.class.getResource(ThemeManager.toClassPathResourcePath(themePath)); + if (themeURL != null) { + try { + inputStream = themeURL.openStream(); + } catch (IOException e) { + } + } + //try plugin theme resource + if (inputStream == null) { + String path = ACTION_IMAGES_PATH + ThemeManager.getTheme() + "/" + imageName; + inputStream = action.getService().getClass().getClassLoader().getResourceAsStream(path); + } + //try plugin default theme resource + if (inputStream == null) { + if (!(ITheme.ZK_THEME_DEFAULT.equals(ThemeManager.getTheme()))) { + String path = ACTION_IMAGES_PATH + ITheme.ZK_THEME_DEFAULT + "/" + imageName; + inputStream = action.getService().getClass().getClassLoader().getResourceAsStream(path); + } + } + //fall back to plugin resource + if (inputStream == null) { + String path = ACTION_IMAGES_PATH + imageName; + inputStream = action.getService().getClass().getClassLoader().getResourceAsStream(path); + } if (inputStream != null) { try { aImage = new AImage(actionId, inputStream); } catch (IOException e) { + } finally { + try { + inputStream.close(); + } catch (IOException e) {} } } - if (aImage != null) + if (aImage != null) { synchronized (imageCache) { imageCache.put(actionId, aImage); } + } } return aImage; } + + /** + * + * @param actionId + * @return font icon sclass + */ + public static String getActionIconSclass(String actionId) { + IServiceHolder action = getAction(actionId); + IAction service = action.getService(); + if (service != null) { + return service.getIconSclass(); + } + return ""; + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/IAction.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/IAction.java index 0e1666c022..b6132d8007 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/IAction.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/IAction.java @@ -31,7 +31,13 @@ public interface IAction { * you can customize toolbar button like add style, client javascript,... * @param toolbarButton */ - public default void decorate(Toolbarbutton toolbarButton) { - + public default void decorate(Toolbarbutton toolbarButton) { + } + + /** + * @return font icon class + */ + public default String getIconSclass() { + return ""; } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java index c1fea592d9..53f07eea3c 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java @@ -300,12 +300,16 @@ public class ADWindowToolbar extends FToolbar implements EventListener if (serviceHolder != null && action != null) { String labelKey = actionId + ".label"; String tooltipKey = actionId + ".tooltip"; - String label = Msg.getMsg(Env.getCtx(), labelKey); - String tooltiptext = Msg.getMsg(Env.getCtx(), tooltipKey); + String label = Msg.getMsg(Env.getCtx(), labelKey, true); + String tooltiptext = Msg.getMsg(Env.getCtx(), labelKey, false); + if (Util.isEmpty(tooltiptext, true)) + tooltiptext = Msg.getMsg(Env.getCtx(), tooltipKey, true); + else + tooltipKey = labelKey; if (labelKey.equals(label)) { label = button.getName(); } - if (tooltipKey.equals(tooltiptext)) { + if (tooltipKey.equals(tooltiptext) || labelKey.equals(tooltiptext)) { tooltipKey = null; } ToolBarButton btn = createButton(button.getComponentName(), null, tooltipKey); @@ -313,11 +317,22 @@ public class ADWindowToolbar extends FToolbar implements EventListener btn.setId(button.getName()); btn.setDisabled(false); - AImage aImage = Actions.getActionImage(actionId); - if (aImage != null) { - btn.setImageContent(aImage); - } else { - btn.setLabel(label); + btn.setIconSclass(null); + if (ThemeManager.isUseFontIconForImage()) { + String iconSclass = Actions.getActionIconSclass(actionId); + if (!Util.isEmpty(iconSclass, true)) { + btn.setIconSclass(iconSclass); + LayoutUtils.addSclass("font-icon-toolbar-button", btn); + } + } + //not using font icon, fallback to image or label + if (Util.isEmpty(btn.getIconSclass(), true)) { + AImage aImage = Actions.getActionImage(actionId); + if (aImage != null) { + btn.setImageContent(aImage); + } else { + btn.setLabel(label); + } } ToolbarCustomButton toolbarCustomBtn = new ToolbarCustomButton(button, btn, actionId, windowNo); @@ -381,7 +396,10 @@ public class ADWindowToolbar extends FToolbar implements EventListener btn.setImage(ThemeManager.getThemeResource("images/"+image + suffix)); } } - btn.setTooltiptext(Msg.getMsg(Env.getCtx(),tooltip)); + String tooltipText = Msg.getMsg(Env.getCtx(),tooltip,false); + if (Util.isEmpty(tooltipText, true)) + tooltipText = Msg.getMsg(Env.getCtx(),tooltip,true); + btn.setTooltiptext(tooltipText); LayoutUtils.addSclass("toolbar-button", btn); buttons.put(name, btn); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java index 9e838cc2f2..67c1ba6762 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java @@ -456,13 +456,15 @@ public class DetailPane extends Panel implements EventListener, IdSpace { String labelKey = actionId + ".label"; String tooltipKey = actionId + ".tooltip"; - String label = Msg.getMsg(Env.getCtx(), labelKey); - String tooltiptext = Msg.getMsg(Env.getCtx(), tooltipKey); + String label = Msg.getMsg(Env.getCtx(), labelKey, true); + String tooltiptext = Msg.getMsg(Env.getCtx(), labelKey, false); + if (Util.isEmpty(tooltiptext, true)) + tooltiptext = Msg.getMsg(Env.getCtx(), tooltipKey, true); if ( labelKey.equals(label) ) { label = toolbarButton.getName(); } - if ( tooltipKey.equals(tooltiptext) ) { - tooltipKey = null; + if ( tooltipKey.equals(tooltiptext) || labelKey.equals(tooltiptext)) { + tooltiptext = label; } ToolBarButton btn = new ToolBarButton(); btn.setName("Btn"+toolbarButton.getComponentName()); diff --git a/org.adempiere.ui.zk/WEB-INF/src/web/theme/default/images/org.idempiere.printformat.editor.action.EditorAction24.png b/org.adempiere.ui.zk/WEB-INF/src/web/theme/default/images/org.idempiere.printformat.editor.action.EditorAction24.png new file mode 100644 index 0000000000000000000000000000000000000000..98899889e6eb64386f88d39f17231493cd7e142f GIT binary patch literal 3621 zcmV+=4%+dFP)Oz@Z0f2-7z;ux~O9+4z06=<WDR*FRcSTFz- zW=q650N5=6FiBTtNC2?60Km==3$g$R3;-}uh=nNt1bYBr$Ri_o0EC$U6h`t_Jn<{8 z5a%iY0C<_QJh>z}MS)ugEpZ1|S1ukX&Pf+56gFW3VVXcL!g-k)GJ!M?;PcD?0HBc- z5#WRK{dmp}uFlRjj{U%*%WZ25jX z{P*?XzTzZ-GF^d31o+^>%=Ap99M6&ogks$0k4OBs3;+Bb(;~!4V!2o<6ys46agIcq zjPo+3B8fthDa9qy|77CdEc*jK-!%ZRYCZvbku9iQV*~a}ClFY4z~c7+0P?$U!PF=S z1Au6Q;m>#f??3%Vpd|o+W=WE9003S@Bra6Svp>fO002awfhw>;8}z{#EWidF!3EsG z3;bXU&9EIRU@z1_9W=mEXoiz;4lcq~xDGvV5BgyU zp1~-*fe8db$Osc*A=-!mVv1NJjtCc-h4>-CNCXm#Bp}I%6j35eku^v$Qi@a{RY)E3 zJ#qp$hg?Rwkvqr$GJ^buyhkyVfwECO)C{#lxu`c9ghrwZ&}4KmnvWKso6vH!8a<3Q zq36)6Xb;+tK10Vaz~~qUGsJ8#F2=(`u{bOVlVi)VBCHIn#u~6ztOL7=^<&SmcLWlF zMZgI*1b0FpVIDz9SWH+>*hr`#93(Um+6gxa1B6k+CnA%mOSC4s5&6UzVlpv@SV$}* z))J2sFA#f(L&P^E5{W}HC%KRUNwK6<(h|}}(r!{C=`5+6G)NjFlgZj-YqAG9lq?`C z$c5yc>d>VnA`E_*3F2Qp##d8RZb=H01_mm@+|Cqnc9PsG(F5HIG_C zt)aG3uTh7n6Et<2In9F>NlT@zqLtGcXcuVrX|L#Xx)I%#9!{6gSJKPrN9dR61N3(c z4Tcqi$B1Vr8Jidf7-t!G7_XR2rWwr)$3XQ?}=hpK0&Z&W{| zep&sA23f;Q!%st`QJ}G3cbou<7-yIK2z4nfCCCtN2-XOGSWo##{8Q{ATurxr~;I`ytDs%xbip}RzP zziy}Qn4Z2~fSycmr`~zJ=lUFdFa1>gZThG6M+{g7vkW8#+YHVaJjFF}Z#*3@$J_By zLtVo_L#1JrVVB{Ak-5=4qt!-@Mh}c>#$4kh<88)m#-k<%CLtzEP3leVno>={htGUuD;o7bD)w_sX$S}eAxwzy?UvgBH(S?;#HZiQMoS*2K2 zT3xe7t(~nU*1N5{rxB;QPLocnp4Ml>u<^FZwyC!nu;thW+pe~4wtZn|Vi#w(#jeBd zlf9FDx_yoPJqHbk*$%56S{;6Kv~mM9!g3B(KJ}#RZ#@)!hR|78Dq|Iq-afF%KE1Brn_fm;Im z_u$xr8UFki1L{Ox>G0o)(&RAZ;=|I=wN2l97;cLaHH6leTB-XXa*h%dBOEvi`+x zi?=Txl?TadvyiL>SuF~-LZ;|cS}4~l2eM~nS7yJ>iOM;atDY;(?aZ^v+mJV$@1Ote z62cPUlD4IWOIIx&SmwQ~YB{nzae3Pc;}r!fhE@iwJh+OsDs9zItL;~pu715HdQEGA zUct(O!LkCy1<%NCg+}G`0PgpNm-?d@-hMgNe6^V+j6x$b<6@S<$+<4_1hi}Ti zncS4LsjI}fWY1>OX6feMEuLErma3QLmkw?X+1j)X-&VBk_4Y;EFPF_I+q;9dL%E~B zJh;4Nr^(LEJ3myURP{Rblsw%57T)g973R8o)DE9*xN#~;4_o$q%o z4K@u`jhx2fBXC4{U8Qn{*%*B$Ge=nny$HAYq{=vy|sI0 z_vss+H_qMky?OB#|JK!>IX&II^LlUh#rO5!7TtbwC;iULyV-Xq?ybB}ykGP{?LpZ? z-G|jbTmIbG@7#ZCz;~eY(cDM(28Dyq{*m>M4?_iynUBkc4TkHUI6gT!;y-fz>HMcd z&t%Ugo)`Y2{>!cx7B7DI)$7;J(U{Spm-3gBzioV_{p!H$8L!*M!p0uH$#^p{Ui4P` z?ZJ24cOCDe-w#jZd?0@)|7iKK^;6KN`;!@ylm7$*nDhK&GcDTy000JJOGiWi{{a60 z|De66lK=n!32;bRa{vGf6951U69E94oEQKA00(qQO+^RZ0tE;)50zv3G5`PrS4l)c zR5;6>l}%_|bri*a=jA1tWNf5SY)nNgQq)#bYaxx9X&W0+X%U0svWrS+K@l>WuBD42 z3T8wXx)TZtX%JmBQpJzLn~DXA)@Dj5hH7eKLagYhagxkCE@nn2VH$1E=Do+e_x$fY z_u~(Mv&8W*zLEE9LC&%OG}}l5uW7yllfZL9hEG$ebi3p}n~jo2qbQmQZIH^O0M+Mz z!DdW1lV{^oZPM&vTSF4fw)dw}si(tAwDZ8A#6_U#e~`LlW*VPmt~WK82KE8BRetXP zIzvFf5-_eIe&9OrV9)OLfl5!>>XuxU@efJAg_ZOLgz+$)5{G~;V6kpZ%r_EmYKW`J zu+$S!;DAJr&0nh| z02uWMuio?0-h?R*0C&|yn+M*Bq9|TX90nOKI?EB8W@*I$#6gC+>PI?V?6)SPnD+AC9+y~qXoU!>Zc!9;fUFTbt9Xw*Y3v|-< zF-b|#=`*>g?xGDU1#o4~i#AE%7GRxJJ~&1puwBw&+pkEtGr90?6h+h5>Yf0IB@)1Z zM7P9Q;0>E8V4KHi{4=Bf?kpSXNnxAyz*}|p?v$o^^!q~V z{MPnD2QVS=Vie^@Z5o{AsKhp#Ebze!Vw>qozp`r6wE&ZdVlpft`3i6}igI67?!Ct( rdToA|nBhk7+QCiX{{Efq*W>dy1(}XVsJn=500000NkvXXu0mjftGC9{ literal 0 HcmV?d00001 diff --git a/org.idempiere.printformat.editor/.project b/org.idempiere.printformat.editor/.project new file mode 100644 index 0000000000..143d535221 --- /dev/null +++ b/org.idempiere.printformat.editor/.project @@ -0,0 +1,39 @@ + + + org.idempiere.printformat.editor + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.pde.ds.core.builder + + + + + org.eclipse.babel.editor.rbeBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + com.jaspersoft.studio.babel.editor.rbeNature + + diff --git a/org.idempiere.printformat.editor/.settings/org.eclipse.pde.core.prefs b/org.idempiere.printformat.editor/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 0000000000..f29e940a00 --- /dev/null +++ b/org.idempiere.printformat.editor/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/org.idempiere.printformat.editor/META-INF/MANIFEST.MF b/org.idempiere.printformat.editor/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..566aabf318 --- /dev/null +++ b/org.idempiere.printformat.editor/META-INF/MANIFEST.MF @@ -0,0 +1,27 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Report Editor +Bundle-SymbolicName: org.idempiere.printformat.editor +Bundle-Version: 8.2.0.qualifier +Bundle-Activator: org.idempiere.printformat.editor.Activator +Bundle-Vendor: TREKGLOBAL +Import-Package: org.osgi.framework, + org.osgi.service.component;version="1.4.0", + org.osgi.service.component.annotations;version="1.3.0" +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-11 +Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version>=11))" +Require-Bundle: org.adempiere.base;bundle-version="8.2.0", + org.adempiere.ui.zk;bundle-version="8.2.0", + org.adempiere.plugin.utils;bundle-version="8.2.0", + zcommon, + zel, + zhtml, + zk, + zkbind, + zkplus, + zul, + zweb +Service-Component: OSGI-INF/org.idempiere.printformat.editor.action.EditorAction.xml +Export-Package: action.images +Automatic-Module-Name: org.idempiere.printformat.editor diff --git a/org.idempiere.printformat.editor/OSGI-INF/org.idempiere.printformat.editor.action.EditorAction.xml b/org.idempiere.printformat.editor/OSGI-INF/org.idempiere.printformat.editor.action.EditorAction.xml new file mode 100644 index 0000000000..bb3290ed7a --- /dev/null +++ b/org.idempiere.printformat.editor/OSGI-INF/org.idempiere.printformat.editor.action.EditorAction.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/org.idempiere.printformat.editor/build.properties b/org.idempiere.printformat.editor/build.properties new file mode 100644 index 0000000000..b3fe17d1f5 --- /dev/null +++ b/org.idempiere.printformat.editor/build.properties @@ -0,0 +1,5 @@ +output.. = target/classes +bin.includes = META-INF/,\ + .,\ + OSGI-INF/ +source.. = src/ diff --git a/org.idempiere.printformat.editor/pom.xml b/org.idempiere.printformat.editor/pom.xml new file mode 100644 index 0000000000..688e9a4efe --- /dev/null +++ b/org.idempiere.printformat.editor/pom.xml @@ -0,0 +1,12 @@ + + 4.0.0 + + org.idempiere + org.idempiere.parent + 8.2.0-SNAPSHOT + ../org.idempiere.parent/pom.xml + + org.idempiere.printformat.editor + eclipse-plugin + diff --git a/org.idempiere.printformat.editor/src/action/images/org.idempiere.printformat.editor.action.EditorAction24.png b/org.idempiere.printformat.editor/src/action/images/org.idempiere.printformat.editor.action.EditorAction24.png new file mode 100644 index 0000000000000000000000000000000000000000..98899889e6eb64386f88d39f17231493cd7e142f GIT binary patch literal 3621 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 literal 0 HcmV?d00001 diff --git a/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/Activator.java b/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/Activator.java new file mode 100644 index 0000000000..5951cbbc9c --- /dev/null +++ b/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/Activator.java @@ -0,0 +1,35 @@ +/*********************************************************************** + * This file is part of iDempiere ERP Open Source * + * http://www.idempiere.org * + * * + * Copyright (C) Contributors * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * + * MA 02110-1301, USA. * + * * + * Contributors: * + * - Trek Global * + **********************************************************************/ +package org.idempiere.printformat.editor; + +import org.adempiere.plugin.utils.Incremental2PackActivator; + +/** + * + * @author hengsin + * + */ +public class Activator extends Incremental2PackActivator { +} diff --git a/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/FieldPosition.java b/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/FieldPosition.java new file mode 100644 index 0000000000..d50bb3f4a8 --- /dev/null +++ b/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/FieldPosition.java @@ -0,0 +1,86 @@ +/*********************************************************************** + * This file is part of iDempiere ERP Open Source * + * http://www.idempiere.org * + * * + * Copyright (C) Contributors * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * + * MA 02110-1301, USA. * + * * + * Contributors: * + * - Trek Global * + **********************************************************************/ +package org.idempiere.printformat.editor; + +import org.compiere.print.MPrintFormatItem; + +/** + * + * @author hengsin + * + */ +public class FieldPosition { + private MPrintFormatItem pfItem; + private float x; + private float y; + + /** + * + * @return {@link MPrintFormatItem} + */ + public MPrintFormatItem getPrintFormatItem() { + return pfItem; + } + + /** + * + * @param pfItem + */ + public void setPrintFormatItem(MPrintFormatItem pfItem) { + this.pfItem = pfItem; + } + + /** + * + * @return x + */ + public float getX() { + return x; + } + + /** + * + * @param x + */ + public void setX(float x) { + this.x = x; + } + + /** + * + * @return y + */ + public float getY() { + return y; + } + + /** + * + * @param y + */ + public void setY(float y) { + this.y = y; + } +} diff --git a/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/PrintAreaBean.java b/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/PrintAreaBean.java new file mode 100644 index 0000000000..0962c8341c --- /dev/null +++ b/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/PrintAreaBean.java @@ -0,0 +1,115 @@ +/*********************************************************************** + * This file is part of iDempiere ERP Open Source * + * http://www.idempiere.org * + * * + * Copyright (C) Contributors * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * + * MA 02110-1301, USA. * + * * + * Contributors: * + * - Trek Global * + **********************************************************************/ +package org.idempiere.printformat.editor; + +/** + * @author hengsin + * + */ +public class PrintAreaBean { + + private float pointX; + private float pointY; + private float currentX; + private float currentY; + + /** + * + * @param areaType + * @param x + * @param y + */ + public PrintAreaBean(int areaType, float x, float y) { + super(); + this.currentX = x; + this.currentY = y; + pointX = x; + pointY = y; + } + + /** + * + * @return x + */ + public float getPointX() { + return pointX; + } + + /** + * + * @param pointX + */ + public void setPointX(float pointX) { + this.pointX = pointX; + } + + /** + * + * @return y + */ + public float getPointY() { + return pointY; + } + + /** + * + * @param pointY + */ + public void setPointY(float pointY) { + this.pointY = pointY; + } + + /** + * + * @return current x + */ + public float getCurrentX() { + return currentX; + } + + /** + * + * @param currentX + */ + public void setCurrentX(float currentX) { + this.currentX = currentX; + } + + /** + * + * @return current y + */ + public float getCurrentY() { + return currentY; + } + + /** + * + * @param currentY + */ + public void setCurrentY(float currentY) { + this.currentY = currentY; + } +} diff --git a/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/action/EditorAction.java b/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/action/EditorAction.java new file mode 100644 index 0000000000..9e99aff53b --- /dev/null +++ b/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/action/EditorAction.java @@ -0,0 +1,65 @@ +/*********************************************************************** + * This file is part of iDempiere ERP Open Source * + * http://www.idempiere.org * + * * + * Copyright (C) Contributors * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * + * MA 02110-1301, USA. * + * * + * Contributors: * + * - Trek Global * + **********************************************************************/ +package org.idempiere.printformat.editor.action; + +import org.adempiere.webui.action.IAction; +import org.adempiere.webui.adwindow.ADWindow; +import org.compiere.util.Env; +import org.idempiere.printformat.editor.ui.WPrintFormatEditor; +import org.osgi.service.component.annotations.Component; + +/** + * @author hengsin + * + */ +@Component(name="org.idempiere.printformat.editor.action.EditorAction", immediate = true, service = IAction.class) +public class EditorAction implements IAction { + + /** + * default constructor + */ + public EditorAction() { + } + + /* (non-Javadoc) + * @see org.adempiere.webui.action.IAction#execute(java.lang.Object) + */ + @Override + public void execute(Object target) { + ADWindow adwindow = (ADWindow) target; + int windowNo = adwindow.getADWindowContent().getWindowNo(); + int AD_PrintFormat_ID = Env.getContextAsInt(Env.getCtx(), windowNo, "AD_PrintFormat_ID", true); + if (AD_PrintFormat_ID > 0) { + WPrintFormatEditor editor = new WPrintFormatEditor(AD_PrintFormat_ID, adwindow.getADWindowContent()); + editor.showEditorWindow(); + } + } + + @Override + public String getIconSclass() { + return "z-icon-th-list"; + } + +} diff --git a/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/ui/PrintFormatEditorUtil.java b/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/ui/PrintFormatEditorUtil.java new file mode 100644 index 0000000000..16848ff7a0 --- /dev/null +++ b/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/ui/PrintFormatEditorUtil.java @@ -0,0 +1,147 @@ +/*********************************************************************** + * This file is part of iDempiere ERP Open Source * + * http://www.idempiere.org * + * * + * Copyright (C) Contributors * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * + * MA 02110-1301, USA. * + * * + * Contributors: * + * - Trek Global * + **********************************************************************/ +package org.idempiere.printformat.editor.ui; + +import org.compiere.print.MPrintFormatItem; +import org.compiere.util.DisplayType; +import org.compiere.util.Util; +import org.zkoss.zk.ui.HtmlBasedComponent; + +/** + * @author milap + * @author hengsin + * + */ +public class PrintFormatEditorUtil { + + public static void addCSSStyle(HtmlBasedComponent comp, String style, + boolean isAppend) { + + if (!Util.isEmpty(comp.getStyle(), true) && isAppend) { + comp.setStyle(comp.getStyle() + style); + } else { + comp.setStyle(style); + } + } + + public static int pointToPixel(float point) { + return Float.valueOf(point * 4 / 3).intValue(); + } + + public static float pixelToPointValue(int pixel) { + return pixel * 3f / 4f; + } + + public static float inchToPointValue(float inch) { + return inch * 72; + } + + public static float mmToPointValue(float mm) { + return inchToPointValue(mm / 25.4f); + } + + public static String getCSSFontFamily(String fontFamily) { + if ("Dialog".equals(fontFamily) || "DialogInput".equals(fontFamily) + || "SansSerif".equals(fontFamily)) { + return "sans-serif"; + } else if ("SansSerif".equals(fontFamily)) { + return "sans-serif"; + } else if ("Serif".equals(fontFamily)) { + return "serif"; + } else if ("Monospaced".equals(fontFamily)) { + return "monospace"; + } + return null; + } + + public static String getAlignmentStyleCSS(MPrintFormatItem pfItem) { + String retValue = "left"; + String align = pfItem.getFieldAlignmentType(); + if (align != null) { + if (align.equalsIgnoreCase("L")) + retValue = "left"; + else if (align.equalsIgnoreCase("T")) + retValue = "right"; + else if (align.equals("C")) + retValue = "center"; + } + if (align == null || align.equalsIgnoreCase("D")) { + if (DisplayType.isNumeric(pfItem.getAD_Column() + .getAD_Reference_ID())) { + retValue = "right"; + } else { + retValue = "left"; + } + } + + return retValue; + } + + public static void setX(MPrintFormatItem pfItem, float xVal) + { + if(!pfItem.isRelativePosition()) + { + pfItem.setXPosition(Float.valueOf(xVal).intValue()); + } + else + pfItem.setXSpace(Float.valueOf(xVal).intValue()); + } + + public static void setY(MPrintFormatItem pfItem, float yVal) + { + if(!pfItem.isRelativePosition()) + { + pfItem.setYPosition(Float.valueOf(yVal).intValue()); + } + else + pfItem.setYSpace(Float.valueOf(yVal).intValue()); + } + + public static int getX(MPrintFormatItem pfItem) + { + int retVal = 0; + if(!pfItem.isRelativePosition()) + { + retVal = pfItem.getXPosition(); + } + else + retVal = pfItem.getXSpace(); + + return retVal; + } + + public static int getY(MPrintFormatItem pfItem) + { + int retVal = 0; + if(!pfItem.isRelativePosition()) + { + retVal = pfItem.getYPosition(); + } + else + retVal = pfItem.getYSpace(); + + return retVal; + } +} \ No newline at end of file diff --git a/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/ui/WPrintFormatEditor.java b/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/ui/WPrintFormatEditor.java new file mode 100644 index 0000000000..c9a7ea630e --- /dev/null +++ b/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/ui/WPrintFormatEditor.java @@ -0,0 +1,1391 @@ +/*********************************************************************** + * This file is part of iDempiere ERP Open Source * + * http://www.idempiere.org * + * * + * Copyright (C) Contributors * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * + * MA 02110-1301, USA. * + * * + * Contributors: * + * - Trek Global * + **********************************************************************/ + +package org.idempiere.printformat.editor.ui; + +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Level; + +import javax.print.attribute.standard.MediaSize; + +import org.adempiere.webui.LayoutUtils; +import org.adempiere.webui.adwindow.ADWindowContent; +import org.adempiere.webui.component.Label; +import org.adempiere.webui.component.ListItem; +import org.adempiere.webui.component.Listbox; +import org.adempiere.webui.component.Window; +import org.adempiere.webui.component.ZkCssHelper; +import org.adempiere.webui.editor.WEditor; +import org.adempiere.webui.event.ValueChangeEvent; +import org.adempiere.webui.event.ValueChangeListener; +import org.adempiere.webui.session.SessionManager; +import org.adempiere.webui.util.ZKUpdateUtil; +import org.compiere.model.MColumn; +import org.compiere.model.X_AD_PrintFormatItem; +import org.compiere.model.X_AD_PrintPaper; +import org.compiere.print.MPrintColor; +import org.compiere.print.MPrintFont; +import org.compiere.print.MPrintFormat; +import org.compiere.print.MPrintFormatItem; +import org.compiere.print.MPrintPaper; +import org.compiere.print.layout.LocationElement; +import org.compiere.print.layout.StringElement; +import org.compiere.util.CLogger; +import org.compiere.util.DB; +import org.compiere.util.DisplayType; +import org.compiere.util.Env; +import org.compiere.util.Evaluatee; +import org.compiere.util.Evaluator; +import org.compiere.util.Msg; +import org.compiere.util.Util; +import org.idempiere.printformat.editor.FieldPosition; +import org.idempiere.printformat.editor.PrintAreaBean; +import org.idempiere.printformat.editor.action.EditorAction; +import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.event.DropEvent; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zk.ui.event.EventListener; +import org.zkoss.zk.ui.event.Events; +import org.zkoss.zk.ui.event.KeyEvent; +import org.zkoss.zk.ui.util.Clients; +import org.zkoss.zul.Absolutechildren; +import org.zkoss.zul.Div; +import org.zkoss.zul.Window.Mode; + +/** + * @author milap + * @author hengsin + * + */ +public class WPrintFormatEditor implements ValueChangeListener { + + private static final String PRINTFORMAT_ITEM_ATTR = "printFormatItem"; + private static final String PT = "pt"; + private static final String selectedStyle = "curser:pointer; border:solid 1px #0000FF;"; + private static final String normalStyle = "curser:pointer; border:solid 1px #CCC;"; + + private static final int AREA_HEADER = 0; + private static final int AREA_CONTENT = 1; + private static final int AREA_FOOTER = 2; + + protected float paperHeight = 11.5f; + protected float paperWidth = 8; + + private float leftRef = 0; + private float rightRef = 0; + private float topRef = 0; + private float bottomRef = 0; + + private WPrintFormatEditorForm printFormatForm = null; + + private HashMap printFormatItemMap = new HashMap(); + private LinkedHashMap fieldPosMap = new LinkedHashMap(); + private Map testValueMap = new HashMap(); + + private Div prevSelectedItem = null; + private String prevStyle = ""; + + // The grid components + private ArrayList formatItems; + + private HashMap editorMap = new HashMap(); + private ArrayList currentEditors = new ArrayList(); + + protected MPrintFormat m_printFormat = null; + + private float lineHeight; + private int AD_PrintFormat_ID; + private ADWindowContent adWindowContent; + + /** Logger */ + private static final CLogger log = CLogger.getCLogger(WPrintFormatEditor.class); + + /** + * + * @param AD_PrintFormat_ID + * @param adWindowContent + */ + public WPrintFormatEditor(int AD_PrintFormat_ID, ADWindowContent adWindowContent) { + this.AD_PrintFormat_ID = AD_PrintFormat_ID; + this.adWindowContent = adWindowContent; + printFormatForm = new WPrintFormatEditorForm(this); + LayoutUtils.addSclass("report-editor-form", printFormatForm); + + } + + /** + * show editor window + */ + public void showEditorWindow() { + try { + m_printFormat = new MPrintFormat(Env.getCtx(), AD_PrintFormat_ID, null); + loadPrintPaper(); + printFormatForm.init(); + String title = Msg.getMsg(Env.getCtx(), EditorAction.class.getName()+".label", true); + title = Util.cleanAmp(title); + printFormatForm.setTitle(title+": "+m_printFormat.getName()); + printFormatForm.setVisible(true); + printFormatForm.setAttribute(Window.MODE_KEY, Mode.HIGHLIGHTED); + SessionManager.getAppDesktop().showWindow(printFormatForm); + initMap(); + initFormatItemListbox(); + updatePreview(); + } catch (Exception ex) { + log.log(Level.SEVERE, ex.getLocalizedMessage(), ex); + } + } + + private void loadPrintPaper() { + int paperID = m_printFormat.getAD_PrintPaper_ID(); + MPrintPaper printPaper = MPrintPaper.get(paperID); + + paperHeight = printPaper.getSizeY().floatValue(); + paperWidth = printPaper.getSizeX().floatValue(); + if (paperHeight > 0 & paperWidth > 0) { + if (X_AD_PrintPaper.DIMENSIONUNITS_MM.equals(printPaper.getDimensionUnits())) { + paperHeight = PrintFormatEditorUtil.mmToPointValue(paperHeight); + paperWidth = PrintFormatEditorUtil.mmToPointValue(paperWidth); + } else { + paperHeight = PrintFormatEditorUtil.inchToPointValue(paperHeight); + paperWidth = PrintFormatEditorUtil.inchToPointValue(paperWidth); + } + } else { + MediaSize mediaSize = printPaper.getMediaSize(); + float mediaHeight=0; + float mediaWidth=0; + if (X_AD_PrintPaper.DIMENSIONUNITS_MM.equals(printPaper.getDimensionUnits())) { + mediaHeight = mediaSize.getY(MediaSize.MM); + mediaWidth = mediaSize.getX(MediaSize.MM); + paperHeight = PrintFormatEditorUtil.mmToPointValue(mediaHeight); + paperWidth = PrintFormatEditorUtil.mmToPointValue(mediaWidth); + } else { + mediaHeight = mediaSize.getY(MediaSize.INCH); + mediaWidth = mediaSize.getX(MediaSize.INCH); + paperHeight = PrintFormatEditorUtil.inchToPointValue(mediaHeight); + paperWidth = PrintFormatEditorUtil.inchToPointValue(mediaWidth); + } + } + + if (printPaper.isLandscape()) { + float t = paperHeight; + paperHeight = paperWidth; + paperWidth = t; + } + + leftRef = printPaper.getMarginLeft(); + rightRef = printPaper.getMarginRight(); + topRef = printPaper.getMarginTop(); + bottomRef = printPaper.getMarginBottom(); + } + + private float getActualPaperWidth() { + return paperWidth - leftRef - rightRef; + } + + private float getActualPaperHeight() { + return paperHeight - topRef - bottomRef; + } + + private void initPrintArea(PrintAreaBean[] pArea) { + + float x = 0; + float y = 0; + + if (!(m_printFormat.isForm() && !m_printFormat.isStandardHeaderFooter())) { + pArea[AREA_CONTENT] = new PrintAreaBean(AREA_CONTENT, x, y); + } else { + + float height = 0; + height = m_printFormat.getHeaderMargin(); + pArea[AREA_HEADER] = new PrintAreaBean(AREA_HEADER, x, y); + + y += height; + height = getActualPaperHeight() - m_printFormat.getHeaderMargin() + - m_printFormat.getFooterMargin(); + pArea[AREA_CONTENT] = new PrintAreaBean(AREA_CONTENT, x, y); + + y += height; + pArea[AREA_FOOTER] = new PrintAreaBean(AREA_FOOTER, x, y); + } + } + + private void initMap() { + + editorMap.put(MPrintFormatItem.COLUMNNAME_IsSuppressNull, printFormatForm.supressNull); + editorMap.put(MPrintFormatItem.COLUMNNAME_IsSetNLPosition, + printFormatForm.setNLPosition); + editorMap.put(MPrintFormatItem.COLUMNNAME_IsRelativePosition, + printFormatForm.relativePosition); + editorMap.put(MPrintFormatItem.COLUMNNAME_IsFilledRectangle, printFormatForm.fillShape); + editorMap.put(MPrintFormatItem.COLUMNNAME_IsNextPage, printFormatForm.nextPage); + editorMap.put(MPrintFormatItem.COLUMNNAME_IsNextLine, printFormatForm.nextLine); + editorMap.put(MPrintFormatItem.COLUMNNAME_IsHeightOneLine, printFormatForm.oneLineOnly); + editorMap.put(MPrintFormatItem.COLUMNNAME_ImageIsAttached, + printFormatForm.imageAttached); + editorMap.put(MPrintFormatItem.COLUMNNAME_IsImageField, printFormatForm.imageField); + editorMap.put(MPrintFormatItem.COLUMNNAME_IsFixedWidth, printFormatForm.fixedWidth); + editorMap.put(MPrintFormatItem.COLUMNNAME_YPosition, printFormatForm.yPosition); + editorMap.put(MPrintFormatItem.COLUMNNAME_XPosition, printFormatForm.xPosition); + editorMap.put(MPrintFormatItem.COLUMNNAME_YSpace, printFormatForm.ySpace); + editorMap.put(MPrintFormatItem.COLUMNNAME_XSpace, printFormatForm.xSpace); + editorMap.put(MPrintFormatItem.COLUMNNAME_MaxHeight, printFormatForm.maxHeight); + editorMap.put(MPrintFormatItem.COLUMNNAME_MaxWidth, printFormatForm.maxWidth); + editorMap.put(MPrintFormatItem.COLUMNNAME_ArcDiameter, printFormatForm.arcDiameter); + editorMap.put(MPrintFormatItem.COLUMNNAME_ShapeType, printFormatForm.shapeType); + editorMap.put(MPrintFormatItem.COLUMNNAME_AD_PrintFormatChild_ID, + printFormatForm.includedPrintFormat); + editorMap.put(MPrintFormatItem.COLUMNNAME_AD_PrintColor_ID, printFormatForm.printColor); + editorMap.put(MPrintFormatItem.COLUMNNAME_LineWidth, printFormatForm.lineWidth); + editorMap.put(MPrintFormatItem.COLUMNNAME_LineAlignmentType, + printFormatForm.lineAlignment); + editorMap.put(MPrintFormatItem.COLUMNNAME_ImageURL, printFormatForm.imageUrl); + editorMap.put(MPrintFormatItem.COLUMNNAME_AD_PrintFont_ID, printFormatForm.printFont); + editorMap.put(MPrintFormatItem.COLUMNNAME_FieldAlignmentType, + printFormatForm.fieldAlignment); + editorMap.put(MPrintFormatItem.COLUMNNAME_Name, printFormatForm.editorName); + editorMap.put(MPrintFormatItem.COLUMNNAME_SeqNo, printFormatForm.editorSeqNo); + editorMap.put(MPrintFormatItem.COLUMNNAME_PrintAreaType, printFormatForm.printAreaType); + + editorMap.put(MPrintFormatItem.COLUMNNAME_PrintName, printFormatForm.editorPrintName); + editorMap.put(MPrintFormatItem.COLUMNNAME_BelowColumn, printFormatForm.belowColumn); + } + + private void validateProperties(final MPrintFormatItem pfItem) { + Evaluatee evaluatee = new Evaluatee() { + @Override + public String get_ValueAsString(String variableName) { + + String retString = null; + + if (pfItem.get_ColumnIndex(variableName) >= 0 ) { + if (pfItem.get_Value(variableName) instanceof Boolean) { + retString = pfItem.get_Value(variableName).equals(true) ? "Y" + : "N"; + } else { + retString = pfItem.get_ValueAsString(variableName); + } + } + + if (Util.isEmpty(retString)) { + MPrintFormat format = MPrintFormat.get(Env.getCtx(), + pfItem.getAD_PrintFormat_ID(), false); + if (format.get_ColumnIndex(variableName) >= 0) { + if (format.get_Value(variableName) instanceof Boolean) { + retString = format.get_Value(variableName).equals(true) ? "Y" + : "N"; + } else { + retString = format.get_ValueAsString(variableName); + } + } + } + return retString; + } + }; + + for (Map.Entry entry : editorMap.entrySet()) { + + String sql = "Select displaylogic from AD_Field Where AD_Column_ID = ? "; + String logic = DB.getSQLValueString( + null, + sql, + MColumn.getColumn_ID(MPrintFormatItem.Table_Name, + entry.getKey())); + + boolean retValue = true; + if (logic != null && logic.trim().length() > 0) { + retValue = Evaluator.evaluateLogic(evaluatee, logic); + } + + if (retValue) { + entry.getValue().getComponent().getParent().setVisible(true); + if (!currentEditors.contains(entry.getKey())) { + currentEditors.add(entry.getKey()); + } + } else { + entry.getValue().getComponent().getParent().setVisible(false); + if (currentEditors.contains(entry.getKey())) { + currentEditors.remove(entry.getKey()); + } + } + } + } + + private void updatePreview() { + if (m_printFormat.isForm()) + updateFormPreview(); + else + updateTablePreview(); + } + + private void updateFormPreview() { + + PrintAreaBean[] printArea = new PrintAreaBean[3]; + initPrintArea(printArea); + float[] prevWidth = { 0, 0, 0 }; + float[] prevHeight = { 0, 0, 0 }; + + float nlPosition = 0; + + printFormatForm.printLayout.getChildren().clear(); + + printFormatItemMap.clear(); + fieldPosMap.clear(); + + Absolutechildren area = new Absolutechildren(); + area.setX(PrintFormatEditorUtil.pointToPixel(leftRef)); + area.setY(PrintFormatEditorUtil.pointToPixel(topRef)); + + Div printableArea = new Div(); + PrintFormatEditorUtil.addCSSStyle(printableArea, + "border: 1px black solid; background-color: white;", false); + ZKUpdateUtil.setWidth(printableArea, getActualPaperWidth() + PT); + ZKUpdateUtil.setHeight(printableArea, getActualPaperHeight() + PT); + printableArea.setTooltiptext(printableArea.getWidth() + " x " + printableArea.getHeight()); + + area.appendChild(printableArea); + printFormatForm.printLayout.appendChild(area); + + lineHeight = new FontMetrics(MPrintFont.get( + m_printFormat.getAD_PrintFont_ID()).getFont()) { + private static final long serialVersionUID = 7467192921216454967L; + }.getHeight() * 1.25f; + + for (MPrintFormatItem pfItem : formatItems) { + + if (!pfItem.isActive() || pfItem.getSeqNo() <= 0 + || pfItem.isPrinted() == false) + continue; + + int currentPrintArea = AREA_CONTENT; + float x = 0; + float y = 0; + float width = 0; + float height = 0; + + if (pfItem.getPrintAreaType().equals( + MPrintFormatItem.PRINTAREATYPE_Header)) { + currentPrintArea = AREA_HEADER; + } else if (pfItem.getPrintAreaType().equals( + MPrintFormatItem.PRINTAREATYPE_Footer)) { + currentPrintArea = AREA_FOOTER; + } + + Absolutechildren child = new Absolutechildren(); + + x = printArea[currentPrintArea].getCurrentX(); + y = printArea[currentPrintArea].getCurrentY(); + + if (pfItem.isRelativePosition() && pfItem.isSetNLPosition()) { + nlPosition = 0; + } + + if (pfItem.isNextLine()) { + y = y + (prevHeight[currentPrintArea] > 0 ? prevHeight[currentPrintArea] : lineHeight) + 2; + x = nlPosition; + } else { + x = x + prevWidth[currentPrintArea] + 2; + } + + if (pfItem.isRelativePosition()) { + x += pfItem.getXSpace(); + y += pfItem.getYSpace(); + } else { + x = printArea[currentPrintArea].getPointX() + + pfItem.getXPosition(); + y = printArea[currentPrintArea].getPointY() + + pfItem.getYPosition(); + if (pfItem.isSetNLPosition()) + nlPosition = x; + } + + Div fieldDiv = new Div(); + fieldDiv.setAttribute(PRINTFORMAT_ITEM_ATTR, pfItem); + String printText = pfItem.getPrintName(); + + if (pfItem.getPrintFormatType().equals( + MPrintFormatItem.PRINTFORMATTYPE_Field) + || pfItem.getPrintFormatType().equals( + MPrintFormatItem.PRINTFORMATTYPE_Text) + || pfItem.getPrintFormatType().equals( + MPrintFormatItem.PRINTFORMATTYPE_Image)) { + String printString = printText != null ? printText : ""; + String displayData = testValueMap.get(pfItem); + + if (pfItem.isTypeText()) + { + if (displayData != null && displayData.length() > 0) + printString = displayData; + else if (printString.length() == 0) + printString = ("{"+pfItem.getName()+"}"); + } + else + printString += displayData != null ? displayData : ("{"+pfItem.getName()+"}"); + + if (pfItem.getAD_Column().getAD_Reference_ID() == DisplayType.Location) { + LocationElement element = new LocationElement(Env.getCtx(), 109, getFont(pfItem), Color.black, + pfItem.isHeightOneLine(), "", "", Env.getAD_Language(Env.getCtx())); + width = pfItem.getMaxWidth() > 0 ? pfItem.getMaxWidth() : element.getWidth(); + height = pfItem.getMaxHeight() > 0 ? pfItem.getMaxHeight() : element.getHeight(); + } else if (pfItem.getPrintFormatType().equals(MPrintFormatItem.PRINTFORMATTYPE_Image)) { + width = pfItem.getMaxWidth(); + height = pfItem.getMaxHeight(); + } else { + StringElement element = new StringElement(printString, getFont(pfItem), null, null, false); + width = pfItem.getMaxWidth() > 0 ? pfItem.getMaxWidth() : element.getWidth(); + height = pfItem.getMaxHeight() > 0 ? pfItem.getMaxHeight() : element.getHeight(); + } + + Label text = new Label(printString); + text.setTooltiptext(printString); + PrintFormatEditorUtil.addCSSStyle(text, + getCssColorStyle(pfItem), false); + if (pfItem.isHeightOneLine()) + PrintFormatEditorUtil.addCSSStyle(text, + "white-space: nowrap;", true); + PrintFormatEditorUtil.addCSSStyle(fieldDiv, + normalStyle, true); + PrintFormatEditorUtil.addCSSStyle(fieldDiv, + "overflow: hidden;", true); + + fieldDiv.appendChild(text); + if (pfItem.getMaxWidth() == 0 && pfItem.isFieldAlignBlock()) { + width = getActualPaperWidth(); + x = 0; + y = y + (prevHeight[currentPrintArea] > 0 ? prevHeight[currentPrintArea] : lineHeight) + 2; + } + } else if (pfItem.getPrintFormatType().equals( + MPrintFormatItem.PRINTFORMATTYPE_Rectangle)) { + + if (pfItem.getShapeType().equals( + MPrintFormatItem.SHAPETYPE_NormalRectangle)) { + PrintFormatEditorUtil.addCSSStyle(fieldDiv, + "border: 1pt solid black;", false); + } else if (pfItem.getShapeType().equals( + MPrintFormatItem.SHAPETYPE_RoundRectangle)) { + PrintFormatEditorUtil.addCSSStyle(fieldDiv, + "border-radius: " + pfItem.getArcDiameter() / 2 + + "pt;border: 1pt solid black;", false); + } + width = pfItem.getMaxWidth(); + height = pfItem.getMaxHeight(); + if (pfItem.isFilledRectangle()) { + MPrintColor itemColor = getPrintColor(pfItem); + if (itemColor != null && itemColor.getAD_PrintColor_ID() > 0) { + PrintFormatEditorUtil.addCSSStyle(fieldDiv, "background-color: #" + + ZkCssHelper.createHexColorString(itemColor.getColor()) + ";" + , true); + } + } + } else if (pfItem.getPrintFormatType().equals( + MPrintFormatItem.PRINTFORMATTYPE_PrintFormat)) { + Label text = new Label(pfItem.getName() + + "(Included print format)"); + PrintFormatEditorUtil.addCSSStyle(text, getCssColorStyle(pfItem), false); + fieldDiv.appendChild(text); + height = lineHeight; + ZKUpdateUtil.setHeight(fieldDiv, height + PT); + fieldDiv.setStyle("border: 2px solid black;"); + width = getActualPaperWidth() - 4; + x = x+2; + + } else if (pfItem.getPrintFormatType().equals( + MPrintFormatItem.PRINTFORMATTYPE_Line)) { + width = pfItem.getMaxWidth(); + height = pfItem.getLineWidth(); + MPrintColor itemColor = getPrintColor(pfItem); + PrintFormatEditorUtil.addCSSStyle(fieldDiv, "background-color: #" + + ZkCssHelper.createHexColorString(itemColor.getColor())+";", true); + } + + ZKUpdateUtil.setHeight(fieldDiv, height + PT); + if (width > 0) + ZKUpdateUtil.setWidth(fieldDiv, width + PT); + + if (pfItem.isTypePrintFormat()) { + height = height + 2; + } + + if ((x+width) > getActualPaperWidth()) { + if (pfItem.getMaxWidth() == 0) { + width = getActualPaperWidth() - x; + ZKUpdateUtil.setWidth(fieldDiv, width + PT); + if (!pfItem.isHeightOneLine()) { + height = height * 2; + ZKUpdateUtil.setHeight(fieldDiv, height + PT); + } + PrintFormatEditorUtil.addCSSStyle(fieldDiv, "overflow: hidden;", true); + } + } + + if (height != lineHeight + && !pfItem.getPrintFormatType().equals( + MPrintFormatItem.PRINTFORMATTYPE_Rectangle)) + prevHeight[currentPrintArea] = height; + else + prevHeight[currentPrintArea] = 0; + + if (!pfItem.getPrintFormatType().equals( + MPrintFormatItem.PRINTFORMATTYPE_Rectangle)) + prevWidth[currentPrintArea] = width; + else + prevWidth[currentPrintArea] = 0; + + printArea[currentPrintArea].setCurrentX(x); + printArea[currentPrintArea].setCurrentY(y); + + child.setX(PrintFormatEditorUtil.pointToPixel(x + leftRef)); + child.setY(PrintFormatEditorUtil.pointToPixel(y + topRef)); + child.setDroppable("true"); + child.addEventListener(Events.ON_DROP, (DropEvent e) -> onDrop(e)); + + child.appendChild(fieldDiv); + child.setDraggable("true"); + + printFormatForm.printLayout.appendChild(child); + + PrintFormatEditorUtil.addCSSStyle(fieldDiv, "text-align:" + + PrintFormatEditorUtil.getAlignmentStyleCSS(pfItem) + ";", + true); + printFormatItemMap.put(pfItem, child); + + if (printFormatForm.printedItemListbox.getSelectedItem().getValue().equals(pfItem)) { + prevStyle = fieldDiv.getStyle(); + prevSelectedItem = fieldDiv; + PrintFormatEditorUtil + .addCSSStyle(fieldDiv, selectedStyle, true); + } + fieldDiv.addEventListener(Events.ON_CLICK, e -> onFieldDivClick(e)); + + FieldPosition pos = new FieldPosition(); + pos.setX(x); + pos.setY(y); + pos.setPrintFormatItem(pfItem); + + fieldPosMap.put(pfItem, pos); + } + + if (m_printFormat.isStandardHeaderFooter()) { + Absolutechildren line = new Absolutechildren(); + ZKUpdateUtil.setHeight(line, "0px"); + line.setId("headerMargin"); + line.setStyle("border: 1px solid #666;cursor: move;"); + line.setY(PrintFormatEditorUtil.pointToPixel(m_printFormat.getHeaderMargin()+topRef)); + line.setX(PrintFormatEditorUtil.pointToPixel(leftRef)-2); + ZKUpdateUtil.setWidth(line, getActualPaperWidth()+4+PT); + line.setDraggable("true"); + printFormatForm.printLayout.appendChild(line); + + line = new Absolutechildren(); + ZKUpdateUtil.setHeight(line, "0px"); + line.setStyle("border: 1px solid #666;cursor: move;"); + line.setY(PrintFormatEditorUtil.pointToPixel(paperHeight - bottomRef - m_printFormat.getFooterMargin())); + line.setX(PrintFormatEditorUtil.pointToPixel(leftRef)-2); + ZKUpdateUtil.setWidth(line, getActualPaperWidth()+4+PT); + line.setDraggable("true"); + line.setId("footerMargin"); + printFormatForm.printLayout.appendChild(line); + } + } + + private void updateTablePreview() { + PrintAreaBean[] printArea = new PrintAreaBean[3]; + initPrintArea(printArea); + float[] prevWidth = { 0, 0, 0 }; + float[] prevHeight = { 0, 0, 0 }; + + printFormatForm.printLayout.getChildren().clear(); + + printFormatItemMap.clear(); + fieldPosMap.clear(); + + Absolutechildren area = new Absolutechildren(); + area.setX(PrintFormatEditorUtil.pointToPixel(leftRef)); + area.setY(PrintFormatEditorUtil.pointToPixel(topRef)); + + Div printableArea = new Div(); + PrintFormatEditorUtil.addCSSStyle(printableArea, + "border: 1px black solid; background-color: white;", false); + ZKUpdateUtil.setWidth(printableArea, getActualPaperWidth() + PT); + ZKUpdateUtil.setHeight(printableArea, getActualPaperHeight() + PT); + printableArea.setTooltiptext(printableArea.getWidth() + " x " + printableArea.getHeight()); + + area.appendChild(printableArea); + printFormatForm.printLayout.appendChild(area); + + lineHeight = new FontMetrics(MPrintFont.get( + m_printFormat.getAD_PrintFont_ID()).getFont()) { + private static final long serialVersionUID = 7467192921216454967L; + }.getHeight() * 1.25f; + + List columns = new ArrayList<>(); + for (MPrintFormatItem pfItem : formatItems) { + + if (!pfItem.isActive() || pfItem.getSeqNo() <= 0 + || pfItem.isPrinted() == false) + continue; + + int currentPrintArea = AREA_CONTENT; + float x = 0; + float y = 0; + float width = 0; + float height = 0; + + Absolutechildren child = new Absolutechildren(); + + x = printArea[currentPrintArea].getCurrentX(); + y = printArea[currentPrintArea].getCurrentY(); + + float[] belowColumn = null; + if (pfItem.isNextLine() && pfItem.getBelowColumn() > 0 && pfItem.getBelowColumn() <= columns.size()) { + belowColumn = columns.get(pfItem.getBelowColumn()-1); + } else { + x = x + prevWidth[currentPrintArea] + 2; + } + + Div fieldDiv = new Div(); + fieldDiv.setAttribute(PRINTFORMAT_ITEM_ATTR, pfItem); + String printText = pfItem.getPrintName(); + + if (pfItem.getPrintFormatType().equals( + MPrintFormatItem.PRINTFORMATTYPE_Field) + || pfItem.getPrintFormatType().equals( + MPrintFormatItem.PRINTFORMATTYPE_Text) + || pfItem.getPrintFormatType().equals( + MPrintFormatItem.PRINTFORMATTYPE_Image)) { + String printString = (printText != null ? printText + "\n" : ""); + String displayData = testValueMap.get(pfItem); + + if (pfItem.isTypeText()) + { + if (displayData != null && displayData.length() > 0) + printString = displayData; + else if (printString.length() == 0) + printString = ("{"+pfItem.getName()+"}"); + } + else + { + if (belowColumn == null) + printString += displayData != null ? displayData : ("{"+pfItem.getName()+"}"); + else + printString = displayData != null ? displayData : ("{"+pfItem.getName()+"}"); + } + + if (pfItem.getAD_Column().getAD_Reference_ID() == DisplayType.Location) { + LocationElement element = new LocationElement(Env.getCtx(), 109, getFont(pfItem), Color.black, + pfItem.isHeightOneLine(), "", "", Env.getAD_Language(Env.getCtx())); + width = pfItem.getMaxWidth() > 0 ? pfItem.getMaxWidth() : element.getWidth(); + height = pfItem.getMaxHeight() > 0 ? pfItem.getMaxHeight() : element.getHeight(); + } else if (pfItem.getPrintFormatType().equals(MPrintFormatItem.PRINTFORMATTYPE_Image)) { + width = pfItem.getMaxWidth(); + height = pfItem.getMaxHeight(); + } else { + StringElement element = new StringElement(printString, getFont(pfItem), null, null, false); + width = pfItem.getMaxWidth() > 0 ? pfItem.getMaxWidth() : element.getWidth(); + height = element.getHeight() + 4; + } + + Label text = new Label(printString); + text.setMultiline(true); + text.setTooltiptext(printString); + PrintFormatEditorUtil.addCSSStyle(text, + getCssColorStyle(pfItem), false); + if (pfItem.isHeightOneLine()) + PrintFormatEditorUtil.addCSSStyle(text, + "white-space: nowrap;", true); + PrintFormatEditorUtil.addCSSStyle(fieldDiv, + normalStyle, true); + PrintFormatEditorUtil.addCSSStyle(fieldDiv, + "overflow: hidden;", true); + + fieldDiv.appendChild(text); + } else if (pfItem.getPrintFormatType().equals( + MPrintFormatItem.PRINTFORMATTYPE_Rectangle)) { + + if (pfItem.getShapeType().equals( + MPrintFormatItem.SHAPETYPE_NormalRectangle)) { + PrintFormatEditorUtil.addCSSStyle(fieldDiv, + "border: 1pt solid black;", false); + } else if (pfItem.getShapeType().equals( + MPrintFormatItem.SHAPETYPE_RoundRectangle)) { + PrintFormatEditorUtil.addCSSStyle(fieldDiv, + "border-radius: " + pfItem.getArcDiameter() / 2 + + "pt;border: 1pt solid black;", false); + } + width = pfItem.getMaxWidth(); + height = pfItem.getMaxHeight(); + if (pfItem.isFilledRectangle()) { + MPrintColor itemColor = getPrintColor(pfItem); + if (itemColor != null && itemColor.getAD_PrintColor_ID() > 0) { + PrintFormatEditorUtil.addCSSStyle(fieldDiv, "background-color: #" + + ZkCssHelper.createHexColorString(itemColor.getColor()) + ";" + , true); + } + } + } else if (pfItem.getPrintFormatType().equals( + MPrintFormatItem.PRINTFORMATTYPE_PrintFormat)) { + Label text = new Label(pfItem.getName() + + "(Included print format)"); + PrintFormatEditorUtil.addCSSStyle(text, getCssColorStyle(pfItem), false); + fieldDiv.appendChild(text); + height = lineHeight; + ZKUpdateUtil.setHeight(fieldDiv, height + PT); + fieldDiv.setStyle("border: 2px solid black;"); + width = getActualPaperWidth() - 4; + x = x+2; + + } else if (pfItem.getPrintFormatType().equals( + MPrintFormatItem.PRINTFORMATTYPE_Line)) { + width = pfItem.getMaxWidth(); + height = pfItem.getLineWidth(); + MPrintColor itemColor = getPrintColor(pfItem); + PrintFormatEditorUtil.addCSSStyle(fieldDiv, "background-color: #" + + ZkCssHelper.createHexColorString(itemColor.getColor())+";", true); + } + + if (belowColumn != null) { + x = belowColumn[0]; + y = belowColumn[1] + belowColumn[3] + 2; + width = belowColumn[2]; + belowColumn[1] = y; + belowColumn[3] = height; + } + + ZKUpdateUtil.setHeight(fieldDiv, height + PT); + if (width > 0) + ZKUpdateUtil.setWidth(fieldDiv, width + PT); + + if (pfItem.isTypePrintFormat()) { + height = height + 2; + } + + if (belowColumn == null) { + if (height != lineHeight + && !pfItem.getPrintFormatType().equals( + MPrintFormatItem.PRINTFORMATTYPE_Rectangle)) + prevHeight[currentPrintArea] = height; + else + prevHeight[currentPrintArea] = 0; + + if (!pfItem.getPrintFormatType().equals( + MPrintFormatItem.PRINTFORMATTYPE_Rectangle)) + prevWidth[currentPrintArea] = width; + else + prevWidth[currentPrintArea] = 0; + + printArea[currentPrintArea].setCurrentX(x); + printArea[currentPrintArea].setCurrentY(y); + } + + child.setX(PrintFormatEditorUtil.pointToPixel(x + leftRef)); + child.setY(PrintFormatEditorUtil.pointToPixel(y + topRef)); + child.setDroppable("true"); + child.addEventListener(Events.ON_DROP, (DropEvent e) -> onDrop(e)); + + child.appendChild(fieldDiv); + child.setDraggable("true"); + + printFormatForm.printLayout.appendChild(child); + + PrintFormatEditorUtil.addCSSStyle(fieldDiv, "text-align:" + + PrintFormatEditorUtil.getAlignmentStyleCSS(pfItem) + ";", + true); + printFormatItemMap.put(pfItem, child); + + if (printFormatForm.printedItemListbox.getSelectedItem().getValue().equals(pfItem)) { + prevStyle = fieldDiv.getStyle(); + prevSelectedItem = fieldDiv; + PrintFormatEditorUtil + .addCSSStyle(fieldDiv, selectedStyle, true); + } + fieldDiv.addEventListener(Events.ON_CLICK, e -> onFieldDivClick(e)); + + FieldPosition pos = new FieldPosition(); + pos.setX(x); + pos.setY(y); + pos.setPrintFormatItem(pfItem); + + fieldPosMap.put(pfItem, pos); + + if (belowColumn == null) + columns.add(new float[] {x, y, width, height}); + } + + if (m_printFormat.isStandardHeaderFooter()) { + Absolutechildren line = new Absolutechildren(); + ZKUpdateUtil.setHeight(line, "0px"); + line.setId("headerMargin"); + line.setStyle("border: 1px solid #666;cursor: move;"); + line.setY(PrintFormatEditorUtil.pointToPixel(m_printFormat.getHeaderMargin()+topRef)); + line.setX(PrintFormatEditorUtil.pointToPixel(leftRef)-2); + ZKUpdateUtil.setWidth(line, getActualPaperWidth()+4+PT); + line.setDraggable("true"); + printFormatForm.printLayout.appendChild(line); + + line = new Absolutechildren(); + ZKUpdateUtil.setHeight(line, "0px"); + line.setStyle("border: 1px solid #666;cursor: move;"); + line.setY(PrintFormatEditorUtil.pointToPixel(paperHeight - bottomRef - m_printFormat.getFooterMargin())); + line.setX(PrintFormatEditorUtil.pointToPixel(leftRef)-2); + ZKUpdateUtil.setWidth(line, getActualPaperWidth()+4+PT); + line.setDraggable("true"); + line.setId("footerMargin"); + printFormatForm.printLayout.appendChild(line); + } + } + + private Font getFont(MPrintFormatItem pfItem) { + Font font = null; + if (pfItem.getAD_PrintFont_ID() > 0) { + font = MPrintFont.get(pfItem.getAD_PrintFont_ID()).getFont(); + } else if (m_printFormat.getAD_PrintFont_ID() > 0) { + font = MPrintFont.get(m_printFormat.getAD_PrintFont_ID()).getFont(); + } + return font; + } + + private void setItemSelected(MPrintFormatItem pfItem) { + if (pfItem != null) { + validateProperties(pfItem); + setProperties(pfItem); + Div fieldDiv = ((Div) printFormatItemMap.get(pfItem).getFirstChild()); + printFormatForm.printedItemListbox.setSelectedIndex(formatItems.indexOf(pfItem)); + if (prevSelectedItem != null) { + PrintFormatEditorUtil.addCSSStyle(prevSelectedItem, prevStyle, + false); + PrintFormatEditorUtil.addCSSStyle(fieldDiv, "text-align:" + + PrintFormatEditorUtil.getAlignmentStyleCSS(pfItem) + + ";", true); + } + prevStyle = fieldDiv.getStyle(); + prevSelectedItem = fieldDiv; + PrintFormatEditorUtil.addCSSStyle(fieldDiv, selectedStyle, false); + PrintFormatEditorUtil.addCSSStyle(fieldDiv, "text-align:" + + PrintFormatEditorUtil.getAlignmentStyleCSS(pfItem) + ";", + true); + PrintFormatEditorUtil.addCSSStyle(fieldDiv, "overflow: hidden;", true); + StringBuilder script = new StringBuilder(); + script.append("var w = zk.Widget.$('#").append(fieldDiv.getUuid()).append("');"); + script.append("if (!(zk(w).isRealScrollIntoView())) w.$n().scrollIntoView();"); + Clients.evalJavaScript(script.toString()); + } + } + + private String getCssColorStyle(MPrintFormatItem pfItem) { + String style = ""; + + Font font = getFont(pfItem); + if (font != null) { + String fontFamily = font.getFamily(); + fontFamily = PrintFormatEditorUtil.getCSSFontFamily(fontFamily); + if (fontFamily.equalsIgnoreCase("dialog")) { + fontFamily = "sans-serif"; + } + style = fontFamily != null ? "font-family:" + fontFamily + ";" : ""; + if (font.isBold()) { + style = style + "font-weight:bold;"; + } + if (font.isItalic()) { + style = style + "font-style:italic;"; + } + int size = font.getSize(); + style = style + "font-size:" + size + "pt;"; + } + + MPrintColor mPrintColor = getPrintColor(pfItem); + if (mPrintColor != null && mPrintColor.getAD_PrintColor_ID() > 0) { + Color color = mPrintColor.getColor(); + if (color != null) { + style = style + "color: #" + ZkCssHelper.createHexColorString(color) + ";"; + } + } + return style; + } + + private MPrintColor getPrintColor(MPrintFormatItem pfItem) { + MPrintColor mPrintColor = null; + if (pfItem.getAD_PrintColor_ID() > 0) { + mPrintColor = MPrintColor.get(Env.getCtx(), + pfItem.getAD_PrintColor_ID()); + } else if (m_printFormat.getAD_PrintColor_ID() > 0) { + mPrintColor = MPrintColor.get(Env.getCtx(), + m_printFormat.getAD_PrintColor_ID()); + } + return mPrintColor; + } + + private void initFormatItemListbox() { + + formatItems = new ArrayList(); + MPrintFormatItem[] formatItem = m_printFormat.getAllItems(); + for (MPrintFormatItem pfItem : formatItem) { + formatItems.add(pfItem); + } + updateLists(null); + resortArrays(); + + } + + + + private void setProperties(MPrintFormatItem pfItem) { + for (String columnName : currentEditors) { + + WEditor editor = editorMap.get(columnName); + editor.setValue(pfItem.get_Value(columnName)); + + } + + printFormatForm.editorTestValue.setValue(testValueMap.get(pfItem)); + } + + + + /** + * Dispose + */ + public void dispose() { + SessionManager.getAppDesktop().closeActiveWindow(); + } // dispose + + @Override + public void valueChange(ValueChangeEvent e) { + MPrintFormatItem pfItem = printFormatForm.printedItemListbox.getSelectedItem() + .getValue(); + if (!"_TestValue_".equals(e.getPropertyName())) { + pfItem.set_ValueOfColumn(e.getPropertyName(), e.getNewValue()); + validateProperties(pfItem); + } else { + testValueMap.put(pfItem, (String)e.getNewValue()); + } + updatePreview(); + } + + private void onFieldDivClick(Event event) { + if (event.getTarget() instanceof Div + && event.getName().equals(Events.ON_CLICK) + && event.getTarget().hasAttribute(PRINTFORMAT_ITEM_ATTR)) { + Div fieldDiv = (Div) event.getTarget(); + MPrintFormatItem pfItem = (MPrintFormatItem) fieldDiv + .getAttribute(PRINTFORMAT_ITEM_ATTR); + setItemSelected(pfItem); + } + } + + private void onSelect(Event event) { + Listbox list = (Listbox) event.getTarget(); + if (list.getSelectedItem() != null) { + MPrintFormatItem pfItem = list.getSelectedItem().getValue(); + setItemSelected(pfItem); + } + } + + protected void onConfirmPanelClick(Event event) { + if (event.getTarget().getId().equals("Ok")) { + onOk(); + } else if (event.getTarget().getId().equals("Cancel")) { + onCancel(); + } else if (event.getTarget().getId().equals("Reset")) { + onReset(); + } + } + + private void onReset() { + m_printFormat.load(null); + initFormatItemListbox(); + updatePreview(); + } + + protected void onCancel() { + printFormatForm.detach(); + } + + protected void onOk() { + m_printFormat.saveEx(); + for (MPrintFormatItem item : formatItems) { + if (!item.isActive()) + continue; + item.saveEx(); + } + onCancel(); + adWindowContent.onRefresh(); + } + + protected void onCtrlKey(KeyEvent keyEvent) { + MPrintFormatItem pfItem = (MPrintFormatItem) prevSelectedItem + .getAttribute(PRINTFORMAT_ITEM_ATTR); + + int currentX = PrintFormatEditorUtil.getX(pfItem); + int currentY = PrintFormatEditorUtil.getY(pfItem); + + switch (keyEvent.getKeyCode()) { + case KeyEvent.LEFT: + PrintFormatEditorUtil.setX(pfItem, currentX - 1); + setProperties(pfItem); + break; + + case KeyEvent.RIGHT: + PrintFormatEditorUtil.setX(pfItem, currentX + 1); + setProperties(pfItem); + break; + + case KeyEvent.UP: + PrintFormatEditorUtil.setY(pfItem, currentY - 1); + setProperties(pfItem); + break; + + case KeyEvent.DOWN: + PrintFormatEditorUtil.setY(pfItem, currentY + 1); + setProperties(pfItem); + break; + + case KeyEvent.DELETE: + hideItem(pfItem); + } + + updatePreview(); + } + + protected void onDrop(DropEvent de) + { + ListItem startItem = null; + ListItem endItem = null; + + if (de.getDragged() instanceof ListItem) { + startItem = (ListItem) de.getDragged(); + } + if (de.getTarget() instanceof ListItem) { + endItem = (ListItem) de.getTarget(); + } + + if (startItem != null && endItem != null) { + if (startItem.getListbox() == printFormatForm.printedItemListbox + && endItem.getListbox() == printFormatForm.nonPrintedItemListbox) { + // item moved from visible to invisible + MPrintFormatItem pfItem = startItem.getValue(); + hideItem(pfItem); + updateLists(null); + updatePreview(); + setProperties((MPrintFormatItem) prevSelectedItem + .getAttribute(PRINTFORMAT_ITEM_ATTR)); // seqno could change + + } else if (startItem.getListbox() == printFormatForm.nonPrintedItemListbox + && endItem.getListbox() == printFormatForm.printedItemListbox + && startItem.getValue() != null) { + // item moved from invisible to visible + MPrintFormatItem pfItem = (MPrintFormatItem) startItem + .getValue(); + MPrintFormatItem pfItemTo = (MPrintFormatItem) endItem + .getValue(); + pfItem.setSeqNo(pfItemTo.getSeqNo() - 5); + pfItem.setIsPrinted(true); + resortArrays(); + setProperties(pfItem); // seqno could change + updateLists(pfItem); + updatePreview(); + } else if (startItem.getListbox() == printFormatForm.printedItemListbox + && endItem.getListbox() == printFormatForm.printedItemListbox) { + // item moved from visible to visible - reorder + MPrintFormatItem pfItem = startItem.getValue(); + MPrintFormatItem pfItem2 = endItem.getValue(); + pfItem.setSeqNo(pfItem2.getSeqNo() - 1); + resortArrays(); + setProperties(pfItem); // seqno could change + updateLists(pfItem); + updatePreview(); + } + } else if (startItem == null && endItem == null) { + // Item dragged in preview division + Absolutechildren child = (Absolutechildren) de.getDragged(); + if ("headerMargin".equals(child.getId())) { + float ptY = PrintFormatEditorUtil.pixelToPointValue(de.getY()); + m_printFormat.setHeaderMargin(Float.valueOf(ptY - topRef).intValue()); + updatePreview(); + return; + } else if ("footerMargin".equals(child.getId())) { + float ptY = PrintFormatEditorUtil.pixelToPointValue(de.getY()); + m_printFormat.setFooterMargin(Float.valueOf(paperHeight - bottomRef - ptY).intValue()); + updatePreview(); + return; + } + MPrintFormatItem pfItem = (MPrintFormatItem) child + .getFirstChild().getAttribute(PRINTFORMAT_ITEM_ATTR); + + Component target = de.getTarget(); + MPrintFormatItem targetItem = target.getFirstChild() != null ? + (MPrintFormatItem) target.getFirstChild().getAttribute(PRINTFORMAT_ITEM_ATTR) : null; + + float ptY = PrintFormatEditorUtil.pixelToPointValue(de.getY()); + float ptX = PrintFormatEditorUtil.pixelToPointValue(de.getX()); + if (targetItem == null) { + if (pfItem.isRelativePosition()) { + FieldPosition fieldpos = fieldPosMap.get(pfItem); + float diffX = ptX - fieldpos.getX() - leftRef; + float diffY = ptY - fieldpos.getY() - topRef; + PrintFormatEditorUtil.setX(pfItem, diffX); + PrintFormatEditorUtil.setY(pfItem, diffY); + } + + if (m_printFormat.isStandardHeaderFooter()) { + if (!pfItem.isRelativePosition()) + PrintFormatEditorUtil.setY(pfItem, ptY - topRef); + pfItem.setPrintAreaType(X_AD_PrintFormatItem.PRINTAREATYPE_Content); + } else { + if (ptY < (topRef + m_printFormat.getHeaderMargin())) { + if (!X_AD_PrintFormatItem.PRINTAREATYPE_Header.equals(pfItem.getPrintAreaType())) { + pfItem.setPrintAreaType(X_AD_PrintFormatItem.PRINTAREATYPE_Header); + if (pfItem.isRelativePosition()) { + pfItem.setIsRelativePosition(false); + } + } + if (!pfItem.isRelativePosition()) + PrintFormatEditorUtil.setY(pfItem, ptY - topRef); + } else if (ptY > (paperHeight-bottomRef-m_printFormat.getFooterMargin())) { + if (!X_AD_PrintFormatItem.PRINTAREATYPE_Footer.equals(pfItem.getPrintAreaType())) { + pfItem.setPrintAreaType(X_AD_PrintFormatItem.PRINTAREATYPE_Footer); + if (pfItem.isRelativePosition()) { + pfItem.setIsRelativePosition(false); + } + } + if (!pfItem.isRelativePosition()) + PrintFormatEditorUtil.setY(pfItem, ptY - (paperHeight-bottomRef-m_printFormat.getFooterMargin())); + } else { + if (!X_AD_PrintFormatItem.PRINTAREATYPE_Content.equals(pfItem.getPrintAreaType())) { + pfItem.setPrintAreaType(X_AD_PrintFormatItem.PRINTAREATYPE_Content); + if (pfItem.isRelativePosition()) { + pfItem.setIsRelativePosition(false); + } + } + if (!pfItem.isRelativePosition()) + PrintFormatEditorUtil.setY(pfItem, ptY - topRef - m_printFormat.getHeaderMargin()); + } + } + + if (!pfItem.isRelativePosition()) + PrintFormatEditorUtil.setX(pfItem, ptX - leftRef); + } else { + pfItem.setSeqNo(targetItem.getSeqNo()+1); + pfItem.setIsRelativePosition(true); + pfItem.setXSpace(0); + pfItem.setYSpace(0); + pfItem.setIsPrinted(true); + pfItem.setPrintAreaType(targetItem.getPrintAreaType()); + resortArrays(); + } + + setProperties(pfItem); + updateLists(pfItem); + updatePreview(); + } else if (startItem != null && endItem == null) { + Component target = de.getTarget(); + MPrintFormatItem targetItem = target.getFirstChild() != null ? + (MPrintFormatItem) target.getFirstChild().getAttribute(PRINTFORMAT_ITEM_ATTR) : null; + // Item moved/dragged from visible/invisible to preview + MPrintFormatItem pfItem = startItem.getValue(); + if (targetItem == null) { + FieldPosition fieldPos = fieldPosMap.get(pfItem); + if (fieldPos == null) + pfItem.setIsRelativePosition(false); + + float ptX = PrintFormatEditorUtil.pixelToPointValue(de.getX()); + float ptY = PrintFormatEditorUtil.pixelToPointValue(de.getY()); + if (fieldPos == null || !pfItem.isRelativePosition()) { + PrintFormatEditorUtil.setX(pfItem, ptX - leftRef); + } else { + float diffX = ptX - fieldPos.getX(); + float diffY = ptY - fieldPos.getY(); + PrintFormatEditorUtil.setX(pfItem, diffX); + PrintFormatEditorUtil.setY(pfItem, diffY); + } + if (m_printFormat.isStandardHeaderFooter()) { + if (fieldPos == null || !pfItem.isRelativePosition()) { + PrintFormatEditorUtil.setY(pfItem, ptY - topRef); + } + pfItem.setPrintAreaType(X_AD_PrintFormatItem.PRINTAREATYPE_Content); + } else { + if (ptY < (topRef + m_printFormat.getHeaderMargin())) { + if (!X_AD_PrintFormatItem.PRINTAREATYPE_Header.equals(pfItem.getPrintAreaType())) { + pfItem.setPrintAreaType(X_AD_PrintFormatItem.PRINTAREATYPE_Header); + if (pfItem.isRelativePosition()) { + pfItem.setIsRelativePosition(false); + PrintFormatEditorUtil.setX(pfItem, ptX - leftRef); + } + } + if (!pfItem.isRelativePosition()) { + PrintFormatEditorUtil.setY(pfItem, ptY - topRef); + } + } else if (ptY > (paperHeight-bottomRef-m_printFormat.getFooterMargin())) { + if (!X_AD_PrintFormatItem.PRINTAREATYPE_Footer.equals(pfItem.getPrintAreaType())) { + pfItem.setPrintAreaType(X_AD_PrintFormatItem.PRINTAREATYPE_Footer); + if (pfItem.isRelativePosition()) { + pfItem.setIsRelativePosition(false); + PrintFormatEditorUtil.setX(pfItem, ptX - leftRef); + } + } + if (!pfItem.isRelativePosition()) { + PrintFormatEditorUtil.setY(pfItem, ptY - (paperHeight-bottomRef-m_printFormat.getFooterMargin())); + } + } else { + if (!X_AD_PrintFormatItem.PRINTAREATYPE_Content.equals(pfItem.getPrintAreaType())) { + pfItem.setPrintAreaType(X_AD_PrintFormatItem.PRINTAREATYPE_Content); + if (pfItem.isRelativePosition()) { + pfItem.setIsRelativePosition(false); + PrintFormatEditorUtil.setX(pfItem, ptX - leftRef); + } + } + if (!pfItem.isRelativePosition()) { + PrintFormatEditorUtil.setY(pfItem, ptY - topRef - m_printFormat.getHeaderMargin()); + } + } + } + pfItem.setIsPrinted(true); + if (startItem.getListbox() == printFormatForm.nonPrintedItemListbox) + pfItem.setSeqNo((printFormatItemMap.size() + 1) * 10 + 5); + resortArrays(); + } else { + pfItem.setSeqNo(targetItem.getSeqNo()+1); + pfItem.setIsRelativePosition(true); + pfItem.setXSpace(0); + pfItem.setYSpace(0); + pfItem.setIsPrinted(true); + pfItem.setPrintAreaType(targetItem.getPrintAreaType()); + resortArrays(); + } + + setProperties(pfItem); // seqno could change + updateLists(pfItem); + updatePreview(); + } else if (startItem == null && endItem != null) { + // Item moved/dragged from preview to invisible + Absolutechildren child = (Absolutechildren) de.getDragged(); + MPrintFormatItem pfItem = (MPrintFormatItem) child + .getFirstChild().getAttribute(PRINTFORMAT_ITEM_ATTR); + hideItem(pfItem); + updatePreview(); + setProperties((MPrintFormatItem) prevSelectedItem + .getAttribute(PRINTFORMAT_ITEM_ATTR)); // seqno could change + } + + } + + private void hideItem(MPrintFormatItem pfItem) { + pfItem.setSeqNo(0); + pfItem.setIsPrinted(false); + resortArrays(); + updateLists(null); + } + + private EventListener onSelectListner = e -> onSelect(e); + + private void updateLists(MPrintFormatItem selectedItem) { + printFormatForm.printedItemListbox.removeAllItems(); + printFormatForm.nonPrintedItemListbox.removeAllItems(); + + printFormatForm.printedItemListbox.removeEventListener(Events.ON_SELECT, onSelectListner); + printFormatForm.printedItemListbox.addEventListener(Events.ON_SELECT, onSelectListner); + + for (MPrintFormatItem pfItem : formatItems) { + if (!pfItem.isActive()) + continue; + + ListItem item = new ListItem(pfItem.getName(), pfItem); + item.setDroppable("true"); + item.setDraggable("true"); + item.addEventListener(Events.ON_DROP, (DropEvent e) -> onDrop(e)); + + if (pfItem.isPrinted()) { + printFormatForm.printedItemListbox.appendChild(item); + if (selectedItem != null && pfItem == selectedItem) { + item.setSelected(true); + } + } else { + printFormatForm.nonPrintedItemListbox.appendChild(item); + if (selectedItem != null && pfItem == selectedItem) { + item.setSelected(true); + } + } + } + if (printFormatForm.nonPrintedItemListbox.getItems().isEmpty()) { + ListItem item = new ListItem("...", null); + item.setDroppable("true"); + printFormatForm.nonPrintedItemListbox.appendChild(item); + item.addEventListener(Events.ON_DROP, (DropEvent e) -> onDrop(e)); + } + + if (printFormatForm.printedItemListbox.getItems().isEmpty()) { + ListItem item = new ListItem("...", null); + item.setDroppable("true"); + printFormatForm.printedItemListbox.appendChild(item); + item.addEventListener(Events.ON_DROP, (DropEvent e) -> onDrop(e)); + } + if (selectedItem == null) + printFormatForm.printedItemListbox.setSelectedIndex(0); + + if (printFormatForm.printedItemListbox.getSelectedItem().getValue() != null) { + validateProperties((MPrintFormatItem) (printFormatForm.printedItemListbox + .getSelectedItem().getValue())); + setProperties((MPrintFormatItem) (printFormatForm.printedItemListbox + .getSelectedItem().getValue())); + } + } + + private void resortArrays() { + Collections.sort(formatItems, new Comparator() { + @Override + public int compare(MPrintFormatItem pfItem1, + MPrintFormatItem pfItem2) { + String compare1 = String.format("%s%10d%s", + (!pfItem1.isPrinted() ? "1" : "0"), + (pfItem1.isPrinted() ? pfItem1.getSeqNo() : 0), + pfItem1.getName()); + String compare2 = String.format("%s%10d%s", + (!pfItem2.isPrinted() ? "1" : "0"), + (pfItem2.isPrinted() ? pfItem2.getSeqNo() : 0), + pfItem2.getName()); + return compare1.compareTo(compare2); + } + }); + + int seq = 10; + for (MPrintFormatItem pfItem : formatItems) { + if (!pfItem.isActive()) + continue; + if (pfItem.isPrinted()) { + pfItem.setSeqNo(seq); + seq = seq + 10; + } else { + pfItem.setSeqNo(0); + } + } + } +} diff --git a/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/ui/WPrintFormatEditorForm.java b/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/ui/WPrintFormatEditorForm.java new file mode 100644 index 0000000000..fa8713ad58 --- /dev/null +++ b/org.idempiere.printformat.editor/src/org/idempiere/printformat/editor/ui/WPrintFormatEditorForm.java @@ -0,0 +1,670 @@ +/*********************************************************************** + * This file is part of iDempiere ERP Open Source * + * http://www.idempiere.org * + * * + * Copyright (C) Contributors * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * + * MA 02110-1301, USA. * + * * + * Contributors: * + * - Trek Global * + **********************************************************************/ +package org.idempiere.printformat.editor.ui; + +import org.adempiere.webui.LayoutUtils; +import org.adempiere.webui.component.Column; +import org.adempiere.webui.component.ConfirmPanel; +import org.adempiere.webui.component.Grid; +import org.adempiere.webui.component.GridFactory; +import org.adempiere.webui.component.Group; +import org.adempiere.webui.component.Label; +import org.adempiere.webui.component.ListHead; +import org.adempiere.webui.component.ListHeader; +import org.adempiere.webui.component.Listbox; +import org.adempiere.webui.component.Row; +import org.adempiere.webui.component.Rows; +import org.adempiere.webui.component.Window; +import org.adempiere.webui.component.ZkCssHelper; +import org.adempiere.webui.editor.WEditor; +import org.adempiere.webui.editor.WNumberEditor; +import org.adempiere.webui.editor.WStringEditor; +import org.adempiere.webui.editor.WTableDirEditor; +import org.adempiere.webui.editor.WYesNoEditor; +import org.adempiere.webui.util.ZKUpdateUtil; +import org.compiere.model.MColumn; +import org.compiere.model.MLookup; +import org.compiere.model.MLookupFactory; +import org.compiere.print.MPrintFormatItem; +import org.compiere.util.DisplayType; +import org.compiere.util.Env; +import org.compiere.util.Msg; +import org.zkoss.zk.ui.HtmlBasedComponent; +import org.zkoss.zk.ui.event.DropEvent; +import org.zkoss.zk.ui.event.Events; +import org.zkoss.zk.ui.event.KeyEvent; +import org.zkoss.zul.Absolutelayout; +import org.zkoss.zul.Borderlayout; +import org.zkoss.zul.Cell; +import org.zkoss.zul.Center; +import org.zkoss.zul.Columns; +import org.zkoss.zul.Div; +import org.zkoss.zul.East; +import org.zkoss.zul.Separator; +import org.zkoss.zul.South; +import org.zkoss.zul.Vlayout; +import org.zkoss.zul.West; + +/** + * + * @author hengsin + * + */ +public class WPrintFormatEditorForm extends Window +{ + /** + * generated serial id + */ + private static final long serialVersionUID = -2533099650671242190L; + + private WPrintFormatEditor pfe; + + protected Borderlayout mainLayout = new Borderlayout(); + private ConfirmPanel confirmPanel = new ConfirmPanel(true, false, true, false, false, false); + protected Listbox printedItemListbox = new Listbox(); + protected Listbox nonPrintedItemListbox = new Listbox(); + private Div centerDiv; + private Vlayout westPaneLayout; + protected Absolutelayout printLayout = null; + + protected WEditor editorName = null; + protected WEditor editorPrintName = null; + protected WEditor editorSeqNo = null; + protected WEditor fieldAlignment = null; + protected WEditor maxWidth = null; + protected WEditor maxHeight = null; + protected WEditor fixedWidth = null; + protected WEditor printFont = null; + protected WEditor imageField = null; + protected WEditor imageAttached = null; + protected WEditor imageUrl = null; + protected WEditor lineAlignment = null; + protected WEditor lineWidth = null; + protected WEditor includedPrintFormat = null; + protected WEditor shapeType = null; + protected WEditor oneLineOnly = null; + protected WEditor nextLine = null; + protected WEditor nextPage = null; + protected WEditor xSpace = null; + protected WEditor ySpace = null; + protected WEditor xPosition = null; + protected WEditor yPosition = null; + protected WYesNoEditor relativePosition = null; + protected WEditor setNLPosition = null; + protected WEditor supressNull = null; + protected WEditor printColor = null; + protected WEditor fillShape = null; + protected WEditor arcDiameter = null; + protected WEditor printAreaType = null; + protected WEditor editorTestValue = null; + protected WEditor belowColumn = null; + + /** + * + * @param printFormatEditor + */ + public WPrintFormatEditorForm(WPrintFormatEditor printFormatEditor) { + pfe = printFormatEditor; + } + + /** + * Static init + * + * @throws Exception + */ + public void init() throws Exception { + setSizable(false); + setClosable(true); + setMaximizable(true); + setMaximized(true); + appendChild(mainLayout); + LayoutUtils.addSclass("tab-editor-form-content", mainLayout); + setBorder("normal"); + + confirmPanel.addActionListener(Events.ON_CLICK, e -> pfe.onConfirmPanelClick(e)); + addEventListener(Events.ON_CANCEL, e -> pfe.onCancel()); + + Borderlayout eastPaneLayout = new Borderlayout(); + + Center eastPaneCenter = new Center(); + Grid propGrid = initPropertiesGrid(); + ZKUpdateUtil.setVflex(propGrid, "1"); + eastPaneCenter.appendChild(propGrid); + eastPaneLayout.appendChild(eastPaneCenter); + South south = new South(); + eastPaneLayout.appendChild(south); + ZKUpdateUtil.setVflex(confirmPanel, "min"); + ZKUpdateUtil.setHflex(confirmPanel, "1"); + south.appendChild(confirmPanel); + ZKUpdateUtil.setWidth(eastPaneLayout, "100%"); + ZKUpdateUtil.setHeight(eastPaneLayout, "100%"); + + East east = new East(); + LayoutUtils.addSclass("tab-editor-form-east-panel", east); + mainLayout.appendChild(east); + east.appendChild(eastPaneLayout); + ZKUpdateUtil.setWidth(east, "25%"); + + Label formatItemLabel = new Label(); + ListHead printedHead = new ListHead(); + printedHead.setParent(printedItemListbox); + ListHeader visibleHeader = new ListHeader(); + formatItemLabel.setText("Displayed"); + visibleHeader.appendChild(formatItemLabel); + visibleHeader.setParent(printedHead); + + ListHead nonPrintedHead = new ListHead(); + nonPrintedHead.setParent(nonPrintedItemListbox); + ListHeader nonPrintedHeader = new ListHeader(); + nonPrintedHeader.appendChild(new Label("Not Displayed")); + nonPrintedHeader.setParent(nonPrintedHead); + + westPaneLayout = new Vlayout(); + ZKUpdateUtil.setHeight(westPaneLayout, "100%"); + westPaneLayout.appendChild(printedItemListbox); + ZKUpdateUtil.setVflex(printedItemListbox, "1"); + westPaneLayout.appendChild(nonPrintedItemListbox); + ZKUpdateUtil.setVflex(nonPrintedItemListbox, "1"); + + printedItemListbox.addEventListener(Events.ON_DROP, (DropEvent e) -> pfe.onDrop(e)); + nonPrintedItemListbox.addEventListener(Events.ON_DROP, (DropEvent e) -> pfe.onDrop(e)); + + West west = new West(); + LayoutUtils.addSclass("tab-editor-form-west-panel", west); + mainLayout.appendChild(west); + west.appendChild(westPaneLayout); + west.setCollapsible(true); + west.setSplittable(true); + ZKUpdateUtil.setWidth(west, "200px"); + + Center center = new Center(); + + centerDiv = new Div(); + PrintFormatEditorUtil + .addCSSStyle( + centerDiv, + "border: dashed 1px black; overflow: auto; background-color: grey;", + false); + ZKUpdateUtil.setHeight(centerDiv, "100%"); + + Div previewDiv = new Div(); + ZKUpdateUtil.setHeight(previewDiv, pfe.paperHeight + "pt"); + ZKUpdateUtil.setWidth(previewDiv, pfe.paperWidth + "pt"); + + printLayout = new Absolutelayout(); + PrintFormatEditorUtil.addCSSStyle(printLayout, + " border: 1px black solid; background-color:#E1E1E1;", false); + + ZKUpdateUtil.setWidth(printLayout, (pfe.paperWidth + "pt")); + ZKUpdateUtil.setHeight(printLayout, (pfe.paperHeight + "pt")); + printLayout.setDroppable("true"); + printLayout.addEventListener(Events.ON_DROP, (DropEvent e) -> pfe.onDrop(e)); + + previewDiv.appendChild(printLayout); + centerDiv.appendChild(previewDiv); + center.appendChild(centerDiv); + + mainLayout.appendChild(center); + setCtrlKeys("#left#right#up#down#del"); + addEventListener(Events.ON_CTRL_KEY, (KeyEvent e) -> pfe.onCtrlKey(e)); + + ZkCssHelper.appendStyle(printLayout, "overflow: auto;"); + } + + /** + * Initialize Grid of Field's Properties return @Grid + */ + private Grid initPropertiesGrid() { + Grid gridView = GridFactory.newGridLayout(); + // + Columns columns = new Columns(); + gridView.appendChild(columns); + // + Column column = new Column(); + columns.appendChild(column); + ZKUpdateUtil.setHflex(column, "min"); + column.setAlign("right"); + + column = new Column(); + columns.appendChild(column); + ZKUpdateUtil.setHflex(column, "1"); + Rows rows = new Rows(); + gridView.appendChild(rows); + + Row row = null; + + row = new Row(); + Group group = new Group(Msg.getMsg(Env.getCtx(), "Property")); + Cell cell = (Cell) group.getFirstChild(); + cell.setSclass("z-group-inner"); + cell.setColspan(2); + cell.setAlign("left"); + group.setOpen(true); + rows.appendChild(group); + + row = new Row(); + Label labelName = new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_Name)); + editorName = new WStringEditor(MPrintFormatItem.COLUMNNAME_Name, false, + false, false, 0, 0, null, null); + editorName.fillHorizontal(); + row.appendChild(labelName.rightAlign()); + row.appendChild(editorName.getComponent()); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + Label labelPrintName = new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_PrintName)); + editorPrintName = new WStringEditor(MPrintFormatItem.COLUMNNAME_PrintName, false, + false, false, 0, 0, null, null); + editorPrintName.fillHorizontal(); + row.appendChild(labelPrintName.rightAlign()); + row.appendChild(editorPrintName.getComponent()); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + Label labelTestValue = new Label(Msg.getElement(Env.getCtx(), "TestValue")); + editorTestValue = new WStringEditor("_TestValue_", false, + false, true, 0, 0, null, null); + editorTestValue.fillHorizontal(); + editorTestValue.addValueChangeListener(pfe); + row.appendChild(labelTestValue.rightAlign()); + row.appendChild(editorTestValue.getComponent()); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + Label labelSeqNo = new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_SeqNo)); + editorSeqNo = new WNumberEditor(MPrintFormatItem.COLUMNNAME_SeqNo, + false, false, false, DisplayType.Integer, labelSeqNo.getValue()); + editorSeqNo.fillHorizontal(); + row.appendChild(labelSeqNo.rightAlign()); + row.appendChild(editorSeqNo.getComponent()); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + Label imgURL = new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_ImageURL)); + imageUrl = new WStringEditor(MPrintFormatItem.COLUMNNAME_ImageURL, false, + false, false, 0, 0, null, null); + ZKUpdateUtil.setHflex((HtmlBasedComponent) imageUrl.getComponent(), "1"); + row.appendChild(imgURL.rightAlign()); + row.appendChild(imageUrl.getComponent()); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + Label labelXPos = new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_XPosition)); + xPosition = new WNumberEditor(MPrintFormatItem.COLUMNNAME_XPosition, + true, false, true, DisplayType.Integer, labelXPos.getValue()); + xPosition.fillHorizontal(); + row.appendChild(labelXPos.rightAlign()); + row.appendChild(xPosition.getComponent()); + xPosition.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + Label labelYPos = new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_YPosition)); + yPosition = new WNumberEditor(MPrintFormatItem.COLUMNNAME_YPosition, + true, false, true, DisplayType.Integer, labelYPos.getValue()); + yPosition.fillHorizontal(); + row.appendChild(labelYPos.rightAlign()); + row.appendChild(yPosition.getComponent()); + yPosition.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + Label labelXSpace = new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_XSpace)); + xSpace = new WNumberEditor(MPrintFormatItem.COLUMNNAME_XSpace, true, + false, true, DisplayType.Integer, labelXSpace.getValue()); + xSpace.fillHorizontal(); + row.appendChild(labelXSpace.rightAlign()); + row.appendChild(xSpace.getComponent()); + xSpace.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + Label labelYSpace = new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_YSpace)); + ySpace = new WNumberEditor(MPrintFormatItem.COLUMNNAME_YSpace, true, + false, true, DisplayType.Integer, labelYSpace.getValue()); + ySpace.fillHorizontal(); + row.appendChild(labelYSpace.rightAlign()); + row.appendChild(ySpace.getComponent()); + ySpace.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + Label lblMaxHeight = new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_MaxHeight)); + maxHeight = new WNumberEditor(MPrintFormatItem.COLUMNNAME_MaxHeight, + true, false, true, DisplayType.Integer, lblMaxHeight.getValue()); + maxHeight.fillHorizontal(); + row.appendChild(lblMaxHeight.rightAlign()); + row.appendChild(maxHeight.getComponent()); + maxHeight.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + Label lblMaxWidth = new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_MaxWidth)); + maxWidth = new WNumberEditor(MPrintFormatItem.COLUMNNAME_MaxWidth, + true, false, true, DisplayType.Integer, lblMaxWidth.getValue()); + maxWidth.fillHorizontal(); + row.appendChild(lblMaxWidth.rightAlign()); + row.appendChild(maxWidth.getComponent()); + maxWidth.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + Label label = new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_ArcDiameter)); + arcDiameter = new WNumberEditor( + MPrintFormatItem.COLUMNNAME_ArcDiameter, true, false, true, + DisplayType.Integer, label.getValue()); + arcDiameter.fillHorizontal(); + row.appendChild(label.rightAlign()); + row.appendChild(arcDiameter.getComponent()); + arcDiameter.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + label = new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_LineWidth)); + lineWidth = new WNumberEditor(MPrintFormatItem.COLUMNNAME_LineWidth, + true, false, true, DisplayType.Integer, label.getValue()); + lineWidth.fillHorizontal(); + row.appendChild(label.rightAlign()); + row.appendChild(lineWidth.getComponent()); + lineWidth.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + row.appendChild(new Label(Msg.getElement( + Env.getCtx(), + MPrintFormatItem.COLUMNNAME_IsRelativePosition))); + relativePosition = new WYesNoEditor( + MPrintFormatItem.COLUMNNAME_IsRelativePosition, "", null, + false, false, true); + row.appendChild(relativePosition.getComponent()); + relativePosition.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + row.appendChild(new Label(Msg.getElement( + Env.getCtx(), + MPrintFormatItem.COLUMNNAME_IsSuppressNull))); + supressNull = new WYesNoEditor( + MPrintFormatItem.COLUMNNAME_IsSuppressNull, "", null, + false, false, true); + row.appendChild(supressNull.getComponent()); + supressNull.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + row.appendChild(new Label(Msg.getElement( + Env.getCtx(), + MPrintFormatItem.COLUMNNAME_IsSetNLPosition))); + setNLPosition = new WYesNoEditor( + MPrintFormatItem.COLUMNNAME_IsSetNLPosition, "", null, + false, false, true); + row.appendChild(setNLPosition.getComponent()); + setNLPosition.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + row.appendChild(new Label( Msg.getElement( + Env.getCtx(), + MPrintFormatItem.COLUMNNAME_IsFilledRectangle))); + fillShape = new WYesNoEditor( + MPrintFormatItem.COLUMNNAME_IsFilledRectangle,"", null, + false, false, true); + row.appendChild(fillShape.getComponent()); + fillShape.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + row.appendChild(new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_IsNextPage))); + nextPage = new WYesNoEditor(MPrintFormatItem.COLUMNNAME_IsNextPage, + "", null, false, + false, true); + row.appendChild(nextPage.getComponent()); + nextPage.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + row.appendChild(new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_IsNextLine))); + nextLine = new WYesNoEditor(MPrintFormatItem.COLUMNNAME_IsNextLine, + "", null, false, + false, true); + row.appendChild(nextLine.getComponent()); + nextLine.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + row.appendChild(new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_BelowColumn))); + belowColumn = new WNumberEditor(MPrintFormatItem.COLUMNNAME_BelowColumn, + false, false, true, DisplayType.Integer, ""); + row.appendChild(belowColumn.getComponent()); + belowColumn.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + row.appendChild(new Label(Msg.getElement( + Env.getCtx(), + MPrintFormatItem.COLUMNNAME_IsHeightOneLine))); + oneLineOnly = new WYesNoEditor( + MPrintFormatItem.COLUMNNAME_IsHeightOneLine, "", null, + false, false, true); + row.appendChild(oneLineOnly.getComponent()); + oneLineOnly.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + row.appendChild(new Label(Msg.getElement( + Env.getCtx(), + MPrintFormatItem.COLUMNNAME_ImageIsAttached))); + imageAttached = new WYesNoEditor( + MPrintFormatItem.COLUMNNAME_ImageIsAttached, "", null, + false, false, true); + row.appendChild(imageAttached.getComponent()); + imageAttached.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + row.appendChild(new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_IsImageField))); + imageField = new WYesNoEditor(MPrintFormatItem.COLUMNNAME_IsImageField, + "", null, false, + false, true); + row.appendChild(imageField.getComponent()); + imageField.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + row.appendChild(new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_IsFixedWidth))); + fixedWidth = new WYesNoEditor(MPrintFormatItem.COLUMNNAME_IsFixedWidth, + "", null, false, + false, true); + row.appendChild(fixedWidth.getComponent()); + fixedWidth.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + label = new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_PrintAreaType)); + int columnID = MColumn.getColumn_ID(MPrintFormatItem.Table_Name, + MPrintFormatItem.COLUMNNAME_PrintAreaType); + MLookup lookup = MLookupFactory.get(Env.getCtx(), 0, 0, columnID, + DisplayType.List); + printAreaType = new WTableDirEditor( + MPrintFormatItem.COLUMNNAME_PrintAreaType, false, false, true, + lookup); + printAreaType.fillHorizontal(); + row.appendChild(label.rightAlign()); + row.appendChild(printAreaType.getComponent()); + printAreaType.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + label = new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_AD_PrintFont_ID)); + columnID = MColumn.getColumn_ID(MPrintFormatItem.Table_Name, + MPrintFormatItem.COLUMNNAME_AD_PrintFont_ID); + lookup = MLookupFactory.get(Env.getCtx(), 0, 0, columnID, + DisplayType.TableDir); + printFont = new WTableDirEditor( + MPrintFormatItem.COLUMNNAME_AD_PrintFont_ID, false, false, + true, lookup); + printFont.fillHorizontal(); + row.appendChild(label.rightAlign()); + row.appendChild(printFont.getComponent()); + printFont.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + label = new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_AD_PrintColor_ID)); + columnID = MColumn.getColumn_ID(MPrintFormatItem.Table_Name, + MPrintFormatItem.COLUMNNAME_AD_PrintColor_ID); + lookup = MLookupFactory.get(Env.getCtx(), 0, 0, columnID, + DisplayType.TableDir); + printColor = new WTableDirEditor( + MPrintFormatItem.COLUMNNAME_AD_PrintColor_ID, false, false, + true, lookup); + printColor.fillHorizontal(); + row.appendChild(label.rightAlign()); + row.appendChild(printColor.getComponent()); + printColor.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + label = new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_AD_PrintFormatChild_ID)); + columnID = MColumn.getColumn_ID(MPrintFormatItem.Table_Name, + MPrintFormatItem.COLUMNNAME_AD_PrintFormatChild_ID); + lookup = MLookupFactory.get(Env.getCtx(), 0, 0, columnID, + DisplayType.Table); + includedPrintFormat = new WTableDirEditor( + MPrintFormatItem.COLUMNNAME_AD_PrintFormatChild_ID, false, + false, true, lookup); + row.appendChild(label.rightAlign()); + row.appendChild(includedPrintFormat.getComponent()); + includedPrintFormat.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + label = new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_LineAlignmentType)); + columnID = MColumn.getColumn_ID(MPrintFormatItem.Table_Name, + MPrintFormatItem.COLUMNNAME_LineAlignmentType); + lookup = MLookupFactory.get(Env.getCtx(), 0, 0, columnID, + DisplayType.List); + lineAlignment = new WTableDirEditor( + MPrintFormatItem.COLUMNNAME_LineAlignmentType, false, false, + true, lookup); + lineAlignment.fillHorizontal(); + row.appendChild(label.rightAlign()); + row.appendChild(lineAlignment.getComponent()); + lineAlignment.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + label = new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_FieldAlignmentType)); + columnID = MColumn.getColumn_ID(MPrintFormatItem.Table_Name, + MPrintFormatItem.COLUMNNAME_FieldAlignmentType); + lookup = MLookupFactory.get(Env.getCtx(), 0, 0, columnID, + DisplayType.List); + fieldAlignment = new WTableDirEditor( + MPrintFormatItem.COLUMNNAME_FieldAlignmentType, false, false, + true, lookup); + fieldAlignment.fillHorizontal(); + row.appendChild(label.rightAlign()); + row.appendChild(fieldAlignment.getComponent()); + fieldAlignment.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + label = new Label(Msg.getElement(Env.getCtx(), + MPrintFormatItem.COLUMNNAME_ShapeType)); + columnID = MColumn.getColumn_ID(MPrintFormatItem.Table_Name, + MPrintFormatItem.COLUMNNAME_ShapeType); + lookup = MLookupFactory.get(Env.getCtx(), 0, 0, columnID, + DisplayType.List); + shapeType = new WTableDirEditor(MPrintFormatItem.COLUMNNAME_ShapeType, + false, false, true, lookup); + row.appendChild(label.rightAlign()); + row.appendChild(shapeType.getComponent()); + shapeType.addValueChangeListener(pfe); + row.setGroup(group); + rows.appendChild(row); + + row = new Row(); + Separator esep = new Separator("horizontal"); + esep.setSpacing("10px"); + row.appendChild(esep); + row.setGroup(group); + rows.appendChild(row); + + return gridView; + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 36a3df8212..b3e414a0bb 100644 --- a/pom.xml +++ b/pom.xml @@ -37,6 +37,7 @@ org.idempiere.webservices-feature org.idempiere.zk.extra org.idempiere.keikai + org.idempiere.printformat.editor org.adempiere.report.jasper-feature org.adempiere.base-feature org.adempiere.replication-feature