IDEMPIERE-5570 Zk: Improve readability of code (#1819)
- for org.adempiere.webui.editor package
This commit is contained in:
parent
f82777c527
commit
66b8271c2b
|
@ -33,12 +33,12 @@ public interface IInputValidator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Valid Input
|
* Get Valid Input
|
||||||
* @return String
|
* @return Expected input string from user
|
||||||
*/
|
*/
|
||||||
public String getValidInput();
|
public String getValidInput();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Valid Input
|
* Set string to validate against user input
|
||||||
* @param validInput
|
* @param validInput
|
||||||
*/
|
*/
|
||||||
public void setValidInput(String validInput);
|
public void setValidInput(String validInput);
|
||||||
|
@ -46,7 +46,7 @@ public interface IInputValidator {
|
||||||
/**
|
/**
|
||||||
* Is Input Valid
|
* Is Input Valid
|
||||||
* @param input
|
* @param input
|
||||||
* @return boolean
|
* @return true if input validate against {@link #getValidInput()}
|
||||||
*/
|
*/
|
||||||
public boolean isValid(String input);
|
public boolean isValid(String input);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ package org.adempiere.webui.editor;
|
||||||
import org.adempiere.webui.adwindow.IADTabpanel;
|
import org.adempiere.webui.adwindow.IADTabpanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Interface for process button
|
||||||
* @author hengsin
|
* @author hengsin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -28,13 +28,28 @@ public interface IProcessButton {
|
||||||
*/
|
*/
|
||||||
public int getProcess_ID();
|
public int getProcess_ID();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return AD_InfoWindow_ID
|
||||||
|
*/
|
||||||
public int getInfoWindow_ID();
|
public int getInfoWindow_ID();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link IADTabpanel} instance that own this button
|
||||||
|
*/
|
||||||
public IADTabpanel getADTabpanel();
|
public IADTabpanel getADTabpanel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Column Name
|
||||||
|
*/
|
||||||
public String getColumnName();
|
public String getColumnName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Description
|
||||||
|
*/
|
||||||
public String getDescription();
|
public String getDescription();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Display text
|
||||||
|
*/
|
||||||
public String getDisplay();
|
public String getDisplay();
|
||||||
}
|
}
|
|
@ -13,12 +13,14 @@
|
||||||
package org.adempiere.webui.editor;
|
package org.adempiere.webui.editor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Interface for field editor that support zoom to AD window.
|
||||||
* @author Low Heng Sin
|
* @author Low Heng Sin
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface IZoomableEditor {
|
public interface IZoomableEditor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zoom to AD window
|
||||||
|
*/
|
||||||
public void actionZoom();
|
public void actionZoom();
|
||||||
|
|
||||||
}
|
}
|
|
@ -40,9 +40,8 @@ import org.zkoss.zul.ListModelList;
|
||||||
import org.zkoss.zul.ListSubModel;
|
import org.zkoss.zul.ListSubModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Model to get filter list from lookup and info window/panel
|
||||||
* @author hengsin
|
* @author hengsin
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class InfoListSubModel implements ListSubModel<ValueNamePair> {
|
public class InfoListSubModel implements ListSubModel<ValueNamePair> {
|
||||||
|
|
||||||
|
@ -88,6 +87,7 @@ public class InfoListSubModel implements ListSubModel<ValueNamePair> {
|
||||||
public ListModel<ValueNamePair> getSubModel(Object value, int nRows) {
|
public ListModel<ValueNamePair> getSubModel(Object value, int nRows) {
|
||||||
ListModelList<ValueNamePair> model = new ListModelList<>();
|
ListModelList<ValueNamePair> model = new ListModelList<>();
|
||||||
if (value != null && !Util.isEmpty(value.toString(), true)) {
|
if (value != null && !Util.isEmpty(value.toString(), true)) {
|
||||||
|
//build query text from input value
|
||||||
String queryText = value.toString().trim();
|
String queryText = value.toString().trim();
|
||||||
StringBuilder queryBuilder = new StringBuilder(queryText);
|
StringBuilder queryBuilder = new StringBuilder(queryText);
|
||||||
queryBuilder.append("?autocomplete={");
|
queryBuilder.append("?autocomplete={");
|
||||||
|
@ -108,6 +108,7 @@ public class InfoListSubModel implements ListSubModel<ValueNamePair> {
|
||||||
queryBuilder.append("}");
|
queryBuilder.append("}");
|
||||||
queryText = queryBuilder.toString();
|
queryText = queryBuilder.toString();
|
||||||
|
|
||||||
|
//build model from infopanel/infowindow processing of query text
|
||||||
final InfoPanel ip = InfoManager.create(lookup, gridField, tableName, keyColumnName, queryText, false, getWhereClause());
|
final InfoPanel ip = InfoManager.create(lookup, gridField, tableName, keyColumnName, queryText, false, getWhereClause());
|
||||||
if (ip != null && ip.loadedOK()) {
|
if (ip != null && ip.loadedOK()) {
|
||||||
int rowCount = ip.getRowCount();
|
int rowCount = ip.getRowCount();
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.compiere.model.MAccountLookup;
|
||||||
import org.compiere.model.MRole;
|
import org.compiere.model.MRole;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.zkoss.zk.au.out.AuScript;
|
import org.zkoss.zk.au.out.AuScript;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
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;
|
import org.zkoss.zk.ui.util.Clients;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Default editor for {@link DisplayType#Account}. <br/>
|
||||||
|
* Implemented with {@link Combinationbox} component and {@link WAccountDialog} dialog.
|
||||||
* @author Low Heng Sin
|
* @author Low Heng Sin
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class WAccountEditor extends WEditor implements ContextMenuListener
|
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()
|
public void cmd_button()
|
||||||
{
|
{
|
||||||
|
@ -158,16 +159,16 @@ public class WAccountEditor extends WEditor implements ContextMenuListener
|
||||||
Clients.response(new AuScript(script));
|
Clients.response(new AuScript(script));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//
|
|
||||||
} // cmd_button
|
} // cmd_button
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Text - try to find Alias or start Dialog
|
* Process input text - try to find Alias or open Dialog
|
||||||
*/
|
*/
|
||||||
public void cmd_text()
|
public void cmd_text()
|
||||||
{
|
{
|
||||||
String text = getComponent().getText();
|
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("%"))
|
if (text == null || text.length() == 0 || text.equals("%"))
|
||||||
{
|
{
|
||||||
cmd_button();
|
cmd_button();
|
||||||
|
@ -224,8 +225,9 @@ public class WAccountEditor extends WEditor implements ContextMenuListener
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cmd_button();
|
cmd_button();
|
||||||
} // actionPerformed
|
} // cmd_text
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
if (Events.ON_CHANGE.equals(event.getName()) || Events.ON_OK.equals(event.getName()))
|
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()
|
public String[] getEvents()
|
||||||
{
|
{
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isReadWrite() {
|
public boolean isReadWrite() {
|
||||||
return getComponent().isEnabled();
|
return getComponent().isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setReadWrite(boolean readWrite) {
|
public void setReadWrite(boolean readWrite) {
|
||||||
getComponent().setEnabled(readWrite);
|
getComponent().setEnabled(readWrite);
|
||||||
|
|
|
@ -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;
|
package org.adempiere.webui.editor;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
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.EventListener;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default editor for {@link DisplayType#Assignment}.<br/>
|
||||||
|
* Implemented with {@link EditorBox} component, {@link WAssignmentDialog} and {@link InfoSchedule} dialog.
|
||||||
|
* @author hengsin
|
||||||
|
*/
|
||||||
public class WAssignmentEditor extends WEditor implements ContextMenuListener {
|
public class WAssignmentEditor extends WEditor implements ContextMenuListener {
|
||||||
|
|
||||||
private static final String RETRIEVE_RESOURCE_ASSIGNMENT_SQL = "SELECT r.Name,ra.AssignDateFrom,ra.Qty,uom.UOMSymbol "
|
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 static final String[] LISTENER_EVENTS = {Events.ON_CLICK};
|
||||||
|
|
||||||
private boolean m_readWrite;
|
private boolean m_readWrite;
|
||||||
|
/** S_ResourceAssignment_ID */
|
||||||
private Object m_value;
|
private Object m_value;
|
||||||
|
|
||||||
private DateFormat m_dateFormat = DisplayType.getDateFormat(DisplayType.DateTime);
|
private DateFormat m_dateFormat = DisplayType.getDateFormat(DisplayType.DateTime);
|
||||||
|
@ -68,6 +97,9 @@ public class WAssignmentEditor extends WEditor implements ContextMenuListener {
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component and context menu
|
||||||
|
*/
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
getComponent().getTextbox().setReadonly(true);
|
getComponent().getTextbox().setReadonly(true);
|
||||||
if (ThemeManager.isUseFontIconForImage())
|
if (ThemeManager.isUseFontIconForImage())
|
||||||
|
@ -82,8 +114,6 @@ public class WAssignmentEditor extends WEditor implements ContextMenuListener {
|
||||||
getComponent().getTextbox().setPlaceholder(gridField.getPlaceholder());
|
getComponent().getTextbox().setPlaceholder(gridField.getPlaceholder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getEvents() {
|
public String[] getEvents() {
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
|
@ -161,6 +191,7 @@ public class WAssignmentEditor extends WEditor implements ContextMenuListener {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event) throws Exception {
|
public void onEvent(Event event) throws Exception {
|
||||||
//
|
//
|
||||||
if (Events.ON_CLICK.equalsIgnoreCase(event.getName()))
|
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)
|
if (S_ResourceAssignment_ID != 0)
|
||||||
{
|
{
|
||||||
final WAssignmentDialog vad = new WAssignmentDialog (ma, true, true);
|
final WAssignmentDialog vad = new WAssignmentDialog (ma, true, true);
|
||||||
|
@ -200,7 +231,7 @@ public class WAssignmentEditor extends WEditor implements ContextMenuListener {
|
||||||
vad.setTitle(null);
|
vad.setTitle(null);
|
||||||
LayoutUtils.openPopupWindow(this.getComponent().getTextbox(), vad);
|
LayoutUtils.openPopupWindow(this.getComponent().getTextbox(), vad);
|
||||||
}
|
}
|
||||||
// Start InfoSchedule directly
|
// Open InfoSchedule directly
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final InfoSchedule is = new InfoSchedule(ma, true, new Callback<MResourceAssignment>() {
|
final InfoSchedule is = new InfoSchedule(ma, true, new Callback<MResourceAssignment>() {
|
||||||
|
@ -227,10 +258,18 @@ public class WAssignmentEditor extends WEditor implements ContextMenuListener {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zoom to window for S_ResourceAssignment
|
||||||
|
*/
|
||||||
private void actionZoom() {
|
private void actionZoom() {
|
||||||
AEnv.zoom(gridField.getGridTab().getAD_Table_ID(), (Integer)getValue());
|
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) {
|
private void processNewValue(final Integer oldValue, MResourceAssignment ma) {
|
||||||
// Set Value
|
// Set Value
|
||||||
if (ma != null && ma.getS_ResourceAssignment_ID() != 0)
|
if (ma != null && ma.getS_ResourceAssignment_ID() != 0)
|
||||||
|
|
|
@ -26,11 +26,14 @@ import org.adempiere.webui.event.ValueChangeEvent;
|
||||||
import org.adempiere.webui.window.WMediaDialog;
|
import org.adempiere.webui.window.WMediaDialog;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Default editor for {@link DisplayType#Binary}.<br/>
|
||||||
|
* Implemented with {@link Button} component and {@link WMediaDialog} dialog.
|
||||||
* @author Low Heng Sin
|
* @author Low Heng Sin
|
||||||
*/
|
*/
|
||||||
public class WBinaryEditor extends WEditor
|
public class WBinaryEditor extends WEditor
|
||||||
|
@ -41,8 +44,10 @@ public class WBinaryEditor extends WEditor
|
||||||
private static final CLogger log = CLogger.getCLogger(WBinaryEditor.class);
|
private static final CLogger log = CLogger.getCLogger(WBinaryEditor.class);
|
||||||
|
|
||||||
private boolean m_mandatory;
|
private boolean m_mandatory;
|
||||||
|
/** Binary data */
|
||||||
private Object m_data;
|
private Object m_data;
|
||||||
|
|
||||||
|
/** ADWindow instance that own this editor */
|
||||||
private ADWindow adwindow;
|
private ADWindow adwindow;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,6 +71,9 @@ public class WBinaryEditor extends WEditor
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component
|
||||||
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
label.setValue(" ");
|
label.setValue(" ");
|
||||||
|
@ -73,7 +81,7 @@ public class WBinaryEditor extends WEditor
|
||||||
getComponent().setTooltiptext(gridField.getDescription());
|
getComponent().setTooltiptext(gridField.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDisplay()
|
public String getDisplay()
|
||||||
{
|
{
|
||||||
return getComponent().getLabel();
|
return getComponent().getLabel();
|
||||||
|
@ -145,6 +153,7 @@ public class WBinaryEditor extends WEditor
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event) throws Exception
|
public void onEvent(Event event) throws Exception
|
||||||
{
|
{
|
||||||
if (Events.ON_CLICK.equals(event.getName()))
|
if (Events.ON_CLICK.equals(event.getName()))
|
||||||
|
|
|
@ -47,8 +47,7 @@ import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is based on org.compiere.grid.ed.VButton written by Jorg Janke.
|
* Default editor for {@link DisplayType#Button}.
|
||||||
* @author Jorg Janke
|
|
||||||
*
|
*
|
||||||
* Modifications - UI Compatibility
|
* Modifications - UI Compatibility
|
||||||
* @author ashley
|
* @author ashley
|
||||||
|
@ -69,7 +68,7 @@ public class WButtonEditor extends WEditor implements IProcessButton
|
||||||
private String m_text;
|
private String m_text;
|
||||||
private boolean m_mandatory;
|
private boolean m_mandatory;
|
||||||
private Object m_value;
|
private Object m_value;
|
||||||
/** List of Key/Name */
|
/** Value:Name. AD_Ref_List values for PaymentRule, DocAction or Posted reference. */
|
||||||
private HashMap<String,String> m_values = null;
|
private HashMap<String,String> m_values = null;
|
||||||
|
|
||||||
/** Description as ToolTip */
|
/** Description as ToolTip */
|
||||||
|
@ -147,11 +146,17 @@ public class WButtonEditor extends WEditor implements IProcessButton
|
||||||
return AD_InfoWindow_ID;
|
return AD_InfoWindow_ID;
|
||||||
} // getInfoWindow_ID
|
} // getInfoWindow_ID
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return GridField
|
||||||
|
*/
|
||||||
public GridField getGridField()
|
public GridField getGridField()
|
||||||
{
|
{
|
||||||
return gridfield;
|
return gridfield;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component
|
||||||
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
label.setValue(" ");
|
label.setValue(" ");
|
||||||
|
@ -233,7 +238,6 @@ public class WButtonEditor extends WEditor implements IProcessButton
|
||||||
return m_mandatory;
|
return m_mandatory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMandatory(boolean mandatory)
|
public void setMandatory(boolean mandatory)
|
||||||
{
|
{
|
||||||
|
@ -288,6 +292,9 @@ public class WButtonEditor extends WEditor implements IProcessButton
|
||||||
getComponent().setEnabled(readWrite);
|
getComponent().setEnabled(readWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return AD_Ref_List Value:Name HashMap
|
||||||
|
*/
|
||||||
public HashMap<String, String> getValues()
|
public HashMap<String, String> getValues()
|
||||||
{
|
{
|
||||||
return m_values;
|
return m_values;
|
||||||
|
@ -338,12 +345,19 @@ public class WButtonEditor extends WEditor implements IProcessButton
|
||||||
|
|
||||||
} // readReference
|
} // readReference
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param actionListener
|
||||||
|
*/
|
||||||
public void addActionListener(ActionListener actionListener)
|
public void addActionListener(ActionListener actionListener)
|
||||||
{
|
{
|
||||||
if (!actionListeners.contains(actionListener))
|
if (!actionListeners.contains(actionListener))
|
||||||
actionListeners.add(actionListener);
|
actionListeners.add(actionListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param actionListener
|
||||||
|
* @return true if found and remove
|
||||||
|
*/
|
||||||
public boolean removeActionListener(ActionListener actionListener)
|
public boolean removeActionListener(ActionListener actionListener)
|
||||||
{
|
{
|
||||||
return actionListeners.remove(actionListener);
|
return actionListeners.remove(actionListener);
|
||||||
|
@ -355,6 +369,7 @@ public class WButtonEditor extends WEditor implements IProcessButton
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event) throws Exception
|
public void onEvent(Event event) throws Exception
|
||||||
{
|
{
|
||||||
if (Events.ON_CLICK.equals(event.getName()))
|
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) {
|
public void setADTabpanel(IADTabpanel adTabpanel) {
|
||||||
this.adTabpanel = adTabpanel;
|
this.adTabpanel = adTabpanel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.adempiere.webui.apps.graph.model.ChartModel;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.model.MChart;
|
import org.compiere.model.MChart;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.zkoss.zk.ui.event.AfterSizeEvent;
|
import org.zkoss.zk.ui.event.AfterSizeEvent;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
|
@ -31,7 +32,8 @@ import org.zkoss.zul.Panel;
|
||||||
import org.zkoss.zul.Panelchildren;
|
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}.<br/>
|
||||||
|
* A readonly editor that render chart from {@link MChart} model to {@link Panel} component.
|
||||||
* @author Low Heng Sin
|
* @author Low Heng Sin
|
||||||
*
|
*
|
||||||
* Modifications - chart display
|
* Modifications - chart display
|
||||||
|
@ -78,6 +80,9 @@ public class WChartEditor extends WEditor
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Re-render chart
|
||||||
|
*/
|
||||||
private void createChart() {
|
private void createChart() {
|
||||||
if (chartHeight > 0 && chartWidth > 0) {
|
if (chartHeight > 0 && chartWidth > 0) {
|
||||||
chartDiv.getChildren().clear();
|
chartDiv.getChildren().clear();
|
||||||
|
@ -96,22 +101,32 @@ public class WChartEditor extends WEditor
|
||||||
return (Panel) component;
|
return (Panel) component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component
|
||||||
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
Panelchildren pc = new Panelchildren();
|
Panelchildren pc = new Panelchildren();
|
||||||
getComponent().appendChild(pc);
|
getComponent().appendChild(pc);
|
||||||
pc.setSclass("chart-field");
|
pc.setSclass("chart-field");
|
||||||
chartDiv = new Div();
|
chartDiv = new Div();
|
||||||
|
//chart is render in ON_AFTER_SIZE event
|
||||||
chartDiv.addEventListener(Events.ON_AFTER_SIZE, this);
|
chartDiv.addEventListener(Events.ON_AFTER_SIZE, this);
|
||||||
pc.appendChild(chartDiv);
|
pc.appendChild(chartDiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link MChart#getName()}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDisplay()
|
public String getDisplay()
|
||||||
{
|
{
|
||||||
return chartModel.get_Translation(MChart.COLUMNNAME_Name);
|
return chartModel.get_Translation(MChart.COLUMNNAME_Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Always return null
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object getValue()
|
public Object getValue()
|
||||||
{
|
{
|
||||||
|
@ -124,23 +139,34 @@ public class WChartEditor extends WEditor
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No op.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setMandatory(boolean mandatory)
|
public void setMandatory(boolean mandatory)
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Always return true
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isReadWrite() {
|
public boolean isReadWrite() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No op.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setReadWrite(boolean readWrite) {
|
public void setReadWrite(boolean readWrite) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No op.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setValue(Object value)
|
public void setValue(Object value)
|
||||||
{
|
{
|
||||||
|
@ -153,6 +179,7 @@ public class WChartEditor extends WEditor
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event) throws Exception
|
public void onEvent(Event event) throws Exception
|
||||||
{
|
{
|
||||||
if (event instanceof AfterSizeEvent && chartModel != null && chartModel.getAD_Chart_ID() > 0)
|
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
|
@Override
|
||||||
public void dynamicDisplay() {
|
public void dynamicDisplay() {
|
||||||
super.dynamicDisplay();
|
super.dynamicDisplay();
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.adempiere.webui.editor;
|
package org.adempiere.webui.editor;
|
||||||
|
|
||||||
import java.beans.PropertyChangeEvent;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
@ -77,7 +76,8 @@ import org.zkoss.zul.Menuitem;
|
||||||
import org.zkoss.zul.South;
|
import org.zkoss.zul.South;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Default editor for {@link DisplayType#ChosenMultipleSelectionList} and {@link DisplayType#ChosenMultipleSelectionTable}.<br/>
|
||||||
|
* Implemented with {@link ChosenSearchBox} component.
|
||||||
* @author hengsin
|
* @author hengsin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -94,12 +94,16 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
}
|
}
|
||||||
|
|
||||||
private Lookup lookup;
|
private Lookup lookup;
|
||||||
|
/** comma separated value list of selected records */
|
||||||
private Object oldValue;
|
private Object oldValue;
|
||||||
|
|
||||||
|
/** CCache listener to auto refresh lookup */
|
||||||
private CCacheListener tableCacheListener;
|
private CCacheListener tableCacheListener;
|
||||||
|
|
||||||
|
/** true if editor is handling onSelect event */
|
||||||
private boolean onselecting = false;
|
private boolean onselecting = false;
|
||||||
|
|
||||||
|
/** Model for {@link Chosenbox} inside {@link ChosenSearchBox} */
|
||||||
private ListModelList<ValueNamePair> model = new ListModelList<>();
|
private ListModelList<ValueNamePair> model = new ListModelList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,6 +126,13 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
this(new ChosenSearchBox(new ChosenboxEditor()), gridField, tableEditor, editorConfiguration);
|
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)
|
private WChosenboxListEditor(Component comp, GridField gridField, boolean tableEditor, IEditorConfiguration editorConfiguration)
|
||||||
{
|
{
|
||||||
super(comp, gridField, tableEditor, 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
|
* Constructor for use if a grid field is unavailable
|
||||||
*
|
*
|
||||||
* @param lookup Store of selectable data
|
* @param lookup Store of selectable data
|
||||||
* @param label column name (not displayed)
|
* @param label field label
|
||||||
* @param description description of component
|
* @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 readonly whether or not the editor is read only
|
||||||
* @param updateable whether the editor contents can be changed
|
* @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);
|
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)
|
private WChosenboxListEditor(Component comp, Lookup lookup, String label, String description, boolean mandatory, boolean readonly, boolean updateable)
|
||||||
{
|
{
|
||||||
super(comp, label, description, mandatory, readonly, 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 columnName
|
||||||
* @param mandatory
|
* @param mandatory
|
||||||
* @param isReadOnly
|
* @param isReadOnly
|
||||||
|
@ -200,6 +219,14 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
this(new ChosenSearchBox(new ChosenboxEditor()), columnName, mandatory, isReadOnly, isUpdateable, lookup);
|
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)
|
private WChosenboxListEditor(Component comp, String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, Lookup lookup)
|
||||||
{
|
{
|
||||||
super(comp, columnName, null, null, mandatory, isReadOnly, isUpdateable);
|
super(comp, columnName, null, null, mandatory, isReadOnly, isUpdateable);
|
||||||
|
@ -211,6 +238,9 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component, lookup and popup menu
|
||||||
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
getComponent().setHflex("true");
|
getComponent().setHflex("true");
|
||||||
|
@ -226,6 +256,7 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
else
|
else
|
||||||
getComponent().getButton().setImage(imageUrl);
|
getComponent().getButton().setImage(imageUrl);
|
||||||
|
|
||||||
|
//open chosenbox dropdown
|
||||||
getComponent().getButton().addEventListener(Events.ON_CLICK, e -> {
|
getComponent().getButton().addEventListener(Events.ON_CLICK, e -> {
|
||||||
if (getComponent().isEnabled()) {
|
if (getComponent().isEnabled()) {
|
||||||
if (!getComponent().getChosenbox().isOpen()) {
|
if (!getComponent().getChosenbox().isOpen()) {
|
||||||
|
@ -277,6 +308,9 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
updateModel();
|
updateModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return comma separated name list of selected records
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDisplay()
|
public String getDisplay()
|
||||||
{
|
{
|
||||||
|
@ -300,6 +334,9 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
return oldValue;
|
return oldValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return comma separated value list of selected records
|
||||||
|
*/
|
||||||
private String getValueFromComponent()
|
private String getValueFromComponent()
|
||||||
{
|
{
|
||||||
StringBuilder retVal = new StringBuilder();
|
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)
|
public void setValue(Object value)
|
||||||
{
|
{
|
||||||
|
@ -331,7 +368,7 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
return;
|
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("[,]");
|
String[] values = ((String)value).split("[,]");
|
||||||
Set<ValueNamePair> selected = new LinkedHashSet<>();
|
Set<ValueNamePair> selected = new LinkedHashSet<>();
|
||||||
|
@ -399,6 +436,9 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
getComponent().setEnabled(readWrite);
|
getComponent().setEnabled(readWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update {@link #model}
|
||||||
|
*/
|
||||||
private void updateModel()
|
private void updateModel()
|
||||||
{
|
{
|
||||||
List<ValueNamePair> list = new ArrayList<>();
|
List<ValueNamePair> list = new ArrayList<>();
|
||||||
|
@ -453,6 +493,7 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
/**
|
/**
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
if (Events.ON_SELECT.equalsIgnoreCase(event.getName()))
|
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) {
|
private void updateValue(Object newValue) {
|
||||||
try {
|
try {
|
||||||
onselecting = true;
|
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) {
|
private boolean isValueChange(Object newValue) {
|
||||||
return (oldValue == null && newValue != null) || (oldValue != null && newValue == null)
|
return (oldValue == null && newValue != null) || (oldValue != null && newValue == null)
|
||||||
|| ((oldValue != null && newValue != null) && !oldValue.equals(newValue));
|
|| ((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.<br/>
|
||||||
|
* Refresh lookup
|
||||||
*/
|
*/
|
||||||
protected void actionRefresh()
|
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
|
@Override
|
||||||
public void dynamicDisplay(Properties ctx)
|
public void dynamicDisplay(Properties ctx)
|
||||||
{
|
{
|
||||||
|
@ -578,6 +619,9 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
super.dynamicDisplay(ctx);
|
super.dynamicDisplay(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup {@link #tableCacheListener}
|
||||||
|
*/
|
||||||
private void createCacheListener() {
|
private void createCacheListener() {
|
||||||
if (lookup != null) {
|
if (lookup != null) {
|
||||||
String columnName = lookup.getColumnName();
|
String columnName = lookup.getColumnName();
|
||||||
|
@ -589,8 +633,10 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom {@link Chosenbox} class for setup and cleanup of tableCacheListener
|
||||||
|
*/
|
||||||
private final static class ChosenboxEditor extends Chosenbox<ValueNamePair> {
|
private final static class ChosenboxEditor extends Chosenbox<ValueNamePair> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generated serial id
|
* generated serial id
|
||||||
*/
|
*/
|
||||||
|
@ -632,7 +678,7 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* clean up tableCacheListener
|
||||||
*/
|
*/
|
||||||
protected void cleanup() {
|
protected void cleanup() {
|
||||||
if (editor != null && editor.tableCacheListener != null) {
|
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<String, Object> {
|
private static class CCacheListener extends CCache<String, Object> {
|
||||||
/**
|
/**
|
||||||
* generated serial
|
* 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<Event> {
|
private class WChosenboxListAssistant extends Window implements EventListener<Event> {
|
||||||
private static final long serialVersionUID = 1043859495570181469L;
|
private static final long serialVersionUID = 1043859495570181469L;
|
||||||
private Button bAdd, bRemove, bUp, bDown;
|
private Button bAdd, bRemove, bUp, bDown;
|
||||||
|
@ -734,12 +786,14 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
mainLayout.appendChild(center);
|
mainLayout.appendChild(center);
|
||||||
center.setAutoscroll(true);
|
center.setAutoscroll(true);
|
||||||
|
|
||||||
|
//Listener for add and remove button
|
||||||
EventListener<Event> actionListener = new EventListener<Event>() {
|
EventListener<Event> actionListener = new EventListener<Event>() {
|
||||||
public void onEvent(Event event) throws Exception {
|
public void onEvent(Event event) throws Exception {
|
||||||
migrateValueAcrossLists(event);
|
migrateValueAcrossLists(event);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Listener for up and down button
|
||||||
EventListener<Event> actionListener2 = new EventListener<Event>() {
|
EventListener<Event> actionListener2 = new EventListener<Event>() {
|
||||||
public void onEvent(Event event) throws Exception {
|
public void onEvent(Event event) throws Exception {
|
||||||
migrateValueWithinSelectedList(event);
|
migrateValueWithinSelectedList(event);
|
||||||
|
@ -815,6 +869,7 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event) throws Exception {
|
public void onEvent(Event event) throws Exception {
|
||||||
if (event.getTarget() == bOk) {
|
if (event.getTarget() == bOk) {
|
||||||
|
|
||||||
|
@ -841,6 +896,15 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
return btn;
|
return btn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param lb
|
||||||
|
* @param model
|
||||||
|
* @param mouseListener
|
||||||
|
* @param crossListMouseListener
|
||||||
|
* @param isItemDraggable
|
||||||
|
* @param headerLabel
|
||||||
|
* @param buttonsLayout
|
||||||
|
*/
|
||||||
private void initListboxAndModel(Listbox lb, SimpleListModel model, EventListener<Event> mouseListener, EventListener<Event> crossListMouseListener, boolean isItemDraggable, String headerLabel, Hlayout buttonsLayout) {
|
private void initListboxAndModel(Listbox lb, SimpleListModel model, EventListener<Event> mouseListener, EventListener<Event> crossListMouseListener, boolean isItemDraggable, String headerLabel, Hlayout buttonsLayout) {
|
||||||
lb.addEventListener(Events.ON_RIGHT_CLICK, this);
|
lb.addEventListener(Events.ON_RIGHT_CLICK, this);
|
||||||
ZKUpdateUtil.setHflex(lb, "1");
|
ZKUpdateUtil.setHflex(lb, "1");
|
||||||
|
@ -913,6 +977,10 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param model
|
||||||
|
* @return opposite model
|
||||||
|
*/
|
||||||
private SimpleListModel getModel(SimpleListModel model) {
|
private SimpleListModel getModel(SimpleListModel model) {
|
||||||
|
|
||||||
SimpleListModel retValue = null;
|
SimpleListModel retValue = null;
|
||||||
|
@ -925,6 +993,10 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle event from add button, remove button and double click.
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
private void migrateValueAcrossLists (Event event) {
|
private void migrateValueAcrossLists (Event event) {
|
||||||
Object source = event.getTarget();
|
Object source = event.getTarget();
|
||||||
if (source instanceof ListItem)
|
if (source instanceof ListItem)
|
||||||
|
@ -940,6 +1012,12 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
migrateLists (listFrom, listTo, endIndex);
|
migrateLists (listFrom, listTo, endIndex);
|
||||||
} // migrateValueAcrossLists
|
} // 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) {
|
private void migrateLists (final Listbox listFrom, final Listbox listTo, final int endIndex) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
final SimpleListModel lmFrom = getModel(listFrom);
|
final SimpleListModel lmFrom = getModel(listFrom);
|
||||||
|
@ -954,12 +1032,18 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
selObjects.add(selObject);
|
selObjects.add(selObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
doTransfer(index, selObjects, lmFrom, lmTo, listFrom, listTo, endIndex);
|
doTransfer(selObjects, lmFrom, lmTo, listTo, endIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doTransfer(int index, List<ValueNamePair > selObjects, SimpleListModel lmFrom, SimpleListModel lmTo, Listbox listFrom , Listbox listTo , int endIndex) {
|
/**
|
||||||
|
* Move selected items from lmFrom to lmTo at endIndex
|
||||||
index = 0;
|
* @param selObjects
|
||||||
|
* @param lmFrom
|
||||||
|
* @param lmTo
|
||||||
|
* @param listTo
|
||||||
|
* @param endIndex
|
||||||
|
*/
|
||||||
|
private void doTransfer(List<ValueNamePair > selObjects, SimpleListModel lmFrom, SimpleListModel lmTo, Listbox listTo , int endIndex) {
|
||||||
Arrays.sort(selObjects.toArray());
|
Arrays.sort(selObjects.toArray());
|
||||||
for (ValueNamePair selObject : selObjects) {
|
for (ValueNamePair selObject : selObjects) {
|
||||||
lmFrom.removeElement(selObject);
|
lmFrom.removeElement(selObject);
|
||||||
|
@ -972,10 +1056,14 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener for DropEvent
|
||||||
|
*/
|
||||||
private class DragListener implements EventListener<Event> {
|
private class DragListener implements EventListener<Event> {
|
||||||
public DragListener() {
|
public DragListener() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event) throws Exception {
|
public void onEvent(Event event) throws Exception {
|
||||||
if (event instanceof DropEvent) {
|
if (event instanceof DropEvent) {
|
||||||
int endIndex = 0;
|
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<ValueNamePair > selObjects) {
|
private void migrateValueWithinSelectedList (SimpleListModel selModel, Listbox selListbox, int endIndex, List<ValueNamePair > selObjects) {
|
||||||
int iniIndex =0;
|
int iniIndex =0;
|
||||||
Arrays.sort(selObjects.toArray());
|
Arrays.sort(selObjects.toArray());
|
||||||
|
@ -1029,6 +1124,11 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle event from up and down button. <br/>
|
||||||
|
* Move selected items up/down within {@link #selectedList}.
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
private void migrateValueWithinSelectedList (Event event) {
|
private void migrateValueWithinSelectedList (Event event) {
|
||||||
Object[] selObjects = selectedList.getSelectedItems().toArray();
|
Object[] selObjects = selectedList.getSelectedItems().toArray();
|
||||||
if (selObjects == null)
|
if (selObjects == null)
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.adempiere.webui.editor;
|
package org.adempiere.webui.editor;
|
||||||
|
|
||||||
import java.beans.PropertyChangeEvent;
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -41,9 +40,11 @@ import org.compiere.model.MSysConfig;
|
||||||
import org.compiere.model.MTable;
|
import org.compiere.model.MTable;
|
||||||
import org.compiere.model.X_AD_CtxHelp;
|
import org.compiere.model.X_AD_CtxHelp;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Util;
|
import org.compiere.util.Util;
|
||||||
import org.compiere.util.ValueNamePair;
|
import org.compiere.util.ValueNamePair;
|
||||||
|
import org.zkoss.addon.chosenbox.Chosenbox;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
|
@ -53,25 +54,32 @@ import org.zkoss.zul.ListModelList;
|
||||||
import org.zkoss.zul.ListSubModel;
|
import org.zkoss.zul.ListSubModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Default editor for {@link DisplayType#ChosenMultipleSelectionSearch}.
|
||||||
|
* Implemented with {@link ChosenSearchBox} component.
|
||||||
* @author hengsin
|
* @author hengsin
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class WChosenboxSearchEditor extends WEditor implements ContextMenuListener
|
public class WChosenboxSearchEditor extends WEditor implements ContextMenuListener
|
||||||
{
|
{
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_SELECT};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_SELECT};
|
||||||
private Lookup lookup;
|
private Lookup lookup;
|
||||||
|
/** Foreign table name */
|
||||||
private String m_tableName = null;
|
private String m_tableName = null;
|
||||||
|
/** Foreign key column name */
|
||||||
private String m_keyColumnName = null;
|
private String m_keyColumnName = null;
|
||||||
|
/** Column name for {@link #lookup} */
|
||||||
private String columnName;
|
private String columnName;
|
||||||
|
/** comma separated value list of selected records */
|
||||||
private String value;
|
private String value;
|
||||||
private InfoPanel infoPanel = null;
|
private InfoPanel infoPanel = null;
|
||||||
|
/** Image URL or font icon sclass for choosebox button */
|
||||||
private String imageUrl;
|
private String imageUrl;
|
||||||
private MyListModel model = new MyListModel();
|
private MyListModel model = new MyListModel();
|
||||||
|
/** Model for {@link Chosenbox} */
|
||||||
private InfoListSubModel subModel = null;
|
private InfoListSubModel subModel = null;
|
||||||
|
|
||||||
private static final CLogger log = CLogger.getCLogger(WChosenboxSearchEditor.class);
|
private static final CLogger log = CLogger.getCLogger(WChosenboxSearchEditor.class);
|
||||||
private static final int DEFAULT_MAX_AUTO_COMPLETE_ROWS = 500;
|
private static final int DEFAULT_MAX_AUTO_COMPLETE_ROWS = 500;
|
||||||
|
/** true when editor is handling ON_SELECT event */
|
||||||
private boolean onselecting;
|
private boolean onselecting;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,7 +126,6 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen
|
||||||
getComponent().setEnabled(readWrite);
|
getComponent().setEnabled(readWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for use if a grid field is unavailable
|
* Constructor for use if a grid field is unavailable
|
||||||
*
|
*
|
||||||
|
@ -144,6 +151,13 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param columnName
|
||||||
|
* @param mandatory
|
||||||
|
* @param readonly
|
||||||
|
* @param updateable
|
||||||
|
* @param lookup
|
||||||
|
*/
|
||||||
public WChosenboxSearchEditor(String columnName, boolean mandatory, boolean readonly, boolean updateable,
|
public WChosenboxSearchEditor(String columnName, boolean mandatory, boolean readonly, boolean updateable,
|
||||||
Lookup lookup)
|
Lookup lookup)
|
||||||
{
|
{
|
||||||
|
@ -163,7 +177,6 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initialise editor
|
* initialise editor
|
||||||
* @param columnName columnName
|
|
||||||
*/
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
|
@ -249,6 +262,9 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return comma separated value list of selected records
|
||||||
|
*/
|
||||||
private String getValueFromComponent()
|
private String getValueFromComponent()
|
||||||
{
|
{
|
||||||
StringBuilder retVal = new StringBuilder();
|
StringBuilder retVal = new StringBuilder();
|
||||||
|
@ -271,6 +287,9 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen
|
||||||
return retVal.length() > 0 ? retVal.toString() : null;
|
return retVal.length() > 0 ? retVal.toString() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return comma separated name list of selected records
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDisplay()
|
public String getDisplay()
|
||||||
{
|
{
|
||||||
|
@ -288,6 +307,7 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen
|
||||||
return display.toString();
|
return display.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event e)
|
public void onEvent(Event e)
|
||||||
{
|
{
|
||||||
if (Events.ON_CLICK.equals(e.getName()))
|
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) {
|
private boolean isValueChange(Object newValue) {
|
||||||
return (value == null && newValue != null) || (value != null && newValue == null)
|
return (value == null && newValue != null) || (value != null && newValue == null)
|
||||||
|| ((value != null && newValue != null) && !value.equals(newValue));
|
|| ((value != null && newValue != null) && !value.equals(newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void propertyChange(PropertyChangeEvent evt)
|
|
||||||
{
|
|
||||||
if ("FieldValue".equals(evt.getPropertyName()))
|
|
||||||
{
|
|
||||||
setValue(evt.getNewValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onMenu(ContextMenuEvent evt)
|
public void onMenu(ContextMenuEvent evt)
|
||||||
{
|
{
|
||||||
if (WEditorPopupMenu.PREFERENCE_EVENT.equals(evt.getContextEvent()))
|
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)
|
private void processSelectedKeys (Object value)
|
||||||
{
|
{
|
||||||
if (log.isLoggable(Level.FINE))
|
if (log.isLoggable(Level.FINE))
|
||||||
|
@ -431,13 +451,19 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen
|
||||||
|
|
||||||
} // actionCombo
|
} // actionCombo
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fire ValueChangeEvent for newValue
|
||||||
|
* @param newValue
|
||||||
|
*/
|
||||||
protected void fireValueChangeEvent(Object newValue) {
|
protected void fireValueChangeEvent(Object newValue) {
|
||||||
ValueChangeEvent evt = new ValueChangeEvent(this, this.getColumnName(), getValue(), newValue);
|
ValueChangeEvent evt = new ValueChangeEvent(this, this.getColumnName(), getValue(), newValue);
|
||||||
// -> ADTabpanel - valuechange
|
// -> ADTabpanel - valuechange
|
||||||
fireValueChange(evt);
|
fireValueChange(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open info panel/window
|
||||||
|
*/
|
||||||
private void actionButton()
|
private void actionButton()
|
||||||
{
|
{
|
||||||
if (lookup == null)
|
if (lookup == null)
|
||||||
|
@ -461,7 +487,10 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen
|
||||||
showInfoPanel(ip);
|
showInfoPanel(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open {@link InfoPanel}
|
||||||
|
* @param ip InfoPanel
|
||||||
|
*/
|
||||||
protected void showInfoPanel(final InfoPanel ip) {
|
protected void showInfoPanel(final InfoPanel ip) {
|
||||||
ip.setVisible(true);
|
ip.setVisible(true);
|
||||||
ip.setStyle("border: 2px");
|
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() {
|
private void setTableAndKeyColumn() {
|
||||||
if (lookup != null && lookup instanceof MLookup) {
|
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()
|
private String getWhereClause()
|
||||||
{
|
{
|
||||||
String whereClause = "";
|
String whereClause = "";
|
||||||
|
@ -563,7 +595,7 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen
|
||||||
return whereClause;
|
return whereClause;
|
||||||
} // getWhereClause
|
} // getWhereClause
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getEvents()
|
public String[] getEvents()
|
||||||
{
|
{
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
|
@ -575,6 +607,9 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen
|
||||||
getComponent().setTableEditorMode(b);
|
getComponent().setTableEditorMode(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link Lookup}
|
||||||
|
*/
|
||||||
public Lookup getLookup() {
|
public Lookup getLookup() {
|
||||||
return lookup;
|
return lookup;
|
||||||
}
|
}
|
||||||
|
@ -588,10 +623,12 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen
|
||||||
super.dynamicDisplay(ctx);
|
super.dynamicDisplay(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link ListSubModel} for {@link Chosenbox} auto complete
|
||||||
|
*/
|
||||||
private class MyListModel extends ListModelList<ValueNamePair> implements ListSubModel<ValueNamePair> {
|
private class MyListModel extends ListModelList<ValueNamePair> implements ListSubModel<ValueNamePair> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* generated serial id
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -1210525428410505409L;
|
private static final long serialVersionUID = -1210525428410505409L;
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.adempiere.webui.event.ValueChangeEvent;
|
||||||
import org.adempiere.webui.theme.ThemeManager;
|
import org.adempiere.webui.theme.ThemeManager;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
import org.compiere.util.Util;
|
import org.compiere.util.Util;
|
||||||
|
@ -52,7 +53,8 @@ import org.zkoss.zul.Html;
|
||||||
import org.zkoss.zul.Menuitem;
|
import org.zkoss.zul.Menuitem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Default editor for {@link DisplayType#Color}.<br/>
|
||||||
|
* Implemented with {@link EditorBox} component and HTML color type (<input type="color">).
|
||||||
* @author Nicolas Micoud (TGI)
|
* @author Nicolas Micoud (TGI)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -62,10 +64,11 @@ public class WColorEditor extends WEditor implements ContextMenuListener
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK};
|
||||||
public static final String COLOR_PICKER_EVENT = "COLOR_PICKER";
|
public static final String COLOR_PICKER_EVENT = "COLOR_PICKER";
|
||||||
|
|
||||||
|
/** Hex coded color value, for e.g #FF0000 */
|
||||||
private String oldValue;
|
private String oldValue;
|
||||||
|
/** Place holder text for text box */
|
||||||
private String placeHolder;
|
private String placeHolder;
|
||||||
|
/** Hidden text box with type set to color. Use to open HTML native color picker. */
|
||||||
private Textbox colorbox;
|
private Textbox colorbox;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,6 +163,9 @@ public class WColorEditor extends WEditor implements ContextMenuListener
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component and context menu
|
||||||
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
if (log.isLoggable(Level.INFO)) log.info("Initializing component");
|
if (log.isLoggable(Level.INFO)) log.info("Initializing component");
|
||||||
|
@ -169,6 +175,10 @@ public class WColorEditor extends WEditor implements ContextMenuListener
|
||||||
addChangeLogMenu(popupMenu);
|
addChangeLogMenu(popupMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add entries to popup context menu
|
||||||
|
* @param popupMenu
|
||||||
|
*/
|
||||||
protected void addColorEditorMenu(WEditorPopupMenu popupMenu) {
|
protected void addColorEditorMenu(WEditorPopupMenu popupMenu) {
|
||||||
Menuitem editor = new Menuitem();
|
Menuitem editor = new Menuitem();
|
||||||
editor.setAttribute("EVENT", WEditorPopupMenu.RESET_EVENT);
|
editor.setAttribute("EVENT", WEditorPopupMenu.RESET_EVENT);
|
||||||
|
@ -191,6 +201,7 @@ public class WColorEditor extends WEditor implements ContextMenuListener
|
||||||
popupMenu.appendChild(editor);
|
popupMenu.appendChild(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onMenu(ContextMenuEvent evt)
|
public void onMenu(ContextMenuEvent evt)
|
||||||
{
|
{
|
||||||
if (WEditorPopupMenu.RESET_EVENT.equals(evt.getContextEvent()))
|
if (WEditorPopupMenu.RESET_EVENT.equals(evt.getContextEvent()))
|
||||||
|
@ -229,6 +240,9 @@ public class WColorEditor extends WEditor implements ContextMenuListener
|
||||||
fillTextbox();
|
fillTextbox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill half of text box with entered color value
|
||||||
|
*/
|
||||||
private void fillTextbox() {
|
private void fillTextbox() {
|
||||||
String style="background-color: transparent !important;";
|
String style="background-color: transparent !important;";
|
||||||
if (!Util.isEmpty(oldValue, true))
|
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
|
* @return background fill style
|
||||||
*/
|
*/
|
||||||
protected String getBackgroundFillStyle(String color) {
|
protected String getBackgroundFillStyle(String color) {
|
||||||
|
@ -271,6 +285,7 @@ public class WColorEditor extends WEditor implements ContextMenuListener
|
||||||
getComponent().getButton().setEnabled(readWrite);
|
getComponent().getButton().setEnabled(readWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
if (Events.ON_CLICK.equalsIgnoreCase(event.getName()))
|
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() {
|
public void openColorPicker() {
|
||||||
String uid = colorbox.getUuid();
|
String uid = colorbox.getUuid();
|
||||||
String script = "(function(){let wgt = zk.Widget.$('#"+uid+"');wgt.$n().click();})()";
|
String script = "(function(){let wgt = zk.Widget.$('#"+uid+"');wgt.$n().click();})()";
|
||||||
Clients.response(new AuScript(script));
|
Clients.response(new AuScript(script));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process newValue from color picker
|
||||||
|
* @param newValue
|
||||||
|
*/
|
||||||
protected void processNewValue(String newValue) {
|
protected void processNewValue(String newValue) {
|
||||||
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
|
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
|
||||||
return;
|
return;
|
||||||
|
@ -301,6 +323,7 @@ public class WColorEditor extends WEditor implements ContextMenuListener
|
||||||
oldValue = getComponent().getTextbox().getValue();
|
oldValue = getComponent().getTextbox().getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getEvents()
|
public String[] getEvents()
|
||||||
{
|
{
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.adempiere.webui.desktop.DashboardController;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.model.MDashboardContent;
|
import org.compiere.model.MDashboardContent;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Util;
|
import org.compiere.util.Util;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
|
@ -41,6 +42,8 @@ import org.zkoss.zul.Panel;
|
||||||
import org.zkoss.zul.Panelchildren;
|
import org.zkoss.zul.Panelchildren;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Default editor for {@link DisplayType#DashboardContent}.<br/>
|
||||||
|
* A readonly editor that render dashboard content from {@link MDashboardContents} to {@link Panel} component.
|
||||||
* @author hengsin
|
* @author hengsin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -64,7 +67,7 @@ public class WDashboardContentEditor extends WEditor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param gridField
|
* @param gridField GridField for PA_DashboardContent_ID
|
||||||
* @param windowNo
|
* @param windowNo
|
||||||
* @param tableEditor
|
* @param tableEditor
|
||||||
* @param editorConfiguration
|
* @param editorConfiguration
|
||||||
|
@ -97,8 +100,8 @@ public class WDashboardContentEditor extends WEditor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.adempiere.webui.editor.WEditor#setReadWrite(boolean)
|
* No op.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setReadWrite(boolean readWrite) {
|
public void setReadWrite(boolean readWrite) {
|
||||||
|
@ -112,29 +115,32 @@ public class WDashboardContentEditor extends WEditor {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.adempiere.webui.editor.WEditor#setValue(java.lang.Object)
|
* No op.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setValue(Object value) {
|
public void setValue(Object value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.adempiere.webui.editor.WEditor#getValue()
|
* Always return null.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object getValue() {
|
public Object getValue() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.adempiere.webui.editor.WEditor#getDisplay()
|
* Always return null.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDisplay() {
|
public String getDisplay() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post {@link #ON_RENDER_CONTENT} event to render dashboard content.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void dynamicDisplay() {
|
public void dynamicDisplay() {
|
||||||
super.dynamicDisplay();
|
super.dynamicDisplay();
|
||||||
|
@ -149,6 +155,10 @@ public class WDashboardContentEditor extends WEditor {
|
||||||
return (Panel) super.getComponent();
|
return (Panel) super.getComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render dashboard content
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
private void render() throws Exception {
|
private void render() throws Exception {
|
||||||
Panel panel = getComponent();
|
Panel panel = getComponent();
|
||||||
panel.setSclass("dashboard-field-panel");
|
panel.setSclass("dashboard-field-panel");
|
||||||
|
|
|
@ -29,11 +29,13 @@ import org.adempiere.webui.event.ValueChangeEvent;
|
||||||
import org.adempiere.webui.window.WFieldRecordInfo;
|
import org.adempiere.webui.window.WFieldRecordInfo;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Default editor for {@link DisplayType#Date}.<br/>
|
||||||
|
* Implemented with {@link Datebox} component.
|
||||||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||||
* @date Mar 12, 2007
|
* @date Mar 12, 2007
|
||||||
* @version $Revision: 0.10 $
|
* @version $Revision: 0.10 $
|
||||||
|
@ -72,16 +74,15 @@ public class WDateEditor extends WEditor implements ContextMenuListener
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for use if a grid field is unavailable
|
* Constructor for use if a grid field is unavailable
|
||||||
*
|
*
|
||||||
* @param label
|
* @param label
|
||||||
* column name (not displayed)
|
* field label
|
||||||
* @param description
|
* @param description
|
||||||
* description of component
|
* field description
|
||||||
* @param mandatory
|
* @param mandatory
|
||||||
* whether a selection must be made
|
* whether field is mandatory
|
||||||
* @param readonly
|
* @param readonly
|
||||||
* whether or not the editor is read only
|
* whether or not the editor is read only
|
||||||
* @param updateable
|
* @param updateable
|
||||||
|
@ -94,6 +95,9 @@ public class WDateEditor extends WEditor implements ContextMenuListener
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor
|
||||||
|
*/
|
||||||
public WDateEditor()
|
public WDateEditor()
|
||||||
{
|
{
|
||||||
this("Date", "Date", false, false, true);
|
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);
|
super(new Datebox(), columnName, title, null, mandatory, readonly, updateable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component and context menu
|
||||||
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
popupMenu = new WEditorPopupMenu(false, false, isShowPreference());
|
popupMenu = new WEditorPopupMenu(false, false, isShowPreference());
|
||||||
|
@ -122,7 +129,7 @@ public class WDateEditor extends WEditor implements ContextMenuListener
|
||||||
getComponent().setPlaceholder(gridField.getPlaceholder());
|
getComponent().setPlaceholder(gridField.getPlaceholder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
if (Events.ON_CHANGE.equalsIgnoreCase(event.getName()) || Events.ON_OK.equalsIgnoreCase(event.getName()))
|
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
|
@Override
|
||||||
public String getDisplay()
|
public String getDisplay()
|
||||||
{
|
{
|
||||||
// Elaine 2008/07/29
|
|
||||||
return getComponent().getText();
|
return getComponent().getText();
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Timestamp getValue()
|
public Timestamp getValue()
|
||||||
{
|
{
|
||||||
// Elaine 2008/07/25
|
|
||||||
if(getComponent().getValue() == null) return null;
|
if(getComponent().getValue() == null) return null;
|
||||||
return Timestamp.valueOf(getComponent().getValue().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
return Timestamp.valueOf(getComponent().getValue().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -211,12 +214,12 @@ public class WDateEditor extends WEditor implements ContextMenuListener
|
||||||
getComponent().setEnabled(readWrite);
|
getComponent().setEnabled(readWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getEvents()
|
public String[] getEvents()
|
||||||
{
|
{
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMenu(ContextMenuEvent evt) {
|
public void onMenu(ContextMenuEvent evt) {
|
||||||
if (WEditorPopupMenu.CHANGE_LOG_EVENT.equals(evt.getContextEvent()))
|
if (WEditorPopupMenu.CHANGE_LOG_EVENT.equals(evt.getContextEvent()))
|
||||||
|
|
|
@ -37,7 +37,8 @@ import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
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
|
* @author Low Heng Sin
|
||||||
*/
|
*/
|
||||||
public class WDatetimeEditor extends WEditor implements ContextMenuListener
|
public class WDatetimeEditor extends WEditor implements ContextMenuListener
|
||||||
|
@ -65,6 +66,8 @@ public class WDatetimeEditor extends WEditor implements ContextMenuListener
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param gridField
|
* @param gridField
|
||||||
|
* @param tableEditor
|
||||||
|
* @param editorConfiguration
|
||||||
*/
|
*/
|
||||||
public WDatetimeEditor(GridField gridField, boolean tableEditor, IEditorConfiguration editorConfiguration)
|
public WDatetimeEditor(GridField gridField, boolean tableEditor, IEditorConfiguration editorConfiguration)
|
||||||
{
|
{
|
||||||
|
@ -72,16 +75,15 @@ public class WDatetimeEditor extends WEditor implements ContextMenuListener
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for use if a grid field is unavailable
|
* Constructor for use if a grid field is unavailable
|
||||||
*
|
*
|
||||||
* @param label
|
* @param label
|
||||||
* column name (not displayed)
|
* field label
|
||||||
* @param description
|
* @param description
|
||||||
* description of component
|
* field description
|
||||||
* @param mandatory
|
* @param mandatory
|
||||||
* whether a selection must be made
|
* whether a field is mandatory
|
||||||
* @param readonly
|
* @param readonly
|
||||||
* whether or not the editor is read only
|
* whether or not the editor is read only
|
||||||
* @param updateable
|
* @param updateable
|
||||||
|
@ -94,6 +96,9 @@ public class WDatetimeEditor extends WEditor implements ContextMenuListener
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor
|
||||||
|
*/
|
||||||
public WDatetimeEditor()
|
public WDatetimeEditor()
|
||||||
{
|
{
|
||||||
this(Msg.getMsg(Env.getCtx(), "DateTime"), Msg.getMsg(Env.getCtx(), "DateTime"), false, false, true);
|
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 mandatory
|
||||||
* @param readonly
|
* @param readonly
|
||||||
* @param updateable
|
* @param updateable
|
||||||
* @param title
|
* @param title field label
|
||||||
*/
|
*/
|
||||||
public WDatetimeEditor(String columnName, boolean mandatory, boolean readonly, boolean updateable,
|
public WDatetimeEditor(String columnName, boolean mandatory, boolean readonly, boolean updateable,
|
||||||
String title)
|
String title)
|
||||||
|
@ -114,6 +119,9 @@ public class WDatetimeEditor extends WEditor implements ContextMenuListener
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component and popup context menu
|
||||||
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
popupMenu = new WEditorPopupMenu(false, false, isShowPreference());
|
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()
|
private boolean isTimestampWithTimeZone()
|
||||||
{
|
{
|
||||||
if (gridField != null)
|
if (gridField != null)
|
||||||
|
@ -189,18 +200,14 @@ public class WDatetimeEditor extends WEditor implements ContextMenuListener
|
||||||
@Override
|
@Override
|
||||||
public String getDisplay()
|
public String getDisplay()
|
||||||
{
|
{
|
||||||
// Elaine 2008/07/29
|
|
||||||
return getComponent().getText();
|
return getComponent().getText();
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValue()
|
public Object getValue()
|
||||||
{
|
{
|
||||||
// Elaine 2008/07/25
|
|
||||||
if(getComponent().getValue() == null) return null;
|
if(getComponent().getValue() == null) return null;
|
||||||
return Timestamp.valueOf(getComponent().getValue().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
return Timestamp.valueOf(getComponent().getValue().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -260,18 +267,17 @@ public class WDatetimeEditor extends WEditor implements ContextMenuListener
|
||||||
return getComponent().isEnabled();
|
return getComponent().isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setReadWrite(boolean readWrite) {
|
public void setReadWrite(boolean readWrite) {
|
||||||
getComponent().setEnabled(readWrite);
|
getComponent().setEnabled(readWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getEvents()
|
public String[] getEvents()
|
||||||
{
|
{
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMenu(ContextMenuEvent evt) {
|
public void onMenu(ContextMenuEvent evt) {
|
||||||
if (WEditorPopupMenu.CHANGE_LOG_EVENT.equals(evt.getContextEvent()))
|
if (WEditorPopupMenu.CHANGE_LOG_EVENT.equals(evt.getContextEvent()))
|
||||||
|
@ -285,7 +291,6 @@ public class WDatetimeEditor extends WEditor implements ContextMenuListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.adempiere.webui.editor.WEditor#setFieldStyle(java.lang.String)
|
* @see org.adempiere.webui.editor.WEditor#setFieldStyle(java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -28,7 +28,9 @@ import org.adempiere.util.GridRowCtx;
|
||||||
import org.adempiere.webui.AdempiereWebUI;
|
import org.adempiere.webui.AdempiereWebUI;
|
||||||
import org.adempiere.webui.ClientInfo;
|
import org.adempiere.webui.ClientInfo;
|
||||||
import org.adempiere.webui.LayoutUtils;
|
import org.adempiere.webui.LayoutUtils;
|
||||||
|
import org.adempiere.webui.adwindow.ADTabpanel;
|
||||||
import org.adempiere.webui.adwindow.ADWindow;
|
import org.adempiere.webui.adwindow.ADWindow;
|
||||||
|
import org.adempiere.webui.adwindow.GridTabRowRenderer;
|
||||||
import org.adempiere.webui.adwindow.IFieldEditorContainer;
|
import org.adempiere.webui.adwindow.IFieldEditorContainer;
|
||||||
import org.adempiere.webui.component.Bandbox;
|
import org.adempiere.webui.component.Bandbox;
|
||||||
import org.adempiere.webui.component.Button;
|
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.Label;
|
||||||
import org.adempiere.webui.component.NumberBox;
|
import org.adempiere.webui.component.NumberBox;
|
||||||
import org.adempiere.webui.component.Paymentbox;
|
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.ContextMenuListener;
|
||||||
import org.adempiere.webui.event.ValueChangeEvent;
|
import org.adempiere.webui.event.ValueChangeEvent;
|
||||||
import org.adempiere.webui.event.ValueChangeListener;
|
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.EventListener;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
import org.zkoss.zul.Combobox;
|
import org.zkoss.zul.Combobox;
|
||||||
|
import org.zkoss.zul.Html;
|
||||||
import org.zkoss.zul.Menuitem;
|
import org.zkoss.zul.Menuitem;
|
||||||
import org.zkoss.zul.Textbox;
|
import org.zkoss.zul.Textbox;
|
||||||
import org.zkoss.zul.Timebox;
|
import org.zkoss.zul.Timebox;
|
||||||
|
@ -68,17 +73,22 @@ import org.zkoss.zul.impl.InputElement;
|
||||||
import org.zkoss.zul.impl.XulElement;
|
import org.zkoss.zul.impl.XulElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Base class for field editor.
|
||||||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||||
* @date Mar 11, 2007
|
* @date Mar 11, 2007
|
||||||
* @version $Revision: 0.10 $
|
* @version $Revision: 0.10 $
|
||||||
*/
|
*/
|
||||||
public abstract class WEditor implements EventListener<Event>, PropertyChangeListener, IInputValidator
|
public abstract class WEditor implements EventListener<Event>, 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;
|
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";
|
public static final String INIT_EDIT_EVENT = "onInitEdit";
|
||||||
|
|
||||||
protected GridField gridField;
|
protected GridField gridField;
|
||||||
|
@ -87,12 +97,14 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
|
|
||||||
protected Label label;
|
protected Label label;
|
||||||
|
|
||||||
|
/** Component of this editor */
|
||||||
protected Component component;
|
protected Component component;
|
||||||
|
|
||||||
protected boolean mandatory;
|
protected boolean mandatory;
|
||||||
|
|
||||||
protected ArrayList<ValueChangeListener> listeners = new ArrayList<ValueChangeListener>();
|
protected ArrayList<ValueChangeListener> listeners = new ArrayList<ValueChangeListener>();
|
||||||
|
|
||||||
|
/** label text */
|
||||||
private String strLabel;
|
private String strLabel;
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
@ -101,18 +113,22 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
|
|
||||||
private String columnName;
|
private String columnName;
|
||||||
|
|
||||||
|
/** Context menu */
|
||||||
protected WEditorPopupMenu popupMenu;
|
protected WEditorPopupMenu popupMenu;
|
||||||
|
|
||||||
|
/** true if it is use inside a grid/list view */
|
||||||
protected boolean tableEditor;
|
protected boolean tableEditor;
|
||||||
|
|
||||||
|
/** true if this is use for process parameter field */
|
||||||
private boolean isProcessParameter;
|
private boolean isProcessParameter;
|
||||||
|
|
||||||
|
/** Optional expected input string */
|
||||||
private String sValidInput;
|
private String sValidInput;
|
||||||
|
|
||||||
private final List<DynamicDisplayListener> dynamicDisplayListeners = new ArrayList<>();
|
private final List<DynamicDisplayListener> dynamicDisplayListeners = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* call to show context menu of this field.
|
* call to show context menu of this field.<br/>
|
||||||
* must call after append component of this field to parent
|
* must call after append component of this field to parent
|
||||||
*/
|
*/
|
||||||
public void showMenu() {
|
public void showMenu() {
|
||||||
|
@ -235,21 +251,19 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normal zk component just fire onChange event when user loss focus
|
* By default, zk component fire onChange event when component loss focus.<br/>
|
||||||
* call this method with true value let component fire event when user type first character
|
* Call this method with true value let component fire event when user type first character.
|
||||||
*
|
* <br/>
|
||||||
* remark: editor set true for this method also need handle INIT_EDIT_EVENT to take effect,
|
* Note: editor that set this to true also need to handle INIT_EDIT_EVENT to take effect,
|
||||||
* can refer implement at {@link WStringEditor#onEvent(Event)}
|
* please see implementation at {@link WStringEditor#onEvent(Event)} for reference.
|
||||||
* @param isChangeEventWhenEditing
|
* @param isChangeEventWhenEditing
|
||||||
*/
|
*/
|
||||||
public void setChangeEventWhenEditing (boolean isChangeEventWhenEditing){
|
public void setChangeEventWhenEditing (boolean isChangeEventWhenEditing){
|
||||||
this.component.setWidgetOverride("isChangeEventWhenEditing", String.valueOf(isChangeEventWhenEditing));
|
this.component.setWidgetOverride("isChangeEventWhenEditing", String.valueOf(isChangeEventWhenEditing));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method is used to distinguish between 2 similar WSearchEditors
|
* @return description
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public String getDescription()
|
public String getDescription()
|
||||||
{
|
{
|
||||||
|
@ -258,37 +272,28 @@ public abstract class WEditor implements EventListener<Event>, 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 comp The editor's component
|
||||||
* @param label column name (not displayed)
|
* @param label field label
|
||||||
* @param description description of component
|
* @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 readonly whether or not the editor is read only
|
||||||
* @param updateable whether the editor contents can be changed
|
* @param updateable whether the editor contents can be changed
|
||||||
*/
|
*/
|
||||||
public WEditor(Component comp, String label, String description, boolean mandatory, boolean readonly, boolean updateable)
|
public WEditor(Component comp, String label, String description, boolean mandatory, boolean readonly, boolean updateable)
|
||||||
{
|
{
|
||||||
if (comp == null)
|
this(comp, null, label, description, mandatory, readonly, updateable);
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Component cannot be null");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setComponent(comp);
|
|
||||||
this.setMandatory(mandatory);
|
|
||||||
this.readOnly = readonly;
|
|
||||||
this.description = description;
|
|
||||||
this.strLabel = label;
|
|
||||||
init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 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 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 readonly whether or not the editor is read only
|
||||||
* @param updateable whether the editor contents can be changed
|
* @param updateable whether the editor contents can be changed
|
||||||
*/
|
*/
|
||||||
|
@ -318,6 +323,9 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
this.component = comp;
|
this.component = comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init label and component
|
||||||
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
label = new Label("");
|
label = new Label("");
|
||||||
|
@ -338,7 +346,7 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
}
|
}
|
||||||
|
|
||||||
component.addEventListener(INIT_EDIT_EVENT, this);
|
component.addEventListener(INIT_EDIT_EVENT, this);
|
||||||
component.setAttribute("idempiere.editor", this);
|
component.setAttribute(IDEMPIERE_EDITOR_ATTR, this);
|
||||||
|
|
||||||
component.addEventListener(Events.ON_FOCUS, e -> {
|
component.addEventListener(Events.ON_FOCUS, e -> {
|
||||||
ADWindow adwindow = ADWindow.findADWindow(component);
|
ADWindow adwindow = ADWindow.findADWindow(component);
|
||||||
|
@ -349,7 +357,6 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return grid field for this editor ( can be null )
|
* @return grid field for this editor ( can be null )
|
||||||
*/
|
*/
|
||||||
public GridField getGridField()
|
public GridField getGridField()
|
||||||
|
@ -358,8 +365,7 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return column name
|
||||||
* @return columnNames
|
|
||||||
*/
|
*/
|
||||||
public String getColumnName()
|
public String getColumnName()
|
||||||
{
|
{
|
||||||
|
@ -368,10 +374,10 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the table qualifier from the supplied column name.
|
* Remove the table qualifier from the supplied column name.
|
||||||
*
|
* <p>
|
||||||
* The column name may be prefixed with the table name
|
* The column name may be prefixed with the table name
|
||||||
* i.e. <code>[table name].[column name]</code>.
|
* i.e. <code>[table name].[column name]</code>.
|
||||||
* The function returns
|
* The function returns the [column name] part.
|
||||||
*
|
*
|
||||||
* @param originalColumnName The column name to clean
|
* @param originalColumnName The column name to clean
|
||||||
* @return the column name with any table qualifier removed
|
* @return the column name with any table qualifier removed
|
||||||
|
@ -391,6 +397,9 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
return cleanColumnName;
|
return cleanColumnName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param columnName
|
||||||
|
*/
|
||||||
protected void setColumnName(String columnName)
|
protected void setColumnName(String columnName)
|
||||||
{
|
{
|
||||||
String cleanColumnName = cleanColumnName(columnName);
|
String cleanColumnName = cleanColumnName(columnName);
|
||||||
|
@ -424,6 +433,7 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Handle PropertyChangeEvent from {@link #gridField}.
|
||||||
* @param evt
|
* @param evt
|
||||||
*/
|
*/
|
||||||
public void propertyChange(final PropertyChangeEvent evt)
|
public void propertyChange(final PropertyChangeEvent evt)
|
||||||
|
@ -444,7 +454,7 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param listener
|
* @param listener ValueChangeListener
|
||||||
*/
|
*/
|
||||||
public void addValueChangeListener(ValueChangeListener listener)
|
public void addValueChangeListener(ValueChangeListener listener)
|
||||||
{
|
{
|
||||||
|
@ -457,11 +467,19 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
listeners.add(listener);
|
listeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param listener
|
||||||
|
* @return true if listener is found and remove from {@link #listeners}
|
||||||
|
*/
|
||||||
public boolean removeValuechangeListener(ValueChangeListener listener)
|
public boolean removeValuechangeListener(ValueChangeListener listener)
|
||||||
{
|
{
|
||||||
return listeners.remove(listener);
|
return listeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fire ValueChangeEvent to ValueChangeListener in {@link #listeners}
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
protected void fireValueChange(ValueChangeEvent event)
|
protected void fireValueChange(ValueChangeEvent event)
|
||||||
{
|
{
|
||||||
//copy to array to avoid concurrent modification exception
|
//copy to array to avoid concurrent modification exception
|
||||||
|
@ -490,7 +508,7 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return editable
|
* @return true if editable
|
||||||
*/
|
*/
|
||||||
public abstract boolean isReadWrite();
|
public abstract boolean isReadWrite();
|
||||||
|
|
||||||
|
@ -505,8 +523,8 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param visible
|
* @param visible visibility for component
|
||||||
* @param labelVisible
|
* @param labelVisible visibility for label
|
||||||
*/
|
*/
|
||||||
public void setVisible(boolean visible, boolean labelVisible)
|
public void setVisible(boolean visible, boolean labelVisible)
|
||||||
{
|
{
|
||||||
|
@ -516,7 +534,7 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return is visible
|
* @return true if component is visible
|
||||||
*/
|
*/
|
||||||
public boolean isVisible()
|
public boolean isVisible()
|
||||||
{
|
{
|
||||||
|
@ -524,7 +542,8 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicating error with changing the style.
|
* Indicating error with changing the style.<br/>
|
||||||
|
* No op. here, for subclass to implement.
|
||||||
* @param error
|
* @param error
|
||||||
*/
|
*/
|
||||||
public void setBackground(boolean error)
|
public void setBackground(boolean error)
|
||||||
|
@ -532,11 +551,17 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set background color of component.<br/>
|
||||||
|
* No op. here, for subclass to implement.
|
||||||
|
* @param color
|
||||||
|
*/
|
||||||
public void setBackground(Color color)
|
public void setBackground(Color color)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder(30);
|
StringBuilder sb = new StringBuilder(30);
|
||||||
|
@ -548,14 +573,13 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Set editor value
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
abstract public void setValue(Object value);
|
abstract public void setValue(Object value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return Object, current value of editor
|
||||||
* @return Object
|
|
||||||
*/
|
*/
|
||||||
abstract public Object getValue();
|
abstract public Object getValue();
|
||||||
|
|
||||||
|
@ -565,10 +589,19 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
*/
|
*/
|
||||||
abstract public String getDisplay();
|
abstract public String getDisplay();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param value
|
||||||
|
* @return display text for grid view, for consumption by {@link #getDisplayComponent()}
|
||||||
|
*/
|
||||||
public String getDisplayTextForGridView(Object value) {
|
public String getDisplayTextForGridView(Object value) {
|
||||||
return getDisplayTextForGridView(null, 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) {
|
public String getDisplayTextForGridView(GridRowCtx gridRowCtx, Object value) {
|
||||||
this.setValue(value);
|
this.setValue(value);
|
||||||
String s = getDisplay();
|
String s = getDisplay();
|
||||||
|
@ -580,7 +613,7 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return list of events
|
* @return list of {@link #component} events that this editor will listen to
|
||||||
*/
|
*/
|
||||||
public String[] getEvents()
|
public String[] getEvents()
|
||||||
{
|
{
|
||||||
|
@ -605,20 +638,24 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return true if field is mandatory
|
||||||
*/
|
*/
|
||||||
public boolean isMandatory()
|
public boolean isMandatory()
|
||||||
{
|
{
|
||||||
return this.mandatory;
|
return this.mandatory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dynamic update of component state
|
||||||
|
*/
|
||||||
public void dynamicDisplay()
|
public void dynamicDisplay()
|
||||||
{
|
{
|
||||||
dynamicDisplay(gridField != null ? gridField.getVO().ctx : Env.getCtx());
|
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)
|
public void dynamicDisplay(Properties ctx)
|
||||||
{
|
{
|
||||||
|
@ -627,20 +664,31 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
updateStyle();
|
updateStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dynamicDisplayListeners.isEmpty())
|
if (!dynamicDisplayListeners.isEmpty())
|
||||||
dynamicDisplayListeners.stream().forEach(e -> e.onDynamicDisplay(ctx, this));
|
dynamicDisplayListeners.stream().forEach(e -> e.onDynamicDisplay(ctx, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update label and component style
|
||||||
|
* @param applyDictionaryStyle
|
||||||
|
*/
|
||||||
public void updateStyle(boolean applyDictionaryStyle) {
|
public void updateStyle(boolean applyDictionaryStyle) {
|
||||||
applyLabelStyles(applyDictionaryStyle);
|
applyLabelStyles(applyDictionaryStyle);
|
||||||
applyFieldStyles(applyDictionaryStyle);
|
applyFieldStyles(applyDictionaryStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update label and component style
|
||||||
|
*/
|
||||||
public void updateStyle() {
|
public void updateStyle() {
|
||||||
applyLabelStyles(true);
|
applyLabelStyles(true);
|
||||||
applyFieldStyles(true);
|
applyFieldStyles(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update label styles
|
||||||
|
* @param applyDictionaryStyle
|
||||||
|
*/
|
||||||
protected void applyLabelStyles(boolean applyDictionaryStyle) {
|
protected void applyLabelStyles(boolean applyDictionaryStyle) {
|
||||||
if (label != null) {
|
if (label != null) {
|
||||||
boolean zoomable = isZoomable();
|
boolean zoomable = isZoomable();
|
||||||
|
@ -673,6 +721,10 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set label style
|
||||||
|
* @param style sclass name (@sclass=) or zclass name (@zclass=) or css style string
|
||||||
|
*/
|
||||||
protected void setLabelStyle(String style) {
|
protected void setLabelStyle(String style) {
|
||||||
if (label != null) {
|
if (label != null) {
|
||||||
if (style != null && style.toLowerCase().startsWith(MStyle.SCLASS_PREFIX)) {
|
if (style != null && style.toLowerCase().startsWith(MStyle.SCLASS_PREFIX)) {
|
||||||
|
@ -684,11 +736,13 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
} else {
|
} else {
|
||||||
label.setStyle(style);
|
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) {
|
protected void applyFieldStyles(boolean applyDictionaryStyle) {
|
||||||
String style = null;
|
String style = null;
|
||||||
if (applyDictionaryStyle && gridField.getAD_FieldStyle_ID() > 0)
|
if (applyDictionaryStyle && gridField.getAD_FieldStyle_ID() > 0)
|
||||||
|
@ -699,6 +753,10 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
setFieldMandatoryStyle(applyDictionaryStyle);
|
setFieldMandatoryStyle(applyDictionaryStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add mandatory style to field
|
||||||
|
* @param applyStyle
|
||||||
|
*/
|
||||||
private void setFieldMandatoryStyle(boolean applyStyle) {
|
private void setFieldMandatoryStyle(boolean applyStyle) {
|
||||||
HtmlBasedComponent component = (HtmlBasedComponent) getComponent();
|
HtmlBasedComponent component = (HtmlBasedComponent) getComponent();
|
||||||
if (component != null) {
|
if (component != null) {
|
||||||
|
@ -709,6 +767,10 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set field style
|
||||||
|
* @param style sclass name (@sclass=) or zclass name (@zclass=) or css style string
|
||||||
|
*/
|
||||||
protected void setFieldStyle(String style) {
|
protected void setFieldStyle(String style) {
|
||||||
HtmlBasedComponent component = (HtmlBasedComponent) getComponent();
|
HtmlBasedComponent component = (HtmlBasedComponent) getComponent();
|
||||||
if (style != null && style.startsWith(MStyle.SCLASS_PREFIX)) {
|
if (style != null && style.startsWith(MStyle.SCLASS_PREFIX)) {
|
||||||
|
@ -744,13 +806,18 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
return true;
|
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) {
|
protected String buildStyle(int AD_Style_ID) {
|
||||||
MStyle style = MStyle.get(Env.getCtx(), AD_Style_ID);
|
MStyle style = MStyle.get(Env.getCtx(), AD_Style_ID);
|
||||||
return style.buildStyle(ThemeManager.getTheme(), getStyleEvaluatee());
|
return style.buildStyle(ThemeManager.getTheme(), getStyleEvaluatee());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stretch editor component to fill container
|
* Stretch editor component to fill parent
|
||||||
*/
|
*/
|
||||||
public void fillHorizontal() {
|
public void fillHorizontal() {
|
||||||
//stretch component to fill grid cell
|
//stretch component to fill grid cell
|
||||||
|
@ -811,15 +878,24 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
updateStyle();
|
updateStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if mandatory style should be added to editor
|
||||||
|
*/
|
||||||
public boolean isMandatoryStyle() {
|
public boolean isMandatoryStyle() {
|
||||||
return mandatory && !readOnly && (isProcessParameter || getGridField().isEditable(true)) && isNullOrEmpty();
|
return mandatory && !readOnly && (isProcessParameter || getGridField().isEditable(true)) && isNullOrEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if current value of editor is null or empty
|
||||||
|
*/
|
||||||
public boolean isNullOrEmpty() {
|
public boolean isNullOrEmpty() {
|
||||||
Object value = getValue();
|
Object value = getValue();
|
||||||
return value == null || value.toString().trim().length() == 0;
|
return value == null || value.toString().trim().length() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if editor support zoom command
|
||||||
|
*/
|
||||||
public boolean isZoomable() {
|
public boolean isZoomable() {
|
||||||
WEditorPopupMenu menu = getPopupMenu();
|
WEditorPopupMenu menu = getPopupMenu();
|
||||||
if (menu != null && menu.isZoomEnabled() && this instanceof IZoomableEditor) {
|
if (menu != null && menu.isZoomEnabled() && this instanceof IZoomableEditor) {
|
||||||
|
@ -829,18 +905,23 @@ public abstract class WEditor implements EventListener<Event>, 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() {
|
protected boolean isShowPreference() {
|
||||||
return MRole.getDefault().isShowPreference() && gridField != null && !gridField.isEncrypted() && !gridField.isEncryptedColumn() && !gridField.isVirtualColumn();
|
return MRole.getDefault().isShowPreference() && gridField != null && !gridField.isEncrypted() && !gridField.isEncryptedColumn() && !gridField.isVirtualColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Add record info entry to context menu
|
||||||
* @param popupMenu
|
* @param popupMenu
|
||||||
*/
|
*/
|
||||||
protected void addChangeLogMenu(WEditorPopupMenu popupMenu) {
|
protected void addChangeLogMenu(WEditorPopupMenu popupMenu) {
|
||||||
|
@ -851,6 +932,7 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Add text editor dialog entry to context menu
|
||||||
* @param popupMenu
|
* @param popupMenu
|
||||||
*/
|
*/
|
||||||
protected void addTextEditorMenu(WEditorPopupMenu popupMenu) {
|
protected void addTextEditorMenu(WEditorPopupMenu popupMenu) {
|
||||||
|
@ -865,6 +947,10 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
popupMenu.appendChild(editor);
|
popupMenu.appendChild(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param comp
|
||||||
|
* @return true if comp is own by this editor instance
|
||||||
|
*/
|
||||||
public boolean isComponentOfEditor(Component comp) {
|
public boolean isComponentOfEditor(Component comp) {
|
||||||
if (comp == getComponent())
|
if (comp == getComponent())
|
||||||
return true;
|
return true;
|
||||||
|
@ -903,24 +989,38 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if editor is use for process parameter field
|
||||||
|
*/
|
||||||
public boolean isProcessParameter() {
|
public boolean isProcessParameter() {
|
||||||
return isProcessParameter;
|
return isProcessParameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to true if editor is use for process parameter field
|
||||||
|
* @param isProcessParameter
|
||||||
|
*/
|
||||||
public void setProcessParameter(boolean isProcessParameter) {
|
public void setProcessParameter(boolean isProcessParameter) {
|
||||||
this.isProcessParameter = isProcessParameter;
|
this.isProcessParameter = isProcessParameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return component use for display value in grid view mode in non edit status
|
* Return component use for display mode in {@link ADTabpanel} grid view ({@link GridTabRowRenderer}) or custom editor
|
||||||
* if return null, a label will replace.
|
* of {@link WListItemRenderer}.<br/>
|
||||||
* because each row must has one instance of this component, don't cache it. just create new instance
|
* For {@link GridTabRowRenderer}, only {@link Html} is supported and will use content
|
||||||
* @return
|
* from {@link #getDisplayTextForGridView(GridRowCtx, Object)}.<br/>
|
||||||
|
* For {@link WListItemRenderer}, {@link Html}, {@link Label} and {@link InputElement} is supported.<br/>
|
||||||
|
* Return null to use the default of {@link ADTabpanel} or {@link WListbox}.<br/>
|
||||||
|
* Note: because each row must has one instance of this component, don't reuse, must always create new instance.<br/>
|
||||||
|
* @return Display {@link Component}
|
||||||
*/
|
*/
|
||||||
public Component getDisplayComponent() {
|
public Component getDisplayComponent() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set focus to next editor
|
||||||
|
*/
|
||||||
protected void focusNext() {
|
protected void focusNext() {
|
||||||
Component comp = getComponent();
|
Component comp = getComponent();
|
||||||
Component parent = comp.getParent();
|
Component parent = comp.getParent();
|
||||||
|
@ -933,6 +1033,10 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return Evaluatee for {@link #buildStyle(int)} use.
|
||||||
|
* @return Evaluatee
|
||||||
|
*/
|
||||||
protected Evaluatee getStyleEvaluatee() {
|
protected Evaluatee getStyleEvaluatee() {
|
||||||
return new EvaluateeWrapper(this, gridField, tableEditor);
|
return new EvaluateeWrapper(this, gridField, tableEditor);
|
||||||
}
|
}
|
||||||
|
@ -987,24 +1091,23 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add listener
|
* add listener for {@link #dynamicDisplay(Properties)}
|
||||||
* @param listener
|
* @param listener {@link DynamicDisplayListener}
|
||||||
*/
|
*/
|
||||||
public void addDynamicDisplayListener(DynamicDisplayListener listener) {
|
public void addDynamicDisplayListener(DynamicDisplayListener listener) {
|
||||||
dynamicDisplayListeners.add(listener);
|
dynamicDisplayListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param listener {@link DynamicDisplayListener}
|
||||||
* @param listener
|
* @return true if listener is found and remove from listener list ({@link #dynamicDisplayListeners}).
|
||||||
* @return true if listener is found and remove from listener list
|
|
||||||
*/
|
*/
|
||||||
public boolean removeDynamicDisplayListener(DynamicDisplayListener listener) {
|
public boolean removeDynamicDisplayListener(DynamicDisplayListener listener) {
|
||||||
return dynamicDisplayListeners.remove(listener);
|
return dynamicDisplayListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* interface for dynamic display event
|
* interface for dynamic display listener
|
||||||
*/
|
*/
|
||||||
public static interface DynamicDisplayListener {
|
public static interface DynamicDisplayListener {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,7 +41,7 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
import org.zkoss.zul.Menuitem;
|
import org.zkoss.zul.Menuitem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Popup context menu for {@link WEditor}.
|
||||||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||||
* @date Mar 25, 2007
|
* @date Mar 25, 2007
|
||||||
* @version $Revision: 0.10 $
|
* @version $Revision: 0.10 $
|
||||||
|
@ -49,16 +49,17 @@ import org.zkoss.zul.Menuitem;
|
||||||
public class WEditorPopupMenu extends Menupopup implements EventListener<Event>
|
public class WEditorPopupMenu extends Menupopup implements EventListener<Event>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
* generated serial id
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 6190279880520042885L;
|
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 EVENT_ATTRIBUTE = "EVENT";
|
||||||
public static final String ZOOM_EVENT = "ZOOM";
|
public static final String ZOOM_EVENT = "ZOOM";
|
||||||
public static final String REQUERY_EVENT = "REQUERY";
|
public static final String REQUERY_EVENT = "REQUERY";
|
||||||
public static final String PREFERENCE_EVENT = "VALUE_PREFERENCE";
|
public static final String PREFERENCE_EVENT = "VALUE_PREFERENCE";
|
||||||
public static final String NEW_EVENT = "NEW_RECORD";
|
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 SHOWLOCATION_EVENT = "SHOW_LOCATION";
|
||||||
public static final String CHANGE_LOG_EVENT = "CHANGE_LOG";
|
public static final String CHANGE_LOG_EVENT = "CHANGE_LOG";
|
||||||
public static final String EDITOR_EVENT = "EDITOR";
|
public static final String EDITOR_EVENT = "EDITOR";
|
||||||
|
@ -67,7 +68,7 @@ public class WEditorPopupMenu extends Menupopup implements EventListener<Event>
|
||||||
public static final String DRILL_EVENT = "DRILL";
|
public static final String DRILL_EVENT = "DRILL";
|
||||||
|
|
||||||
private boolean newEnabled = true;
|
private boolean newEnabled = true;
|
||||||
private boolean updateEnabled = true; // Elaine 2009/02/16 - update record
|
private boolean updateEnabled = true;
|
||||||
private boolean zoomEnabled = true;
|
private boolean zoomEnabled = true;
|
||||||
private boolean requeryEnabled = true;
|
private boolean requeryEnabled = true;
|
||||||
private boolean preferencesEnabled = true;
|
private boolean preferencesEnabled = true;
|
||||||
|
@ -78,15 +79,20 @@ public class WEditorPopupMenu extends Menupopup implements EventListener<Event>
|
||||||
private Menuitem requeryItem;
|
private Menuitem requeryItem;
|
||||||
private Menuitem prefItem;
|
private Menuitem prefItem;
|
||||||
private Menuitem newItem;
|
private Menuitem newItem;
|
||||||
private Menuitem updateItem; // Elaine 2009/02/16 - update record
|
private Menuitem updateItem;
|
||||||
private Menuitem showLocationItem;
|
private Menuitem showLocationItem;
|
||||||
private Menuitem drillItem;
|
private Menuitem drillItem;
|
||||||
|
|
||||||
private ArrayList<ContextMenuListener> menuListeners = new ArrayList<ContextMenuListener>();
|
private ArrayList<ContextMenuListener> menuListeners = new ArrayList<ContextMenuListener>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param zoom
|
||||||
|
* @param requery
|
||||||
|
* @param preferences
|
||||||
|
*/
|
||||||
public WEditorPopupMenu(boolean zoom, boolean requery, boolean 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
|
@Deprecated
|
||||||
|
@ -107,6 +113,15 @@ public class WEditorPopupMenu extends Menupopup implements EventListener<Event>
|
||||||
this(zoom, requery, preferences, newRecord, updateRecord, false, null);
|
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)
|
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);
|
this(zoom, requery, preferences, newRecord, updateRecord, showLocation, false, lookup);
|
||||||
|
@ -119,6 +134,7 @@ public class WEditorPopupMenu extends Menupopup implements EventListener<Event>
|
||||||
* @param newRecord - enable new record (ignored and recalculated if lookup is received)
|
* @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 updateRecord - enable update record (ignored and recalculated if lookup is received)
|
||||||
* @param showLocation - enable show location in menu
|
* @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
|
* @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)
|
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<Event>
|
||||||
this.requeryEnabled = requery;
|
this.requeryEnabled = requery;
|
||||||
this.preferencesEnabled = preferences;
|
this.preferencesEnabled = preferences;
|
||||||
this.newEnabled = newRecord;
|
this.newEnabled = newRecord;
|
||||||
this.updateEnabled = updateRecord; // Elaine 2009/02/16 - update record
|
this.updateEnabled = updateRecord;
|
||||||
this.showLocation = showLocation;
|
this.showLocation = showLocation;
|
||||||
this.drillEnabled = drillEnabled;
|
this.drillEnabled = drillEnabled;
|
||||||
|
|
||||||
|
@ -182,7 +198,13 @@ public class WEditorPopupMenu extends Menupopup implements EventListener<Event>
|
||||||
init();
|
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,
|
return DB.getSQLValueEx(null,
|
||||||
"SELECT COUNT(*) "
|
"SELECT COUNT(*) "
|
||||||
+ "FROM AD_Field f "
|
+ "FROM AD_Field f "
|
||||||
|
@ -197,10 +219,16 @@ public class WEditorPopupMenu extends Menupopup implements EventListener<Event>
|
||||||
winID,winIDPO,tableName) > 0;
|
winID,winIDPO,tableName) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if zoom is enable
|
||||||
|
*/
|
||||||
public boolean isZoomEnabled() {
|
public boolean isZoomEnabled() {
|
||||||
return zoomEnabled;
|
return zoomEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init context menu items
|
||||||
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
if (zoomEnabled)
|
if (zoomEnabled)
|
||||||
|
@ -256,7 +284,6 @@ public class WEditorPopupMenu extends Menupopup implements EventListener<Event>
|
||||||
this.appendChild(newItem);
|
this.appendChild(newItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Elaine 2009/02/16 - update record
|
|
||||||
if (updateEnabled)
|
if (updateEnabled)
|
||||||
{
|
{
|
||||||
updateItem = new Menuitem();
|
updateItem = new Menuitem();
|
||||||
|
@ -297,12 +324,17 @@ public class WEditorPopupMenu extends Menupopup implements EventListener<Event>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add context menu listener
|
||||||
|
* @param listener {@link ContextMenuListener}
|
||||||
|
*/
|
||||||
public void addMenuListener(ContextMenuListener listener)
|
public void addMenuListener(ContextMenuListener listener)
|
||||||
{
|
{
|
||||||
if (!menuListeners.contains(listener))
|
if (!menuListeners.contains(listener))
|
||||||
menuListeners.add(listener);
|
menuListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
String evt = (String)event.getTarget().getAttribute(EVENT_ATTRIBUTE);
|
String evt = (String)event.getTarget().getAttribute(EVENT_ATTRIBUTE);
|
||||||
|
@ -320,6 +352,10 @@ public class WEditorPopupMenu extends Menupopup implements EventListener<Event>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add field suggestion context menu item
|
||||||
|
* @param field
|
||||||
|
*/
|
||||||
public void addSuggestion(final GridField field) {
|
public void addSuggestion(final GridField field) {
|
||||||
if (!MRole.getDefault().isTableAccessExcluded(MFieldSuggestion.Table_ID)) {
|
if (!MRole.getDefault().isTableAccessExcluded(MFieldSuggestion.Table_ID)) {
|
||||||
Menuitem editor = new Menuitem(Msg.getElement(Env.getCtx(), "AD_FieldSuggestion_ID"));
|
Menuitem editor = new Menuitem(Msg.getElement(Env.getCtx(), "AD_FieldSuggestion_ID"));
|
||||||
|
|
|
@ -21,12 +21,14 @@ import org.adempiere.webui.event.ValueChangeEvent;
|
||||||
import org.adempiere.webui.theme.ThemeManager;
|
import org.adempiere.webui.theme.ThemeManager;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Default editor for {@link DisplayType#FilePath}.<br/>
|
||||||
|
* Implemented with {@link FilenameBox} (with upload disable) and {@link FolderBrowser} component.
|
||||||
* @author Low Heng Sin
|
* @author Low Heng Sin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -37,6 +39,7 @@ public class WFileDirectoryEditor extends WEditor
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static final CLogger log = CLogger.getCLogger(WFileDirectoryEditor.class);
|
private static final CLogger log = CLogger.getCLogger(WFileDirectoryEditor.class);
|
||||||
|
|
||||||
|
/** absolute folder/directory path */
|
||||||
private String oldValue;
|
private String oldValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109,6 +112,7 @@ public class WFileDirectoryEditor extends WEditor
|
||||||
getComponent().setEnabled(readWrite);
|
getComponent().setEnabled(readWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
String newValue = null;
|
String newValue = null;
|
||||||
|
@ -134,6 +138,10 @@ public class WFileDirectoryEditor extends WEditor
|
||||||
processNewValue(newValue);
|
processNewValue(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process newValue from user input
|
||||||
|
* @param newValue
|
||||||
|
*/
|
||||||
protected void processNewValue(String newValue) {
|
protected void processNewValue(String newValue) {
|
||||||
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
|
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
|
||||||
return;
|
return;
|
||||||
|
@ -146,7 +154,7 @@ public class WFileDirectoryEditor extends WEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load file
|
* Open folder selection dialog ({@link FolderBrowser}.
|
||||||
*/
|
*/
|
||||||
private void cmd_file()
|
private void cmd_file()
|
||||||
{
|
{
|
||||||
|
@ -162,6 +170,7 @@ public class WFileDirectoryEditor extends WEditor
|
||||||
});
|
});
|
||||||
} // cmd_file
|
} // cmd_file
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getEvents()
|
public String[] getEvents()
|
||||||
{
|
{
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
|
|
|
@ -27,13 +27,15 @@ import org.adempiere.webui.event.ValueChangeEvent;
|
||||||
import org.adempiere.webui.theme.ThemeManager;
|
import org.adempiere.webui.theme.ThemeManager;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
import org.zkoss.util.media.Media;
|
import org.zkoss.util.media.Media;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
import org.zkoss.zk.ui.event.UploadEvent;
|
import org.zkoss.zk.ui.event.UploadEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Default editor for {@link DisplayType#FileName}.<br/>
|
||||||
|
* Implemented with {@link FilenameBox} component with upload enabled.
|
||||||
* @author Low Heng Sin
|
* @author Low Heng Sin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -43,6 +45,7 @@ public class WFilenameEditor extends WEditor
|
||||||
|
|
||||||
private static final CLogger log = CLogger.getCLogger(WFilenameEditor.class);
|
private static final CLogger log = CLogger.getCLogger(WFilenameEditor.class);
|
||||||
|
|
||||||
|
/** absolute folder path + file name */
|
||||||
private String oldValue;
|
private String oldValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,6 +120,7 @@ public class WFilenameEditor extends WEditor
|
||||||
getComponent().setEnabled(readWrite);
|
getComponent().setEnabled(readWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
String newValue = null;
|
String newValue = null;
|
||||||
|
@ -140,6 +144,10 @@ public class WFilenameEditor extends WEditor
|
||||||
processNewValue(newValue);
|
processNewValue(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process newValue from user input
|
||||||
|
* @param newValue
|
||||||
|
*/
|
||||||
protected void processNewValue(String newValue) {
|
protected void processNewValue(String newValue) {
|
||||||
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
|
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
|
||||||
return;
|
return;
|
||||||
|
@ -151,13 +159,14 @@ public class WFilenameEditor extends WEditor
|
||||||
fireValueChange(changeEvent);
|
fireValueChange(changeEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process uploaded file from file selection dialog
|
||||||
|
* @param file {@link Media}
|
||||||
|
*/
|
||||||
private void processUploadMedia(Media file) {
|
private void processUploadMedia(Media file) {
|
||||||
if (file == null)
|
if (file == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// String fileName = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + ;
|
|
||||||
// File tempFile = new File(fileName);
|
|
||||||
|
|
||||||
FileOutputStream fos = null;
|
FileOutputStream fos = null;
|
||||||
String fileName = null;
|
String fileName = null;
|
||||||
try {
|
try {
|
||||||
|
@ -203,6 +212,7 @@ public class WFilenameEditor extends WEditor
|
||||||
processNewValue(getComponent().getText());
|
processNewValue(getComponent().getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getEvents()
|
public String[] getEvents()
|
||||||
{
|
{
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
|
|
|
@ -41,10 +41,9 @@ import org.zkoss.zul.Html;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HTML Editor
|
* Default editor for html (AD_Field.IsHtml=Y) text display type (String, PrinterName, Text, TextLong and Memo). <br/>
|
||||||
* <p> Implementation of an editor to show HTML content </p>
|
* Implemented with {@link Html} component and html editor dialog ({@link WTextEditorDialog}) to show and edit HTML content.
|
||||||
*
|
*
|
||||||
* Based on contribution from
|
|
||||||
* @author muriloht (muriloht@devcoffee.com.br, http://www.devcoffee.com.br)
|
* @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 $
|
* @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;
|
private AbstractADWindowContent adwindowContent;
|
||||||
|
|
||||||
/** HTML Model */
|
/** HTML component */
|
||||||
private Html box = null;
|
private Html box = null;
|
||||||
|
|
||||||
private boolean m_mandatory;
|
private boolean m_mandatory;
|
||||||
|
@ -91,6 +90,9 @@ public class WHtmlEditor extends WEditor implements ContextMenuListener
|
||||||
return (Div) component;
|
return (Div) component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component and context menu.
|
||||||
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
if (log.isLoggable(Level.INFO)) log.info("Initializing component");
|
if (log.isLoggable(Level.INFO)) log.info("Initializing component");
|
||||||
|
@ -133,7 +135,6 @@ public class WHtmlEditor extends WEditor implements ContextMenuListener
|
||||||
return m_mandatory;
|
return m_mandatory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMandatory(boolean mandatory)
|
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() {
|
private void editorEvent() {
|
||||||
adwindowContent = findADWindowContent();
|
adwindowContent = findADWindowContent();
|
||||||
final WTextEditorDialog dialog = new WTextEditorDialog(gridField.getVO().Header, getDisplay(),
|
final WTextEditorDialog dialog = new WTextEditorDialog(gridField.getVO().Header, getDisplay(),
|
||||||
|
@ -230,6 +234,9 @@ public class WHtmlEditor extends WEditor implements ContextMenuListener
|
||||||
dialog.focus();
|
dialog.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return AbstractADWindowContent that own the component of this editor instance
|
||||||
|
*/
|
||||||
private AbstractADWindowContent findADWindowContent() {
|
private AbstractADWindowContent findADWindowContent() {
|
||||||
Component parent = getComponent().getParent();
|
Component parent = getComponent().getParent();
|
||||||
while(parent != null) {
|
while(parent != null) {
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.adempiere.webui.window.WImageDialog;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.model.MImage;
|
import org.compiere.model.MImage;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.zkoss.image.AImage;
|
import org.zkoss.image.AImage;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
|
@ -34,10 +35,9 @@ import org.zkoss.zul.Cell;
|
||||||
import org.zkoss.zul.Image;
|
import org.zkoss.zul.Image;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is based on org.compiere.grid.ed.VImage written by Jorg Janke.
|
* Default editor for {@link DisplayType#Image}.<br/>
|
||||||
* @author Jorg Janke
|
* Implemented with {@link Image} component and {@link WImageDialog}.
|
||||||
*
|
*
|
||||||
* Modifications - UI Compatibility
|
|
||||||
* @author Low Heng Sin
|
* @author Low Heng Sin
|
||||||
*/
|
*/
|
||||||
public class WImageEditor extends WEditor
|
public class WImageEditor extends WEditor
|
||||||
|
@ -94,6 +94,9 @@ public class WImageEditor extends WEditor
|
||||||
return (Image) component;
|
return (Image) component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component
|
||||||
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
AImage img = null;
|
AImage img = null;
|
||||||
|
@ -189,6 +192,7 @@ public class WImageEditor extends WEditor
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event) throws Exception
|
public void onEvent(Event event) throws Exception
|
||||||
{
|
{
|
||||||
if (Events.ON_CLICK.equals(event.getName()) && readwrite)
|
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
|
@Override
|
||||||
public void fillHorizontal() {
|
public void fillHorizontal() {
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
package org.adempiere.webui.editor;
|
package org.adempiere.webui.editor;
|
||||||
|
|
||||||
import java.beans.PropertyChangeEvent;
|
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
@ -38,6 +37,7 @@ import org.compiere.model.GridField;
|
||||||
import org.compiere.model.MLocation;
|
import org.compiere.model.MLocation;
|
||||||
import org.compiere.model.MLocationLookup;
|
import org.compiere.model.MLocationLookup;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
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;
|
import org.zkoss.zk.ui.event.OpenEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Default editor for {@link DisplayType#Location}.<br/>
|
||||||
|
* Implemented with {@link Locationbox} component and {@link WLocationDialog}.
|
||||||
* @author Sendy Yagambrum
|
* @author Sendy Yagambrum
|
||||||
* @date July 16, 2007
|
* @date July 16, 2007
|
||||||
*
|
*
|
||||||
* This class is based on VLocation written by Jorg Janke
|
*/
|
||||||
**/
|
|
||||||
public class WLocationEditor extends WEditor implements EventListener<Event>, PropertyChangeListener, ContextMenuListener, IZoomableEditor
|
public class WLocationEditor extends WEditor implements EventListener<Event>, PropertyChangeListener, ContextMenuListener, IZoomableEditor
|
||||||
{
|
{
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK};
|
||||||
|
@ -97,6 +98,9 @@ public class WLocationEditor extends WEditor implements EventListener<Event>, Pr
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component and context menu
|
||||||
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
if (ThemeManager.isUseFontIconForImage())
|
if (ThemeManager.isUseFontIconForImage())
|
||||||
|
@ -164,7 +168,7 @@ public class WLocationEditor extends WEditor implements EventListener<Event>, Pr
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return Editor value
|
* Return Editor value
|
||||||
* @return value
|
* @return C_Location_ID
|
||||||
*/
|
*/
|
||||||
public int getC_Location_ID()
|
public int getC_Location_ID()
|
||||||
{
|
{
|
||||||
|
@ -173,22 +177,12 @@ public class WLocationEditor extends WEditor implements EventListener<Event>, Pr
|
||||||
return m_value.getC_Location_ID();
|
return m_value.getC_Location_ID();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Property Change Listener
|
|
||||||
* @param evt PropertyChangeEvent
|
|
||||||
*/
|
|
||||||
public void propertyChange (PropertyChangeEvent evt)
|
|
||||||
{
|
|
||||||
if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY))
|
|
||||||
setValue(evt.getNewValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onEvent(Event event) throws Exception
|
public void onEvent(Event event) throws Exception
|
||||||
{
|
{
|
||||||
//
|
|
||||||
if ("onClick".equals(event.getName()))
|
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 WLocationDialog ld = new WLocationDialog(Msg.getMsg(Env.getCtx(), "Location"), m_value, gridField);
|
||||||
final int oldValue = m_value == null ? 0 : m_value.getC_Location_ID();
|
final int oldValue = m_value == null ? 0 : m_value.getC_Location_ID();
|
||||||
ld.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
ld.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.adempiere.webui.editor;
|
||||||
|
|
||||||
import static org.compiere.model.SystemIDs.WINDOW_WAREHOUSE_LOCATOR;
|
import static org.compiere.model.SystemIDs.WINDOW_WAREHOUSE_LOCATOR;
|
||||||
|
|
||||||
import java.beans.PropertyChangeEvent;
|
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
@ -50,6 +49,7 @@ import org.compiere.model.MWarehouse;
|
||||||
import org.compiere.model.X_M_MovementLine;
|
import org.compiere.model.X_M_MovementLine;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
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;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locator Editor : Based on VLocator
|
* Default editor for {@link DisplayType#Locator}.<br/>
|
||||||
|
* Implemented with {@link EditorBox} component and {@link WLocatorDialog}.
|
||||||
*
|
*
|
||||||
* @author Niraj Sohun
|
* @author Niraj Sohun
|
||||||
* @date Jul 23, 2007
|
* @date Jul 23, 2007
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class WLocatorEditor extends WEditor implements EventListener<Event>, PropertyChangeListener, ContextMenuListener, IZoomableEditor
|
public class WLocatorEditor extends WEditor implements EventListener<Event>, PropertyChangeListener, ContextMenuListener, IZoomableEditor
|
||||||
{
|
{
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK};
|
||||||
|
|
||||||
private MLocatorLookup m_mLocator;
|
private MLocatorLookup m_mLocator;
|
||||||
|
/** M_Locator_ID */
|
||||||
private Object m_value;
|
private Object m_value;
|
||||||
private int m_WindowNo;
|
private int m_WindowNo;
|
||||||
|
|
||||||
private static final CLogger log = CLogger.getCLogger(WLocatorEditor.class);
|
private static final CLogger log = CLogger.getCLogger(WLocatorEditor.class);
|
||||||
/**
|
|
||||||
* IDE Constructor
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default Constructor
|
||||||
|
*/
|
||||||
public WLocatorEditor()
|
public WLocatorEditor()
|
||||||
{
|
{
|
||||||
this("M_Locator_ID", false, false, true, null, 0);
|
this("M_Locator_ID", false, false, true, null, 0);
|
||||||
|
@ -91,7 +92,6 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
* @param mLocator locator (lookup) model
|
* @param mLocator locator (lookup) model
|
||||||
* @param windowNo window no
|
* @param windowNo window no
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public WLocatorEditor( String columnName, boolean mandatory, boolean isReadOnly,
|
public WLocatorEditor( String columnName, boolean mandatory, boolean isReadOnly,
|
||||||
boolean isUpdateable, MLocatorLookup mLocator, int windowNo)
|
boolean isUpdateable, MLocatorLookup mLocator, int windowNo)
|
||||||
{
|
{
|
||||||
|
@ -105,8 +105,8 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
getComponent().setButtonImage(ThemeManager.getThemeResource("images/Locator16.png"));
|
getComponent().setButtonImage(ThemeManager.getThemeResource("images/Locator16.png"));
|
||||||
getComponent().getTextbox().setReadonly(true);
|
getComponent().getTextbox().setReadonly(true);
|
||||||
|
|
||||||
m_WindowNo = windowNo; //Yvonne: move it b4 setDefault_Locator_ID()
|
m_WindowNo = windowNo;
|
||||||
setDefault_Locator_ID(); // set default locator, teo_sarca [ 1661546 ]
|
setDefault_Locator_ID();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,7 +133,7 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
getComponent().setButtonImage(ThemeManager.getThemeResource("images/Locator16.png"));
|
getComponent().setButtonImage(ThemeManager.getThemeResource("images/Locator16.png"));
|
||||||
getComponent().getTextbox().setReadonly(true);
|
getComponent().getTextbox().setReadonly(true);
|
||||||
|
|
||||||
setDefault_Locator_ID(); // set default locator, teo_sarca [ 1661546 ]
|
setDefault_Locator_ID();
|
||||||
|
|
||||||
m_WindowNo = gridField.getWindowNo();
|
m_WindowNo = gridField.getWindowNo();
|
||||||
|
|
||||||
|
@ -145,6 +145,10 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
public void setValue(Object value)
|
public void setValue(Object value)
|
||||||
{
|
{
|
||||||
setValue (value, false);
|
setValue (value, false);
|
||||||
|
@ -152,10 +156,9 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Value
|
* Set Value
|
||||||
* @param value value
|
* @param value new value
|
||||||
* @param fire data binding
|
* @param fire true to fire value change event
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void setValue (Object value, boolean fire)
|
private void setValue (Object value, boolean fire)
|
||||||
{
|
{
|
||||||
if(m_mLocator==null)
|
if(m_mLocator==null)
|
||||||
|
@ -187,7 +190,6 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
* Return Editor value
|
* Return Editor value
|
||||||
* @return value
|
* @return value
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Object getValue()
|
public Object getValue()
|
||||||
{
|
{
|
||||||
if (getM_Locator_ID() == 0)
|
if (getM_Locator_ID() == 0)
|
||||||
|
@ -214,9 +216,8 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get M_Locator_ID
|
* Get M_Locator_ID
|
||||||
* @return id
|
* @return M_Locator_ID
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public int getM_Locator_ID()
|
public int getM_Locator_ID()
|
||||||
{
|
{
|
||||||
if (m_value != null
|
if (m_value != null
|
||||||
|
@ -227,15 +228,16 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
} // getM_Locator_ID
|
} // getM_Locator_ID
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return Display Value
|
* Return Display text
|
||||||
* @return display value
|
* @return display text
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getDisplay()
|
public String getDisplay()
|
||||||
{
|
{
|
||||||
return getComponent().getText();
|
return getComponent().getText();
|
||||||
} // getDisplay
|
} // getDisplay
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event) throws Exception
|
public void onEvent(Event event) throws Exception
|
||||||
{
|
{
|
||||||
if (Events.ON_CLICK.equalsIgnoreCase(event.getName()))
|
if (Events.ON_CLICK.equalsIgnoreCase(event.getName()))
|
||||||
|
@ -244,15 +246,13 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
int only_Warehouse_ID = getOnly_Warehouse_ID();
|
int only_Warehouse_ID = getOnly_Warehouse_ID();
|
||||||
int only_Product_ID = getOnly_Product_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))
|
if (event.getTarget() == getComponent() && actionText(only_Warehouse_ID, only_Product_ID))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Button - Start Dialog
|
// Button - Start Dialog
|
||||||
|
|
||||||
int M_Locator_ID = 0;
|
int M_Locator_ID = 0;
|
||||||
|
|
||||||
if (m_value instanceof Integer)
|
if (m_value instanceof Integer)
|
||||||
|
@ -269,7 +269,6 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
public void onEvent(Event event) throws Exception {
|
public void onEvent(Event event) throws Exception {
|
||||||
m_mLocator.setOnly_Warehouse_ID(0);
|
m_mLocator.setOnly_Warehouse_ID(0);
|
||||||
// redisplay
|
// redisplay
|
||||||
|
|
||||||
if (!ld.isChanged())
|
if (!ld.isChanged())
|
||||||
return;
|
return;
|
||||||
setValue (ld.getValue(), true);
|
setValue (ld.getValue(), true);
|
||||||
|
@ -300,6 +299,9 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh MLocator lookup
|
||||||
|
*/
|
||||||
public void actionRefresh()
|
public void actionRefresh()
|
||||||
{
|
{
|
||||||
if (m_mLocator != null)
|
if (m_mLocator != null)
|
||||||
|
@ -315,13 +317,12 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void actionZoom()
|
public void actionZoom()
|
||||||
{
|
{
|
||||||
int AD_Window_ID = MTable.get(Env.getCtx(), MLocator.Table_ID).getAD_Window_ID();
|
int AD_Window_ID = MTable.get(Env.getCtx(), MLocator.Table_ID).getAD_Window_ID();
|
||||||
if (AD_Window_ID <= 0)
|
if (AD_Window_ID <= 0)
|
||||||
AD_Window_ID = WINDOW_WAREHOUSE_LOCATOR; // hardcoded window Warehouse & Locators
|
AD_Window_ID = WINDOW_WAREHOUSE_LOCATOR; // hardcoded window Warehouse & Locators
|
||||||
log.info("");
|
|
||||||
//
|
|
||||||
|
|
||||||
MQuery zoomQuery = new MQuery();
|
MQuery zoomQuery = new MQuery();
|
||||||
zoomQuery.addRestriction(MLocator.COLUMNNAME_M_Locator_ID, MQuery.EQUAL, getValue());
|
zoomQuery.addRestriction(MLocator.COLUMNNAME_M_Locator_ID, MQuery.EQUAL, getValue());
|
||||||
|
@ -330,6 +331,7 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
AEnv.zoom(AD_Window_ID, zoomQuery);
|
AEnv.zoom(AD_Window_ID, zoomQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onMenu(ContextMenuEvent evt)
|
public void onMenu(ContextMenuEvent evt)
|
||||||
{
|
{
|
||||||
if (WEditorPopupMenu.REQUERY_EVENT.equals(evt.getContextEvent()))
|
if (WEditorPopupMenu.REQUERY_EVENT.equals(evt.getContextEvent()))
|
||||||
|
@ -352,19 +354,18 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hit Enter in Text Field
|
* Process input text from user
|
||||||
* @param only_Warehouse_ID if not 0 restrict warehouse
|
* @param only_Warehouse_ID if not 0 restrict warehouse
|
||||||
* @param only_Product_ID of not 0 restricted product
|
* @param only_Product_ID of not 0 restricted product
|
||||||
* @return true if found
|
* @return true if found
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private boolean actionText(int only_Warehouse_ID, int only_Product_ID)
|
private boolean actionText(int only_Warehouse_ID, int only_Product_ID)
|
||||||
{
|
{
|
||||||
String text = getComponent().getText();
|
String text = getComponent().getText();
|
||||||
log.fine(text);
|
if (log.isLoggable(Level.FINE))
|
||||||
|
log.fine(text);
|
||||||
|
|
||||||
// Null
|
// Null
|
||||||
|
|
||||||
if (text == null || text.length() == 0)
|
if (text == null || text.length() == 0)
|
||||||
{
|
{
|
||||||
if (isMandatory())
|
if (isMandatory())
|
||||||
|
@ -382,7 +383,6 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
text = text.toUpperCase() + "%";
|
text = text.toUpperCase() + "%";
|
||||||
|
|
||||||
// Look up - see MLocatorLookup.run
|
// Look up - see MLocatorLookup.run
|
||||||
|
|
||||||
StringBuffer sql = new StringBuffer("SELECT M_Locator_ID FROM M_Locator ")
|
StringBuffer sql = new StringBuffer("SELECT M_Locator_ID FROM M_Locator ")
|
||||||
.append(" WHERE IsActive='Y' AND UPPER(Value) LIKE ")
|
.append(" WHERE IsActive='Y' AND UPPER(Value) LIKE ")
|
||||||
.append(DB.TO_STRING(text));
|
.append(DB.TO_STRING(text));
|
||||||
|
@ -457,7 +457,7 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
* Set Field/WindowNo for ValuePreference (NOP)
|
* Set Field/WindowNo for ValuePreference (NOP)
|
||||||
* @param mField Model Field
|
* @param mField Model Field
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "11")
|
||||||
public void setField (org.compiere.model.GridField mField)
|
public void setField (org.compiere.model.GridField mField)
|
||||||
{
|
{
|
||||||
} // setField
|
} // setField
|
||||||
|
@ -466,7 +466,6 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
* Get Warehouse restriction if any.
|
* Get Warehouse restriction if any.
|
||||||
* @return M_Warehouse_ID or 0
|
* @return M_Warehouse_ID or 0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected int getOnly_Warehouse_ID()
|
protected int getOnly_Warehouse_ID()
|
||||||
{
|
{
|
||||||
//IDEMPIERE-4882 : Load Locator To field value as per Warehouse TO field value
|
//IDEMPIERE-4882 : Load Locator To field value as per Warehouse TO field value
|
||||||
|
@ -495,6 +494,7 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
log.log(Level.WARNING, ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return only_Warehouse_ID;
|
return only_Warehouse_ID;
|
||||||
|
@ -504,7 +504,6 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
* Get Product restriction if any.
|
* Get Product restriction if any.
|
||||||
* @return M_Product_ID or 0
|
* @return M_Product_ID or 0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected int getOnly_Product_ID()
|
protected int getOnly_Product_ID()
|
||||||
{
|
{
|
||||||
if (!Env.isSOTrx(Env.getCtx(), m_WindowNo))
|
if (!Env.isSOTrx(Env.getCtx(), m_WindowNo))
|
||||||
|
@ -528,6 +527,7 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
log.log(Level.WARNING, ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
return only_Product_ID;
|
return only_Product_ID;
|
||||||
} // getOnly_Product_ID
|
} // getOnly_Product_ID
|
||||||
|
@ -538,11 +538,9 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
*
|
*
|
||||||
* @since 3.1.4
|
* @since 3.1.4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void setDefault_Locator_ID()
|
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)
|
if (!isMandatory() || m_mLocator == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -572,20 +570,10 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
|
||||||
setValue(Integer.valueOf(loc.get_ID()));
|
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
|
* return listener events to be associated with editor component
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String[] getEvents()
|
public String[] getEvents()
|
||||||
{
|
{
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
|
|
|
@ -38,6 +38,8 @@ import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Default editor for {@link DisplayType#ID} and {@link DisplayType#isNumeric(int)}.<br/>
|
||||||
|
* Implemented with {@link NumberBox}.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||||
* @date Mar 11, 2007
|
* @date Mar 11, 2007
|
||||||
|
@ -55,30 +57,34 @@ public class WNumberEditor extends WEditor implements ContextMenuListener
|
||||||
public static final int MAX_DISPLAY_LENGTH = 35;
|
public static final int MAX_DISPLAY_LENGTH = 35;
|
||||||
public static final int MIN_DISPLAY_LENGTH = 11;
|
public static final int MIN_DISPLAY_LENGTH = 11;
|
||||||
|
|
||||||
|
/** Integer or BigDecimal */
|
||||||
private Object oldValue;
|
private Object oldValue;
|
||||||
|
|
||||||
private int displayType;
|
private int displayType;
|
||||||
|
|
||||||
private String originalStyle;
|
private String originalStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor, default to {@link DisplayType#Number}.
|
||||||
|
*/
|
||||||
public WNumberEditor()
|
public WNumberEditor()
|
||||||
{
|
{
|
||||||
this(DisplayType.Number);
|
this(DisplayType.Number);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param displayType
|
* @param displayType
|
||||||
*/
|
*/
|
||||||
public WNumberEditor(int displayType)
|
public WNumberEditor(int displayType)
|
||||||
{
|
{
|
||||||
this("Number", false, false, true, displayType, "");
|
this("Number", false, false, true, displayType, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param gridField
|
* @param gridField
|
||||||
*/
|
*/
|
||||||
public WNumberEditor(GridField gridField)
|
public WNumberEditor(GridField gridField)
|
||||||
{
|
{
|
||||||
this(gridField, false, null);
|
this(gridField, false, null);
|
||||||
|
@ -107,6 +113,13 @@ public class WNumberEditor extends WEditor implements ContextMenuListener
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create new {@link NumberBox} instance.
|
||||||
|
* @param gridField
|
||||||
|
* @param tableEditor
|
||||||
|
* @param editorConfiguration
|
||||||
|
* @return NumberBox
|
||||||
|
*/
|
||||||
protected static NumberBox newNumberBox(GridField gridField, boolean tableEditor, IEditorConfiguration editorConfiguration) {
|
protected static NumberBox newNumberBox(GridField gridField, boolean tableEditor, IEditorConfiguration editorConfiguration) {
|
||||||
if (editorConfiguration != null && editorConfiguration instanceof INumberEditorConfiguration) {
|
if (editorConfiguration != null && editorConfiguration instanceof INumberEditorConfiguration) {
|
||||||
INumberEditorConfiguration config = (INumberEditorConfiguration) editorConfiguration;
|
INumberEditorConfiguration config = (INumberEditorConfiguration) editorConfiguration;
|
||||||
|
@ -119,7 +132,7 @@ public class WNumberEditor extends WEditor implements ContextMenuListener
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param gridField
|
* @param gridField
|
||||||
* @param integral
|
* @param integral true to create NumberBox for DisplayType.Integer
|
||||||
*/
|
*/
|
||||||
public WNumberEditor(GridField gridField, boolean integral)
|
public WNumberEditor(GridField gridField, boolean integral)
|
||||||
{
|
{
|
||||||
|
@ -153,6 +166,9 @@ public class WNumberEditor extends WEditor implements ContextMenuListener
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component and context menu
|
||||||
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
setChangeEventWhenEditing (true);
|
setChangeEventWhenEditing (true);
|
||||||
|
@ -166,8 +182,6 @@ public class WNumberEditor extends WEditor implements ContextMenuListener
|
||||||
displayLength = MIN_DISPLAY_LENGTH;
|
displayLength = MIN_DISPLAY_LENGTH;
|
||||||
if (!tableEditor)
|
if (!tableEditor)
|
||||||
getComponent().getDecimalbox().setCols(displayLength);
|
getComponent().getDecimalbox().setCols(displayLength);
|
||||||
// else
|
|
||||||
// getComponent().getDecimalbox().setCols(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DisplayType.isID(displayType))
|
if (DisplayType.isID(displayType))
|
||||||
|
@ -199,6 +213,7 @@ public class WNumberEditor extends WEditor implements ContextMenuListener
|
||||||
* Event handler
|
* Event handler
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
if (Events.ON_CHANGE.equalsIgnoreCase(event.getName()) || Events.ON_OK.equalsIgnoreCase(event.getName()))
|
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
|
* IDEMPIERE-2553 - Enter amounts without decimal separator
|
||||||
* @param oldValue
|
* @param oldValue
|
||||||
* @return
|
* @return oldValue (if oldValue is already with decimal point)<br/>
|
||||||
|
* or oldValue divided by AutomaticDecimalPlacesForAmoun value from Env context
|
||||||
|
* (for e.g, if AutomaticDecimalPlacesForAmoun=2, oldValue/100)
|
||||||
*/
|
*/
|
||||||
public BigDecimal addDecimalPlaces(BigDecimal oldValue){
|
public BigDecimal addDecimalPlaces(BigDecimal oldValue){
|
||||||
if(oldValue.toString().contains("."))
|
if(oldValue.toString().contains("."))
|
||||||
|
@ -257,8 +274,11 @@ public class WNumberEditor extends WEditor implements ContextMenuListener
|
||||||
divisor = BigDecimal.TEN.pow(decimalPlaces);
|
divisor = BigDecimal.TEN.pow(decimalPlaces);
|
||||||
BigDecimal newValue = oldValue.divide(divisor, decimalPlaces, RoundingMode.HALF_UP);
|
BigDecimal newValue = oldValue.divide(divisor, decimalPlaces, RoundingMode.HALF_UP);
|
||||||
return newValue;
|
return newValue;
|
||||||
} //getAddDecimalPlaces
|
} //addDecimalPlaces
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return NumberBox
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public NumberBox getComponent() {
|
public NumberBox getComponent() {
|
||||||
return (NumberBox) component;
|
return (NumberBox) component;
|
||||||
|
@ -310,6 +330,7 @@ public class WNumberEditor extends WEditor implements ContextMenuListener
|
||||||
* Handle context menu events
|
* Handle context menu events
|
||||||
* @param evt
|
* @param evt
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onMenu(ContextMenuEvent evt)
|
public void onMenu(ContextMenuEvent evt)
|
||||||
{
|
{
|
||||||
if (WEditorPopupMenu.PREFERENCE_EVENT.equals(evt.getContextEvent()))
|
if (WEditorPopupMenu.PREFERENCE_EVENT.equals(evt.getContextEvent()))
|
||||||
|
@ -330,8 +351,9 @@ public class WNumberEditor extends WEditor implements ContextMenuListener
|
||||||
getComponent().setTableEditorMode(b);
|
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
|
@Override
|
||||||
protected void setFieldStyle(String style) {
|
protected void setFieldStyle(String style) {
|
||||||
|
|
|
@ -31,14 +31,17 @@ import org.adempiere.webui.window.WPAttributeDialog;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.model.GridTab;
|
import org.compiere.model.GridTab;
|
||||||
import org.compiere.model.Lookup;
|
import org.compiere.model.Lookup;
|
||||||
|
import org.compiere.model.MPAttributeLookup;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Default editor for {@link DisplayType#PAttribute}.<br/>
|
||||||
|
* Implemented with {@link PAttributebox} component and {@link WPAttributeDialog} dialog.
|
||||||
* @author Low Heng Sin
|
* @author Low Heng Sin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -50,10 +53,12 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener
|
||||||
|
|
||||||
protected int m_WindowNo;
|
protected int m_WindowNo;
|
||||||
|
|
||||||
|
/** {@link MPAttributeLookup} */
|
||||||
protected Lookup m_mPAttribute;
|
protected Lookup m_mPAttribute;
|
||||||
|
|
||||||
protected int m_C_BPartner_ID;
|
protected int m_C_BPartner_ID;
|
||||||
|
|
||||||
|
/** M_AttributeSetInstance_ID */
|
||||||
protected Object m_value;
|
protected Object m_value;
|
||||||
|
|
||||||
/** No Instance Key */
|
/** No Instance Key */
|
||||||
|
@ -83,12 +88,14 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component and context menu
|
||||||
|
*/
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
if (ThemeManager.isUseFontIconForImage())
|
if (ThemeManager.isUseFontIconForImage())
|
||||||
getComponent().getButton().setIconSclass("z-icon-PAttribute");
|
getComponent().getButton().setIconSclass("z-icon-PAttribute");
|
||||||
else
|
else
|
||||||
getComponent().setButtonImage(ThemeManager.getThemeResource("images/PAttribute16.png"));
|
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_WindowNo = gridField.getWindowNo();
|
||||||
m_mPAttribute = gridField.getLookup();
|
m_mPAttribute = gridField.getLookup();
|
||||||
|
@ -141,6 +148,7 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener
|
||||||
return getComponent().getText();
|
return getComponent().getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
if (Events.ON_CHANGE.equals(event.getName()) || Events.ON_OK.equals(event.getName()))
|
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()
|
private void cmd_dialog()
|
||||||
{
|
{
|
||||||
//
|
|
||||||
Integer oldValue = (Integer)getValue ();
|
Integer oldValue = (Integer)getValue ();
|
||||||
final int oldValueInt = oldValue == null ? 0 : oldValue.intValue ();
|
final int oldValueInt = oldValue == null ? 0 : oldValue.intValue ();
|
||||||
int M_AttributeSetInstance_ID = oldValueInt;
|
int M_AttributeSetInstance_ID = oldValueInt;
|
||||||
|
@ -247,6 +254,11 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener
|
||||||
}
|
}
|
||||||
} // cmd_dialog
|
} // 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) {
|
private void processChanges(int oldValueInt, int M_AttributeSetInstance_ID) {
|
||||||
if (log.isLoggable(Level.FINEST)) log.finest("Changed M_AttributeSetInstance_ID=" + 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
|
m_value = new Object(); // force re-query display
|
||||||
|
@ -264,11 +276,13 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getEvents()
|
public String[] getEvents()
|
||||||
{
|
{
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onMenu(ContextMenuEvent evt)
|
public void onMenu(ContextMenuEvent evt)
|
||||||
{
|
{
|
||||||
if (WEditorPopupMenu.ZOOM_EVENT.equals(evt.getContextEvent()))
|
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()
|
public void actionZoom()
|
||||||
{
|
{
|
||||||
AEnv.actionZoom(m_mPAttribute, getValue());
|
AEnv.actionZoom(m_mPAttribute, getValue());
|
||||||
|
|
|
@ -17,17 +17,21 @@
|
||||||
|
|
||||||
package org.adempiere.webui.editor;
|
package org.adempiere.webui.editor;
|
||||||
|
|
||||||
|
import org.adempiere.webui.component.Textbox;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Default editor for encrypted (AD_Field.IsEncrypted=Y) text display type (String, PrinterName, Text, TextLong and Memo).<br/>
|
||||||
|
* Extend {@link WStringEditor} and set {@link Textbox} to type="password".
|
||||||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||||
* @date Mar 12, 2007
|
* @date Mar 12, 2007
|
||||||
* @version $Revision: 0.10 $
|
* @version $Revision: 0.10 $
|
||||||
*/
|
*/
|
||||||
public class WPasswordEditor extends WStringEditor
|
public class WPasswordEditor extends WStringEditor
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Default constructor
|
||||||
|
*/
|
||||||
public WPasswordEditor()
|
public WPasswordEditor()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
|
@ -45,7 +45,8 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
import org.zkoss.zul.Comboitem;
|
import org.zkoss.zul.Comboitem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Default editor for {@link DisplayType#Payment}.<br/>
|
||||||
|
* Implemented with {@link Paymentbox} component, {@link WPaymentFormWindow} and {@link IPaymentForm} service.
|
||||||
* @author Elaine
|
* @author Elaine
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -56,6 +57,8 @@ public class WPaymentEditor extends WEditor implements ListDataListener, Context
|
||||||
public final static String[] LISTENER_EVENTS = {Events.ON_SELECT};
|
public final static String[] LISTENER_EVENTS = {Events.ON_SELECT};
|
||||||
|
|
||||||
private MPaymentLookup lookup;
|
private MPaymentLookup lookup;
|
||||||
|
|
||||||
|
/** Payment rule (Cash, credit card, etc) */
|
||||||
private Object oldValue;
|
private Object oldValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,6 +81,9 @@ public class WPaymentEditor extends WEditor implements ListDataListener, Context
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component and context menu
|
||||||
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
getComponent().getCombobox().setAutocomplete(true);
|
getComponent().getCombobox().setAutocomplete(true);
|
||||||
|
@ -213,6 +219,9 @@ public class WPaymentEditor extends WEditor implements ListDataListener, Context
|
||||||
getComponent().setEnabled(readWrite, readWrite && !m_onlyRule);
|
getComponent().setEnabled(readWrite, readWrite && !m_onlyRule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh lookup list
|
||||||
|
*/
|
||||||
private void refreshList()
|
private void refreshList()
|
||||||
{
|
{
|
||||||
if (getComponent().getCombobox().getItemCount() > 0)
|
if (getComponent().getCombobox().getItemCount() > 0)
|
||||||
|
@ -368,17 +377,23 @@ public class WPaymentEditor extends WEditor implements ListDataListener, Context
|
||||||
@Override
|
@Override
|
||||||
public void intervalRemoved(javax.swing.event.ListDataEvent e) {}
|
public void intervalRemoved(javax.swing.event.ListDataEvent e) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param newValue
|
||||||
|
* @return true if newValue is different from {@link #oldValue}
|
||||||
|
*/
|
||||||
private boolean isValueChange(Object newValue) {
|
private boolean isValueChange(Object newValue) {
|
||||||
return (oldValue == null && newValue != null) || (oldValue != null && newValue == null)
|
return (oldValue == null && newValue != null) || (oldValue != null && newValue == null)
|
||||||
|| ((oldValue != null && newValue != null) && !oldValue.equals(newValue));
|
|| ((oldValue != null && newValue != null) && !oldValue.equals(newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getEvents() {
|
public String[] getEvents() {
|
||||||
return LISTENER_EVENTS;
|
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
|
@Override
|
||||||
protected void setFieldStyle(String style) {
|
protected void setFieldStyle(String style) {
|
||||||
|
@ -404,6 +419,9 @@ public class WPaymentEditor extends WEditor implements ListDataListener, Context
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh lookup list
|
||||||
|
*/
|
||||||
public void actionRefresh()
|
public void actionRefresh()
|
||||||
{
|
{
|
||||||
if (lookup != null)
|
if (lookup != null)
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
package org.adempiere.webui.editor;
|
package org.adempiere.webui.editor;
|
||||||
|
|
||||||
import java.beans.PropertyChangeEvent;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -59,7 +58,8 @@ import org.zkoss.zul.Radio;
|
||||||
import org.zkoss.zul.Radiogroup;
|
import org.zkoss.zul.Radiogroup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Default editor for {@link DisplayType#RadiogroupList}.<br/>
|
||||||
|
* Implemented with {@link RadioGroupEditor} component.
|
||||||
* @author hengsin
|
* @author hengsin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -76,8 +76,10 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L
|
||||||
}
|
}
|
||||||
|
|
||||||
private Lookup lookup;
|
private Lookup lookup;
|
||||||
|
/** selected value */
|
||||||
private Object oldValue;
|
private Object oldValue;
|
||||||
|
|
||||||
|
/** true when editor is handling ON_CHECK event */
|
||||||
private boolean onselecting = false;
|
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
|
* Constructor for use if a grid field is unavailable
|
||||||
*
|
*
|
||||||
* @param lookup Store of selectable data
|
* @param lookup Lookup list
|
||||||
* @param label column name (not displayed)
|
* @param label field label
|
||||||
* @param description description of component
|
* @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 readonly whether or not the editor is read only
|
||||||
* @param updateable whether the editor contents can be changed
|
* @param updateable whether the editor contents can be changed
|
||||||
*/
|
*/
|
||||||
|
@ -145,6 +147,9 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init lookup and context menu
|
||||||
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
boolean zoom= false;
|
boolean zoom= false;
|
||||||
|
@ -200,6 +205,7 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setValue(Object value)
|
public void setValue(Object value)
|
||||||
{
|
{
|
||||||
if (onselecting) {
|
if (onselecting) {
|
||||||
|
@ -293,6 +299,9 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L
|
||||||
getComponent().setEnabled(readWrite);
|
getComponent().setEnabled(readWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh lookup list
|
||||||
|
*/
|
||||||
private void refreshList()
|
private void refreshList()
|
||||||
{
|
{
|
||||||
if (getComponent().getItemCount() > 0)
|
if (getComponent().getItemCount() > 0)
|
||||||
|
@ -372,6 +381,7 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L
|
||||||
getComponent().setValue(oldValue);
|
getComponent().setValue(oldValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
if (Events.ON_CHECK.equalsIgnoreCase(event.getName()))
|
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) {
|
private boolean isValueChange(Object newValue) {
|
||||||
return (oldValue == null && newValue != null) || (oldValue != null && newValue == null)
|
return (oldValue == null && newValue != null) || (oldValue != null && newValue == null)
|
||||||
|| ((oldValue != null && newValue != null) && !oldValue.equals(newValue));
|
|| ((oldValue != null && newValue != null) && !oldValue.equals(newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getEvents()
|
public String[] getEvents()
|
||||||
{
|
{
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh lookup list
|
||||||
|
*/
|
||||||
public void actionRefresh()
|
public void actionRefresh()
|
||||||
{
|
{
|
||||||
if (lookup != null)
|
if (lookup != null)
|
||||||
|
@ -430,11 +448,15 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Lookup
|
||||||
|
*/
|
||||||
public Lookup getLookup()
|
public Lookup getLookup()
|
||||||
{
|
{
|
||||||
return lookup;
|
return lookup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onMenu(ContextMenuEvent evt)
|
public void onMenu(ContextMenuEvent evt)
|
||||||
{
|
{
|
||||||
if (WEditorPopupMenu.REQUERY_EVENT.equals(evt.getContextEvent()))
|
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
|
@Override
|
||||||
public void dynamicDisplay(Properties ctx)
|
public void dynamicDisplay(Properties ctx)
|
||||||
{
|
{
|
||||||
|
@ -487,6 +501,9 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L
|
||||||
getPopupMenu().addContextElement(getComponent().radioGroup);
|
getPopupMenu().addContextElement(getComponent().radioGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Container for {@link Radiogroup} and {@link Radio} component.
|
||||||
|
*/
|
||||||
private static class RadioGroupEditor extends Hlayout {
|
private static class RadioGroupEditor extends Hlayout {
|
||||||
/**
|
/**
|
||||||
* generated serial id
|
* generated serial id
|
||||||
|
@ -495,6 +512,9 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L
|
||||||
private Radiogroup radioGroup;
|
private Radiogroup radioGroup;
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor
|
||||||
|
*/
|
||||||
private RadioGroupEditor() {
|
private RadioGroupEditor() {
|
||||||
newRadioGroup();
|
newRadioGroup();
|
||||||
appendChild(radioGroup);
|
appendChild(radioGroup);
|
||||||
|
@ -503,6 +523,9 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L
|
||||||
setStyle("white-space: normal");
|
setStyle("white-space: normal");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create new {@link Radiogroup} instance.
|
||||||
|
*/
|
||||||
private void newRadioGroup() {
|
private void newRadioGroup() {
|
||||||
radioGroup = new Radiogroup();
|
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) {
|
public boolean isSelected(Object value) {
|
||||||
Radio radio = getSelectedItem();
|
Radio radio = getSelectedItem();
|
||||||
if (radio != null && radio.getValue() != null && value != null) {
|
if (radio != null && radio.getValue() != null && value != null) {
|
||||||
|
@ -527,16 +554,26 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return selected {@link Radio} item
|
||||||
|
*/
|
||||||
public Radio getSelectedItem() {
|
public Radio getSelectedItem() {
|
||||||
return radioGroup.getSelectedItem();
|
return radioGroup.getSelectedItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set {@link #radioGroup} selected item to item
|
||||||
|
* @param item
|
||||||
|
*/
|
||||||
public void setSelectedItem(Radio item) {
|
public void setSelectedItem(Radio item) {
|
||||||
if (item != null && item.isSelected())
|
if (item != null && item.isSelected())
|
||||||
item.setSelected(false);
|
item.setSelected(false);
|
||||||
radioGroup.setSelectedItem(item);
|
radioGroup.setSelectedItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all {@link Radio} items from {@link #radioGroup}
|
||||||
|
*/
|
||||||
public void removeAllItems() {
|
public void removeAllItems() {
|
||||||
List<Radio> items = radioGroup.getItems();
|
List<Radio> items = radioGroup.getItems();
|
||||||
for (Radio radio : items) {
|
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) {
|
public void setValue(Object newValue) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
if (newValue != null) {
|
if (newValue != null) {
|
||||||
|
@ -560,10 +601,18 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L
|
||||||
setSelectedItem(null);
|
setSelectedItem(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return radio item count
|
||||||
|
*/
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return radioGroup.getItemCount();
|
return radioGroup.getItemCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add new {@link Radio} item
|
||||||
|
* @param name
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
public void appendItem(String name, String value) {
|
public void appendItem(String name, String value) {
|
||||||
if (Util.isEmpty(name))
|
if (Util.isEmpty(name))
|
||||||
return;
|
return;
|
||||||
|
@ -571,6 +620,12 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L
|
||||||
radioGroup.appendChild(radio);
|
radioGroup.appendChild(radio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create new {@link Radio} item.
|
||||||
|
* @param name
|
||||||
|
* @param value
|
||||||
|
* @return {@link Radio}
|
||||||
|
*/
|
||||||
protected Radio newRadio(String name, Object value) {
|
protected Radio newRadio(String name, Object value) {
|
||||||
Radio radio = new Radio(name);
|
Radio radio = new Radio(name);
|
||||||
radio.setValue(value);
|
radio.setValue(value);
|
||||||
|
@ -579,6 +634,11 @@ public class WRadioGroupEditor extends WEditor implements ContextMenuListener, L
|
||||||
return radio;
|
return radio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add new {@link Radio} item
|
||||||
|
* @param name
|
||||||
|
* @param key
|
||||||
|
*/
|
||||||
public void appendItem(String name, int key) {
|
public void appendItem(String name, int key) {
|
||||||
if (Util.isEmpty(name))
|
if (Util.isEmpty(name))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -61,7 +61,9 @@ import org.zkoss.zk.ui.sys.ComponentCtrl;
|
||||||
import org.zkoss.zul.Div;
|
import org.zkoss.zul.Div;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Default editor for {@link DisplayType#RecordID} and {@link DisplayType#RecordUU}.<br/>
|
||||||
|
* Implemented with composite component of {@link Textbox} and {@link ToolBarButton}.<br/>
|
||||||
|
* The editor uses {@link WRecordIDDialog} for edit or viewing.
|
||||||
* @author Peter Takacs, Cloudempiere
|
* @author Peter Takacs, Cloudempiere
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -69,12 +71,12 @@ public class WRecordIDEditor extends WEditor implements ContextMenuListener, IZo
|
||||||
|
|
||||||
/** Is Read/Write enabled on the editor */
|
/** Is Read/Write enabled on the editor */
|
||||||
private boolean m_ReadWrite;
|
private boolean m_ReadWrite;
|
||||||
/** Old value (Record_ID) */
|
/** Record_ID or Record_UU value */
|
||||||
private Object recordIDValue;
|
private Object recordIDValue;
|
||||||
/** Old value (AD_Table_ID) */
|
/** AD_Table_ID value */
|
||||||
private Object tableIDValue;
|
private Object tableIDValue;
|
||||||
|
|
||||||
/** Current tab's AD_Table_ID GrodField */
|
/** Current tab's AD_Table_ID GridField */
|
||||||
private GridField tableIDGridField;
|
private GridField tableIDGridField;
|
||||||
|
|
||||||
// UI components
|
// UI components
|
||||||
|
@ -82,7 +84,7 @@ public class WRecordIDEditor extends WEditor implements ContextMenuListener, IZo
|
||||||
private ToolBarButton editButton;
|
private ToolBarButton editButton;
|
||||||
private ToolBarButton zoomButton;
|
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_ZOOM_PNG = "images/Zoom16.png";
|
||||||
private static final String IMAGES_CONTEXT_EDIT_RECORD_PNG = "images/EditRecord16.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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component and context menu
|
||||||
|
*/
|
||||||
private void init() {
|
private void init() {
|
||||||
if(gridTab != null) {
|
if(gridTab != null) {
|
||||||
tableIDGridField = gridTab.getField("AD_Table_ID");
|
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) {
|
private void afterPageAttached(Object t) {
|
||||||
if (t instanceof Component) {
|
if (t instanceof Component) {
|
||||||
Component component = (Component) t;
|
Component component = (Component) t;
|
||||||
|
@ -173,25 +182,28 @@ public class WRecordIDEditor extends WEditor implements ContextMenuListener, IZo
|
||||||
field = field.clone(gridField.getVO().ctx);
|
field = field.clone(gridField.getVO().ctx);
|
||||||
field.loadLookupNoValidate();
|
field.loadLookupNoValidate();
|
||||||
Lookup lookup = field.getLookup();
|
Lookup lookup = field.getLookup();
|
||||||
if (lookup != null && lookup instanceof MLookup)
|
if (lookup != null && lookup instanceof MLookup)
|
||||||
{
|
|
||||||
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 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;
|
mLookup.getLookupInfo().IsValidated = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
tableIDGridField = field;
|
||||||
tableIDGridField = field;
|
if (tableIDValue != null)
|
||||||
if (tableIDValue != null)
|
tableIDGridField.setValue(tableIDValue, false);
|
||||||
tableIDGridField.setValue(tableIDValue, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh text box display text
|
||||||
|
*/
|
||||||
private void actionRefresh()
|
private void actionRefresh()
|
||||||
{
|
{
|
||||||
recordTextBox.setValue(getDisplay());
|
recordTextBox.setValue(getDisplay());
|
||||||
|
@ -221,7 +233,6 @@ public class WRecordIDEditor extends WEditor implements ContextMenuListener, IZo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMenu(ContextMenuEvent evt)
|
public void onMenu(ContextMenuEvent evt)
|
||||||
{
|
{
|
||||||
|
@ -257,6 +268,7 @@ public class WRecordIDEditor extends WEditor implements ContextMenuListener, IZo
|
||||||
return m_ReadWrite;
|
return m_ReadWrite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void propertyChange(PropertyChangeEvent evt)
|
public void propertyChange(PropertyChangeEvent evt)
|
||||||
{
|
{
|
||||||
if (GridField.PROPERTY.equals(evt.getPropertyName()))
|
if (GridField.PROPERTY.equals(evt.getPropertyName()))
|
||||||
|
@ -286,10 +298,9 @@ public class WRecordIDEditor extends WEditor implements ContextMenuListener, IZo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Value
|
* Set Value
|
||||||
* @param value value
|
* @param value new value
|
||||||
* @param fire data binding
|
* @param fire true to fire value change event
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void setValue (Object value, boolean fire) {
|
private void setValue (Object value, boolean fire) {
|
||||||
if (value == null || Util.isEmpty(value.toString(), true)) {
|
if (value == null || Util.isEmpty(value.toString(), true)) {
|
||||||
recordTextBox.setValue("");
|
recordTextBox.setValue("");
|
||||||
|
@ -453,7 +464,7 @@ public class WRecordIDEditor extends WEditor implements ContextMenuListener, IZo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get AD_Table_ID
|
* Get AD_Table_ID
|
||||||
* @return Object
|
* @return AD_Table_ID value
|
||||||
*/
|
*/
|
||||||
public Object getAD_Table_ID() {
|
public Object getAD_Table_ID() {
|
||||||
return tableIDValue;
|
return tableIDValue;
|
||||||
|
|
|
@ -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_INVOICELINE_M_PRODUCT_ID;
|
||||||
import static org.compiere.model.SystemIDs.COLUMN_C_INVOICE_C_BPARTNER_ID;
|
import static org.compiere.model.SystemIDs.COLUMN_C_INVOICE_C_BPARTNER_ID;
|
||||||
|
|
||||||
import java.beans.PropertyChangeEvent;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
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.event.ValueChangeListener;
|
||||||
import org.adempiere.webui.factory.InfoManager;
|
import org.adempiere.webui.factory.InfoManager;
|
||||||
import org.adempiere.webui.grid.WQuickEntry;
|
import org.adempiere.webui.grid.WQuickEntry;
|
||||||
|
import org.adempiere.webui.info.InfoWindow;
|
||||||
import org.adempiere.webui.panel.IHelpContext;
|
import org.adempiere.webui.panel.IHelpContext;
|
||||||
import org.adempiere.webui.panel.InfoPanel;
|
import org.adempiere.webui.panel.InfoPanel;
|
||||||
import org.adempiere.webui.part.WindowContainer;
|
import org.adempiere.webui.part.WindowContainer;
|
||||||
|
@ -72,8 +72,8 @@ import org.zkoss.zk.ui.event.InputEvent;
|
||||||
import org.zkoss.zk.ui.util.Clients;
|
import org.zkoss.zk.ui.util.Clients;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search Editor for web UI.
|
* Default editor for {@link DisplayType#Search} and {@link DisplayType#SearchUU}.<br/>
|
||||||
* Web UI port of search type VLookup
|
* Implemented with {@link CustomSearchBox} component and {@link InfoPanel}, {@link InfoWindow} dialog.
|
||||||
*
|
*
|
||||||
* @author Ashley G Ramdass
|
* @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 int DEFAULT_MAX_AUTO_COMPLETE_ROWS = 500;
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_CHANGE, Events.ON_OK};
|
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";
|
public static final String ATTRIBUTE_IS_INFO_PANEL_OPEN = "ATTRIBUTE_IS_INFO_PANEL_OPEN";
|
||||||
protected Lookup lookup;
|
protected Lookup lookup;
|
||||||
|
/** Reference/target table name */
|
||||||
private String m_tableName = null;
|
private String m_tableName = null;
|
||||||
|
/** Reference/target key column name */
|
||||||
private String m_keyColumnName = null;
|
private String m_keyColumnName = null;
|
||||||
|
/** Source/field column name */
|
||||||
private String columnName;
|
private String columnName;
|
||||||
|
/** ID or UUID value */
|
||||||
private Object value;
|
private Object value;
|
||||||
protected InfoPanel infoPanel = null;
|
protected InfoPanel infoPanel = null;
|
||||||
|
/** Image URL or font icon sclass for CustomSearchbox button */
|
||||||
private String imageUrl;
|
private String imageUrl;
|
||||||
|
/** Model for auto complete search */
|
||||||
private InfoListSubModel listModel = null;
|
private InfoListSubModel listModel = null;
|
||||||
|
|
||||||
private static final CLogger log = CLogger.getCLogger(WSearchEditor.class);
|
private static final CLogger log = CLogger.getCLogger(WSearchEditor.class);
|
||||||
|
|
||||||
private static final String IN_PROGRESS_IMAGE = "~./zk/img/progress3.gif";
|
private static final String IN_PROGRESS_IMAGE = "~./zk/img/progress3.gif";
|
||||||
|
|
||||||
|
/** ADWindow instance that own this editor */
|
||||||
protected ADWindow adwindow;
|
protected ADWindow adwindow;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -148,9 +156,9 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
* Constructor for use if a grid field is unavailable
|
* Constructor for use if a grid field is unavailable
|
||||||
*
|
*
|
||||||
* @param lookup Store of selectable data
|
* @param lookup Store of selectable data
|
||||||
* @param label column name (not displayed)
|
* @param label field label
|
||||||
* @param description description of component
|
* @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 readonly whether or not the editor is read only
|
||||||
* @param updateable whether the editor contents can be changed
|
* @param updateable whether the editor contents can be changed
|
||||||
*/
|
*/
|
||||||
|
@ -169,6 +177,14 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param columnName
|
||||||
|
* @param mandatory
|
||||||
|
* @param readonly
|
||||||
|
* @param updateable
|
||||||
|
* @param lookup
|
||||||
|
*/
|
||||||
public WSearchEditor(String columnName, boolean mandatory, boolean readonly, boolean updateable,
|
public WSearchEditor(String columnName, boolean mandatory, boolean readonly, boolean updateable,
|
||||||
Lookup lookup)
|
Lookup lookup)
|
||||||
{
|
{
|
||||||
|
@ -187,8 +203,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initialise editor
|
* Initialise component and context menu
|
||||||
* @param columnName columnName
|
|
||||||
*/
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
|
@ -327,6 +342,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
return getComponent().getText();
|
return getComponent().getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event e)
|
public void onEvent(Event e)
|
||||||
{
|
{
|
||||||
if (Events.ON_CHANGE.equals(e.getName()))
|
if (Events.ON_CHANGE.equals(e.getName()))
|
||||||
|
@ -354,7 +370,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
&& !isQuickFormComp
|
&& !isQuickFormComp
|
||||||
&& isReadWrite())
|
&& isReadWrite())
|
||||||
{
|
{
|
||||||
// open Info window similar to swing client
|
// open Info window
|
||||||
if (infoPanel != null)
|
if (infoPanel != null)
|
||||||
{
|
{
|
||||||
infoPanel.detach();
|
infoPanel.detach();
|
||||||
|
@ -376,32 +392,33 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public void propertyChange(PropertyChangeEvent evt)
|
* Refresh editor value
|
||||||
{
|
* @param value
|
||||||
if ("FieldValue".equals(evt.getPropertyName()))
|
*/
|
||||||
{
|
|
||||||
actionRefresh(evt.getNewValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void actionRefresh(Object value)
|
protected void actionRefresh(Object value)
|
||||||
{
|
{
|
||||||
// boolean mandatory = isMandatory();
|
|
||||||
// AEnv.actionRefresh(lookup, value, mandatory);
|
|
||||||
setValue(value);
|
setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zoom to window for reference/target table
|
||||||
|
*/
|
||||||
public void actionZoom()
|
public void actionZoom()
|
||||||
{
|
{
|
||||||
AEnv.actionZoom(lookup, getValue());
|
AEnv.actionZoom(lookup, getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zoom to window for reference/target table
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
private void actionZoom(Object value)
|
private void actionZoom(Object value)
|
||||||
{
|
{
|
||||||
AEnv.actionZoom(lookup, value);
|
AEnv.actionZoom(lookup, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onMenu(ContextMenuEvent evt)
|
public void onMenu(ContextMenuEvent evt)
|
||||||
{
|
{
|
||||||
if (WEditorPopupMenu.REQUERY_EVENT.equals(evt.getContextEvent()))
|
if (WEditorPopupMenu.REQUERY_EVENT.equals(evt.getContextEvent()))
|
||||||
|
@ -427,7 +444,6 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
}
|
}
|
||||||
actionQuickEntry(true);
|
actionQuickEntry(true);
|
||||||
}
|
}
|
||||||
// Elaine 2009/02/16 - update record
|
|
||||||
else if (WEditorPopupMenu.UPDATE_EVENT.equals(evt.getContextEvent()))
|
else if (WEditorPopupMenu.UPDATE_EVENT.equals(evt.getContextEvent()))
|
||||||
{
|
{
|
||||||
if (infoPanel != null)
|
if (infoPanel != null)
|
||||||
|
@ -445,9 +461,12 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
{
|
{
|
||||||
actionDrill();
|
actionDrill();
|
||||||
}
|
}
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process text input from user
|
||||||
|
* @param text
|
||||||
|
*/
|
||||||
protected void actionText(String text)
|
protected void actionText(String text)
|
||||||
{
|
{
|
||||||
// Nothing entered
|
// Nothing entered
|
||||||
|
@ -464,6 +483,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
if (m_tableName == null) // sets table name & key column
|
if (m_tableName == null) // sets table name & key column
|
||||||
setTableAndKeyColumn();
|
setTableAndKeyColumn();
|
||||||
|
|
||||||
|
// process input text with infopanel/infowindow
|
||||||
final InfoPanel ip = InfoManager.create(lookup, gridField, m_tableName, m_keyColumnName, getComponent().getText(), false, getWhereClause());
|
final InfoPanel ip = InfoManager.create(lookup, gridField, m_tableName, m_keyColumnName, getComponent().getText(), false, getWhereClause());
|
||||||
if (ip != null && ip.loadedOK() && ip.getRowCount() == 1)
|
if (ip != null && ip.loadedOK() && ip.getRowCount() == 1)
|
||||||
{
|
{
|
||||||
|
@ -516,6 +536,9 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
resetButtonState();
|
resetButtonState();
|
||||||
} // actionText
|
} // actionText
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open drill assistant dialog
|
||||||
|
*/
|
||||||
protected void actionDrill() {
|
protected void actionDrill() {
|
||||||
if(getGridField() == null || getGridField().getGridTab() == null)
|
if(getGridField() == null || getGridField().getGridTab() == null)
|
||||||
return;
|
return;
|
||||||
|
@ -530,6 +553,9 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
AEnv.actionDrill(data, windowNo);
|
AEnv.actionDrill(data, windowNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset state of {@link CustomSearchBox} button to default
|
||||||
|
*/
|
||||||
protected void resetButtonState() {
|
protected void resetButtonState() {
|
||||||
getComponent().getButton().setEnabled(true);
|
getComponent().getButton().setEnabled(true);
|
||||||
if (ThemeManager.isUseFontIconForImage())
|
if (ThemeManager.isUseFontIconForImage())
|
||||||
|
@ -539,7 +565,11 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
getComponent().invalidate();
|
getComponent().invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process value from InfoPanel/InfoWindow.<br/>
|
||||||
|
* Fire ValueChangeEvent.
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
protected void actionCombo (Object value)
|
protected void actionCombo (Object value)
|
||||||
{
|
{
|
||||||
if (log.isLoggable(Level.FINE))
|
if (log.isLoggable(Level.FINE))
|
||||||
|
@ -640,8 +670,6 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
setValue(Integer.valueOf(result));
|
setValue(Integer.valueOf(result));
|
||||||
actionCombo (Integer.valueOf(result)); // data binding
|
actionCombo (Integer.valueOf(result)); // data binding
|
||||||
lookup.refresh();
|
lookup.refresh();
|
||||||
|
|
||||||
//setValue(getValue());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -657,6 +685,10 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
}
|
}
|
||||||
} // actionQuickEntry
|
} // actionQuickEntry
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle onClick event from {@link CustomSearchBox} button.
|
||||||
|
* @param queryValue
|
||||||
|
*/
|
||||||
protected void actionButton(String queryValue)
|
protected void actionButton(String queryValue)
|
||||||
{
|
{
|
||||||
if (lookup == null)
|
if (lookup == null)
|
||||||
|
@ -675,8 +707,6 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
if (log.isLoggable(Level.FINE))
|
if (log.isLoggable(Level.FINE))
|
||||||
log.fine(lookup.getColumnName() + ", Zoom=" + lookup.getZoom() + " (" + whereClause + ")");
|
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
|
// Replace Value with name if no value exists
|
||||||
if (queryValue.length() == 0 && getComponent().getText().length() > 0)
|
if (queryValue.length() == 0 && getComponent().getText().length() > 0)
|
||||||
queryValue = getComponent().getText();
|
queryValue = getComponent().getText();
|
||||||
|
@ -689,7 +719,10 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
showInfoPanel(ip);
|
showInfoPanel(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open InfoPanel/InfoWindow dialog
|
||||||
|
* @param ip InfoPanel
|
||||||
|
*/
|
||||||
public void showInfoPanel(final InfoPanel ip) {
|
public void showInfoPanel(final InfoPanel ip) {
|
||||||
ip.setVisible(true);
|
ip.setVisible(true);
|
||||||
ip.setStyle("border: 2px");
|
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() {
|
private void setTableAndKeyColumn() {
|
||||||
if (lookup != null && lookup instanceof MLookup) {
|
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()
|
private String getWhereClause()
|
||||||
{
|
{
|
||||||
String whereClause = "";
|
String whereClause = "";
|
||||||
|
@ -800,9 +837,6 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
else if (validation.length() > 0)
|
else if (validation.length() > 0)
|
||||||
whereClause += " AND " + validation;
|
whereClause += " AND " + validation;
|
||||||
|
|
||||||
// log.finest("ZoomQuery=" + (lookup.getZoomQuery()==null ? "" : lookup.getZoomQuery().getWhereClause())
|
|
||||||
// + ", Validation=" + lookup.getValidation());
|
|
||||||
|
|
||||||
if (whereClause.indexOf('@') != -1)
|
if (whereClause.indexOf('@') != -1)
|
||||||
{
|
{
|
||||||
String validated = Env.parseContext(Env.getCtx(), lookup.getWindowNo(), whereClause, false);
|
String validated = Env.parseContext(Env.getCtx(), lookup.getWindowNo(), whereClause, false);
|
||||||
|
@ -819,12 +853,13 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
return whereClause;
|
return whereClause;
|
||||||
} // getWhereClause
|
} // getWhereClause
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getEvents()
|
public String[] getEvents()
|
||||||
{
|
{
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void valueChange(ValueChangeEvent evt)
|
public void valueChange(ValueChangeEvent evt)
|
||||||
{
|
{
|
||||||
if ("zoom".equals(evt.getPropertyName()))
|
if ("zoom".equals(evt.getPropertyName()))
|
||||||
|
@ -847,12 +882,15 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
getComponent().setTableEditorMode(b);
|
getComponent().setTableEditorMode(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if InfoPanel/InfoWindow dialog is active
|
||||||
|
*/
|
||||||
public boolean isShowingDialog (){
|
public boolean isShowingDialog (){
|
||||||
return infoPanel != null;
|
return infoPanel != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Create new WSearhEditor instance for C_Invoice.C_BPartner_ID column.
|
||||||
* @param windowNo
|
* @param windowNo
|
||||||
* @return WSearchEditor
|
* @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
|
* @param windowNo
|
||||||
* @return WSearchEditor
|
* @return WSearchEditor
|
||||||
*/
|
*/
|
||||||
|
@ -890,7 +929,6 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dynamicDisplay(Properties ctx) {
|
public void dynamicDisplay(Properties ctx) {
|
||||||
if (lookup instanceof MLookup) {
|
if (lookup instanceof MLookup) {
|
||||||
|
@ -911,6 +949,9 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search box component
|
||||||
|
*/
|
||||||
static class CustomSearchBox extends ComboEditorBox {
|
static class CustomSearchBox extends ComboEditorBox {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -918,6 +959,9 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 7490301044763375829L;
|
private static final long serialVersionUID = 7490301044763375829L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set script for spin animation when editor is processing user input text
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onPageAttached(Page newpage, Page oldpage) {
|
public void onPageAttached(Page newpage, Page oldpage) {
|
||||||
super.onPageAttached(newpage, oldpage);
|
super.onPageAttached(newpage, oldpage);
|
||||||
|
|
|
@ -43,7 +43,8 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
import org.zkoss.zk.ui.sys.ComponentCtrl;
|
import org.zkoss.zk.ui.sys.ComponentCtrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Default editor for text display type (String, PrinterName, Text, TextLong and Memo).<br/>
|
||||||
|
* Implemented with {@link Textbox} or {@link Combobox} (AD_Field.IsAutocomplete=Y) component and {@link WTextEditorDialog} dialog.
|
||||||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||||
* @date Mar 11, 2007
|
* @date Mar 11, 2007
|
||||||
* @version $Revision: 0.10 $
|
* @version $Revision: 0.10 $
|
||||||
|
@ -57,7 +58,7 @@ public class WStringEditor extends WEditor implements ContextMenuListener
|
||||||
private AbstractADWindowContent adwindowContent;
|
private AbstractADWindowContent adwindowContent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* to ease porting of swing form
|
* Default constructor
|
||||||
*/
|
*/
|
||||||
public WStringEditor()
|
public WStringEditor()
|
||||||
{
|
{
|
||||||
|
@ -99,7 +100,6 @@ public class WStringEditor extends WEditor implements ContextMenuListener
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* to ease porting of swing form
|
|
||||||
* @param columnName
|
* @param columnName
|
||||||
* @param mandatory
|
* @param mandatory
|
||||||
* @param isReadOnly
|
* @param isReadOnly
|
||||||
|
@ -135,6 +135,10 @@ public class WStringEditor extends WEditor implements ContextMenuListener
|
||||||
getComponent().setReadonly(!readWrite);
|
getComponent().setReadonly(!readWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component and context menu
|
||||||
|
* @param obscureType
|
||||||
|
*/
|
||||||
private void init(String obscureType)
|
private void init(String obscureType)
|
||||||
{
|
{
|
||||||
setChangeEventWhenEditing (true);
|
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));
|
getComponent().addCallback(ComponentCtrl.AFTER_PAGE_DETACHED, t -> ((AbstractComponent)t).setWidgetListener("onBind", null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
boolean isStartEdit = INIT_EDIT_EVENT.equalsIgnoreCase (event.getName());
|
boolean isStartEdit = INIT_EDIT_EVENT.equalsIgnoreCase (event.getName());
|
||||||
|
@ -242,6 +247,10 @@ public class WStringEditor extends WEditor implements ContextMenuListener
|
||||||
oldValue = getComponent().getValue();
|
oldValue = getComponent().getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set type of textbox to password or text
|
||||||
|
* @param password true to set type to password
|
||||||
|
*/
|
||||||
protected void setTypePassword(boolean password)
|
protected void setTypePassword(boolean password)
|
||||||
{
|
{
|
||||||
if (password)
|
if (password)
|
||||||
|
@ -260,6 +269,7 @@ public class WStringEditor extends WEditor implements ContextMenuListener
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onMenu(ContextMenuEvent evt)
|
public void onMenu(ContextMenuEvent evt)
|
||||||
{
|
{
|
||||||
if (WEditorPopupMenu.PREFERENCE_EVENT.equals(evt.getContextEvent()))
|
if (WEditorPopupMenu.PREFERENCE_EVENT.equals(evt.getContextEvent()))
|
||||||
|
@ -325,6 +335,9 @@ public class WStringEditor extends WEditor implements ContextMenuListener
|
||||||
actionRefresh();
|
actionRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh auto complete combo
|
||||||
|
*/
|
||||||
public void actionRefresh() {
|
public void actionRefresh() {
|
||||||
//refresh auto complete list
|
//refresh auto complete list
|
||||||
if (gridField.isAutocomplete()) {
|
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() {
|
private AbstractADWindowContent findADWindowContent() {
|
||||||
Component parent = getComponent().getParent();
|
Component parent = getComponent().getParent();
|
||||||
while(parent != null) {
|
while(parent != null) {
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
package org.adempiere.webui.editor;
|
package org.adempiere.webui.editor;
|
||||||
|
|
||||||
import java.beans.PropertyChangeEvent;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
@ -80,7 +79,8 @@ import org.zkoss.zul.Comboitem;
|
||||||
import org.zkoss.zul.Menuitem;
|
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 <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||||
* @date Mar 12, 2007
|
* @date Mar 12, 2007
|
||||||
* @version $Revision: 0.10 $
|
* @version $Revision: 0.10 $
|
||||||
|
@ -88,11 +88,13 @@ import org.zkoss.zul.Menuitem;
|
||||||
public class WTableDirEditor extends WEditor implements ListDataListener,
|
public class WTableDirEditor extends WEditor implements ListDataListener,
|
||||||
ContextMenuListener, IZoomableEditor
|
ContextMenuListener, IZoomableEditor
|
||||||
{
|
{
|
||||||
|
/** custom script for up arrow key processed */
|
||||||
private static final String UP_PRESSED_OVERRIDE_SCRIPT = "function(evt) {"
|
private static final String UP_PRESSED_OVERRIDE_SCRIPT = "function(evt) {"
|
||||||
+ " if (!this.isOpen()) this.open();"
|
+ " if (!this.isOpen()) this.open();"
|
||||||
+ " this.$upPressed_(evt);"
|
+ " this.$upPressed_(evt);"
|
||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
|
/** custom script for down arrow key processed */
|
||||||
private static final String DOWN_PRESSED_OVERRIDE_SCRIPT = "function(evt) {"
|
private static final String DOWN_PRESSED_OVERRIDE_SCRIPT = "function(evt) {"
|
||||||
+ " if (!this.isOpen()) this.open();"
|
+ " if (!this.isOpen()) this.open();"
|
||||||
+ " this.$dnPressed_(evt);"
|
+ " this.$dnPressed_(evt);"
|
||||||
|
@ -109,15 +111,22 @@ ContextMenuListener, IZoomableEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
private Lookup lookup;
|
private Lookup lookup;
|
||||||
|
/** ID, UUID or AD_RefList Value */
|
||||||
private Object oldValue;
|
private Object oldValue;
|
||||||
|
/** Reference/target table name */
|
||||||
private String m_tableName = null;
|
private String m_tableName = null;
|
||||||
|
/** Reference/target key column name */
|
||||||
private String m_keyColumnName = null;
|
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
|
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
|
protected boolean onlyShortListItems; // IDEMPIERE 90
|
||||||
|
|
||||||
|
/** CCache listener to auto refresh lookup list */
|
||||||
private CCacheListener tableCacheListener;
|
private CCacheListener tableCacheListener;
|
||||||
|
|
||||||
|
/** true if editor is handling ON_SELECT event */
|
||||||
private boolean onselecting = false;
|
private boolean onselecting = false;
|
||||||
|
|
||||||
private boolean retainSelectedValueAfterRefresh = true;
|
private boolean retainSelectedValueAfterRefresh = true;
|
||||||
|
@ -149,9 +158,9 @@ ContextMenuListener, IZoomableEditor
|
||||||
* Constructor for use if a grid field is unavailable
|
* Constructor for use if a grid field is unavailable
|
||||||
*
|
*
|
||||||
* @param lookup Store of selectable data
|
* @param lookup Store of selectable data
|
||||||
* @param label column name (not displayed)
|
* @param label field label
|
||||||
* @param description description of component
|
* @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 readonly whether or not the editor is read only
|
||||||
* @param updateable whether the editor contents can be changed
|
* @param updateable whether the editor contents can be changed
|
||||||
*/
|
*/
|
||||||
|
@ -160,11 +169,29 @@ ContextMenuListener, IZoomableEditor
|
||||||
this(lookup, label, description, mandatory, readonly, updateable, false);
|
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)
|
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);
|
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)
|
private WTableDirEditor(Component comp, Lookup lookup, String label, String description, boolean mandatory, boolean readonly, boolean updateable)
|
||||||
{
|
{
|
||||||
super(comp, label, description, mandatory, readonly, updateable);
|
super(comp, label, description, mandatory, readonly, updateable);
|
||||||
|
@ -181,7 +208,6 @@ ContextMenuListener, IZoomableEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For ease of porting swing form
|
|
||||||
* @param columnName
|
* @param columnName
|
||||||
* @param mandatory
|
* @param mandatory
|
||||||
* @param isReadOnly
|
* @param isReadOnly
|
||||||
|
@ -193,11 +219,27 @@ ContextMenuListener, IZoomableEditor
|
||||||
this(columnName, mandatory, isReadOnly, isUpdateable, lookup, false);
|
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)
|
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);
|
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)
|
private WTableDirEditor(Component comp, String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, Lookup lookup)
|
||||||
{
|
{
|
||||||
super(comp, columnName, null, null, mandatory, isReadOnly, isUpdateable);
|
super(comp, columnName, null, null, mandatory, isReadOnly, isUpdateable);
|
||||||
|
@ -210,6 +252,9 @@ ContextMenuListener, IZoomableEditor
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component and context menu
|
||||||
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
ZKUpdateUtil.setWidth(getComponent(), "200px");
|
ZKUpdateUtil.setWidth(getComponent(), "200px");
|
||||||
|
@ -249,7 +294,7 @@ ContextMenuListener, IZoomableEditor
|
||||||
refreshList();
|
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(".");
|
int posPoint = tableName_temp.indexOf(".");
|
||||||
String tableName = tableName_temp.substring(0, posPoint);
|
String tableName = tableName_temp.substring(0, posPoint);
|
||||||
|
|
||||||
|
@ -299,6 +344,9 @@ ContextMenuListener, IZoomableEditor
|
||||||
getComponent().setPlaceholder(gridField.getPlaceholder());
|
getComponent().setPlaceholder(gridField.getPlaceholder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create {@link #tableCacheListener} instance
|
||||||
|
*/
|
||||||
private void createCacheListener() {
|
private void createCacheListener() {
|
||||||
if (lookup != null) {
|
if (lookup != null) {
|
||||||
String columnName = lookup.getColumnName();
|
String columnName = lookup.getColumnName();
|
||||||
|
@ -339,6 +387,7 @@ ContextMenuListener, IZoomableEditor
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setValue(Object value)
|
public void setValue(Object value)
|
||||||
{
|
{
|
||||||
if (onselecting) {
|
if (onselecting) {
|
||||||
|
@ -437,6 +486,9 @@ ContextMenuListener, IZoomableEditor
|
||||||
getComponent().setButtonVisible(readWrite);
|
getComponent().setButtonVisible(readWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh lookup list
|
||||||
|
*/
|
||||||
private void refreshList()
|
private void refreshList()
|
||||||
{
|
{
|
||||||
if (getComponent().getItemCount() > 0)
|
if (getComponent().getItemCount() > 0)
|
||||||
|
@ -544,6 +596,7 @@ ContextMenuListener, IZoomableEditor
|
||||||
getComponent().setValue(oldValue);
|
getComponent().setValue(oldValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
if (Events.ON_SELECT.equalsIgnoreCase(event.getName()))
|
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) {
|
private boolean isValueChange(Object newValue) {
|
||||||
return (oldValue == null && newValue != null) || (oldValue != null && newValue == null)
|
return (oldValue == null && newValue != null) || (oldValue != null && newValue == null)
|
||||||
|| ((oldValue != null && newValue != null) && !oldValue.equals(newValue));
|
|| ((oldValue != null && newValue != null) && !oldValue.equals(newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getEvents()
|
public String[] getEvents()
|
||||||
{
|
{
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void contentsChanged(ListDataEvent e)
|
public void contentsChanged(ListDataEvent e)
|
||||||
{
|
{
|
||||||
refreshList();
|
refreshList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void intervalAdded(ListDataEvent e)
|
public void intervalAdded(ListDataEvent e)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void intervalRemoved(ListDataEvent e)
|
public void intervalRemoved(ListDataEvent e)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh lookup list
|
||||||
|
*/
|
||||||
public void actionRefresh()
|
public void actionRefresh()
|
||||||
{
|
{
|
||||||
if (lookup != null)
|
if (lookup != null)
|
||||||
|
@ -653,16 +717,23 @@ ContextMenuListener, IZoomableEditor
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.adempiere.webui.editor.IZoomableEditor#actionZoom()
|
* @see org.adempiere.webui.editor.IZoomableEditor#actionZoom()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void actionZoom()
|
public void actionZoom()
|
||||||
{
|
{
|
||||||
AEnv.actionZoom(lookup, getValue());
|
AEnv.actionZoom(lookup, getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Lookup
|
||||||
|
*/
|
||||||
public Lookup getLookup()
|
public Lookup getLookup()
|
||||||
{
|
{
|
||||||
return lookup;
|
return lookup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open drill assistant dialog
|
||||||
|
*/
|
||||||
protected void actionDrill() {
|
protected void actionDrill() {
|
||||||
if(getGridField() == null || getGridField().getGridTab() == null)
|
if(getGridField() == null || getGridField().getGridTab() == null)
|
||||||
return;
|
return;
|
||||||
|
@ -681,7 +752,7 @@ ContextMenuListener, IZoomableEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets m_tableName and m_keyColumnName
|
* Set {@link #m_tableName} and {@link #m_keyColumnName}.
|
||||||
*/
|
*/
|
||||||
private void setTableAndKeyColumn() {
|
private void setTableAndKeyColumn() {
|
||||||
if (lookup != null && lookup instanceof MLookup) {
|
if (lookup != null && lookup instanceof MLookup) {
|
||||||
|
@ -756,6 +827,9 @@ ContextMenuListener, IZoomableEditor
|
||||||
AEnv.showWindow(vqe);
|
AEnv.showWindow(vqe);
|
||||||
} // actionQuickEntry
|
} // actionQuickEntry
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open {@link WLocationDialog}
|
||||||
|
*/
|
||||||
protected void actionLocation() {
|
protected void actionLocation() {
|
||||||
int BPLocation_ID = 0;
|
int BPLocation_ID = 0;
|
||||||
Object value = getValue();
|
Object value = getValue();
|
||||||
|
@ -776,6 +850,7 @@ ContextMenuListener, IZoomableEditor
|
||||||
|
|
||||||
} // actionLocation
|
} // actionLocation
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onMenu(ContextMenuEvent evt)
|
public void onMenu(ContextMenuEvent evt)
|
||||||
{
|
{
|
||||||
if (WEditorPopupMenu.REQUERY_EVENT.equals(evt.getContextEvent()))
|
if (WEditorPopupMenu.REQUERY_EVENT.equals(evt.getContextEvent()))
|
||||||
|
@ -833,14 +908,6 @@ ContextMenuListener, IZoomableEditor
|
||||||
// IDEMPIERE 90
|
// IDEMPIERE 90
|
||||||
}
|
}
|
||||||
|
|
||||||
public void propertyChange(PropertyChangeEvent evt)
|
|
||||||
{
|
|
||||||
if ("FieldValue".equals(evt.getPropertyName()))
|
|
||||||
{
|
|
||||||
setValue(evt.getNewValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dynamicDisplay(Properties ctx)
|
public void dynamicDisplay(Properties ctx)
|
||||||
{
|
{
|
||||||
|
@ -872,6 +939,9 @@ ContextMenuListener, IZoomableEditor
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom {@link Combobox} class
|
||||||
|
*/
|
||||||
private static class EditorCombobox extends Combobox implements ITableDirEditor {
|
private static class EditorCombobox extends Combobox implements ITableDirEditor {
|
||||||
/**
|
/**
|
||||||
* generated serial id
|
* generated serial id
|
||||||
|
@ -888,6 +958,9 @@ ContextMenuListener, IZoomableEditor
|
||||||
super.setPage(page);
|
super.setPage(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create CCache listener
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onPageAttached(Page newpage, Page oldpage) {
|
public void onPageAttached(Page newpage, Page oldpage) {
|
||||||
super.onPageAttached(newpage, oldpage);
|
super.onPageAttached(newpage, oldpage);
|
||||||
|
@ -914,7 +987,7 @@ ContextMenuListener, IZoomableEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Clean up CCache listener
|
||||||
*/
|
*/
|
||||||
public void cleanup() {
|
public void cleanup() {
|
||||||
if (editor.tableCacheListener != null) {
|
if (editor.tableCacheListener != null) {
|
||||||
|
@ -929,6 +1002,9 @@ ContextMenuListener, IZoomableEditor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom {@link AutoComplete} class
|
||||||
|
*/
|
||||||
private static class EditorAutoComplete extends AutoComplete implements ITableDirEditor {
|
private static class EditorAutoComplete extends AutoComplete implements ITableDirEditor {
|
||||||
/**
|
/**
|
||||||
* generated serial id
|
* generated serial id
|
||||||
|
@ -945,6 +1021,9 @@ ContextMenuListener, IZoomableEditor
|
||||||
super.setPage(page);
|
super.setPage(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create CCache listener instance
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onPageAttached(Page newpage, Page oldpage) {
|
public void onPageAttached(Page newpage, Page oldpage) {
|
||||||
super.onPageAttached(newpage, oldpage);
|
super.onPageAttached(newpage, oldpage);
|
||||||
|
@ -971,7 +1050,7 @@ ContextMenuListener, IZoomableEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Clean up CCache listener
|
||||||
*/
|
*/
|
||||||
public void cleanup() {
|
public void cleanup() {
|
||||||
if (editor.tableCacheListener != null) {
|
if (editor.tableCacheListener != null) {
|
||||||
|
@ -997,6 +1076,9 @@ ContextMenuListener, IZoomableEditor
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CCache listener to auto refresh lookup list
|
||||||
|
*/
|
||||||
private static class CCacheListener extends CCache<String, Object> {
|
private static class CCacheListener extends CCache<String, Object> {
|
||||||
/**
|
/**
|
||||||
* generated serial
|
* generated serial
|
||||||
|
@ -1052,7 +1134,6 @@ ContextMenuListener, IZoomableEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return true if current selected value is always retain after refresh of list
|
* @return true if current selected value is always retain after refresh of list
|
||||||
*/
|
*/
|
||||||
public boolean isRetainSelectedValueAfterRefresh() {
|
public boolean isRetainSelectedValueAfterRefresh() {
|
||||||
|
|
|
@ -26,11 +26,13 @@ import org.adempiere.webui.event.ValueChangeEvent;
|
||||||
import org.adempiere.webui.window.WFieldRecordInfo;
|
import org.adempiere.webui.window.WFieldRecordInfo;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Default editor for {@link DisplayType#Time}.<br/>
|
||||||
|
* Implemented with {@link Timebox} component.
|
||||||
* @author Low Heng Sin
|
* @author Low Heng Sin
|
||||||
*/
|
*/
|
||||||
public class WTimeEditor extends WEditor implements ContextMenuListener
|
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
|
* Constructor for use if a grid field is unavailable
|
||||||
*
|
*
|
||||||
* @param label
|
* @param label
|
||||||
* column name (not displayed)
|
* field label
|
||||||
* @param description
|
* @param description
|
||||||
* description of component
|
* description of component
|
||||||
* @param mandatory
|
* @param mandatory
|
||||||
* whether a selection must be made
|
* whether field is mandatory
|
||||||
* @param readonly
|
* @param readonly
|
||||||
* whether or not the editor is read only
|
* whether or not the editor is read only
|
||||||
* @param updateable
|
* @param updateable
|
||||||
|
@ -102,12 +104,18 @@ public class WTimeEditor extends WEditor implements ContextMenuListener
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor
|
||||||
|
*/
|
||||||
public WTimeEditor()
|
public WTimeEditor()
|
||||||
{
|
{
|
||||||
this("Time", "Time", false, false, true);
|
this("Time", "Time", false, false, true);
|
||||||
init();
|
init();
|
||||||
} // VDate
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component and context menu
|
||||||
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
getComponent().setCols(10);
|
getComponent().setCols(10);
|
||||||
|
@ -118,6 +126,7 @@ public class WTimeEditor extends WEditor implements ContextMenuListener
|
||||||
getComponent().setPlaceholder(gridField.getPlaceholder());
|
getComponent().setPlaceholder(gridField.getPlaceholder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
if (Events.ON_CHANGE.equalsIgnoreCase(event.getName()) || Events.ON_OK.equalsIgnoreCase(event.getName()))
|
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
|
@Override
|
||||||
public String getDisplay()
|
public String getDisplay()
|
||||||
{
|
{
|
||||||
// Elaine 2008/07/29
|
|
||||||
return getComponent().getText();
|
return getComponent().getText();
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValue()
|
public Object getValue()
|
||||||
{
|
{
|
||||||
// Elaine 2008/07/25
|
|
||||||
if(getComponent().getValue() == null) return null;
|
if(getComponent().getValue() == null) return null;
|
||||||
return new Timestamp(getComponent().getValue().getTime());
|
return new Timestamp(getComponent().getValue().getTime());
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -196,7 +201,6 @@ public class WTimeEditor extends WEditor implements ContextMenuListener
|
||||||
return !getComponent().isReadonly();
|
return !getComponent().isReadonly();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setReadWrite(boolean readWrite) {
|
public void setReadWrite(boolean readWrite) {
|
||||||
getComponent().setReadonly(!readWrite);
|
getComponent().setReadonly(!readWrite);
|
||||||
|
|
|
@ -42,6 +42,7 @@ import org.adempiere.webui.event.ContextMenuListener;
|
||||||
import org.adempiere.webui.event.ValueChangeEvent;
|
import org.adempiere.webui.event.ValueChangeEvent;
|
||||||
import org.adempiere.webui.session.SessionManager;
|
import org.adempiere.webui.session.SessionManager;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
import org.compiere.util.NamePair;
|
import org.compiere.util.NamePair;
|
||||||
|
@ -55,17 +56,24 @@ import org.zkoss.zul.Menu;
|
||||||
import org.zkoss.zul.Menuitem;
|
import org.zkoss.zul.Menuitem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Default editor for {@link DisplayType#TimeZoneId}.<br/>
|
||||||
|
* Implemented with {@link Combobox} component.
|
||||||
* @author hengsin
|
* @author hengsin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class WTimeZoneEditor extends WEditor implements ContextMenuListener {
|
public class WTimeZoneEditor extends WEditor implements ContextMenuListener {
|
||||||
|
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE};
|
||||||
|
/** Time zone context menu name/id */
|
||||||
private static final String TIME_ZONE = "TIME_ZONE";
|
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";
|
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";
|
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";
|
private static final String TIME_ZONE_ID_ATTR = "TIME_ZONE_ID";
|
||||||
|
|
||||||
|
/** Time zone id */
|
||||||
private String oldValue;
|
private String oldValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,6 +122,9 @@ public class WTimeZoneEditor extends WEditor implements ContextMenuListener {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component and context menu
|
||||||
|
*/
|
||||||
private void init() {
|
private void init() {
|
||||||
popupMenu = new WEditorPopupMenu(false, false, isShowPreference());
|
popupMenu = new WEditorPopupMenu(false, false, isShowPreference());
|
||||||
popupMenu.addMenuListener(this);
|
popupMenu.addMenuListener(this);
|
||||||
|
@ -150,6 +161,9 @@ public class WTimeZoneEditor extends WEditor implements ContextMenuListener {
|
||||||
getComponent().addEventListener(Events.ON_BLUR, e -> onBlur());
|
getComponent().addEventListener(Events.ON_BLUR, e -> onBlur());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle onBlur event of component
|
||||||
|
*/
|
||||||
private void onBlur() {
|
private void onBlur() {
|
||||||
Comboitem item = getComponent().getSelectedItem();
|
Comboitem item = getComponent().getSelectedItem();
|
||||||
if (item == null)
|
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) {
|
private boolean isValueChange(String newValue) {
|
||||||
return (oldValue == null && newValue != null) || (oldValue != null && newValue == null)
|
return (oldValue == null && newValue != null) || (oldValue != null && newValue == null)
|
||||||
|| ((oldValue != null && newValue != null) && !oldValue.equals(newValue));
|
|| ((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) {
|
private boolean processCustomZoneId(String customId) {
|
||||||
TimeZone timeZone = TimeZone.getTimeZone(customId);
|
TimeZone timeZone = TimeZone.getTimeZone(customId);
|
||||||
if (timeZone != null && timeZone.getID().equals(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) {
|
private void setTimeZoneFromContextMenu(String id) {
|
||||||
String newValue = id;
|
String newValue = id;
|
||||||
String currentValue = oldValue;
|
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
|
* @param popupMenu
|
||||||
*/
|
*/
|
||||||
private void addTimeZoneMenu(WEditorPopupMenu popupMenu) {
|
private void addTimeZoneMenu(WEditorPopupMenu popupMenu) {
|
||||||
if (popupMenu != null && isReadWrite() && popupMenu.getAttribute(TIME_ZONE_ADDED) == null) {
|
if (popupMenu != null && isReadWrite() && popupMenu.getAttribute(TIME_ZONE_ADDED) == null) {
|
||||||
|
//time zone id from browser
|
||||||
ClientInfo clientInfo = SessionManager.getAppDesktop().getClientInfo();
|
ClientInfo clientInfo = SessionManager.getAppDesktop().getClientInfo();
|
||||||
if (clientInfo != null && clientInfo.timeZone != null) {
|
if (clientInfo != null && clientInfo.timeZone != null) {
|
||||||
TimeZone firstSameRule = null;
|
TimeZone firstSameRule = null;
|
||||||
TimeZone found = null;
|
TimeZone found = null;
|
||||||
|
//match by id, fallback to first with same rawOffset+DSTSavings+useDayLightTime
|
||||||
for(int i = 0; i < getComponent().getItemCount(); i++) {
|
for(int i = 0; i < getComponent().getItemCount(); i++) {
|
||||||
String id = getComponent().getItemAtIndex(i).getValue();
|
String id = getComponent().getItemAtIndex(i).getValue();
|
||||||
TimeZone tz = TimeZone.getTimeZone(id);
|
TimeZone tz = TimeZone.getTimeZone(id);
|
||||||
|
@ -385,6 +415,7 @@ public class WTimeZoneEditor extends WEditor implements ContextMenuListener {
|
||||||
if (popupMenu.getAttribute(TIME_ZONE_ADDED) == null) {
|
if (popupMenu.getAttribute(TIME_ZONE_ADDED) == null) {
|
||||||
List<String> labels = new ArrayList<String>();
|
List<String> labels = new ArrayList<String>();
|
||||||
List<String> ids = new ArrayList<String>();
|
List<String> ids = new ArrayList<String>();
|
||||||
|
//match by rawOffset
|
||||||
for(int i = 0; i < getComponent().getItemCount(); i++) {
|
for(int i = 0; i < getComponent().getItemCount(); i++) {
|
||||||
String id = getComponent().getItemAtIndex(i).getValue();
|
String id = getComponent().getItemAtIndex(i).getValue();
|
||||||
tz = TimeZone.getTimeZone(id);
|
tz = TimeZone.getTimeZone(id);
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.adempiere.webui.editor;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Simple text editor for unknown display type.
|
||||||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||||
* @date Mar 12, 2007
|
* @date Mar 12, 2007
|
||||||
* @version $Revision: 0.10 $
|
* @version $Revision: 0.10 $
|
||||||
|
|
|
@ -25,9 +25,14 @@ import org.adempiere.webui.event.ValueChangeEvent;
|
||||||
import org.adempiere.webui.theme.ThemeManager;
|
import org.adempiere.webui.theme.ThemeManager;
|
||||||
import org.adempiere.webui.window.WFieldRecordInfo;
|
import org.adempiere.webui.window.WFieldRecordInfo;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default editor for {@link DisplayType#URL}.<br/>
|
||||||
|
* Implemented with {@link Urlbox} component.
|
||||||
|
*/
|
||||||
public class WUrlEditor extends WEditor implements ContextMenuListener
|
public class WUrlEditor extends WEditor implements ContextMenuListener
|
||||||
{
|
{
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE, Events.ON_OK};
|
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);
|
getComponent().setEnabled(readWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
if (Events.ON_CHANGE.equals(event.getName()) || Events.ON_OK.equals(event.getName()))
|
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()
|
public String[] getEvents()
|
||||||
{
|
{
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
package org.adempiere.webui.editor;
|
package org.adempiere.webui.editor;
|
||||||
|
|
||||||
import java.beans.PropertyChangeEvent;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.adempiere.webui.ValuePreference;
|
import org.adempiere.webui.ValuePreference;
|
||||||
|
@ -28,13 +27,15 @@ import org.adempiere.webui.event.ValueChangeEvent;
|
||||||
import org.adempiere.webui.window.WFieldRecordInfo;
|
import org.adempiere.webui.window.WFieldRecordInfo;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Default editor for {@link DisplayType#YesNo}. <br/>
|
||||||
|
* Implemented with {@link Checkbox} component.
|
||||||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||||
* @date Mar 11, 2007
|
* @date Mar 11, 2007
|
||||||
* @version $Revision: 0.10 $
|
* @version $Revision: 0.10 $
|
||||||
|
@ -88,6 +89,9 @@ public class WYesNoEditor extends WEditor implements ContextMenuListener
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init component and context menu
|
||||||
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
if (gridField != null)
|
if (gridField != null)
|
||||||
|
@ -102,6 +106,7 @@ public class WYesNoEditor extends WEditor implements ContextMenuListener
|
||||||
addChangeLogMenu(popupMenu);
|
addChangeLogMenu(popupMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
if (Events.ON_CHECK.equalsIgnoreCase(event.getName()))
|
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
|
@Override
|
||||||
public String getDisplay()
|
public String getDisplay()
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.compiere.util.CCache;
|
||||||
import org.osgi.framework.Constants;
|
import org.osgi.framework.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Static methods to create new {@link WEditor} instance for {@link GridField}.
|
||||||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||||
* @date Mar 12, 2007
|
* @date Mar 12, 2007
|
||||||
* @version $Revision: 0.10 $
|
* @version $Revision: 0.10 $
|
||||||
|
|
Loading…
Reference in New Issue