OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 87 Rev 140
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.JScrollPane;
-
 
9
import javax.swing.JTextArea;
-
 
10
 
8
 
11
import org.openconcerto.sql.element.GroupSQLComponent;
9
import org.openconcerto.sql.element.GroupSQLComponent;
12
import org.openconcerto.sql.element.SQLElement;
10
import org.openconcerto.sql.element.SQLElement;
-
 
11
import org.openconcerto.sql.model.SQLBackgroundTableCache;
-
 
12
import org.openconcerto.sql.model.SQLRow;
-
 
13
import org.openconcerto.sql.model.SQLRowValues;
-
 
14
import org.openconcerto.sql.model.SQLTable;
13
import org.openconcerto.sql.sqlobject.SQLSearchableTextCombo;
15
import org.openconcerto.sql.sqlobject.SQLSearchableTextCombo;
-
 
16
import org.openconcerto.sql.users.UserManager;
14
import org.openconcerto.ui.JDate;
17
import org.openconcerto.ui.JDate;
-
 
18
import org.openconcerto.ui.JLabelBold;
15
import org.openconcerto.ui.component.ComboLockedMode;
19
import org.openconcerto.ui.component.ComboLockedMode;
-
 
20
import org.openconcerto.ui.component.ITextArea;
16
import org.openconcerto.ui.group.Group;
21
import org.openconcerto.ui.group.Group;
17
 
22
 
18
public class LeadSQLComponent extends GroupSQLComponent {
23
public class LeadSQLComponent extends GroupSQLComponent {
19
    public LeadSQLComponent(SQLElement element, Group group) {
24
    public LeadSQLComponent(SQLElement element, Group group) {
20
        super(element, group);
25
        super(element, group);
Line 22... Line 27...
22
 
27
 
23
    @Override
28
    @Override
24
    protected Set<String> createRequiredNames() {
29
    protected Set<String> createRequiredNames() {
25
        final Set<String> s = new HashSet<String>(1);
30
        final Set<String> s = new HashSet<String>(1);
26
        s.add("ID_ADRESSE");
31
        s.add("ID_ADRESSE");
-
 
32
        s.add("NOM");
27
        return s;
33
        return s;
28
    }
34
    }
29
 
35
 
30
    @Override
36
    @Override
-
 
37
    public JComponent getLabel(String id) {
-
 
38
        if (id.equals("customerrelationship.lead.person")) {
-
 
39
            return new JLabelBold("Contact");
-
 
40
        } else if (id.equals("customerrelationship.lead.contact")) {
-
 
41
            return new JLabel();
-
 
42
        } else if (id.equals("customerrelationship.lead.address")) {
-
 
43
            return new JLabelBold("Adresse");
-
 
44
        } else {
-
 
45
            return super.getLabel(id);
-
 
46
        }
-
 
47
    }
-
 
48
 
-
 
49
    @Override
31
    public JComponent createEditor(String id) {
50
    public JComponent createEditor(String id) {
-
 
51
 
32
        if (id.equals("INFORMATION")) {
52
        if (id.equals("INFORMATION") || id.equals("INFOS")) {
33
            final JTextArea jTextArea = new JTextArea();
53
            final ITextArea jTextArea = new ITextArea();
34
            jTextArea.setFont(new JLabel().getFont());
54
            jTextArea.setFont(new JLabel().getFont());
35
            return new JScrollPane(jTextArea);
55
            return jTextArea;
36
        } else if (id.equals("INDUSTRY") || id.equals("STATUS") || id.equals("RATING") || id.equals("SOURCE")) {
56
        } else if (id.equals("INDUSTRY") || id.equals("STATUS") || id.equals("RATING") || id.equals("SOURCE") || id.equals("DISPO")) {
37
            return new SQLSearchableTextCombo(ComboLockedMode.UNLOCKED, 1, 20, false);
57
            return new SQLSearchableTextCombo(ComboLockedMode.UNLOCKED, 1, 20, false);
38
        } else if (id.equals("DATE")) {
58
        } else if (id.equals("DATE")) {
39
            return new JDate(true);
59
            return new JDate(true);
40
        }
60
        }
41
        return super.createEditor(id);
61
        return super.createEditor(id);
42
    }
62
    }
-
 
63
 
-
 
64
    @Override
-
 
65
    protected SQLRowValues createDefaults() {
-
 
66
        SQLRowValues rowVals = new SQLRowValues(getTable());
-
 
67
        rowVals.put("STATUS", "Nouveau");
-
 
68
 
-
 
69
        final int idUser = UserManager.getInstance().getCurrentUser().getId();
-
 
70
        final SQLTable foreignTableComm = getTable().getForeignTable("ID_COMMERCIAL");
-
 
71
        SQLRow rowsComm = SQLBackgroundTableCache.getInstance().getCacheForTable(foreignTableComm).getFirstRowContains(idUser, foreignTableComm.getField("ID_USER_COMMON"));
-
 
72
 
-
 
73
        if (rowsComm != null) {
-
 
74
            rowVals.put("ID_COMMERCIAL", rowsComm.getID());
-
 
75
        }
-
 
76
        return rowVals;
-
 
77
    }
43
}
78
}