use of javax.swing.JCheckBox in project aima-java by aimacode.
the class MapViewFrame method initToolbar.
/**
* Defines the functionality of the toolbar by adding components to it.
* Override to customize!
*/
protected void initToolbar() {
toolbar.setFloatable(false);
loadButton = new JButton("Load");
loadButton.setToolTipText("Load Map (<ctrl> bounding box mode, <shift> overview mode)");
loadButton.addActionListener(this);
toolbar.add(loadButton);
saveButton = new JButton("Save");
saveButton.setToolTipText("Save Visible Map");
saveButton.addActionListener(this);
toolbar.add(saveButton);
statisticsButton = new JButton("Statistics");
statisticsButton.setToolTipText("Show Map Statistics");
statisticsButton.addActionListener(this);
toolbar.add(statisticsButton);
sidebarCheckBox = new JCheckBox("Sidebar");
sidebarCheckBox.addActionListener(this);
sidebarCheckBox.setSelected(false);
showSidebar(false);
toolbar.add(sidebarCheckBox);
InfoField infoField = new InfoField(view, getMap());
view.addMapViewEventListener(infoField.getMapViewEventListener());
getMap().addMapDataEventListener(infoField.getMapDataEventListener());
toolbar.add(infoField);
}
use of javax.swing.JCheckBox in project adempiere by adempiere.
the class VBOMDrop method actionPerformed.
// getPreferredSize
/**************************************************************************
* Action Listener
* @param e event
*/
public void actionPerformed(ActionEvent e) {
log.config(e.getActionCommand());
Object source = e.getSource();
// Toggle Qty Enabled
if (source instanceof JCheckBox || source instanceof JRadioButton) {
cmd_selection(source);
// need to de-select the others in group
if (source instanceof JRadioButton) {
// find Button Group
Iterator it = m_buttonGroups.values().iterator();
while (it.hasNext()) {
ButtonGroup group = (ButtonGroup) it.next();
Enumeration en = group.getElements();
while (en.hasMoreElements()) {
// We found the group
if (source == en.nextElement()) {
Enumeration info = group.getElements();
while (info.hasMoreElements()) {
Object infoObj = info.nextElement();
if (source != infoObj)
cmd_selection(infoObj);
}
}
}
}
}
} else // Product / Qty
if (source == productField || source == productQty) {
m_qty = (BigDecimal) productQty.getValue();
KeyNamePair pp = (KeyNamePair) productField.getSelectedItem();
m_product = MProduct.get(Env.getCtx(), pp.getKey());
createMainPanel();
sizeIt();
} else // Order
if (source == orderField) {
KeyNamePair pp = (KeyNamePair) orderField.getSelectedItem();
boolean valid = (pp != null && pp.getKey() > 0);
//
if (invoiceField != null)
invoiceField.setReadWrite(!valid);
if (projectField != null)
projectField.setReadWrite(!valid);
} else // Invoice
if (source == invoiceField) {
KeyNamePair pp = (KeyNamePair) invoiceField.getSelectedItem();
boolean valid = (pp != null && pp.getKey() > 0);
//
if (orderField != null)
orderField.setReadWrite(!valid);
if (projectField != null)
projectField.setReadWrite(!valid);
} else // Project
if (source == projectField) {
KeyNamePair pp = (KeyNamePair) projectField.getSelectedItem();
boolean valid = (pp != null && pp.getKey() > 0);
//
if (orderField != null)
orderField.setReadWrite(!valid);
if (invoiceField != null)
invoiceField.setReadWrite(!valid);
} else // OK
if (e.getActionCommand().equals(ConfirmPanel.A_OK)) {
if (cmd_save())
dispose();
} else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL))
dispose();
// Enable OK
boolean OK = m_product != null;
if (OK) {
KeyNamePair pp = null;
if (orderField != null)
pp = (KeyNamePair) orderField.getSelectedItem();
if ((pp == null || pp.getKey() <= 0) && invoiceField != null)
pp = (KeyNamePair) invoiceField.getSelectedItem();
if ((pp == null || pp.getKey() <= 0) && projectField != null)
pp = (KeyNamePair) projectField.getSelectedItem();
OK = (pp != null && pp.getKey() > 0);
}
confirmPanel.getOKButton().setEnabled(OK);
}
use of javax.swing.JCheckBox in project adempiere by adempiere.
the class VBOMDrop method addDisplay.
// addBOMLine
/**
* Add Line to Display
* @param parentM_Product_ID parent product
* @param M_Product_ID product
* @param bomType bom type
* @param name name
* @param lineQty qty
*/
private void addDisplay(int parentM_Product_ID, int M_Product_ID, String bomType, String name, String feature, BigDecimal lineQty) {
log.fine("M_Product_ID=" + M_Product_ID + ",Type=" + bomType + ",Name=" + name + ",feature=" + feature + ",Qty=" + lineQty);
//
boolean selected = true;
if (MPPProductBOMLine.COMPONENTTYPE_Component.equals(bomType)) {
String title = "";
JCheckBox cb = new JCheckBox(title);
cb.setSelected(true);
cb.setEnabled(false);
// cb.addActionListener(this); // will not change
m_selectionList.add(cb);
this.add(cb, new ALayoutConstraint(m_bomLine++, 0));
} else if (MPPProductBOMLine.COMPONENTTYPE_Option.equals(bomType)) {
//String title = Msg.getMsg(Env.getCtx(), "Optional");
JCheckBox cb = new JCheckBox(feature);
cb.setSelected(false);
selected = false;
cb.addActionListener(this);
m_selectionList.add(cb);
this.add(cb, new ALayoutConstraint(m_bomLine++, 0));
} else if (MPPProductBOMLine.COMPONENTTYPE_Variant.equals(bomType)) {
//String title = Msg.getMsg(Env.getCtx(), "Variant") + " " + bomType;
JRadioButton b = new JRadioButton(feature);
String groupName = feature + "_" + String.valueOf(parentM_Product_ID) + "_" + bomType;
ButtonGroup group = (ButtonGroup) m_buttonGroups.get(groupName);
if (group == null) {
log.fine("ButtonGroup=" + groupName);
group = new ButtonGroup();
m_buttonGroups.put(groupName, group);
group.add(b);
// select first one
b.setSelected(true);
} else {
group.add(b);
b.setSelected(false);
selected = false;
}
b.addActionListener(this);
m_selectionList.add(b);
this.add(b, new ALayoutConstraint(m_bomLine++, 0));
}
// Add to List & display
m_productList.add(new Integer(M_Product_ID));
VNumber qty = new VNumber("Qty", true, false, true, DisplayType.Quantity, name);
qty.setValue(lineQty);
qty.setReadWrite(selected);
m_qtyList.add(qty);
CLabel label = new CLabel(name);
label.setLabelFor(qty);
this.add(label);
this.add(qty);
}
use of javax.swing.JCheckBox in project adempiere by adempiere.
the class MiniTable method prepareRenderer.
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
Component c = super.prepareRenderer(renderer, row, column);
JComponent jc = (JComponent) c;
if (c == null)
return c;
// Row is selected
Color selectedColor = AdempierePLAF.getFieldBackground_Selected();
// Even row
Color normalColor = AdempierePLAF.getFieldBackground_Normal();
// Odd row
Color backColor = AdempierePLAF.getInfoBackground();
// Lead row border
Color borderColor = AdempierePLAF.getFieldBackground_Mandatory();
CompoundBorder cb = null;
ListSelectionModel rsm = this.getSelectionModel();
boolean readOnly = !this.isCellEditable(row, column);
if (!(row == rsm.getLeadSelectionIndex())) {
if (// Highlighted but not the lead
rsm.isSelectedIndex(row)) {
c.setBackground(selectedColor);
jc.setBorder(new MatteBorder(1, 1, 1, 1, selectedColor));
} else if (// Not selected but even in number
row % 2 == 0) {
c.setBackground(normalColor);
jc.setBorder(new MatteBorder(1, 1, 1, 1, normalColor));
} else // Not selected and odd in number
{
// If not shaded, match the table's background
c.setBackground(backColor);
jc.setBorder(new MatteBorder(1, 1, 1, 1, backColor));
}
// Buttons and checkboxes need to have the border turned on
if (c.getClass().equals(JCheckBox.class)) {
((JCheckBox) c).setBorderPainted(false);
} else if (c.getClass().equals(JButton.class)) {
((JButton) c).setBorderPainted(false);
}
} else {
if (c.getClass().equals(JCheckBox.class)) {
((JCheckBox) c).setBorderPainted(true);
} else if (c.getClass().equals(JButton.class)) {
((JButton) c).setBorderPainted(true);
}
// Define border - compond border maintains the spacing of 1px around the field
if (column == 0) {
cb = new CompoundBorder(new EmptyBorder(new Insets(0, 0, 0, 1)), new MatteBorder(1, 1, 1, 0, borderColor));
} else if (column == this.getColumnCount() - 1) {
cb = new CompoundBorder(new EmptyBorder(new Insets(0, 1, 0, 0)), new MatteBorder(1, 0, 1, 1, borderColor));
} else {
cb = new CompoundBorder(new EmptyBorder(new Insets(0, 1, 0, 1)), new MatteBorder(1, 0, 1, 0, borderColor));
}
// Set border
jc.setBorder(cb);
// Set background color
if (!readOnly && this.isRowChecked(row))
c.setBackground(normalColor);
else
c.setBackground(selectedColor);
}
return c;
}
use of javax.swing.JCheckBox in project adempiere by adempiere.
the class VProductConfigurationBOM method actionPerformed.
// getPreferredSize
/**************************************************************************
* Action Listener
* @param e event
*/
public void actionPerformed(ActionEvent e) {
log.config(e.getActionCommand());
Object source = e.getSource();
// Toggle Qty Enabled
if (source instanceof JCheckBox || source instanceof JRadioButton) {
cmd_selection(source);
// need to de-select the others in group
if (source instanceof JRadioButton) {
// find Button Group
Iterator it = m_buttonGroups.values().iterator();
while (it.hasNext()) {
ButtonGroup group = (ButtonGroup) it.next();
Enumeration en = group.getElements();
while (en.hasMoreElements()) {
// We found the group
if (source == en.nextElement()) {
Enumeration info = group.getElements();
while (info.hasMoreElements()) {
Object infoObj = info.nextElement();
if (source != infoObj)
cmd_selection(infoObj);
}
}
}
}
}
} else // Product / Qty
if (source == productField || source == productQty) {
m_qty = (BigDecimal) productQty.getValue();
KeyNamePair pp = (KeyNamePair) productField.getSelectedItem();
m_product = MProduct.get(Env.getCtx(), pp.getKey());
createMainPanel();
sizeIt();
} else // Order
if (source == orderField) {
KeyNamePair pp = (KeyNamePair) orderField.getSelectedItem();
boolean valid = (pp != null && pp.getKey() > 0);
//
if (invoiceField != null)
invoiceField.setReadWrite(!valid);
if (projectField != null)
projectField.setReadWrite(!valid);
} else // Invoice
if (source == invoiceField) {
KeyNamePair pp = (KeyNamePair) invoiceField.getSelectedItem();
boolean valid = (pp != null && pp.getKey() > 0);
//
if (orderField != null)
orderField.setReadWrite(!valid);
if (projectField != null)
projectField.setReadWrite(!valid);
} else // Project
if (source == projectField) {
KeyNamePair pp = (KeyNamePair) projectField.getSelectedItem();
boolean valid = (pp != null && pp.getKey() > 0);
//
if (orderField != null)
orderField.setReadWrite(!valid);
if (invoiceField != null)
invoiceField.setReadWrite(!valid);
} else // OK
if (e.getActionCommand().equals(ConfirmPanel.A_OK)) {
if (cmd_save())
dispose();
} else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL))
dispose();
// Enable OK
boolean OK = m_product != null;
if (OK) {
KeyNamePair pp = null;
if (orderField != null)
pp = (KeyNamePair) orderField.getSelectedItem();
if ((pp == null || pp.getKey() <= 0) && invoiceField != null)
pp = (KeyNamePair) invoiceField.getSelectedItem();
if ((pp == null || pp.getKey() <= 0) && projectField != null)
pp = (KeyNamePair) projectField.getSelectedItem();
OK = (pp != null && pp.getKey() > 0);
}
confirmPanel.getOKButton().setEnabled(OK);
}
Aggregations