diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Bandbox.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Bandbox.java index 525208f93e..e1fede0889 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Bandbox.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Bandbox.java @@ -31,4 +31,9 @@ public class Bandbox extends org.zkoss.zul.Bandbox { this.setDisabled(!enabled); } + + public boolean isEnabled() + { + return !isDisabled(); + } } \ No newline at end of file diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Checkbox.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Checkbox.java index 10f3eea4f1..d0bc364381 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Checkbox.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Checkbox.java @@ -31,4 +31,9 @@ public class Checkbox extends org.zkoss.zul.Checkbox { this.setDisabled(!enabled); } + + public boolean isEnabled() + { + return !this.isDisabled(); + } } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Datebox.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Datebox.java index 12b0d4e39f..5765bd3e3c 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Datebox.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Datebox.java @@ -31,4 +31,9 @@ public class Datebox extends org.zkoss.zul.Datebox { this.setReadonly(!enabled); } + + public boolean isEnabled() + { + return !isReadonly(); + } } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/FilenameBox.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/FilenameBox.java index 57e42eae8a..95be1a9796 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/FilenameBox.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/FilenameBox.java @@ -74,6 +74,11 @@ public class FilenameBox extends Hbox button.setEnabled(enabled); } + public boolean isEnabled() + { + return !textbox.isReadonly(); + } + public void setButtonEnabled(boolean enabled) { button.setEnabled(enabled); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Label.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Label.java index 836fdf2e3b..877874fad6 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Label.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Label.java @@ -17,6 +17,8 @@ package org.adempiere.webui.component; +import org.zkoss.zk.ui.Component; + /** * * @author Ashley G Ramdass @@ -26,6 +28,10 @@ package org.adempiere.webui.component; public class Label extends org.zkoss.zul.Label { private static final long serialVersionUID = 1L; + + private Component decorator; + + private boolean mandatory; public Label() { @@ -36,4 +42,44 @@ public class Label extends org.zkoss.zul.Label { super(value); } + + public boolean isMandatory() { + return mandatory; + } + + public void setMandatory(boolean mandatory) { + this.mandatory = mandatory; + setupMandatoryDecorator(); + } + + public Component getDecorator() { + return decorator; + } + + @Override + public void setValue(String value) { + super.setValue(value); + setupMandatoryDecorator(); + } + + @Override + public boolean setVisible(boolean visible) { + if (decorator != null) { + if (visible) + decorator.setVisible(getValue() != null && getValue().trim().length() > 0 && mandatory); + else + decorator.setVisible(false); + } + return super.setVisible(visible); + } + + private void setupMandatoryDecorator() { + String value = getValue(); + if (value != null && (value.trim().length() > 0) && mandatory) { + if (decorator == null) + decorator = new Label("*"); + ((Label)decorator).setStyle("text-decoration: none; font-size: xx-small; vertical-align: top;"); + } else if (decorator != null) + decorator.setVisible(false); + } } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Searchbox.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Searchbox.java index c4b97083a7..e0bac7a3e4 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Searchbox.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Searchbox.java @@ -97,14 +97,4 @@ public class Searchbox extends Hbox { m_propertyChangeListeners.addPropertyChangeListener(l); } - - /** - * Set whether the SearchBox represents a mandatory field. - * - * @param mandatory whether the search box must be filled - */ - public void setMandatory(boolean mandatory) - { - txt.setMandatory(mandatory); - } } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Textbox.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Textbox.java index f3c08c471e..65d32c4112 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Textbox.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Textbox.java @@ -18,6 +18,8 @@ package org.adempiere.webui.component; import org.zkoss.zk.ui.WrongValueException; +import org.zkoss.zul.Constraint; +import org.zkoss.zul.SimpleConstraint; /** * @@ -44,19 +46,4 @@ public class Textbox extends org.zkoss.zul.Textbox { this.setDisabled(!enabled); } - - /** - * Set whether the textbox represents a mandatory field. - * - * @param mandatory whether the texbox must be filled - */ - public void setMandatory(boolean mandatory) - { -/* if (mandatory) - { - ZkCssHelper.setStyleBackgroundColor(this, AdempierePLAF.getFieldBackground_Mandatory()); - } -*/ - this.setStyle("background-color:#e1d6d6"); - } } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Urlbox.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Urlbox.java index bee7c788c8..3b9765abca 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Urlbox.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Urlbox.java @@ -74,6 +74,11 @@ public class Urlbox extends Hbox btnUrl.setEnabled(enabled); } + public boolean isEnabled() + { + return !txtUrl.isReadonly(); + } + public void setButtonEnabled(boolean enabled) { btnUrl.setEnabled(enabled); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/IZoomableEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/IZoomableEditor.java index eede83a846..61a32cf099 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/IZoomableEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/IZoomableEditor.java @@ -1,5 +1,22 @@ +/****************************************************************************** + * Copyright (C) 2008 Low Heng Sin 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. * + *****************************************************************************/ package org.adempiere.webui.editor; +/** + * + * @author Low Heng Sin + * + */ public interface IZoomableEditor { public void actionZoom(); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WBinaryEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WBinaryEditor.java index c5301dc820..e65ddc83cf 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WBinaryEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WBinaryEditor.java @@ -9,9 +9,6 @@ * 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 * - * Posterita Ltd., 3, Draper Avenue, Quatre Bornes, Mauritius * - * or via info@posterita.org or http://www.posterita.org/ * *****************************************************************************/ package org.adempiere.webui.editor; @@ -83,6 +80,16 @@ public class WBinaryEditor extends WEditor } @Override + public boolean isReadWrite() { + return getComponent().isEnabled(); + } + + @Override + public void setReadWrite(boolean readWrite) { + getComponent().setEnabled(readWrite); + } + + @Override public void setValue(Object value) { log.config("=" + value); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WButtonEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WButtonEditor.java index ca7754365a..a4c538ffbc 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WButtonEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WButtonEditor.java @@ -57,8 +57,6 @@ public class WButtonEditor extends WEditor logger = CLogger.getCLogger(WButtonEditor.class); } - private Button button; - private String m_text; private boolean m_mandatory; private Object m_value; @@ -77,7 +75,6 @@ public class WButtonEditor extends WEditor public WButtonEditor(GridField gridField) { super(new Button(), gridField); - button = (Button)super.component; m_text = gridField.getHeader(); AD_Process_ID = gridField.getAD_Process_ID(); gridfield = gridField; @@ -101,37 +98,37 @@ public class WButtonEditor extends WEditor private void init() { label.setValue(" "); - button.setLabel(gridField.getHeader()); - button.setTooltiptext(gridField.getDescription()); - button.addEventListener(Events.ON_CLICK, this); + getComponent().setLabel(gridField.getHeader()); + getComponent().setTooltiptext(gridField.getDescription()); + getComponent().addEventListener(Events.ON_CLICK, this); String columnName = super.getColumnName(); if (columnName.equals("PaymentRule")) { readReference(195); // this.setForeground(Color.blue); - button.setImage("/images/Payment16.gif"); // 29*14 + getComponent().setImage("/images/Payment16.gif"); // 29*14 } else if (columnName.equals("DocAction")) { readReference(135); // this.setForeground(Color.blue); - button.setImage("/images/Process16.gif"); // 16*16 + getComponent().setImage("/images/Process16.gif"); // 16*16 } else if (columnName.equals("CreateFrom")) { - button.setImage("/images/Copy16.gif"); // 16*16 + getComponent().setImage("/images/Copy16.gif"); // 16*16 } else if (columnName.equals("Record_ID")) { - button.setImage("/images/Zoom16.gif"); // 16*16 - button.setLabel(Msg.getMsg(Env.getCtx(), "ZoomDocument")); + getComponent().setImage("/images/Zoom16.gif"); // 16*16 + getComponent().setLabel(Msg.getMsg(Env.getCtx(), "ZoomDocument")); } else if (columnName.equals("Posted")) { readReference(234); // this.setForeground(Color.magenta); - button.setImage("/images/InfoAccount16.gif"); // 16*16 + getComponent().setImage("/images/InfoAccount16.gif"); // 16*16 } if (gridField.getColumnName().endsWith("_ID") && !gridField.getColumnName().equals("Record_ID")) @@ -193,10 +190,25 @@ public class WButtonEditor extends WEditor if (pp != null) text = pp.getName(); } - button.setLabel(text != null ? text : ""); + getComponent().setLabel(text != null ? text : ""); } - public HashMap getValues() + @Override + public Button getComponent() { + return (Button) component; + } + + @Override + public boolean isReadWrite() { + return getComponent().isEnabled(); + } + + @Override + public void setReadWrite(boolean readWrite) { + getComponent().setEnabled(readWrite); + } + + public HashMap getValues() { return m_values; } // getValues diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WDateEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WDateEditor.java index 1b9419ef94..7cc82b3b89 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WDateEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WDateEditor.java @@ -46,12 +46,9 @@ public class WDateEditor extends WEditor private Timestamp oldValue = new Timestamp(0); - private Datebox datebox; - public WDateEditor(GridField gridField) { super(new Datebox(), gridField); - datebox = (Datebox)super.component; } @@ -73,7 +70,6 @@ public class WDateEditor extends WEditor { super(new Datebox(), label, description, mandatory, readonly, updateable); - this.datebox = (Datebox)super.component; setColumnName("Date"); } @@ -84,7 +80,7 @@ public class WDateEditor extends WEditor public void onEvent(Event event) { - Date date = datebox.getValue(); + Date date = getComponent().getValue(); Timestamp newValue = null; if (date != null) @@ -129,7 +125,7 @@ public class WDateEditor extends WEditor } else if (value instanceof Timestamp) { - datebox.setValue((Timestamp)value); + getComponent().setValue((Timestamp)value); oldValue = (Timestamp)value; } else @@ -137,7 +133,23 @@ public class WDateEditor extends WEditor logger.log(Level.SEVERE, "New field value is not of type timestamp"); } } - + + @Override + public Datebox getComponent() { + return (Datebox) component; + } + + @Override + public boolean isReadWrite() { + return getComponent().isEnabled(); + } + + + @Override + public void setReadWrite(boolean readWrite) { + getComponent().setEnabled(readWrite); + } + public String[] getEvents() { return LISTENER_EVENTS; diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WEditor.java index 0c29a9549c..545c795c1b 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WEditor.java @@ -22,15 +22,7 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.ArrayList; -import org.adempiere.webui.component.Button; -import org.adempiere.webui.component.Checkbox; -import org.adempiere.webui.component.Datebox; -import org.adempiere.webui.component.EditorBox; import org.adempiere.webui.component.Label; -import org.adempiere.webui.component.Listbox; -import org.adempiere.webui.component.Locationbox; -import org.adempiere.webui.component.Searchbox; -import org.adempiere.webui.component.Urlbox; import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeListener; import org.compiere.model.GridField; @@ -38,7 +30,6 @@ import org.compiere.model.GridTab; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.HtmlBasedComponent; import org.zkoss.zk.ui.event.EventListener; -import org.zkoss.zul.impl.InputElement; /** * @@ -257,77 +248,9 @@ public abstract class WEditor implements EventListener, PropertyChangeListener return label; } - public void setReadWrite(boolean readWrite) - { - if (component instanceof Checkbox) - { - ((Checkbox)component).setEnabled(readWrite); - } - else if (component instanceof Button) - { - ((Button)component).setEnabled(readWrite); - } - else if (component instanceof Listbox) - { - ((Listbox)component).setEnabled(readWrite); - } - else if (component instanceof Datebox) - { - ((Datebox)component).setEnabled(readWrite); - } - else if (component instanceof Urlbox) - { - ((Urlbox)component).setEnabled(readWrite); - } - else if (component instanceof Searchbox) - { - ((Searchbox)component).setEnabled(readWrite); - } - else if (component instanceof Locationbox) - { - ((Locationbox)component).setEnabled(readWrite); - } - else if (component instanceof EditorBox) - { - ((EditorBox)component).setEnabled(readWrite); - } - else - { - ((InputElement)component).setReadonly(!readWrite); - } - } + public abstract void setReadWrite(boolean readWrite); - public boolean isReadWrite() - { - if (component instanceof Checkbox) - { - return ((Checkbox)component).isDisabled(); - } - else if (component instanceof Button) - { - return ((Button)component).isEnabled(); - } - else if (component instanceof Listbox) - { - return ((Listbox)component).isEnabled(); - } - else if (component instanceof Searchbox) - { - return ((Searchbox)component).isEnabled(); - } - else if (component instanceof Locationbox) - { - return ((Locationbox)component).isEnabled(); - } - else if (component instanceof EditorBox) - { - return ((EditorBox)component).isEnabled(); - } - else - { - return ((InputElement)component).isReadonly(); - } - } + public abstract boolean isReadWrite(); public void setVisible(boolean visible) { @@ -378,6 +301,8 @@ public abstract class WEditor implements EventListener, PropertyChangeListener public void setMandatory (boolean mandatory) { this.mandatory = mandatory; + if (label != null) + label.setMandatory(mandatory); } public boolean isMandatory() diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WFilenameEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WFilenameEditor.java index b9c137c3d2..d4c4e9185a 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WFilenameEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WFilenameEditor.java @@ -9,9 +9,6 @@ * 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 * - * Posterita Ltd., 3, Draper Avenue, Quatre Bornes, Mauritius * - * or via info@posterita.org or http://www.posterita.org/ * *****************************************************************************/ package org.adempiere.webui.editor; @@ -80,6 +77,16 @@ public class WFilenameEditor extends WEditor return getComponent().getText(); } + @Override + public boolean isReadWrite() { + return getComponent().isEnabled(); + } + + @Override + public void setReadWrite(boolean readWrite) { + getComponent().setEnabled(readWrite); + } + public void onEvent(Event event) { if (Events.ON_CHANGE.equals(event.getName())) diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WImageEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WImageEditor.java index 1e2cb21d53..43ecc19ca8 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WImageEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WImageEditor.java @@ -9,9 +9,6 @@ * 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 * - * Posterita Ltd., 3, Draper Avenue, Quatre Bornes, Mauritius * - * or via info@posterita.org or http://www.posterita.org/ * *****************************************************************************/ package org.adempiere.webui.editor; @@ -98,8 +95,18 @@ public class WImageEditor extends WEditor { m_mandatory = mandatory; } - + @Override + public boolean isReadWrite() { + return getComponent().isEnabled(); + } + + @Override + public void setReadWrite(boolean readWrite) { + getComponent().setEnabled(readWrite); + } + + @Override public void setValue(Object value) { int newValue = 0; diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WLocationEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WLocationEditor.java index 0fe9978401..458f13683d 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WLocationEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WLocationEditor.java @@ -44,7 +44,6 @@ public class WLocationEditor extends WEditor implements EventListener, PropertyC private static CLogger log = CLogger.getCLogger(WLocationEditor.class); private static final long serialVersionUID = 1L; - private Locationbox locationbox; private String m_columnName; private MLocationLookup m_Location; private MLocation m_value; @@ -64,14 +63,13 @@ public class WLocationEditor extends WEditor implements EventListener, PropertyC m_columnName = columnName; m_Location = mLocation; - locationbox = (Locationbox)super.component; - locationbox.setButtonImage("/images/Location10.gif"); + getComponent().setButtonImage("/images/Location10.gif"); } @Override public String getDisplay() { - return locationbox.getText(); + return getComponent().getText(); } @Override @@ -88,19 +86,34 @@ public class WLocationEditor extends WEditor implements EventListener, PropertyC if (value == null) { m_value = null; - locationbox.setText(null); + getComponent().setText(null); } else { m_value = m_Location.getLocation(value, null); if (m_value == null) - locationbox.setText("<" + value + ">"); + getComponent().setText("<" + value + ">"); else - locationbox.setText(m_value.toString()); + getComponent().setText(m_value.toString()); } } + + @Override + public Locationbox getComponent() { + return (Locationbox) component; + } - /** + @Override + public boolean isReadWrite() { + return getComponent().isEnabled(); + } + + @Override + public void setReadWrite(boolean readWrite) { + getComponent().setEnabled(readWrite); + } + + /** * Return Editor value * @return value */ diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WLocatorEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WLocatorEditor.java index 46a371c2ce..5f4cd3c9b1 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WLocatorEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WLocatorEditor.java @@ -53,7 +53,6 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh private String m_columnName; private MLocatorLookup m_mLocator; - private EditorBox editorbox; private MLocator m_value; private int m_WindowNo; @@ -85,8 +84,7 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh m_columnName = columnName; m_mLocator = mLocator; - editorbox = (EditorBox)super.component; - editorbox.setButtonImage("/images/Locator10.gif"); + getComponent().setButtonImage("/images/Locator10.gif"); setDefault_Locator_ID(); // set default locator, teo_sarca [ 1661546 ] } @@ -114,7 +112,7 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh } m_value = m_mLocator.getMLocator(value, null); - editorbox.setText(m_mLocator.getDisplay(value)); // loads value + getComponent().setText(m_mLocator.getDisplay(value)); // loads value // Data Binding if (fire) { @@ -137,6 +135,21 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh return m_value; } // getValue + @Override + public EditorBox getComponent() { + return (EditorBox) component; + } + + @Override + public boolean isReadWrite() { + return getComponent().isEnabled(); + } + + @Override + public void setReadWrite(boolean readWrite) { + getComponent().setEnabled(readWrite); + } + /** * Get M_Locator_ID * @return id @@ -157,7 +170,7 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh public String getDisplay() { - return editorbox.getText(); + return getComponent().getText(); } // getDisplay public void onEvent(Event event) throws Exception @@ -171,7 +184,7 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh // Text Entry ok - if (event.getTarget() == editorbox && actionText(only_Warehouse_ID, only_Product_ID)) + if (event.getTarget() == getComponent() && actionText(only_Warehouse_ID, only_Product_ID)) return; // Button - Start Dialog @@ -210,7 +223,7 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh private boolean actionText(int only_Warehouse_ID, int only_Product_ID) { - String text = editorbox.getText(); + String text = getComponent().getText(); log.fine(text); // Null diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java index 77417bce31..38fddb62f7 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java @@ -39,8 +39,6 @@ public class WNumberEditor extends WEditor public static final int MAX_DISPLAY_LENGTH = 20; - private NumberBox comp; - private String oldValue; private boolean mandatory = false; @@ -49,42 +47,55 @@ public class WNumberEditor extends WEditor { super(new NumberBox(gridField.getDisplayType() == DisplayType.Integer), gridField); - comp = (NumberBox)super.component; init(); } public WNumberEditor(GridField gridField, boolean integral) { super(new NumberBox(integral), gridField); - comp = (NumberBox)super.component; init(); } private void init() { - comp.setMaxlength(gridField.getFieldLength()); - comp.setCols(MAX_DISPLAY_LENGTH); - comp.setTooltiptext(gridField.getDescription()); + getComponent().setMaxlength(gridField.getFieldLength()); + getComponent().setCols(MAX_DISPLAY_LENGTH); + getComponent().setTooltiptext(gridField.getDescription()); } public void onEvent(Event event) { - String newValue = comp.getValue(); + String newValue = getComponent().getValue(); ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue); super.fireValueChange(changeEvent); oldValue = newValue; } - + @Override + public NumberBox getComponent() { + return (NumberBox) component; + } + + @Override + public boolean isReadWrite() { + return getComponent().isEnabled(); + } + + @Override + public void setReadWrite(boolean readWrite) { + getComponent().setEnabled(readWrite); + } + + @Override public String getDisplay() { - return comp.getValue(); + return getComponent().getValue(); } @Override public Object getValue() { - return comp.getValue(); + return getComponent().getValue(); } @Override @@ -104,11 +115,11 @@ public class WNumberEditor extends WEditor { if (value != null) { - comp.setValue(value.toString()); + getComponent().setValue(value.toString()); } else { - comp.setValue("0"); + getComponent().setValue("0"); } } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WPAttributeEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WPAttributeEditor.java index ca881171ca..ab63f67031 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WPAttributeEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WPAttributeEditor.java @@ -9,9 +9,6 @@ * 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 * - * Posterita Ltd., 3, Draper Avenue, Quatre Bornes, Mauritius * - * or via info@posterita.org or http://www.posterita.org/ * *****************************************************************************/ package org.adempiere.webui.editor; diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java index 85088f92c5..c3f81bd902 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java @@ -42,7 +42,6 @@ import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; import org.compiere.util.Msg; -import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Events; @@ -56,7 +55,6 @@ import org.zkoss.zk.ui.event.Events; public class WSearchEditor extends WEditor implements ContextMenuListener, ValueChangeListener, IZoomableEditor { private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_CHANGE}; - private Searchbox searchbox; private Lookup lookup; private String m_tableName = null; private String m_keyColumnName = null; @@ -78,23 +76,23 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value init(); } - /** - * Set the underlying component. - * - * @param comp the component to use - */ - protected void setComponent(Component comp) - { - // TODO remove this duplication of components. - // Only need component from WEditor (superclass) - // and can then override get component and cast it to Searchbox - if (!(comp instanceof Searchbox)) - { - throw new IllegalArgumentException("A search editor must contain a Searchbox"); - } - super.setComponent(comp); - this.searchbox = (Searchbox)super.component; - } + + @Override + public Searchbox getComponent() { + return (Searchbox) super.getComponent(); + } + + @Override + public boolean isReadWrite() { + return getComponent().isEnabled(); + } + + + @Override + public void setReadWrite(boolean readWrite) { + getComponent().setEnabled(readWrite); + } + /** * Constructor for use if a grid field is unavailable @@ -131,19 +129,19 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value columnName = this.getColumnName(); popupMenu = new WEditorPopupMenu(true, true, true, true); - (searchbox.getTextBox()).setContext(popupMenu.getId()); + (getComponent().getTextBox()).setContext(popupMenu.getId()); if (columnName.equals("C_BPartner_ID")) { - searchbox.setButtonImage("/images/BPartner10.gif"); + getComponent().setButtonImage("/images/BPartner10.gif"); } else if (columnName.equals("M_Product_ID")) { - searchbox.setButtonImage("/images/Product10.gif"); + getComponent().setButtonImage("/images/Product10.gif"); } else { - searchbox.setButtonImage("/images/PickOpen10.gif"); + getComponent().setButtonImage("/images/PickOpen10.gif"); } return; @@ -167,25 +165,14 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value text = text.substring(1); } - searchbox.setText(text); + getComponent().setText(text); } else { - searchbox.setText(""); + getComponent().setText(""); } } - /** - * Set whether the editor represents a mandatory field. - * - * @param mandatory whether the editor must be filled - */ - public void setMandatory(boolean mandatory) - { - searchbox.setMandatory(mandatory); - super.setMandatory(mandatory); - } - @Override public Object getValue() { @@ -195,14 +182,14 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value @Override public String getDisplay() { - return searchbox.getText(); + return getComponent().getText(); } public void onEvent(Event e) { if ("onChange".equals(e.getName())) { - actionText(searchbox.getText()); + actionText(getComponent().getText()); } else if ("onClick".equals(e.getName())) @@ -345,7 +332,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value log.fine(getColumnName() + " - Not Unique - " + finalSQL); //m_value = null; // force re-display - actionButton(searchbox.getText()); + actionButton(getComponent().getText()); return; } log.fine(getColumnName() + " - Unique ID=" + id); @@ -454,8 +441,8 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value Env.setContext(Env.getCtx(), lookup.getWindowNo(), Env.TAB_INFO, "M_Lookup_ID", "0"); // Replace Value with name if no value exists - if (queryValue.length() == 0 && searchbox.getText().length() > 0) - queryValue = "@" + searchbox.getText() + "@"; // Name indicator - otherwise Value + if (queryValue.length() == 0 && getComponent().getText().length() > 0) + queryValue = "@" + getComponent().getText() + "@"; // Name indicator - otherwise Value int M_Warehouse_ID = Env.getContextAsInt(Env.getCtx(), lookup.getWindowNo(), "M_Warehouse_ID"); int M_PriceList_ID = Env.getContextAsInt(Env.getCtx(), lookup.getWindowNo(), "M_PriceList_ID"); @@ -475,8 +462,8 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value else if (col.equals("C_BPartner_ID")) { // Replace Value with name if no value exists - if (queryValue.length() == 0 && searchbox.getText().length() > 0) - queryValue = searchbox.getText(); + if (queryValue.length() == 0 && getComponent().getText().length() > 0) + queryValue = getComponent().getText(); boolean isSOTrx = true; // default @@ -503,8 +490,8 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value if (m_tableName == null) // sets table name & key column getDirectAccessSQL("*"); - if (queryValue.length() == 0 && searchbox.getText().length() > 0) - queryValue = searchbox.getText(); + if (queryValue.length() == 0 && getComponent().getText().length() > 0) + queryValue = getComponent().getText(); boolean isSOTrx = true; // default diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WStringEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WStringEditor.java index 6a2ef66adb..bcd4e06029 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WStringEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WStringEditor.java @@ -54,8 +54,18 @@ public class WStringEditor extends WEditor implements ContextMenuListener public Textbox getComponent() { return (Textbox) component; } - - private void init() + + @Override + public boolean isReadWrite() { + return !getComponent().isReadonly(); + } + + @Override + public void setReadWrite(boolean readWrite) { + getComponent().setReadonly(!readWrite); + } + + private void init() { getComponent().setMaxlength(gridField.getFieldLength()); int displayLength = gridField.getDisplayLength(); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java index f50d57f1c5..5f506a9940 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java @@ -59,14 +59,12 @@ ContextMenuListener, IZoomableEditor } private Lookup lookup; - private Listbox listbox; private Object oldValue; private WEditorPopupMenu popupMenu; public WTableDirEditor(GridField gridField) { super(new Listbox(), gridField); - listbox = (Listbox)super.component; lookup = gridField.getLookup(); init(); } @@ -90,7 +88,6 @@ ContextMenuListener, IZoomableEditor throw new IllegalArgumentException("Lookup cannot be null"); } - this.listbox = (Listbox)super.component; this.lookup = lookup; super.setColumnName(lookup.getColumnName()); init(); @@ -98,11 +95,11 @@ ContextMenuListener, IZoomableEditor private void init() { - listbox.setRows(0); - listbox.setMultiple(false); - listbox.setMold("select"); - listbox.setWidth("200px"); - listbox.addPropertyChangeListener(this); + getComponent().setRows(0); + getComponent().setMultiple(false); + getComponent().setMold("select"); + getComponent().setWidth("200px"); + getComponent().addPropertyChangeListener(this); boolean zoom= false; if (lookup != null) @@ -119,7 +116,7 @@ ContextMenuListener, IZoomableEditor } popupMenu = new WEditorPopupMenu(zoom, true, true); - listbox.setContext(popupMenu.getId()); + getComponent().setContext(popupMenu.getId()); } @Override @@ -127,7 +124,7 @@ ContextMenuListener, IZoomableEditor { String display = null; - ListItem selItem = listbox.getSelectedItem(); + ListItem selItem = getComponent().getSelectedItem(); if (selItem != null) { display = selItem.getLabel(); @@ -139,7 +136,7 @@ ContextMenuListener, IZoomableEditor public Object getValue() { Object retVal = null; - ListItem selItem = listbox.getSelectedItem(); + ListItem selItem = getComponent().getSelectedItem(); if (selItem != null) { retVal = selItem.getValue(); @@ -151,9 +148,9 @@ ContextMenuListener, IZoomableEditor { if (value != null && (value instanceof Integer || value instanceof String)) { - listbox.setValue(value); + getComponent().setValue(value); - if (listbox.getSelectedIndex() == -1 && lookup != null) + if (getComponent().getSelectedIndex() == -1 && lookup != null) { lookup.refresh(); oldValue = value; @@ -162,16 +159,31 @@ ContextMenuListener, IZoomableEditor } else { - listbox.setValue(null); + getComponent().setValue(null); } oldValue = value; } - private void refreshList() + @Override + public Listbox getComponent() { + return (Listbox) component; + } + + @Override + public boolean isReadWrite() { + return getComponent().isEnabled(); + } + + @Override + public void setReadWrite(boolean readWrite) { + getComponent().setEnabled(readWrite); + } + + private void refreshList() { - if (listbox.getItemCount() > 0) - listbox.getItems().clear(); + if (getComponent().getItemCount() > 0) + getComponent().getItems().clear(); if (lookup != null) { @@ -183,17 +195,17 @@ ContextMenuListener, IZoomableEditor if (obj instanceof KeyNamePair) { KeyNamePair lookupKNPair = (KeyNamePair) obj; - listbox.appendItem(lookupKNPair.getName(), lookupKNPair.getKey()); + getComponent().appendItem(lookupKNPair.getName(), lookupKNPair.getKey()); } else if (obj instanceof ValueNamePair) { ValueNamePair lookupKNPair = (ValueNamePair) obj; - listbox.appendItem(lookupKNPair.getName(), lookupKNPair.getValue()); + getComponent().appendItem(lookupKNPair.getName(), lookupKNPair.getValue()); } } } - listbox.setValue(oldValue); + getComponent().setValue(oldValue); } public void onEvent(Event event) diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WUrlEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WUrlEditor.java index 0cdd1ca1fc..fa7a38b14f 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WUrlEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WUrlEditor.java @@ -31,13 +31,10 @@ public class WUrlEditor extends WEditor { private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_CHANGE}; - private Urlbox urlbox; - public WUrlEditor(GridField gridField) { super(new Urlbox(), gridField); - this.urlbox = (Urlbox)super.component; - urlbox.setButtonImage("/images/Online16.gif"); + getComponent().setButtonImage("/images/Online16.gif"); } @@ -46,36 +43,54 @@ public class WUrlEditor extends WEditor { if (value == null) { - urlbox.setText(""); + getComponent().setText(""); } else { - urlbox.setText(String.valueOf(value)); + getComponent().setText(String.valueOf(value)); } } @Override public Object getValue() { - return urlbox.getText(); + return getComponent().getText(); } @Override public String getDisplay() { - return urlbox.getText(); + return getComponent().getText(); } + + @Override + public Urlbox getComponent() { + return (Urlbox) component; + } + + + @Override + public boolean isReadWrite() { + return getComponent().isEnabled(); + } + + + @Override + public void setReadWrite(boolean readWrite) { + getComponent().setEnabled(readWrite); + } + public void onEvent(Event event) { if (Events.ON_CHANGE.equals(event.getName())) { - ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), urlbox.getText(), urlbox.getText()); + ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), getComponent().getText(), getComponent().getText()); fireValueChange(changeEvent); } else if (Events.ON_CLICK.equals(event.getName())) { - String urlString =urlbox.getText(); + String urlString =getComponent().getText(); String message = null; if (urlString != null && urlString.length() > 0) { diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WYesNoEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WYesNoEditor.java index e3aa462e04..17f624ef90 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WYesNoEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WYesNoEditor.java @@ -45,13 +45,11 @@ public class WYesNoEditor extends WEditor logger = CLogger.getCLogger(WYesNoEditor.class); } - private Checkbox checkbox; private boolean oldValue = false; public WYesNoEditor(GridField gridField) { super(new Checkbox(), gridField); - checkbox = (Checkbox)super.component; init(); } @@ -59,7 +57,7 @@ public class WYesNoEditor extends WEditor { super.label.setValue(""); super.label.setTooltiptext(""); - checkbox.setLabel(gridField.getHeader()); + getComponent().setLabel(gridField.getHeader()); } public void onEvent(Event event) @@ -81,14 +79,14 @@ public class WYesNoEditor extends WEditor @Override public String getDisplay() { - String display = checkbox.isChecked() ? "Y" : "N"; + String display = getComponent().isChecked() ? "Y" : "N"; return Msg.translate(Env.getCtx(), display); } @Override public Object getValue() { - return new Boolean(checkbox.isChecked()); + return new Boolean(getComponent().isChecked()); } @Override @@ -98,13 +96,13 @@ public class WYesNoEditor extends WEditor { Boolean val = ((value == null) ? false : (Boolean) value); - checkbox.setChecked(val); + getComponent().setChecked(val); oldValue = val; } else if (value instanceof String) { Boolean val = value.equals("Y"); - checkbox.setChecked(val); + getComponent().setChecked(val); oldValue = val; } else @@ -113,11 +111,26 @@ public class WYesNoEditor extends WEditor "New field value of unknown type, Type: " + value.getClass() + ", Value: " + value); - checkbox.setChecked(false); + getComponent().setChecked(false); } } - public String[] getEvents() + @Override + public Checkbox getComponent() { + return (Checkbox) component; + } + + @Override + public boolean isReadWrite() { + return getComponent().isEnabled(); + } + + @Override + public void setReadWrite(boolean readWrite) { + getComponent().setEnabled(readWrite); + } + + public String[] getEvents() { return LISTENER_EVENTS; } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java index 26d7214129..aa0ea9e854 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java @@ -332,6 +332,8 @@ DataStatusListener, ValueChangeListener, IADTabpanel div.setAlign("right"); Label label = editor.getLabel(); div.appendChild(label); + if (label.getDecorator() != null) + div.appendChild(label.getDecorator()); row.appendChild(div); row.appendChild(editor.getComponent()); if (field.isLongField()) {