use of org.adempiere.webui.component.Combobox in project adempiere by adempiere.
the class InfoPanel method onEvent.
// getAD_Window_ID
public void onEvent(Event event) {
if (!p_loadedOK)
// We aren't ready
return;
if (m_busy)
// We're busy. Ignore events.
return;
if (event != null) {
if (event.getName().equals("onOK")) {
// The enter key was pressed in a criteria field. Ignore it. The key click will trigger
// other events that will be trapped.
event.stopPropagation();
return;
}
Component component = event.getTarget();
if (component != null) {
// Generic components in the criteria fields
if (component instanceof Textbox) {
Textbox tb = ((Textbox) component);
if (tb.hasChanged()) {
p_triggerRefresh = true;
} else {
// if the dialog was opened from a menu.
if (isModal())
// Save the selection and close;
dispose(true);
else
return;
}
} else if (component instanceof Checkbox) {
// Check box changes generally always cause a refresh
// Capture changes that don't in a specific event handler
p_triggerRefresh = true;
Checkbox cb = (Checkbox) component;
if (cb.getName() != null && cb.getName().equals("AutoQuery")) {
// Only trigger a refresh if the check box is selected
if (!cb.isSelected()) {
return;
}
}
} else {
// Assume another type of component
if (event.getName().equals("onChange")) {
if (component instanceof Combobox) {
if (// Test for meaningful changes. Null == " ".
hasOutstandingChanges())
p_triggerRefresh = true;
} else
p_triggerRefresh = true;
}
}
// Buttons
if (component.equals(confirmPanel.getButton(ConfirmPanel.A_OK))) {
// VLookup fields in the criteria
if (hasOutstandingChanges()) {
return;
} else {
// We might close
p_triggerRefresh = false;
}
onOk();
} else if (component == p_table && event.getName().equals(Events.ON_DOUBLE_CLICK)) {
onDoubleClick();
} else if (component.equals(confirmPanel.getButton(ConfirmPanel.A_RESET))) {
// Created by the reset button, if used, to reset the criteria panel.
// Go back to the defaults
// Prevent other actions
m_busy = true;
// Should be overridden in the subordinate class
initInfo();
m_busy = false;
p_triggerRefresh = true;
// Ignore the autoQuery value and refresh now.
p_refreshNow = true;
} else if (component.equals(confirmPanel.getButton(ConfirmPanel.A_REFRESH))) {
// Refresh always causes a requery in case there are
// changes to the underlying tables - even if the
// criteria haven't changed.
p_resetColumns = true;
p_triggerRefresh = true;
p_refreshNow = true;
} else if (component.equals(confirmPanel.getButton(ConfirmPanel.A_CANCEL))) {
m_cancel = true;
// close
dispose(false);
} else // Elaine 2008/12/16
if (component.equals(confirmPanel.getButton(ConfirmPanel.A_HISTORY))) {
if (!p_table.getChildren().isEmpty() && p_table.getSelectedRowKey() != null) {
showHistory();
}
return;
} else if (component.equals(confirmPanel.getButton(ConfirmPanel.A_CUSTOMIZE))) {
if (!p_table.getChildren().isEmpty() && p_table.getSelectedRowKey() != null) {
customize();
}
return;
} else //
if (component.equals(confirmPanel.getButton(ConfirmPanel.A_ZOOM))) {
if (!p_table.getChildren().isEmpty() && p_table.getSelectedRowKey() != null) {
zoom();
if (isModal())
this.detach();
}
return;
} else if (component == paging) {
int pgNo = paging.getActivePage();
if (pageNo != pgNo) {
p_table.clearSelection();
pageNo = pgNo;
int start = pageNo * PAGE_SIZE;
int end = start + PAGE_SIZE;
List<Object> subList = readLine(start, end);
model = new ListModelTable(subList);
model.setSorter(this);
model.addTableModelListener(this);
p_table.setData(model, null);
p_table.setSelectedIndex(0);
}
}
}
// All events, unless trapped above, will get here.
// Check if we need to reset the table. The flag is reset when
// the table is reset. The first change triggers the reset.
p_resetColumns = p_resetColumns || columnIsDynamic(component);
// Refresh if the autoquery feature is selected or the refresh button is clicked.
if ((p_triggerRefresh && autoQuery()) || p_refreshNow) {
prepareAndExecuteQuery();
p_refreshNow = false;
}
}
}
use of org.adempiere.webui.component.Combobox in project adempiere by adempiere.
the class InfoProductPanel method onEvent.
// isUnconfirmed
public void onEvent(Event e) {
if (!p_loadedOK)
return;
Component component = e.getTarget();
if (component != null) {
// Handle product info specific fields here
if (component.equals(confirmPanel.getButton(ConfirmPanel.A_PATTRIBUTE))) {
// Find the ASI used by the product on the lead row
MProduct mp = MProduct.get(Env.getCtx(), m_M_Product_ID);
// Set title and parameters for the PattributeInstance window
String title = "";
int wh_id = 0;
if (isValidVObject(fWarehouse_ID)) {
title = mp.getName() + " - " + fWarehouse_ID.getDisplay();
wh_id = ((Integer) (fWarehouse_ID.getValue())).intValue();
}
// Get the business partner from the context - it may be different than the Vendor
int bp_id = 0;
String s_bp_id = Env.getContext(Env.getCtx(), p_WindowNo, p_TabNo, "C_BPartner_ID", false);
if (s_bp_id != null && s_bp_id.length() != 0 && (new Integer(s_bp_id).intValue() > 0))
bp_id = new Integer(s_bp_id).intValue();
// Display the window
InfoPAttributeInstancePanel pai = new InfoPAttributeInstancePanel(this, title, wh_id, 0, p_table.getLeadRowKey(), bp_id);
if (!pai.wasCancelled()) {
// Get the results and update the fASI criteria field
m_M_AttributeSetInstance_ID = pai.getM_AttributeSetInstance_ID();
m_M_Locator_ID = pai.getM_Locator_ID();
if (m_M_AttributeSetInstance_ID > 0)
fASI_ID.setValue(m_M_AttributeSetInstance_ID);
else
// No instance
fASI_ID.setValue(0);
}
// looking around.
if (// If the results are saved, we can save now - an ASI is product specific
p_saveResults && m_M_AttributeSetInstance_ID != -1 && !pai.wasCancelled()) {
dispose(p_saveResults);
return;
}
return;
} else if (component instanceof Combobox) {
if (e.getName().equals("onChange")) {
// perform field-specific changes
if (component.equals(fWarehouse_ID.getComponent())) {
if (!isValidVObject(fWarehouse_ID)) {
// Disable the stock button
checkOnlyStock.setSelected(false);
checkOnlyStock.setEnabled(false);
} else
checkOnlyStock.setEnabled(true);
}
}
} else if (component instanceof Checkbox) {
Checkbox cb = (Checkbox) component;
// ShowDetail check box
if (cb.getName() != null && cb.getName().equals("ShowDetail")) {
// Refresh only the ATP tab
refreshAtpTab();
return;
}
} else if (// a tab in the ATP panel is selected
component instanceof Tab) {
if (detailTabBox.getSelectedIndex() == 5) {
checkShowDetail.setEnabled(true);
} else {
checkShowDetail.setEnabled(false);
}
refresh();
return;
}
}
//
super.onEvent(e);
}
use of org.adempiere.webui.component.Combobox in project adempiere by adempiere.
the class RolePanel method initComponents.
@SuppressWarnings("unchecked")
private void initComponents() {
Language language = Env.getLanguage(m_ctx);
ResourceBundle res = ResourceBundle.getBundle(RESOURCE, language.getLocale());
lblRole = new Label();
lblRole.setId("lblRole");
lblRole.setValue(res.getString("Role"));
lblClient = new Label();
lblClient.setId("lblClient");
lblClient.setValue(res.getString("Client"));
lblOrganisation = new Label();
lblOrganisation.setId("lblOrganisation");
lblOrganisation.setValue(res.getString("Organization"));
lblWarehouse = new Label();
lblWarehouse.setId("lblWarehouse");
lblWarehouse.setValue(res.getString("Warehouse"));
lstRole = new Combobox();
lstRole.setAutocomplete(true);
lstRole.setAutodrop(true);
lstRole.setId("lstRole");
lstRole.addEventListener(Events.ON_SELECT, this);
lstClient = new Combobox();
lstClient.setAutocomplete(true);
lstClient.setAutodrop(true);
lstClient.setId("lstClient");
lstClient.addEventListener(Events.ON_SELECT, this);
lstOrganisation = new Combobox();
lstOrganisation.setAutocomplete(true);
lstOrganisation.setAutodrop(true);
lstOrganisation.setId("lstOrganisation");
lstOrganisation.addEventListener(Events.ON_SELECT, this);
lstWarehouse = new Combobox();
lstWarehouse.setAutocomplete(true);
lstWarehouse.setAutodrop(true);
lstWarehouse.setId("lstWarehouse");
lstWarehouse.addEventListener(Events.ON_SELECT, this);
btnOk = new Button();
btnOk.setId("btnOk");
btnOk.setLabel("Ok");
btnOk.addEventListener("onClick", this);
btnCancel = new Button();
btnCancel.setId("btnCancel");
btnCancel.setLabel("Cancel");
btnCancel.addEventListener("onClick", this);
// initial role - Elaine 2009/02/06
UserPreference userPreference = SessionManager.getSessionApplication().getUserPreference();
String initDefault = userPreference.getProperty(UserPreference.P_ROLE);
for (int i = 0; i < rolesKNPairs.length; i++) {
ComboItem ci = new ComboItem(rolesKNPairs[i].getName(), rolesKNPairs[i].getID());
lstRole.appendChild(ci);
if (rolesKNPairs[i].getID().equals(initDefault))
lstRole.setSelectedItem(ci);
}
if (lstRole.getSelectedIndex() == -1 && lstRole.getItemCount() > 0)
lstRole.setSelectedIndex(0);
// If we have only one role, we can hide the combobox - metas-2009_0021_AP1_G94
if (lstRole.getItemCount() == 1 && !MSysConfig.getBooleanValue("ALogin_ShowOneRole", true)) {
lstRole.setSelectedIndex(0);
lblRole.setVisible(false);
lstRole.setVisible(false);
} else {
lblRole.setVisible(true);
lstRole.setVisible(true);
}
updateClientList();
}
use of org.adempiere.webui.component.Combobox in project adempiere by adempiere.
the class WDeleteEntity method dynInit.
/**
* Dyn Init
*/
public void dynInit() {
// Client Pick
clientPick = new Combobox();
tablePick = new Combobox();
// Load Clients
for (KeyNamePair client : getClients()) {
clientPick.appendItem(client.getName(), client);
}
//
clientPick.setSelectedIndex(0);
// Load Tables
for (KeyNamePair tables : getTables()) {
tablePick.appendItem(tables.getName(), tables);
}
//
tablePick.setSelectedIndex(0);
}
use of org.adempiere.webui.component.Combobox in project adempiere by adempiere.
the class WDelete method dynInit.
public void dynInit() throws Exception {
// Client Pick
String sql = "SELECT AD_Client_ID, Name FROM AD_Client WHERE AD_Client_ID <> 0";
clientPick = new Combobox();
PreparedStatement pstmt1 = DB.prepareStatement(sql, null);
ResultSet rs1 = null;
String clientName = null;
Integer clientID = null;
try {
rs1 = pstmt1.executeQuery();
while (rs1.next()) {
clientID = new Integer(rs1.getInt(1));
clientName = new String(rs1.getString(2));
clientPick.appendItem(clientName, clientID);
clientMap.put(clientName, clientID);
}
} catch (SQLException e) {
System.out.println(e);
} finally {
DB.close(rs1);
DB.close(pstmt1);
}
// Table Pick
MLookup lookupTable = MLookupFactory.get(Env.getCtx(), form.getWindowNo(), 0, ad_table_id, DisplayType.TableDir);
tablePick = new WTableDirEditor("AD_Table_ID", true, false, true, lookupTable);
tablePick.setValue(new Integer((Integer) Env.getContextAsInt(Env.getCtx(), "$AD_Table_ID")));
tablePick.addValueChangeListener(this);
}
Aggregations