📄 findvalueeditor.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.apps.search;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import javax.swing.event.*;
import javax.swing.table.*;
import org.compiere.util.*;
import org.compiere.grid.ed.*;
import org.compiere.model.*;
/**
* Cell editor for Find Value field.
* Editor depends on Column setting
* Has to save entries how they are used in the query, i.e. '' for strings
*
* @author Jorg Janke
* @version $Id: FindValueEditor.java,v 1.2 2002/08/14 04:22:51 jjanke Exp $
*/
public final class FindValueEditor extends AbstractCellEditor implements TableCellEditor
{
/**
* Constructor
* @param find find
* @param value2 true if it is the "to" value column
*/
public FindValueEditor (Find find, boolean value2)
{
super();
m_find = find;
m_value2 = value2;
}
private Find m_find;
private boolean m_value2;
private boolean m_between;
private VEditor m_editor = null;
/**
* Get Value
* Need to convert to String
* @return current value
*/
public Object getCellEditorValue()
{
// Log.trace(Log.l4_Data, "FindValueEditor.getCellEditorValue");
if (m_editor == null)
return null;
Object obj = m_editor.getValue(); // returns Integer, BidDecimal, String
if (obj == null)
return null;
//
String retValue = obj.toString();
return retValue;
} // getCellEditorValue
/**
* Get Editor
*
* @param table Table
* @param value Value
* @param isSelected cell is selected
* @param row row
* @param col column
* @return Editor component
*/
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int col)
{
// Log.trace(Log.l4_Data, "FindValueEditor.getTableCellEditorComponent", "r=" + row + ", c=" + col);
// Between - enables value2
m_between = false;
Object betw = table.getModel().getValueAt(row, Find.INDEX_OPERATOR);
if (betw != null && betw.toString().equals(MQuery.OPERATORS[MQuery.BETWEEN_INDEX].toString()))
m_between = true;
String columnName = null;
Object column = table.getModel().getValueAt(row, Find.INDEX_COLUMNNAME);
if (column != null)
columnName = ((ValueNamePair)column).getValue();
// Create Editor
MField field = m_find.getTargetMField(columnName);
// Log.trace(Log.l5_DData, "Field=" + field);
m_editor = VEditorFactory.getEditor(field, true);
if (m_editor == null)
m_editor = new VString();
m_editor.setValue(value);
m_editor.setReadWrite(true);
m_editor.setBorder(null);
//
return (Component)m_editor;
} // getTableCellEditorComponent
/**
* Cell Editable
* @param e event
* @return true if editable
*/
public boolean isCellEditable (EventObject e)
{
if (m_value2 && !m_between)
return false;
return true;
} // isCellEditable
} // FindValueEditor
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -