OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 140 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 140 Rev 181
Line 3... Line 3...
3
import java.util.HashSet;
3
import java.util.HashSet;
4
import java.util.Set;
4
import java.util.Set;
5
 
5
 
6
import javax.swing.JComponent;
6
import javax.swing.JComponent;
7
import javax.swing.JLabel;
7
import javax.swing.JLabel;
-
 
8
import javax.swing.JTextField;
8
 
9
 
-
 
10
import org.openconcerto.modules.customerrelationship.lead.visit.LeadActionItemTable;
9
import org.openconcerto.sql.element.GroupSQLComponent;
11
import org.openconcerto.sql.element.GroupSQLComponent;
10
import org.openconcerto.sql.element.SQLElement;
12
import org.openconcerto.sql.element.SQLElement;
11
import org.openconcerto.sql.model.SQLBackgroundTableCache;
13
import org.openconcerto.sql.model.SQLBackgroundTableCache;
12
import org.openconcerto.sql.model.SQLRow;
14
import org.openconcerto.sql.model.SQLRow;
-
 
15
import org.openconcerto.sql.model.SQLRowAccessor;
13
import org.openconcerto.sql.model.SQLRowValues;
16
import org.openconcerto.sql.model.SQLRowValues;
14
import org.openconcerto.sql.model.SQLTable;
17
import org.openconcerto.sql.model.SQLTable;
-
 
18
import org.openconcerto.sql.sqlobject.ElementComboBox;
15
import org.openconcerto.sql.sqlobject.SQLSearchableTextCombo;
19
import org.openconcerto.sql.sqlobject.SQLSearchableTextCombo;
16
import org.openconcerto.sql.users.UserManager;
20
import org.openconcerto.sql.users.UserManager;
17
import org.openconcerto.ui.JDate;
21
import org.openconcerto.ui.JDate;
18
import org.openconcerto.ui.JLabelBold;
22
import org.openconcerto.ui.JLabelBold;
19
import org.openconcerto.ui.component.ComboLockedMode;
23
import org.openconcerto.ui.component.ComboLockedMode;
20
import org.openconcerto.ui.component.ITextArea;
24
import org.openconcerto.ui.component.ITextArea;
21
import org.openconcerto.ui.group.Group;
25
import org.openconcerto.ui.group.Group;
22
 
26
 
23
public class LeadSQLComponent extends GroupSQLComponent {
27
public class LeadSQLComponent extends GroupSQLComponent {
-
 
28
 
-
 
29
    private LeadActionItemTable tableCall, tableVisit;
-
 
30
 
24
    public LeadSQLComponent(SQLElement element, Group group) {
31
    public LeadSQLComponent(SQLElement element, Group group) {
25
        super(element, group);
32
        super(element, group);
-
 
33
        startTabGroupAfter("customerrelationship.lead.state");
26
    }
34
    }
27
 
35
 
28
    @Override
36
    @Override
29
    protected Set<String> createRequiredNames() {
37
    protected Set<String> createRequiredNames() {
30
        final Set<String> s = new HashSet<String>(1);
38
        final Set<String> s = new HashSet<String>(1);
Line 35... Line 43...
35
 
43
 
36
    @Override
44
    @Override
37
    public JComponent getLabel(String id) {
45
    public JComponent getLabel(String id) {
38
        if (id.equals("customerrelationship.lead.person")) {
46
        if (id.equals("customerrelationship.lead.person")) {
39
            return new JLabelBold("Contact");
47
            return new JLabelBold("Contact");
-
 
48
        }
-
 
49
        if (id.equals("customerrelationship.lead.items.visit.tab")) {
-
 
50
            return new JLabelBold("Visites");
-
 
51
        }
-
 
52
        if (id.equals("customerrelationship.lead.items.visit")) {
-
 
53
            return new JLabelBold("");
-
 
54
        }
-
 
55
        if (id.equals("customerrelationship.lead.items.call.tab")) {
-
 
56
            return new JLabelBold("Appels");
-
 
57
        }
-
 
58
        if (id.equals("customerrelationship.lead.items.call")) {
-
 
59
            return new JLabelBold("");
40
        } else if (id.equals("customerrelationship.lead.contact")) {
60
        } else if (id.equals("customerrelationship.lead.contact")) {
41
            return new JLabel();
61
            return new JLabel();
42
        } else if (id.equals("customerrelationship.lead.address")) {
62
        } else if (id.equals("customerrelationship.lead.address")) {
43
            return new JLabelBold("Adresse");
63
            return new JLabelBold("Adresse");
-
 
64
        } else if (id.equals("customerrelationship.lead.info")) {
-
 
65
            return new JLabelBold("Infos");
-
 
66
        } else if (id.equals("customerrelationship.lead.state")) {
-
 
67
            return new JLabelBold("Statut");
44
        } else {
68
        } else {
45
            return super.getLabel(id);
69
            return super.getLabel(id);
46
        }
70
        }
47
    }
71
    }
48
 
72
 
49
    @Override
73
    @Override
50
    public JComponent createEditor(String id) {
74
    public JComponent createEditor(String id) {
51
 
-
 
52
        if (id.equals("INFORMATION") || id.equals("INFOS")) {
75
        if (id.equals("INFORMATION") || id.equals("INFOS")) {
53
            final ITextArea jTextArea = new ITextArea();
76
            final ITextArea jTextArea = new ITextArea(3,3);
54
            jTextArea.setFont(new JLabel().getFont());
77
            jTextArea.setFont(new JLabel().getFont());
55
            return jTextArea;
78
            return jTextArea;
-
 
79
        } else if (id.equals("ID_COMMERCIAL") || id.equals("ID_TITRE_PERSONNEL")) {
-
 
80
            ElementComboBox comp = new ElementComboBox(false, 1);
-
 
81
            ((ElementComboBox) comp).init(getElement().getForeignElement(id));
-
 
82
            return comp;
-
 
83
        } else if (id.equals("customerrelationship.lead.items.call")) {
-
 
84
            tableCall = new LeadActionItemTable(getElement().getDirectory().getElement(Module.TABLE_LEAD_CALL));
-
 
85
            return tableCall;
-
 
86
        } else if (id.equals("customerrelationship.lead.items.visit")) {
-
 
87
            tableVisit = new LeadActionItemTable(getElement().getDirectory().getElement(Module.TABLE_LEAD_VISIT));
-
 
88
            return tableVisit;
56
        } else if (id.equals("INDUSTRY") || id.equals("STATUS") || id.equals("RATING") || id.equals("SOURCE") || id.equals("DISPO")) {
89
        } else if (id.equals("INDUSTRY") || id.equals("STATUS") || id.equals("RATING") || id.equals("SOURCE") || id.equals("DISPO")) {
57
            return new SQLSearchableTextCombo(ComboLockedMode.UNLOCKED, 1, 20, false);
90
            return new SQLSearchableTextCombo(ComboLockedMode.UNLOCKED, 1, 1, false);
58
        } else if (id.equals("DATE")) {
91
        } else if (id.equals("DATE")) {
59
            return new JDate(true);
92
            return new JDate(true);
60
        }
93
        }
-
 
94
        
61
        return super.createEditor(id);
95
        JComponent comp = super.createEditor(id);
-
 
96
        
-
 
97
        if(comp.getClass() == JTextField.class) {
-
 
98
        	JTextField jtxt = new JTextField(10);
-
 
99
        	comp = jtxt;
-
 
100
        }
-
 
101
        
-
 
102
        return comp;
-
 
103
    }
-
 
104
 
-
 
105
    @Override
-
 
106
    public int insert(SQLRow order) {
-
 
107
        int id = super.insert(order);
-
 
108
        this.tableCall.updateField("ID_LEAD", id);
-
 
109
        this.tableVisit.updateField("ID_LEAD", id);
-
 
110
        return id;
-
 
111
    }
-
 
112
 
-
 
113
    @Override
-
 
114
    public void select(SQLRowAccessor r) {
-
 
115
        super.select(r);
-
 
116
        if (r != null) {
-
 
117
            this.tableCall.insertFrom("ID_LEAD", r.getID());
-
 
118
            this.tableVisit.insertFrom("ID_LEAD", r.getID());
-
 
119
        }
-
 
120
    }
-
 
121
 
-
 
122
    @Override
-
 
123
    public void update() {
-
 
124
        super.update();
-
 
125
        this.tableCall.updateField("ID_LEAD", getSelectedID());
-
 
126
        this.tableVisit.updateField("ID_LEAD", getSelectedID());
62
    }
127
    }
63
 
128
 
64
    @Override
129
    @Override
65
    protected SQLRowValues createDefaults() {
130
    protected SQLRowValues createDefaults() {
66
        SQLRowValues rowVals = new SQLRowValues(getTable());
131
        SQLRowValues rowVals = new SQLRowValues(getTable());