Dépôt officiel du code source de l'ERP OpenConcerto
Rev 144 | Rev 180 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.customerrelationship.customer.element;
import org.openconcerto.erp.core.edm.AttachmentAction;
import org.openconcerto.erp.core.reports.history.ui.HistoriqueClientFrame;
import org.openconcerto.sql.element.GlobalMapper;
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.request.SQLFieldTranslator;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.ui.light.LightUIElement;
import org.openconcerto.ui.light.LightUILine;
import org.openconcerto.ui.light.LightUIPanel;
import org.openconcerto.ui.light.SimpleTextLine;
import java.awt.event.ActionEvent;
import java.util.List;
import javax.swing.AbstractAction;
public class CustomerSQLElement extends ClientNormalSQLElement {
public CustomerSQLElement() {
super();
final CustomerGroup group = new CustomerGroup();
GlobalMapper.getInstance().map(CustomerGroup.ID, group);
setDefaultGroup(group);
PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction().getAction(), true);
actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(actionAttachment);
PredicateRowAction actionHistory = new PredicateRowAction(new AbstractAction("Historique client") {
@Override
public void actionPerformed(ActionEvent e) {
HistoriqueClientFrame histoFrame = new HistoriqueClientFrame();
int idClient = IListe.get(e).getSelectedId();
histoFrame.selectId(idClient);
histoFrame.setVisible(true);
}
}, true);
actionHistory.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(actionHistory);
}
@Override
public SQLComponent createComponent() {
final GroupSQLComponent c = new CustomerSQLComponent(this);
c.startTabGroupAfter("customerrelationship.customer.identifier");
return c;
}
@Override
protected List<String> getListFields() {
final List<String> fields = super.getListFields();
if (getTable().contains("GROUPE")) {
fields.add("GROUPE");
}
fields.add("SOLDE_COMPTE");
fields.add("REMIND_DATE");
fields.add("OBSOLETE");
return fields;
}
@Override
protected void fillDataPanel(final String sessionToken, final List<SQLRowAccessor> selection, final LightUIPanel dataPanel) {
final SQLFieldTranslator translator = this.getDirectory().getTranslator();
final SQLRowAccessor sqlRow = selection.get(0);
final int rowId = sqlRow.getID();
final LightUILine mainLine = new LightUILine();
final LightUIPanel mainLinePanel = new LightUIPanel(dataPanel.getId() + ".main.line." + rowId);
mainLinePanel.setWeightX(1);
final SimpleTextLine spacer = new SimpleTextLine("", true, LightUIElement.HALIGN_LEFT, 2);
spacer.setMarginBottom(4);
String name = sqlRow.getString("NOM");
mainLinePanel.addChild(new SimpleTextLine(name, true, LightUIElement.HALIGN_LEFT));
final SimpleTextLine titleSituationContact = new SimpleTextLine("Coordonnées du client", true, LightUIElement.HALIGN_LEFT, 2);
titleSituationContact.setMarginTop(10);
mainLinePanel.addChild(titleSituationContact);
addFieldToPanel("TEL", mainLinePanel, sqlRow, translator, true, "non renseigné");
addFieldToPanel("MAIL", mainLinePanel, sqlRow, translator, true, "non renseigné");
mainLine.addChild(mainLinePanel);
dataPanel.addChild(mainLine);
}
}