From 339d10e78787005cc43273e7801405551c5f69cf Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 21 Jun 2013 19:57:56 -0500 Subject: [PATCH] IDEMPIERE-1087 Process Parameters don't have contextual menu (right click) / based on patch from Juliana Corredor --- .../src/org/compiere/model/GridField.java | 18 ++++---- .../webui/apps/ProcessParameterPanel.java | 44 +++++++++++++++++-- .../org/adempiere/webui/editor/WEditor.java | 3 +- 3 files changed, 52 insertions(+), 13 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/GridField.java b/org.adempiere.base/src/org/compiere/model/GridField.java index 8240fe8103..7d3276ac0f 100644 --- a/org.adempiere.base/src/org/compiere/model/GridField.java +++ b/org.adempiere.base/src/org/compiere/model/GridField.java @@ -450,13 +450,15 @@ public class GridField keyColumn = "AD_EntityType_ID"; if (!keyColumn.endsWith("_ID")) keyColumn += "_ID"; // AD_Language_ID - int Record_ID = Env.getContextAsInt(ctx, m_vo.WindowNo, m_vo.TabNo, keyColumn); - int AD_Table_ID = m_vo.AD_Table_ID; - if (!MRole.getDefault(ctx, false).canUpdate( - AD_Client_ID, AD_Org_ID, AD_Table_ID, Record_ID, false)) - return false; - if (!MRole.getDefault(ctx, false).isColumnAccess(AD_Table_ID, m_vo.AD_Column_ID, false)) - return false; + if (getGridTab() != null) { + int Record_ID = Env.getContextAsInt(ctx, m_vo.WindowNo, m_vo.TabNo, keyColumn); + int AD_Table_ID = m_vo.AD_Table_ID; + if (!MRole.getDefault(ctx, false).canUpdate( + AD_Client_ID, AD_Org_ID, AD_Table_ID, Record_ID, false)) + return false; + if (!MRole.getDefault(ctx, false).isColumnAccess(AD_Table_ID, m_vo.AD_Column_ID, false)) + return false; + } } // Do we have a readonly rule @@ -487,7 +489,7 @@ public class GridField return true; // BF [ 2910368 ] // Record is not Active - if (checkContext && !Env.getContext(ctx, m_vo.WindowNo,m_vo.TabNo, "IsActive").equals("Y")) + if (checkContext && getGridTab() != null && !Env.getContext(ctx, m_vo.WindowNo,m_vo.TabNo, "IsActive").equals("Y")) return false; // ultimately visibility decides diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java index d482832b29..a294ba81f6 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java @@ -29,6 +29,7 @@ import org.adempiere.webui.component.GridFactory; import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; +import org.adempiere.webui.editor.IZoomableEditor; import org.adempiere.webui.editor.WEditor; import org.adempiere.webui.editor.WEditorPopupMenu; import org.adempiere.webui.editor.WebEditorFactory; @@ -54,6 +55,7 @@ import org.zkoss.zk.ui.event.Events; import org.zkoss.zul.Div; import org.zkoss.zul.Hbox; import org.zkoss.zul.Label; +import org.zkoss.zul.impl.XulElement; /** * Process Parameter Panel, based on existing ProcessParameter dialog. - @@ -68,7 +70,8 @@ public class ProcessParameterPanel extends Panel implements /** * */ - private static final long serialVersionUID = 7163263872945366389L; + private static final long serialVersionUID = -5996487688479454715L; + private String width; /** @@ -291,9 +294,25 @@ public class ProcessParameterPanel extends Panel implements editor.fillHorizontal(); // setup editor context menu WEditorPopupMenu popupMenu = editor.getPopupMenu(); - if (popupMenu != null) { - popupMenu.addMenuListener((ContextMenuListener) editor); + if (popupMenu != null) + { + popupMenu.addMenuListener((ContextMenuListener)editor); + popupMenu.setId(mField.getColumnName()+"-popup"); this.appendChild(popupMenu); + if (!mField.isFieldOnly()) + { + Label label = editor.getLabel(); + if (popupMenu.isZoomEnabled() && editor instanceof IZoomableEditor) + { + label.addEventListener(Events.ON_CLICK, new ZoomListener((IZoomableEditor) editor)); + } + + popupMenu.addContextElement(label); + if (editor.getComponent() instanceof XulElement) + { + popupMenu.addContextElement((XulElement) editor.getComponent()); + } + } } // m_wEditors.add(editor); // add to Editors @@ -634,6 +653,7 @@ public class ProcessParameterPanel extends Panel implements m_wEditors2.get(i).setVisible(false); } } + editor.updateLabelStyle(); } } @@ -661,5 +681,21 @@ public class ProcessParameterPanel extends Panel implements m_processInfo = processInfo; } -} // ProcessParameterPanel + static class ZoomListener implements EventListener { + private IZoomableEditor searchEditor; + + ZoomListener(IZoomableEditor editor) { + searchEditor = editor; + } + + public void onEvent(Event event) throws Exception { + if (Events.ON_CLICK.equals(event.getName())) { + searchEditor.actionZoom(); + } + + } + + } + +} // ProcessParameterPanel diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditor.java index a396a48a07..e47d057e3d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditor.java @@ -566,7 +566,8 @@ public abstract class WEditor implements EventListener, PropertyChangeLis * @return boolean */ protected boolean isShowPreference() { - return MRole.getDefault().isShowPreference() && gridField != null && !gridField.isEncrypted() && !gridField.isEncryptedColumn(); + return MRole.getDefault().isShowPreference() && gridField != null && !gridField.isEncrypted() && !gridField.isEncryptedColumn() + && gridTab != null; // don't show preference for process parameters } /**