use of org.compiere.swing.CComboBox in project adempiere by adempiere.
the class VPAttributeDialog method saveSelection.
// cmd_zoom
/**
* Save Selection
* @return true if saved
*/
private boolean saveSelection() {
if (!m_readWrite)
return true;
log.info("");
MAttributeSet as = m_masi.getMAttributeSet();
if (as == null)
return true;
//
m_changed = false;
String mandatory = "";
if ((!m_productWindow || !m_productASI) && as.isLot()) {
log.fine("Lot=" + fieldLotString.getText());
String text = fieldLotString.getText();
m_masi.setLot(text);
if (as.isLotMandatory() && (text == null || text.length() == 0))
mandatory += " - " + Msg.translate(Env.getCtx(), "Lot");
m_changed = true;
}
// Lot
if ((!m_productWindow || !m_productASI) && as.isSerNo()) {
log.fine("SerNo=" + fieldSerNo.getText());
String text = fieldSerNo.getText();
m_masi.setSerNo(text);
if (as.isSerNoMandatory() && (text == null || text.length() == 0))
mandatory += " - " + Msg.translate(Env.getCtx(), "SerNo");
m_changed = true;
}
// SerNo
if ((!m_productWindow || !m_productASI) && as.isGuaranteeDate()) {
log.fine("GuaranteeDate=" + fieldGuaranteeDate.getValue());
Timestamp ts = (Timestamp) fieldGuaranteeDate.getValue();
m_masi.setGuaranteeDate(ts);
if (as.isGuaranteeDateMandatory() && ts == null)
mandatory += " - " + Msg.translate(Env.getCtx(), "GuaranteeDate");
m_changed = true;
}
// New Instance
if (m_changed || m_masi.getM_AttributeSetInstance_ID() == 0) {
m_masi.save();
m_M_AttributeSetInstance_ID = m_masi.getM_AttributeSetInstance_ID();
m_M_AttributeSetInstanceName = m_masi.getDescription();
}
// Save attributes
if (m_M_AttributeSetInstance_ID > 0 && m_readWrite) {
// Save Instance Attributes
MAttribute[] attributes = as.getMAttributes(!m_productASI);
for (int i = 0; i < attributes.length; i++) {
if (MAttribute.ATTRIBUTEVALUETYPE_List.equals(attributes[i].getAttributeValueType())) {
CComboBox editor = (CComboBox) m_editors.get(i);
MAttributeValue value = (MAttributeValue) editor.getSelectedItem();
log.fine(attributes[i].getName() + "=" + value);
if (attributes[i].isMandatory() && value == null)
mandatory += " - " + attributes[i].getName();
attributes[i].setMAttributeInstance(m_M_AttributeSetInstance_ID, value);
} else if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attributes[i].getAttributeValueType())) {
VNumber editor = (VNumber) m_editors.get(i);
BigDecimal value = (BigDecimal) editor.getValue();
log.fine(attributes[i].getName() + "=" + value);
if (attributes[i].isMandatory() && value == null)
mandatory += " - " + attributes[i].getName();
//setMAttributeInstance doesn't work without decimal point
if (value != null && value.scale() == 0)
value = value.setScale(1, BigDecimal.ROUND_HALF_UP);
attributes[i].setMAttributeInstance(m_M_AttributeSetInstance_ID, value);
} else {
VString editor = (VString) m_editors.get(i);
String value = editor.getText();
log.fine(attributes[i].getName() + "=" + value);
if (attributes[i].isMandatory() && (value == null || value.length() == 0))
mandatory += " - " + attributes[i].getName();
attributes[i].setMAttributeInstance(m_M_AttributeSetInstance_ID, value);
}
}
m_changed = true;
}
// Save Model
if (m_changed) {
m_masi.setDescription();
m_masi.save();
}
m_M_AttributeSetInstance_ID = m_masi.getM_AttributeSetInstance_ID();
m_M_AttributeSetInstanceName = m_masi.getDescription();
//
if (mandatory.length() > 0) {
ADialog.error(m_WindowNo, this, "FillMandatory", mandatory);
return false;
}
return true;
}
use of org.compiere.swing.CComboBox in project adempiere by adempiere.
the class Find method initFindAdvanced.
// addSelectionColumn
/**
* Init Find GridController
*/
private void initFindAdvanced() {
log.config("");
advancedTable.setModel(new DefaultTableModel(0, 7));
advancedTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
advancedTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
advancedTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
TableCellRenderer renderer = new ProxyRenderer(advancedTable.getDefaultRenderer(Object.class));
advancedTable.setDefaultRenderer(Object.class, renderer);
InputMap im = advancedTable.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
final Action tabAction = advancedTable.getActionMap().get(im.get(tab));
Action tabActionWrapper = new AbstractAction() {
private static final long serialVersionUID = -6868476640719619801L;
public void actionPerformed(ActionEvent e) {
tabAction.actionPerformed(e);
JTable table = (JTable) e.getSource();
table.requestFocusInWindow();
}
};
advancedTable.getActionMap().put(im.get(tab), tabActionWrapper);
KeyStroke shiftTab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK);
final Action shiftTabAction = advancedTable.getActionMap().get(im.get(shiftTab));
Action shiftTabActionWrapper = new AbstractAction() {
private static final long serialVersionUID = 5493691483070046620L;
public void actionPerformed(ActionEvent e) {
shiftTabAction.actionPerformed(e);
JTable table = (JTable) e.getSource();
table.requestFocusInWindow();
}
};
advancedTable.getActionMap().put(im.get(shiftTab), shiftTabActionWrapper);
// 0 = Columns
ArrayList<ValueNamePair> items = new ArrayList<ValueNamePair>();
for (int c = 0; c < m_findFields.length; c++) {
GridField field = m_findFields[c];
String columnName = field.getColumnName();
String header = field.getHeader();
if (header == null || header.length() == 0) {
header = Msg.translate(Env.getCtx(), columnName);
if (header == null || header.length() == 0)
continue;
}
if (field.isKey())
header += (" (ID)");
ValueNamePair pp = new ValueNamePair(columnName, header);
// System.out.println(pp + " = " + field);
items.add(pp);
}
columnValueNamePairs = new ValueNamePair[items.size()];
items.toArray(columnValueNamePairs);
// sort alpha
Arrays.sort(columnValueNamePairs);
columns = new CComboBox(columnValueNamePairs);
columns.addActionListener(this);
TableColumn tc = advancedTable.getColumnModel().getColumn(INDEX_COLUMNNAME);
tc.setPreferredWidth(120);
FindCellEditor dce = new FindCellEditor(columns);
dce.addCellEditorListener(new CellEditorListener() {
public void editingCanceled(ChangeEvent ce) {
}
public void editingStopped(ChangeEvent ce) {
int col = advancedTable.getSelectedColumn();
int row = advancedTable.getSelectedRow();
if (col == INDEX_COLUMNNAME && row >= 0) {
advancedTable.setValueAt(null, row, INDEX_VALUE);
advancedTable.setValueAt(null, row, INDEX_VALUE2);
}
}
});
tc.setCellEditor(dce);
tc.setHeaderValue(Msg.translate(Env.getCtx(), "AD_Column_ID"));
// 0 = And/Or
andOr = new CComboBox(new String[] { "", Msg.getMsg(Env.getCtx(), "AND"), Msg.getMsg(Env.getCtx(), "OR") });
tc = advancedTable.getColumnModel().getColumn(INDEX_ANDOR);
tc.setPreferredWidth(45);
dce = new FindCellEditor(andOr);
tc.setCellEditor(dce);
tc.setHeaderValue(Msg.getMsg(Env.getCtx(), "And/Or"));
// 1 = Left Bracket
leftBrackets = new CComboBox(new String[] { "", "(", "((", "(((" });
tc = advancedTable.getColumnModel().getColumn(INDEX_LEFTBRACKET);
tc.setPreferredWidth(25);
dce = new FindCellEditor(leftBrackets);
tc.setCellEditor(dce);
tc.setHeaderValue("(");
// 3 = Operators
operators = new CComboBox(MQuery.OPERATORS);
tc = advancedTable.getColumnModel().getColumn(INDEX_OPERATOR);
tc.setPreferredWidth(55);
dce = new FindCellEditor(operators);
tc.setCellEditor(dce);
tc.setHeaderValue(Msg.getMsg(Env.getCtx(), "Operator"));
// 4 = QueryValue
tc = advancedTable.getColumnModel().getColumn(INDEX_VALUE);
FindValueEditor fve = new FindValueEditor(this, false);
tc.setCellEditor(fve);
tc.setPreferredWidth(120);
tc.setCellRenderer(new ProxyRenderer(new FindValueRenderer(this, false)));
tc.setHeaderValue(Msg.getMsg(Env.getCtx(), "QueryValue"));
// 5 = QueryValue2
tc = advancedTable.getColumnModel().getColumn(INDEX_VALUE2);
tc.setPreferredWidth(120);
fve = new FindValueEditor(this, true);
tc.setCellEditor(fve);
tc.setCellRenderer(new ProxyRenderer(new FindValueRenderer(this, false)));
tc.setHeaderValue(Msg.getMsg(Env.getCtx(), "QueryValue2"));
// 6 = Right Bracket
rightBrackets = new CComboBox(new String[] { "", ")", "))", ")))" });
tc = advancedTable.getColumnModel().getColumn(INDEX_RIGHTBRACKET);
tc.setPreferredWidth(25);
dce = new FindCellEditor(rightBrackets);
tc.setCellEditor(dce);
tc.setHeaderValue(")");
// phib: disabled auto-completion as it causes date fields to have to be entered twice
//AutoCompletion.enable(columns);
//AutoCompletion.enable(operators);
//user query
refreshUserQueries();
}
use of org.compiere.swing.CComboBox in project adempiere by adempiere.
the class VTreeMaintenance method preInit.
// init
/**
* Fill Tree Combo
*/
private void preInit() {
treeField = new CComboBox(getTreeData());
treeField.addActionListener(this);
//
centerTree = new VTreePanel(m_WindowNo, false, true);
centerTree.addPropertyChangeListener(VTreePanel.NODE_SELECTION, this);
}
use of org.compiere.swing.CComboBox in project adempiere by adempiere.
the class VDeleteEntity method preInit.
/**
* Pre Init
*/
private void preInit() {
refreshButton = ConfirmPanel.createRefreshButton(false);
refreshButton.addActionListener(this);
//
dryRun = new CCheckBox(Msg.getMsg(Env.getCtx(), "DryRun"), true);
clientLabel = new CLabel(Msg.getElement(Env.getCtx(), "AD_Client_ID"));
clientPick = new CComboBox(getClients());
clientPick.setSelectedItem(null);
clientPick.setMandatory(true);
clientPick.setBackground(false);
tableLabel = new CLabel(Msg.getElement(Env.getCtx(), "AD_Table_ID"));
tablePick = new CComboBox(getTables());
tablePick.setSelectedItem(null);
tablePick.setMandatory(true);
tablePick.setBackground(false);
rootNode = new DefaultMutableTreeNode(null);
tree = new CheckboxTree(rootNode);
treePane = new JScrollPane(tree);
JViewport viewPort = treePane.getViewport();
viewPort.add(tree);
}
use of org.compiere.swing.CComboBox in project adempiere by adempiere.
the class VProductConfigurationBOM method createSelectionPanel.
/**************************************************************************
* Create Selection Panel
* @param order
* @param invoice
* @param project
*/
private void createSelectionPanel(boolean order, boolean invoice, boolean project) {
int row = 0;
selectionPanel.setBorder(new TitledBorder(Msg.translate(Env.getCtx(), "Selection")));
productField = new CComboBox(getProducts());
CLabel label = new CLabel(Msg.translate(Env.getCtx(), "M_Product_ID"));
label.setLabelFor(productField);
selectionPanel.add(label, new ALayoutConstraint(row++, 0));
selectionPanel.add(productField);
productField.addActionListener(this);
// Qty
label = new CLabel(productQty.getTitle());
label.setLabelFor(productQty);
selectionPanel.add(label);
selectionPanel.add(productQty);
productQty.setValue(Env.ONE);
productQty.addActionListener(this);
if (order) {
orderField = new CComboBox(getOrders());
label = new CLabel(Msg.translate(Env.getCtx(), "C_Order_ID"));
label.setLabelFor(orderField);
selectionPanel.add(label, new ALayoutConstraint(row++, 0));
selectionPanel.add(orderField);
orderField.addActionListener(this);
}
if (invoice) {
invoiceField = new CComboBox(getInvoices());
label = new CLabel(Msg.translate(Env.getCtx(), "C_Invoice_ID"));
label.setLabelFor(invoiceField);
selectionPanel.add(label, new ALayoutConstraint(row++, 0));
selectionPanel.add(invoiceField);
invoiceField.addActionListener(this);
}
if (project) {
projectField = new CComboBox(getProjects());
label = new CLabel(Msg.translate(Env.getCtx(), "C_Project_ID"));
label.setLabelFor(projectField);
selectionPanel.add(label, new ALayoutConstraint(row++, 0));
selectionPanel.add(projectField);
projectField.addActionListener(this);
}
// Enabled in ActionPerformed
confirmPanel.getOKButton().setEnabled(false);
// Size
Dimension size = selectionPanel.getPreferredSize();
size.width = WINDOW_WIDTH;
selectionPanel.setPreferredSize(size);
}
Aggregations