Dépôt officiel du code source de l'ERP OpenConcerto
Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package org.openconcerto.modules.customersupport;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import org.openconcerto.erp.core.edm.AttachmentAction;
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ModuleElement;
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.ui.JDateTime;
public class CustomerTicketHistorySQLElement extends ModuleElement {
public CustomerTicketHistorySQLElement(AbstractModule module) {
super(module, Module.TABLE_CUSTOMER_SUPPORT_TICKET_HISTORY);
this.setL18nLocation(CustomerTicketHistorySQLElement.class);
PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction().getAction(), true);
actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(actionAttachment);
}
@Override
protected String createCode() {
return "customersupport.ticket.history";
}
@Override
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_USER_COMMON");
l.add("DATE");
l.add("ID_" + Module.TABLE_CUSTOMER_SUPPORT_TICKET);
l.add("INFORMATION");
return l;
}
@Override
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("INFORMATION");
return l;
}
@Override
protected String getParentFFName() {
return "ID_" + Module.TABLE_CUSTOMER_SUPPORT_TICKET;
}
@Override
public SQLComponent createComponent() {
return new GroupSQLComponent(this, new CustomerTicketSupportHistoryGroup()) {
@Override
protected Set<String> createRequiredNames() {
final Set<String> s = new HashSet<String>(1);
s.add("ID_USER_COMMON");
s.add("DATE");
return s;
}
// @Override
// public JComponent getLabel(String id) {
// if (id.equals("customerrelationship.lead.call.content")) {
// return new JLabelBold("Description de l'appel téléphonique");
// } else if (id.equals("customerrelationship.lead.call.next")) {
// return new JLabelBold("Suite à donner");
// }
// return super.getLabel(id);
// }
@Override
public JComponent createEditor(String id) {
if (id.equals("INFORMATION")) {
final JTextArea jTextArea = new JTextArea();
jTextArea.setFont(new JLabel().getFont());
jTextArea.setMinimumSize(new Dimension(200, 150));
jTextArea.setPreferredSize(new Dimension(200, 150));
return new JScrollPane(jTextArea);
} else if (id.equals("DATE")) {
return new JDateTime(true);
}
return super.createEditor(id);
}
@Override
protected SQLRowValues createDefaults() {
SQLRowValues rowVals = new SQLRowValues(getTable());
final int idUser = UserManager.getInstance().getCurrentUser().getId();
rowVals.put("ID_USER_COMMON", idUser);
return rowVals;
}
};
}
}