Dépôt officiel du code source de l'ERP OpenConcerto
Blame | Last modification | View Log | RSS feed
package org.openconcerto.modules.customersupport;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
import org.openconcerto.erp.core.edm.AttachmentPanel;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.ui.PanelFrame;
import org.openconcerto.ui.component.ITextArea;
public class HistoryPanel extends JPanel {
HistoryPanel(final SQLRowAccessor sqlRowAccessor, final SuiviTicketPanel panelSource) {
final SQLRowAccessor foreignUser = sqlRowAccessor.getForeign("ID_USER_COMMON");
final Date date = sqlRowAccessor.getDate("DATE") == null ? new Date() : sqlRowAccessor.getDate("DATE").getTime();
String user = foreignUser.getString("PRENOM") + " " + foreignUser.getString("NOM");
String info = sqlRowAccessor.getString("INFORMATION");
this.setOpaque(true);
this.setBackground(Color.WHITE);
this.setLayout(new GridBagLayout());
this.setBorder(BorderFactory.createLineBorder(Color.GRAY));
final GridBagConstraints c = new DefaultGridBagConstraints();
final DateFormat format = new SimpleDateFormat("dd/MM/yy HH:mm");
JLabel l1 = new JLabelBold("Le " + format.format(date) + ", créé par " + user);
this.add(l1, c);
String files = "Fichiers liés";
if (sqlRowAccessor.getInt("ATTACHMENTS") > 0) {
files += " (" + sqlRowAccessor.getInt("ATTACHMENTS") + ")";
}
final JButton button = new JButton(files);
button.setOpaque(false);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
AttachmentPanel panel = new AttachmentPanel(sqlRowAccessor);
panel.addListener(new ListDataListener() {
@Override
public void intervalRemoved(ListDataEvent e) {
panelSource.fillPanelHistory();
}
@Override
public void intervalAdded(ListDataEvent e) {
panelSource.fillPanelHistory();
}
@Override
public void contentsChanged(ListDataEvent e) {
panelSource.fillPanelHistory();
}
});
PanelFrame frame = new PanelFrame(panel, "Liste des fichiers liés");
FrameUtil.show(frame);
}
});
c.gridx++;
c.anchor = GridBagConstraints.EAST;
this.add(button, c);
c.gridy++;
c.gridx = 0;
ITextArea text = new ITextArea(3, 50);
text.setEditable(false);
text.setEnabled(false);
text.setBorder(null);
text.setDisabledTextColor(Color.BLACK);
text.setText(info);
c.weightx = 1;
this.add(text, c);
}
}