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);
}
public void showWindowInTabPanel(Window window)
{
Tabpanel tabPanel = new Tabpanel();
window.setParent(tabPanel);
String title = window.getTitle();
window.setTitle(null);
windowContainer.addWindow(tabPanel, title, true);
}
/**
* @param event
*/
public void onEvent(Event event)
{
Component comp = event.getTarget();
@ -720,50 +714,97 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
if(menu.getAction().equals(MMenu.ACTION_Window))
{
ADWindow adWindow = new ADWindow(Env.getCtx(), menu.getAD_Window_ID());
DesktopTabpanel tabPanel = new DesktopTabpanel();
adWindow.createPart(tabPanel);
windowContainer.addWindow(tabPanel, adWindow.getTitle(), true);
openWindow(menu.getAD_Window_ID());
}
else if(menu.getAction().equals(MMenu.ACTION_Process) ||
menu.getAction().equals(MMenu.ACTION_Report))
{
ProcessDialog pd = new ProcessDialog (menu.getAD_Process_ID(), menu.isSOTrx());
if (pd.isValid()) {
pd.setPage(page);
pd.setClosable(true);
pd.setWidth("500px");
pd.doHighlighted();
}
openProcessDialog(menu.getAD_Process_ID(), menu.isSOTrx());
}
else if(menu.getAction().equals(MMenu.ACTION_Form))
{
ADForm form = ADForm.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);
openForm(menu.getAD_Form_ID());
}
else
{
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)
{
showURL(url, url, closeable);
}
/**
*
* @param url
* @param title
* @param closeable
*/
public void showURL(String url, String title, boolean closeable)
{
Iframe iframe = new Iframe(url);
addWin(iframe, title, closeable);
}
/**
* @param webDoc
* @param title
* @param closeable
*/
public void showURL(WebDoc webDoc, String title, boolean closeable)
{
Iframe iframe = new Iframe();
@ -774,6 +815,12 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
addWin(iframe, title, closeable);
}
/**
*
* @param fr
* @param title
* @param closeable
*/
private void addWin(Iframe fr, String title, boolean closeable)
{
fr.setWidth("100%");
@ -791,7 +838,10 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
windowContainer.addWindow(tabPanel, title, closeable);
}
/**
* @param AD_Window_ID
* @param query
*/
public void showZoomWindow(int AD_Window_ID, MQuery 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);
}
/**
* @param win
*/
public void showWindow(Window win)
{
String pos = win.getPosition();
this.showWindow(win, pos);
}
/**
* @param win
* @param pos
*/
public void showWindow(Window win, String pos)
{
win.setPage(page);
@ -819,31 +876,33 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
mode = objMode.toString();
}
if ("modal".equals(mode))
if (Window.MODE_MODAL.equals(mode))
{
showModal(win);
}
else if ("popup".equals(mode))
else if (Window.MODE_POPUP.equals(mode))
{
showPopup(win, pos);
}
else if ("overlapped".equals(mode))
else if (Window.MODE_OVERLAPPED.equals(mode))
{
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);
}
// win.setVisible(true);
}
}
public void showModal(Window win)
/**
*
* @param win
*/
private void showModal(Window win)
{
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)
win.setPosition("center");
@ -866,7 +930,12 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
win.doPopup();
}
public void showOverlapped(Window win, String position)
/**
*
* @param win
* @param position
*/
private void showOverlapped(Window win, String position)
{
if (position == null)
win.setPosition("center");
@ -876,7 +945,12 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
win.doOverlapped();
}
public void showHighlighted(Window win, String position)
/**
*
* @param win
* @param position
*/
private void showHighlighted(Window win, String position)
{
if (position == null)
win.setPosition("center");
@ -886,36 +960,56 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
win.doHighlighted();
}
public void showEmbedded(Window win, String position)
/**
*
* @param window
*/
private void showEmbedded(Window window)
{
if (position == null)
win.setPosition("center");
else
win.setPosition(position);
win.doEmbedded();
Tabpanel tabPanel = new Tabpanel();
window.setParent(tabPanel);
String title = window.getTitle();
window.setTitle(null);
windowContainer.addWindow(tabPanel, title, true);
}
/**
* @return clientInfo
*/
public ClientInfo getClientInfo() {
return clientInfo;
}
/**
*
* @param clientInfo
*/
public void setClientInfo(ClientInfo clientInfo) {
this.clientInfo = clientInfo;
}
/**
* @param win
*/
public int registerWindow(Object win) {
int retValue = windows.size();
windows.add(win);
return retValue;
}
/**
* @param WindowNo
*/
public void unregisterWindow(int WindowNo) {
if (WindowNo < windows.size())
windows.set(WindowNo, null);
}
/**
*
* @param WindowNo
* @return Object
*/
public Object findWindow(int WindowNo) {
if (WindowNo < windows.size())
return windows.get(WindowNo);
@ -923,11 +1017,18 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
return null;
}
/**
* Close active tab
*/
public void removeWindow()
{
windowContainer.removeWindow();
}
/**
*
* @param page
*/
public void setPage(Page page) {
if (this.page != 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() {
return layout;
}

View File

@ -1,30 +1,98 @@
package org.adempiere.webui;
import org.adempiere.webui.apps.ProcessDialog;
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.util.WebDoc;
public interface IDesktop {
/**
*
* @return ClientInfo
*/
public ClientInfo getClientInfo();
/**
*
* @param nodeId
*/
public void onMenuSelected(int nodeId);
/**
*
* @param window
* @return windowNo
*/
public int registerWindow(Object window);
/**
* close active window
*/
public void removeWindow();
/**
*
* @param url
* @param closeable
*/
public void showURL(String url, boolean closeable);
/**
*
* @param doc
* @param string
* @param closeable
*/
public void showURL(WebDoc doc, String string, boolean closeable);
/**
*
* @param win
*/
public void showWindow(Window win);
/**
*
* @param win
* @param position
*/
public void showWindow(Window win, String position);
/**
*
* @param window_ID
* @param query
*/
public void showZoomWindow(int window_ID, MQuery query);
/**
*
* @param 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
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;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InvalidClassException;
import java.io.NotSerializableException;
import java.net.URI;
@ -26,6 +30,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Enumeration;
import java.util.List;
import java.util.logging.Level;
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.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
*
@ -735,4 +747,36 @@ public final class AEnv
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

View File

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

View File

@ -18,13 +18,13 @@ package org.adempiere.webui.apps.form;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.math.*;
import java.sql.*;
import java.util.*;
import java.util.logging.*;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.DesktopTabpanel;
import org.adempiere.webui.component.Label;
@ -68,12 +68,6 @@ import org.zkoss.zul.Div;
import org.zkoss.zul.Html;
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
*
@ -706,26 +700,7 @@ public class WInOutGen extends ADForm implements EventListener, ValueChangeListe
if (pdfList.size() > 1) {
try {
File outFile = File.createTempFile("WInOutGen", ".pdf");
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.mergePdf(pdfList, outFile);
Clients.showBusy(null, false);
Window win = new SimplePDFViewer(this.getFormName(), new FileInputStream(outFile));
@ -745,7 +720,6 @@ public class WInOutGen extends ADForm implements EventListener, ValueChangeListe
}
}
/**************************************************************************
* Lock User Interface.
* 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.FileInputStream;
import java.io.FileOutputStream;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -29,6 +28,7 @@ import java.util.List;
import java.util.logging.Level;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.DesktopTabpanel;
import org.adempiere.webui.component.Label;
@ -86,11 +86,6 @@ import org.zkoss.zul.Div;
import org.zkoss.zul.Html;
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
@ -705,26 +700,7 @@ public class WInvoiceGen extends ADForm
if (pdfList.size() > 1) {
try {
File outFile = File.createTempFile("WInvoiceGen", ".pdf");
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.mergePdf(pdfList, outFile);
Clients.showBusy(null, false);
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 dateFromLabel = new Label();
private Label dateToLabel = new Label();
private WDateEditor dateFrom = new WDateEditor("DateFrom", false, false, true, DisplayType.Date, "DateFrom");
private WDateEditor dateTo = new WDateEditor("DateTo", false, false, true, DisplayType.Date, "DateTo");
private WDateEditor dateFrom = new WDateEditor("DateFrom", false, false, true, "DateFrom");
private WDateEditor dateTo = new WDateEditor("DateTo", false, false, true, "DateTo");
private Button bSearch = new Button();
private Panel southPanel = new Panel();
private Grid southLayout = GridFactory.newGridLayout();

View File

@ -101,7 +101,7 @@ public class WPayment extends Window
m_mTab = mTab;
try
{
bDateField = new WDateEditor("DateAcct", false, false, true, DisplayType.Date, "DateAcct");
bDateField = new WDateEditor("DateAcct", false, false, true, "DateAcct");
zkInit();
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);
mtypeField = new WTableDirEditor("MovementType", false, false, true, mtypeLookup);
// Dates
dateFField = new WDateEditor("DateFrom", false, false, true, DisplayType.Date, Msg.getMsg(Env.getCtx(), "DateFrom"));
dateTField = new WDateEditor("DateTo", false, false, true, DisplayType.Date, Msg.getMsg(Env.getCtx(), "DateTo"));
dateFField = new WDateEditor("DateFrom", false, false, true, Msg.getMsg(Env.getCtx(), "DateFrom"));
dateTField = new WDateEditor("DateTo", false, false, true, Msg.getMsg(Env.getCtx(), "DateTo"));
//
confirmPanel.addActionListener(this);
statusBar.setStatusLine("");

View File

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

View File

@ -17,12 +17,14 @@
package org.adempiere.webui.component;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.text.ParseException;
import org.zkoss.zul.Bandpopup;
import org.zkoss.zul.Button;
import org.adempiere.webui.apps.AEnv;
import org.zkoss.zul.Decimalbox;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.Popup;
import org.zkoss.zul.Vbox;
/**
@ -31,7 +33,7 @@ import org.zkoss.zul.Vbox;
* @date Mar 11, 2007
* @version $Revision: 0.10 $
*/
public class NumberBox extends Bandbox
public class NumberBox extends Panel
{
private static final long serialVersionUID = 1L;
@ -41,6 +43,9 @@ public class NumberBox extends Bandbox
NumberFormat format = null;
private Decimalbox decimalBox = null;
private Button btn;
public NumberBox(boolean integral)
{
super();
@ -50,10 +55,25 @@ public class NumberBox extends Bandbox
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.getId() + "'," + integral + ", event);");
this.appendChild(getBandPopup());
decimalBox.getId() + "'," + integral + ", event);");
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)
@ -61,70 +81,64 @@ public class NumberBox extends Bandbox
this.format = format;
}
public void setValue(Number value)
public void setValue(Object value)
{
if (format != null)
{
super.setValue(format.format(value));
}
if (value == null)
decimalBox.setValue(null);
else if (value instanceof BigDecimal)
decimalBox.setValue((BigDecimal) value);
else if (value instanceof Number)
decimalBox.setValue(new BigDecimal(((Number)value).doubleValue()));
else
{
super.setValue(value.toString());
}
decimalBox.setValue(new BigDecimal(value.toString()));
}
public void setRawValue(Object value)
public BigDecimal getValue()
{
super.setRawValue(value);
return decimalBox.getValue();
}
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)
{
String formattedValue = "";
Number numberValue = null;
if (format != null)
{
try
{
numberValue = format.parse(value);
formattedValue = format.format(numberValue);
numberValue = format.parse(value);
setValue(numberValue);
}
catch (ParseException e)
{
formattedValue = value;
}
}
else
{
formattedValue = value;
}
super.setValue(formattedValue);
decimalBox.setValue(new BigDecimal(value));
}
}
/*
public void setReadonly(boolean readonly)
private Popup getCalculatorPopup()
{
// Due to bug in bandbox - once set readonly, setting to not readonly
// does not work
super.setDisabled(readonly);
}*/
private Bandpopup getBandPopup()
{
Bandpopup bandPopup = new Bandpopup();
Popup popup = new Popup();
Vbox vbox = new Vbox();
txtCalc = new Textbox();
txtCalc.setAction("onKeyPress : return calc.validate('" +
this.getId() + "!real','" + txtCalc.getId()
decimalBox.getId() + "','" + txtCalc.getId()
+ "'," + integral + ", event);");
txtCalc.setMaxlength(250);
txtCalc.setCols(30);
@ -252,7 +266,7 @@ public class NumberBox extends Bandbox
Button btnEqual = new Button();
btnEqual.setWidth("30px");
btnEqual.setLabel("=");
btnEqual.setAction("onClick : calc.evaluate('" + this.getId() + "!real','"
btnEqual.setAction("onClick : calc.evaluate('" + decimalBox.getId() + "','"
+ txtCalcId + "')");
Button btnAdd = new Button();
@ -271,7 +285,30 @@ public class NumberBox extends Bandbox
vbox.appendChild(row3);
vbox.appendChild(row4);
bandPopup.appendChild(vbox);
return bandPopup;
popup.appendChild(vbox);
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.setValue((BigDecimal)field);
numberbox.setWidth("100px");
numberbox.setButtonVisible(true);
numberbox.setReadonly(false);
numberbox.setEnabled(true);
numberbox.setStyle("text-align:right; "
+ listcell.getStyle());
numberbox.addEventListener(Events.ON_CHANGE, this);
@ -578,7 +577,7 @@ public class WListItemRenderer implements ListitemRenderer, EventListener, Listi
}
else if (source instanceof NumberBox)
{
value = new BigDecimal(((NumberBox)source).getValue());
value = ((NumberBox)source).getValue();
}
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_HIGHLIGHTED = "highlighted";
public static final String MODE_KEY = "mode";
public Window()
{
super();

View File

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

View File

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

View File

@ -331,7 +331,7 @@ ContextMenuListener, IZoomableEditor
@Override
public void dynamicDisplay()
{
if (isReadWrite() && (!lookup.isValidated() || !lookup.isLoaded()))
if (isReadWrite() && (lookup != null) && (!lookup.isValidated() || !lookup.isLoaded()))
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 */
else if (DisplayType.isDate(displayType))
{
editor = new WDateEditor(gridField);
if (displayType == DisplayType.Time)
editor = new WTimeEditor(gridField);
else
editor = new WDateEditor(gridField);
}
/** Button */

View File

@ -952,11 +952,10 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
if (dialog.isValid()) {
dialog.setPosition("center");
try {
dialog.setPage(this.getComponent().getPage());
dialog.doModal();
}
catch (InterruptedException e) {
e.printStackTrace();
}
}
}
@ -1337,31 +1336,24 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
if (m_uiLocked) return;
m_uiLocked = true;
boolean notPrint = pi != null
&& pi.getAD_Process_ID() != curTab.getAD_Process_ID()
&& pi.isReportingProcess() == false;
//
// Process Result
if (notPrint) // refresh if not print
if (Executions.getCurrent() != null)
Clients.showBusy(null, true);
else
{
if (Executions.getCurrent() != null)
Clients.showBusy("Processing...", true);
else
{
try {
//get full control of desktop
Executions.activate(getComponent().getDesktop());
try {
Clients.showBusy("Processing...", true);
} catch(Error ex){
throw ex;
} finally{
//release full control of desktop
Executions.deactivate(getComponent().getDesktop());
}
} catch (Exception e) {
logger.log(Level.WARNING, "Failed to lock UI.", e);
}
try {
//get full control of desktop
Executions.activate(getComponent().getDesktop());
try {
Clients.showBusy(null, true);
} catch(Error ex){
throw ex;
} finally{
//release full control of desktop
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)
{
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);
fResource.setEnabled(readWrite);
fDateFrom.setReadonly(!readWrite);
fQty.setReadonly(!readWrite);
fQty.setEnabled(readWrite);
m_setting = false;
} // dynInit
@ -265,7 +265,7 @@ public class WAssignmentDialog extends Window implements EventListener
Calendar date = new GregorianCalendar();
getDateAndTimeFrom(date);
Timestamp assignDateFrom = new Timestamp(date.getTimeInMillis());
BigDecimal qty = new BigDecimal(fQty.getValue());
BigDecimal qty = fQty.getValue();
KeyNamePair uom = (KeyNamePair)m_lookup.get(fResource.getSelectedItem());
int minutes = MUOMConversion.convertToMinutes(Env.getCtx(), uom.getKey(), qty);
Timestamp assignDateTo = TimeUtil.addMinutess(assignDateFrom, minutes);
@ -339,8 +339,8 @@ public class WAssignmentDialog extends Window implements EventListener
Timestamp assignDateFrom = new Timestamp(date.getTimeInMillis());
if (assignDateFrom != null)
m_mAssignment.setAssignDateFrom (assignDateFrom);
if (fQty.getValue() != null && fQty.getValue().trim().length() > 0) {
BigDecimal qty = new BigDecimal(fQty.getValue());
if (fQty.getValue() != null) {
BigDecimal qty = fQty.getValue();
m_mAssignment.setQty(qty);
}
m_mAssignment.setName((String)fName.getValue());

View File

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

View File

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