IDEMPIERE-129 Restrictions on Toolbar and Menu - Implement for zk

http://jira.idempiere.com/browse/IDEMPIERE-129
This commit is contained in:
Carlos Ruiz 2012-04-05 00:45:17 -05:00
parent a515c81c2d
commit 69875e9083
4 changed files with 114 additions and 2 deletions

View File

@ -1238,6 +1238,41 @@ ALTER TABLE AD_ToolBarButtonRestrict MODIFY Action NULL
UPDATE AD_Column SET IsUpdateable='N',Updated=TO_DATE('2012-03-29 13:45:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Column_ID=200111 UPDATE AD_Column SET IsUpdateable='N',Updated=TO_DATE('2012-03-29 13:45:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Column_ID=200111
; ;
-- 05-abr-2012 0:19:55 COT
-- IDEMPIERE-129 Restrictions on Toolbar and Menu
UPDATE AD_ToolBarButton SET ComponentName='Toggle',Updated=TO_DATE('2012-04-05 00:19:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200041
;
-- 05-abr-2012 0:20:01 COT
-- IDEMPIERE-129 Restrictions on Toolbar and Menu
UPDATE AD_ToolBarButton SET ComponentName='HistoryRecords',Updated=TO_DATE('2012-04-05 00:20:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200042
;
-- 05-abr-2012 0:20:10 COT
-- IDEMPIERE-129 Restrictions on Toolbar and Menu
UPDATE AD_ToolBarButton SET ComponentName='ParentRecord',Updated=TO_DATE('2012-04-05 00:20:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200043
;
-- 05-abr-2012 0:20:12 COT
-- IDEMPIERE-129 Restrictions on Toolbar and Menu
UPDATE AD_ToolBarButton SET ComponentName='DetailRecord',Updated=TO_DATE('2012-04-05 00:20:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200044
;
-- 05-abr-2012 0:20:32 COT
-- IDEMPIERE-129 Restrictions on Toolbar and Menu
UPDATE AD_ToolBarButton SET ComponentName='ActiveWorkflows',Updated=TO_DATE('2012-04-05 00:20:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200054
;
-- 05-abr-2012 0:20:35 COT
-- IDEMPIERE-129 Restrictions on Toolbar and Menu
UPDATE AD_ToolBarButton SET ComponentName='Requests',Updated=TO_DATE('2012-04-05 00:20:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200055
;
-- 05-abr-2012 0:20:39 COT
-- IDEMPIERE-129 Restrictions on Toolbar and Menu
UPDATE AD_ToolBarButton SET ComponentName='ProductInfo',Updated=TO_DATE('2012-04-05 00:20:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200056
;
UPDATE AD_System UPDATE AD_System
SET LastMigrationScriptApplied='833_IDEMPIERE-129.sql' SET LastMigrationScriptApplied='833_IDEMPIERE-129.sql'
WHERE LastMigrationScriptApplied<'833_IDEMPIERE-129.sql' WHERE LastMigrationScriptApplied<'833_IDEMPIERE-129.sql'

View File

@ -1238,6 +1238,41 @@ INSERT INTO t_alter_column values('ad_toolbarbuttonrestrict','"action"',null,'NU
UPDATE AD_Column SET IsUpdateable='N',Updated=TO_TIMESTAMP('2012-03-29 13:45:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Column_ID=200111 UPDATE AD_Column SET IsUpdateable='N',Updated=TO_TIMESTAMP('2012-03-29 13:45:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Column_ID=200111
; ;
-- 05-abr-2012 0:19:55 COT
-- IDEMPIERE-129 Restrictions on Toolbar and Menu
UPDATE AD_ToolBarButton SET ComponentName='Toggle',Updated=TO_TIMESTAMP('2012-04-05 00:19:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200041
;
-- 05-abr-2012 0:20:01 COT
-- IDEMPIERE-129 Restrictions on Toolbar and Menu
UPDATE AD_ToolBarButton SET ComponentName='HistoryRecords',Updated=TO_TIMESTAMP('2012-04-05 00:20:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200042
;
-- 05-abr-2012 0:20:10 COT
-- IDEMPIERE-129 Restrictions on Toolbar and Menu
UPDATE AD_ToolBarButton SET ComponentName='ParentRecord',Updated=TO_TIMESTAMP('2012-04-05 00:20:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200043
;
-- 05-abr-2012 0:20:12 COT
-- IDEMPIERE-129 Restrictions on Toolbar and Menu
UPDATE AD_ToolBarButton SET ComponentName='DetailRecord',Updated=TO_TIMESTAMP('2012-04-05 00:20:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200044
;
-- 05-abr-2012 0:20:32 COT
-- IDEMPIERE-129 Restrictions on Toolbar and Menu
UPDATE AD_ToolBarButton SET ComponentName='ActiveWorkflows',Updated=TO_TIMESTAMP('2012-04-05 00:20:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200054
;
-- 05-abr-2012 0:20:35 COT
-- IDEMPIERE-129 Restrictions on Toolbar and Menu
UPDATE AD_ToolBarButton SET ComponentName='Requests',Updated=TO_TIMESTAMP('2012-04-05 00:20:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200055
;
-- 05-abr-2012 0:20:39 COT
-- IDEMPIERE-129 Restrictions on Toolbar and Menu
UPDATE AD_ToolBarButton SET ComponentName='ProductInfo',Updated=TO_TIMESTAMP('2012-04-05 00:20:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200056
;
UPDATE AD_System UPDATE AD_System
SET LastMigrationScriptApplied='833_IDEMPIERE-129.sql' SET LastMigrationScriptApplied='833_IDEMPIERE-129.sql'
WHERE LastMigrationScriptApplied<'833_IDEMPIERE-129.sql' WHERE LastMigrationScriptApplied<'833_IDEMPIERE-129.sql'

View File

@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.webui.AdempiereIdGenerator; import org.adempiere.webui.AdempiereIdGenerator;
@ -30,6 +31,8 @@ import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.event.ToolbarListener; import org.adempiere.webui.event.ToolbarListener;
import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.session.SessionManager;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import org.compiere.model.MToolBarButtonRestrict;
import org.compiere.model.X_AD_ToolBarButton;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
@ -51,10 +54,12 @@ import org.zkoss.zul.Space;
*/ */
public class CWindowToolbar extends FToolbar implements EventListener public class CWindowToolbar extends FToolbar implements EventListener
{ {
private static final String BTNPREFIX = "Btn";
/** /**
* *
*/ */
private static final long serialVersionUID = -762537218475834634L; private static final long serialVersionUID = 5233006056333191551L;
private static final String TOOLBAR_BUTTON_STYLE = "background-color: transparent; display:inline-block; margin-left: 1px; margin-right: 1px; width: 26px; height: 24px;"; private static final String TOOLBAR_BUTTON_STYLE = "background-color: transparent; display:inline-block; margin-left: 1px; margin-right: 1px; width: 26px; height: 24px;";
@ -209,7 +214,7 @@ public class CWindowToolbar extends FToolbar implements EventListener
private ToolBarButton createButton(String name, String image, String tooltip) private ToolBarButton createButton(String name, String image, String tooltip)
{ {
ToolBarButton btn = new ToolBarButton(""); ToolBarButton btn = new ToolBarButton("");
btn.setName("Btn"+name); btn.setName(BTNPREFIX+name);
if (windowNo > 0) if (windowNo > 0)
btn.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + btn.getName() + "_" + windowNo + (embedded ? "E" : "")); btn.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + btn.getName() + "_" + windowNo + (embedded ? "E" : ""));
else else
@ -633,4 +638,39 @@ public class CWindowToolbar extends FToolbar implements EventListener
if (btnExport != null) if (btnExport != null)
btnExport.setDisabled(!b); btnExport.setDisabled(!b);
} }
private boolean ToolBarMenuRestictionLoaded = false;
public void updateToolBarAndMenuWithRestriction(int AD_Window_ID) {
if (ToolBarMenuRestictionLoaded)
return;
Properties m_ctx = Env.getCtx();
int ToolBarButton_ID = 0;
int[] restrictionList = MToolBarButtonRestrict.getOf(m_ctx, MRole.getDefault().getAD_Role_ID(), "W", AD_Window_ID, this.getClass().getName(), null);
log.info("restrictionList="+restrictionList.toString());
for (int i = 0; i < restrictionList.length; i++)
{
ToolBarButton_ID= restrictionList[i];
X_AD_ToolBarButton tbt = new X_AD_ToolBarButton(m_ctx, ToolBarButton_ID, null);
String restrictName = BTNPREFIX + tbt.getComponentName();
log.config("tbt="+tbt.getAD_ToolBarButton_ID() + " / " + restrictName);
for (Component p = this.getFirstChild(); p != null; p = p.getNextSibling()) {
if (p instanceof ToolBarButton) {
System.out.println(((ToolBarButton)p).getName());
if ( restrictName.equals(((ToolBarButton)p).getName()) ) {
this.removeChild(p);
break;
}
}
}
} // All restrictions
ToolBarMenuRestictionLoaded = true;
}
} }

View File

@ -1332,6 +1332,8 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
toolbar.enablePrint(curTab.isPrinted()); toolbar.enablePrint(curTab.isPrinted());
toolbar.enableReport(true); toolbar.enableReport(true);
toolbar.enableExport(!curTab.isSortTab()); toolbar.enableExport(!curTab.isSortTab());
toolbar.updateToolBarAndMenuWithRestriction(gridWindow.getAD_Window_ID());
} }
/** /**