📄 veditorfactory.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Business Solution
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
* Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.grid.ed;
import javax.swing.*;
import org.compiere.util.*;
import org.compiere.model.*;
import org.compiere.swing.*;
import org.compiere.plaf.*;
/**
* Factory for VEditor and its Label for single Row display and multi row-editor
*
* @see VCellRenderer for multi-row display
* @author Jorg Janke
* @version $Id: VEditorFactory.java,v 1.14 2003/04/29 09:26:24 jpedersen Exp $
*/
public class VEditorFactory
{
/**
* Create Editor for MField.
* The Name is set to the column name for dynamic display management
* @param mField MField
* @param tableEditor true if table editor
* @return grid editor
*/
public static VEditor getEditor (MField mField, boolean tableEditor)
{
return getEditor (null, mField, tableEditor);
} // getEditor
/**
* Create Editor for MField.
* The Name is set to the column name for dynamic display management
* @param mTab MTab
* @param mField MField
* @param tableEditor true if table editor
* @return grid editor
*/
public static VEditor getEditor (MTab mTab, MField mField, boolean tableEditor)
{
if (mField == null)
return null;
VEditor editor = null;
int displayType = mField.getDisplayType();
String columnName = mField.getColumnName();
boolean mandatory = mField.isMandatory(false); // no context check
boolean readOnly = mField.isReadOnly();
boolean updateable = mField.isUpdateable();
int WindowNo = mField.getWindowNo();
// Not a Field
if (mField.isHeading())
return null;
// String (clear/password)
if (displayType == DisplayType.String
|| (tableEditor && displayType == DisplayType.Text))
{
if (mField.isEncryptedField())
{
VPassword vs = new VPassword (columnName, mandatory, readOnly, updateable,
mField.getDisplayLength(), mField.getFieldLength(), mField.getVFormat());
vs.setName (columnName);
vs.setField (mField);
editor = vs;
}
else
{
VString vs = new VString (columnName, mandatory, readOnly, updateable,
mField.getDisplayLength(), mField.getFieldLength(), mField.getVFormat());
vs.setName (columnName);
vs.setField (mField);
editor = vs;
}
}
// Lookup
else if (DisplayType.isLookup(displayType) || displayType == DisplayType.ID)
{
VLookup vl = new VLookup(columnName, mandatory, readOnly, updateable,
mField.getLookup(), displayType, WindowNo);
vl.setName(columnName);
vl.setField (mField);
editor = vl;
}
// Number
else if (DisplayType.isNumeric(displayType))
{
VNumber vn = new VNumber(columnName, mandatory, readOnly, updateable,
displayType, mField.getHeader());
vn.setRange(mField.getValueMin(), mField.getValueMax());
vn.setName(columnName);
vn.setField (mField);
editor = vn;
}
// YesNo
else if (displayType == DisplayType.YesNo)
{
VCheckBox vc = new VCheckBox(columnName, mandatory, readOnly, updateable,
mField.getHeader(), mField.getDescription(), tableEditor);
vc.setName(columnName);
vc.setField (mField);
editor = vc;
}
// Text (single row)
else if (displayType == DisplayType.Text)
{
VText vt = new VText(columnName, mandatory, readOnly, updateable,
mField.getDisplayLength(), mField.getFieldLength());
vt.setName(columnName);
vt.setField (mField);
editor = vt;
}
// Memo (single row)
else if (displayType == DisplayType.Memo)
{
Log.trace(Log.l4_Data, "***************Editorfactory calls Vmemo*************");
VMemo vt = new VMemo(columnName, mandatory, readOnly, updateable,
mField.getDisplayLength(), mField.getFieldLength());
vt.setName(columnName);
vt.setField (mField);
editor = vt;
}
// Date
else if (DisplayType.isDate(displayType))
{
if (displayType == DisplayType.DateTime)
readOnly = true;
VDate vd = new VDate(columnName, mandatory, readOnly, updateable,
displayType, mField.getHeader());
vd.setName(columnName);
vd.setField (mField);
editor = vd;
}
// Location
else if (displayType == DisplayType.Location)
{
VLocation loc = new VLocation (columnName, mandatory, readOnly, updateable,
(MLocation)mField.getLookup());
loc.setName(columnName);
loc.setField (mField);
editor = loc;
}
// Locator
else if (displayType == DisplayType.Locator)
{
VLocator loc = new VLocator (columnName, mandatory, readOnly, updateable,
(MLocator)mField.getLookup());
loc.setName(columnName);
loc.setField (mField);
editor = loc;
}
// Account
else if (displayType == DisplayType.Account)
{
VAccount acct = new VAccount (columnName, mandatory, readOnly, updateable,
(MAccount)mField.getLookup(), mField.getHeader());
acct.setName(columnName);
acct.setField (mField);
editor = acct;
}
// Button
else if (displayType == DisplayType.Button)
{
VButton button = new VButton(columnName, mandatory, readOnly, updateable,
mField.getHeader(), mField.getDescription(), mField.getHelp(), mField.getAD_Process_ID());
button.setName(columnName);
button.setField (mField);
editor = button;
}
// Assignment
else if (displayType == DisplayType.Assignment)
{
VAssignment assign = new VAssignment (mandatory, readOnly, updateable);
assign.setName(columnName);
assign.setField (mField);
editor = assign;
}
// Color
else if (displayType == DisplayType.Color)
{
VColor color = new VColor (mTab, mandatory, readOnly);
color.setName(columnName);
color.setField (mField);
editor = color;
}
// Image
else if (displayType == DisplayType.Image)
{
VImage image = new VImage (WindowNo);
image.setName(columnName);
image.setField (mField);
editor = image;
}
else
Log.error("VEditorFactory.getEditor - " + columnName + " - Unknown Type: " + displayType);
return editor;
} // getEditor
/**
* Create Label for MField. (null for YesNo/Button)
* The Name is set to the column name for dynamic display management
*
* @param mField MField
* @return Label
*/
public static CLabel getLabel (MField mField)
{
if (mField == null)
return null;
int displayType = mField.getDisplayType();
// No Label for FieldOnly, CheckBox, Button
if (mField.isFieldOnly()
|| displayType == DisplayType.YesNo
|| displayType == DisplayType.Button)
return null;
//
CLabel label = new CLabel(mField.getHeader(), mField.getDescription());
label.setName(mField.getColumnName());
// label.setFont(CompierePLAF.getFont_Label());
// label.setForeground(CompierePLAF.getTextColor_Label());
return label;
} // getLabel
} // VEditorFactory
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -