* Implemented zoom across.
* Bug: Zoom to transaction screen failed.
This commit is contained in:
parent
4bc63ab3b4
commit
998ab34d8d
|
@ -23,6 +23,9 @@ import java.util.List;
|
|||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.webui.apps.ProcessDialog;
|
||||
import org.adempiere.webui.component.Grid;
|
||||
import org.adempiere.webui.component.Row;
|
||||
import org.adempiere.webui.component.Rows;
|
||||
import org.adempiere.webui.component.Tabpanel;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.adempiere.webui.event.MenuListener;
|
||||
|
@ -46,6 +49,8 @@ import org.zkoss.zkex.zul.Borderlayout;
|
|||
import org.zkoss.zkex.zul.Center;
|
||||
import org.zkoss.zkex.zul.North;
|
||||
import org.zkoss.zkex.zul.West;
|
||||
import org.zkoss.zul.Caption;
|
||||
import org.zkoss.zul.Groupbox;
|
||||
import org.zkoss.zul.Iframe;
|
||||
import org.zkoss.zul.Label;
|
||||
|
||||
|
@ -120,9 +125,27 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
|
|||
//TODO: dashboard
|
||||
Tabpanel homeTab = new Tabpanel();
|
||||
windowContainer.addWindow(homeTab, "Home", false);
|
||||
Label t = new Label();
|
||||
t.setValue("My Home!");
|
||||
t.setParent(homeTab);
|
||||
|
||||
Grid grid = new Grid();
|
||||
grid.setOddRowSclass("even");
|
||||
grid.setSclass("grid-no-striped");
|
||||
grid.setWidth("100%");
|
||||
grid.setHeight("100%");
|
||||
homeTab.appendChild(grid);
|
||||
|
||||
Rows rows = new Rows();
|
||||
grid.appendChild(rows);
|
||||
|
||||
Row row = new Row();
|
||||
rows.appendChild(row);
|
||||
|
||||
Groupbox groupBox = new Groupbox();
|
||||
row.appendChild(groupBox);
|
||||
Caption caption = new Caption("Favourites");
|
||||
groupBox.appendChild(caption);
|
||||
groupBox.setMold("3d");
|
||||
groupBox.appendChild(new Label("My Favourites!"));
|
||||
groupBox.setClosable(true);
|
||||
|
||||
//register as 0
|
||||
registerWindow(homeTab);
|
||||
|
|
|
@ -0,0 +1,238 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. 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., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.util.*;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zul.Label;
|
||||
import org.zkoss.zul.Menuitem;
|
||||
import org.zkoss.zul.Menupopup;
|
||||
|
||||
/**
|
||||
* Application Zoom Across Launcher.
|
||||
* Called from APanel; Queries available Zoom Targets for Table.
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: AZoomAcross.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
||||
*
|
||||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL - FR [ 1762465 ]
|
||||
*
|
||||
* ZK Port
|
||||
* @author Low Heng Sin
|
||||
*/
|
||||
public class WZoomAcross implements EventListener
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
* @param invoker component to display popup (optional)
|
||||
* @param tableName table name
|
||||
* @param query query
|
||||
*/
|
||||
public WZoomAcross (Component invoker, String tableName, MQuery query)
|
||||
{
|
||||
log.config("TableName=" + tableName + " - " + query);
|
||||
m_tableName = tableName;
|
||||
m_query = query;
|
||||
|
||||
// See What is there
|
||||
getZoomTargets (invoker, tableName);
|
||||
} // AReport
|
||||
|
||||
/** The Query */
|
||||
private MQuery m_query;
|
||||
/** The Popup */
|
||||
private Menupopup m_popup = new Menupopup(); //"ZoomMenu"
|
||||
/** The Option List */
|
||||
private ArrayList<KeyNamePair> m_list = new ArrayList<KeyNamePair>();
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(WZoomAcross.class);
|
||||
/** Table Name */
|
||||
private String m_tableName;
|
||||
private ArrayList<String> m_targets = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* Get the Zomm Targets for the table.
|
||||
* Fill the list and the popup menu
|
||||
* @param invoker component to display popup (optional)
|
||||
* @param tableName table
|
||||
*/
|
||||
private void getZoomTargets (Component invoker, String tableName)
|
||||
{
|
||||
String sql = "SELECT DISTINCT ws.AD_Window_ID,ws.Name, wp.AD_Window_ID,wp.Name, t.TableName "
|
||||
+ "FROM AD_Table t ";
|
||||
boolean baseLanguage = Env.isBaseLanguage(Env.getCtx(), "AD_Window");
|
||||
if (baseLanguage)
|
||||
sql += "INNER JOIN AD_Window ws ON (t.AD_Window_ID=ws.AD_Window_ID)"
|
||||
+ " LEFT OUTER JOIN AD_Window wp ON (t.PO_Window_ID=wp.AD_Window_ID) ";
|
||||
else
|
||||
sql += "INNER JOIN AD_Window_Trl ws ON (t.AD_Window_ID=ws.AD_Window_ID AND ws.AD_Language=?)"
|
||||
+ " LEFT OUTER JOIN AD_Window_Trl wp ON (t.PO_Window_ID=wp.AD_Window_ID AND wp.AD_Language=?) ";
|
||||
//
|
||||
sql += "WHERE t.TableName NOT LIKE 'I%'" // No Import
|
||||
+ " AND EXISTS (SELECT * FROM AD_Tab tt " // First Tab
|
||||
+ "WHERE (tt.AD_Window_ID=ws.AD_Window_ID OR tt.AD_Window_ID=wp.AD_Window_ID)"
|
||||
+ " AND tt.AD_Table_ID=t.AD_Table_ID AND tt.SeqNo=10)"
|
||||
+ " AND t.AD_Table_ID IN "
|
||||
+ "(SELECT AD_Table_ID FROM AD_Column "
|
||||
+ "WHERE ColumnName=? AND IsKey='N' AND IsParent='N') " // #x
|
||||
+ "ORDER BY 2";
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
int index = 1;
|
||||
if (!baseLanguage)
|
||||
{
|
||||
pstmt.setString (index++, Env.getAD_Language(Env.getCtx()));
|
||||
pstmt.setString (index++, Env.getAD_Language(Env.getCtx()));
|
||||
}
|
||||
pstmt.setString (index++, tableName + "_ID");
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
int AD_Window_ID = rs.getInt(1);
|
||||
String Name = rs.getString(2);
|
||||
int PO_Window_ID = rs.getInt(3);
|
||||
String targetTableName = rs.getString(5);
|
||||
if (PO_Window_ID == 0)
|
||||
addTarget(targetTableName, AD_Window_ID, Name, null);
|
||||
else
|
||||
addTarget(targetTableName, AD_Window_ID, Name, Boolean.TRUE);
|
||||
// PO
|
||||
if (PO_Window_ID != 0)
|
||||
{
|
||||
Name = rs.getString(4);
|
||||
addTarget(targetTableName, PO_Window_ID, Name, Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
|
||||
// Begin - afalcone - Bug Fix [ 1659420 ] Usability: zoom across
|
||||
/*
|
||||
// No Zoom
|
||||
if (m_list.size() == 0)
|
||||
{
|
||||
ADialog.info(0, invoker, "NoZoomTarget");
|
||||
log.info("BaseLanguage=" + baseLanguage);
|
||||
}
|
||||
else if (invoker.isShowing())
|
||||
m_popup.show(invoker, 0, invoker.getHeight()); // below button
|
||||
*/
|
||||
|
||||
// No Zoom
|
||||
if (m_list.size() == 0)
|
||||
{
|
||||
m_popup.appendChild(new Label(Msg.getMsg(Env.getCtx(), "NoZoomTarget"))); // Added
|
||||
log.info("BaseLanguage=" + baseLanguage);
|
||||
}
|
||||
m_popup.setPage(invoker.getPage());
|
||||
m_popup.open(invoker);
|
||||
|
||||
//End - afalcone - Bug Fix [ 1659420 ] Usability: zoom across
|
||||
|
||||
} // getZoomTargets
|
||||
|
||||
/**
|
||||
* Check Target and Add to popup
|
||||
* @param targetTableName table name
|
||||
* @param AD_Window_ID window
|
||||
* @param Name name
|
||||
* @param isSO has po/so Window
|
||||
* @return true if there is a record
|
||||
*/
|
||||
private boolean addTarget (String targetTableName,
|
||||
int AD_Window_ID, String Name, Boolean isSO)
|
||||
{
|
||||
String key = targetTableName + AD_Window_ID + Name + isSO;
|
||||
if (m_targets.contains(key))
|
||||
return false;
|
||||
else
|
||||
m_targets.add(key);
|
||||
|
||||
String sql = "SELECT COUNT(*) FROM " + targetTableName
|
||||
+ " WHERE " + m_query.getWhereClause(false);
|
||||
String sqlAdd = "";
|
||||
if (isSO != null)
|
||||
{
|
||||
/*
|
||||
For RMA, Material Receipt window should be loaded for IsSOTrx=true
|
||||
and Shipment for IsSOTrx=false
|
||||
*/
|
||||
|
||||
if (MRMA.Table_Name.equals(m_tableName) && (AD_Window_ID == 169
|
||||
|| AD_Window_ID == 184))
|
||||
{
|
||||
isSO = !isSO;
|
||||
}
|
||||
sqlAdd = " AND IsSOTrx=" + (isSO.booleanValue() ? "'Y'" : "'N'");
|
||||
}
|
||||
int count = DB.getSQLValue(null, sql+sqlAdd);
|
||||
if (count < 0 && isSO != null) // error try again w/o SO
|
||||
count = DB.getSQLValue(null, sql);
|
||||
if (count <= 0)
|
||||
return false;
|
||||
//
|
||||
System.err.println("AD_Window_ID=" + AD_Window_ID + " targetTable=" + targetTableName + " Name="+Name + " Count=" + count);
|
||||
KeyNamePair pp = new KeyNamePair (AD_Window_ID, Name + " (#"+count+")");
|
||||
m_list.add(pp);
|
||||
Menuitem menuItem = new Menuitem(pp.toString());
|
||||
menuItem.addEventListener(Events.ON_CLICK, this);
|
||||
m_popup.appendChild(menuItem);
|
||||
m_query.setRecordCount(count);
|
||||
return true;
|
||||
} // checkTarget
|
||||
|
||||
/**
|
||||
* Launch Zoom
|
||||
* @param pp KeyPair
|
||||
*/
|
||||
private void launchZoom (KeyNamePair pp)
|
||||
{
|
||||
int AD_Window_ID = pp.getKey();
|
||||
AEnv.zoom(AD_Window_ID, m_query);
|
||||
} // launchZoom
|
||||
|
||||
public void onEvent(Event e) throws Exception {
|
||||
if (e.getTarget() instanceof Menuitem) {
|
||||
String cmd = ((Menuitem)e.getTarget()).getLabel();
|
||||
for (int i = 0; i < m_list.size(); i++)
|
||||
{
|
||||
KeyNamePair pp = (KeyNamePair)m_list.get(i);
|
||||
if (cmd.equals(pp.getName()))
|
||||
{
|
||||
launchZoom (pp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // AZoom
|
|
@ -68,6 +68,8 @@ public class CWindowToolbar extends FToolbar implements EventListener
|
|||
|
||||
private ArrayList<ToolbarListener> listeners = new ArrayList<ToolbarListener>();
|
||||
|
||||
private Event event;
|
||||
|
||||
public CWindowToolbar()
|
||||
{
|
||||
init();
|
||||
|
@ -120,7 +122,7 @@ public class CWindowToolbar extends FToolbar implements EventListener
|
|||
|
||||
btnGridToggle = new ToolBarButton("");
|
||||
btnGridToggle.setName("btnGridToggle");
|
||||
btnGridToggle.setImage("/images/ZoomAcross24.gif");
|
||||
btnGridToggle.setImage("/images/Multi24.gif");
|
||||
btnGridToggle.setTooltiptext(Msg.getMsg(Env.getCtx(),"Multi"));
|
||||
|
||||
btnHistoryRecords = new ToolBarButton("");
|
||||
|
@ -147,17 +149,17 @@ public class CWindowToolbar extends FToolbar implements EventListener
|
|||
btnFirst.setName("btnFirst");
|
||||
btnFirst.setImage("/images/First24.gif");
|
||||
btnFirst.setTooltip(Msg.getMsg(Env.getCtx(),"First"));
|
||||
|
||||
|
||||
btnPrevious = new ToolBarButton("");
|
||||
btnPrevious.setName("btnPrevious");
|
||||
btnPrevious.setImage("/images/Previous24.gif");
|
||||
btnPrevious.setTooltip(Msg.getMsg(Env.getCtx(),"Previous"));
|
||||
|
||||
|
||||
btnNext = new ToolBarButton("");
|
||||
btnNext.setName("btnNext");
|
||||
btnNext.setImage("/images/Next24.gif");
|
||||
btnNext.setTooltip(Msg.getMsg(Env.getCtx(),"Next"));
|
||||
|
||||
|
||||
btnLast = new ToolBarButton("");
|
||||
btnLast.setName("btnLast");
|
||||
btnLast.setImage("/images/Last24.gif");
|
||||
|
@ -168,12 +170,12 @@ public class CWindowToolbar extends FToolbar implements EventListener
|
|||
btnReport.setName("btnReport");
|
||||
btnReport.setImage("/images/Report24.gif");
|
||||
btnReport.setTooltip(Msg.getMsg(Env.getCtx(),"Report"));
|
||||
|
||||
|
||||
btnArchive = new ToolBarButton("");
|
||||
btnArchive.setName("btnArchive");
|
||||
btnArchive.setImage("/images/Archive24.gif");
|
||||
btnArchive.setTooltip(Msg.getMsg(Env.getCtx(),"Archive"));
|
||||
|
||||
|
||||
btnPrint = new ToolBarButton("");
|
||||
btnPrint.setName("btnPrint");
|
||||
btnPrint.setImage("/images/Print24.gif");
|
||||
|
@ -184,22 +186,22 @@ public class CWindowToolbar extends FToolbar implements EventListener
|
|||
btnZoomAcross.setName("btnZoomAcross");
|
||||
btnZoomAcross.setImage("/images/ZoomAcross24.gif");
|
||||
btnZoomAcross.setTooltip(Msg.getMsg(Env.getCtx(),"ZoomAcross"));
|
||||
|
||||
|
||||
btnActiveWorkflows = new ToolBarButton("");
|
||||
btnActiveWorkflows.setName("btnActiveWorkflows");
|
||||
btnActiveWorkflows.setImage("/images/WorkFlow24.gif");
|
||||
btnActiveWorkflows.setTooltip(Msg.getMsg(Env.getCtx(),"WorkFlow"));
|
||||
|
||||
|
||||
btnRequests = new ToolBarButton("");
|
||||
btnRequests.setName("btnRequests");
|
||||
btnRequests.setImage("/images/Request24.gif");
|
||||
btnRequests.setTooltip(Msg.getMsg(Env.getCtx(),"Request"));
|
||||
|
||||
|
||||
btnProductInfo = new ToolBarButton("");
|
||||
btnProductInfo.setName("btnProductInfo");
|
||||
btnProductInfo.setImage("/images/Product24.gif");
|
||||
btnProductInfo.setTooltip(Msg.getMsg(Env.getCtx(),"InfoProduct"));
|
||||
|
||||
|
||||
// btnExit = new ToolBarButton("");
|
||||
// btnExit.setName("btnExit");
|
||||
// btnExit.setImage("/images/End24.gif");
|
||||
|
@ -231,7 +233,7 @@ public class CWindowToolbar extends FToolbar implements EventListener
|
|||
this.appendChild(btnArchive);
|
||||
this.appendChild(btnPrint);
|
||||
addSeparator();
|
||||
//this.appendChild(btnZoomAcross);
|
||||
this.appendChild(btnZoomAcross);
|
||||
this.appendChild(btnActiveWorkflows);
|
||||
this.appendChild(btnRequests);
|
||||
this.appendChild(btnProductInfo);
|
||||
|
@ -255,6 +257,8 @@ public class CWindowToolbar extends FToolbar implements EventListener
|
|||
// Testing Purposes
|
||||
|
||||
btnGridToggle.setDisabled(false);
|
||||
|
||||
btnZoomAcross.setDisabled(false);
|
||||
}
|
||||
|
||||
protected void addSeparator()
|
||||
|
@ -277,7 +281,7 @@ public class CWindowToolbar extends FToolbar implements EventListener
|
|||
}
|
||||
|
||||
public void onEvent(Event event)
|
||||
{
|
||||
{
|
||||
String eventName = event.getName();
|
||||
Component eventComp = event.getTarget();
|
||||
|
||||
|
@ -286,6 +290,7 @@ public class CWindowToolbar extends FToolbar implements EventListener
|
|||
{
|
||||
if(eventComp instanceof ToolBarButton)
|
||||
{
|
||||
this.event = event;
|
||||
ToolBarButton cComponent = (ToolBarButton) eventComp;
|
||||
String compName = cComponent.getName();
|
||||
String methodName = "on" + compName.substring(3);
|
||||
|
@ -318,6 +323,7 @@ public class CWindowToolbar extends FToolbar implements EventListener
|
|||
log.log(Level.SEVERE, "Could not invoke Toolbar listener method: " + methodName + "()", e);
|
||||
}
|
||||
}
|
||||
this.event = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -443,4 +449,9 @@ public class CWindowToolbar extends FToolbar implements EventListener
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public Event getEvent()
|
||||
{
|
||||
return event;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.adempiere.webui.panel;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.webui.WZoomAcross;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.apps.ProcessModalDialog;
|
||||
import org.adempiere.webui.apps.WReport;
|
||||
|
@ -234,7 +235,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
Env.setContext(ctx, curWindowNo, "WindowName", gridWindow.getName());
|
||||
curTab.getTableModel().setChanged(false);
|
||||
curTabIndex = 0;
|
||||
curTabpanel.query();
|
||||
curTabpanel.query(m_onlyCurrentRows, m_onlyCurrentDays, 0);
|
||||
curTabpanel.activate(true);
|
||||
|
||||
//if (tabbox.getTabCount() > 0)
|
||||
|
@ -251,7 +252,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
if (gridWindow.isTransaction())
|
||||
{
|
||||
toolbar.enableHistoryRecords(true);
|
||||
history(1);
|
||||
}
|
||||
|
||||
updateToolbar();
|
||||
|
@ -949,6 +949,33 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
new WReport (curTab.getAD_Table_ID(), query, null, curWindowNo);
|
||||
|
||||
}
|
||||
|
||||
public void onZoomAcross() {
|
||||
if (toolbar.getEvent() != null)
|
||||
{
|
||||
int record_ID = curTab.getRecord_ID();
|
||||
if (record_ID <= 0)
|
||||
return;
|
||||
|
||||
// Query
|
||||
MQuery query = new MQuery();
|
||||
// Current row
|
||||
String link = curTab.getKeyColumnName();
|
||||
// Link for detail records
|
||||
if (link.length() == 0)
|
||||
link = curTab.getLinkColumnName();
|
||||
if (link.length() != 0)
|
||||
{
|
||||
if (link.endsWith("_ID"))
|
||||
query.addRestriction(link, MQuery.EQUAL,
|
||||
new Integer(Env.getContextAsInt(ctx, curWindowNo, link)));
|
||||
else
|
||||
query.addRestriction(link, MQuery.EQUAL,
|
||||
Env.getContext(ctx, curWindowNo, link));
|
||||
}
|
||||
new WZoomAcross (toolbar.getEvent().getTarget(), curTab.getTableName(), query);
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Start Button Process
|
||||
|
|
Loading…
Reference in New Issue