public Object getValue(SpreadSheetCellValueContext context) { SQLRowAccessor row = context.getRow(); BigDecimal percent = row.getBigDecimal("POURCENT_FACTURABLE"); BigDecimal amount = row.getBigDecimal("MONTANT_FACTURABLE"); Acompte a = new Acompte(percent, amount); return a.toPlainString(); }
@Override public JComponent getRenderer(final SQLRowAccessor row, int maxWidth) { final JPanel p = new JPanel(); p.setLayout(new VFlowLayout(VFlowLayout.TOP, 2, 2, true)); p.setBorder(BorderFactory.createLineBorder(new Color(206, 226, 255))); final String number = row.getForeign("ID_COMMANDE_CLIENT").getString("NUMERO"); final String customer = row.getForeign("ID_COMMANDE_CLIENT").getForeign("ID_CLIENT").getString("NOM"); // Amount final long amount = row.getBigDecimal("T_PV_HT") .setScale(2, BigDecimal.ROUND_HALF_UP) .movePointRight(2) .longValue(); String total = GestionDevise.currencyToString(amount, true) + " € HT"; final long totalAmount = row.getForeign("ID_COMMANDE_CLIENT").getLong("T_HT"); if (totalAmount != amount) { total += ", commande de " + GestionDevise.currencyToString(totalAmount, true) + " € HT"; } // Hours int h = getHours(row); p.add(new JLabelBold(number + " " + customer)); p.add(new JLabel(total)); if (h > 0) { p.add(new JLabel(h + " heures prévues")); } if (row.getTable().getDBRoot().contains("AFFAIRE_TEMPS")) { // Time spend double time = getTimeSpent(row); final JLabel lTime = new JLabel(time + " heures passées"); if (time > h) { lTime.setFont(lTime.getFont().deriveFont(Font.BOLD)); lTime.setForeground(new Color(255, 135, 30)); } if (time > 0) { p.add(lTime); } } p.setBackground(new Color(239, 243, 248)); p.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) { final SQLRowAccessor foreign = row.getForeign("ID_COMMANDE_CLIENT"); EditFrame frame = new EditFrame( ComptaPropsConfiguration.getInstanceCompta() .getDirectory() .getElement(foreign.getTable()), EditPanel.MODIFICATION); frame.selectionId(foreign.getID()); FrameUtil.showPacked(frame); } } }); return p; }