diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/IInputValidator.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/IInputValidator.java index 750372f1d5..fa771daa9c 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/IInputValidator.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/IInputValidator.java @@ -33,12 +33,12 @@ public interface IInputValidator { /** * Get Valid Input - * @return String + * @return Expected input string from user */ public String getValidInput(); /** - * Set Valid Input + * Set string to validate against user input * @param validInput */ public void setValidInput(String validInput); @@ -46,7 +46,7 @@ public interface IInputValidator { /** * Is Input Valid * @param input - * @return boolean + * @return true if input validate against {@link #getValidInput()} */ public boolean isValid(String input); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/IProcessButton.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/IProcessButton.java index d7fd9d6dea..e34ed3d672 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/IProcessButton.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/IProcessButton.java @@ -16,7 +16,7 @@ package org.adempiere.webui.editor; import org.adempiere.webui.adwindow.IADTabpanel; /** - * + * Interface for process button * @author hengsin * */ @@ -28,13 +28,28 @@ public interface IProcessButton { */ public int getProcess_ID(); + /** + * @return AD_InfoWindow_ID + */ public int getInfoWindow_ID(); + /** + * @return {@link IADTabpanel} instance that own this button + */ public IADTabpanel getADTabpanel(); + /** + * @return Column Name + */ public String getColumnName(); + /** + * @return Description + */ public String getDescription(); + /** + * @return Display text + */ public String getDisplay(); } \ No newline at end of file diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/IZoomableEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/IZoomableEditor.java index 61a32cf099..05840a9420 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/IZoomableEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/IZoomableEditor.java @@ -13,12 +13,14 @@ package org.adempiere.webui.editor; /** - * + * Interface for field editor that support zoom to AD window. * @author Low Heng Sin - * */ public interface IZoomableEditor { + /** + * Zoom to AD window + */ public void actionZoom(); } \ No newline at end of file diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/InfoListSubModel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/InfoListSubModel.java index a10902d1f6..3aa565d670 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/InfoListSubModel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/InfoListSubModel.java @@ -40,9 +40,8 @@ import org.zkoss.zul.ListModelList; import org.zkoss.zul.ListSubModel; /** - * + * Model to get filter list from lookup and info window/panel * @author hengsin - * */ public class InfoListSubModel implements ListSubModel { @@ -88,6 +87,7 @@ public class InfoListSubModel implements ListSubModel { public ListModel getSubModel(Object value, int nRows) { ListModelList model = new ListModelList<>(); if (value != null && !Util.isEmpty(value.toString(), true)) { + //build query text from input value String queryText = value.toString().trim(); StringBuilder queryBuilder = new StringBuilder(queryText); queryBuilder.append("?autocomplete={"); @@ -108,6 +108,7 @@ public class InfoListSubModel implements ListSubModel { queryBuilder.append("}"); queryText = queryBuilder.toString(); + //build model from infopanel/infowindow processing of query text final InfoPanel ip = InfoManager.create(lookup, gridField, tableName, keyColumnName, queryText, false, getWhereClause()); if (ip != null && ip.loadedOK()) { int rowCount = ip.getRowCount(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAccountEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAccountEditor.java index 9146348fee..452ab4a5fe 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAccountEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAccountEditor.java @@ -30,6 +30,7 @@ import org.compiere.model.MAccountLookup; import org.compiere.model.MRole; import org.compiere.util.CLogger; import org.compiere.util.DB; +import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.zkoss.zk.au.out.AuScript; import org.zkoss.zk.ui.event.Event; @@ -37,9 +38,9 @@ import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.util.Clients; /** - * + * Default editor for {@link DisplayType#Account}.
+ * Implemented with {@link Combinationbox} component and {@link WAccountDialog} dialog. * @author Low Heng Sin - * */ public class WAccountEditor extends WEditor implements ContextMenuListener { @@ -112,7 +113,7 @@ public class WAccountEditor extends WEditor implements ContextMenuListener } /** - * Button - Start Dialog + * Button - open {@link WAccountDialog}. */ public void cmd_button() { @@ -158,16 +159,16 @@ public class WAccountEditor extends WEditor implements ContextMenuListener Clients.response(new AuScript(script)); } }); - // } // cmd_button /** - * Text - try to find Alias or start Dialog + * Process input text - try to find Alias or open Dialog */ public void cmd_text() { String text = getComponent().getText(); - log.info("Text=" + text); + if (log.isLoggable(Level.INFO)) + log.info("Text=" + text); if (text == null || text.length() == 0 || text.equals("%")) { cmd_button(); @@ -224,8 +225,9 @@ public class WAccountEditor extends WEditor implements ContextMenuListener } else cmd_button(); - } // actionPerformed + } // cmd_text + @Override public void onEvent(Event event) { if (Events.ON_CHANGE.equals(event.getName()) || Events.ON_OK.equals(event.getName())) @@ -238,18 +240,17 @@ public class WAccountEditor extends WEditor implements ContextMenuListener } } + @Override public String[] getEvents() { return LISTENER_EVENTS; } - @Override public boolean isReadWrite() { return getComponent().isEnabled(); } - @Override public void setReadWrite(boolean readWrite) { getComponent().setEnabled(readWrite); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAssignmentEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAssignmentEditor.java index 4c27aeecc5..4f6dabcc3e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAssignmentEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAssignmentEditor.java @@ -1,3 +1,26 @@ +/*********************************************************************** + * This file is part of iDempiere ERP Open Source * + * http://www.idempiere.org * + * * + * Copyright (C) Contributors * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * 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., 51 Franklin Street, Fifth Floor, Boston, * + * MA 02110-1301, USA. * + * * + * Contributors: * + **********************************************************************/ package org.adempiere.webui.editor; import java.sql.PreparedStatement; @@ -29,6 +52,11 @@ import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; +/** + * Default editor for {@link DisplayType#Assignment}.
+ * Implemented with {@link EditorBox} component, {@link WAssignmentDialog} and {@link InfoSchedule} dialog. + * @author hengsin + */ public class WAssignmentEditor extends WEditor implements ContextMenuListener { private static final String RETRIEVE_RESOURCE_ASSIGNMENT_SQL = "SELECT r.Name,ra.AssignDateFrom,ra.Qty,uom.UOMSymbol " @@ -43,6 +71,7 @@ public class WAssignmentEditor extends WEditor implements ContextMenuListener { private static final String[] LISTENER_EVENTS = {Events.ON_CLICK}; private boolean m_readWrite; + /** S_ResourceAssignment_ID */ private Object m_value; private DateFormat m_dateFormat = DisplayType.getDateFormat(DisplayType.DateTime); @@ -68,6 +97,9 @@ public class WAssignmentEditor extends WEditor implements ContextMenuListener { initComponents(); } + /** + * Init component and context menu + */ private void initComponents() { getComponent().getTextbox().setReadonly(true); if (ThemeManager.isUseFontIconForImage()) @@ -82,8 +114,6 @@ public class WAssignmentEditor extends WEditor implements ContextMenuListener { getComponent().getTextbox().setPlaceholder(gridField.getPlaceholder()); } - - @Override public String[] getEvents() { return LISTENER_EVENTS; @@ -160,7 +190,8 @@ public class WAssignmentEditor extends WEditor implements ContextMenuListener { } } - + + @Override public void onEvent(Event event) throws Exception { // if (Events.ON_CLICK.equalsIgnoreCase(event.getName())) @@ -184,7 +215,7 @@ public class WAssignmentEditor extends WEditor implements ContextMenuListener { } } - // Start VAssignment Dialog + // Open WAssignmentDialog Dialog if (S_ResourceAssignment_ID != 0) { final WAssignmentDialog vad = new WAssignmentDialog (ma, true, true); @@ -200,7 +231,7 @@ public class WAssignmentEditor extends WEditor implements ContextMenuListener { vad.setTitle(null); LayoutUtils.openPopupWindow(this.getComponent().getTextbox(), vad); } - // Start InfoSchedule directly + // Open InfoSchedule directly else { final InfoSchedule is = new InfoSchedule(ma, true, new Callback() { @@ -227,10 +258,18 @@ public class WAssignmentEditor extends WEditor implements ContextMenuListener { } + /** + * Zoom to window for S_ResourceAssignment + */ private void actionZoom() { AEnv.zoom(gridField.getGridTab().getAD_Table_ID(), (Integer)getValue()); } + /** + * Fire {@link ValueChangeEvent} after changes from InfoSchedule or WAssignmentDialog. + * @param oldValue + * @param ma MResourceAssignment + */ private void processNewValue(final Integer oldValue, MResourceAssignment ma) { // Set Value if (ma != null && ma.getS_ResourceAssignment_ID() != 0) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WBinaryEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WBinaryEditor.java index 1523fbaf06..bcbb308c97 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WBinaryEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WBinaryEditor.java @@ -26,11 +26,14 @@ import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.window.WMediaDialog; import org.compiere.model.GridField; import org.compiere.util.CLogger; +import org.compiere.util.DisplayType; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; /** + * Default editor for {@link DisplayType#Binary}.
+ * Implemented with {@link Button} component and {@link WMediaDialog} dialog. * @author Low Heng Sin */ public class WBinaryEditor extends WEditor @@ -41,8 +44,10 @@ public class WBinaryEditor extends WEditor private static final CLogger log = CLogger.getCLogger(WBinaryEditor.class); private boolean m_mandatory; + /** Binary data */ private Object m_data; + /** ADWindow instance that own this editor */ private ADWindow adwindow; /** @@ -66,6 +71,9 @@ public class WBinaryEditor extends WEditor init(); } + /** + * Init component + */ private void init() { label.setValue(" "); @@ -73,7 +81,7 @@ public class WBinaryEditor extends WEditor getComponent().setTooltiptext(gridField.getDescription()); } - @Override + @Override public String getDisplay() { return getComponent().getLabel(); @@ -145,6 +153,7 @@ public class WBinaryEditor extends WEditor return LISTENER_EVENTS; } + @Override public void onEvent(Event event) throws Exception { if (Events.ON_CLICK.equals(event.getName())) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WButtonEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WButtonEditor.java index a865fb6ba4..2658227c11 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WButtonEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WButtonEditor.java @@ -47,8 +47,7 @@ import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Events; /** - * This class is based on org.compiere.grid.ed.VButton written by Jorg Janke. - * @author Jorg Janke + * Default editor for {@link DisplayType#Button}. * * Modifications - UI Compatibility * @author ashley @@ -69,7 +68,7 @@ public class WButtonEditor extends WEditor implements IProcessButton private String m_text; private boolean m_mandatory; private Object m_value; - /** List of Key/Name */ + /** Value:Name. AD_Ref_List values for PaymentRule, DocAction or Posted reference. */ private HashMap m_values = null; /** Description as ToolTip */ @@ -147,11 +146,17 @@ public class WButtonEditor extends WEditor implements IProcessButton return AD_InfoWindow_ID; } // getInfoWindow_ID + /** + * @return GridField + */ public GridField getGridField() { return gridfield; } + /** + * Init component + */ private void init() { label.setValue(" "); @@ -232,7 +237,6 @@ public class WButtonEditor extends WEditor implements IProcessButton { return m_mandatory; } - @Override public void setMandatory(boolean mandatory) @@ -288,6 +292,9 @@ public class WButtonEditor extends WEditor implements IProcessButton getComponent().setEnabled(readWrite); } + /** + * @return AD_Ref_List Value:Name HashMap + */ public HashMap getValues() { return m_values; @@ -338,12 +345,19 @@ public class WButtonEditor extends WEditor implements IProcessButton } // readReference + /** + * @param actionListener + */ public void addActionListener(ActionListener actionListener) { if (!actionListeners.contains(actionListener)) actionListeners.add(actionListener); } + /** + * @param actionListener + * @return true if found and remove + */ public boolean removeActionListener(ActionListener actionListener) { return actionListeners.remove(actionListener); @@ -355,6 +369,7 @@ public class WButtonEditor extends WEditor implements IProcessButton return LISTENER_EVENTS; } + @Override public void onEvent(Event event) throws Exception { if (Events.ON_CLICK.equals(event.getName())) @@ -369,6 +384,9 @@ public class WButtonEditor extends WEditor implements IProcessButton } } + /** + * @param adTabpanel + */ public void setADTabpanel(IADTabpanel adTabpanel) { this.adTabpanel = adTabpanel; } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WChartEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WChartEditor.java index 00310825a6..a3eec080d5 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WChartEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WChartEditor.java @@ -22,6 +22,7 @@ import org.adempiere.webui.apps.graph.model.ChartModel; import org.compiere.model.GridField; import org.compiere.model.MChart; import org.compiere.util.CLogger; +import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.zkoss.zk.ui.event.AfterSizeEvent; import org.zkoss.zk.ui.event.Event; @@ -31,7 +32,8 @@ import org.zkoss.zul.Panel; import org.zkoss.zul.Panelchildren; /** - * This class is based on org.compiere.grid.ed.WImageEditor and WGraph written by Low Heng Sin. + * Default editor for {@link DisplayType#Chart}.
+ * A readonly editor that render chart from {@link MChart} model to {@link Panel} component. * @author Low Heng Sin * * Modifications - chart display @@ -78,6 +80,9 @@ public class WChartEditor extends WEditor init(); } + /** + * Re-render chart + */ private void createChart() { if (chartHeight > 0 && chartWidth > 0) { chartDiv.getChildren().clear(); @@ -96,22 +101,32 @@ public class WChartEditor extends WEditor return (Panel) component; } + /** + * Init component + */ private void init() { Panelchildren pc = new Panelchildren(); getComponent().appendChild(pc); pc.setSclass("chart-field"); chartDiv = new Div(); + //chart is render in ON_AFTER_SIZE event chartDiv.addEventListener(Events.ON_AFTER_SIZE, this); pc.appendChild(chartDiv); } + /** + * @return {@link MChart#getName()} + */ @Override public String getDisplay() { return chartModel.get_Translation(MChart.COLUMNNAME_Name); } + /** + * Always return null + */ @Override public Object getValue() { @@ -124,23 +139,34 @@ public class WChartEditor extends WEditor return false; } - + /** + * No op. + */ @Override public void setMandatory(boolean mandatory) { ; } + /** + * Always return true + */ @Override public boolean isReadWrite() { return true; } + /** + * No op. + */ @Override public void setReadWrite(boolean readWrite) { } + /** + * No op. + */ @Override public void setValue(Object value) { @@ -153,6 +179,7 @@ public class WChartEditor extends WEditor return LISTENER_EVENTS; } + @Override public void onEvent(Event event) throws Exception { if (event instanceof AfterSizeEvent && chartModel != null && chartModel.getAD_Chart_ID() > 0) @@ -181,6 +208,9 @@ public class WChartEditor extends WEditor } } + /** + * Call {@link #createChart()} to re-render chart. + */ @Override public void dynamicDisplay() { super.dynamicDisplay(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WChosenboxListEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WChosenboxListEditor.java index 5304a11b2b..abefe9c524 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WChosenboxListEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WChosenboxListEditor.java @@ -13,7 +13,6 @@ *****************************************************************************/ package org.adempiere.webui.editor; -import java.beans.PropertyChangeEvent; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedHashSet; @@ -77,7 +76,8 @@ import org.zkoss.zul.Menuitem; import org.zkoss.zul.South; /** - * + * Default editor for {@link DisplayType#ChosenMultipleSelectionList} and {@link DisplayType#ChosenMultipleSelectionTable}.
+ * Implemented with {@link ChosenSearchBox} component. * @author hengsin * */ @@ -94,12 +94,16 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener } private Lookup lookup; + /** comma separated value list of selected records */ private Object oldValue; + /** CCache listener to auto refresh lookup */ private CCacheListener tableCacheListener; + /** true if editor is handling onSelect event */ private boolean onselecting = false; + /** Model for {@link Chosenbox} inside {@link ChosenSearchBox} */ private ListModelList model = new ListModelList<>(); /** @@ -122,6 +126,13 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener this(new ChosenSearchBox(new ChosenboxEditor()), gridField, tableEditor, editorConfiguration); } + /** + * + * @param comp + * @param gridField + * @param tableEditor + * @param editorConfiguration + */ private WChosenboxListEditor(Component comp, GridField gridField, boolean tableEditor, IEditorConfiguration editorConfiguration) { super(comp, gridField, tableEditor, editorConfiguration); @@ -133,9 +144,9 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener * Constructor for use if a grid field is unavailable * * @param lookup Store of selectable data - * @param label column name (not displayed) + * @param label field label * @param description description of component - * @param mandatory whether a selection must be made + * @param mandatory whether field is mandatory * @param readonly whether or not the editor is read only * @param updateable whether the editor contents can be changed */ @@ -159,6 +170,15 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener this(new ChosenSearchBox(new ChosenboxEditor()), lookup, label, description, mandatory, readonly, updateable); } + /** + * @param comp + * @param lookup + * @param label + * @param description + * @param mandatory + * @param readonly + * @param updateable + */ private WChosenboxListEditor(Component comp, Lookup lookup, String label, String description, boolean mandatory, boolean readonly, boolean updateable) { super(comp, label, description, mandatory, readonly, updateable); @@ -174,7 +194,6 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener } /** - * For ease of porting swing form * @param columnName * @param mandatory * @param isReadOnly @@ -200,6 +219,14 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener this(new ChosenSearchBox(new ChosenboxEditor()), columnName, mandatory, isReadOnly, isUpdateable, lookup); } + /** + * @param comp + * @param columnName + * @param mandatory + * @param isReadOnly + * @param isUpdateable + * @param lookup + */ private WChosenboxListEditor(Component comp, String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, Lookup lookup) { super(comp, columnName, null, null, mandatory, isReadOnly, isUpdateable); @@ -211,6 +238,9 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener init(); } + /** + * Init component, lookup and popup menu + */ private void init() { getComponent().setHflex("true"); @@ -226,6 +256,7 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener else getComponent().getButton().setImage(imageUrl); + //open chosenbox dropdown getComponent().getButton().addEventListener(Events.ON_CLICK, e -> { if (getComponent().isEnabled()) { if (!getComponent().getChosenbox().isOpen()) { @@ -277,6 +308,9 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener updateModel(); } + /** + * @return comma separated name list of selected records + */ @Override public String getDisplay() { @@ -300,6 +334,9 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener return oldValue; } + /** + * @return comma separated value list of selected records + */ private String getValueFromComponent() { StringBuilder retVal = new StringBuilder(); @@ -323,7 +360,7 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener } /** - * @param value + * @param value comma separated value list of selected records */ public void setValue(Object value) { @@ -331,7 +368,7 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener return; } - if (value != null && value instanceof String && !Util.isEmpty((String) value, true)) + if (value != null && value instanceof String && !Util.isEmpty((String) value, true)) { String[] values = ((String)value).split("[,]"); Set selected = new LinkedHashSet<>(); @@ -399,6 +436,9 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener getComponent().setEnabled(readWrite); } + /** + * Update {@link #model} + */ private void updateModel() { List list = new ArrayList<>(); @@ -453,6 +493,7 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener /** * @param event */ + @Override public void onEvent(Event event) { if (Events.ON_SELECT.equalsIgnoreCase(event.getName())) @@ -461,6 +502,10 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener } } + /** + * Handle ON_SELECT event + * @param newValue + */ private void updateValue(Object newValue) { try { onselecting = true; @@ -482,6 +527,10 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener } } + /** + * @param newValue + * @return true if newValue is different from {@link #oldValue} + */ private boolean isValueChange(Object newValue) { return (oldValue == null && newValue != null) || (oldValue != null && newValue == null) || ((oldValue != null && newValue != null) && !oldValue.equals(newValue)); @@ -494,7 +543,8 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener } /** - * action for requery menu + * Action for re-query menu.
+ * Refresh lookup */ protected void actionRefresh() { @@ -555,15 +605,6 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener } } - @Override - public void propertyChange(PropertyChangeEvent evt) - { - if ("FieldValue".equals(evt.getPropertyName())) - { - setValue(evt.getNewValue()); - } - } - @Override public void dynamicDisplay(Properties ctx) { @@ -578,6 +619,9 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener super.dynamicDisplay(ctx); } + /** + * Setup {@link #tableCacheListener} + */ private void createCacheListener() { if (lookup != null) { String columnName = lookup.getColumnName(); @@ -589,8 +633,10 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener } } - private final static class ChosenboxEditor extends Chosenbox { - + /** + * Custom {@link Chosenbox} class for setup and cleanup of tableCacheListener + */ + private final static class ChosenboxEditor extends Chosenbox { /** * generated serial id */ @@ -632,7 +678,7 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener } /** - * + * clean up tableCacheListener */ protected void cleanup() { if (editor != null && editor.tableCacheListener != null) { @@ -642,6 +688,9 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener } } + /** + * CCache listener class to auto refresh lookup + */ private static class CCacheListener extends CCache { /** * generated serial @@ -682,6 +731,9 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener } } + /** + * Assistant dialog to manage selection of items and to change ordering of selected items. + */ private class WChosenboxListAssistant extends Window implements EventListener { private static final long serialVersionUID = 1043859495570181469L; private Button bAdd, bRemove, bUp, bDown; @@ -734,12 +786,14 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener mainLayout.appendChild(center); center.setAutoscroll(true); + //Listener for add and remove button EventListener actionListener = new EventListener() { public void onEvent(Event event) throws Exception { migrateValueAcrossLists(event); } }; + //Listener for up and down button EventListener actionListener2 = new EventListener() { public void onEvent(Event event) throws Exception { migrateValueWithinSelectedList(event); @@ -815,6 +869,7 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener } } + @Override public void onEvent(Event event) throws Exception { if (event.getTarget() == bOk) { @@ -841,6 +896,15 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener return btn; } + /** + * @param lb + * @param model + * @param mouseListener + * @param crossListMouseListener + * @param isItemDraggable + * @param headerLabel + * @param buttonsLayout + */ private void initListboxAndModel(Listbox lb, SimpleListModel model, EventListener mouseListener, EventListener crossListMouseListener, boolean isItemDraggable, String headerLabel, Hlayout buttonsLayout) { lb.addEventListener(Events.ON_RIGHT_CLICK, this); ZKUpdateUtil.setHflex(lb, "1"); @@ -913,6 +977,10 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener return retValue; } + /** + * @param model + * @return opposite model + */ private SimpleListModel getModel(SimpleListModel model) { SimpleListModel retValue = null; @@ -925,6 +993,10 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener return retValue; } + /** + * Handle event from add button, remove button and double click. + * @param event + */ private void migrateValueAcrossLists (Event event) { Object source = event.getTarget(); if (source instanceof ListItem) @@ -940,6 +1012,12 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener migrateLists (listFrom, listTo, endIndex); } // migrateValueAcrossLists + /** + * Move selected items from listFrom to listTo at endIndex + * @param listFrom + * @param listTo + * @param endIndex + */ private void migrateLists (final Listbox listFrom, final Listbox listTo, final int endIndex) { int index = 0; final SimpleListModel lmFrom = getModel(listFrom); @@ -954,12 +1032,18 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener selObjects.add(selObject); } - doTransfer(index, selObjects, lmFrom, lmTo, listFrom, listTo, endIndex); + doTransfer(selObjects, lmFrom, lmTo, listTo, endIndex); } - private void doTransfer(int index, List selObjects, SimpleListModel lmFrom, SimpleListModel lmTo, Listbox listFrom , Listbox listTo , int endIndex) { - - index = 0; + /** + * Move selected items from lmFrom to lmTo at endIndex + * @param selObjects + * @param lmFrom + * @param lmTo + * @param listTo + * @param endIndex + */ + private void doTransfer(List selObjects, SimpleListModel lmFrom, SimpleListModel lmTo, Listbox listTo , int endIndex) { Arrays.sort(selObjects.toArray()); for (ValueNamePair selObject : selObjects) { lmFrom.removeElement(selObject); @@ -972,10 +1056,14 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener } } + /** + * Listener for DropEvent + */ private class DragListener implements EventListener { public DragListener() { } + @Override public void onEvent(Event event) throws Exception { if (event instanceof DropEvent) { int endIndex = 0; @@ -1009,6 +1097,13 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener } } + /** + * Move selected items to endIndex + * @param selModel + * @param selListbox + * @param endIndex + * @param selObjects + */ private void migrateValueWithinSelectedList (SimpleListModel selModel, Listbox selListbox, int endIndex, List selObjects) { int iniIndex =0; Arrays.sort(selObjects.toArray()); @@ -1029,6 +1124,11 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener } } + /** + * Handle event from up and down button.
+ * Move selected items up/down within {@link #selectedList}. + * @param event + */ private void migrateValueWithinSelectedList (Event event) { Object[] selObjects = selectedList.getSelectedItems().toArray(); if (selObjects == null) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WChosenboxSearchEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WChosenboxSearchEditor.java index 85034c52e9..932e7fd6d0 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WChosenboxSearchEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WChosenboxSearchEditor.java @@ -13,7 +13,6 @@ *****************************************************************************/ package org.adempiere.webui.editor; -import java.beans.PropertyChangeEvent; import java.util.LinkedHashSet; import java.util.Properties; import java.util.Set; @@ -41,9 +40,11 @@ import org.compiere.model.MSysConfig; import org.compiere.model.MTable; import org.compiere.model.X_AD_CtxHelp; import org.compiere.util.CLogger; +import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.compiere.util.Util; import org.compiere.util.ValueNamePair; +import org.zkoss.addon.chosenbox.Chosenbox; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; @@ -53,25 +54,32 @@ import org.zkoss.zul.ListModelList; import org.zkoss.zul.ListSubModel; /** - * + * Default editor for {@link DisplayType#ChosenMultipleSelectionSearch}. + * Implemented with {@link ChosenSearchBox} component. * @author hengsin - * */ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListener { private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_SELECT}; private Lookup lookup; + /** Foreign table name */ private String m_tableName = null; + /** Foreign key column name */ private String m_keyColumnName = null; + /** Column name for {@link #lookup} */ private String columnName; + /** comma separated value list of selected records */ private String value; private InfoPanel infoPanel = null; + /** Image URL or font icon sclass for choosebox button */ private String imageUrl; private MyListModel model = new MyListModel(); + /** Model for {@link Chosenbox} */ private InfoListSubModel subModel = null; private static final CLogger log = CLogger.getCLogger(WChosenboxSearchEditor.class); private static final int DEFAULT_MAX_AUTO_COMPLETE_ROWS = 500; + /** true when editor is handling ON_SELECT event */ private boolean onselecting; /** @@ -118,7 +126,6 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen getComponent().setEnabled(readWrite); } - /** * Constructor for use if a grid field is unavailable * @@ -144,6 +151,13 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen init(); } + /** + * @param columnName + * @param mandatory + * @param readonly + * @param updateable + * @param lookup + */ public WChosenboxSearchEditor(String columnName, boolean mandatory, boolean readonly, boolean updateable, Lookup lookup) { @@ -163,7 +177,6 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen /** * initialise editor - * @param columnName columnName */ private void init() { @@ -249,6 +262,9 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen return value; } + /** + * @return comma separated value list of selected records + */ private String getValueFromComponent() { StringBuilder retVal = new StringBuilder(); @@ -271,6 +287,9 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen return retVal.length() > 0 ? retVal.toString() : null; } + /** + * @return comma separated name list of selected records + */ @Override public String getDisplay() { @@ -288,6 +307,7 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen return display.toString(); } + @Override public void onEvent(Event e) { if (Events.ON_CLICK.equals(e.getName())) @@ -322,20 +342,16 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen } } + /** + * @param newValue + * @return true if newValue is different from {@link #value} + */ private boolean isValueChange(Object newValue) { return (value == null && newValue != null) || (value != null && newValue == null) || ((value != null && newValue != null) && !value.equals(newValue)); } @Override - public void propertyChange(PropertyChangeEvent evt) - { - if ("FieldValue".equals(evt.getPropertyName())) - { - setValue(evt.getNewValue()); - } - } - public void onMenu(ContextMenuEvent evt) { if (WEditorPopupMenu.PREFERENCE_EVENT.equals(evt.getContextEvent())) @@ -350,6 +366,10 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen } } + /** + * Process selected items from info panel/window + * @param value + */ private void processSelectedKeys (Object value) { if (log.isLoggable(Level.FINE)) @@ -431,13 +451,19 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen } // actionCombo - + /** + * Fire ValueChangeEvent for newValue + * @param newValue + */ protected void fireValueChangeEvent(Object newValue) { ValueChangeEvent evt = new ValueChangeEvent(this, this.getColumnName(), getValue(), newValue); // -> ADTabpanel - valuechange fireValueChange(evt); } + /** + * Open info panel/window + */ private void actionButton() { if (lookup == null) @@ -461,7 +487,10 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen showInfoPanel(ip); } - + /** + * Open {@link InfoPanel} + * @param ip InfoPanel + */ protected void showInfoPanel(final InfoPanel ip) { ip.setVisible(true); ip.setStyle("border: 2px"); @@ -498,7 +527,7 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen } /** - * Sets m_tableName and m_keyColumnName + * Set {@link #m_tableName} and {@link #m_keyColumnName} */ private void setTableAndKeyColumn() { if (lookup != null && lookup instanceof MLookup) { @@ -529,6 +558,9 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen } } + /** + * @return where clause from {@link #lookup} validation code. + */ private String getWhereClause() { String whereClause = ""; @@ -563,7 +595,7 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen return whereClause; } // getWhereClause - + @Override public String[] getEvents() { return LISTENER_EVENTS; @@ -575,6 +607,9 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen getComponent().setTableEditorMode(b); } + /** + * @return {@link Lookup} + */ public Lookup getLookup() { return lookup; } @@ -588,10 +623,12 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen super.dynamicDisplay(ctx); } + /** + * {@link ListSubModel} for {@link Chosenbox} auto complete + */ private class MyListModel extends ListModelList implements ListSubModel { - /** - * + * generated serial id */ private static final long serialVersionUID = -1210525428410505409L; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WColorEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WColorEditor.java index d27afffc38..8b2ed883d6 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WColorEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WColorEditor.java @@ -38,6 +38,7 @@ import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.theme.ThemeManager; import org.compiere.model.GridField; import org.compiere.util.CLogger; +import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.compiere.util.Msg; import org.compiere.util.Util; @@ -52,7 +53,8 @@ import org.zkoss.zul.Html; import org.zkoss.zul.Menuitem; /** - * + * Default editor for {@link DisplayType#Color}.
+ * Implemented with {@link EditorBox} component and HTML color type (<input type="color">). * @author Nicolas Micoud (TGI) * */ @@ -62,10 +64,11 @@ public class WColorEditor extends WEditor implements ContextMenuListener private static final String[] LISTENER_EVENTS = {Events.ON_CLICK}; public static final String COLOR_PICKER_EVENT = "COLOR_PICKER"; + /** Hex coded color value, for e.g #FF0000 */ private String oldValue; - + /** Place holder text for text box */ private String placeHolder; - + /** Hidden text box with type set to color. Use to open HTML native color picker. */ private Textbox colorbox; /** @@ -160,6 +163,9 @@ public class WColorEditor extends WEditor implements ContextMenuListener return null; } + /** + * Init component and context menu + */ private void init() { if (log.isLoggable(Level.INFO)) log.info("Initializing component"); @@ -169,6 +175,10 @@ public class WColorEditor extends WEditor implements ContextMenuListener addChangeLogMenu(popupMenu); } + /** + * Add entries to popup context menu + * @param popupMenu + */ protected void addColorEditorMenu(WEditorPopupMenu popupMenu) { Menuitem editor = new Menuitem(); editor.setAttribute("EVENT", WEditorPopupMenu.RESET_EVENT); @@ -191,6 +201,7 @@ public class WColorEditor extends WEditor implements ContextMenuListener popupMenu.appendChild(editor); } + @Override public void onMenu(ContextMenuEvent evt) { if (WEditorPopupMenu.RESET_EVENT.equals(evt.getContextEvent())) @@ -229,6 +240,9 @@ public class WColorEditor extends WEditor implements ContextMenuListener fillTextbox(); } + /** + * Fill half of text box with entered color value + */ private void fillTextbox() { String style="background-color: transparent !important;"; if (!Util.isEmpty(oldValue, true)) @@ -241,7 +255,7 @@ public class WColorEditor extends WEditor implements ContextMenuListener } /** - * @param color hex color string + * @param color hex coded color string * @return background fill style */ protected String getBackgroundFillStyle(String color) { @@ -271,6 +285,7 @@ public class WColorEditor extends WEditor implements ContextMenuListener getComponent().getButton().setEnabled(readWrite); } + @Override public void onEvent(Event event) { if (Events.ON_CLICK.equalsIgnoreCase(event.getName())) @@ -283,12 +298,19 @@ public class WColorEditor extends WEditor implements ContextMenuListener } } + /** + * Open HTML native color picker + */ public void openColorPicker() { String uid = colorbox.getUuid(); String script = "(function(){let wgt = zk.Widget.$('#"+uid+"');wgt.$n().click();})()"; Clients.response(new AuScript(script)); } + /** + * Process newValue from color picker + * @param newValue + */ protected void processNewValue(String newValue) { if (oldValue != null && newValue != null && oldValue.equals(newValue)) { return; @@ -301,6 +323,7 @@ public class WColorEditor extends WEditor implements ContextMenuListener oldValue = getComponent().getTextbox().getValue(); } + @Override public String[] getEvents() { return LISTENER_EVENTS; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WDashboardContentEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WDashboardContentEditor.java index 2dc29c4007..623c4a16a2 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WDashboardContentEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WDashboardContentEditor.java @@ -31,6 +31,7 @@ import org.adempiere.webui.desktop.DashboardController; import org.compiere.model.GridField; import org.compiere.model.MDashboardContent; import org.compiere.util.CLogger; +import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.compiere.util.Util; import org.zkoss.zk.ui.event.Event; @@ -41,6 +42,8 @@ import org.zkoss.zul.Panel; import org.zkoss.zul.Panelchildren; /** + * Default editor for {@link DisplayType#DashboardContent}.
+ * A readonly editor that render dashboard content from {@link MDashboardContents} to {@link Panel} component. * @author hengsin * */ @@ -64,7 +67,7 @@ public class WDashboardContentEditor extends WEditor { /** * - * @param gridField + * @param gridField GridField for PA_DashboardContent_ID * @param windowNo * @param tableEditor * @param editorConfiguration @@ -97,8 +100,8 @@ public class WDashboardContentEditor extends WEditor { } } - /* (non-Javadoc) - * @see org.adempiere.webui.editor.WEditor#setReadWrite(boolean) + /** + * No op. */ @Override public void setReadWrite(boolean readWrite) { @@ -112,29 +115,32 @@ public class WDashboardContentEditor extends WEditor { return false; } - /* (non-Javadoc) - * @see org.adempiere.webui.editor.WEditor#setValue(java.lang.Object) + /** + * No op. */ @Override public void setValue(Object value) { } - /* (non-Javadoc) - * @see org.adempiere.webui.editor.WEditor#getValue() + /** + * Always return null. */ @Override public Object getValue() { return null; } - /* (non-Javadoc) - * @see org.adempiere.webui.editor.WEditor#getDisplay() + /** + * Always return null. */ @Override public String getDisplay() { return null; } + /** + * Post {@link #ON_RENDER_CONTENT} event to render dashboard content. + */ @Override public void dynamicDisplay() { super.dynamicDisplay(); @@ -149,6 +155,10 @@ public class WDashboardContentEditor extends WEditor { return (Panel) super.getComponent(); } + /** + * Render dashboard content + * @throws Exception + */ private void render() throws Exception { Panel panel = getComponent(); panel.setSclass("dashboard-field-panel"); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WDateEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WDateEditor.java index 8e6dd5e56c..bd42d3ab8c 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WDateEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WDateEditor.java @@ -29,11 +29,13 @@ import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.window.WFieldRecordInfo; import org.compiere.model.GridField; import org.compiere.util.CLogger; +import org.compiere.util.DisplayType; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Events; /** - * + * Default editor for {@link DisplayType#Date}.
+ * Implemented with {@link Datebox} component. * @author Ashley G Ramdass * @date Mar 12, 2007 * @version $Revision: 0.10 $ @@ -72,16 +74,15 @@ public class WDateEditor extends WEditor implements ContextMenuListener init(); } - /** * Constructor for use if a grid field is unavailable * * @param label - * column name (not displayed) + * field label * @param description - * description of component + * field description * @param mandatory - * whether a selection must be made + * whether field is mandatory * @param readonly * whether or not the editor is read only * @param updateable @@ -94,6 +95,9 @@ public class WDateEditor extends WEditor implements ContextMenuListener init(); } + /** + * Default constructor + */ public WDateEditor() { this("Date", "Date", false, false, true); @@ -113,6 +117,9 @@ public class WDateEditor extends WEditor implements ContextMenuListener super(new Datebox(), columnName, title, null, mandatory, readonly, updateable); } + /** + * Init component and context menu + */ private void init() { popupMenu = new WEditorPopupMenu(false, false, isShowPreference()); @@ -122,7 +129,7 @@ public class WDateEditor extends WEditor implements ContextMenuListener getComponent().setPlaceholder(gridField.getPlaceholder()); } - + @Override public void onEvent(Event event) { if (Events.ON_CHANGE.equalsIgnoreCase(event.getName()) || Events.ON_OK.equalsIgnoreCase(event.getName())) @@ -149,18 +156,14 @@ public class WDateEditor extends WEditor implements ContextMenuListener @Override public String getDisplay() { - // Elaine 2008/07/29 return getComponent().getText(); - // } @Override public Timestamp getValue() { - // Elaine 2008/07/25 if(getComponent().getValue() == null) return null; return Timestamp.valueOf(getComponent().getValue().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()); - // } @Override @@ -211,12 +214,12 @@ public class WDateEditor extends WEditor implements ContextMenuListener getComponent().setEnabled(readWrite); } + @Override public String[] getEvents() { return LISTENER_EVENTS; } - @Override public void onMenu(ContextMenuEvent evt) { if (WEditorPopupMenu.CHANGE_LOG_EVENT.equals(evt.getContextEvent())) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WDatetimeEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WDatetimeEditor.java index d0cb6eca38..5d71bdfda6 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WDatetimeEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WDatetimeEditor.java @@ -37,7 +37,8 @@ import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Events; /** - * + * Default editor for {@link DisplayType#DateTime} and {@link DisplayType#TimestampWithTimeZone}. + * Implemented with {@link DatetimeBox} component. * @author Low Heng Sin */ public class WDatetimeEditor extends WEditor implements ContextMenuListener @@ -63,8 +64,10 @@ public class WDatetimeEditor extends WEditor implements ContextMenuListener } /** - * + * * @param gridField + * @param tableEditor + * @param editorConfiguration */ public WDatetimeEditor(GridField gridField, boolean tableEditor, IEditorConfiguration editorConfiguration) { @@ -72,16 +75,15 @@ public class WDatetimeEditor extends WEditor implements ContextMenuListener init(); } - /** * Constructor for use if a grid field is unavailable * * @param label - * column name (not displayed) + * field label * @param description - * description of component + * field description * @param mandatory - * whether a selection must be made + * whether a field is mandatory * @param readonly * whether or not the editor is read only * @param updateable @@ -94,6 +96,9 @@ public class WDatetimeEditor extends WEditor implements ContextMenuListener init(); } + /** + * Default constructor + */ public WDatetimeEditor() { this(Msg.getMsg(Env.getCtx(), "DateTime"), Msg.getMsg(Env.getCtx(), "DateTime"), false, false, true); @@ -105,7 +110,7 @@ public class WDatetimeEditor extends WEditor implements ContextMenuListener * @param mandatory * @param readonly * @param updateable - * @param title + * @param title field label */ public WDatetimeEditor(String columnName, boolean mandatory, boolean readonly, boolean updateable, String title) @@ -114,6 +119,9 @@ public class WDatetimeEditor extends WEditor implements ContextMenuListener init(); } + /** + * Init component and popup context menu + */ private void init() { popupMenu = new WEditorPopupMenu(false, false, isShowPreference()); @@ -145,6 +153,9 @@ public class WDatetimeEditor extends WEditor implements ContextMenuListener } } + /** + * @return true if this is for {@link DisplayType#TimestampWithTimeZone} + */ private boolean isTimestampWithTimeZone() { if (gridField != null) @@ -189,18 +200,14 @@ public class WDatetimeEditor extends WEditor implements ContextMenuListener @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 Timestamp.valueOf(getComponent().getValue().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()); - // } @Override @@ -260,18 +267,17 @@ public class WDatetimeEditor extends WEditor implements ContextMenuListener return getComponent().isEnabled(); } - @Override public void setReadWrite(boolean readWrite) { getComponent().setEnabled(readWrite); } + @Override public String[] getEvents() { return LISTENER_EVENTS; } - @Override public void onMenu(ContextMenuEvent evt) { if (WEditorPopupMenu.CHANGE_LOG_EVENT.equals(evt.getContextEvent())) @@ -285,7 +291,6 @@ public class WDatetimeEditor extends WEditor implements ContextMenuListener } } - /* (non-Javadoc) * @see org.adempiere.webui.editor.WEditor#setFieldStyle(java.lang.String) */ diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditor.java index c882e04114..207523cb28 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditor.java @@ -28,7 +28,9 @@ import org.adempiere.util.GridRowCtx; import org.adempiere.webui.AdempiereWebUI; import org.adempiere.webui.ClientInfo; import org.adempiere.webui.LayoutUtils; +import org.adempiere.webui.adwindow.ADTabpanel; import org.adempiere.webui.adwindow.ADWindow; +import org.adempiere.webui.adwindow.GridTabRowRenderer; import org.adempiere.webui.adwindow.IFieldEditorContainer; import org.adempiere.webui.component.Bandbox; import org.adempiere.webui.component.Button; @@ -39,6 +41,8 @@ import org.adempiere.webui.component.EditorBox; import org.adempiere.webui.component.Label; import org.adempiere.webui.component.NumberBox; import org.adempiere.webui.component.Paymentbox; +import org.adempiere.webui.component.WListItemRenderer; +import org.adempiere.webui.component.WListbox; import org.adempiere.webui.event.ContextMenuListener; import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeListener; @@ -61,6 +65,7 @@ import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; import org.zkoss.zul.Combobox; +import org.zkoss.zul.Html; import org.zkoss.zul.Menuitem; import org.zkoss.zul.Textbox; import org.zkoss.zul.Timebox; @@ -68,17 +73,22 @@ import org.zkoss.zul.impl.InputElement; import org.zkoss.zul.impl.XulElement; /** - * + * Base class for field editor. * @author Ashley G Ramdass * @date Mar 11, 2007 * @version $Revision: 0.10 $ */ public abstract class WEditor implements EventListener, PropertyChangeListener, IInputValidator { - private static final String[] lISTENER_EVENTS = {}; + /** Component attribute to store reference to WEditor instance */ + public static final String IDEMPIERE_EDITOR_ATTR = "idempiere.editor"; + private static final String[] lISTENER_EVENTS = {}; + + /** Max display length for string editor */ public static final int MAX_DISPLAY_LENGTH = 35; + /** Event to indicate start of editing a text field */ public static final String INIT_EDIT_EVENT = "onInitEdit"; protected GridField gridField; @@ -86,13 +96,15 @@ public abstract class WEditor implements EventListener, PropertyChangeLis protected GridTab gridTab; protected Label label; - + + /** Component of this editor */ protected Component component; protected boolean mandatory; protected ArrayList listeners = new ArrayList(); + /** label text */ private String strLabel; private String description; @@ -100,19 +112,23 @@ public abstract class WEditor implements EventListener, PropertyChangeLis protected boolean readOnly; private String columnName; - + + /** Context menu */ protected WEditorPopupMenu popupMenu; - + + /** true if it is use inside a grid/list view */ protected boolean tableEditor; + /** true if this is use for process parameter field */ private boolean isProcessParameter; + /** Optional expected input string */ private String sValidInput; private final List dynamicDisplayListeners = new ArrayList<>(); /** - * call to show context menu of this field. + * call to show context menu of this field.
* must call after append component of this field to parent */ public void showMenu() { @@ -235,21 +251,19 @@ public abstract class WEditor implements EventListener, PropertyChangeLis } /** - * Normal zk component just fire onChange event when user loss focus - * call this method with true value let component fire event when user type first character - * - * remark: editor set true for this method also need handle INIT_EDIT_EVENT to take effect, - * can refer implement at {@link WStringEditor#onEvent(Event)} + * By default, zk component fire onChange event when component loss focus.
+ * Call this method with true value let component fire event when user type first character. + *
+ * Note: editor that set this to true also need to handle INIT_EDIT_EVENT to take effect, + * please see implementation at {@link WStringEditor#onEvent(Event)} for reference. * @param isChangeEventWhenEditing */ public void setChangeEventWhenEditing (boolean isChangeEventWhenEditing){ this.component.setWidgetOverride("isChangeEventWhenEditing", String.valueOf(isChangeEventWhenEditing)); } - /** - * Method is used to distinguish between 2 similar WSearchEditors - * + * @return description */ public String getDescription() { @@ -258,37 +272,28 @@ public abstract class WEditor implements EventListener, PropertyChangeLis } /** - * Constructor for use if a grid field is unavailable + * Constructor to use if a grid field is unavailable * * @param comp The editor's component - * @param label column name (not displayed) + * @param label field label * @param description description of component - * @param mandatory whether a selection must be made + * @param mandatory whether field is mandatory * @param readonly whether or not the editor is read only * @param updateable whether the editor contents can be changed */ public WEditor(Component comp, String label, String description, boolean mandatory, boolean readonly, boolean updateable) { - if (comp == null) - { - throw new IllegalArgumentException("Component cannot be null"); - } - - this.setComponent(comp); - this.setMandatory(mandatory); - this.readOnly = readonly; - this.description = description; - this.strLabel = label; - init(); + this(comp, null, label, description, mandatory, readonly, updateable); } /** - * Constructor for use if a grid field is unavailable + * Constructor to use if a grid field is unavailable * * @param comp The editor's component - * @param label column name (not displayed) + * @param columnName column name + * @param label field label * @param description description of component - * @param mandatory whether a selection must be made + * @param mandatory whether field is mandatory * @param readonly whether or not the editor is read only * @param updateable whether the editor contents can be changed */ @@ -318,6 +323,9 @@ public abstract class WEditor implements EventListener, PropertyChangeLis this.component = comp; } + /** + * Init label and component + */ private void init() { label = new Label(""); @@ -338,7 +346,7 @@ public abstract class WEditor implements EventListener, PropertyChangeLis } component.addEventListener(INIT_EDIT_EVENT, this); - component.setAttribute("idempiere.editor", this); + component.setAttribute(IDEMPIERE_EDITOR_ATTR, this); component.addEventListener(Events.ON_FOCUS, e -> { ADWindow adwindow = ADWindow.findADWindow(component); @@ -349,7 +357,6 @@ public abstract class WEditor implements EventListener, PropertyChangeLis } /** - * * @return grid field for this editor ( can be null ) */ public GridField getGridField() @@ -358,8 +365,7 @@ public abstract class WEditor implements EventListener, PropertyChangeLis } /** - * - * @return columnNames + * @return column name */ public String getColumnName() { @@ -368,10 +374,10 @@ public abstract class WEditor implements EventListener, PropertyChangeLis /** * Remove the table qualifier from the supplied column name. - * + *

* The column name may be prefixed with the table name * i.e. [table name].[column name]. - * The function returns + * The function returns the [column name] part. * * @param originalColumnName The column name to clean * @return the column name with any table qualifier removed @@ -391,6 +397,9 @@ public abstract class WEditor implements EventListener, PropertyChangeLis return cleanColumnName; } + /** + * @param columnName + */ protected void setColumnName(String columnName) { String cleanColumnName = cleanColumnName(columnName); @@ -424,6 +433,7 @@ public abstract class WEditor implements EventListener, PropertyChangeLis } /** + * Handle PropertyChangeEvent from {@link #gridField}. * @param evt */ public void propertyChange(final PropertyChangeEvent evt) @@ -444,7 +454,7 @@ public abstract class WEditor implements EventListener, PropertyChangeLis } /** - * @param listener + * @param listener ValueChangeListener */ public void addValueChangeListener(ValueChangeListener listener) { @@ -457,11 +467,19 @@ public abstract class WEditor implements EventListener, PropertyChangeLis listeners.add(listener); } + /** + * @param listener + * @return true if listener is found and remove from {@link #listeners} + */ public boolean removeValuechangeListener(ValueChangeListener listener) { return listeners.remove(listener); } + /** + * Fire ValueChangeEvent to ValueChangeListener in {@link #listeners} + * @param event + */ protected void fireValueChange(ValueChangeEvent event) { //copy to array to avoid concurrent modification exception @@ -490,7 +508,7 @@ public abstract class WEditor implements EventListener, PropertyChangeLis /** * - * @return editable + * @return true if editable */ public abstract boolean isReadWrite(); @@ -505,8 +523,8 @@ public abstract class WEditor implements EventListener, PropertyChangeLis /** * - * @param visible - * @param labelVisible + * @param visible visibility for component + * @param labelVisible visibility for label */ public void setVisible(boolean visible, boolean labelVisible) { @@ -516,7 +534,7 @@ public abstract class WEditor implements EventListener, PropertyChangeLis /** * - * @return is visible + * @return true if component is visible */ public boolean isVisible() { @@ -524,7 +542,8 @@ public abstract class WEditor implements EventListener, PropertyChangeLis } /** - * Indicating error with changing the style. + * Indicating error with changing the style.
+ * No op. here, for subclass to implement. * @param error */ public void setBackground(boolean error) @@ -532,11 +551,17 @@ public abstract class WEditor implements EventListener, PropertyChangeLis } + /** + * Set background color of component.
+ * No op. here, for subclass to implement. + * @param color + */ public void setBackground(Color color) { } + @Override public String toString() { StringBuilder sb = new StringBuilder(30); @@ -548,14 +573,13 @@ public abstract class WEditor implements EventListener, PropertyChangeLis } /** - * + * Set editor value * @param value */ abstract public void setValue(Object value); /** - * - * @return Object + * @return Object, current value of editor */ abstract public Object getValue(); @@ -565,10 +589,19 @@ public abstract class WEditor implements EventListener, PropertyChangeLis */ abstract public String getDisplay(); + /** + * @param value + * @return display text for grid view, for consumption by {@link #getDisplayComponent()} + */ public String getDisplayTextForGridView(Object value) { return getDisplayTextForGridView(null, value); } + /** + * @param gridRowCtx {@link GridRowCtx} + * @param value + * @return display text for grid view, for consumption by {@link #getDisplayComponent()} + */ public String getDisplayTextForGridView(GridRowCtx gridRowCtx, Object value) { this.setValue(value); String s = getDisplay(); @@ -580,7 +613,7 @@ public abstract class WEditor implements EventListener, PropertyChangeLis /** * - * @return list of events + * @return list of {@link #component} events that this editor will listen to */ public String[] getEvents() { @@ -605,20 +638,24 @@ public abstract class WEditor implements EventListener, PropertyChangeLis /** * - * @return boolean + * @return true if field is mandatory */ public boolean isMandatory() { return this.mandatory; } + /** + * Dynamic update of component state + */ public void dynamicDisplay() { dynamicDisplay(gridField != null ? gridField.getVO().ctx : Env.getCtx()); } /** - * allow subclass to perform dynamic loading of data + * Dynamic update of component state + * @param ctx */ public void dynamicDisplay(Properties ctx) { @@ -627,20 +664,31 @@ public abstract class WEditor implements EventListener, PropertyChangeLis updateStyle(); } - if (!dynamicDisplayListeners.isEmpty()) - dynamicDisplayListeners.stream().forEach(e -> e.onDynamicDisplay(ctx, this)); + if (!dynamicDisplayListeners.isEmpty()) + dynamicDisplayListeners.stream().forEach(e -> e.onDynamicDisplay(ctx, this)); } + /** + * Update label and component style + * @param applyDictionaryStyle + */ public void updateStyle(boolean applyDictionaryStyle) { applyLabelStyles(applyDictionaryStyle); applyFieldStyles(applyDictionaryStyle); } + /** + * Update label and component style + */ public void updateStyle() { applyLabelStyles(true); applyFieldStyles(true); } + /** + * Update label styles + * @param applyDictionaryStyle + */ protected void applyLabelStyles(boolean applyDictionaryStyle) { if (label != null) { boolean zoomable = isZoomable(); @@ -673,6 +721,10 @@ public abstract class WEditor implements EventListener, PropertyChangeLis } } + /** + * Set label style + * @param style sclass name (@sclass=) or zclass name (@zclass=) or css style string + */ protected void setLabelStyle(String style) { if (label != null) { if (style != null && style.toLowerCase().startsWith(MStyle.SCLASS_PREFIX)) { @@ -684,11 +736,13 @@ public abstract class WEditor implements EventListener, PropertyChangeLis } else { label.setStyle(style); } -// if (this instanceof WRadioGroupEditor) -// System.out.println(getComponent().getUuid() + " label stype="+label.getStyle()); } } + /** + * Update field styles + * @param applyDictionaryStyle + */ protected void applyFieldStyles(boolean applyDictionaryStyle) { String style = null; if (applyDictionaryStyle && gridField.getAD_FieldStyle_ID() > 0) @@ -699,6 +753,10 @@ public abstract class WEditor implements EventListener, PropertyChangeLis setFieldMandatoryStyle(applyDictionaryStyle); } + /** + * Add mandatory style to field + * @param applyStyle + */ private void setFieldMandatoryStyle(boolean applyStyle) { HtmlBasedComponent component = (HtmlBasedComponent) getComponent(); if (component != null) { @@ -709,6 +767,10 @@ public abstract class WEditor implements EventListener, PropertyChangeLis } } + /** + * Set field style + * @param style sclass name (@sclass=) or zclass name (@zclass=) or css style string + */ protected void setFieldStyle(String style) { HtmlBasedComponent component = (HtmlBasedComponent) getComponent(); if (style != null && style.startsWith(MStyle.SCLASS_PREFIX)) { @@ -744,13 +806,18 @@ public abstract class WEditor implements EventListener, PropertyChangeLis return true; } + /** + * Build css inline style from AD_Style record + * @param AD_Style_ID + * @return css inline style string + */ protected String buildStyle(int AD_Style_ID) { MStyle style = MStyle.get(Env.getCtx(), AD_Style_ID); return style.buildStyle(ThemeManager.getTheme(), getStyleEvaluatee()); } /** - * Stretch editor component to fill container + * Stretch editor component to fill parent */ public void fillHorizontal() { //stretch component to fill grid cell @@ -811,15 +878,24 @@ public abstract class WEditor implements EventListener, PropertyChangeLis updateStyle(); } + /** + * @return true if mandatory style should be added to editor + */ public boolean isMandatoryStyle() { return mandatory && !readOnly && (isProcessParameter || getGridField().isEditable(true)) && isNullOrEmpty(); } + /** + * @return true if current value of editor is null or empty + */ public boolean isNullOrEmpty() { Object value = getValue(); return value == null || value.toString().trim().length() == 0; } + /** + * @return true if editor support zoom command + */ public boolean isZoomable() { WEditorPopupMenu menu = getPopupMenu(); if (menu != null && menu.isZoomEnabled() && this instanceof IZoomableEditor) { @@ -829,18 +905,23 @@ public abstract class WEditor implements EventListener, PropertyChangeLis } } - public void setTableEditor(boolean b) { - tableEditor = b; + /** + * Set grid view mode. Have no effect if editor doesn't has a separate grid view mode. + * @param tableEditorMode + */ + public void setTableEditor(boolean tableEditorMode) { + tableEditor = tableEditorMode; } /** - * @return boolean + * @return true if preference dialog is available and accessible */ protected boolean isShowPreference() { return MRole.getDefault().isShowPreference() && gridField != null && !gridField.isEncrypted() && !gridField.isEncryptedColumn() && !gridField.isVirtualColumn(); } /** + * Add record info entry to context menu * @param popupMenu */ protected void addChangeLogMenu(WEditorPopupMenu popupMenu) { @@ -851,6 +932,7 @@ public abstract class WEditor implements EventListener, PropertyChangeLis } /** + * Add text editor dialog entry to context menu * @param popupMenu */ protected void addTextEditorMenu(WEditorPopupMenu popupMenu) { @@ -865,6 +947,10 @@ public abstract class WEditor implements EventListener, PropertyChangeLis popupMenu.appendChild(editor); } + /** + * @param comp + * @return true if comp is own by this editor instance + */ public boolean isComponentOfEditor(Component comp) { if (comp == getComponent()) return true; @@ -903,24 +989,38 @@ public abstract class WEditor implements EventListener, PropertyChangeLis return false; } + /** + * @return true if editor is use for process parameter field + */ public boolean isProcessParameter() { return isProcessParameter; } + /** + * Set to true if editor is use for process parameter field + * @param isProcessParameter + */ public void setProcessParameter(boolean isProcessParameter) { this.isProcessParameter = isProcessParameter; } /** - * return component use for display value in grid view mode in non edit status - * if return null, a label will replace. - * because each row must has one instance of this component, don't cache it. just create new instance - * @return + * Return component use for display mode in {@link ADTabpanel} grid view ({@link GridTabRowRenderer}) or custom editor + * of {@link WListItemRenderer}.
+ * For {@link GridTabRowRenderer}, only {@link Html} is supported and will use content + * from {@link #getDisplayTextForGridView(GridRowCtx, Object)}.
+ * For {@link WListItemRenderer}, {@link Html}, {@link Label} and {@link InputElement} is supported.
+ * Return null to use the default of {@link ADTabpanel} or {@link WListbox}.
+ * Note: because each row must has one instance of this component, don't reuse, must always create new instance.
+ * @return Display {@link Component} */ public Component getDisplayComponent() { return null; } + /** + * Set focus to next editor + */ protected void focusNext() { Component comp = getComponent(); Component parent = comp.getParent(); @@ -933,6 +1033,10 @@ public abstract class WEditor implements EventListener, PropertyChangeLis } } + /** + * Return Evaluatee for {@link #buildStyle(int)} use. + * @return Evaluatee + */ protected Evaluatee getStyleEvaluatee() { return new EvaluateeWrapper(this, gridField, tableEditor); } @@ -987,24 +1091,23 @@ public abstract class WEditor implements EventListener, PropertyChangeLis } /** - * add listener - * @param listener + * add listener for {@link #dynamicDisplay(Properties)} + * @param listener {@link DynamicDisplayListener} */ public void addDynamicDisplayListener(DynamicDisplayListener listener) { dynamicDisplayListeners.add(listener); } /** - * - * @param listener - * @return true if listener is found and remove from listener list + * @param listener {@link DynamicDisplayListener} + * @return true if listener is found and remove from listener list ({@link #dynamicDisplayListeners}). */ public boolean removeDynamicDisplayListener(DynamicDisplayListener listener) { return dynamicDisplayListeners.remove(listener); } /** - * interface for dynamic display event + * interface for dynamic display listener */ public static interface DynamicDisplayListener { /** diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditorPopupMenu.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditorPopupMenu.java index 29cafdd308..7b1fa63ff7 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditorPopupMenu.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WEditorPopupMenu.java @@ -41,7 +41,7 @@ import org.zkoss.zk.ui.event.Events; import org.zkoss.zul.Menuitem; /** - * + * Popup context menu for {@link WEditor}. * @author Ashley G Ramdass * @date Mar 25, 2007 * @version $Revision: 0.10 $ @@ -49,16 +49,17 @@ import org.zkoss.zul.Menuitem; public class WEditorPopupMenu extends Menupopup implements EventListener { /** - * + * generated serial id */ private static final long serialVersionUID = 6190279880520042885L; + /** Menu item attribute to store context menu event name (zoom, requery, etc) */ public static final String EVENT_ATTRIBUTE = "EVENT"; public static final String ZOOM_EVENT = "ZOOM"; public static final String REQUERY_EVENT = "REQUERY"; public static final String PREFERENCE_EVENT = "VALUE_PREFERENCE"; public static final String NEW_EVENT = "NEW_RECORD"; - public static final String UPDATE_EVENT = "UPDATE_RECORD"; // Elaine 2009/02/16 - update record + public static final String UPDATE_EVENT = "UPDATE_RECORD"; public static final String SHOWLOCATION_EVENT = "SHOW_LOCATION"; public static final String CHANGE_LOG_EVENT = "CHANGE_LOG"; public static final String EDITOR_EVENT = "EDITOR"; @@ -67,7 +68,7 @@ public class WEditorPopupMenu extends Menupopup implements EventListener public static final String DRILL_EVENT = "DRILL"; private boolean newEnabled = true; - private boolean updateEnabled = true; // Elaine 2009/02/16 - update record + private boolean updateEnabled = true; private boolean zoomEnabled = true; private boolean requeryEnabled = true; private boolean preferencesEnabled = true; @@ -78,15 +79,20 @@ public class WEditorPopupMenu extends Menupopup implements EventListener private Menuitem requeryItem; private Menuitem prefItem; private Menuitem newItem; - private Menuitem updateItem; // Elaine 2009/02/16 - update record + private Menuitem updateItem; private Menuitem showLocationItem; private Menuitem drillItem; private ArrayList menuListeners = new ArrayList(); + /** + * @param zoom + * @param requery + * @param preferences + */ public WEditorPopupMenu(boolean zoom, boolean requery, boolean preferences) { - this(zoom, requery, preferences, false, false, false, false, null); // no check zoom + this(zoom, requery, preferences, false, false, false, false, null); } @Deprecated @@ -107,6 +113,15 @@ public class WEditorPopupMenu extends Menupopup implements EventListener this(zoom, requery, preferences, newRecord, updateRecord, false, null); } + /** + * @param zoom + * @param requery + * @param preferences + * @param newRecord + * @param updateRecord + * @param showLocation + * @param lookup + */ public WEditorPopupMenu(boolean zoom, boolean requery, boolean preferences, boolean newRecord, boolean updateRecord, boolean showLocation, Lookup lookup) { this(zoom, requery, preferences, newRecord, updateRecord, showLocation, false, lookup); @@ -119,6 +134,7 @@ public class WEditorPopupMenu extends Menupopup implements EventListener * @param newRecord - enable new record (ignored and recalculated if lookup is received) * @param updateRecord - enable update record (ignored and recalculated if lookup is received) * @param showLocation - enable show location in menu + * @param drillEnabled - enable drill assistant menu * @param lookup - when this parameter is received then new and update are calculated based on the zoom and quickentry */ public WEditorPopupMenu(boolean zoom, boolean requery, boolean preferences, boolean newRecord, boolean updateRecord, boolean showLocation, boolean drillEnabled, Lookup lookup) @@ -128,7 +144,7 @@ public class WEditorPopupMenu extends Menupopup implements EventListener this.requeryEnabled = requery; this.preferencesEnabled = preferences; this.newEnabled = newRecord; - this.updateEnabled = updateRecord; // Elaine 2009/02/16 - update record + this.updateEnabled = updateRecord; this.showLocation = showLocation; this.drillEnabled = drillEnabled; @@ -182,7 +198,13 @@ public class WEditorPopupMenu extends Menupopup implements EventListener init(); } - boolean hasQuickEntryField(int winID, int winIDPO, String tableName) { + /** + * @param winID + * @param winIDPO + * @param tableName + * @return true if window has quick entry fields (i.e AD_Field.IsQuickEntry=Y) + */ + protected boolean hasQuickEntryField(int winID, int winIDPO, String tableName) { return DB.getSQLValueEx(null, "SELECT COUNT(*) " + "FROM AD_Field f " @@ -197,10 +219,16 @@ public class WEditorPopupMenu extends Menupopup implements EventListener winID,winIDPO,tableName) > 0; } + /** + * @return true if zoom is enable + */ public boolean isZoomEnabled() { return zoomEnabled; } + /** + * Init context menu items + */ private void init() { if (zoomEnabled) @@ -256,7 +284,6 @@ public class WEditorPopupMenu extends Menupopup implements EventListener this.appendChild(newItem); } - // Elaine 2009/02/16 - update record if (updateEnabled) { updateItem = new Menuitem(); @@ -297,12 +324,17 @@ public class WEditorPopupMenu extends Menupopup implements EventListener } } + /** + * Add context menu listener + * @param listener {@link ContextMenuListener} + */ public void addMenuListener(ContextMenuListener listener) { if (!menuListeners.contains(listener)) menuListeners.add(listener); } + @Override public void onEvent(Event event) { String evt = (String)event.getTarget().getAttribute(EVENT_ATTRIBUTE); @@ -320,6 +352,10 @@ public class WEditorPopupMenu extends Menupopup implements EventListener } } + /** + * Add field suggestion context menu item + * @param field + */ public void addSuggestion(final GridField field) { if (!MRole.getDefault().isTableAccessExcluded(MFieldSuggestion.Table_ID)) { Menuitem editor = new Menuitem(Msg.getElement(Env.getCtx(), "AD_FieldSuggestion_ID")); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WFileDirectoryEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WFileDirectoryEditor.java index 7d95739a95..b022295944 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WFileDirectoryEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WFileDirectoryEditor.java @@ -21,12 +21,14 @@ import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.theme.ThemeManager; import org.compiere.model.GridField; import org.compiere.util.CLogger; +import org.compiere.util.DisplayType; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; /** - * + * Default editor for {@link DisplayType#FilePath}.
+ * Implemented with {@link FilenameBox} (with upload disable) and {@link FolderBrowser} component. * @author Low Heng Sin * */ @@ -37,6 +39,7 @@ public class WFileDirectoryEditor extends WEditor @SuppressWarnings("unused") private static final CLogger log = CLogger.getCLogger(WFileDirectoryEditor.class); + /** absolute folder/directory path */ private String oldValue; /** @@ -109,6 +112,7 @@ public class WFileDirectoryEditor extends WEditor getComponent().setEnabled(readWrite); } + @Override public void onEvent(Event event) { String newValue = null; @@ -134,6 +138,10 @@ public class WFileDirectoryEditor extends WEditor processNewValue(newValue); } + /** + * Process newValue from user input + * @param newValue + */ protected void processNewValue(String newValue) { if (oldValue != null && newValue != null && oldValue.equals(newValue)) { return; @@ -146,7 +154,7 @@ public class WFileDirectoryEditor extends WEditor } /** - * Load file + * Open folder selection dialog ({@link FolderBrowser}. */ private void cmd_file() { @@ -162,6 +170,7 @@ public class WFileDirectoryEditor extends WEditor }); } // cmd_file + @Override public String[] getEvents() { return LISTENER_EVENTS; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WFilenameEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WFilenameEditor.java index 668ad7ba18..428c6027d3 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WFilenameEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WFilenameEditor.java @@ -27,13 +27,15 @@ import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.theme.ThemeManager; import org.compiere.model.GridField; import org.compiere.util.CLogger; +import org.compiere.util.DisplayType; import org.zkoss.util.media.Media; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.UploadEvent; /** - * + * Default editor for {@link DisplayType#FileName}.
+ * Implemented with {@link FilenameBox} component with upload enabled. * @author Low Heng Sin * */ @@ -43,6 +45,7 @@ public class WFilenameEditor extends WEditor private static final CLogger log = CLogger.getCLogger(WFilenameEditor.class); + /** absolute folder path + file name */ private String oldValue; /** @@ -117,6 +120,7 @@ public class WFilenameEditor extends WEditor getComponent().setEnabled(readWrite); } + @Override public void onEvent(Event event) { String newValue = null; @@ -140,6 +144,10 @@ public class WFilenameEditor extends WEditor processNewValue(newValue); } + /** + * Process newValue from user input + * @param newValue + */ protected void processNewValue(String newValue) { if (oldValue != null && newValue != null && oldValue.equals(newValue)) { return; @@ -151,13 +159,14 @@ public class WFilenameEditor extends WEditor fireValueChange(changeEvent); } + /** + * Process uploaded file from file selection dialog + * @param file {@link Media} + */ private void processUploadMedia(Media file) { if (file == null) return; - // String fileName = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + ; - // File tempFile = new File(fileName); - FileOutputStream fos = null; String fileName = null; try { @@ -203,6 +212,7 @@ public class WFilenameEditor extends WEditor processNewValue(getComponent().getText()); } + @Override public String[] getEvents() { return LISTENER_EVENTS; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WHtmlEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WHtmlEditor.java index c8000067bd..9f7f2cbaad 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WHtmlEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WHtmlEditor.java @@ -41,10 +41,9 @@ import org.zkoss.zul.Html; /** - * HTML Editor - *

Implementation of an editor to show HTML content

- * - * Based on contribution from + * Default editor for html (AD_Field.IsHtml=Y) text display type (String, PrinterName, Text, TextLong and Memo).
+ * Implemented with {@link Html} component and html editor dialog ({@link WTextEditorDialog}) to show and edit HTML content. + * * @author muriloht (muriloht@devcoffee.com.br, http://www.devcoffee.com.br) * @version $Id: WHTMLEditor.java, v1.0 11/11/2014 20:25:06, muriloht Exp $ */ @@ -55,7 +54,7 @@ public class WHtmlEditor extends WEditor implements ContextMenuListener private AbstractADWindowContent adwindowContent; - /** HTML Model */ + /** HTML component */ private Html box = null; private boolean m_mandatory; @@ -91,6 +90,9 @@ public class WHtmlEditor extends WEditor implements ContextMenuListener return (Div) component; } + /** + * Init component and context menu. + */ private void init() { if (log.isLoggable(Level.INFO)) log.info("Initializing component"); @@ -133,7 +135,6 @@ public class WHtmlEditor extends WEditor implements ContextMenuListener return m_mandatory; } - @Override public void setMandatory(boolean mandatory) { @@ -198,6 +199,9 @@ public class WHtmlEditor extends WEditor implements ContextMenuListener } } + /** + * Open text and html editor dialog ({@link WTextEditorDialog}. + */ private void editorEvent() { adwindowContent = findADWindowContent(); final WTextEditorDialog dialog = new WTextEditorDialog(gridField.getVO().Header, getDisplay(), @@ -230,6 +234,9 @@ public class WHtmlEditor extends WEditor implements ContextMenuListener dialog.focus(); } + /** + * @return AbstractADWindowContent that own the component of this editor instance + */ private AbstractADWindowContent findADWindowContent() { Component parent = getComponent().getParent(); while(parent != null) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WImageEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WImageEditor.java index c9ceae914b..5a42eb0aa6 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WImageEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WImageEditor.java @@ -23,6 +23,7 @@ import org.adempiere.webui.window.WImageDialog; import org.compiere.model.GridField; import org.compiere.model.MImage; import org.compiere.util.CLogger; +import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.zkoss.image.AImage; import org.zkoss.zk.ui.Component; @@ -34,10 +35,9 @@ import org.zkoss.zul.Cell; import org.zkoss.zul.Image; /** - * This class is based on org.compiere.grid.ed.VImage written by Jorg Janke. - * @author Jorg Janke + * Default editor for {@link DisplayType#Image}.
+ * Implemented with {@link Image} component and {@link WImageDialog}. * - * Modifications - UI Compatibility * @author Low Heng Sin */ public class WImageEditor extends WEditor @@ -94,6 +94,9 @@ public class WImageEditor extends WEditor return (Image) component; } + /** + * Init component + */ private void init() { AImage img = null; @@ -189,6 +192,7 @@ public class WImageEditor extends WEditor return LISTENER_EVENTS; } + @Override public void onEvent(Event event) throws Exception { if (Events.ON_CLICK.equals(event.getName()) && readwrite) @@ -221,8 +225,8 @@ public class WImageEditor extends WEditor } } - /* (non-Javadoc) - * @see org.adempiere.webui.editor.WEditor#fillHorizontal() + /** + * No op., doesn't support stretch of component. */ @Override public void fillHorizontal() { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WLocationEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WLocationEditor.java index 712346e535..f1dac7247e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WLocationEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WLocationEditor.java @@ -17,7 +17,6 @@ package org.adempiere.webui.editor; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.logging.Level; @@ -38,6 +37,7 @@ import org.compiere.model.GridField; import org.compiere.model.MLocation; import org.compiere.model.MLocationLookup; import org.compiere.util.CLogger; +import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.compiere.util.Msg; import org.zkoss.zk.ui.event.Event; @@ -46,11 +46,12 @@ import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.OpenEvent; /** + * Default editor for {@link DisplayType#Location}.
+ * Implemented with {@link Locationbox} component and {@link WLocationDialog}. * @author Sendy Yagambrum * @date July 16, 2007 * - * This class is based on VLocation written by Jorg Janke - **/ + */ public class WLocationEditor extends WEditor implements EventListener, PropertyChangeListener, ContextMenuListener, IZoomableEditor { private static final String[] LISTENER_EVENTS = {Events.ON_CLICK}; @@ -97,6 +98,9 @@ public class WLocationEditor extends WEditor implements EventListener, Pr init(); } + /** + * Init component and context menu + */ private void init() { if (ThemeManager.isUseFontIconForImage()) @@ -164,7 +168,7 @@ public class WLocationEditor extends WEditor implements EventListener, Pr /** * Return Editor value - * @return value + * @return C_Location_ID */ public int getC_Location_ID() { @@ -172,23 +176,13 @@ public class WLocationEditor extends WEditor implements EventListener, Pr return 0; return m_value.getC_Location_ID(); } - - /** - * Property Change Listener - * @param evt PropertyChangeEvent - */ - public void propertyChange (PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } - + + @Override public void onEvent(Event event) throws Exception { - // if ("onClick".equals(event.getName())) { - if (log.isLoggable(Level.CONFIG)) log.config( "actionPerformed - " + m_value); + if (log.isLoggable(Level.CONFIG)) log.config( "onEvent - " + m_value); final WLocationDialog ld = new WLocationDialog(Msg.getMsg(Env.getCtx(), "Location"), m_value, gridField); final int oldValue = m_value == null ? 0 : m_value.getC_Location_ID(); ld.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener() { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WLocatorEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WLocatorEditor.java index 74cf693165..36cdb037b5 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WLocatorEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WLocatorEditor.java @@ -19,7 +19,6 @@ package org.adempiere.webui.editor; import static org.compiere.model.SystemIDs.WINDOW_WAREHOUSE_LOCATOR; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -50,6 +49,7 @@ import org.compiere.model.MWarehouse; import org.compiere.model.X_M_MovementLine; import org.compiere.util.CLogger; import org.compiere.util.DB; +import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.compiere.util.Msg; import org.zkoss.zk.ui.event.Event; @@ -57,25 +57,26 @@ import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; /** - * Locator Editor : Based on VLocator + * Default editor for {@link DisplayType#Locator}.
+ * Implemented with {@link EditorBox} component and {@link WLocatorDialog}. * * @author Niraj Sohun * @date Jul 23, 2007 */ - public class WLocatorEditor extends WEditor implements EventListener, PropertyChangeListener, ContextMenuListener, IZoomableEditor { private static final String[] LISTENER_EVENTS = {Events.ON_CLICK}; private MLocatorLookup m_mLocator; + /** M_Locator_ID */ private Object m_value; private int m_WindowNo; private static final CLogger log = CLogger.getCLogger(WLocatorEditor.class); - /** - * IDE Constructor - */ + /** + * Default Constructor + */ public WLocatorEditor() { this("M_Locator_ID", false, false, true, null, 0); @@ -90,8 +91,7 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro * @param isUpdateable updateable * @param mLocator locator (lookup) model * @param windowNo window no - */ - + */ public WLocatorEditor( String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, MLocatorLookup mLocator, int windowNo) { @@ -105,8 +105,8 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro getComponent().setButtonImage(ThemeManager.getThemeResource("images/Locator16.png")); getComponent().getTextbox().setReadonly(true); - m_WindowNo = windowNo; //Yvonne: move it b4 setDefault_Locator_ID() - setDefault_Locator_ID(); // set default locator, teo_sarca [ 1661546 ] + m_WindowNo = windowNo; + setDefault_Locator_ID(); } /** @@ -133,7 +133,7 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro getComponent().setButtonImage(ThemeManager.getThemeResource("images/Locator16.png")); getComponent().getTextbox().setReadonly(true); - setDefault_Locator_ID(); // set default locator, teo_sarca [ 1661546 ] + setDefault_Locator_ID(); m_WindowNo = gridField.getWindowNo(); @@ -145,6 +145,10 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro } } + /** + * @param value + */ + @Override public void setValue(Object value) { setValue (value, false); @@ -152,10 +156,9 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro /** * Set Value - * @param value value - * @param fire data binding - */ - + * @param value new value + * @param fire true to fire value change event + */ private void setValue (Object value, boolean fire) { if(m_mLocator==null) @@ -186,8 +189,7 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro /** * Return Editor value * @return value - */ - + */ public Object getValue() { if (getM_Locator_ID() == 0) @@ -214,9 +216,8 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro /** * Get M_Locator_ID - * @return id - */ - + * @return M_Locator_ID + */ public int getM_Locator_ID() { if (m_value != null @@ -227,15 +228,16 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro } // getM_Locator_ID /** - * Return Display Value - * @return display value + * Return Display text + * @return display text */ - + @Override public String getDisplay() { return getComponent().getText(); } // getDisplay + @Override public void onEvent(Event event) throws Exception { if (Events.ON_CLICK.equalsIgnoreCase(event.getName())) @@ -244,15 +246,13 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro int only_Warehouse_ID = getOnly_Warehouse_ID(); int only_Product_ID = getOnly_Product_ID(); - if (log.isLoggable(Level.CONFIG)) log.config("Only Warehouse_ID=" + only_Warehouse_ID + ", Product_ID=" + only_Product_ID); + if (log.isLoggable(Level.CONFIG)) log.config("Only Warehouse_ID=" + only_Warehouse_ID + ", Only Product_ID=" + only_Product_ID); - // Text Entry ok - + // Text Entry ok if (event.getTarget() == getComponent() && actionText(only_Warehouse_ID, only_Product_ID)) return; - // Button - Start Dialog - + // Button - Start Dialog int M_Locator_ID = 0; if (m_value instanceof Integer) @@ -268,8 +268,7 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro @Override public void onEvent(Event event) throws Exception { m_mLocator.setOnly_Warehouse_ID(0); - // redisplay - + // redisplay if (!ld.isChanged()) return; setValue (ld.getValue(), true); @@ -300,6 +299,9 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro } } + /** + * Refresh MLocator lookup + */ public void actionRefresh() { if (m_mLocator != null) @@ -315,13 +317,12 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro } } + @Override public void actionZoom() { int AD_Window_ID = MTable.get(Env.getCtx(), MLocator.Table_ID).getAD_Window_ID(); if (AD_Window_ID <= 0) AD_Window_ID = WINDOW_WAREHOUSE_LOCATOR; // hardcoded window Warehouse & Locators - log.info(""); - // MQuery zoomQuery = new MQuery(); zoomQuery.addRestriction(MLocator.COLUMNNAME_M_Locator_ID, MQuery.EQUAL, getValue()); @@ -330,6 +331,7 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro AEnv.zoom(AD_Window_ID, zoomQuery); } + @Override public void onMenu(ContextMenuEvent evt) { if (WEditorPopupMenu.REQUERY_EVENT.equals(evt.getContextEvent())) @@ -352,19 +354,18 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro } /** - * Hit Enter in Text Field + * Process input text from user * @param only_Warehouse_ID if not 0 restrict warehouse * @param only_Product_ID of not 0 restricted product * @return true if found - */ - + */ private boolean actionText(int only_Warehouse_ID, int only_Product_ID) { String text = getComponent().getText(); - log.fine(text); - - // Null + if (log.isLoggable(Level.FINE)) + log.fine(text); + // Null if (text == null || text.length() == 0) { if (isMandatory()) @@ -381,8 +382,7 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro else text = text.toUpperCase() + "%"; - // Look up - see MLocatorLookup.run - + // Look up - see MLocatorLookup.run StringBuffer sql = new StringBuffer("SELECT M_Locator_ID FROM M_Locator ") .append(" WHERE IsActive='Y' AND UPPER(Value) LIKE ") .append(DB.TO_STRING(text)); @@ -457,7 +457,7 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro * Set Field/WindowNo for ValuePreference (NOP) * @param mField Model Field */ - + @Deprecated(forRemoval = true, since = "11") public void setField (org.compiere.model.GridField mField) { } // setField @@ -465,8 +465,7 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro /** * Get Warehouse restriction if any. * @return M_Warehouse_ID or 0 - */ - + */ protected int getOnly_Warehouse_ID() { //IDEMPIERE-4882 : Load Locator To field value as per Warehouse TO field value @@ -495,6 +494,7 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro } catch (Exception ex) { + log.log(Level.WARNING, ex.getMessage(), ex); } return only_Warehouse_ID; @@ -503,8 +503,7 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro /** * Get Product restriction if any. * @return M_Product_ID or 0 - */ - + */ protected int getOnly_Product_ID() { if (!Env.isSOTrx(Env.getCtx(), m_WindowNo)) @@ -528,6 +527,7 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro } catch (Exception ex) { + log.log(Level.WARNING, ex.getMessage(), ex); } return only_Product_ID; } // getOnly_Product_ID @@ -537,12 +537,10 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro * and we have a warehouse restriction. * * @since 3.1.4 - */ - + */ private void setDefault_Locator_ID() { - // teo_sarca, FR [ 1661546 ] Mandatory locator fields should use defaults - + // teo_sarca, FR [ 1661546 ] Mandatory locator fields should use defaults if (!isMandatory() || m_mLocator == null) { return; @@ -572,20 +570,10 @@ public class WLocatorEditor extends WEditor implements EventListener, Pro setValue(Integer.valueOf(loc.get_ID())); } - /** - * Property Change Listener - * @param evt PropertyChangeEvent - */ - - public void propertyChange (PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } - /** * return listener events to be associated with editor component */ + @Override public String[] getEvents() { return LISTENER_EVENTS; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java index 1a41bd4336..1d357c485b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java @@ -38,7 +38,9 @@ import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Events; /** - * + * Default editor for {@link DisplayType#ID} and {@link DisplayType#isNumeric(int)}.
+ * Implemented with {@link NumberBox}. + * * @author Ashley G Ramdass * @date Mar 11, 2007 * @version $Revision: 0.10 $ @@ -55,30 +57,34 @@ public class WNumberEditor extends WEditor implements ContextMenuListener public static final int MAX_DISPLAY_LENGTH = 35; public static final int MIN_DISPLAY_LENGTH = 11; + /** Integer or BigDecimal */ private Object oldValue; private int displayType; private String originalStyle; + /** + * Default constructor, default to {@link DisplayType#Number}. + */ public WNumberEditor() { this(DisplayType.Number); } /** - * - * @param displayType - */ + * + * @param displayType + */ public WNumberEditor(int displayType) { this("Number", false, false, true, displayType, ""); } /** - * - * @param gridField - */ + * + * @param gridField + */ public WNumberEditor(GridField gridField) { this(gridField, false, null); @@ -107,6 +113,13 @@ public class WNumberEditor extends WEditor implements ContextMenuListener init(); } + /** + * Create new {@link NumberBox} instance. + * @param gridField + * @param tableEditor + * @param editorConfiguration + * @return NumberBox + */ protected static NumberBox newNumberBox(GridField gridField, boolean tableEditor, IEditorConfiguration editorConfiguration) { if (editorConfiguration != null && editorConfiguration instanceof INumberEditorConfiguration) { INumberEditorConfiguration config = (INumberEditorConfiguration) editorConfiguration; @@ -119,7 +132,7 @@ public class WNumberEditor extends WEditor implements ContextMenuListener /** * * @param gridField - * @param integral + * @param integral true to create NumberBox for DisplayType.Integer */ public WNumberEditor(GridField gridField, boolean integral) { @@ -153,6 +166,9 @@ public class WNumberEditor extends WEditor implements ContextMenuListener init(); } + /** + * Init component and context menu + */ private void init() { setChangeEventWhenEditing (true); @@ -166,8 +182,6 @@ public class WNumberEditor extends WEditor implements ContextMenuListener displayLength = MIN_DISPLAY_LENGTH; if (!tableEditor) getComponent().getDecimalbox().setCols(displayLength); -// else -// getComponent().getDecimalbox().setCols(0); } if (DisplayType.isID(displayType)) @@ -199,6 +213,7 @@ public class WNumberEditor extends WEditor implements ContextMenuListener * Event handler * @param event */ + @Override public void onEvent(Event event) { if (Events.ON_CHANGE.equalsIgnoreCase(event.getName()) || Events.ON_OK.equalsIgnoreCase(event.getName())) @@ -238,7 +253,9 @@ public class WNumberEditor extends WEditor implements ContextMenuListener /** * IDEMPIERE-2553 - Enter amounts without decimal separator * @param oldValue - * @return + * @return oldValue (if oldValue is already with decimal point)
+ * or oldValue divided by AutomaticDecimalPlacesForAmoun value from Env context + * (for e.g, if AutomaticDecimalPlacesForAmoun=2, oldValue/100) */ public BigDecimal addDecimalPlaces(BigDecimal oldValue){ if(oldValue.toString().contains(".")) @@ -257,8 +274,11 @@ public class WNumberEditor extends WEditor implements ContextMenuListener divisor = BigDecimal.TEN.pow(decimalPlaces); BigDecimal newValue = oldValue.divide(divisor, decimalPlaces, RoundingMode.HALF_UP); return newValue; - } //getAddDecimalPlaces + } //addDecimalPlaces + /** + * @return NumberBox + */ @Override public NumberBox getComponent() { return (NumberBox) component; @@ -310,6 +330,7 @@ public class WNumberEditor extends WEditor implements ContextMenuListener * Handle context menu events * @param evt */ + @Override public void onMenu(ContextMenuEvent evt) { if (WEditorPopupMenu.PREFERENCE_EVENT.equals(evt.getContextEvent())) @@ -330,8 +351,9 @@ public class WNumberEditor extends WEditor implements ContextMenuListener getComponent().setTableEditorMode(b); } - /* (non-Javadoc) - * @see org.adempiere.webui.editor.WEditor#setFieldStyle(java.lang.String) + /** + * Set field style to Decimalbox inside {@link NumberBox}. + * @param style */ @Override protected void setFieldStyle(String style) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPAttributeEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPAttributeEditor.java index 117a68bee4..dc7085da16 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPAttributeEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPAttributeEditor.java @@ -31,14 +31,17 @@ import org.adempiere.webui.window.WPAttributeDialog; import org.compiere.model.GridField; import org.compiere.model.GridTab; import org.compiere.model.Lookup; +import org.compiere.model.MPAttributeLookup; import org.compiere.util.CLogger; +import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; /** - * + * Default editor for {@link DisplayType#PAttribute}.
+ * Implemented with {@link PAttributebox} component and {@link WPAttributeDialog} dialog. * @author Low Heng Sin * */ @@ -50,10 +53,12 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener protected int m_WindowNo; + /** {@link MPAttributeLookup} */ protected Lookup m_mPAttribute; protected int m_C_BPartner_ID; - + + /** M_AttributeSetInstance_ID */ protected Object m_value; /** No Instance Key */ @@ -83,12 +88,14 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener initComponents(); } + /** + * Init component and context menu + */ private void initComponents() { if (ThemeManager.isUseFontIconForImage()) getComponent().getButton().setIconSclass("z-icon-PAttribute"); else getComponent().setButtonImage(ThemeManager.getThemeResource("images/PAttribute16.png")); - // getComponent().addEventListener(Events.ON_CLICK, this); // IDEMPIERE-426 - dup listener, already set at WEditor m_WindowNo = gridField.getWindowNo(); m_mPAttribute = gridField.getLookup(); @@ -141,6 +148,7 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener return getComponent().getText(); } + @Override public void onEvent(Event event) { if (Events.ON_CHANGE.equals(event.getName()) || Events.ON_OK.equals(event.getName())) @@ -169,11 +177,10 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener } /** - * Start dialog + * Open {@link WPAttributeDialog} */ private void cmd_dialog() { - // Integer oldValue = (Integer)getValue (); final int oldValueInt = oldValue == null ? 0 : oldValue.intValue (); int M_AttributeSetInstance_ID = oldValueInt; @@ -247,6 +254,11 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener } } // cmd_dialog + /** + * Process new M_AttributeSetInstance_ID from {@link WPAttributeDialog}. + * @param oldValueInt + * @param M_AttributeSetInstance_ID + */ private void processChanges(int oldValueInt, int M_AttributeSetInstance_ID) { if (log.isLoggable(Level.FINEST)) log.finest("Changed M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID); m_value = new Object(); // force re-query display @@ -264,11 +276,13 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener } } + @Override public String[] getEvents() { return LISTENER_EVENTS; } + @Override public void onMenu(ContextMenuEvent evt) { if (WEditorPopupMenu.ZOOM_EVENT.equals(evt.getContextEvent())) @@ -281,6 +295,9 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener } } + /** + * Zoom to record of {@link #getValue()}. + */ public void actionZoom() { AEnv.actionZoom(m_mPAttribute, getValue()); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPasswordEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPasswordEditor.java index d470a1d24c..d82809d0e9 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPasswordEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPasswordEditor.java @@ -17,17 +17,21 @@ package org.adempiere.webui.editor; +import org.adempiere.webui.component.Textbox; import org.compiere.model.GridField; /** - * + * Default editor for encrypted (AD_Field.IsEncrypted=Y) text display type (String, PrinterName, Text, TextLong and Memo).
+ * Extend {@link WStringEditor} and set {@link Textbox} to type="password". * @author Ashley G Ramdass * @date Mar 12, 2007 * @version $Revision: 0.10 $ */ public class WPasswordEditor extends WStringEditor -{ - +{ + /** + * Default constructor + */ public WPasswordEditor() { super(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPaymentEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPaymentEditor.java index 518d0c4202..3f1fe2b353 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPaymentEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPaymentEditor.java @@ -45,7 +45,8 @@ import org.zkoss.zk.ui.event.Events; import org.zkoss.zul.Comboitem; /** - * + * Default editor for {@link DisplayType#Payment}.
+ * Implemented with {@link Paymentbox} component, {@link WPaymentFormWindow} and {@link IPaymentForm} service. * @author Elaine * */ @@ -56,6 +57,8 @@ public class WPaymentEditor extends WEditor implements ListDataListener, Context public final static String[] LISTENER_EVENTS = {Events.ON_SELECT}; private MPaymentLookup lookup; + + /** Payment rule (Cash, credit card, etc) */ private Object oldValue; /** @@ -78,6 +81,9 @@ public class WPaymentEditor extends WEditor implements ListDataListener, Context init(); } + /** + * Init component and context menu + */ private void init() { getComponent().getCombobox().setAutocomplete(true); @@ -213,6 +219,9 @@ public class WPaymentEditor extends WEditor implements ListDataListener, Context getComponent().setEnabled(readWrite, readWrite && !m_onlyRule); } + /** + * Refresh lookup list + */ private void refreshList() { if (getComponent().getCombobox().getItemCount() > 0) @@ -368,17 +377,23 @@ public class WPaymentEditor extends WEditor implements ListDataListener, Context @Override public void intervalRemoved(javax.swing.event.ListDataEvent e) {} + /** + * @param newValue + * @return true if newValue is different from {@link #oldValue} + */ private boolean isValueChange(Object newValue) { return (oldValue == null && newValue != null) || (oldValue != null && newValue == null) || ((oldValue != null && newValue != null) && !oldValue.equals(newValue)); } + @Override public String[] getEvents() { return LISTENER_EVENTS; } - /* (non-Javadoc) - * @see org.adempiere.webui.editor.WEditor#setFieldStyle(java.lang.String) + /** + * Set style to combobox inside {@link Paymentbox} + * @param style */ @Override protected void setFieldStyle(String style) { @@ -404,6 +419,9 @@ public class WPaymentEditor extends WEditor implements ListDataListener, Context } } + /** + * Refresh lookup list + */ public void actionRefresh() { if (lookup != null) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WRadioGroupEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WRadioGroupEditor.java index 52cc2a3809..064ce50d51 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WRadioGroupEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WRadioGroupEditor.java @@ -20,7 +20,6 @@ package org.adempiere.webui.editor; -import java.beans.PropertyChangeEvent; import java.math.BigDecimal; import java.sql.Timestamp; import java.util.List; @@ -59,7 +58,8 @@ import org.zkoss.zul.Radio; import org.zkoss.zul.Radiogroup; /** - * + * Default editor for {@link DisplayType#RadiogroupList}.
+ * Implemented with {@link RadioGroupEditor} component. * @author hengsin * */ @@ -76,8 +76,10 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L } private Lookup lookup; + /** selected value */ private Object oldValue; + /** true when editor is handling ON_CHECK event */ private boolean onselecting = false; /** @@ -105,10 +107,10 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L /** * Constructor for use if a grid field is unavailable * - * @param lookup Store of selectable data - * @param label column name (not displayed) + * @param lookup Lookup list + * @param label field label * @param description description of component - * @param mandatory whether a selection must be made + * @param mandatory whether a field is mandatory * @param readonly whether or not the editor is read only * @param updateable whether the editor contents can be changed */ @@ -145,6 +147,9 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L init(); } + /** + * Init lookup and context menu + */ private void init() { boolean zoom= false; @@ -200,6 +205,7 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L return retVal; } + @Override public void setValue(Object value) { if (onselecting) { @@ -293,6 +299,9 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L getComponent().setEnabled(readWrite); } + /** + * Refresh lookup list + */ private void refreshList() { if (getComponent().getItemCount() > 0) @@ -372,6 +381,7 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L getComponent().setValue(oldValue); } + @Override public void onEvent(Event event) { if (Events.ON_CHECK.equalsIgnoreCase(event.getName())) @@ -398,16 +408,24 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L } } + /** + * @param newValue + * @return true if newValue is different from {@link #oldValue} + */ private boolean isValueChange(Object newValue) { return (oldValue == null && newValue != null) || (oldValue != null && newValue == null) || ((oldValue != null && newValue != null) && !oldValue.equals(newValue)); } + @Override public String[] getEvents() { return LISTENER_EVENTS; } + /** + * Refresh lookup list + */ public void actionRefresh() { if (lookup != null) @@ -430,11 +448,15 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L } } + /** + * @return Lookup + */ public Lookup getLookup() { return lookup; } + @Override public void onMenu(ContextMenuEvent evt) { if (WEditorPopupMenu.REQUERY_EVENT.equals(evt.getContextEvent())) @@ -457,14 +479,6 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L } } - public void propertyChange(PropertyChangeEvent evt) - { - if ("FieldValue".equals(evt.getPropertyName())) - { - setValue(evt.getNewValue()); - } - } - @Override public void dynamicDisplay(Properties ctx) { @@ -487,6 +501,9 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L getPopupMenu().addContextElement(getComponent().radioGroup); } + /** + * Container for {@link Radiogroup} and {@link Radio} component. + */ private static class RadioGroupEditor extends Hlayout { /** * generated serial id @@ -495,6 +512,9 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L private Radiogroup radioGroup; private boolean enabled; + /** + * Default constructor + */ private RadioGroupEditor() { newRadioGroup(); appendChild(radioGroup); @@ -503,6 +523,9 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L setStyle("white-space: normal"); } + /** + * Create new {@link Radiogroup} instance. + */ private void newRadioGroup() { radioGroup = new Radiogroup(); } @@ -519,6 +542,10 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L } } + /** + * @param value + * @return true if value equals to value of selected {@link Radio} item. + */ public boolean isSelected(Object value) { Radio radio = getSelectedItem(); if (radio != null && radio.getValue() != null && value != null) { @@ -527,16 +554,26 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L return false; } + /** + * @return selected {@link Radio} item + */ public Radio getSelectedItem() { return radioGroup.getSelectedItem(); } + /** + * Set {@link #radioGroup} selected item to item + * @param item + */ public void setSelectedItem(Radio item) { if (item != null && item.isSelected()) item.setSelected(false); radioGroup.setSelectedItem(item); } + /** + * Remove all {@link Radio} items from {@link #radioGroup} + */ public void removeAllItems() { List items = radioGroup.getItems(); for (Radio radio : items) { @@ -544,6 +581,10 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L } } + /** + * Set selected item by newValue + * @param newValue + */ public void setValue(Object newValue) { boolean found = false; if (newValue != null) { @@ -560,10 +601,18 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L setSelectedItem(null); } + /** + * @return radio item count + */ public int getItemCount() { return radioGroup.getItemCount(); } + /** + * Add new {@link Radio} item + * @param name + * @param value + */ public void appendItem(String name, String value) { if (Util.isEmpty(name)) return; @@ -571,6 +620,12 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L radioGroup.appendChild(radio); } + /** + * Create new {@link Radio} item. + * @param name + * @param value + * @return {@link Radio} + */ protected Radio newRadio(String name, Object value) { Radio radio = new Radio(name); radio.setValue(value); @@ -579,6 +634,11 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L return radio; } + /** + * Add new {@link Radio} item + * @param name + * @param key + */ public void appendItem(String name, int key) { if (Util.isEmpty(name)) return; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WRecordIDEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WRecordIDEditor.java index 145a80555c..3aede6bb0e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WRecordIDEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WRecordIDEditor.java @@ -61,7 +61,9 @@ import org.zkoss.zk.ui.sys.ComponentCtrl; import org.zkoss.zul.Div; /** - * + * Default editor for {@link DisplayType#RecordID} and {@link DisplayType#RecordUU}.
+ * Implemented with composite component of {@link Textbox} and {@link ToolBarButton}.
+ * The editor uses {@link WRecordIDDialog} for edit or viewing. * @author Peter Takacs, Cloudempiere * */ @@ -69,12 +71,12 @@ public class WRecordIDEditor extends WEditor implements ContextMenuListener, IZo /** Is Read/Write enabled on the editor */ private boolean m_ReadWrite; - /** Old value (Record_ID) */ + /** Record_ID or Record_UU value */ private Object recordIDValue; - /** Old value (AD_Table_ID) */ + /** AD_Table_ID value */ private Object tableIDValue; - /** Current tab's AD_Table_ID GrodField */ + /** Current tab's AD_Table_ID GridField */ private GridField tableIDGridField; // UI components @@ -82,7 +84,7 @@ public class WRecordIDEditor extends WEditor implements ContextMenuListener, IZo private ToolBarButton editButton; private ToolBarButton zoomButton; - // images + // image url for toolbar button private static final String IMAGES_CONTEXT_ZOOM_PNG = "images/Zoom16.png"; private static final String IMAGES_CONTEXT_EDIT_RECORD_PNG = "images/EditRecord16.png"; @@ -101,6 +103,9 @@ public class WRecordIDEditor extends WEditor implements ContextMenuListener, IZo init(); } + /** + * Init component and context menu + */ private void init() { if(gridTab != null) { tableIDGridField = gridTab.getField("AD_Table_ID"); @@ -155,6 +160,10 @@ public class WRecordIDEditor extends WEditor implements ContextMenuListener, IZo } } + /** + * Handle AFTER_PAGE_ATTACHED callback to get AD_Table_ID grid field from find window + * @param t + */ private void afterPageAttached(Object t) { if (t instanceof Component) { Component component = (Component) t; @@ -173,25 +182,28 @@ public class WRecordIDEditor extends WEditor implements ContextMenuListener, IZo field = field.clone(gridField.getVO().ctx); field.loadLookupNoValidate(); Lookup lookup = field.getLookup(); - if (lookup != null && lookup instanceof MLookup) - { - MLookup mLookup = (MLookup) lookup; - mLookup.getLookupInfo().tabNo = FindWindow.TABNO; - - if (field.getVO().ValidationCodeLookup != null && !field.getVO().ValidationCodeLookup.isEmpty()) + if (lookup != null && lookup instanceof MLookup) { - mLookup.getLookupInfo().ValidationCode = field.getVO().ValidationCodeLookup; + MLookup mLookup = (MLookup) lookup; + mLookup.getLookupInfo().tabNo = FindWindow.TABNO; + + if (field.getVO().ValidationCodeLookup != null && !field.getVO().ValidationCodeLookup.isEmpty()) + { + mLookup.getLookupInfo().ValidationCode = field.getVO().ValidationCodeLookup; mLookup.getLookupInfo().IsValidated = false; + } } - } - tableIDGridField = field; - if (tableIDValue != null) - tableIDGridField.setValue(tableIDValue, false); + tableIDGridField = field; + if (tableIDValue != null) + tableIDGridField.setValue(tableIDValue, false); } } } } + /** + * Refresh text box display text + */ private void actionRefresh() { recordTextBox.setValue(getDisplay()); @@ -221,7 +233,6 @@ public class WRecordIDEditor extends WEditor implements ContextMenuListener, IZo } } - @Override public void onMenu(ContextMenuEvent evt) { @@ -257,6 +268,7 @@ public class WRecordIDEditor extends WEditor implements ContextMenuListener, IZo return m_ReadWrite; } + @Override public void propertyChange(PropertyChangeEvent evt) { if (GridField.PROPERTY.equals(evt.getPropertyName())) @@ -286,10 +298,9 @@ public class WRecordIDEditor extends WEditor implements ContextMenuListener, IZo /** * Set Value - * @param value value - * @param fire data binding - */ - + * @param value new value + * @param fire true to fire value change event + */ private void setValue (Object value, boolean fire) { if (value == null || Util.isEmpty(value.toString(), true)) { recordTextBox.setValue(""); @@ -453,7 +464,7 @@ public class WRecordIDEditor extends WEditor implements ContextMenuListener, IZo /** * Get AD_Table_ID - * @return Object + * @return AD_Table_ID value */ public Object getAD_Table_ID() { return tableIDValue; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java index 5d7f51245d..cb8d596533 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java @@ -20,7 +20,6 @@ package org.adempiere.webui.editor; import static org.compiere.model.SystemIDs.COLUMN_C_INVOICELINE_M_PRODUCT_ID; import static org.compiere.model.SystemIDs.COLUMN_C_INVOICE_C_BPARTNER_ID; -import java.beans.PropertyChangeEvent; import java.util.Properties; import java.util.logging.Level; @@ -40,6 +39,7 @@ import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeListener; import org.adempiere.webui.factory.InfoManager; import org.adempiere.webui.grid.WQuickEntry; +import org.adempiere.webui.info.InfoWindow; import org.adempiere.webui.panel.IHelpContext; import org.adempiere.webui.panel.InfoPanel; import org.adempiere.webui.part.WindowContainer; @@ -72,8 +72,8 @@ import org.zkoss.zk.ui.event.InputEvent; import org.zkoss.zk.ui.util.Clients; /** - * Search Editor for web UI. - * Web UI port of search type VLookup + * Default editor for {@link DisplayType#Search} and {@link DisplayType#SearchUU}.
+ * Implemented with {@link CustomSearchBox} component and {@link InfoPanel}, {@link InfoWindow} dialog. * * @author Ashley G Ramdass * @@ -82,20 +82,28 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value { private static final int DEFAULT_MAX_AUTO_COMPLETE_ROWS = 500; private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_CHANGE, Events.ON_OK}; + /** Boolean component attribute to store whether info panel is open */ public static final String ATTRIBUTE_IS_INFO_PANEL_OPEN = "ATTRIBUTE_IS_INFO_PANEL_OPEN"; protected Lookup lookup; + /** Reference/target table name */ private String m_tableName = null; + /** Reference/target key column name */ private String m_keyColumnName = null; + /** Source/field column name */ private String columnName; + /** ID or UUID value */ private Object value; protected InfoPanel infoPanel = null; + /** Image URL or font icon sclass for CustomSearchbox button */ private String imageUrl; + /** Model for auto complete search */ private InfoListSubModel listModel = null; private static final CLogger log = CLogger.getCLogger(WSearchEditor.class); private static final String IN_PROGRESS_IMAGE = "~./zk/img/progress3.gif"; + /** ADWindow instance that own this editor */ protected ADWindow adwindow; /** @@ -148,9 +156,9 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value * Constructor for use if a grid field is unavailable * * @param lookup Store of selectable data - * @param label column name (not displayed) + * @param label field label * @param description description of component - * @param mandatory whether a selection must be made + * @param mandatory whether field is mandatory * @param readonly whether or not the editor is read only * @param updateable whether the editor contents can be changed */ @@ -169,6 +177,14 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value init(); } + /** + * + * @param columnName + * @param mandatory + * @param readonly + * @param updateable + * @param lookup + */ public WSearchEditor(String columnName, boolean mandatory, boolean readonly, boolean updateable, Lookup lookup) { @@ -187,8 +203,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value /** - * initialise editor - * @param columnName columnName + * Initialise component and context menu */ private void init() { @@ -327,6 +342,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value return getComponent().getText(); } + @Override public void onEvent(Event e) { if (Events.ON_CHANGE.equals(e.getName())) @@ -354,7 +370,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value && !isQuickFormComp && isReadWrite()) { - // open Info window similar to swing client + // open Info window if (infoPanel != null) { infoPanel.detach(); @@ -376,32 +392,33 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value } } - @Override - public void propertyChange(PropertyChangeEvent evt) - { - if ("FieldValue".equals(evt.getPropertyName())) - { - actionRefresh(evt.getNewValue()); - } - } - + /** + * Refresh editor value + * @param value + */ protected void actionRefresh(Object value) { -// boolean mandatory = isMandatory(); -// AEnv.actionRefresh(lookup, value, mandatory); setValue(value); } + /** + * Zoom to window for reference/target table + */ public void actionZoom() { AEnv.actionZoom(lookup, getValue()); } + /** + * Zoom to window for reference/target table + * @param value + */ private void actionZoom(Object value) { AEnv.actionZoom(lookup, value); } + @Override public void onMenu(ContextMenuEvent evt) { if (WEditorPopupMenu.REQUERY_EVENT.equals(evt.getContextEvent())) @@ -427,7 +444,6 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value } actionQuickEntry(true); } - // Elaine 2009/02/16 - update record else if (WEditorPopupMenu.UPDATE_EVENT.equals(evt.getContextEvent())) { if (infoPanel != null) @@ -445,9 +461,12 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value { actionDrill(); } - // } + /** + * Process text input from user + * @param text + */ protected void actionText(String text) { // Nothing entered @@ -464,6 +483,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value if (m_tableName == null) // sets table name & key column setTableAndKeyColumn(); + // process input text with infopanel/infowindow final InfoPanel ip = InfoManager.create(lookup, gridField, m_tableName, m_keyColumnName, getComponent().getText(), false, getWhereClause()); if (ip != null && ip.loadedOK() && ip.getRowCount() == 1) { @@ -516,6 +536,9 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value resetButtonState(); } // actionText + /** + * Open drill assistant dialog + */ protected void actionDrill() { if(getGridField() == null || getGridField().getGridTab() == null) return; @@ -530,6 +553,9 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value AEnv.actionDrill(data, windowNo); } + /** + * Reset state of {@link CustomSearchBox} button to default + */ protected void resetButtonState() { getComponent().getButton().setEnabled(true); if (ThemeManager.isUseFontIconForImage()) @@ -539,7 +565,11 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value getComponent().invalidate(); } - + /** + * Process value from InfoPanel/InfoWindow.
+ * Fire ValueChangeEvent. + * @param value + */ protected void actionCombo (Object value) { if (log.isLoggable(Level.FINE)) @@ -640,8 +670,6 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value setValue(Integer.valueOf(result)); actionCombo (Integer.valueOf(result)); // data binding lookup.refresh(); - - //setValue(getValue()); } }); @@ -657,6 +685,10 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value } } // actionQuickEntry + /** + * Handle onClick event from {@link CustomSearchBox} button. + * @param queryValue + */ protected void actionButton(String queryValue) { if (lookup == null) @@ -675,8 +707,6 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value if (log.isLoggable(Level.FINE)) log.fine(lookup.getColumnName() + ", Zoom=" + lookup.getZoom() + " (" + whereClause + ")"); - // boolean resetValue = false; // Reset value so that is always treated as new entry - // Replace Value with name if no value exists if (queryValue.length() == 0 && getComponent().getText().length() > 0) queryValue = getComponent().getText(); @@ -689,7 +719,10 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value showInfoPanel(ip); } - + /** + * Open InfoPanel/InfoWindow dialog + * @param ip InfoPanel + */ public void showInfoPanel(final InfoPanel ip) { ip.setVisible(true); ip.setStyle("border: 2px"); @@ -749,7 +782,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value } /** - * Sets m_tableName and m_keyColumnName + * Set {@link #m_tableName} and {@link #m_keyColumnName}. */ private void setTableAndKeyColumn() { if (lookup != null && lookup instanceof MLookup) { @@ -780,6 +813,10 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value } } + /** + * Parse where clause from lookup validation code. + * @return where clause + */ private String getWhereClause() { String whereClause = ""; @@ -800,9 +837,6 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value else if (validation.length() > 0) whereClause += " AND " + validation; - // log.finest("ZoomQuery=" + (lookup.getZoomQuery()==null ? "" : lookup.getZoomQuery().getWhereClause()) - // + ", Validation=" + lookup.getValidation()); - if (whereClause.indexOf('@') != -1) { String validated = Env.parseContext(Env.getCtx(), lookup.getWindowNo(), whereClause, false); @@ -819,12 +853,13 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value return whereClause; } // getWhereClause - + @Override public String[] getEvents() { return LISTENER_EVENTS; } + @Override public void valueChange(ValueChangeEvent evt) { if ("zoom".equals(evt.getPropertyName())) @@ -847,12 +882,15 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value getComponent().setTableEditorMode(b); } - + /** + * @return true if InfoPanel/InfoWindow dialog is active + */ public boolean isShowingDialog (){ return infoPanel != null; } /** + * Create new WSearhEditor instance for C_Invoice.C_BPartner_ID column. * @param windowNo * @return WSearchEditor */ @@ -872,6 +910,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value } /** + * Create new WSearchEditor instance for C_InvoiceLine.M_Product_ID column. * @param windowNo * @return WSearchEditor */ @@ -889,8 +928,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value } return null; } - - + @Override public void dynamicDisplay(Properties ctx) { if (lookup instanceof MLookup) { @@ -911,6 +949,9 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value return s; } + /** + * Search box component + */ static class CustomSearchBox extends ComboEditorBox { /** @@ -918,6 +959,9 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value */ private static final long serialVersionUID = 7490301044763375829L; + /** + * Set script for spin animation when editor is processing user input text + */ @Override public void onPageAttached(Page newpage, Page oldpage) { super.onPageAttached(newpage, oldpage); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WStringEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WStringEditor.java index baf0cf83b9..eadf2ddab2 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WStringEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WStringEditor.java @@ -43,7 +43,8 @@ import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.sys.ComponentCtrl; /** - * + * Default editor for text display type (String, PrinterName, Text, TextLong and Memo).
+ * Implemented with {@link Textbox} or {@link Combobox} (AD_Field.IsAutocomplete=Y) component and {@link WTextEditorDialog} dialog. * @author Ashley G Ramdass * @date Mar 11, 2007 * @version $Revision: 0.10 $ @@ -57,7 +58,7 @@ public class WStringEditor extends WEditor implements ContextMenuListener private AbstractADWindowContent adwindowContent; /** - * to ease porting of swing form + * Default constructor */ public WStringEditor() { @@ -99,7 +100,6 @@ public class WStringEditor extends WEditor implements ContextMenuListener } /** - * to ease porting of swing form * @param columnName * @param mandatory * @param isReadOnly @@ -135,6 +135,10 @@ public class WStringEditor extends WEditor implements ContextMenuListener getComponent().setReadonly(!readWrite); } + /** + * Init component and context menu + * @param obscureType + */ private void init(String obscureType) { setChangeEventWhenEditing (true); @@ -194,6 +198,7 @@ public class WStringEditor extends WEditor implements ContextMenuListener getComponent().addCallback(ComponentCtrl.AFTER_PAGE_DETACHED, t -> ((AbstractComponent)t).setWidgetListener("onBind", null)); } + @Override public void onEvent(Event event) { boolean isStartEdit = INIT_EDIT_EVENT.equalsIgnoreCase (event.getName()); @@ -242,6 +247,10 @@ public class WStringEditor extends WEditor implements ContextMenuListener oldValue = getComponent().getValue(); } + /** + * Set type of textbox to password or text + * @param password true to set type to password + */ protected void setTypePassword(boolean password) { if (password) @@ -260,6 +269,7 @@ public class WStringEditor extends WEditor implements ContextMenuListener return LISTENER_EVENTS; } + @Override public void onMenu(ContextMenuEvent evt) { if (WEditorPopupMenu.PREFERENCE_EVENT.equals(evt.getContextEvent())) @@ -325,6 +335,9 @@ public class WStringEditor extends WEditor implements ContextMenuListener actionRefresh(); } + /** + * Refresh auto complete combo + */ public void actionRefresh() { //refresh auto complete list if (gridField.isAutocomplete()) { @@ -337,6 +350,10 @@ public class WStringEditor extends WEditor implements ContextMenuListener } } + /** + * Find AbstractADWindowContent instance that own this editor + * @return AbstractADWindowContent + */ private AbstractADWindowContent findADWindowContent() { Component parent = getComponent().getParent(); while(parent != null) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java index f6b10d0350..7f21b9e273 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java @@ -20,7 +20,6 @@ package org.adempiere.webui.editor; -import java.beans.PropertyChangeEvent; import java.math.BigDecimal; import java.sql.Timestamp; import java.util.Properties; @@ -80,7 +79,8 @@ import org.zkoss.zul.Comboitem; import org.zkoss.zul.Menuitem; /** - * + * Default editor for display type TableDir, TableDirUU, Table, TableUU and List. + * Implemented with {@link EditorCombobox} or {@link EditorAutoComplete} (AD_Field.IsAutoComplete=Y) component. * @author Ashley G Ramdass * @date Mar 12, 2007 * @version $Revision: 0.10 $ @@ -88,11 +88,13 @@ import org.zkoss.zul.Menuitem; public class WTableDirEditor extends WEditor implements ListDataListener, ContextMenuListener, IZoomableEditor { + /** custom script for up arrow key processed */ private static final String UP_PRESSED_OVERRIDE_SCRIPT = "function(evt) {" + " if (!this.isOpen()) this.open();" + " this.$upPressed_(evt);" + "}"; + /** custom script for down arrow key processed */ private static final String DOWN_PRESSED_OVERRIDE_SCRIPT = "function(evt) {" + " if (!this.isOpen()) this.open();" + " this.$dnPressed_(evt);" @@ -109,15 +111,22 @@ ContextMenuListener, IZoomableEditor } private Lookup lookup; + /** ID, UUID or AD_RefList Value */ private Object oldValue; + /** Reference/target table name */ private String m_tableName = null; + /** Reference/target key column name */ private String m_keyColumnName = null; + /** Context menu item attribute to store context menu event name/id */ public static final String SHORT_LIST_EVENT = "SHORT_LIST"; // IDEMPIERE 90 + /** true if lookup only contain short list items (i.e with IsShortList=Y) */ protected boolean onlyShortListItems; // IDEMPIERE 90 + /** CCache listener to auto refresh lookup list */ private CCacheListener tableCacheListener; + /** true if editor is handling ON_SELECT event */ private boolean onselecting = false; private boolean retainSelectedValueAfterRefresh = true; @@ -149,9 +158,9 @@ ContextMenuListener, IZoomableEditor * Constructor for use if a grid field is unavailable * * @param lookup Store of selectable data - * @param label column name (not displayed) + * @param label field label * @param description description of component - * @param mandatory whether a selection must be made + * @param mandatory whether field is mandatory * @param readonly whether or not the editor is read only * @param updateable whether the editor contents can be changed */ @@ -160,11 +169,29 @@ ContextMenuListener, IZoomableEditor this(lookup, label, description, mandatory, readonly, updateable, false); } + /** + * @param lookup + * @param label + * @param description + * @param mandatory + * @param readonly + * @param updateable + * @param autocomplete + */ public WTableDirEditor(Lookup lookup, String label, String description, boolean mandatory, boolean readonly, boolean updateable, boolean autocomplete) { this(autocomplete ? new EditorAutoComplete() : new EditorCombobox(), lookup, label, description, mandatory, readonly, updateable); } + /** + * @param comp + * @param lookup + * @param label + * @param description + * @param mandatory + * @param readonly + * @param updateable + */ private WTableDirEditor(Component comp, Lookup lookup, String label, String description, boolean mandatory, boolean readonly, boolean updateable) { super(comp, label, description, mandatory, readonly, updateable); @@ -181,7 +208,6 @@ ContextMenuListener, IZoomableEditor } /** - * For ease of porting swing form * @param columnName * @param mandatory * @param isReadOnly @@ -193,11 +219,27 @@ ContextMenuListener, IZoomableEditor this(columnName, mandatory, isReadOnly, isUpdateable, lookup, false); } + /** + * @param columnName + * @param mandatory + * @param isReadOnly + * @param isUpdateable + * @param lookup + * @param autocomplete + */ public WTableDirEditor(String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, Lookup lookup, boolean autocomplete) { this(autocomplete ? new EditorAutoComplete() : new EditorCombobox(), columnName, mandatory, isReadOnly, isUpdateable, lookup); } + /** + * @param comp Component + * @param columnName + * @param mandatory + * @param isReadOnly + * @param isUpdateable + * @param lookup + */ private WTableDirEditor(Component comp, String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, Lookup lookup) { super(comp, columnName, null, null, mandatory, isReadOnly, isUpdateable); @@ -210,6 +252,9 @@ ContextMenuListener, IZoomableEditor init(); } + /** + * Init component and context menu + */ private void init() { ZKUpdateUtil.setWidth(getComponent(), "200px"); @@ -249,7 +294,7 @@ ContextMenuListener, IZoomableEditor refreshList(); } - String tableName_temp = lookup.getColumnName(); // Returns AD_Org.AD_Org_ID + String tableName_temp = lookup.getColumnName(); // Returns [table name].[key column name] int posPoint = tableName_temp.indexOf("."); String tableName = tableName_temp.substring(0, posPoint); @@ -299,6 +344,9 @@ ContextMenuListener, IZoomableEditor getComponent().setPlaceholder(gridField.getPlaceholder()); } + /** + * Create {@link #tableCacheListener} instance + */ private void createCacheListener() { if (lookup != null) { String columnName = lookup.getColumnName(); @@ -339,6 +387,7 @@ ContextMenuListener, IZoomableEditor return retVal; } + @Override public void setValue(Object value) { if (onselecting) { @@ -437,6 +486,9 @@ ContextMenuListener, IZoomableEditor getComponent().setButtonVisible(readWrite); } + /** + * Refresh lookup list + */ private void refreshList() { if (getComponent().getItemCount() > 0) @@ -544,6 +596,7 @@ ContextMenuListener, IZoomableEditor getComponent().setValue(oldValue); } + @Override public void onEvent(Event event) { if (Events.ON_SELECT.equalsIgnoreCase(event.getName())) @@ -607,27 +660,38 @@ ContextMenuListener, IZoomableEditor } } + /** + * @param newValue + * @return true if newValue is different from {@link #oldValue} + */ private boolean isValueChange(Object newValue) { return (oldValue == null && newValue != null) || (oldValue != null && newValue == null) || ((oldValue != null && newValue != null) && !oldValue.equals(newValue)); } + @Override public String[] getEvents() { return LISTENER_EVENTS; } + @Override public void contentsChanged(ListDataEvent e) { refreshList(); } + @Override public void intervalAdded(ListDataEvent e) {} + @Override public void intervalRemoved(ListDataEvent e) {} + /** + * Refresh lookup list + */ public void actionRefresh() { if (lookup != null) @@ -653,16 +717,23 @@ ContextMenuListener, IZoomableEditor /* (non-Javadoc) * @see org.adempiere.webui.editor.IZoomableEditor#actionZoom() */ + @Override public void actionZoom() { AEnv.actionZoom(lookup, getValue()); } + /** + * @return Lookup + */ public Lookup getLookup() { return lookup; } + /** + * Open drill assistant dialog + */ protected void actionDrill() { if(getGridField() == null || getGridField().getGridTab() == null) return; @@ -681,7 +752,7 @@ ContextMenuListener, IZoomableEditor } /** - * Sets m_tableName and m_keyColumnName + * Set {@link #m_tableName} and {@link #m_keyColumnName}. */ private void setTableAndKeyColumn() { if (lookup != null && lookup instanceof MLookup) { @@ -756,6 +827,9 @@ ContextMenuListener, IZoomableEditor AEnv.showWindow(vqe); } // actionQuickEntry + /** + * Open {@link WLocationDialog} + */ protected void actionLocation() { int BPLocation_ID = 0; Object value = getValue(); @@ -776,6 +850,7 @@ ContextMenuListener, IZoomableEditor } // actionLocation + @Override public void onMenu(ContextMenuEvent evt) { if (WEditorPopupMenu.REQUERY_EVENT.equals(evt.getContextEvent())) @@ -833,14 +908,6 @@ ContextMenuListener, IZoomableEditor // IDEMPIERE 90 } - public void propertyChange(PropertyChangeEvent evt) - { - if ("FieldValue".equals(evt.getPropertyName())) - { - setValue(evt.getNewValue()); - } - } - @Override public void dynamicDisplay(Properties ctx) { @@ -872,6 +939,9 @@ ContextMenuListener, IZoomableEditor return s; } + /** + * Custom {@link Combobox} class + */ private static class EditorCombobox extends Combobox implements ITableDirEditor { /** * generated serial id @@ -888,6 +958,9 @@ ContextMenuListener, IZoomableEditor super.setPage(page); } + /** + * Create CCache listener + */ @Override public void onPageAttached(Page newpage, Page oldpage) { super.onPageAttached(newpage, oldpage); @@ -914,7 +987,7 @@ ContextMenuListener, IZoomableEditor } /** - * + * Clean up CCache listener */ public void cleanup() { if (editor.tableCacheListener != null) { @@ -929,6 +1002,9 @@ ContextMenuListener, IZoomableEditor } } + /** + * Custom {@link AutoComplete} class + */ private static class EditorAutoComplete extends AutoComplete implements ITableDirEditor { /** * generated serial id @@ -945,6 +1021,9 @@ ContextMenuListener, IZoomableEditor super.setPage(page); } + /** + * Create CCache listener instance + */ @Override public void onPageAttached(Page newpage, Page oldpage) { super.onPageAttached(newpage, oldpage); @@ -971,7 +1050,7 @@ ContextMenuListener, IZoomableEditor } /** - * + * Clean up CCache listener */ public void cleanup() { if (editor.tableCacheListener != null) { @@ -997,6 +1076,9 @@ ContextMenuListener, IZoomableEditor } + /** + * CCache listener to auto refresh lookup list + */ private static class CCacheListener extends CCache { /** * generated serial @@ -1052,7 +1134,6 @@ ContextMenuListener, IZoomableEditor } /** - * * @return true if current selected value is always retain after refresh of list */ public boolean isRetainSelectedValueAfterRefresh() { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTimeEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTimeEditor.java index a731f09c47..1e652eb579 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTimeEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTimeEditor.java @@ -26,11 +26,13 @@ import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.window.WFieldRecordInfo; import org.compiere.model.GridField; import org.compiere.util.CLogger; +import org.compiere.util.DisplayType; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Events; /** - * + * Default editor for {@link DisplayType#Time}.
+ * Implemented with {@link Timebox} component. * @author Low Heng Sin */ public class WTimeEditor extends WEditor implements ContextMenuListener @@ -85,11 +87,11 @@ public class WTimeEditor extends WEditor implements ContextMenuListener * Constructor for use if a grid field is unavailable * * @param label - * column name (not displayed) + * field label * @param description * description of component * @param mandatory - * whether a selection must be made + * whether field is mandatory * @param readonly * whether or not the editor is read only * @param updateable @@ -102,12 +104,18 @@ public class WTimeEditor extends WEditor implements ContextMenuListener init(); } + /** + * Default constructor + */ public WTimeEditor() { this("Time", "Time", false, false, true); init(); - } // VDate + } + /** + * Init component and context menu + */ private void init() { getComponent().setCols(10); @@ -118,6 +126,7 @@ public class WTimeEditor extends WEditor implements ContextMenuListener getComponent().setPlaceholder(gridField.getPlaceholder()); } + @Override public void onEvent(Event event) { if (Events.ON_CHANGE.equalsIgnoreCase(event.getName()) || Events.ON_OK.equalsIgnoreCase(event.getName())) @@ -153,18 +162,14 @@ public class WTimeEditor extends WEditor implements ContextMenuListener @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 @@ -196,7 +201,6 @@ public class WTimeEditor extends WEditor implements ContextMenuListener return !getComponent().isReadonly(); } - @Override public void setReadWrite(boolean readWrite) { getComponent().setReadonly(!readWrite); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTimeZoneEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTimeZoneEditor.java index 07ec1ebdaf..16ad1416e2 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTimeZoneEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTimeZoneEditor.java @@ -42,6 +42,7 @@ import org.adempiere.webui.event.ContextMenuListener; import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.session.SessionManager; import org.compiere.model.GridField; +import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.compiere.util.Msg; import org.compiere.util.NamePair; @@ -55,17 +56,24 @@ import org.zkoss.zul.Menu; import org.zkoss.zul.Menuitem; /** + * Default editor for {@link DisplayType#TimeZoneId}.
+ * Implemented with {@link Combobox} component. * @author hengsin * */ public class WTimeZoneEditor extends WEditor implements ContextMenuListener { private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE}; + /** Time zone context menu name/id */ private static final String TIME_ZONE = "TIME_ZONE"; + /** Context popup menu attribute to indicate time zone context menu items have been added */ private static final String TIME_ZONE_ADDED = "TIME_ZONE_ADDED"; + /** Context menu attribute to indicate this is a context menu item */ private static final String TIME_ZONE_ITEM_ATTR = "TIME_ZONE_ITEM"; + /** Context menu attribute to store time zone id */ private static final String TIME_ZONE_ID_ATTR = "TIME_ZONE_ID"; + /** Time zone id */ private String oldValue; /** @@ -114,6 +122,9 @@ public class WTimeZoneEditor extends WEditor implements ContextMenuListener { init(); } + /** + * Init component and context menu + */ private void init() { popupMenu = new WEditorPopupMenu(false, false, isShowPreference()); popupMenu.addMenuListener(this); @@ -150,6 +161,9 @@ public class WTimeZoneEditor extends WEditor implements ContextMenuListener { getComponent().addEventListener(Events.ON_BLUR, e -> onBlur()); } + /** + * Handle onBlur event of component + */ private void onBlur() { Comboitem item = getComponent().getSelectedItem(); if (item == null) @@ -178,6 +192,10 @@ public class WTimeZoneEditor extends WEditor implements ContextMenuListener { } } + /** + * @param newValue + * @return true if newValue is different from {@link #oldValue} + */ private boolean isValueChange(String newValue) { return (oldValue == null && newValue != null) || (oldValue != null && newValue == null) || ((oldValue != null && newValue != null) && !oldValue.equals(newValue)); @@ -214,6 +232,11 @@ public class WTimeZoneEditor extends WEditor implements ContextMenuListener { } } + /** + * Process customId enter by user + * @param customId + * @return true if customId is valid and added to Combobox + */ private boolean processCustomZoneId(String customId) { TimeZone timeZone = TimeZone.getTimeZone(customId); if (timeZone != null && timeZone.getID().equals(customId)) { @@ -327,6 +350,10 @@ public class WTimeZoneEditor extends WEditor implements ContextMenuListener { } + /** + * Process time zone id from time zone context menu + * @param id + */ private void setTimeZoneFromContextMenu(String id) { String newValue = id; String currentValue = oldValue; @@ -349,14 +376,17 @@ public class WTimeZoneEditor extends WEditor implements ContextMenuListener { } /** + * Add time zone menu item to context menu popup * @param popupMenu */ private void addTimeZoneMenu(WEditorPopupMenu popupMenu) { if (popupMenu != null && isReadWrite() && popupMenu.getAttribute(TIME_ZONE_ADDED) == null) { + //time zone id from browser ClientInfo clientInfo = SessionManager.getAppDesktop().getClientInfo(); if (clientInfo != null && clientInfo.timeZone != null) { TimeZone firstSameRule = null; TimeZone found = null; + //match by id, fallback to first with same rawOffset+DSTSavings+useDayLightTime for(int i = 0; i < getComponent().getItemCount(); i++) { String id = getComponent().getItemAtIndex(i).getValue(); TimeZone tz = TimeZone.getTimeZone(id); @@ -385,6 +415,7 @@ public class WTimeZoneEditor extends WEditor implements ContextMenuListener { if (popupMenu.getAttribute(TIME_ZONE_ADDED) == null) { List labels = new ArrayList(); List ids = new ArrayList(); + //match by rawOffset for(int i = 0; i < getComponent().getItemCount(); i++) { String id = getComponent().getItemAtIndex(i).getValue(); tz = TimeZone.getTimeZone(id); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WUnknownEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WUnknownEditor.java index 106599db31..b45e07cd3a 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WUnknownEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WUnknownEditor.java @@ -20,7 +20,7 @@ package org.adempiere.webui.editor; import org.compiere.model.GridField; /** - * + * Simple text editor for unknown display type. * @author Ashley G Ramdass * @date Mar 12, 2007 * @version $Revision: 0.10 $ diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WUrlEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WUrlEditor.java index 4a89dc88a8..90e2354178 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WUrlEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WUrlEditor.java @@ -25,9 +25,14 @@ import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.window.WFieldRecordInfo; import org.compiere.model.GridField; +import org.compiere.util.DisplayType; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Events; +/** + * Default editor for {@link DisplayType#URL}.
+ * Implemented with {@link Urlbox} component. + */ public class WUrlEditor extends WEditor implements ContextMenuListener { private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE, Events.ON_OK}; @@ -110,7 +115,7 @@ public class WUrlEditor extends WEditor implements ContextMenuListener getComponent().setEnabled(readWrite); } - + @Override public void onEvent(Event event) { if (Events.ON_CHANGE.equals(event.getName()) || Events.ON_OK.equals(event.getName())) @@ -128,6 +133,7 @@ public class WUrlEditor extends WEditor implements ContextMenuListener } } + @Override public String[] getEvents() { return LISTENER_EVENTS; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WYesNoEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WYesNoEditor.java index d8d9a04a78..f218d05c51 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WYesNoEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WYesNoEditor.java @@ -17,7 +17,6 @@ package org.adempiere.webui.editor; -import java.beans.PropertyChangeEvent; import java.util.logging.Level; import org.adempiere.webui.ValuePreference; @@ -28,13 +27,15 @@ import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.window.WFieldRecordInfo; import org.compiere.model.GridField; import org.compiere.util.CLogger; +import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.compiere.util.Msg; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Events; /** - * + * Default editor for {@link DisplayType#YesNo}.
+ * Implemented with {@link Checkbox} component. * @author Ashley G Ramdass * @date Mar 11, 2007 * @version $Revision: 0.10 $ @@ -88,6 +89,9 @@ public class WYesNoEditor extends WEditor implements ContextMenuListener init(); } + /** + * Init component and context menu + */ private void init() { if (gridField != null) @@ -102,6 +106,7 @@ public class WYesNoEditor extends WEditor implements ContextMenuListener addChangeLogMenu(popupMenu); } + @Override public void onEvent(Event event) { if (Events.ON_CHECK.equalsIgnoreCase(event.getName())) @@ -113,14 +118,6 @@ public class WYesNoEditor extends WEditor implements ContextMenuListener } } - public void propertyChange(PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - { - setValue(evt.getNewValue()); - } - } - @Override public String getDisplay() { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WebEditorFactory.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WebEditorFactory.java index 9baa93b10e..4f94931871 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WebEditorFactory.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WebEditorFactory.java @@ -29,7 +29,7 @@ import org.compiere.util.CCache; import org.osgi.framework.Constants; /** - * + * Static methods to create new {@link WEditor} instance for {@link GridField}. * @author Ashley G Ramdass * @date Mar 12, 2007 * @version $Revision: 0.10 $