use of org.compiere.grid.ed.VEditor in project adempiere by adempiere.
the class Find method cmd_ok_Simple.
// stateChanged
/**
* Simple OK Button pressed
*/
private void cmd_ok_Simple() {
// Create Query String
m_query = new MQuery(m_tableName);
m_query.addRestriction(Env.parseContext(Env.getCtx(), m_targetWindowNo, m_whereExtended, false));
if (hasValue && !valueField.getText().equals("%") && valueField.getText().length() != 0) {
String value = valueField.getText().toUpperCase();
if (!value.endsWith("%"))
value += "%";
m_query.addRestriction("UPPER(Value)", MQuery.LIKE, value, valueLabel.getText(), value);
}
//
if (hasDocNo && !docNoField.getText().equals("%") && docNoField.getText().length() != 0) {
String value = docNoField.getText().toUpperCase();
if (!value.endsWith("%"))
value += "%";
m_query.addRestriction("UPPER(DocumentNo)", MQuery.LIKE, value, docNoLabel.getText(), value);
}
//
if ((hasName) && !nameField.getText().equals("%") && nameField.getText().length() != 0) {
String value = nameField.getText().toUpperCase();
if (!value.endsWith("%"))
value += "%";
m_query.addRestriction("UPPER(Name)", MQuery.LIKE, value, nameLabel.getText(), value);
}
//
if (hasDescription && !descriptionField.getText().equals("%") && descriptionField.getText().length() != 0) {
String value = descriptionField.getText().toUpperCase();
if (!value.endsWith("%"))
value += "%";
m_query.addRestriction("UPPER(Description)", MQuery.LIKE, value, descriptionLabel.getText(), value);
}
// Special Editors
for (int i = 0; i < m_sEditors.size(); i++) {
VEditor ved = (VEditor) m_sEditors.get(i);
Object value = ved.getValue();
Object modifiedvalue = null;
String ColumnSQL = null;
String ColumnName = ((Component) ved).getName();
GridField field = getTargetMField(ColumnName);
if (value != null && value.toString().length() > 0) {
ColumnName = ((Component) ved).getName();
log.fine(ColumnName + "=" + value);
// globalqss - Carlos Ruiz - 20060711
// fix a bug with virtualColumn + isSelectionColumn not yielding results
field = getTargetMField(ColumnName);
boolean isProductCategoryField = isProductCategoryField(field.getAD_Column_ID());
ColumnSQL = field.getColumnSQL(false);
// Be more permissive for String columns
if (isSearchLike(field)) {
String valueStr = value.toString().toUpperCase();
if (!valueStr.endsWith("%"))
valueStr += "%";
//
ColumnSQL = "UPPER(" + ColumnSQL + ")";
modifiedvalue = valueStr;
} else
modifiedvalue = value;
//
if (modifiedvalue.toString().indexOf('%') != -1 && !field.isRangeLookup())
m_query.addRestriction(ColumnSQL, MQuery.LIKE, modifiedvalue, ColumnName, ved.getDisplay());
else if (isProductCategoryField && value instanceof Integer)
m_query.addRestriction(getSubCategoryWhereClause(((Integer) value).intValue()));
else if (!field.isRangeLookup())
m_query.addRestriction(ColumnSQL, MQuery.EQUAL, value, ColumnName, ved.getDisplay());
/*
if (value.toString().indexOf('%') != -1)
m_query.addRestriction(ColumnName, MQuery.LIKE, value, ColumnName, ved.getDisplay());
else
m_query.addRestriction(ColumnName, MQuery.EQUAL, value, ColumnName, ved.getDisplay());
*/
// end globalqss patch
}
if (field.isRangeLookup()) {
VEditor editor2 = (VEditor) m_sEditors2.get(i);
Object value2 = null;
Object parsedValue = null;
Object parsedValue2 = null;
String infoDisplay_to = null;
String infoDisplay = null;
if (editor2 != null)
value2 = editor2.getValue();
//GridField field = null;
if ((value != null && !value.toString().isEmpty()) && (value2 != null && !value2.toString().isEmpty()) && value2.toString().length() > 0) {
ColumnName = ((Component) ved).getName();
log.fine(ColumnName + "=" + value2);
field = getTargetMField(ColumnName);
infoDisplay = value.toString();
parsedValue = parseValue(field, value);
parsedValue2 = parseValue(field, value2);
infoDisplay_to = value2.toString();
if (parsedValue2 == null)
continue;
m_query.addRangeRestriction(ColumnSQL, parsedValue, parsedValue2, ColumnSQL, infoDisplay, infoDisplay_to);
} else //then get all the records after the First value
if (value != null && !value.toString().isEmpty() && (value2 == null || value2.toString().isEmpty())) {
ColumnName = ((Component) ved).getName();
m_query.addRestriction(ColumnSQL, MQuery.GREATER_EQUAL, value, ColumnName, ved.getDisplay());
} else // then get all the records before the second value
if ((value == null || value.toString().isEmpty()) && value2 != null && !value2.toString().isEmpty()) {
ColumnName = ((Component) ved).getName();
field = getTargetMField(ColumnName);
ColumnSQL = field.getColumnSQL(false);
m_query.addRestriction(ColumnSQL, MQuery.LESS_EQUAL, value2, ColumnName, editor2.getDisplay());
}
}
}
// editors
// teo_sarca [ 1708717 ]
m_isCancel = false;
// Test for no records
if (getNoOfRecords(m_query, true) != 0)
dispose();
}
use of org.compiere.grid.ed.VEditor in project adempiere by adempiere.
the class GridController method dispose.
// jbInit
/**
* Displose
*/
public void dispose() {
log.config("(" + m_mTab.toString() + ")");
// clear info
stopEditor(false);
if (m_mTab.isLoadComplete()) {
if (m_mTab.needSave(true, false))
m_mTab.dataIgnore();
}
// Listeners
if (m_mTab.isLoadComplete()) {
m_mTab.getTableModel().removeDataStatusListener(this);
m_mTab.getTableModel().removeVetoableChangeListener(this);
}
vTable.getSelectionModel().removeListSelectionListener(this);
m_mTab.removePropertyChangeListener(vTable);
// editors
Component[] comp = vPanel.getComponentsRecursive();
for (int i = 0; i < comp.length; i++) {
if (comp[i] instanceof VEditor) {
VEditor vEditor = (VEditor) comp[i];
vEditor.removeVetoableChangeListener(this);
String columnName = comp[i].getName();
GridField mField = m_mTab.getField(columnName);
if (mField != null)
mField.removePropertyChangeListener(vEditor);
vEditor.dispose();
}
}
/** @todo Remove APanel Button listeners */
vTable.removeAll();
// remove reference
vTable.setModel(new DefaultTableModel());
vTable = null;
vPanel.removeAll();
vPanel = null;
//srPane.removeAll();
//srPane = null;
splitPane.removeAll();
splitPane = null;
m_mTab = null;
m_tree = null;
this.removeAll();
}
use of org.compiere.grid.ed.VEditor in project adempiere by adempiere.
the class GridController method init.
// initGrid
private void init() {
// Set up Multi Row Table
vTable.setModel(m_mTab.getTableModel());
// Update Table Info -------------------------------------------------
int size = setupVTable(m_aPanel, m_mTab, vTable);
// Single Row -------------------------------------------------------
if (!m_onlyMultiRow) {
// Set Softcoded Mnemonic &x
for (int i = 0; i < size; i++) {
GridField mField = m_mTab.getField(i);
if (mField.isDisplayed())
vPanel.setMnemonic(mField);
}
// Add Fields
for (int i = 0; i < size; i++) {
GridField mField = m_mTab.getField(i);
if (mField.isDisplayed()) {
VEditor vEditor = VEditorFactory.getEditor(m_mTab, mField, false);
if (vEditor == null) {
log.warning("Editor not created for " + mField.getColumnName());
continue;
}
// MField => VEditor - New Field value to be updated to editor
mField.addPropertyChangeListener(vEditor);
// VEditor => this - New Editor value to be updated here (MTable)
vEditor.addVetoableChangeListener(this);
// Add to VPanel
vPanel.addFieldBuffered(vEditor, mField);
// APanel Listen to buttons
if (mField.getDisplayType() == DisplayType.Button && m_aPanel != null)
((JButton) vEditor).addActionListener(m_aPanel);
}
}
// for all fields
// flush the last one through
vPanel.addFieldBuffered(null, null);
// No Included Grid Controller
/*
srPane.setResizeWeight(1); // top part gets all
srPane.setDividerSize (0);
srPane.setDividerLocation (9999);
*/
// Use SR to size MR
mrPane.setPreferredSize(vPanel.getPreferredSize());
}
// Single-Row
// Tree Graphics Layout
int AD_Tree_ID = 0;
if (m_mTab.isTreeTab())
AD_Tree_ID = MTree.getDefaultAD_Tree_ID(Env.getAD_Client_ID(Env.getCtx()), m_mTab.getKeyColumnName());
if (m_mTab.isTreeTab() && AD_Tree_ID != 0) {
m_tree = new VTreePanel(m_WindowNo, false, true);
if (// initialize other tabs later
m_mTab.getTabNo() == 0)
m_tree.initTree(AD_Tree_ID);
m_tree.addPropertyChangeListener(VTreePanel.NODE_SELECTION, this);
graphPanel.add(m_tree, BorderLayout.CENTER);
splitPane.setDividerLocation(250);
// splitPane.resetToPreferredSizes();
} else // No Graphics - hide
{
graphPanel.setPreferredSize(new Dimension(0, 0));
splitPane.setDividerSize(0);
splitPane.setDividerLocation(0);
}
// Receive DataStatusChanged info from MTab
m_mTab.addDataStatusListener(this);
// Receive vetoableChange info from MTable when saving
m_mTab.getTableModel().addVetoableChangeListener(this);
// Selection Listener -> valueChanged
vTable.getSelectionModel().addListSelectionListener(this);
// Navigation (RowChanged)
m_mTab.addPropertyChangeListener(vTable);
// Update UI
vTable.autoSize(true);
// Set initial presentation
if (m_onlyMultiRow || !m_mTab.isSingleRow())
switchMultiRow();
else
switchSingleRow();
init = true;
}
use of org.compiere.grid.ed.VEditor in project adempiere by adempiere.
the class VBrowser method getPanelParameters.
@Override
public LinkedHashMap<String, GridField> getPanelParameters() {
LinkedHashMap<String, GridField> m_List = new LinkedHashMap<String, GridField>();
for (Entry<String, Object> entry : searchPanel.getParameters().entrySet()) {
VEditor editor = (VEditor) entry.getValue();
// BR [ 251 ]
if (!((Component) editor).isVisible() || editor.getField().isInfoOnly())
continue;
//
GridField field = editor.getField();
m_List.put(entry.getKey(), field);
}
// Default Return
return m_List;
}
use of org.compiere.grid.ed.VEditor in project adempiere by adempiere.
the class VBrowserSearch method setComponentVisibility.
@Override
public void setComponentVisibility(int index, Boolean visible, Boolean isRange) {
VEditor editor = (VEditor) getEditor(index);
VEditor editorTo = (VEditor) getEditorTo(index);
// Validate null
if (editor == null)
return;
Component[] components = centerPanel.getComponents();
for (Component comp : components) {
if (editor.getField().getColumnName().equals(comp.getName())) {
if (visible) {
if (!comp.isVisible()) {
// visibility
comp.setVisible(true);
// FR [ 349 ]
if (isRange && editorTo != null) {
editorTo.setVisible(true);
m_separators.get(index).setText(" - ");
}
}
} else if (comp.isVisible()) {
comp.setVisible(false);
// BR [ 590 ]
if (isRange && editorTo != null) {
editorTo.setVisible(false);
m_separators.get(index).setText("");
}
}
}
}
}
Aggregations