merge revision 6275-6315 from branches/adempiere341

This commit is contained in:
Heng Sin Low 2008-09-03 02:50:56 +00:00
parent 7de7553dac
commit 3824014613
26 changed files with 1923 additions and 1767 deletions

View File

@ -519,15 +519,9 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
"Notice : " + noOfNotice + ", Request : " + noOfRequest + ", Workflow Activities : " + noOfWorkflow); "Notice : " + noOfNotice + ", Request : " + noOfRequest + ", Workflow Activities : " + noOfWorkflow);
} }
public void showWindowInTabPanel(Window window) /**
{ * @param event
Tabpanel tabPanel = new Tabpanel(); */
window.setParent(tabPanel);
String title = window.getTitle();
window.setTitle(null);
windowContainer.addWindow(tabPanel, title, true);
}
public void onEvent(Event event) public void onEvent(Event event)
{ {
Component comp = event.getTarget(); Component comp = event.getTarget();
@ -720,50 +714,97 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
if(menu.getAction().equals(MMenu.ACTION_Window)) if(menu.getAction().equals(MMenu.ACTION_Window))
{ {
ADWindow adWindow = new ADWindow(Env.getCtx(), menu.getAD_Window_ID()); openWindow(menu.getAD_Window_ID());
DesktopTabpanel tabPanel = new DesktopTabpanel();
adWindow.createPart(tabPanel);
windowContainer.addWindow(tabPanel, adWindow.getTitle(), true);
} }
else if(menu.getAction().equals(MMenu.ACTION_Process) || else if(menu.getAction().equals(MMenu.ACTION_Process) ||
menu.getAction().equals(MMenu.ACTION_Report)) menu.getAction().equals(MMenu.ACTION_Report))
{ {
ProcessDialog pd = new ProcessDialog (menu.getAD_Process_ID(), menu.isSOTrx()); openProcessDialog(menu.getAD_Process_ID(), menu.isSOTrx());
if (pd.isValid()) {
pd.setPage(page);
pd.setClosable(true);
pd.setWidth("500px");
pd.doHighlighted();
}
} }
else if(menu.getAction().equals(MMenu.ACTION_Form)) else if(menu.getAction().equals(MMenu.ACTION_Form))
{ {
ADForm form = ADForm.openForm(menu.getAD_Form_ID()); openForm(menu.getAD_Form_ID());
DesktopTabpanel tabPanel = new DesktopTabpanel();
form.setParent(tabPanel);
//do not show window title when open as tab
form.setTitle(null);
windowContainer.addWindow(tabPanel, form.getFormName(), true);
} }
else else
{ {
throw new ApplicationException("Menu Action not yet implemented: " + menu.getAction()); throw new ApplicationException("Menu Action not yet implemented: " + menu.getAction());
} }
} }
/**
*
* @param processId
* @param soTrx
* @return ProcessDialog
*/
public ProcessDialog openProcessDialog(int processId, boolean soTrx) {
ProcessDialog pd = new ProcessDialog (processId, soTrx);
if (pd.isValid()) {
pd.setPage(page);
pd.setClosable(true);
pd.setWidth("500px");
pd.doHighlighted();
}
return pd;
}
/**
*
* @param formId
* @return ADWindow
*/
public ADForm openForm(int formId) {
ADForm form = ADForm.openForm(formId);
DesktopTabpanel tabPanel = new DesktopTabpanel();
form.setParent(tabPanel);
//do not show window title when open as tab
form.setTitle(null);
windowContainer.addWindow(tabPanel, form.getFormName(), true);
return form;
}
/**
*
* @param windowId
* @return ADWindow
*/
public ADWindow openWindow(int windowId) {
ADWindow adWindow = new ADWindow(Env.getCtx(), windowId);
DesktopTabpanel tabPanel = new DesktopTabpanel();
adWindow.createPart(tabPanel);
windowContainer.addWindow(tabPanel, adWindow.getTitle(), true);
return adWindow;
}
/**
* @param url
*/
public void showURL(String url, boolean closeable) public void showURL(String url, boolean closeable)
{ {
showURL(url, url, closeable); showURL(url, url, closeable);
} }
/**
*
* @param url
* @param title
* @param closeable
*/
public void showURL(String url, String title, boolean closeable) public void showURL(String url, String title, boolean closeable)
{ {
Iframe iframe = new Iframe(url); Iframe iframe = new Iframe(url);
addWin(iframe, title, closeable); addWin(iframe, title, closeable);
} }
/**
* @param webDoc
* @param title
* @param closeable
*/
public void showURL(WebDoc webDoc, String title, boolean closeable) public void showURL(WebDoc webDoc, String title, boolean closeable)
{ {
Iframe iframe = new Iframe(); Iframe iframe = new Iframe();
@ -774,6 +815,12 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
addWin(iframe, title, closeable); addWin(iframe, title, closeable);
} }
/**
*
* @param fr
* @param title
* @param closeable
*/
private void addWin(Iframe fr, String title, boolean closeable) private void addWin(Iframe fr, String title, boolean closeable)
{ {
fr.setWidth("100%"); fr.setWidth("100%");
@ -791,7 +838,10 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
windowContainer.addWindow(tabPanel, title, closeable); windowContainer.addWindow(tabPanel, title, closeable);
} }
/**
* @param AD_Window_ID
* @param query
*/
public void showZoomWindow(int AD_Window_ID, MQuery query) public void showZoomWindow(int AD_Window_ID, MQuery query)
{ {
ADWindow wnd = new ADWindow(Env.getCtx(), AD_Window_ID, query); ADWindow wnd = new ADWindow(Env.getCtx(), AD_Window_ID, query);
@ -801,12 +851,19 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
windowContainer.addWindow(tabPanel, wnd.getTitle(), true); windowContainer.addWindow(tabPanel, wnd.getTitle(), true);
} }
/**
* @param win
*/
public void showWindow(Window win) public void showWindow(Window win)
{ {
String pos = win.getPosition(); String pos = win.getPosition();
this.showWindow(win, pos); this.showWindow(win, pos);
} }
/**
* @param win
* @param pos
*/
public void showWindow(Window win, String pos) public void showWindow(Window win, String pos)
{ {
win.setPage(page); win.setPage(page);
@ -819,31 +876,33 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
mode = objMode.toString(); mode = objMode.toString();
} }
if ("modal".equals(mode)) if (Window.MODE_MODAL.equals(mode))
{ {
showModal(win); showModal(win);
} }
else if ("popup".equals(mode)) else if (Window.MODE_POPUP.equals(mode))
{ {
showPopup(win, pos); showPopup(win, pos);
} }
else if ("overlapped".equals(mode)) else if (Window.MODE_OVERLAPPED.equals(mode))
{ {
showOverlapped(win, pos); showOverlapped(win, pos);
} }
else if ("embedded".equals(mode)) else if (Window.MODE_EMBEDDED.equals(mode))
{ {
showEmbedded(win, pos); showEmbedded(win);
} }
else if ("highlighted".equals(mode)) else if (Window.MODE_HIGHLIGHTED.equals(mode))
{ {
showHighlighted(win, pos); showHighlighted(win, pos);
} }
// win.setVisible(true);
} }
public void showModal(Window win) /**
*
* @param win
*/
private void showModal(Window win)
{ {
try try
{ {
@ -856,7 +915,12 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
} }
public void showPopup(Window win, String position) /**
*
* @param win
* @param position
*/
private void showPopup(Window win, String position)
{ {
if (position == null) if (position == null)
win.setPosition("center"); win.setPosition("center");
@ -866,7 +930,12 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
win.doPopup(); win.doPopup();
} }
public void showOverlapped(Window win, String position) /**
*
* @param win
* @param position
*/
private void showOverlapped(Window win, String position)
{ {
if (position == null) if (position == null)
win.setPosition("center"); win.setPosition("center");
@ -876,7 +945,12 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
win.doOverlapped(); win.doOverlapped();
} }
public void showHighlighted(Window win, String position) /**
*
* @param win
* @param position
*/
private void showHighlighted(Window win, String position)
{ {
if (position == null) if (position == null)
win.setPosition("center"); win.setPosition("center");
@ -886,36 +960,56 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
win.doHighlighted(); win.doHighlighted();
} }
public void showEmbedded(Window win, String position) /**
*
* @param window
*/
private void showEmbedded(Window window)
{ {
if (position == null) Tabpanel tabPanel = new Tabpanel();
win.setPosition("center"); window.setParent(tabPanel);
else String title = window.getTitle();
win.setPosition(position); window.setTitle(null);
windowContainer.addWindow(tabPanel, title, true);
win.doEmbedded();
} }
/**
* @return clientInfo
*/
public ClientInfo getClientInfo() { public ClientInfo getClientInfo() {
return clientInfo; return clientInfo;
} }
/**
*
* @param clientInfo
*/
public void setClientInfo(ClientInfo clientInfo) { public void setClientInfo(ClientInfo clientInfo) {
this.clientInfo = clientInfo; this.clientInfo = clientInfo;
} }
/**
* @param win
*/
public int registerWindow(Object win) { public int registerWindow(Object win) {
int retValue = windows.size(); int retValue = windows.size();
windows.add(win); windows.add(win);
return retValue; return retValue;
} }
/**
* @param WindowNo
*/
public void unregisterWindow(int WindowNo) { public void unregisterWindow(int WindowNo) {
if (WindowNo < windows.size()) if (WindowNo < windows.size())
windows.set(WindowNo, null); windows.set(WindowNo, null);
} }
/**
*
* @param WindowNo
* @return Object
*/
public Object findWindow(int WindowNo) { public Object findWindow(int WindowNo) {
if (WindowNo < windows.size()) if (WindowNo < windows.size())
return windows.get(WindowNo); return windows.get(WindowNo);
@ -923,11 +1017,18 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
return null; return null;
} }
/**
* Close active tab
*/
public void removeWindow() public void removeWindow()
{ {
windowContainer.removeWindow(); windowContainer.removeWindow();
} }
/**
*
* @param page
*/
public void setPage(Page page) { public void setPage(Page page) {
if (this.page != page) { if (this.page != page) {
layout.setPage(page); layout.setPage(page);
@ -935,6 +1036,10 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
} }
} }
/**
* Get the root component
* @return Component
*/
public Component getComponent() { public Component getComponent() {
return layout; return layout;
} }

View File

@ -1,30 +1,98 @@
package org.adempiere.webui; package org.adempiere.webui;
import org.adempiere.webui.apps.ProcessDialog;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.panel.ADForm;
import org.adempiere.webui.window.ADWindow;
import org.compiere.model.MQuery; import org.compiere.model.MQuery;
import org.compiere.util.WebDoc; import org.compiere.util.WebDoc;
public interface IDesktop { public interface IDesktop {
/**
*
* @return ClientInfo
*/
public ClientInfo getClientInfo(); public ClientInfo getClientInfo();
/**
*
* @param nodeId
*/
public void onMenuSelected(int nodeId); public void onMenuSelected(int nodeId);
/**
*
* @param window
* @return windowNo
*/
public int registerWindow(Object window); public int registerWindow(Object window);
/**
* close active window
*/
public void removeWindow(); public void removeWindow();
/**
*
* @param url
* @param closeable
*/
public void showURL(String url, boolean closeable); public void showURL(String url, boolean closeable);
/**
*
* @param doc
* @param string
* @param closeable
*/
public void showURL(WebDoc doc, String string, boolean closeable); public void showURL(WebDoc doc, String string, boolean closeable);
/**
*
* @param win
*/
public void showWindow(Window win); public void showWindow(Window win);
/**
*
* @param win
* @param position
*/
public void showWindow(Window win, String position); public void showWindow(Window win, String position);
/**
*
* @param window_ID
* @param query
*/
public void showZoomWindow(int window_ID, MQuery query); public void showZoomWindow(int window_ID, MQuery query);
/**
*
* @param windowNo
*/
public void unregisterWindow(int windowNo); public void unregisterWindow(int windowNo);
public void showWindowInTabPanel(Window win); // Elaine 2008/07/30 /**
*
* @param processId
* @param soTrx
* @return ProcessDialog
*/
public ProcessDialog openProcessDialog(int processId, boolean soTrx);
/**
*
* @param formId
* @return ADWindow
*/
public ADForm openForm(int formId);
/**
*
* @param windowId
* @return ADWindow
*/
public ADWindow openWindow(int windowId);
} }

View File

@ -164,7 +164,8 @@ public class WArchive implements EventListener
else // all Reports else // all Reports
av.query(true, m_AD_Table_ID, 0); av.query(true, m_AD_Table_ID, 0);
SessionManager.getAppDesktop().showWindowInTabPanel(form); form.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
SessionManager.getAppDesktop().showWindow(form);
} }
} }
} }

View File

@ -17,6 +17,10 @@
package org.adempiere.webui.apps; package org.adempiere.webui.apps;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InvalidClassException; import java.io.InvalidClassException;
import java.io.NotSerializableException; import java.io.NotSerializableException;
import java.net.URI; import java.net.URI;
@ -26,6 +30,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import javax.servlet.ServletRequest; import javax.servlet.ServletRequest;
@ -51,6 +56,13 @@ import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Execution; import org.zkoss.zk.ui.Execution;
import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.Executions;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfImportedPage;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfWriter;
/** /**
* Windows Application Environment and utilities * Windows Application Environment and utilities
* *
@ -735,4 +747,36 @@ public final class AEnv
return false; return false;
} }
/**
*
* @param pdfList
* @param outFile
* @throws IOException
* @throws DocumentException
* @throws FileNotFoundException
*/
public static void mergePdf(List<File> pdfList, File outFile) throws IOException,
DocumentException, FileNotFoundException {
Document document = null;
PdfWriter copy = null;
for (File f : pdfList)
{
PdfReader reader = new PdfReader(f.getAbsolutePath());
if (document == null)
{
document = new Document(reader.getPageSizeWithRotation(1));
copy = PdfWriter.getInstance(document, new FileOutputStream(outFile));
document.open();
}
int pages = reader.getNumberOfPages();
PdfContentByte cb = copy.getDirectContent();
for (int i = 1; i <= pages; i++) {
document.newPage();
PdfImportedPage page = copy.getImportedPage(reader, i);
cb.addTemplate(page, 0, 0);
}
}
document.close();
}
} // AEnv } // AEnv

View File

@ -252,13 +252,16 @@ public class ProcessModalDialog extends Window implements EventListener
m_autoStart = true; m_autoStart = true;
} }
if (m_autoStart) { if (m_autoStart) {
this.getFirstChild().setVisible(false);
startProcess(); startProcess();
return true;
} }
} }
// Check if the process is a silent one // Check if the process is a silent one
if(isValid() && m_ShowHelp != null && m_ShowHelp.equals("S")) if(isValid() && m_ShowHelp != null && m_ShowHelp.equals("S"))
{ {
this.getFirstChild().setVisible(false);
startProcess(); startProcess();
} }
return true; return true;
@ -268,22 +271,24 @@ public class ProcessModalDialog extends Window implements EventListener
* launch process * launch process
*/ */
private void startProcess() private void startProcess()
{ {
m_processRunnable = new ProcessRunnable(Executions.getCurrent().getDesktop());
m_pi.setPrintPreview(true); m_pi.setPrintPreview(true);
if (m_ASyncProcess != null) { if (m_ASyncProcess != null) {
m_ASyncProcess.lockUI(m_pi); m_ASyncProcess.lockUI(m_pi);
} else {
Clients.showBusy(null, true);
} }
m_processRunnable = new ProcessRunnable(Executions.getCurrent().getDesktop());
//use echo, otherwise lock ui wouldn't work //use echo, otherwise lock ui wouldn't work
Clients.response(new AuEcho(this, "runProcessBackground", null)); Clients.response(new AuEcho(this, "runASyncProcess", null));
} }
/** /**
* internal use, don't call this directly * internal use, don't call this directly
*/ */
public void runProcessBackground() { public void runASyncProcess() {
new Thread(m_processRunnable).start(); new Thread(m_processRunnable).start();
} }
@ -302,6 +307,8 @@ public class ProcessModalDialog extends Window implements EventListener
} finally { } finally {
if (m_ASyncProcess != null) { if (m_ASyncProcess != null) {
m_ASyncProcess.unlockUI(m_pi); m_ASyncProcess.unlockUI(m_pi);
} else {
Clients.showBusy(null, false);
} }
//release full control of desktop //release full control of desktop
Executions.deactivate(desktop); Executions.deactivate(desktop);

View File

@ -18,13 +18,13 @@ package org.adempiere.webui.apps.form;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.math.*; import java.math.*;
import java.sql.*; import java.sql.*;
import java.util.*; import java.util.*;
import java.util.logging.*; import java.util.logging.*;
import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.DesktopTabpanel; import org.adempiere.webui.component.DesktopTabpanel;
import org.adempiere.webui.component.Label; import org.adempiere.webui.component.Label;
@ -68,12 +68,6 @@ import org.zkoss.zul.Div;
import org.zkoss.zul.Html; import org.zkoss.zul.Html;
import org.zkoss.zul.Space; import org.zkoss.zul.Space;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfImportedPage;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfWriter;
/** /**
* Manual Shipment Selection * Manual Shipment Selection
* *
@ -706,26 +700,7 @@ public class WInOutGen extends ADForm implements EventListener, ValueChangeListe
if (pdfList.size() > 1) { if (pdfList.size() > 1) {
try { try {
File outFile = File.createTempFile("WInOutGen", ".pdf"); File outFile = File.createTempFile("WInOutGen", ".pdf");
Document document = null; AEnv.mergePdf(pdfList, outFile);
PdfWriter copy = null;
for (File f : pdfList)
{
PdfReader reader = new PdfReader(f.getAbsolutePath());
if (document == null)
{
document = new Document(reader.getPageSizeWithRotation(1));
copy = PdfWriter.getInstance(document, new FileOutputStream(outFile));
document.open();
}
int pages = reader.getNumberOfPages();
PdfContentByte cb = copy.getDirectContent();
for (int i = 1; i <= pages; i++) {
document.newPage();
PdfImportedPage page = copy.getImportedPage(reader, i);
cb.addTemplate(page, 0, 0);
}
}
document.close();
Clients.showBusy(null, false); Clients.showBusy(null, false);
Window win = new SimplePDFViewer(this.getFormName(), new FileInputStream(outFile)); Window win = new SimplePDFViewer(this.getFormName(), new FileInputStream(outFile));
@ -745,7 +720,6 @@ public class WInOutGen extends ADForm implements EventListener, ValueChangeListe
} }
} }
/************************************************************************** /**************************************************************************
* Lock User Interface. * Lock User Interface.
* Called from the Worker before processing * Called from the Worker before processing

View File

@ -18,7 +18,6 @@ package org.adempiere.webui.apps.form;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -29,6 +28,7 @@ import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.DesktopTabpanel; import org.adempiere.webui.component.DesktopTabpanel;
import org.adempiere.webui.component.Label; import org.adempiere.webui.component.Label;
@ -86,11 +86,6 @@ import org.zkoss.zul.Div;
import org.zkoss.zul.Html; import org.zkoss.zul.Html;
import org.zkoss.zul.Space; import org.zkoss.zul.Space;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfImportedPage;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfWriter;
/** /**
* Manual Invoice Selection * Manual Invoice Selection
@ -705,26 +700,7 @@ public class WInvoiceGen extends ADForm
if (pdfList.size() > 1) { if (pdfList.size() > 1) {
try { try {
File outFile = File.createTempFile("WInvoiceGen", ".pdf"); File outFile = File.createTempFile("WInvoiceGen", ".pdf");
Document document = null; AEnv.mergePdf(pdfList, outFile);
PdfWriter copy = null;
for (File f : pdfList)
{
PdfReader reader = new PdfReader(f.getAbsolutePath());
if (document == null)
{
document = new Document(reader.getPageSizeWithRotation(1));
copy = PdfWriter.getInstance(document, new FileOutputStream(outFile));
document.open();
}
int pages = reader.getNumberOfPages();
PdfContentByte cb = copy.getDirectContent();
for (int i = 1; i <= pages; i++) {
document.newPage();
PdfImportedPage page = copy.getImportedPage(reader, i);
cb.addTemplate(page, 0, 0);
}
}
document.close();
Clients.showBusy(null, false); Clients.showBusy(null, false);
Window win = new SimplePDFViewer(this.getFormName(), new FileInputStream(outFile)); Window win = new SimplePDFViewer(this.getFormName(), new FileInputStream(outFile));

View File

@ -162,8 +162,8 @@ public class WMatch extends ADForm
private Label onlyProductLabel = new Label(); private Label onlyProductLabel = new Label();
private Label dateFromLabel = new Label(); private Label dateFromLabel = new Label();
private Label dateToLabel = new Label(); private Label dateToLabel = new Label();
private WDateEditor dateFrom = new WDateEditor("DateFrom", false, false, true, DisplayType.Date, "DateFrom"); private WDateEditor dateFrom = new WDateEditor("DateFrom", false, false, true, "DateFrom");
private WDateEditor dateTo = new WDateEditor("DateTo", false, false, true, DisplayType.Date, "DateTo"); private WDateEditor dateTo = new WDateEditor("DateTo", false, false, true, "DateTo");
private Button bSearch = new Button(); private Button bSearch = new Button();
private Panel southPanel = new Panel(); private Panel southPanel = new Panel();
private Grid southLayout = GridFactory.newGridLayout(); private Grid southLayout = GridFactory.newGridLayout();

View File

@ -101,7 +101,7 @@ public class WPayment extends Window
m_mTab = mTab; m_mTab = mTab;
try try
{ {
bDateField = new WDateEditor("DateAcct", false, false, true, DisplayType.Date, "DateAcct"); bDateField = new WDateEditor("DateAcct", false, false, true, "DateAcct");
zkInit(); zkInit();
m_initOK = dynInit(button); // Null Pointer if order/invoice not saved yet m_initOK = dynInit(button); // Null Pointer if order/invoice not saved yet
} }

View File

@ -184,8 +184,8 @@ public class WTrxMaterial extends ADForm
MLookup mtypeLookup = MLookupFactory.get (ctx, m_WindowNo, 0, 3666, DisplayType.List); MLookup mtypeLookup = MLookupFactory.get (ctx, m_WindowNo, 0, 3666, DisplayType.List);
mtypeField = new WTableDirEditor("MovementType", false, false, true, mtypeLookup); mtypeField = new WTableDirEditor("MovementType", false, false, true, mtypeLookup);
// Dates // Dates
dateFField = new WDateEditor("DateFrom", false, false, true, DisplayType.Date, Msg.getMsg(Env.getCtx(), "DateFrom")); dateFField = new WDateEditor("DateFrom", false, false, true, Msg.getMsg(Env.getCtx(), "DateFrom"));
dateTField = new WDateEditor("DateTo", false, false, true, DisplayType.Date, Msg.getMsg(Env.getCtx(), "DateTo")); dateTField = new WDateEditor("DateTo", false, false, true, Msg.getMsg(Env.getCtx(), "DateTo"));
// //
confirmPanel.addActionListener(this); confirmPanel.addActionListener(this);
statusBar.setStatusLine(""); statusBar.setStatusLine("");

View File

@ -28,6 +28,7 @@ public class WPerformanceDetail extends Window
WBarGraph barPanel = new WBarGraph(goal); WBarGraph barPanel = new WBarGraph(goal);
appendChild(barPanel); appendChild(barPanel);
SessionManager.getAppDesktop().showWindowInTabPanel(this); this.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
SessionManager.getAppDesktop().showWindow(this);
} // PerformanceDetail } // PerformanceDetail
} }

View File

@ -17,12 +17,14 @@
package org.adempiere.webui.component; package org.adempiere.webui.component;
import java.math.BigDecimal;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.text.ParseException; import java.text.ParseException;
import org.zkoss.zul.Bandpopup; import org.adempiere.webui.apps.AEnv;
import org.zkoss.zul.Button; import org.zkoss.zul.Decimalbox;
import org.zkoss.zul.Hbox; import org.zkoss.zul.Hbox;
import org.zkoss.zul.Popup;
import org.zkoss.zul.Vbox; import org.zkoss.zul.Vbox;
/** /**
@ -31,7 +33,7 @@ import org.zkoss.zul.Vbox;
* @date Mar 11, 2007 * @date Mar 11, 2007
* @version $Revision: 0.10 $ * @version $Revision: 0.10 $
*/ */
public class NumberBox extends Bandbox public class NumberBox extends Panel
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -41,6 +43,9 @@ public class NumberBox extends Bandbox
NumberFormat format = null; NumberFormat format = null;
private Decimalbox decimalBox = null;
private Button btn;
public NumberBox(boolean integral) public NumberBox(boolean integral)
{ {
super(); super();
@ -50,10 +55,25 @@ public class NumberBox extends Bandbox
private void init() private void init()
{ {
this.setImage("/images/Calculator16.png"); decimalBox = new Decimalbox();
if (integral)
decimalBox.setScale(0);
btn = new Button();
btn.setImage("/images/Calculator16.png");
this.setAction("onKeyPress : return calc.validate('" + this.setAction("onKeyPress : return calc.validate('" +
this.getId() + "'," + integral + ", event);"); decimalBox.getId() + "'," + integral + ", event);");
this.appendChild(getBandPopup());
Popup popup = getCalculatorPopup();
btn.setHeight("22px");
btn.setWidth("26px");
btn.setPopup(popup);
appendChild(decimalBox);
appendChild(btn);
appendChild(popup);
String style = AEnv.isFirefox2() ? "display: inline" : "display: inline-block";
this.setStyle(style);
} }
public void setFormat(NumberFormat format) public void setFormat(NumberFormat format)
@ -61,70 +81,64 @@ public class NumberBox extends Bandbox
this.format = format; this.format = format;
} }
public void setValue(Number value) public void setValue(Object value)
{ {
if (format != null) if (value == null)
{ decimalBox.setValue(null);
super.setValue(format.format(value)); else if (value instanceof BigDecimal)
} decimalBox.setValue((BigDecimal) value);
else if (value instanceof Number)
decimalBox.setValue(new BigDecimal(((Number)value).doubleValue()));
else else
{ decimalBox.setValue(new BigDecimal(value.toString()));
super.setValue(value.toString());
}
} }
public void setRawValue(Object value) public BigDecimal getValue()
{ {
super.setRawValue(value); return decimalBox.getValue();
} }
public String getText() public String getText()
{ {
return super.getText(); BigDecimal value = decimalBox.getValue();
if (value == null) return null;
if (format != null)
return format.format(value);
else
return value.toPlainString();
} }
public void setValue(String value) public void setValue(String value)
{ {
String formattedValue = "";
Number numberValue = null; Number numberValue = null;
if (format != null) if (format != null)
{ {
try try
{ {
numberValue = format.parse(value); numberValue = format.parse(value);
formattedValue = format.format(numberValue); setValue(numberValue);
} }
catch (ParseException e) catch (ParseException e)
{ {
formattedValue = value;
} }
} }
else else
{ {
formattedValue = value; decimalBox.setValue(new BigDecimal(value));
} }
super.setValue(formattedValue);
} }
/* private Popup getCalculatorPopup()
public void setReadonly(boolean readonly)
{ {
// Due to bug in bandbox - once set readonly, setting to not readonly Popup popup = new Popup();
// does not work
super.setDisabled(readonly);
}*/
private Bandpopup getBandPopup()
{
Bandpopup bandPopup = new Bandpopup();
Vbox vbox = new Vbox(); Vbox vbox = new Vbox();
txtCalc = new Textbox(); txtCalc = new Textbox();
txtCalc.setAction("onKeyPress : return calc.validate('" + txtCalc.setAction("onKeyPress : return calc.validate('" +
this.getId() + "!real','" + txtCalc.getId() decimalBox.getId() + "','" + txtCalc.getId()
+ "'," + integral + ", event);"); + "'," + integral + ", event);");
txtCalc.setMaxlength(250); txtCalc.setMaxlength(250);
txtCalc.setCols(30); txtCalc.setCols(30);
@ -252,7 +266,7 @@ public class NumberBox extends Bandbox
Button btnEqual = new Button(); Button btnEqual = new Button();
btnEqual.setWidth("30px"); btnEqual.setWidth("30px");
btnEqual.setLabel("="); btnEqual.setLabel("=");
btnEqual.setAction("onClick : calc.evaluate('" + this.getId() + "!real','" btnEqual.setAction("onClick : calc.evaluate('" + decimalBox.getId() + "','"
+ txtCalcId + "')"); + txtCalcId + "')");
Button btnAdd = new Button(); Button btnAdd = new Button();
@ -271,7 +285,30 @@ public class NumberBox extends Bandbox
vbox.appendChild(row3); vbox.appendChild(row3);
vbox.appendChild(row4); vbox.appendChild(row4);
bandPopup.appendChild(vbox); popup.appendChild(vbox);
return bandPopup; return popup;
} }
public boolean isIntegral() {
return integral;
}
public void setIntegral(boolean integral) {
this.integral = integral;
if (integral)
decimalBox.setScale(0);
else
decimalBox.setScale(Decimalbox.AUTO);
}
public void setEnabled(boolean enabled)
{
decimalBox.setReadonly(!enabled);
btn.setEnabled(enabled);
}
public boolean isEnabled()
{
return decimalBox.isReadonly();
}
} }

View File

@ -287,8 +287,7 @@ public class WListItemRenderer implements ListitemRenderer, EventListener, Listi
numberbox.setFormat(format); numberbox.setFormat(format);
numberbox.setValue((BigDecimal)field); numberbox.setValue((BigDecimal)field);
numberbox.setWidth("100px"); numberbox.setWidth("100px");
numberbox.setButtonVisible(true); numberbox.setEnabled(true);
numberbox.setReadonly(false);
numberbox.setStyle("text-align:right; " numberbox.setStyle("text-align:right; "
+ listcell.getStyle()); + listcell.getStyle());
numberbox.addEventListener(Events.ON_CHANGE, this); numberbox.addEventListener(Events.ON_CHANGE, this);
@ -578,7 +577,7 @@ public class WListItemRenderer implements ListitemRenderer, EventListener, Listi
} }
else if (source instanceof NumberBox) else if (source instanceof NumberBox)
{ {
value = new BigDecimal(((NumberBox)source).getValue()); value = ((NumberBox)source).getValue();
} }
if(value != null) if(value != null)

View File

@ -35,6 +35,10 @@ public class Window extends org.zkoss.zul.Window
public static final String MODE_EMBEDDED = "embedded"; public static final String MODE_EMBEDDED = "embedded";
public static final String MODE_HIGHLIGHTED = "highlighted";
public static final String MODE_KEY = "mode";
public Window() public Window()
{ {
super(); super();

View File

@ -46,6 +46,10 @@ public class WDateEditor extends WEditor
private Timestamp oldValue = new Timestamp(0); private Timestamp oldValue = new Timestamp(0);
/**
*
* @param gridField
*/
public WDateEditor(GridField gridField) public WDateEditor(GridField gridField)
{ {
super(new Datebox(), gridField); super(new Datebox(), gridField);
@ -76,23 +80,21 @@ public class WDateEditor extends WEditor
{ {
this("Date", "Date", false, false, true); this("Date", "Date", false, false, true);
} // VDate } // VDate
/** /**
* *
* @param columnName * @param columnName
* @param mandatory * @param mandatory
* @param readonly * @param readonly
* @param updateable * @param updateable
* @param displayType * @param title
* @param label
*/ */
public WDateEditor(String columnName, boolean mandatory, boolean readonly, boolean updateable, public WDateEditor(String columnName, boolean mandatory, boolean readonly, boolean updateable,
int displayType, String label) { String title)
//TODO: support for displayType {
super(new Datebox(), columnName, label, null, mandatory, readonly, updateable); super(new Datebox(), columnName, title, null, mandatory, readonly, updateable);
} }
public void onEvent(Event event) public void onEvent(Event event)
{ {
Date date = getComponent().getValue(); Date date = getComponent().getValue();

View File

@ -43,7 +43,7 @@ public class WNumberEditor extends WEditor
public static final int MAX_DISPLAY_LENGTH = 20; public static final int MAX_DISPLAY_LENGTH = 20;
private String oldValue; private BigDecimal oldValue;
private boolean mandatory = false; private boolean mandatory = false;
@ -95,11 +95,8 @@ public class WNumberEditor extends WEditor
{ {
if (gridField != null) if (gridField != null)
{ {
getComponent().setMaxlength(gridField.getFieldLength());
getComponent().setTooltiptext(gridField.getDescription()); getComponent().setTooltiptext(gridField.getDescription());
} }
getComponent().setCols(MAX_DISPLAY_LENGTH);
} }
/** /**
@ -108,14 +105,8 @@ public class WNumberEditor extends WEditor
*/ */
public void onEvent(Event event) public void onEvent(Event event)
{ {
String newValue = getComponent().getValue(); BigDecimal newValue = getComponent().getValue();
BigDecimal oldNumber = null; ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
if (oldValue != null && oldValue.trim().length() > 0)
oldNumber = new BigDecimal(oldValue);
BigDecimal newNumber = null;
if (newValue != null && newValue.trim().length() > 0)
newNumber = new BigDecimal(newValue);
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldNumber, newNumber);
super.fireValueChange(changeEvent); super.fireValueChange(changeEvent);
oldValue = newValue; oldValue = newValue;
} }
@ -138,7 +129,7 @@ public class WNumberEditor extends WEditor
@Override @Override
public String getDisplay() public String getDisplay()
{ {
return getComponent().getValue(); return getComponent().getText();
} }
@Override @Override
@ -162,14 +153,7 @@ public class WNumberEditor extends WEditor
@Override @Override
public void setValue(Object value) public void setValue(Object value)
{ {
if (value != null) getComponent().setValue(value);
{
getComponent().setValue(value.toString());
}
else
{
getComponent().setValue("0");
}
} }
@Override @Override

View File

@ -331,7 +331,7 @@ ContextMenuListener, IZoomableEditor
@Override @Override
public void dynamicDisplay() public void dynamicDisplay()
{ {
if (isReadWrite() && (!lookup.isValidated() || !lookup.isLoaded())) if (isReadWrite() && (lookup != null) && (!lookup.isValidated() || !lookup.isLoaded()))
this.actionRefresh(); this.actionRefresh();
} }
} }

View File

@ -0,0 +1,174 @@
/******************************************************************************
* Copyright (C) 2008 Low Heng Sin *
* 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. *
*****************************************************************************/
package org.adempiere.webui.editor;
import java.sql.Timestamp;
import java.util.Date;
import java.util.logging.Level;
import org.adempiere.webui.event.ValueChangeEvent;
import org.compiere.model.GridField;
import org.compiere.util.CLogger;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Timebox;
/**
*
* @author Low Heng Sin
*/
public class WTimeEditor extends WEditor
{
private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE};
private static final CLogger logger;
static
{
logger = CLogger.getCLogger(WDateEditor.class);
}
private Timestamp oldValue = new Timestamp(0);
/**
*
* @param gridField
*/
public WTimeEditor(GridField gridField)
{
super(new Timebox(), gridField);
}
/**
*
* @param columnName
* @param mandatory
* @param readonly
* @param updateable
* @param title
*/
public WTimeEditor(String columnName, boolean mandatory, boolean readonly, boolean updateable,
String title)
{
super(new Timebox(), columnName, title, null, mandatory, readonly, updateable);
}
/**
* Constructor for use if a grid field is unavailable
*
* @param label
* column name (not displayed)
* @param description
* description of component
* @param mandatory
* whether a selection must be made
* @param readonly
* whether or not the editor is read only
* @param updateable
* whether the editor contents can be changed
*/
public WTimeEditor (String label, String description, boolean mandatory, boolean readonly, boolean updateable)
{
super(new Timebox(), label, description, mandatory, readonly, updateable);
setColumnName("Time");
}
public WTimeEditor()
{
this("Time", "Time", false, false, true);
} // VDate
public void onEvent(Event event)
{
Date date = getComponent().getValue();
Timestamp newValue = null;
if (date != null)
{
newValue = new Timestamp(date.getTime());
}
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
super.fireValueChange(changeEvent);
oldValue = newValue;
}
@Override
public String getDisplay()
{
// Elaine 2008/07/29
return getComponent().getText();
//
}
@Override
public Object getValue()
{
// Elaine 2008/07/25
if(getComponent().getValue() == null) return null;
return new Timestamp(getComponent().getValue().getTime());
//
}
@Override
public boolean isMandatory()
{
return false;
}
@Override
public void setMandatory(boolean mandatory)
{
}
@Override
public void setValue(Object value)
{
if (value == null)
{
oldValue = null;
getComponent().setValue(null);
}
else if (value instanceof Timestamp)
{
getComponent().setValue((Timestamp)value);
oldValue = (Timestamp)value;
}
else
{
logger.log(Level.SEVERE, "New field value is not of type timestamp");
}
}
@Override
public Timebox getComponent() {
return (Timebox) component;
}
@Override
public boolean isReadWrite() {
return !getComponent().isReadonly();
}
@Override
public void setReadWrite(boolean readWrite) {
getComponent().setReadonly(!readWrite);
}
public String[] getEvents()
{
return LISTENER_EVENTS;
}
}

View File

@ -105,7 +105,10 @@ public class WebEditorFactory
/** Date */ /** Date */
else if (DisplayType.isDate(displayType)) else if (DisplayType.isDate(displayType))
{ {
editor = new WDateEditor(gridField); if (displayType == DisplayType.Time)
editor = new WTimeEditor(gridField);
else
editor = new WDateEditor(gridField);
} }
/** Button */ /** Button */

View File

@ -952,11 +952,10 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
if (dialog.isValid()) { if (dialog.isValid()) {
dialog.setPosition("center"); dialog.setPosition("center");
try { try {
dialog.setPage(this.getComponent().getPage());
dialog.doModal(); dialog.doModal();
} }
catch (InterruptedException e) { catch (InterruptedException e) {
e.printStackTrace();
} }
} }
} }
@ -1337,31 +1336,24 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
if (m_uiLocked) return; if (m_uiLocked) return;
m_uiLocked = true; m_uiLocked = true;
boolean notPrint = pi != null
&& pi.getAD_Process_ID() != curTab.getAD_Process_ID() if (Executions.getCurrent() != null)
&& pi.isReportingProcess() == false; Clients.showBusy(null, true);
// else
// Process Result
if (notPrint) // refresh if not print
{ {
if (Executions.getCurrent() != null) try {
Clients.showBusy("Processing...", true); //get full control of desktop
else Executions.activate(getComponent().getDesktop());
{ try {
try { Clients.showBusy(null, true);
//get full control of desktop } catch(Error ex){
Executions.activate(getComponent().getDesktop()); throw ex;
try { } finally{
Clients.showBusy("Processing...", true); //release full control of desktop
} catch(Error ex){ Executions.deactivate(getComponent().getDesktop());
throw ex; }
} finally{ } catch (Exception e) {
//release full control of desktop logger.log(Level.WARNING, "Failed to lock UI.", e);
Executions.deactivate(getComponent().getDesktop());
}
} catch (Exception e) {
logger.log(Level.WARNING, "Failed to lock UI.", e);
}
} }
} }
} }

View File

@ -63,7 +63,7 @@ public class SessionContextListener implements ExecutionInit,
if (parent == null) if (parent == null)
{ {
exec.removeAttribute(SESSION_CTX); exec.removeAttribute(SESSION_CTX);
ServerContext.dispose(); // ServerContext.dispose();
} }
} }

View File

@ -239,7 +239,7 @@ public class WAssignmentDialog extends Window implements EventListener
confirmPanel.getButton("Cancel").setVisible(readWrite); confirmPanel.getButton("Cancel").setVisible(readWrite);
fResource.setEnabled(readWrite); fResource.setEnabled(readWrite);
fDateFrom.setReadonly(!readWrite); fDateFrom.setReadonly(!readWrite);
fQty.setReadonly(!readWrite); fQty.setEnabled(readWrite);
m_setting = false; m_setting = false;
} // dynInit } // dynInit
@ -265,7 +265,7 @@ public class WAssignmentDialog extends Window implements EventListener
Calendar date = new GregorianCalendar(); Calendar date = new GregorianCalendar();
getDateAndTimeFrom(date); getDateAndTimeFrom(date);
Timestamp assignDateFrom = new Timestamp(date.getTimeInMillis()); Timestamp assignDateFrom = new Timestamp(date.getTimeInMillis());
BigDecimal qty = new BigDecimal(fQty.getValue()); BigDecimal qty = fQty.getValue();
KeyNamePair uom = (KeyNamePair)m_lookup.get(fResource.getSelectedItem()); KeyNamePair uom = (KeyNamePair)m_lookup.get(fResource.getSelectedItem());
int minutes = MUOMConversion.convertToMinutes(Env.getCtx(), uom.getKey(), qty); int minutes = MUOMConversion.convertToMinutes(Env.getCtx(), uom.getKey(), qty);
Timestamp assignDateTo = TimeUtil.addMinutess(assignDateFrom, minutes); Timestamp assignDateTo = TimeUtil.addMinutess(assignDateFrom, minutes);
@ -339,8 +339,8 @@ public class WAssignmentDialog extends Window implements EventListener
Timestamp assignDateFrom = new Timestamp(date.getTimeInMillis()); Timestamp assignDateFrom = new Timestamp(date.getTimeInMillis());
if (assignDateFrom != null) if (assignDateFrom != null)
m_mAssignment.setAssignDateFrom (assignDateFrom); m_mAssignment.setAssignDateFrom (assignDateFrom);
if (fQty.getValue() != null && fQty.getValue().trim().length() > 0) { if (fQty.getValue() != null) {
BigDecimal qty = new BigDecimal(fQty.getValue()); BigDecimal qty = fQty.getValue();
m_mAssignment.setQty(qty); m_mAssignment.setQty(qty);
} }
m_mAssignment.setName((String)fName.getValue()); m_mAssignment.setName((String)fName.getValue());

View File

@ -486,7 +486,7 @@ public class WPAttributeDialog extends Window implements EventListener
editor.setValue(Env.ZERO); editor.setValue(Env.ZERO);
row.appendChild(editor); row.appendChild(editor);
if (readOnly) if (readOnly)
editor.setReadonly(true); editor.setEnabled(false);
else else
m_editors.add (editor); m_editors.add (editor);
} }
@ -773,7 +773,7 @@ public class WPAttributeDialog extends Window implements EventListener
else if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attributes[i].getAttributeValueType())) else if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attributes[i].getAttributeValueType()))
{ {
NumberBox editor = (NumberBox)m_editors.get(i); NumberBox editor = (NumberBox)m_editors.get(i);
BigDecimal value = new BigDecimal(editor.getValue()); BigDecimal value = editor.getValue();
log.fine(attributes[i].getName() + "=" + value); log.fine(attributes[i].getName() + "=" + value);
if (attributes[i].isMandatory() && value == null) if (attributes[i].isMandatory() && value == null)
mandatory += " - " + attributes[i].getName(); mandatory += " - " + attributes[i].getName();

View File

@ -34,7 +34,7 @@ public class ZkReportViewerProvider implements ReportViewerProvider {
viewer.setClosable(true); viewer.setClosable(true);
viewer.setWidth("95%"); viewer.setWidth("95%");
SessionManager.getAppDesktop().showWindowInTabPanel(viewer); viewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
// AEnv.showWindow(viewer); SessionManager.getAppDesktop().showWindow(viewer);
} }
} }